[mapguide-commits] r5139 - in trunk/MgDev: Common/MapGuideCommon/MapLayer Common/MdfModel Common/MdfParser Common/PlatformBase Common/PlatformBase/Exception Common/PlatformBase/MapLayer Common/PlatformBase/Services Common/Renderers Common/Schema Common/Stylization Server/src/Services/Rendering Web/src/HttpHandler

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Fri Sep 17 04:00:59 EDT 2010


Author: liuar
Date: 2010-09-17 08:00:59 +0000 (Fri, 17 Sep 2010)
New Revision: 5139

Added:
   trunk/MgDev/Common/MdfModel/TileWatermarkPosition.cpp
   trunk/MgDev/Common/MdfModel/TileWatermarkPosition.h
   trunk/MgDev/Common/MdfModel/WatermarkAppearance.cpp
   trunk/MgDev/Common/MdfModel/WatermarkAppearance.h
   trunk/MgDev/Common/MdfModel/WatermarkDefinition.cpp
   trunk/MgDev/Common/MdfModel/WatermarkDefinition.h
   trunk/MgDev/Common/MdfModel/WatermarkInstance.cpp
   trunk/MgDev/Common/MdfModel/WatermarkInstance.h
   trunk/MgDev/Common/MdfModel/WatermarkOffsetUnit.h
   trunk/MgDev/Common/MdfModel/WatermarkPosition.cpp
   trunk/MgDev/Common/MdfModel/WatermarkPosition.h
   trunk/MgDev/Common/MdfModel/WatermarkXOffset.cpp
   trunk/MgDev/Common/MdfModel/WatermarkXOffset.h
   trunk/MgDev/Common/MdfModel/WatermarkYOffset.cpp
   trunk/MgDev/Common/MdfModel/WatermarkYOffset.h
   trunk/MgDev/Common/MdfModel/XYWatermarkPosition.cpp
   trunk/MgDev/Common/MdfModel/XYWatermarkPosition.h
   trunk/MgDev/Common/MdfParser/IOTileWatermarkPosition.cpp
   trunk/MgDev/Common/MdfParser/IOTileWatermarkPosition.h
   trunk/MgDev/Common/MdfParser/IOWatermarkAppearance.cpp
   trunk/MgDev/Common/MdfParser/IOWatermarkAppearance.h
   trunk/MgDev/Common/MdfParser/IOWatermarkDefinition.cpp
   trunk/MgDev/Common/MdfParser/IOWatermarkDefinition.h
   trunk/MgDev/Common/MdfParser/IOWatermarkInstance.cpp
   trunk/MgDev/Common/MdfParser/IOWatermarkInstance.h
   trunk/MgDev/Common/MdfParser/IOWatermarkOffsetUnit.cpp
   trunk/MgDev/Common/MdfParser/IOWatermarkOffsetUnit.h
   trunk/MgDev/Common/MdfParser/IOWatermarkXOffset.cpp
   trunk/MgDev/Common/MdfParser/IOWatermarkXOffset.h
   trunk/MgDev/Common/MdfParser/IOWatermarkYOffset.cpp
   trunk/MgDev/Common/MdfParser/IOWatermarkYOffset.h
   trunk/MgDev/Common/MdfParser/IOXYWatermarkPosition.cpp
   trunk/MgDev/Common/MdfParser/IOXYWatermarkPosition.h
   trunk/MgDev/Common/PlatformBase/Exception/InvalidWatermarkDefinitionException.cpp
   trunk/MgDev/Common/PlatformBase/Exception/InvalidWatermarkDefinitionException.h
   trunk/MgDev/Common/PlatformBase/MapLayer/Watermark.cpp
   trunk/MgDev/Common/PlatformBase/MapLayer/Watermark.h
   trunk/MgDev/Common/Renderers/RenderUtil.cpp
   trunk/MgDev/Common/Renderers/RenderUtil.h
   trunk/MgDev/Common/Schema/LayerDefinition-1.4.0.xsd
   trunk/MgDev/Common/Schema/MapDefinition-1.1.0.xsd
   trunk/MgDev/Common/Schema/WatermarkDefinition-1.0.0.xsd
Modified:
   trunk/MgDev/Common/MapGuideCommon/MapLayer/Map.cpp
   trunk/MgDev/Common/MapGuideCommon/MapLayer/Map.h
   trunk/MgDev/Common/MdfModel/LayerDefinition.cpp
   trunk/MgDev/Common/MdfModel/LayerDefinition.h
   trunk/MgDev/Common/MdfModel/MapDefinition.cpp
   trunk/MgDev/Common/MdfModel/MapDefinition.h
   trunk/MgDev/Common/MdfModel/MdfModel.vcproj
   trunk/MgDev/Common/MdfParser/IODrawingLayerDefinition.cpp
   trunk/MgDev/Common/MdfParser/IODrawingLayerDefinition.h
   trunk/MgDev/Common/MdfParser/IOGridLayerDefinition.cpp
   trunk/MgDev/Common/MdfParser/IOGridLayerDefinition.h
   trunk/MgDev/Common/MdfParser/IOMapDefinition.cpp
   trunk/MgDev/Common/MdfParser/IOMapDefinition.h
   trunk/MgDev/Common/MdfParser/IOVectorLayerDefinition.cpp
   trunk/MgDev/Common/MdfParser/IOVectorLayerDefinition.h
   trunk/MgDev/Common/MdfParser/MdfParser.vcproj
   trunk/MgDev/Common/MdfParser/SAX2Parser.cpp
   trunk/MgDev/Common/MdfParser/SAX2Parser.h
   trunk/MgDev/Common/PlatformBase/MapLayer/MapBase.cpp
   trunk/MgDev/Common/PlatformBase/MapLayer/MapBase.h
   trunk/MgDev/Common/PlatformBase/PlatformBase.h
   trunk/MgDev/Common/PlatformBase/PlatformBase.vcproj
   trunk/MgDev/Common/PlatformBase/PlatformBaseBuild.cpp
   trunk/MgDev/Common/PlatformBase/Services/PlatformBaseClassId.h
   trunk/MgDev/Common/PlatformBase/Services/ResourceDefs.cpp
   trunk/MgDev/Common/PlatformBase/Services/ResourceDefs.h
   trunk/MgDev/Common/Renderers/AGGImageIO.h
   trunk/MgDev/Common/Renderers/AGGRenderer.cpp
   trunk/MgDev/Common/Renderers/AGGRenderer.h
   trunk/MgDev/Common/Renderers/DWFRenderer.cpp
   trunk/MgDev/Common/Renderers/DWFRenderer.h
   trunk/MgDev/Common/Renderers/GDRenderer.cpp
   trunk/MgDev/Common/Renderers/GDRenderer.h
   trunk/MgDev/Common/Renderers/KmlRenderer.cpp
   trunk/MgDev/Common/Renderers/KmlRenderer.h
   trunk/MgDev/Common/Renderers/Renderers.vcproj
   trunk/MgDev/Common/Stylization/DefaultStylizer.cpp
   trunk/MgDev/Common/Stylization/DefaultStylizer.h
   trunk/MgDev/Common/Stylization/SE_RenderProxies.h
   trunk/MgDev/Common/Stylization/SE_Renderer.cpp
   trunk/MgDev/Common/Stylization/SE_Renderer.h
   trunk/MgDev/Common/Stylization/SE_SymbolDefProxies.cpp
   trunk/MgDev/Common/Stylization/SE_SymbolDefProxies.h
   trunk/MgDev/Common/Stylization/Stylization.h
   trunk/MgDev/Common/Stylization/StylizationEngine.cpp
   trunk/MgDev/Common/Stylization/StylizationEngine.h
   trunk/MgDev/Common/Stylization/Stylizer.h
   trunk/MgDev/Server/src/Services/Rendering/FeatureInfoRenderer.cpp
   trunk/MgDev/Server/src/Services/Rendering/FeatureInfoRenderer.h
   trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp
   trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.h
   trunk/MgDev/Web/src/HttpHandler/HttpWmsGetMap.cpp
Log:
Watermark Implementation

Modified: trunk/MgDev/Common/MapGuideCommon/MapLayer/Map.cpp
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/MapLayer/Map.cpp	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/MapGuideCommon/MapLayer/Map.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -35,7 +35,8 @@
     : MgMapBase(),
     m_inSave(false),
     m_unpackedLayersGroups(false),
-    m_colorPalette(NULL)        // lazy instantiation
+    m_colorPalette(NULL),        // lazy instantiation
+    m_watermarkUsage(Viewer)
 {
 }
 
@@ -47,7 +48,8 @@
     : MgMapBase(),
     m_inSave(false),
     m_unpackedLayersGroups(false),
-    m_colorPalette(NULL)        // lazy instantiation
+    m_colorPalette(NULL),        // lazy instantiation
+    m_watermarkUsage(Viewer)
 {
     if (NULL == siteConnection)
     {
@@ -891,6 +893,9 @@
         }
     }
 
+    //watermark usage
+    stream->WriteInt32(m_watermarkUsage);
+
     // Serialize Layers and Groups as a blob.
     if (m_inSave)
     {
@@ -1009,6 +1014,9 @@
 
     m_changeLists->SetCheckForDuplicates(true);
 
+    //watermark usage
+    streamReader->GetInt32(m_watermarkUsage);
+
     //blob for layers and groups
     INT32 nBytes = 0;
     streamReader->GetInt32(nBytes);
@@ -1151,3 +1159,13 @@
         }
     }
 }
+
+INT32 MgMap::GetWatermarkUsage()
+{
+    return m_watermarkUsage;
+}
+
+void MgMap::SetWatermarkUsage(INT32 watermarkUsage)
+{
+    m_watermarkUsage = watermarkUsage;
+}

Modified: trunk/MgDev/Common/MapGuideCommon/MapLayer/Map.h
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/MapLayer/Map.h	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/MapGuideCommon/MapLayer/Map.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -224,6 +224,20 @@
 
 PUBLISHED_API:
 
+    /////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Watermark usage environment.
+    /// \n
+    /// \c WMS - Usage WMS watermark.
+    /// \n
+    /// \c Viewer - Use Viewer watermark.
+    ///
+    enum
+    {
+        WMS = 1,
+        Viewer = 2
+    };
+
     //////////////////////////////////////////////////////////////////
     /// \brief
     /// Constructs an empty un-initialized MgMap object.
@@ -518,6 +532,15 @@
     ///
     void Save();
 
+    /////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Get the watermark usage
+    ///
+    /// \return
+    /// The integer value
+    ///
+    INT32 GetWatermarkUsage();
+
 INTERNAL_API:
 
     /// \brief
@@ -582,6 +605,14 @@
     ///
     void BulkLoadIdentityProperties(MgFeatureService* featureService);
 
+    /// \brief
+    /// Sets the watermark usage
+    ///
+    /// \param dpi
+    /// Watermark usage
+    ///
+    virtual void SetWatermarkUsage(INT32 watermarkUsage);
+
 protected:
 
     //////////////////////////////////////////////////////////////////
@@ -635,6 +666,8 @@
     bool m_inSave;
     bool m_unpackedLayersGroups;
     ColorStringList* m_colorPalette;
+
+    INT32 m_watermarkUsage;
 };
 /// \}
 

Modified: trunk/MgDev/Common/MdfModel/LayerDefinition.cpp
===================================================================
--- trunk/MgDev/Common/MdfModel/LayerDefinition.cpp	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/MdfModel/LayerDefinition.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -99,3 +99,13 @@
 {
     this->m_opacity = opacity;
 }
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for a list of WatermarkInstance objects that represent
+//          the Watermarks property.
+// RETURNS: A pointer to a modifiable WatermarkInstanceCollection.
+//-------------------------------------------------------------------------
+WatermarkInstanceCollection* LayerDefinition::GetWatermarks()
+{
+    return &this->m_listWatermarks;
+}

Modified: trunk/MgDev/Common/MdfModel/LayerDefinition.h
===================================================================
--- trunk/MgDev/Common/MdfModel/LayerDefinition.h	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/MdfModel/LayerDefinition.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -20,6 +20,7 @@
 
 #include "MdfModel.h"
 #include "MdfRootObject.h"
+#include "WatermarkInstance.h"
 
 BEGIN_NAMESPACE_MDFMODEL
 
@@ -48,6 +49,10 @@
         const double GetOpacity() const;
         void SetOpacity(const double opacity);
 
+        // Property : Watermarks
+        // The List of watermark instance in this layer.
+        WatermarkInstanceCollection* GetWatermarks();
+
     private:
         // Data members
         // The ID of the DataSource used by this layer
@@ -58,6 +63,8 @@
 
         // The opacity value
         double m_opacity;
+
+        WatermarkInstanceCollection m_listWatermarks;
     };
 
 END_NAMESPACE_MDFMODEL

Modified: trunk/MgDev/Common/MdfModel/MapDefinition.cpp
===================================================================
--- trunk/MgDev/Common/MdfModel/MapDefinition.cpp	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/MdfModel/MapDefinition.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -190,6 +190,16 @@
 }
 
 //-------------------------------------------------------------------------
+// PURPOSE: Accessor method for a list of WatermarkInstance objects that represent
+//          the Watermarks property.
+// RETURNS: A pointer to a modifiable WatermarkInstanceCollection.
+//-------------------------------------------------------------------------
+WatermarkInstanceCollection* MapDefinition::GetWatermarks()
+{
+    return &this->m_listWatermarks;
+}
+
+//-------------------------------------------------------------------------
 // PURPOSE: Accessor method for a collection of doubles that
 //          represent the scales that the base map tiles can be displayed at.
 // RETURNS: A pointer to a modifiable LayerGroupCollection.

Modified: trunk/MgDev/Common/MdfModel/MapDefinition.h
===================================================================
--- trunk/MgDev/Common/MdfModel/MapDefinition.h	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/MdfModel/MapDefinition.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -23,6 +23,7 @@
 #include "MapLayer.h"
 #include "MapLayerGroup.h"
 #include "BaseMapLayerGroup.h"
+#include "WatermarkInstance.h"
 #include "DisplayScale.h"
 
 BEGIN_NAMESPACE_MDFMODEL
@@ -73,6 +74,10 @@
         // The collection of LayerGroups.
         MapLayerGroupCollection* GetLayerGroups();
 
+        // Property : MapWatermarks
+        // The List of watermark instances.
+        WatermarkInstanceCollection* GetWatermarks();
+
         // Property : FiniteDisplayScales
         // The scales that the base map tiles can be displayed at
         DisplayScaleCollection* GetFiniteDisplayScales();
@@ -98,6 +103,7 @@
         MdfString m_strBkGrnd;
         MapLayerCollection m_listLayers;
         MapLayerGroupCollection m_collLayerGroups;
+        WatermarkInstanceCollection m_listWatermarks;
         MdfString m_strName;
         MdfString m_strMetadata;
         MdfString m_strCoordSys;

Modified: trunk/MgDev/Common/MdfModel/MdfModel.vcproj
===================================================================
--- trunk/MgDev/Common/MdfModel/MdfModel.vcproj	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/MdfModel/MdfModel.vcproj	2010-09-17 08:00:59 UTC (rev 5139)
@@ -1103,6 +1103,78 @@
 				>
 			</File>
 		</Filter>
+		<Filter
+			Name="WatermarkDefinition"
+			>
+			<File
+				RelativePath=".\TileWatermarkPosition.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\TileWatermarkPosition.h"
+				>
+			</File>
+			<File
+				RelativePath=".\WatermarkAppearance.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\WatermarkAppearance.h"
+				>
+			</File>
+			<File
+				RelativePath=".\WatermarkDefinition.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\WatermarkDefinition.h"
+				>
+			</File>
+			<File
+				RelativePath=".\WatermarkInstance.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\WatermarkInstance.h"
+				>
+			</File>
+			<File
+				RelativePath=".\WatermarkOffsetUnit.h"
+				>
+			</File>
+			<File
+				RelativePath=".\WatermarkPosition.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\WatermarkPosition.h"
+				>
+			</File>
+			<File
+				RelativePath=".\WatermarkXOffset.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\WatermarkXOffset.h"
+				>
+			</File>
+			<File
+				RelativePath=".\WatermarkYOffset.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\WatermarkYOffset.h"
+				>
+			</File>
+			<File
+				RelativePath=".\XYWatermarkPosition.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\XYWatermarkPosition.h"
+				>
+			</File>
+		</Filter>
 		<File
 			RelativePath=".\Base64.h"
 			>

Added: trunk/MgDev/Common/MdfModel/TileWatermarkPosition.cpp
===================================================================
--- trunk/MgDev/Common/MdfModel/TileWatermarkPosition.cpp	                        (rev 0)
+++ trunk/MgDev/Common/MdfModel/TileWatermarkPosition.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,218 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+//-------------------------------------------------------------------------
+// DESCRIPTION:
+// The TileWatermarkPosition class implementation.
+// TileWatermarkPosition class is one implementation of WatermarkPosition to 
+// define the position of watermark.
+//-------------------------------------------------------------------------
+
+#include "stdafx.h"
+#include <cmath>
+#include "TileWatermarkPosition.h"
+
+using namespace MDFMODEL_NAMESPACE;
+
+const double TileWatermarkPosition::doubleTolerance = 0.01;
+
+//-------------------------------------------------------------------------
+// PURPOSE: Construct and initialize an instance of the TileWatermarkPosition class.
+//-------------------------------------------------------------------------
+TileWatermarkPosition::TileWatermarkPosition()
+    :m_horizontalPosition(NULL), m_verticalPosition(NULL)
+{
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Destructor. Release any dynamically allocated resources.
+//-------------------------------------------------------------------------
+TileWatermarkPosition::~TileWatermarkPosition()
+{
+    delete this->m_horizontalPosition;
+    delete this->m_verticalPosition;
+}
+
+//-------------------------------------------------------------------------
+// Get the tile width 
+//-------------------------------------------------------------------------
+double TileWatermarkPosition::GetTileWidth() const
+{
+    return this->m_tileWidth;
+}
+
+//-------------------------------------------------------------------------
+// Set the tile width 
+//-------------------------------------------------------------------------
+void TileWatermarkPosition::SetTileWidth(const double& dTileWidth)
+{
+    this->m_tileWidth = dTileWidth;
+}
+
+//-------------------------------------------------------------------------
+// Get the tile height 
+//-------------------------------------------------------------------------
+double TileWatermarkPosition::GetTileHeight() const
+{
+    return this->m_tileHeight;
+}
+
+//-------------------------------------------------------------------------
+// Set the tile height 
+//-------------------------------------------------------------------------
+void TileWatermarkPosition::SetTileHeight(const double& dTileHeight)
+{
+    this->m_tileHeight = dTileHeight;
+}
+
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the HorizontalPosition property.
+//          The WatermarkXOffset is the type of offset used in the position of watermark.
+// RETURNS: The pointer of WatermarkXOffset.
+//-------------------------------------------------------------------------
+const WatermarkXOffset* TileWatermarkPosition::GetHorizontalPosition() const
+{
+    return this->m_horizontalPosition;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the HorizontalPosition property.
+//          The WatermarkXOffset is the type of offset used in the position of watermark.
+// RETURNS: The pointer of WatermarkXOffset.
+//-------------------------------------------------------------------------
+WatermarkXOffset* TileWatermarkPosition::GetHorizontalPosition()
+{
+    return this->m_horizontalPosition;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the HorizontalPosition property.
+//          The WatermarkXOffset is the type of offset used in the position of watermark.
+// PARAMETERS:
+//        Input:
+//          pXPosition - Adopted WatermarkXOffset object that is created on the heap.
+//                             It may be NULL.
+//-------------------------------------------------------------------------
+void TileWatermarkPosition::AdoptHorizontalPosition(WatermarkXOffset *pHorizontalPosition)
+{
+    if (this->m_horizontalPosition != pHorizontalPosition)
+    {
+        delete this->m_horizontalPosition;
+        this->m_horizontalPosition = pHorizontalPosition;
+    }
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the HorizontalPosition property.
+//          The WatermarkXOffset is the type of offset used in the position of watermark.
+// RETURNS: The pointer to the orphaned WatermarkXOffset object. It may be NULL.
+//-------------------------------------------------------------------------
+WatermarkXOffset* TileWatermarkPosition::OrphanHorizontalPosition()
+{
+    WatermarkXOffset* pRet = this->m_horizontalPosition;
+    this->m_horizontalPosition = NULL;
+    return pRet;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the VerticalPosition property.
+//          The WatermarkYOffset is the type of offset used in the position of watermark.
+// RETURNS: The pointer of WatermarkYOffset.
+//-------------------------------------------------------------------------
+const WatermarkYOffset* TileWatermarkPosition::GetVerticalPosition() const
+{
+    return this->m_verticalPosition;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the VerticalPosition property.
+//          The WatermarkYOffset is the type of offset used in the position of watermark.
+// RETURNS: The pointer of WatermarkYOffset.
+//-------------------------------------------------------------------------
+WatermarkYOffset* TileWatermarkPosition::GetVerticalPosition()
+{
+    return this->m_verticalPosition;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the VerticalPosition property.
+//          The WatermarkYOffset is the type of offset used in the position of watermark.
+// PARAMETERS:
+//        Input:
+//          pYPosition - Adopted WatermarkYOffset object that is created on the heap.
+//                             It may be NULL.
+//-------------------------------------------------------------------------
+void TileWatermarkPosition::AdoptVerticalPosition(WatermarkYOffset *pVerticalPosition)
+{
+    if (this->m_verticalPosition != pVerticalPosition)
+    {
+        delete this->m_verticalPosition;
+        this->m_verticalPosition = pVerticalPosition;
+    }
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the VerticalPosition property.
+//          The WatermarkYOffset is the type of offset used in the position of watermark.
+// RETURNS: The pointer to the orphaned WatermarkYOffset object. It may be NULL.
+//-------------------------------------------------------------------------
+WatermarkYOffset* TileWatermarkPosition::OrphanVerticalPosition()
+{
+    WatermarkYOffset* pRet = this->m_verticalPosition;
+    this->m_verticalPosition = NULL;
+    return pRet;
+}
+
+//-------------------------------------------------------------------------
+// Whether this position is the same as given one
+//-------------------------------------------------------------------------
+bool TileWatermarkPosition::Equals(WatermarkPosition* another)
+{
+    TileWatermarkPosition* anotherPosition = dynamic_cast<TileWatermarkPosition*>(another);
+    if(!anotherPosition) return false;
+
+    if(fabs(this->m_tileWidth - anotherPosition->m_tileWidth) > doubleTolerance)
+        return false;
+    if(fabs(this->m_tileHeight - anotherPosition->m_tileHeight) > doubleTolerance)
+        return false;
+    
+    if(!this->m_horizontalPosition)
+    {
+        if(anotherPosition->m_horizontalPosition) return false;
+    }
+    else if(!this->m_horizontalPosition->Equals(anotherPosition->m_horizontalPosition))
+        return false;
+
+    if(!this->m_verticalPosition)
+    {
+        return !anotherPosition->m_verticalPosition;
+    }
+    else
+    {
+        return this->m_verticalPosition->Equals(anotherPosition->m_verticalPosition);
+    }
+}
+
+#ifdef _WIN32
+#ifdef _DEBUG
+int TileWatermarkPosition::DumpMemoryLeaks()
+{
+    return _CrtDumpMemoryLeaks();
+}
+#endif
+#endif

Added: trunk/MgDev/Common/MdfModel/TileWatermarkPosition.h
===================================================================
--- trunk/MgDev/Common/MdfModel/TileWatermarkPosition.h	                        (rev 0)
+++ trunk/MgDev/Common/MdfModel/TileWatermarkPosition.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,88 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef TILEWATERMARKPOSITION_H_
+#define TILEWATERMARKPOSITION_H_
+
+#include "MdfModel.h"
+#include "WatermarkPosition.h"
+#include "WatermarkXOffset.h"
+#include "WatermarkYOffset.h"
+
+BEGIN_NAMESPACE_MDFMODEL
+
+    //-------------------------------------------------------------------------
+    // DESCRIPTION:
+    // The TileWatermarkPosition class is one concrete implementation of WatermarkPosition.
+    // It will repeat the source both in X and Y dimension. Tile is the unit of repeat.
+    // Within tile it uses X-Y as the position of watermark.
+    //------------------------------------------------------------------------
+class MDFMODEL_API TileWatermarkPosition: public WatermarkPosition
+    {
+    public:
+        // Construction, destruction, initialization.
+        TileWatermarkPosition();
+        virtual ~TileWatermarkPosition();
+
+        // Operations
+
+        // Property: TileWidth
+        double GetTileWidth() const;
+        void SetTileWidth(const double& dTileWidth);
+
+        // Property: TileHeight
+        double GetTileHeight() const;
+        void SetTileHeight(const double& dTileHeight);
+        
+        // Property: HorizontalPosition
+        const WatermarkXOffset* GetHorizontalPosition() const;
+        WatermarkXOffset* GetHorizontalPosition();
+        void AdoptHorizontalPosition(WatermarkXOffset *pHorizontalPosition);
+        WatermarkXOffset* OrphanHorizontalPosition();
+        
+        // Property: VerticalPosition
+        const WatermarkYOffset* GetVerticalPosition() const;
+        WatermarkYOffset* GetVerticalPosition();
+        void AdoptVerticalPosition(WatermarkYOffset *pVerticalPosition);
+        WatermarkYOffset* OrphanVerticalPosition();
+
+        virtual bool Equals(WatermarkPosition* another);
+
+//#ifdef _WIN32
+#if _DEBUG
+        // for memory leak testing
+        static int DumpMemoryLeaks();
+#endif
+//#endif
+
+    private:
+        // Hidden TileWatermarkPosition copy constructor and assignment operator.
+         TileWatermarkPosition(const TileWatermarkPosition&);
+         TileWatermarkPosition& operator=(const TileWatermarkPosition&);
+
+        // Data members
+        // See corresponding properties for descriptions
+         double m_tileWidth;
+         double m_tileHeight;
+         WatermarkXOffset* m_horizontalPosition;
+         WatermarkYOffset* m_verticalPosition;
+
+        static const double doubleTolerance;
+    };
+
+END_NAMESPACE_MDFMODEL
+#endif // TILEWATERMARKPOSITION_H_

Added: trunk/MgDev/Common/MdfModel/WatermarkAppearance.cpp
===================================================================
--- trunk/MgDev/Common/MdfModel/WatermarkAppearance.cpp	                        (rev 0)
+++ trunk/MgDev/Common/MdfModel/WatermarkAppearance.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,99 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+//-------------------------------------------------------------------------
+// DESCRIPTION:
+// The WatermarkAppearance class implementation.
+// WatermarkAppearance class is to define the appearance of watermark.
+//-------------------------------------------------------------------------
+
+#include <cmath>
+#include "stdafx.h"
+#include "WatermarkAppearance.h"
+
+using namespace MDFMODEL_NAMESPACE;
+
+const double WatermarkAppearance::doubleTolerance = 0.01;
+
+//-------------------------------------------------------------------------
+// PURPOSE: Construct and initialize an instance of the WatermarkAppearance class.
+//-------------------------------------------------------------------------
+WatermarkAppearance::WatermarkAppearance()
+{
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Destructor. Release any dynamically allocated resources.
+//-------------------------------------------------------------------------
+WatermarkAppearance::~WatermarkAppearance()
+{
+}
+
+//-------------------------------------------------------------------------
+// Returns the transparency (0 - 100). O means totally opaque. 100 means totally
+// transparent. 
+//-------------------------------------------------------------------------
+double WatermarkAppearance::GetTransparency() const
+{
+    return this->m_transparency;
+}
+
+//-------------------------------------------------------------------------
+// Set the transparency (0 - 100). O means totally opaque. 100 means totally
+// transparent. If the parameter is more than 100, treat it as 100. If the
+// parameter is less than 0, treat it as 0.
+//-------------------------------------------------------------------------
+void WatermarkAppearance::SetTransparency(const double& dTransparency)
+{
+    this->m_transparency = (dTransparency > 100) ? 100 : (dTransparency < 0 ? 0 : dTransparency);
+}
+
+//-------------------------------------------------------------------------
+// Returns the rotation (0 - 360). O means no rotation. 90 means rotating 90 degree
+// anticlockwise. 360 should be the same as 0 as it turns a whole circle.
+//-------------------------------------------------------------------------
+double WatermarkAppearance::GetRotation() const
+{
+    return this->m_rotation;
+}
+
+//-------------------------------------------------------------------------
+// Set the rotation (0 - 360). O means no rotation. 90 means rotating 90 degree
+// anticlockwise. 360 should be the same as 0 as it turns a whole circle. 
+// If the parameter is more than 360, treat it as 360. If the
+// parameter is less than 0, treat it as 0.
+//-------------------------------------------------------------------------
+void WatermarkAppearance::SetRotation(const double& dRotation)
+{
+    this->m_rotation = (dRotation > 360) ? 360 : (dRotation < 0 ? 0 : dRotation);
+}
+
+bool WatermarkAppearance::Equals(WatermarkAppearance* another)
+{
+    return another
+            && fabs(this->m_transparency - another->m_transparency) < doubleTolerance
+            && fabs(this->m_rotation - another->m_rotation) < doubleTolerance;
+}
+
+#ifdef _WIN32
+#ifdef _DEBUG
+int WatermarkAppearance::DumpMemoryLeaks()
+{
+    return _CrtDumpMemoryLeaks();
+}
+#endif
+#endif

Added: trunk/MgDev/Common/MdfModel/WatermarkAppearance.h
===================================================================
--- trunk/MgDev/Common/MdfModel/WatermarkAppearance.h	                        (rev 0)
+++ trunk/MgDev/Common/MdfModel/WatermarkAppearance.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,68 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef WATERMARKAPPEARANCE_H_
+#define WATERMARKAPPEARANCE_H_
+
+#include "MdfModel.h"
+
+BEGIN_NAMESPACE_MDFMODEL
+
+    //-------------------------------------------------------------------------
+    // DESCRIPTION:
+    // The WatermarkAppearance class is to define the appearance of watermark.
+    //------------------------------------------------------------------------
+class MDFMODEL_API WatermarkAppearance
+    {
+    public:
+        // Construction, destruction, initialization.
+        WatermarkAppearance();
+        virtual ~WatermarkAppearance();
+
+        // Operations
+        // Property: Transparency
+        double GetTransparency() const;
+        void SetTransparency(const double& dTransparency);
+
+        // Property: Rotation
+        double GetRotation() const;
+        void SetRotation(const double& dRotation);
+
+        virtual bool Equals(WatermarkAppearance* another);
+
+//#ifdef _WIN32
+#if _DEBUG
+        // for memory leak testing
+        static int DumpMemoryLeaks();
+#endif
+//#endif
+
+    private:
+        // Hidden WatermarkAppearance copy constructor and assignment operator.
+         WatermarkAppearance(const WatermarkAppearance&);
+         WatermarkAppearance& operator=(const WatermarkAppearance&);
+
+        // Data members
+        // See corresponding properties for descriptions
+        double m_transparency;
+        double m_rotation;
+
+        static const double doubleTolerance;
+    };
+
+END_NAMESPACE_MDFMODEL
+#endif // WATERMARKAPPEARANCE_H_

Added: trunk/MgDev/Common/MdfModel/WatermarkDefinition.cpp
===================================================================
--- trunk/MgDev/Common/MdfModel/WatermarkDefinition.cpp	                        (rev 0)
+++ trunk/MgDev/Common/MdfModel/WatermarkDefinition.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,209 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+//-------------------------------------------------------------------------
+// DESCRIPTION:
+// The WatermarkDefinition class implementation.
+// All the data objects in the WatermarkDefinition (Content, Appearance, Position etc) 
+// are accessible. While unfettered access to all the stored objects in provided, 
+// these data are still owned by the WatermarkDefinition object.
+// Methods that have a prefix of "Adopt", imply that the object passed to them
+// has to be created on the heap and the WaterDefinition object is now responsible 
+// for its deletion. Methods that have a prefix of "Orphan" imply that the pointer
+// returned, points to an object on the heap and its is the caller who is responsible
+// for its deletion. Methods that have a "Get" prefix simply give access without
+// a change of ownership.
+//-------------------------------------------------------------------------
+
+#include "stdafx.h"
+#include "WatermarkDefinition.h"
+
+using namespace MDFMODEL_NAMESPACE;
+
+//-------------------------------------------------------------------------
+// PURPOSE: Construct and initialize an instance of the WatermarkDefinition class.
+//-------------------------------------------------------------------------
+WatermarkDefinition::WatermarkDefinition()
+    :m_source(NULL), m_appearance(NULL), m_position(NULL)
+{
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Destructor. Release any dynamically allocated resources.
+//-------------------------------------------------------------------------
+WatermarkDefinition::~WatermarkDefinition()
+{
+    delete this->m_source;
+    delete this->m_appearance;
+}
+
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the source property.
+//          The SymbolDefinition is the type of source content used in watermark.
+// RETURNS: The pointer of symbol definition.
+//-------------------------------------------------------------------------
+const SymbolDefinition* WatermarkDefinition::GetSource() const
+{
+    return this->m_source;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the source property.
+//          The SymbolDefinition is the type of source content used in watermark.
+// RETURNS: The pointer of symbol definition.
+//-------------------------------------------------------------------------
+SymbolDefinition* WatermarkDefinition::GetSource()
+{
+    return this->m_source;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the source property.
+//          The SymbolDefinition is the type of source content used in watermark.
+// PARAMETERS:
+//        Input:
+//          pSource - Adopted SymbolDefinition object that is created on the heap.
+//                             It may be NULL.
+//-------------------------------------------------------------------------
+void WatermarkDefinition::AdoptSource(SymbolDefinition *pSource)
+{
+    if (this->m_source != pSource)
+    {
+        delete this->m_source;
+        this->m_source = pSource;
+    }
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the source property.
+//          The SymbolDefinition is the type of source content used in watermark.
+// RETURNS: The pointer to the orphaned SymbolDefinition object. It may be NULL.
+//-------------------------------------------------------------------------
+SymbolDefinition* WatermarkDefinition::OrphanSource()
+{
+    SymbolDefinition* pRet = this->m_source;
+    this->m_source = NULL;
+    return pRet;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the appearance property.
+//          The WatermarkAppearance is the type of appearance in watermark.
+// RETURNS: The pointer of watermark appearance.
+//-------------------------------------------------------------------------
+const WatermarkAppearance* WatermarkDefinition::GetAppearance() const
+{
+    return this->m_appearance;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the appearance property.
+//          The WatermarkAppearance is the type of appearance in watermark.
+// RETURNS: The pointer of watermark appearance.
+//-------------------------------------------------------------------------
+WatermarkAppearance* WatermarkDefinition::GetAppearance()
+{
+    return this->m_appearance;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the appearance property.
+//          The WatermarkAppearance is the type of appearance in watermark.
+// PARAMETERS:
+//        Input:
+//          pAppearance - Adopted WatermarkAppearance object that is created on the heap.
+//                             It may be NULL.
+//-------------------------------------------------------------------------
+void WatermarkDefinition::AdoptAppearance(WatermarkAppearance *pAppearance)
+{
+    if (this->m_appearance != pAppearance)
+    {
+        delete this->m_appearance;
+        this->m_appearance = pAppearance;
+    }
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the appearance property.
+//          The WatermarkAppearance is the type of appearance in watermark.
+// RETURNS: The pointer to the orphaned WatermarkAppearance object. It may be NULL.
+//-------------------------------------------------------------------------
+WatermarkAppearance* WatermarkDefinition::OrphanAppearance()
+{
+    WatermarkAppearance* pRet = this->m_appearance;
+    this->m_appearance = NULL;
+    return pRet;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the position property.
+//          The WatermarkPosition is the type of position in watermark.
+// RETURNS: The pointer of watermark position.
+//-------------------------------------------------------------------------
+const WatermarkPosition* WatermarkDefinition::GetPosition() const
+{
+    return this->m_position;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the position property.
+//          The WatermarkPosition is the type of position in watermark.
+// RETURNS: The pointer of watermark position.
+//-------------------------------------------------------------------------
+WatermarkPosition* WatermarkDefinition::GetPosition()
+{
+    return this->m_position;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the position property.
+//          The WatermarkPosition is the type of position in watermark.
+// PARAMETERS:
+//        Input:
+//          pPosition - Adopted WatermarkPosition object that is created on the heap.
+//                             It may be NULL.
+//-------------------------------------------------------------------------
+void WatermarkDefinition::AdoptPosition(WatermarkPosition *pPosition)
+{
+    if (this->m_position != pPosition)
+    {
+        delete this->m_position;
+        this->m_position = pPosition;
+    }
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the position property.
+//          The WatermarkPosition is the type of position in watermark.
+// RETURNS: The pointer to the orphaned WatermarkPosition object. It may be NULL.
+//-------------------------------------------------------------------------
+WatermarkPosition* WatermarkDefinition::OrphanPosition()
+{
+    WatermarkPosition* pRet = this->m_position;
+    this->m_position = NULL;
+    return pRet;
+}
+
+#ifdef _WIN32
+#ifdef _DEBUG
+int WatermarkDefinition::DumpMemoryLeaks()
+{
+    return _CrtDumpMemoryLeaks();
+}
+#endif
+#endif

Added: trunk/MgDev/Common/MdfModel/WatermarkDefinition.h
===================================================================
--- trunk/MgDev/Common/MdfModel/WatermarkDefinition.h	                        (rev 0)
+++ trunk/MgDev/Common/MdfModel/WatermarkDefinition.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,81 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef WATERMARKDEFINITION_H_
+#define WATERMARKDEFINITION_H_
+
+#include "MdfModel.h"
+#include "MdfRootObject.h"
+#include "SymbolDefinition.h"
+#include "WatermarkAppearance.h"
+#include "WatermarkPosition.h"
+
+BEGIN_NAMESPACE_MDFMODEL
+
+    //-------------------------------------------------------------------------
+    // DESCRIPTION:
+    // The WatermarkDefinition class is the root document node of the MdfModel. Through its
+    // interface, one can get access to all the data in the WatermarkDefinition.
+    //------------------------------------------------------------------------
+class MDFMODEL_API WatermarkDefinition: public MdfRootObject
+    {
+    public:
+        // Construction, destruction, initialization.
+        WatermarkDefinition();
+        virtual ~WatermarkDefinition();
+
+        // Operations
+        
+        // Property: Source
+        const SymbolDefinition* GetSource() const;
+        SymbolDefinition* GetSource();
+        void AdoptSource(SymbolDefinition *pSource);
+        SymbolDefinition* OrphanSource();
+        
+        // Property: Appearance
+        const WatermarkAppearance* GetAppearance() const;
+        WatermarkAppearance* GetAppearance();
+        void AdoptAppearance(WatermarkAppearance *pAppearance);
+        WatermarkAppearance* OrphanAppearance();
+        
+        // Property: Position
+        const WatermarkPosition* GetPosition() const;
+        WatermarkPosition* GetPosition();
+        void AdoptPosition(WatermarkPosition *pPosition);
+        WatermarkPosition* OrphanPosition();
+
+//#ifdef _WIN32
+#if _DEBUG
+        // for memory leak testing
+        static int DumpMemoryLeaks();
+#endif
+//#endif
+
+    private:
+        // Hidden WatermarkDefinition copy constructor and assignment operator.
+         WatermarkDefinition(const WatermarkDefinition&);
+         WatermarkDefinition& operator=(const WatermarkDefinition&);
+
+        // Data members
+        // See corresponding properties for descriptions
+         SymbolDefinition* m_source;
+         WatermarkAppearance* m_appearance;
+         WatermarkPosition* m_position;
+    };
+
+END_NAMESPACE_MDFMODEL
+#endif // WATERMARKDEFINITION_H_

Added: trunk/MgDev/Common/MdfModel/WatermarkInstance.cpp
===================================================================
--- trunk/MgDev/Common/MdfModel/WatermarkInstance.cpp	                        (rev 0)
+++ trunk/MgDev/Common/MdfModel/WatermarkInstance.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,292 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+//-------------------------------------------------------------------------
+// DESCRIPTION:
+// WatermarkInstance Class implementation.
+//-------------------------------------------------------------------------
+
+#include "stdafx.h"
+#include "WatermarkInstance.h"
+
+using namespace MDFMODEL_NAMESPACE;
+
+//-------------------------------------------------------------------------
+// PURPOSE: Construct and initialize an instance of the WatermarkInstance class.
+// PARAMETERS:
+//     Input:
+//          strName - the unique WatermarkInstance name. Cannot be an empty string.
+//          strWatermarkResourceID - the resource ID for the watermark definition.
+//-------------------------------------------------------------------------
+WatermarkInstance::WatermarkInstance(const MdfString& strName, const MdfString& strWatermarkResourceID)
+: m_strName(strName)
+, m_strWatermarkResourceID(strWatermarkResourceID)
+, m_usage(ALL)
+, m_pWatermarkDefinition(NULL)
+, m_appearanceOverride(NULL)
+, m_positionOverride(NULL)
+{
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Destructor. Release any dynamically allocated resources.
+//-------------------------------------------------------------------------
+WatermarkInstance::~WatermarkInstance()
+{
+    delete this->m_pWatermarkDefinition;
+    delete this->m_appearanceOverride;
+    delete this->m_positionOverride;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor for the unique WatermarkInstance name.
+//-------------------------------------------------------------------------
+const MdfString& WatermarkInstance::GetName() const
+{
+    return this->m_strName;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor to the WatermarkInstance name.
+// PARAMETERS:
+//     Input:
+//          strName - unique WatermarkInstance name that is not a blank string.
+//-------------------------------------------------------------------------
+void WatermarkInstance::SetName(const MdfString& strName)
+{
+    if (strName.length() > 0)
+        this->m_strName = strName;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor for the WatermarkDefinition resourceID that this WatermarkInstance references.
+// RETURNS:
+//-------------------------------------------------------------------------
+const MdfString& WatermarkInstance::GetWatermarkResourceID() const
+{
+    return this->m_strWatermarkResourceID;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor to the WatermarkDefinition Uri that this WatermarkInstance references.
+// PARAMETERS:
+//      Input:
+//          strWatermarkResourceID - the watermark resourceID for this WatermarkInstance.Cannot be an empty
+//-------------------------------------------------------------------------
+void WatermarkInstance::SetWatermarkResourceID(const MdfString& strWatermarkResourceID)
+{
+    if (strWatermarkResourceID.length() > 0)
+        this->m_strWatermarkResourceID = strWatermarkResourceID;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Gets a value determining the meaning of the Usage property value.
+// RETURNS: The type of value stored in the Usage property.
+//-------------------------------------------------------------------------
+const WatermarkInstance::Usage WatermarkInstance::GetUsage() const
+{
+    return this->m_usage;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Sets a value determining the meaning of the Usage property value.
+// PARAMETERS:
+//          unit - The type of value stored in the Usage property.
+//-------------------------------------------------------------------------
+void WatermarkInstance::SetUsage(WatermarkInstance::Usage usage)
+{
+    this->m_usage = usage;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the watermark definition property.
+//          The WatermarkDefinition is the type of watermark definition.
+// RETURNS: The pointer of watermark definition.
+//-------------------------------------------------------------------------
+const WatermarkDefinition* WatermarkInstance::GetWatermarkDefinition() const
+{
+    return this->m_pWatermarkDefinition;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the watermark definition property.
+//          The WatermarkDefinition is the type of watermark definition.
+// RETURNS: The pointer of watermark definition.
+//-------------------------------------------------------------------------
+WatermarkDefinition* WatermarkInstance::GetWatermarkDefinition()
+{
+    return this->m_pWatermarkDefinition;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the watermark definition property.
+//          The WatermarkDefinition is the type of watermark definition.
+// PARAMETERS:
+//        Input:
+//          pWatermarkDefinition - Adopted WatermarkDefinition object that is created on the heap.
+//                             It may be NULL.
+//-------------------------------------------------------------------------
+void WatermarkInstance::AdoptWatermarkDefinition(WatermarkDefinition *pWatermarkDefinition)
+{
+    if (this->m_pWatermarkDefinition != pWatermarkDefinition)
+    {
+        delete this->m_pWatermarkDefinition;
+        this->m_pWatermarkDefinition = pWatermarkDefinition;
+    }
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the watermark definition property.
+//          The WatermarkDefinition is the type of watermark definition.
+// RETURNS: The pointer to the orphaned WatermarkDefinition object. It may be NULL.
+//-------------------------------------------------------------------------
+WatermarkDefinition* WatermarkInstance::OrphanWatermarkDefinition()
+{
+    WatermarkDefinition* pRet = this->m_pWatermarkDefinition;
+    this->m_pWatermarkDefinition = NULL;
+    return pRet;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the appearance override property.
+//          The WatermarkAppearance is the type of appearance override in watermark instance.
+// RETURNS: The pointer of watermark appearance override.
+//-------------------------------------------------------------------------
+const WatermarkAppearance* WatermarkInstance::GetAppearanceOverride() const
+{
+    return this->m_appearanceOverride;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the appearance override property.
+//          The WatermarkAppearance is the type of appearance override in watermark instance.
+// RETURNS: The pointer of watermark appearance override.
+//-------------------------------------------------------------------------
+WatermarkAppearance* WatermarkInstance::GetAppearanceOverride()
+{
+    return this->m_appearanceOverride;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the appearance override property.
+//          The WatermarkAppearance is the type of appearance override in watermark instance.
+// PARAMETERS:
+//        Input:
+//          pAppearanceOverride - Adopted WatermarkAppearance object that is created on the heap.
+//                             It may be NULL.
+//-------------------------------------------------------------------------
+void WatermarkInstance::AdoptAppearanceOverride(WatermarkAppearance *pAppearanceOverride)
+{
+    if (this->m_appearanceOverride != pAppearanceOverride)
+    {
+        delete this->m_appearanceOverride;
+        this->m_appearanceOverride = pAppearanceOverride;
+    }
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the appearance override property.
+//          The WatermarkAppearance is the type of appearance override in watermark instance.
+// RETURNS: The pointer to the orphaned WatermarkAppearance object. It may be NULL.
+//-------------------------------------------------------------------------
+WatermarkAppearance* WatermarkInstance::OrphanAppearanceOverride()
+{
+    WatermarkAppearance* pRet = this->m_appearanceOverride;
+    this->m_appearanceOverride = NULL;
+    return pRet;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the position override property.
+//          The WatermarkPosition is the type of position override in watermark instance.
+// RETURNS: The pointer of watermark position override.
+//-------------------------------------------------------------------------
+const WatermarkPosition* WatermarkInstance::GetPositionOverride() const
+{
+    return this->m_positionOverride;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the position override property.
+//          The WatermarkPosition is the type of position override in watermark instance.
+// RETURNS: The pointer of watermark position override.
+//-------------------------------------------------------------------------
+WatermarkPosition* WatermarkInstance::GetPositionOverride()
+{
+    return this->m_positionOverride;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the position property override.
+//          The WatermarkPosition is the type of position override in watermark instance.
+// PARAMETERS:
+//        Input:
+//          pPosition - Adopted WatermarkPosition object that is created on the heap.
+//                             It may be NULL.
+//-------------------------------------------------------------------------
+void WatermarkInstance::AdoptPositionOverride(WatermarkPosition *pPositionOverride)
+{
+    if (this->m_positionOverride != pPositionOverride)
+    {
+        delete this->m_positionOverride;
+        this->m_positionOverride = pPositionOverride;
+    }
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the position property override.
+//          The WatermarkPosition is the type of position override in watermark instance.
+// RETURNS: The pointer to the orphaned WatermarkPosition object. It may be NULL.
+//-------------------------------------------------------------------------
+WatermarkPosition* WatermarkInstance::OrphanPositionOverride()
+{
+    WatermarkPosition* pRet = this->m_positionOverride;
+    this->m_positionOverride = NULL;
+    return pRet;
+}
+
+bool WatermarkInstance::Equals(WatermarkInstance* another)
+{
+    if(!another) return false;
+    if(::wcscmp(this->m_strWatermarkResourceID.c_str(), 
+        another->m_strWatermarkResourceID.c_str())) 
+        return false;
+    if(!this->m_appearanceOverride)
+    {
+        if(another->m_appearanceOverride) return false;
+    }
+    else if(!this->m_appearanceOverride->Equals(another->m_appearanceOverride))
+        return false;
+
+    if(!this->m_positionOverride)
+    {
+        return !(another->m_positionOverride);
+    }
+    else
+    {
+        return this->m_positionOverride->Equals(another->m_positionOverride);
+    }
+}
+
+#ifdef _WIN32
+#ifdef _DEBUG
+int WatermarkInstance::DumpMemoryLeaks()
+{
+    return _CrtDumpMemoryLeaks();
+}
+#endif
+#endif

Added: trunk/MgDev/Common/MdfModel/WatermarkInstance.h
===================================================================
--- trunk/MgDev/Common/MdfModel/WatermarkInstance.h	                        (rev 0)
+++ trunk/MgDev/Common/MdfModel/WatermarkInstance.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,114 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef WATERMARKINSTANCE_H_
+#define WATERMARKINSTANCE_H_
+
+#include "MdfModel.h"
+#include "MdfOwnerCollection.h"
+#include "WatermarkDefinition.h"
+#include "WatermarkAppearance.h"
+#include "WatermarkPosition.h"
+
+BEGIN_NAMESPACE_MDFMODEL
+
+    //-------------------------------------------------------------------------
+    // DESCRIPTION:
+    // WatermarkInstance defines how a watermark should be made part of a layer / map.
+    // It is important to note, that multiple WatermarkInstance can hold onto the same
+    // reference of a WatermarkDefinition object. It is the user's responsibility to ensure
+    // that duplicated WatermarkDefinitions are deleted.
+    //------------------------------------------------------------------------
+class MDFMODEL_API WatermarkInstance
+    {
+    public:
+
+        // Describes the content of the Usage property
+        enum Usage
+        {
+            WMS = 1,
+            Viewer = 2,
+            ALL = WMS | Viewer
+        };
+
+        // Construction, destruction, initialization.
+        WatermarkInstance(const MdfString& strName, const MdfString& strWatermarkResourceID);
+        virtual ~WatermarkInstance();
+
+        // Operations
+        // Property : Name
+        // The name of WatermarkInstance. Must be a unique WatermarkInstance name.
+        const MdfString& GetName() const;
+        void SetName(const MdfString& strName);
+
+        //Property : WatermarkResourceID
+        // The Watermark ResourceID that this WatermarkInstance refers to for its WatermarkDefinition object
+        const MdfString& GetWatermarkResourceID() const;
+        void SetWatermarkResourceID(const MdfString& strWaterResourceID);
+
+        // Property: Usage
+        const Usage GetUsage() const;
+        void SetUsage(Usage usage);
+
+        // Property : WatermarkDefinition
+        // WatermarkDefinition that this WatermarkInstance refers to.
+        const WatermarkDefinition* GetWatermarkDefinition() const;
+        WatermarkDefinition* GetWatermarkDefinition();
+        void AdoptWatermarkDefinition(WatermarkDefinition *pWatermarkDefinition);
+        WatermarkDefinition* OrphanWatermarkDefinition();
+
+        // Property: AppearanceOverride
+        const WatermarkAppearance* GetAppearanceOverride() const;
+        WatermarkAppearance* GetAppearanceOverride();
+        void AdoptAppearanceOverride(WatermarkAppearance *pAppearanceOverride);
+        WatermarkAppearance* OrphanAppearanceOverride();
+
+        // Property: PositionOverride
+        const WatermarkPosition* GetPositionOverride() const;
+        WatermarkPosition* GetPositionOverride();
+        void AdoptPositionOverride(WatermarkPosition *pPositionOverride);
+        WatermarkPosition* OrphanPositionOverride();
+
+        bool Equals(WatermarkInstance* another);
+
+//#ifdef _WIN32
+#if _DEBUG
+        // for memory leak testing
+        static int DumpMemoryLeaks();
+#endif
+//#endif
+
+    private:
+        // Hidden WatermarkInstance copy constructor and assignment operator.
+         WatermarkInstance(const WatermarkInstance&);
+         WatermarkInstance& operator=(const WatermarkInstance&);
+
+        // Data members
+        // See corresponding properties for descriptions
+         MdfString m_strName;
+         MdfString m_strWatermarkResourceID;
+         Usage m_usage;
+         WatermarkDefinition* m_pWatermarkDefinition;
+         WatermarkAppearance* m_appearanceOverride;
+         WatermarkPosition* m_positionOverride;
+    };
+
+    typedef MdfOwnerCollection<WatermarkInstance> WatermarkInstanceCollection;
+    EXPIMP_TEMPLATE template class MDFMODEL_API MdfOwnerCollection<WatermarkInstance>;
+
+END_NAMESPACE_MDFMODEL
+#endif // WATERMARKINSTANCE_H_

Added: trunk/MgDev/Common/MdfModel/WatermarkOffsetUnit.h
===================================================================
--- trunk/MgDev/Common/MdfModel/WatermarkOffsetUnit.h	                        (rev 0)
+++ trunk/MgDev/Common/MdfModel/WatermarkOffsetUnit.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,42 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef WATERMARKOFFSETUNIT_H_
+#define WATERMARKOFFSETUNIT_H_     
+
+#include "MdfModel.h"
+
+
+namespace MdfModel{
+    namespace WatermarkOffset {
+
+        //-------------------------------------------------------------------------
+        // DESCRIPTION:
+        // The WatermarkOffsetUnit enum is to describe the content of the Unit property
+        // in watermark offset.
+        //------------------------------------------------------------------------
+        enum WatermarkOffsetUnit
+        {
+            Inches,
+            Centimeters,
+            Millimeters,
+            Pixels,
+            Points
+        };
+    }
+}
+#endif // WATERMARKOFFSETUNIT_H_

Added: trunk/MgDev/Common/MdfModel/WatermarkPosition.cpp
===================================================================
--- trunk/MgDev/Common/MdfModel/WatermarkPosition.cpp	                        (rev 0)
+++ trunk/MgDev/Common/MdfModel/WatermarkPosition.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,40 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+//-------------------------------------------------------------------------
+// DESCRIPTION:
+// The WatermarkPosition class implementation.
+//-------------------------------------------------------------------------
+
+#include "stdafx.h"
+#include "WatermarkPosition.h"
+
+using namespace MDFMODEL_NAMESPACE;
+
+//-------------------------------------------------------------------------
+// PURPOSE: Construct and initialize an instance of the WatermarkPosition class.
+//-------------------------------------------------------------------------
+WatermarkPosition::WatermarkPosition()
+{
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Destructor. Release any dynamically allocated resources.
+//-------------------------------------------------------------------------
+WatermarkPosition::~WatermarkPosition()
+{
+}

Added: trunk/MgDev/Common/MdfModel/WatermarkPosition.h
===================================================================
--- trunk/MgDev/Common/MdfModel/WatermarkPosition.h	                        (rev 0)
+++ trunk/MgDev/Common/MdfModel/WatermarkPosition.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,46 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef WATERMARKPOSITION_H_
+#define WATERMARKPOSITION_H_
+
+#include "MdfModel.h"
+
+BEGIN_NAMESPACE_MDFMODEL
+
+    //-------------------------------------------------------------------------
+    // DESCRIPTION:
+    // The WatermarkPosition class is the abstract class of position.
+    // It doesn't contain any field inside itself.
+    //------------------------------------------------------------------------
+class MDFMODEL_API WatermarkPosition
+    {
+    public:
+        // Destruction
+        virtual ~WatermarkPosition();
+
+        virtual bool Equals(WatermarkPosition* another) = 0;
+
+    private:
+    protected:
+        // Construction, initialization
+        // Default constructor is protected to make this class abstract.
+        WatermarkPosition();
+    };
+
+END_NAMESPACE_MDFMODEL
+#endif // WATERMARKPOSITION_H_

Added: trunk/MgDev/Common/MdfModel/WatermarkXOffset.cpp
===================================================================
--- trunk/MgDev/Common/MdfModel/WatermarkXOffset.cpp	                        (rev 0)
+++ trunk/MgDev/Common/MdfModel/WatermarkXOffset.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,117 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+//-------------------------------------------------------------------------
+// DESCRIPTION:
+// The WatermarkXOffset class implementation.
+// WatermarkXOffset class is to define the offset of watermark at one dimension.
+//-------------------------------------------------------------------------
+
+#include <cmath>
+#include "stdafx.h"
+#include "WatermarkXOffset.h"
+
+using namespace MDFMODEL_NAMESPACE;
+
+const double WatermarkXOffset::doubleTolerance = 0.01;
+
+//-------------------------------------------------------------------------
+// PURPOSE: Construct and initialize an instance of the WatermarkXOffset class.
+//-------------------------------------------------------------------------
+WatermarkXOffset::WatermarkXOffset()
+: m_unit(WatermarkOffset::Pixels)
+, m_alignment(Center)
+{
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Destructor. Release any dynamically allocated resources.
+//-------------------------------------------------------------------------
+WatermarkXOffset::~WatermarkXOffset()
+{
+}
+
+//-------------------------------------------------------------------------
+// Get the offset length 
+//-------------------------------------------------------------------------
+double WatermarkXOffset::GetLength() const
+{
+    return this->m_length;
+}
+
+//-------------------------------------------------------------------------
+// Set the offset length 
+//-------------------------------------------------------------------------
+void WatermarkXOffset::SetLength(const double& dLength)
+{
+    this->m_length = dLength;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Gets a value determining the meaning of the Unit property value.
+// RETURNS: The type of value stored in the Unit property.
+//-------------------------------------------------------------------------
+WatermarkOffset::WatermarkOffsetUnit WatermarkXOffset::GetUnit() const
+{
+    return this->m_unit;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Sets a value determining the meaning of the Unit property value.
+// PARAMETERS:
+//          unit - The type of value stored in the Unit property.
+//-------------------------------------------------------------------------
+void WatermarkXOffset::SetUnit(WatermarkOffset::WatermarkOffsetUnit unit)
+{
+    this->m_unit = unit;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Gets a value determining the meaning of the Alignment property value.
+// RETURNS: The type of value stored in the Alignment property.
+//-------------------------------------------------------------------------
+WatermarkXOffset::HorizontalAlignment WatermarkXOffset::GetAlignment() const
+{
+    return this->m_alignment;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Sets a value determining the meaning of the Alignment property value.
+// PARAMETERS:
+//          alignment - The type of value stored in the Alignment property.
+//-------------------------------------------------------------------------
+void WatermarkXOffset::SetAlignment(WatermarkXOffset::HorizontalAlignment alignment)
+{
+    this->m_alignment = alignment;
+}
+
+bool WatermarkXOffset::Equals(WatermarkXOffset* another)
+{
+    return another
+            && fabs(this->m_length - another->m_length) < doubleTolerance
+            && this->m_unit == another->m_unit
+            && this->m_alignment == another->m_alignment;
+}
+
+#ifdef _WIN32
+#ifdef _DEBUG
+int WatermarkXOffset::DumpMemoryLeaks()
+{
+    return _CrtDumpMemoryLeaks();
+}
+#endif
+#endif

Added: trunk/MgDev/Common/MdfModel/WatermarkXOffset.h
===================================================================
--- trunk/MgDev/Common/MdfModel/WatermarkXOffset.h	                        (rev 0)
+++ trunk/MgDev/Common/MdfModel/WatermarkXOffset.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,88 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef WATERMARKXOFFSET_H_
+#define WATERMARKXOFFSET_H_
+
+#include "MdfModel.h"
+#include "WatermarkOffsetUnit.h"
+
+BEGIN_NAMESPACE_MDFMODEL
+
+    //-------------------------------------------------------------------------
+    // DESCRIPTION:
+    // The WatermarkXOffest class is to define the offset in X-axis of the watermark.
+    //------------------------------------------------------------------------
+    class MDFMODEL_API WatermarkXOffset
+    {
+    public:
+
+        // Describes the content of the Alignment property
+        enum HorizontalAlignment
+        {
+            Left,
+            Center,
+            Right,
+        };
+
+        // Construction, destruction, initialization.
+        WatermarkXOffset();
+        virtual ~WatermarkXOffset();
+
+        // Operations
+        // Property: Length
+        double GetLength() const;
+        void SetLength(const double& dLength);
+
+        // Property : Unit
+        WatermarkOffset::WatermarkOffsetUnit GetUnit() const;
+        void SetUnit(WatermarkOffset::WatermarkOffsetUnit unit);
+
+        // Property : Alignment
+        HorizontalAlignment GetAlignment() const;
+        void SetAlignment(HorizontalAlignment alignment);
+
+        virtual bool Equals(WatermarkXOffset* another);
+
+//#ifdef _WIN32
+#if _DEBUG
+        // for memory leak testing
+        static int DumpMemoryLeaks();
+#endif
+//#endif
+
+    private:
+        // Hidden WatermarkXOffset copy constructor and assignment operator.
+         WatermarkXOffset(const WatermarkXOffset&);
+         WatermarkXOffset& operator=(const WatermarkXOffset&);
+
+
+        // Data members
+        // See corresponding properties for descriptions
+         double m_length;
+
+        // The meaning of the string in the Unit property.
+         WatermarkOffset::WatermarkOffsetUnit m_unit;
+
+        // The meaning of the string in the Alignment property.
+         HorizontalAlignment m_alignment;
+
+        static const double doubleTolerance;
+    };
+
+END_NAMESPACE_MDFMODEL
+#endif // WATERMARKXOFFSET_H_

Added: trunk/MgDev/Common/MdfModel/WatermarkYOffset.cpp
===================================================================
--- trunk/MgDev/Common/MdfModel/WatermarkYOffset.cpp	                        (rev 0)
+++ trunk/MgDev/Common/MdfModel/WatermarkYOffset.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,117 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+//-------------------------------------------------------------------------
+// DESCRIPTION:
+// The WatermarkYOffset class implementation.
+// WatermarkYOffset class is to define the offset of watermark at one dimension.
+//-------------------------------------------------------------------------
+
+#include <cmath>
+#include "stdafx.h"
+#include "WatermarkYOffset.h"
+
+using namespace MDFMODEL_NAMESPACE;
+
+const double WatermarkYOffset::doubleTolerance = 0.01;
+
+//-------------------------------------------------------------------------
+// PURPOSE: Construct and initialize an instance of the WatermarkYOffset class.
+//-------------------------------------------------------------------------
+WatermarkYOffset::WatermarkYOffset()
+: m_unit(WatermarkOffset::Pixels)
+, m_alignment(Center)
+{
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Destructor. Release any dynamically allocated resources.
+//-------------------------------------------------------------------------
+WatermarkYOffset::~WatermarkYOffset()
+{
+}
+
+//-------------------------------------------------------------------------
+// Get the offset length 
+//-------------------------------------------------------------------------
+double WatermarkYOffset::GetLength() const
+{
+    return this->m_length;
+}
+
+//-------------------------------------------------------------------------
+// Set the offset length 
+//-------------------------------------------------------------------------
+void WatermarkYOffset::SetLength(const double& dLength)
+{
+    this->m_length = dLength;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Gets a value determining the meaning of the Unit property value.
+// RETURNS: The type of value stored in the Unit property.
+//-------------------------------------------------------------------------
+WatermarkOffset::WatermarkOffsetUnit WatermarkYOffset::GetUnit() const
+{
+    return this->m_unit;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Sets a value determining the meaning of the Unit property value.
+// PARAMETERS:
+//          unit - The type of value stored in the Unit property.
+//-------------------------------------------------------------------------
+void WatermarkYOffset::SetUnit(WatermarkOffset::WatermarkOffsetUnit unit)
+{
+    this->m_unit = unit;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Gets a value determining the meaning of the Alignment property value.
+// RETURNS: The type of value stored in the Alignment property.
+//-------------------------------------------------------------------------
+WatermarkYOffset::VerticalAlignment WatermarkYOffset::GetAlignment() const
+{
+    return this->m_alignment;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Sets a value determining the meaning of the Alignment property value.
+// PARAMETERS:
+//          alignment - The type of value stored in the Alignment property.
+//-------------------------------------------------------------------------
+void WatermarkYOffset::SetAlignment(WatermarkYOffset::VerticalAlignment alignment)
+{
+    this->m_alignment = alignment;
+}
+
+bool WatermarkYOffset::Equals(WatermarkYOffset* another)
+{
+    return another
+            && fabs(this->m_length - another->m_length) < doubleTolerance
+            && this->m_unit == another->m_unit
+            && this->m_alignment == another->m_alignment;
+}
+
+#ifdef _WIN32
+#ifdef _DEBUG
+int WatermarkYOffset::DumpMemoryLeaks()
+{
+    return _CrtDumpMemoryLeaks();
+}
+#endif
+#endif

Added: trunk/MgDev/Common/MdfModel/WatermarkYOffset.h
===================================================================
--- trunk/MgDev/Common/MdfModel/WatermarkYOffset.h	                        (rev 0)
+++ trunk/MgDev/Common/MdfModel/WatermarkYOffset.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,88 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef WATERMARKYOFFSET_H_
+#define WATERMARKYOFFSET_H_
+
+#include "MdfModel.h"
+#include "WatermarkOffsetUnit.h"
+
+BEGIN_NAMESPACE_MDFMODEL
+
+    //-------------------------------------------------------------------------
+    // DESCRIPTION:
+    // The WatermarkOffest class is to define the offset in Y-axis of the watermark.
+    //------------------------------------------------------------------------
+    class MDFMODEL_API WatermarkYOffset
+    {
+    public:
+
+        // Describes the content of the Alignment property
+        enum VerticalAlignment
+        {
+            Top,
+            Center,
+            Bottom
+        };
+
+        // Construction, destruction, initialization.
+        WatermarkYOffset();
+        virtual ~WatermarkYOffset();
+
+        // Operations
+        // Property: Length
+        double GetLength() const;
+        void SetLength(const double& dLength);
+
+        // Property : Unit
+        WatermarkOffset::WatermarkOffsetUnit GetUnit() const;
+        void SetUnit(WatermarkOffset::WatermarkOffsetUnit unit);
+
+        // Property : Alignment
+        VerticalAlignment GetAlignment() const;
+        void SetAlignment(VerticalAlignment alignment);
+
+        virtual bool Equals(WatermarkYOffset* another);
+
+//#ifdef _WIN32
+#if _DEBUG
+        // for memory leak testing
+        static int DumpMemoryLeaks();
+#endif
+//#endif
+
+    private:
+        // Hidden WatermarkYOffset copy constructor and assignment operator.
+         WatermarkYOffset(const WatermarkYOffset&);
+         WatermarkYOffset& operator=(const WatermarkYOffset&);
+
+
+        // Data members
+        // See corresponding properties for descriptions
+         double m_length;
+
+        // The meaning of the string in the Unit property.
+         WatermarkOffset::WatermarkOffsetUnit m_unit;
+
+        // The meaning of the string in the Alignment property.
+         VerticalAlignment m_alignment;
+
+        static const double doubleTolerance;
+    };
+
+END_NAMESPACE_MDFMODEL
+#endif // WATERMARKYOFFSET_H_

Added: trunk/MgDev/Common/MdfModel/XYWatermarkPosition.cpp
===================================================================
--- trunk/MgDev/Common/MdfModel/XYWatermarkPosition.cpp	                        (rev 0)
+++ trunk/MgDev/Common/MdfModel/XYWatermarkPosition.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,175 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+//-------------------------------------------------------------------------
+// DESCRIPTION:
+// The XYWatermarkPosition class implementation.
+// XYWatermarkPosition class is one implementation of WatermarkPosition to 
+// define the position of watermark.
+//-------------------------------------------------------------------------
+
+#include "stdafx.h"
+#include "XYWatermarkPosition.h"
+
+using namespace MDFMODEL_NAMESPACE;
+
+//-------------------------------------------------------------------------
+// PURPOSE: Construct and initialize an instance of the XYWatermarkPosition class.
+//-------------------------------------------------------------------------
+XYWatermarkPosition::XYWatermarkPosition()
+: m_XPosition(NULL)
+, m_YPosition(NULL)
+{
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Destructor. Release any dynamically allocated resources.
+//-------------------------------------------------------------------------
+XYWatermarkPosition::~XYWatermarkPosition()
+{
+    delete this->m_XPosition;
+    delete this->m_YPosition;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the XPosition property.
+//          The WatermarkXOffset is the type of offset used in the position of watermark.
+// RETURNS: The pointer of WatermarkXOffset.
+//-------------------------------------------------------------------------
+const WatermarkXOffset* XYWatermarkPosition::GetXPosition() const
+{
+    return this->m_XPosition;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the XPosition property.
+//          The WatermarkXOffset is the type of offset used in the position of watermark.
+// RETURNS: The pointer of WatermarkXOffset.
+//-------------------------------------------------------------------------
+WatermarkXOffset* XYWatermarkPosition::GetXPosition()
+{
+    return this->m_XPosition;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the XPosition property.
+//          The WatermarkXOffset is the type of offset used in the position of watermark.
+// PARAMETERS:
+//        Input:
+//          pXPosition - Adopted WatermarkXOffset object that is created on the heap.
+//                             It may be NULL.
+//-------------------------------------------------------------------------
+void XYWatermarkPosition::AdoptXPosition(WatermarkXOffset *pXPosition)
+{
+    if (this->m_XPosition != pXPosition)
+    {
+        delete this->m_XPosition;
+        this->m_XPosition = pXPosition;
+    }
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the XPosition property.
+//          The WatermarkXOffset is the type of offset used in the position of watermark.
+// RETURNS: The pointer to the orphaned WatermarkXOffset object. It may be NULL.
+//-------------------------------------------------------------------------
+WatermarkXOffset* XYWatermarkPosition::OrphanXPosition()
+{
+    WatermarkXOffset* pRet = this->m_XPosition;
+    this->m_XPosition = NULL;
+    return pRet;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the YPosition property.
+//          The WatermarkYOffset is the type of offset used in the position of watermark.
+// RETURNS: The pointer of WatermarkYOffset.
+//-------------------------------------------------------------------------
+const WatermarkYOffset* XYWatermarkPosition::GetYPosition() const
+{
+    return this->m_YPosition;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the YPosition property.
+//          The WatermarkYOffset is the type of offset used in the position of watermark.
+// RETURNS: The pointer of WatermarkYOffset.
+//-------------------------------------------------------------------------
+WatermarkYOffset* XYWatermarkPosition::GetYPosition()
+{
+    return this->m_YPosition;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the YPosition property.
+//          The WatermarkYOffset is the type of offset used in the position of watermark.
+// PARAMETERS:
+//        Input:
+//          pYPosition - Adopted WatermarkYOffset object that is created on the heap.
+//                             It may be NULL.
+//-------------------------------------------------------------------------
+void XYWatermarkPosition::AdoptYPosition(WatermarkYOffset *pYPosition)
+{
+    if (this->m_YPosition != pYPosition)
+    {
+        delete this->m_YPosition;
+        this->m_YPosition = pYPosition;
+    }
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the YPosition property.
+//          The WatermarkYOffset is the type of offset used in the position of watermark.
+// RETURNS: The pointer to the orphaned WatermarkYOffset object. It may be NULL.
+//-------------------------------------------------------------------------
+WatermarkYOffset* XYWatermarkPosition::OrphanYPosition()
+{
+    WatermarkYOffset* pRet = this->m_YPosition;
+    this->m_YPosition = NULL;
+    return pRet;
+}
+
+bool XYWatermarkPosition::Equals(WatermarkPosition* another)
+{
+    XYWatermarkPosition* anotherPosition = dynamic_cast<XYWatermarkPosition*>(another);
+    if(!anotherPosition) return false;
+    
+    if(!this->m_XPosition)
+    {
+        if(anotherPosition->m_XPosition) return false;
+    }
+    else if(!this->m_XPosition->Equals(anotherPosition->m_XPosition))
+        return false;
+
+    if(!this->m_YPosition)
+    {
+        return !anotherPosition->m_YPosition;
+    }
+    else
+    {
+        return this->m_YPosition->Equals(anotherPosition->m_YPosition);
+    }
+}
+
+#ifdef _WIN32
+#ifdef _DEBUG
+int XYWatermarkPosition::DumpMemoryLeaks()
+{
+    return _CrtDumpMemoryLeaks();
+}
+#endif
+#endif

Added: trunk/MgDev/Common/MdfModel/XYWatermarkPosition.h
===================================================================
--- trunk/MgDev/Common/MdfModel/XYWatermarkPosition.h	                        (rev 0)
+++ trunk/MgDev/Common/MdfModel/XYWatermarkPosition.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,75 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef XYWATERMARKPOSITION_H_
+#define XYWATERMARKPOSITION_H_
+
+#include "MdfModel.h"
+#include "WatermarkPosition.h"
+#include "WatermarkXOffset.h"
+#include "WatermarkYOffset.h"
+
+BEGIN_NAMESPACE_MDFMODEL
+
+    //-------------------------------------------------------------------------
+    // DESCRIPTION:
+    // The XYWatermarkPosition class is one concrete implementation of WatermarkPosition.
+    // It uses X-Y as the position of watermark.
+    //------------------------------------------------------------------------
+class MDFMODEL_API XYWatermarkPosition: public WatermarkPosition
+    {
+    public:
+        // Construction, destruction, initialization.
+        XYWatermarkPosition();
+        virtual ~XYWatermarkPosition();
+
+        // Operations
+        
+        // Property: XPosition
+        const WatermarkXOffset* GetXPosition() const;
+        WatermarkXOffset* GetXPosition();
+        void AdoptXPosition(WatermarkXOffset *pXPosition);
+        WatermarkXOffset* OrphanXPosition();
+        
+        // Property: YPosition
+        const WatermarkYOffset* GetYPosition() const;
+        WatermarkYOffset* GetYPosition();
+        void AdoptYPosition(WatermarkYOffset *pYPosition);
+        WatermarkYOffset* OrphanYPosition();
+
+        virtual bool Equals(WatermarkPosition* another);
+
+//#ifdef _WIN32
+#if _DEBUG
+        // for memory leak testing
+        static int DumpMemoryLeaks();
+#endif
+//#endif
+
+    private:
+        // Hidden XYWatermarkPosition copy constructor and assignment operator.
+         XYWatermarkPosition(const XYWatermarkPosition&);
+         XYWatermarkPosition& operator=(const XYWatermarkPosition&);
+
+        // Data members
+        // See corresponding properties for descriptions
+         WatermarkXOffset* m_XPosition;
+         WatermarkYOffset* m_YPosition;
+    };
+
+END_NAMESPACE_MDFMODEL
+#endif // XYWATERMARKPOSITION_H_

Modified: trunk/MgDev/Common/MdfParser/IODrawingLayerDefinition.cpp
===================================================================
--- trunk/MgDev/Common/MdfParser/IODrawingLayerDefinition.cpp	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/MdfParser/IODrawingLayerDefinition.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -18,6 +18,7 @@
 #include "stdafx.h"
 #include "IODrawingLayerDefinition.h"
 #include "VectorScaleRange.h"
+#include "IOWatermarkInstance.h"
 #include "IOUnknown.h"
 
 using namespace XERCES_CPP_NAMESPACE;
@@ -33,6 +34,8 @@
 ELEM_MAP_ENTRY(6, MinScale);
 ELEM_MAP_ENTRY(7, MaxScale);
 ELEM_MAP_ENTRY(8, ExtendedData1);
+ELEM_MAP_ENTRY(9, Watermarks);
+ELEM_MAP_ENTRY(10, Watermark);
 
 
 IODrawingLayerDefinition::IODrawingLayerDefinition(Version& version) : SAX2ElementHandler(version)
@@ -63,6 +66,20 @@
         this->m_startElemName = name;
         break;
 
+    case eWatermark:
+        {
+            Version wdVersion;
+            if (!IODrawingLayerDefinition::GetWatermarkVersion(
+                &this->m_version, wdVersion))
+                return;
+            WatermarkInstance* layerWatermark = new WatermarkInstance(L"", L"");
+            this->m_layer->GetWatermarks()->Adopt(layerWatermark);
+            IOWatermarkInstance* IO = new IOWatermarkInstance(layerWatermark, wdVersion);
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
+        break;
+
     case eExtendedData1:
         this->m_procExtData = true;
         break;
@@ -122,6 +139,14 @@
     }
 }
 
+// Determine which WatermarkDefinition schema version to use based
+// on the supplied LDF version:
+// * LDF version <= 1.4.0  =>  WD version 1.0.0
+bool IODrawingLayerDefinition::GetWatermarkVersion(Version* ldfVersion, Version& wmVersion)
+{
+    wmVersion = Version(1, 0, 0);
+    return true;
+}
 
 void IODrawingLayerDefinition::Write(MdfStream& fd, DrawingLayerDefinition* drawingLayer, Version* version)
 {
@@ -134,9 +159,9 @@
             // LDF in MapGuide 2006
             strVersion = L"1.0.0";
         }
-        else if ((*version >= Version(1, 0, 0)) && (*version <= Version(1, 3, 0)))
+        else if ((*version >= Version(1, 0, 0)) && (*version <= Version(1, 4, 0)))
         {
-            // LDF in MapGuide 2007 / 2008 / 2009 / 2010
+            // LDF in MapGuide 2007 / 2008 / 2009 / 2010 / 2012
             strVersion = version->ToString();
         }
         else
@@ -150,7 +175,7 @@
     else
     {
         // use the current highest version
-        strVersion = L"1.3.0";
+        strVersion = L"1.4.0";
     }
 
     fd << tab() << "<LayerDefinition xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"LayerDefinition-" << EncodeString(strVersion) << ".xsd\" version=\"" << EncodeString(strVersion) << "\">" << std::endl; // NOXLATE
@@ -172,6 +197,21 @@
         fd << endStr(sOpacity) << std::endl;
     }
 
+    //Property: LayerWatermark (Optional)
+    if(*version >= Version(1, 4, 0))
+    {
+        int watermarkCount = drawingLayer->GetWatermarks()->GetCount();
+        if(watermarkCount != 0)
+        {
+            fd << tab() << startStr(sWatermarks) << std::endl; // NOXLATE
+            inctab();
+            for (int i=0; i<watermarkCount; ++i)
+                IOWatermarkInstance::Write(fd, drawingLayer->GetWatermarks()->GetAt(i), version);
+            dectab();
+            fd << endStr(sWatermarks) << std::endl; // NOXLATE
+        }
+    }
+
     // Property: Sheet
     fd << tab() << startStr(sSheet);
     fd << EncodeString(drawingLayer->GetSheet());

Modified: trunk/MgDev/Common/MdfParser/IODrawingLayerDefinition.h
===================================================================
--- trunk/MgDev/Common/MdfParser/IODrawingLayerDefinition.h	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/MdfParser/IODrawingLayerDefinition.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -41,6 +41,7 @@
         static void Write(MdfStream& fd, DrawingLayerDefinition* drawingLayer, Version* version);
 
     private:
+        static bool GetWatermarkVersion(Version* ldfVersion, Version& wmVersion);
         DrawingLayerDefinition* m_layer;
 };
 

Modified: trunk/MgDev/Common/MdfParser/IOGridLayerDefinition.cpp
===================================================================
--- trunk/MgDev/Common/MdfParser/IOGridLayerDefinition.cpp	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/MdfParser/IOGridLayerDefinition.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -18,6 +18,7 @@
 #include "stdafx.h"
 #include "IOGridLayerDefinition.h"
 #include "IOGridScaleRange.h"
+#include "IOWatermarkInstance.h"
 #include "IOUnknown.h"
 
 using namespace XERCES_CPP_NAMESPACE;
@@ -33,6 +34,8 @@
 ELEM_MAP_ENTRY(6, Filter);
 ELEM_MAP_ENTRY(7, GridScaleRange);
 ELEM_MAP_ENTRY(8, ExtendedData1);
+ELEM_MAP_ENTRY(9, Watermarks);
+ELEM_MAP_ENTRY(10, Watermark);
 
 
 IOGridLayerDefinition::IOGridLayerDefinition(Version& version) : SAX2ElementHandler(version)
@@ -63,6 +66,20 @@
         this->m_startElemName = name;
         break;
 
+    case eWatermark:
+        {
+            Version wdVersion;
+            if (!IOGridLayerDefinition::GetWatermarkVersion(
+                &this->m_version, wdVersion))
+                return;
+            WatermarkInstance* layerWatermark = new WatermarkInstance(L"", L"");
+            this->m_layer->GetWatermarks()->Adopt(layerWatermark);
+            IOWatermarkInstance* IO = new IOWatermarkInstance(layerWatermark, wdVersion);
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
+        break;
+
     case eGridScaleRange:
         {
             IOGridScaleRange* IO = new IOGridScaleRange(this->m_layer, this->m_version);
@@ -126,6 +143,14 @@
     }
 }
 
+// Determine which WatermarkDefinition schema version to use based
+// on the supplied LDF version:
+// * LDF version <= 1.4.0  =>  WD version 1.0.0
+bool IOGridLayerDefinition::GetWatermarkVersion(Version* ldfVersion, Version& wmVersion)
+{
+    wmVersion = Version(1, 0, 0);
+    return true;
+}
 
 void IOGridLayerDefinition::Write(MdfStream& fd, GridLayerDefinition* gridLayer, Version* version)
 {
@@ -138,9 +163,9 @@
             // LDF in MapGuide 2006
             strVersion = L"1.0.0";
         }
-        else if ((*version >= Version(1, 0, 0)) && (*version <= Version(1, 3, 0)))
+        else if ((*version >= Version(1, 0, 0)) && (*version <= Version(1, 4, 0)))
         {
-            // LDF in MapGuide 2007 / 2008 / 2009 / 2010
+            // LDF in MapGuide 2007 / 2008 / 2009 / 2010 / 2012
             strVersion = version->ToString();
         }
         else
@@ -154,7 +179,7 @@
     else
     {
         // use the current highest version
-        strVersion = L"1.3.0";
+        strVersion = L"1.4.0";
     }
 
     fd << tab() << "<LayerDefinition xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"LayerDefinition-" << EncodeString(strVersion) << ".xsd\" version=\"" << EncodeString(strVersion) << "\">" << std::endl; // NOXLATE
@@ -176,6 +201,21 @@
         fd << endStr(sOpacity) << std::endl;
     }
 
+    //Property: LayerWatermark (Optional)
+    if(*version >= Version(1, 4, 0))
+    {
+        int watermarkCount = gridLayer->GetWatermarks()->GetCount();
+        if(watermarkCount != 0)
+        {
+            fd << tab() << startStr(sWatermarks) << std::endl; // NOXLATE
+            inctab();
+            for (int i=0; i<watermarkCount; ++i)
+                IOWatermarkInstance::Write(fd, gridLayer->GetWatermarks()->GetAt(i), version);
+            dectab();
+            fd << endStr(sWatermarks) << std::endl; // NOXLATE
+        }
+    }
+
     // Property: FeatureName
     fd << tab() << startStr(sFeatureName);
     fd << EncodeString(gridLayer->GetFeatureName());

Modified: trunk/MgDev/Common/MdfParser/IOGridLayerDefinition.h
===================================================================
--- trunk/MgDev/Common/MdfParser/IOGridLayerDefinition.h	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/MdfParser/IOGridLayerDefinition.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -41,6 +41,7 @@
         static void Write(MdfStream& fd, GridLayerDefinition* gridLayer, Version* version);
 
     private:
+        static bool GetWatermarkVersion(Version* ldfVersion, Version& wmVersion);
         GridLayerDefinition* m_layer;
 };
 

Modified: trunk/MgDev/Common/MdfParser/IOMapDefinition.cpp
===================================================================
--- trunk/MgDev/Common/MdfParser/IOMapDefinition.cpp	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/MdfParser/IOMapDefinition.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -21,6 +21,7 @@
 #include "IOFill.h"
 #include "IOMapLayer.h"
 #include "IOMapLayerGroup.h"
+#include "IOWatermarkInstance.h"
 #include "IOBaseMapDefinition.h"
 
 using namespace XERCES_CPP_NAMESPACE;
@@ -73,6 +74,18 @@
             handlerStack->push(IO);
             IO->StartElement(name, handlerStack);
         }
+        else if (this->m_currElemName == L"Watermark") // NOXLATE
+        {
+            Version wdVersion;
+            if (!IOMapDefinition::GetWatermarkVersion(
+                &this->m_version, wdVersion))
+                return;
+            WatermarkInstance* mapWatermark = new WatermarkInstance(L"", L"");
+            this->m_map->GetWatermarks()->Adopt(mapWatermark);
+            IOWatermarkInstance* IO = new IOWatermarkInstance(mapWatermark, wdVersion);
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
         else if (this->m_currElemName == L"BaseMapDefinition") // NOXLATE
         {
             IOBaseMapDefinition* IO = new IOBaseMapDefinition(this->m_map, this->m_version);
@@ -107,10 +120,26 @@
     }
 }
 
+// Determine which WatermarkDefinition schema version to use based
+// on the supplied LDF version:
+// * MDF version <= 1.1.0  =>  WD version 1.0.0
+bool IOMapDefinition::GetWatermarkVersion(Version* mdfVersion, Version& wmVersion)
+{
+    wmVersion = Version(1, 0, 0);
+    return true;
+}
 
 void IOMapDefinition::Write(MdfStream& fd, MapDefinition* map, Version* version)
 {
-    fd << tab() << "<MapDefinition xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"MapDefinition-1.0.0.xsd\">" << std::endl; // NOXLATE
+    MdfString strVersion = version ? version->ToString() : L"1.1.0";
+    if(*version <= Version(1, 0, 0))
+    {
+        fd << tab() << "<MapDefinition xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"MapDefinition-1.0.0.xsd\">" << std::endl; // NOXLATE
+    }
+    else
+    {
+        fd << tab() << "<MapDefinition xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"MapDefinition-" << EncodeString(strVersion) << ".xsd\" version=\"" << EncodeString(strVersion) << "\">" << std::endl; // NOXLATE
+    }
     inctab();
 
     // Property: Name
@@ -150,6 +179,21 @@
     if (map->GetFiniteDisplayScales()->GetCount() > 0)
         IOBaseMapDefinition::Write(fd, map, version);
 
+    //Property: MapWatermark (Optional)
+    if(*version >= Version(1, 1, 0))
+    {
+        int watermarkCount = map->GetWatermarks()->GetCount();
+        if(watermarkCount != 0)
+        {
+            fd << tab() << startStr("Watermarks") << std::endl; // NOXLATE
+            inctab();
+            for (int i=0; i<watermarkCount; ++i)
+                IOWatermarkInstance::Write(fd, map->GetWatermarks()->GetAt(i), version);
+            dectab();
+            fd << endStr("Watermarks") << std::endl; // NOXLATE
+        }
+    }
+
     dectab();
     fd << tab() << "</MapDefinition>" << std::endl; // NOXLATE
 }

Modified: trunk/MgDev/Common/MdfParser/IOMapDefinition.h
===================================================================
--- trunk/MgDev/Common/MdfParser/IOMapDefinition.h	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/MdfParser/IOMapDefinition.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -41,6 +41,7 @@
         static void Write(MdfStream& fd, MapDefinition* map, Version* version);
 
     private:
+        static bool GetWatermarkVersion(Version* mdfVersion, Version& wmVersion);
         MapDefinition* m_map;
 };
 

Added: trunk/MgDev/Common/MdfParser/IOTileWatermarkPosition.cpp
===================================================================
--- trunk/MgDev/Common/MdfParser/IOTileWatermarkPosition.cpp	                        (rev 0)
+++ trunk/MgDev/Common/MdfParser/IOTileWatermarkPosition.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,128 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#include "stdafx.h"
+#include "IOTileWatermarkPosition.h"
+#include "IOWatermarkXOffset.h"
+#include "IOWatermarkYOffset.h"
+
+using namespace XERCES_CPP_NAMESPACE;
+using namespace MDFMODEL_NAMESPACE;
+using namespace MDFPARSER_NAMESPACE;
+
+CREATE_ELEMENT_MAP;
+ELEM_MAP_ENTRY(1, TilePosition);
+ELEM_MAP_ENTRY(2, HorizontalPosition);
+ELEM_MAP_ENTRY(3, VerticalPosition);
+ELEM_MAP_ENTRY(4, TileWidth);
+ELEM_MAP_ENTRY(5, TileHeight);
+
+IOTileWatermarkPosition::IOTileWatermarkPosition(Version& version)
+: SAX2ElementHandler(version), m_position(NULL)
+{
+}
+
+
+IOTileWatermarkPosition::IOTileWatermarkPosition(TileWatermarkPosition* position, Version& version)
+: SAX2ElementHandler(version), m_position(position)
+{
+}
+
+
+IOTileWatermarkPosition::~IOTileWatermarkPosition()
+{
+    delete this->m_position;
+}
+
+
+void IOTileWatermarkPosition::StartElement(const wchar_t* name, HandlerStack* handlerStack)
+{
+    this->m_currElemName = name;
+    this->m_currElemId = _ElementIdFromName(name);
+
+    switch (this->m_currElemId)
+    {
+    case eTilePosition:
+        this->m_startElemName = name;
+        break;
+    case eHorizontalPosition:
+        {
+            WatermarkXOffset* horizontalOffset = new WatermarkXOffset();
+            this->m_position->AdoptHorizontalPosition(horizontalOffset);
+            IOWatermarkXOffset* IO = new IOWatermarkXOffset(horizontalOffset, this->m_version);
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
+        break;
+    case eVerticalPosition:
+        {
+            WatermarkYOffset* verticalOffset = new WatermarkYOffset();
+            this->m_position->AdoptVerticalPosition(verticalOffset);
+            IOWatermarkYOffset* IO = new IOWatermarkYOffset(verticalOffset, this->m_version);
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
+        break;
+    }
+}
+
+
+void IOTileWatermarkPosition::ElementChars(const wchar_t* ch)
+{
+    switch (this->m_currElemId)
+    {
+    case eTileWidth:
+        this->m_position->SetTileWidth(wstrToDouble(ch));
+        break;
+
+    case eTileHeight:
+        this->m_position->SetTileHeight(wstrToDouble(ch));
+        break;
+    }
+}
+
+
+void IOTileWatermarkPosition::EndElement(const wchar_t* name, HandlerStack* handlerStack)
+{
+    if (this->m_startElemName == name)
+    {
+        this->m_position = NULL;
+        this->m_startElemName = L"";
+        handlerStack->pop();
+        delete this;
+    }
+}
+
+
+void IOTileWatermarkPosition::Write(MdfStream& fd, TileWatermarkPosition* position, Version* version)
+{
+    fd << tab() << startStr(sTilePosition) << std::endl;
+    inctab();
+
+    fd << tab() << startStr(sTileWidth);
+    fd << DoubleToStr(position->GetTileWidth());
+    fd << endStr(sTileWidth) << std::endl;
+    fd << tab() << startStr(sTileHeight);
+    fd << DoubleToStr(position->GetTileHeight());
+    fd << endStr(sTileHeight) << std::endl;
+
+    IOWatermarkXOffset::Write(fd, position->GetHorizontalPosition(), version, sHorizontalPosition);
+    IOWatermarkYOffset::Write(fd, position->GetVerticalPosition(), version, sVerticalPosition);
+
+    dectab();
+    fd << tab() << endStr(sTilePosition) << std::endl;
+}

Added: trunk/MgDev/Common/MdfParser/IOTileWatermarkPosition.h
===================================================================
--- trunk/MgDev/Common/MdfParser/IOTileWatermarkPosition.h	                        (rev 0)
+++ trunk/MgDev/Common/MdfParser/IOTileWatermarkPosition.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,48 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef _IOTILEWATERMARKPOSITION_H
+#define _IOTILEWATERMARKPOSITION_H
+
+#include "SAX2ElementHandler.h"
+#include "TileWatermarkPosition.h"
+#include "Version.h"
+
+using namespace XERCES_CPP_NAMESPACE;
+using namespace MDFMODEL_NAMESPACE;
+
+BEGIN_NAMESPACE_MDFPARSER
+
+class IOTileWatermarkPosition : public SAX2ElementHandler
+{
+    public:
+        IOTileWatermarkPosition(Version& version);
+        IOTileWatermarkPosition(TileWatermarkPosition* position, Version& version);
+        virtual ~IOTileWatermarkPosition();
+
+        virtual void StartElement(const wchar_t* name, HandlerStack* handlerStack);
+        virtual void ElementChars(const wchar_t* ch);
+        virtual void EndElement(const wchar_t* name, HandlerStack* handlerStack);
+
+        static void Write(MdfStream& fd, TileWatermarkPosition* position, Version* version);
+
+    private:
+        TileWatermarkPosition* m_position;
+};
+
+END_NAMESPACE_MDFPARSER
+#endif // _IOTILEWATERMARKPOSITION_H

Modified: trunk/MgDev/Common/MdfParser/IOVectorLayerDefinition.cpp
===================================================================
--- trunk/MgDev/Common/MdfParser/IOVectorLayerDefinition.cpp	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/MdfParser/IOVectorLayerDefinition.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -19,6 +19,7 @@
 #include "IOVectorLayerDefinition.h"
 #include "IONameStringPair.h"
 #include "IOVectorScaleRange.h"
+#include "IOWatermarkInstance.h"
 #include "IOUnknown.h"
 
 using namespace XERCES_CPP_NAMESPACE;
@@ -38,6 +39,8 @@
 ELEM_MAP_ENTRY(10, ToolTip);
 ELEM_MAP_ENTRY(11, VectorScaleRange);
 ELEM_MAP_ENTRY(12, ExtendedData1);
+ELEM_MAP_ENTRY(13, Watermarks);
+ELEM_MAP_ENTRY(14, Watermark);
 
 
 IOVectorLayerDefinition::IOVectorLayerDefinition(Version& version) : SAX2ElementHandler(version)
@@ -68,6 +71,20 @@
         this->m_startElemName = name;
         break;
 
+    case eWatermark:
+        {
+            Version wdVersion;
+            if (!IOVectorLayerDefinition::GetWatermarkVersion(
+                &this->m_version, wdVersion))
+                return;
+            WatermarkInstance* layerWatermark = new WatermarkInstance(L"", L"");
+            this->m_layer->GetWatermarks()->Adopt(layerWatermark);
+            IOWatermarkInstance* IO = new IOWatermarkInstance(layerWatermark, wdVersion);
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
+        break;
+
     case ePropertyMapping:
         {
             IONameStringPair* IO = new IONameStringPair(this->m_layer, this->m_version);
@@ -154,7 +171,16 @@
     }
 }
 
+// Determine which WatermarkDefinition schema version to use based
+// on the supplied LDF version:
+// * LDF version <= 1.4.0  =>  WD version 1.0.0
+bool IOVectorLayerDefinition::GetWatermarkVersion(Version* ldfVersion, Version& wmVersion)
+{
+    wmVersion = Version(1, 0, 0);
+    return true;
+}
 
+
 void IOVectorLayerDefinition::Write(MdfStream& fd, VectorLayerDefinition* vectorLayer, Version* version)
 {
     // verify the LDF version
@@ -166,9 +192,9 @@
             // LDF in MapGuide 2006
             strVersion = L"1.0.0";
         }
-        else if ((*version >= Version(1, 0, 0)) && (*version <= Version(1, 3, 0)))
+        else if ((*version >= Version(1, 0, 0)) && (*version <= Version(1, 4, 0)))
         {
-            // LDF in MapGuide 2007 / 2008 / 2009 / 2010
+            // LDF in MapGuide 2007 / 2008 / 2009 / 2010 / 2012
             strVersion = version->ToString();
         }
         else
@@ -182,7 +208,7 @@
     else
     {
         // use the current highest version
-        strVersion = L"1.3.0";
+        strVersion = L"1.4.0";
     }
 
     fd << tab() << "<LayerDefinition xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"LayerDefinition-" << EncodeString(strVersion) << ".xsd\" version=\"" << EncodeString(strVersion) << "\">" << std::endl; // NOXLATE
@@ -204,6 +230,21 @@
         fd << endStr(sOpacity) << std::endl;
     }
 
+    //Property: LayerWatermark (Optional)
+    if(*version >= Version(1, 4, 0))
+    {
+        int watermarkCount = vectorLayer->GetWatermarks()->GetCount();
+        if(watermarkCount != 0)
+        {
+            fd << tab() << startStr(sWatermarks) << std::endl; // NOXLATE
+            inctab();
+            for (int i=0; i<watermarkCount; ++i)
+                IOWatermarkInstance::Write(fd, vectorLayer->GetWatermarks()->GetAt(i), version);
+            dectab();
+            fd << endStr(sWatermarks) << std::endl; // NOXLATE
+        }
+    }
+
     // Property: FeatureName
     fd << tab() << startStr(sFeatureName);
     fd << EncodeString(vectorLayer->GetFeatureName());

Modified: trunk/MgDev/Common/MdfParser/IOVectorLayerDefinition.h
===================================================================
--- trunk/MgDev/Common/MdfParser/IOVectorLayerDefinition.h	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/MdfParser/IOVectorLayerDefinition.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -41,6 +41,7 @@
         static void Write(MdfStream& fd, VectorLayerDefinition* vectorLayer, Version* version);
 
     private:
+        static bool GetWatermarkVersion(Version* ldfVersion, Version& wmVersion);
         VectorLayerDefinition* m_layer;
 };
 

Added: trunk/MgDev/Common/MdfParser/IOWatermarkAppearance.cpp
===================================================================
--- trunk/MgDev/Common/MdfParser/IOWatermarkAppearance.cpp	                        (rev 0)
+++ trunk/MgDev/Common/MdfParser/IOWatermarkAppearance.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,105 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#include "stdafx.h"
+#include "IOWatermarkAppearance.h"
+
+using namespace XERCES_CPP_NAMESPACE;
+using namespace MDFMODEL_NAMESPACE;
+using namespace MDFPARSER_NAMESPACE;
+
+CREATE_ELEMENT_MAP;
+ELEM_MAP_ENTRY(1, Appearance);
+ELEM_MAP_ENTRY(2, AppearanceOverride);
+ELEM_MAP_ENTRY(3, Transparency);
+ELEM_MAP_ENTRY(4, Rotation);
+
+IOWatermarkAppearance::IOWatermarkAppearance(Version& version)
+: SAX2ElementHandler(version), m_appearance(NULL)
+{
+}
+
+
+IOWatermarkAppearance::IOWatermarkAppearance(WatermarkAppearance* appearance, Version& version)
+: SAX2ElementHandler(version), m_appearance(appearance)
+{
+}
+
+
+IOWatermarkAppearance::~IOWatermarkAppearance()
+{
+    delete this->m_appearance;
+}
+
+
+void IOWatermarkAppearance::StartElement(const wchar_t* name, HandlerStack* handlerStack)
+{
+    this->m_currElemName = name;
+    this->m_currElemId = _ElementIdFromName(name);
+
+    switch (this->m_currElemId)
+    {
+    case eAppearance:
+        this->m_startElemName = name;
+        break;
+    case eAppearanceOverride:
+        this->m_startElemName = name;
+        break;
+    }
+}
+
+
+void IOWatermarkAppearance::ElementChars(const wchar_t* ch)
+{
+    switch (this->m_currElemId)
+    {
+    case eTransparency:
+        this->m_appearance->SetTransparency(wstrToDouble(ch));
+        break;
+
+    case eRotation:
+        this->m_appearance->SetRotation(wstrToDouble(ch));
+        break;
+    }
+}
+
+
+void IOWatermarkAppearance::EndElement(const wchar_t* name, HandlerStack* handlerStack)
+{
+    if (this->m_startElemName == name)
+    {
+        this->m_appearance = NULL;
+        this->m_startElemName = L"";
+        handlerStack->pop();
+        delete this;
+    }
+}
+
+
+void IOWatermarkAppearance::Write(MdfStream& fd, WatermarkAppearance* appearance, Version* version, const std::string& name)
+{
+    fd << tab() << startStr(name) << std::endl;
+    inctab();
+    fd << tab() << startStr(sTransparency);
+    fd << DoubleToStr(appearance->GetTransparency());
+    fd << endStr(sTransparency) << std::endl;
+    fd << tab() << startStr(sRotation);
+    fd << DoubleToStr(appearance->GetRotation());
+    fd << endStr(sRotation) << std::endl;
+    dectab();
+    fd << tab() << endStr(name) << std::endl;
+}

Added: trunk/MgDev/Common/MdfParser/IOWatermarkAppearance.h
===================================================================
--- trunk/MgDev/Common/MdfParser/IOWatermarkAppearance.h	                        (rev 0)
+++ trunk/MgDev/Common/MdfParser/IOWatermarkAppearance.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,48 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef _IOWATERMARKAPPEARANCE_H
+#define _IOWATERMARKAPPEARANCE_H
+
+#include "SAX2ElementHandler.h"
+#include "WatermarkAppearance.h"
+#include "Version.h"
+
+using namespace XERCES_CPP_NAMESPACE;
+using namespace MDFMODEL_NAMESPACE;
+
+BEGIN_NAMESPACE_MDFPARSER
+
+class IOWatermarkAppearance : public SAX2ElementHandler
+{
+    public:
+        IOWatermarkAppearance(Version& version);
+        IOWatermarkAppearance(WatermarkAppearance* appearance, Version& version);
+        virtual ~IOWatermarkAppearance();
+
+        virtual void StartElement(const wchar_t* name, HandlerStack* handlerStack);
+        virtual void ElementChars(const wchar_t* ch);
+        virtual void EndElement(const wchar_t* name, HandlerStack* handlerStack);
+
+        static void Write(MdfStream& fd, WatermarkAppearance* appearance, Version* version, const std::string& name);
+
+    private:
+        WatermarkAppearance* m_appearance;
+};
+
+END_NAMESPACE_MDFPARSER
+#endif // _IOWATERMARKAPPEARANCE_H

Added: trunk/MgDev/Common/MdfParser/IOWatermarkDefinition.cpp
===================================================================
--- trunk/MgDev/Common/MdfParser/IOWatermarkDefinition.cpp	                        (rev 0)
+++ trunk/MgDev/Common/MdfParser/IOWatermarkDefinition.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,219 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#include "stdafx.h"
+#include "IOWatermarkDefinition.h"
+#include "IOSimpleSymbolDefinition.h"
+#include "IOCompoundSymbolDefinition.h"
+#include "IOWatermarkAppearance.h"
+#include "IOXYWatermarkPosition.h"
+#include "IOTileWatermarkPosition.h"
+
+using namespace XERCES_CPP_NAMESPACE;
+using namespace MDFMODEL_NAMESPACE;
+using namespace MDFPARSER_NAMESPACE;
+
+CREATE_ELEMENT_MAP;
+ELEM_MAP_ENTRY(1, WatermarkDefinition);
+ELEM_MAP_ENTRY(2, WatermarkSource);
+ELEM_MAP_ENTRY(3, SimpleSymbolDefinition);
+ELEM_MAP_ENTRY(4, CompoundSymbolDefinition);
+ELEM_MAP_ENTRY(5, Appearance);
+ELEM_MAP_ENTRY(6, Position);
+ELEM_MAP_ENTRY(7, XYPosition);
+ELEM_MAP_ENTRY(8, TilePosition);
+ELEM_MAP_ENTRY(9, ExtendedData);
+
+IOWatermarkDefinition::IOWatermarkDefinition(Version& version) 
+: SAX2ElementHandler(version), m_watermark(NULL)
+{
+}
+
+
+IOWatermarkDefinition::IOWatermarkDefinition(WatermarkDefinition* watermark, Version& version)
+: SAX2ElementHandler(version), m_watermark(watermark)
+{
+}
+
+
+IOWatermarkDefinition::~IOWatermarkDefinition()
+{
+    delete this->m_watermark;
+}
+
+
+void IOWatermarkDefinition::StartElement(const wchar_t* name, HandlerStack* handlerStack)
+{
+    this->m_currElemName = name;
+    this->m_currElemId = _ElementIdFromName(name);
+
+    switch (this->m_currElemId)
+    {
+    case eWatermarkDefinition:
+        this->m_startElemName = name;
+        break;
+
+        //TODO: Other elements
+    case eSimpleSymbolDefinition:
+        {
+            Version sdVersion;
+            if (!IOWatermarkDefinition::GetSymbolDefinitionVersion(
+                &this->m_version, sdVersion))
+                return;
+
+            SimpleSymbolDefinition* simpleSymbol = new SimpleSymbolDefinition();
+            this->m_watermark->AdoptSource(simpleSymbol);
+            IOSimpleSymbolDefinition* IO = new IOSimpleSymbolDefinition(simpleSymbol, sdVersion);
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
+        break;
+    case eCompoundSymbolDefinition:
+        {
+            Version sdVersion;
+            if (!IOWatermarkDefinition::GetSymbolDefinitionVersion(
+                &this->m_version, sdVersion))
+                return;
+            CompoundSymbolDefinition* compoundSymbol = new CompoundSymbolDefinition();
+            this->m_watermark->AdoptSource(compoundSymbol);
+            IOCompoundSymbolDefinition* IO = new IOCompoundSymbolDefinition(
+                compoundSymbol, sdVersion);
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
+        break;
+    case eAppearance:
+        {
+            WatermarkAppearance* appearance = new WatermarkAppearance();
+            this->m_watermark->AdoptAppearance(appearance);
+            IOWatermarkAppearance* IO = new IOWatermarkAppearance(
+                appearance, this->m_version);
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
+        break;
+    case eXYPosition:
+        {
+            XYWatermarkPosition* position = new XYWatermarkPosition();
+            this->m_watermark->AdoptPosition(position);
+            IOXYWatermarkPosition* IO = new IOXYWatermarkPosition(
+                position, this->m_version);
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
+        break;
+    case eTilePosition:
+        {
+            TileWatermarkPosition* position = new TileWatermarkPosition();
+            this->m_watermark->AdoptPosition(position);
+            IOTileWatermarkPosition* IO = new IOTileWatermarkPosition(
+                position, this->m_version);
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
+        break;
+
+    case eExtendedData:
+        this->m_procExtData = true;
+        break;
+
+    case eUnknown:
+        ParseUnknownXml(name, handlerStack);
+        break;
+    }
+}
+
+
+void IOWatermarkDefinition::ElementChars(const wchar_t* ch)
+{
+}
+
+
+void IOWatermarkDefinition::EndElement(const wchar_t* name, HandlerStack* handlerStack)
+{
+    if (this->m_startElemName == name)
+    {
+        this->m_watermark->SetUnknownXml(this->m_unknownXml);
+
+        this->m_watermark = NULL;
+        this->m_startElemName = L"";
+        handlerStack->pop();
+        delete this;
+    }
+    else if (eExtendedData == _ElementIdFromName(name))
+    {
+        this->m_procExtData = false;
+    }
+}
+
+// Determine which SymbolDefinition schema version to use based
+// on the supplied WDF version:
+// * WDF version <= 1.0.0  =>  SD version 1.1.0
+bool IOWatermarkDefinition::GetSymbolDefinitionVersion(Version* wmVersion, Version& sdVersion)
+{
+    sdVersion = Version(1, 1, 0);
+    return true;
+}
+
+
+void IOWatermarkDefinition::Write(MdfStream& fd, WatermarkDefinition* watermark, Version* version)
+{
+    MdfString strVersion = version->ToString();
+    fd << tab() << "<WatermarkDefinition xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"WatermarkDefinition-" << EncodeString(strVersion) << ".xsd\" version=\"" << EncodeString(strVersion) << "\">" << std::endl; // NOXLATE
+    inctab();
+
+    fd << tab() << startStr(sWatermarkSource) << std::endl;
+    inctab();
+
+    SymbolDefinition* symbol = watermark->GetSource();
+    Version sdVersion;
+    if (IOWatermarkDefinition::GetSymbolDefinitionVersion(version, sdVersion))
+    {
+        SimpleSymbolDefinition* simpleSymbol = dynamic_cast<SimpleSymbolDefinition*>(symbol);
+        CompoundSymbolDefinition* compoundSymbol = dynamic_cast<CompoundSymbolDefinition*>(symbol);
+
+        if (simpleSymbol)
+            IOSimpleSymbolDefinition::Write(fd, simpleSymbol, false, &sdVersion);
+        else if (compoundSymbol)
+            IOCompoundSymbolDefinition::Write(fd, compoundSymbol, false, &sdVersion);
+    }
+
+    dectab();
+    fd << endStr(sWatermarkSource) << std::endl;
+
+    IOWatermarkAppearance::Write(fd, watermark->GetAppearance(), version, sAppearance);
+
+    fd << tab() << startStr(sPosition) << std::endl;
+    inctab();
+
+    WatermarkPosition* position = watermark->GetPosition();
+    XYWatermarkPosition* xyPosition = dynamic_cast<XYWatermarkPosition*>(position);
+    TileWatermarkPosition* tilePosition = dynamic_cast<TileWatermarkPosition*>(position);
+
+    if (xyPosition)
+        IOXYWatermarkPosition::Write(fd, xyPosition, version);
+    else if (tilePosition)
+        IOTileWatermarkPosition::Write(fd, tilePosition, version);
+
+    dectab();
+    fd << endStr(sPosition) << std::endl;
+
+    //Position
+
+    dectab();
+    fd << tab() << "</WatermarkDefinition>" << std::endl; // NOXLATE
+}

Added: trunk/MgDev/Common/MdfParser/IOWatermarkDefinition.h
===================================================================
--- trunk/MgDev/Common/MdfParser/IOWatermarkDefinition.h	                        (rev 0)
+++ trunk/MgDev/Common/MdfParser/IOWatermarkDefinition.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,51 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef _IOWATERMARKDEFINITION_H
+#define _IOWATERMARKDEFINITION_H
+
+#include "SAX2ElementHandler.h"
+#include "WatermarkDefinition.h"
+#include "Version.h"
+
+using namespace XERCES_CPP_NAMESPACE;
+using namespace MDFMODEL_NAMESPACE;
+
+BEGIN_NAMESPACE_MDFPARSER
+
+class IOWatermarkDefinition : public SAX2ElementHandler
+{
+    public:
+        IOWatermarkDefinition(Version& version);
+        IOWatermarkDefinition(WatermarkDefinition* watermark, Version& version);
+        virtual ~IOWatermarkDefinition();
+
+        virtual void StartElement(const wchar_t* name, HandlerStack* handlerStack);
+        virtual void ElementChars(const wchar_t* ch);
+        virtual void EndElement(const wchar_t* name, HandlerStack* handlerStack);
+
+        static void Write(MdfStream& fd, WatermarkDefinition* watermark, Version* version);
+
+    private:
+        static bool GetSymbolDefinitionVersion(Version* wdfVersion, Version& sdVersion);
+
+    private:
+        WatermarkDefinition* m_watermark;
+};
+
+END_NAMESPACE_MDFPARSER
+#endif // _IOWATERMARKDEFINITION_H

Added: trunk/MgDev/Common/MdfParser/IOWatermarkInstance.cpp
===================================================================
--- trunk/MgDev/Common/MdfParser/IOWatermarkInstance.cpp	                        (rev 0)
+++ trunk/MgDev/Common/MdfParser/IOWatermarkInstance.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,182 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#include "stdafx.h"
+#include "IOWatermarkInstance.h"
+#include "IOWatermarkAppearance.h"
+#include "IOXYWatermarkPosition.h"
+#include "IOTileWatermarkPosition.h"
+
+using namespace XERCES_CPP_NAMESPACE;
+using namespace MDFMODEL_NAMESPACE;
+using namespace MDFPARSER_NAMESPACE;
+
+CREATE_ELEMENT_MAP;
+ELEM_MAP_ENTRY(1, Watermark);
+ELEM_MAP_ENTRY(2, Name);
+ELEM_MAP_ENTRY(3, ResourceId);
+ELEM_MAP_ENTRY(4, Usage);
+ELEM_MAP_ENTRY(5, AppearanceOverride);
+ELEM_MAP_ENTRY(6, PositionOverride);
+ELEM_MAP_ENTRY(7, XYPosition);
+ELEM_MAP_ENTRY(8, TilePosition);
+ELEM_MAP_ENTRY(9, ExtendedData);
+
+IOWatermarkInstance::IOWatermarkInstance(Version& version)
+: SAX2ElementHandler(version), m_watermark(NULL)
+{
+}
+
+
+IOWatermarkInstance::IOWatermarkInstance(WatermarkInstance* watermark, Version& version) : SAX2ElementHandler(version), m_watermark(watermark)
+{
+}
+
+
+IOWatermarkInstance::~IOWatermarkInstance()
+{
+    delete this->m_watermark;
+}
+
+
+void IOWatermarkInstance::StartElement(const wchar_t* name, HandlerStack* handlerStack)
+{
+    this->m_currElemName = name;
+    this->m_currElemId = _ElementIdFromName(name);
+
+    switch (this->m_currElemId)
+    {
+    case eWatermark:
+        this->m_startElemName = name;
+        break;
+    case eAppearanceOverride:
+        {
+            WatermarkAppearance* appearance = new WatermarkAppearance();
+            this->m_watermark->AdoptAppearanceOverride(appearance);
+            IOWatermarkAppearance* IO = new IOWatermarkAppearance(appearance, this->m_version);
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
+        break;
+    case eXYPosition:
+        {
+            XYWatermarkPosition* position = new XYWatermarkPosition();
+            this->m_watermark->AdoptPositionOverride(position);
+            IOXYWatermarkPosition* IO = new IOXYWatermarkPosition(position, this->m_version);
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
+        break;
+    case eTilePosition:
+        {
+            TileWatermarkPosition* position = new TileWatermarkPosition();
+            this->m_watermark->AdoptPositionOverride(position);
+            IOTileWatermarkPosition* IO = new IOTileWatermarkPosition(position, this->m_version);
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
+        break;
+    case eExtendedData:
+        this->m_procExtData = true;
+        break;
+    }
+}
+
+void IOWatermarkInstance::ElementChars(const wchar_t* ch)
+{
+    switch (this->m_currElemId)
+    {
+    case eName:
+        this->m_watermark->SetName(ch);
+        break;
+
+    case eResourceId:
+        this->m_watermark->SetWatermarkResourceID(ch);
+        break;
+    case eUsage:
+        if (::wcscmp(ch, L"WMS") == 0) // NOXLATE
+            this->m_watermark->SetUsage(WatermarkInstance::WMS);
+        else if (::wcscmp(ch, L"Viewer") == 0) // NOXLATE
+            this->m_watermark->SetUsage(WatermarkInstance::Viewer);
+        else
+            this->m_watermark->SetUsage(WatermarkInstance::ALL);  //Treat as "ALL" if string is incorrect
+        break;
+    }
+}
+
+
+void IOWatermarkInstance::EndElement(const wchar_t* name, HandlerStack* handlerStack)
+{
+    if (this->m_startElemName == name)
+    {
+        this->m_watermark = NULL;
+        this->m_startElemName = L"";
+        handlerStack->pop();
+        delete this;
+    }
+}
+
+
+void IOWatermarkInstance::Write(MdfStream& fd, WatermarkInstance* watermark, Version* version)
+{
+    fd << tab() << startStr(sWatermark) << std::endl;
+    inctab();
+
+    fd << tab() << startStr(sName);
+    fd << EncodeString(watermark->GetName());
+    fd << endStr(sName) << std::endl;
+    fd << tab() << startStr(sResourceId);
+    fd << EncodeString(watermark->GetWatermarkResourceID());
+    fd << endStr(sResourceId) << std::endl;
+
+    fd << tab() << startStr(sUsage);
+    WatermarkInstance::Usage usage = watermark->GetUsage();
+    if(usage == WatermarkInstance::WMS)
+        fd << "WMS"; // NOXLATE
+    else if(usage == WatermarkInstance::Viewer)
+        fd << "Viewer"; // NOXLATE
+    else
+        fd << "ALL";     //Treat "ALL" as default value
+    fd << endStr(sUsage) << std::endl;
+
+    WatermarkAppearance* appearanceOverride = watermark->GetAppearanceOverride();
+    if(appearanceOverride)
+    {
+        IOWatermarkAppearance::Write(fd, appearanceOverride, version, sAppearanceOverride);
+    }
+    
+    WatermarkPosition* positionOverride = watermark->GetPositionOverride();
+    if(positionOverride)
+    {
+        fd << tab() << startStr(sPositionOverride) << std::endl;
+        inctab();
+
+        XYWatermarkPosition* xyPositionOverride = dynamic_cast<XYWatermarkPosition*>(positionOverride);
+        TileWatermarkPosition* tilePositionOverride = dynamic_cast<TileWatermarkPosition*>(positionOverride);
+
+        if (xyPositionOverride)
+            IOXYWatermarkPosition::Write(fd, xyPositionOverride, version);
+        else if (tilePositionOverride)
+            IOTileWatermarkPosition::Write(fd, tilePositionOverride, version);
+
+        dectab();
+        fd << endStr(sPositionOverride) << std::endl;
+    }
+
+    dectab();
+    fd << tab() << endStr(sWatermark) << std::endl;
+}

Added: trunk/MgDev/Common/MdfParser/IOWatermarkInstance.h
===================================================================
--- trunk/MgDev/Common/MdfParser/IOWatermarkInstance.h	                        (rev 0)
+++ trunk/MgDev/Common/MdfParser/IOWatermarkInstance.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,48 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef _IOWATERMARKINSTANCE_H
+#define _IOWATERMARKINSTANCE_H
+
+#include "SAX2ElementHandler.h"
+#include "WatermarkInstance.h"
+#include "Version.h"
+
+using namespace XERCES_CPP_NAMESPACE;
+using namespace MDFMODEL_NAMESPACE;
+
+BEGIN_NAMESPACE_MDFPARSER
+
+class IOWatermarkInstance : public SAX2ElementHandler
+{
+    public:
+        IOWatermarkInstance(Version& version);
+        IOWatermarkInstance(WatermarkInstance* watermark, Version& version);
+        virtual ~IOWatermarkInstance();
+
+        virtual void StartElement(const wchar_t* name, HandlerStack* handlerStack);
+        virtual void ElementChars(const wchar_t* ch);
+        virtual void EndElement(const wchar_t* name, HandlerStack* handlerStack);
+
+        static void Write(MdfStream& fd, WatermarkInstance* watermark, Version* version);
+
+    private:
+        WatermarkInstance* m_watermark;
+};
+
+END_NAMESPACE_MDFPARSER
+#endif // _IOWATERMARKINSTANCE_H

Added: trunk/MgDev/Common/MdfParser/IOWatermarkOffsetUnit.cpp
===================================================================
--- trunk/MgDev/Common/MdfParser/IOWatermarkOffsetUnit.cpp	                        (rev 0)
+++ trunk/MgDev/Common/MdfParser/IOWatermarkOffsetUnit.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,55 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#include "stdafx.h"
+#include "IOWatermarkOffsetUnit.h"
+
+using namespace XERCES_CPP_NAMESPACE;
+using namespace MDFMODEL_NAMESPACE;
+using namespace MDFPARSER_NAMESPACE;
+
+
+WatermarkOffset::WatermarkOffsetUnit IOWatermarkOffsetUnit::ParseWatermarkOffsetUnit(
+    const wchar_t* ch)
+{
+    if (::wcscmp(ch, L"Inches") == 0) // NOXLATE
+        return WatermarkOffset::Inches;
+    else if (::wcscmp(ch, L"Centimeters") == 0) // NOXLATE
+        return WatermarkOffset::Centimeters;
+    else if (::wcscmp(ch, L"Millimeters") == 0) // NOXLATE
+        return WatermarkOffset::Millimeters;
+    else if (::wcscmp(ch, L"Points") == 0) // NOXLATE
+        return WatermarkOffset::Points;
+    else    // Treat as "Pixels" if string is incorrect
+        return WatermarkOffset::Pixels;    
+}
+
+void IOWatermarkOffsetUnit::Write(MdfStream& fd, WatermarkOffset::WatermarkOffsetUnit offsetUnit)
+{
+    fd << tab() << startStr("Unit"); // NOXLATE
+    if(offsetUnit == WatermarkOffset::Inches)
+        fd << "Inches"; // NOXLATE
+    else if (offsetUnit == WatermarkOffset::Centimeters)
+        fd << "Centimeters"; // NOXLATE
+    else if (offsetUnit == WatermarkOffset::Millimeters)
+        fd << "Millimeters"; // NOXLATE
+    else if (offsetUnit == WatermarkOffset::Points)
+        fd << "Points"; // NOXLATE
+    else    // Treat "Pixels" as default one
+        fd << "Pixels"; // NOXLATE
+    fd << endStr("Unit") << std::endl; // NOXLATE
+}

Added: trunk/MgDev/Common/MdfParser/IOWatermarkOffsetUnit.h
===================================================================
--- trunk/MgDev/Common/MdfParser/IOWatermarkOffsetUnit.h	                        (rev 0)
+++ trunk/MgDev/Common/MdfParser/IOWatermarkOffsetUnit.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,40 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef _IOWATERMARKOFFSETUNIT_H
+#define _IOWATERMARKOFFSETUNIT_H
+
+#include "SAX2ElementHandler.h"
+#include "WatermarkOffsetUnit.h"
+#include "Version.h"
+
+using namespace XERCES_CPP_NAMESPACE;
+using namespace MDFMODEL_NAMESPACE;
+
+BEGIN_NAMESPACE_MDFPARSER
+
+class IOWatermarkOffsetUnit
+{
+    public:
+        static WatermarkOffset::WatermarkOffsetUnit ParseWatermarkOffsetUnit(
+            const wchar_t* ch);
+
+        static void Write(MdfStream& fd, WatermarkOffset::WatermarkOffsetUnit offsetUnit);
+};
+
+END_NAMESPACE_MDFPARSER
+#endif // _IOWATERMARKOFFSETUNIT_H

Added: trunk/MgDev/Common/MdfParser/IOWatermarkXOffset.cpp
===================================================================
--- trunk/MgDev/Common/MdfParser/IOWatermarkXOffset.cpp	                        (rev 0)
+++ trunk/MgDev/Common/MdfParser/IOWatermarkXOffset.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,127 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#include "stdafx.h"
+#include "IOWatermarkXOffset.h"
+#include "IOWatermarkOffsetUnit.h"
+
+using namespace XERCES_CPP_NAMESPACE;
+using namespace MDFMODEL_NAMESPACE;
+using namespace MDFPARSER_NAMESPACE;
+
+CREATE_ELEMENT_MAP;
+ELEM_MAP_ENTRY(1, XPosition);
+ELEM_MAP_ENTRY(2, HorizontalPosition);
+ELEM_MAP_ENTRY(3, Offset);
+ELEM_MAP_ENTRY(4, Unit);
+ELEM_MAP_ENTRY(5, Alignment);
+
+IOWatermarkXOffset::IOWatermarkXOffset(Version& version)
+: SAX2ElementHandler(version), m_XOffset(NULL)
+{
+}
+
+
+IOWatermarkXOffset::IOWatermarkXOffset(WatermarkXOffset* xOffset, Version& version)
+: SAX2ElementHandler(version), m_XOffset(xOffset)
+{
+}
+
+
+IOWatermarkXOffset::~IOWatermarkXOffset()
+{
+    delete this->m_XOffset;
+}
+
+
+void IOWatermarkXOffset::StartElement(const wchar_t* name, HandlerStack* handlerStack)
+{
+    this->m_currElemName = name;
+    this->m_currElemId = _ElementIdFromName(name);
+
+    switch (this->m_currElemId)
+    {
+    case eXPosition:
+        this->m_startElemName = name;
+        break;
+    case eHorizontalPosition:
+        this->m_startElemName = name;
+        break;
+    }
+}
+
+
+void IOWatermarkXOffset::ElementChars(const wchar_t* ch)
+{
+    switch (this->m_currElemId)
+    {
+    case eOffset:
+        this->m_XOffset->SetLength(wstrToDouble(ch));
+        break;
+
+    case eAlignment:
+        if (::wcscmp(ch, L"Left") == 0) // NOXLATE
+            this->m_XOffset->SetAlignment(WatermarkXOffset::Left);
+        else if (::wcscmp(ch, L"Right") == 0) // NOXLATE
+            this->m_XOffset->SetAlignment(WatermarkXOffset::Right);
+        else
+            this->m_XOffset->SetAlignment(WatermarkXOffset::Center);  //Treat as "Center" if string is incorrect
+        break;
+    
+    case eUnit:
+        this->m_XOffset->SetUnit(IOWatermarkOffsetUnit::ParseWatermarkOffsetUnit(ch));
+        break;
+    }
+}
+
+
+void IOWatermarkXOffset::EndElement(const wchar_t* name, HandlerStack* handlerStack)
+{
+    if (this->m_startElemName == name)
+    {
+        this->m_XOffset = NULL;
+        this->m_startElemName = L"";
+        handlerStack->pop();
+        delete this;
+    }
+}
+
+
+void IOWatermarkXOffset::Write(MdfStream& fd, WatermarkXOffset* xOffset, Version* version, const std::string& name)
+{
+    fd << tab() << startStr(name) << std::endl;
+    inctab();
+
+    fd << tab() << startStr(sOffset);
+    fd << DoubleToStr(xOffset->GetLength());
+    fd << endStr(sOffset) << std::endl;
+
+    IOWatermarkOffsetUnit::Write(fd, xOffset->GetUnit());
+
+    fd << tab() << startStr(sAlignment);
+    WatermarkXOffset::HorizontalAlignment alignment = xOffset->GetAlignment();
+    if(alignment == WatermarkXOffset::Left)
+        fd << "Left"; // NOXLATE
+    else if(alignment == WatermarkXOffset::Right)
+        fd << "Right"; // NOXLATE
+    else    //Treat "Center" as default value
+        fd << "Center";      // NOXLATE
+    fd << endStr(sAlignment) << std::endl;
+
+    dectab();
+    fd << tab() << endStr(name) << std::endl;
+}

Added: trunk/MgDev/Common/MdfParser/IOWatermarkXOffset.h
===================================================================
--- trunk/MgDev/Common/MdfParser/IOWatermarkXOffset.h	                        (rev 0)
+++ trunk/MgDev/Common/MdfParser/IOWatermarkXOffset.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,48 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef _IOWATERMARKXOFFSET_H
+#define _IOWATERMARKXOFFSET_H
+
+#include "SAX2ElementHandler.h"
+#include "WatermarkXOffset.h"
+#include "Version.h"
+
+using namespace XERCES_CPP_NAMESPACE;
+using namespace MDFMODEL_NAMESPACE;
+
+BEGIN_NAMESPACE_MDFPARSER
+
+class IOWatermarkXOffset : public SAX2ElementHandler
+{
+    public:
+        IOWatermarkXOffset(Version& version);
+        IOWatermarkXOffset(WatermarkXOffset* xOffset, Version& version);
+        virtual ~IOWatermarkXOffset();
+
+        virtual void StartElement(const wchar_t* name, HandlerStack* handlerStack);
+        virtual void ElementChars(const wchar_t* ch);
+        virtual void EndElement(const wchar_t* name, HandlerStack* handlerStack);
+
+        static void Write(MdfStream& fd, WatermarkXOffset* xOffset, Version* version, const std::string& name);
+
+    private:
+        WatermarkXOffset* m_XOffset;
+};
+
+END_NAMESPACE_MDFPARSER
+#endif // _IOWATERMARKXOFFSET_H

Added: trunk/MgDev/Common/MdfParser/IOWatermarkYOffset.cpp
===================================================================
--- trunk/MgDev/Common/MdfParser/IOWatermarkYOffset.cpp	                        (rev 0)
+++ trunk/MgDev/Common/MdfParser/IOWatermarkYOffset.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,127 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#include "stdafx.h"
+#include "IOWatermarkYOffset.h"
+#include "IOWatermarkOffsetUnit.h"
+
+using namespace XERCES_CPP_NAMESPACE;
+using namespace MDFMODEL_NAMESPACE;
+using namespace MDFPARSER_NAMESPACE;
+
+CREATE_ELEMENT_MAP;
+ELEM_MAP_ENTRY(1, YPosition);
+ELEM_MAP_ENTRY(2, VerticalPosition);
+ELEM_MAP_ENTRY(3, Offset);
+ELEM_MAP_ENTRY(4, Unit);
+ELEM_MAP_ENTRY(5, Alignment);
+
+IOWatermarkYOffset::IOWatermarkYOffset(Version& version)
+: SAX2ElementHandler(version), m_YOffset(NULL)
+{
+}
+
+
+IOWatermarkYOffset::IOWatermarkYOffset(WatermarkYOffset* yOffset, Version& version)
+: SAX2ElementHandler(version), m_YOffset(yOffset)
+{
+}
+
+
+IOWatermarkYOffset::~IOWatermarkYOffset()
+{
+    delete this->m_YOffset;
+}
+
+
+void IOWatermarkYOffset::StartElement(const wchar_t* name, HandlerStack* handlerStack)
+{
+    this->m_currElemName = name;
+    this->m_currElemId = _ElementIdFromName(name);
+
+    switch (this->m_currElemId)
+    {
+    case eYPosition:
+        this->m_startElemName = name;
+        break;
+    case eVerticalPosition:
+        this->m_startElemName = name;
+        break;
+    }
+}
+
+
+void IOWatermarkYOffset::ElementChars(const wchar_t* ch)
+{
+    switch (this->m_currElemId)
+    {
+    case eOffset:
+        this->m_YOffset->SetLength(wstrToDouble(ch));
+        break;
+
+    case eAlignment:
+        if (::wcscmp(ch, L"Top") == 0) // NOXLATE
+            this->m_YOffset->SetAlignment(WatermarkYOffset::Top);
+        else if (::wcscmp(ch, L"Bottom") == 0) // NOXLATE
+            this->m_YOffset->SetAlignment(WatermarkYOffset::Bottom);
+        else
+            this->m_YOffset->SetAlignment(WatermarkYOffset::Center);  //Treat as "Center" if string is incorrect
+        break;
+    
+    case eUnit:
+        this->m_YOffset->SetUnit(IOWatermarkOffsetUnit::ParseWatermarkOffsetUnit(ch));
+        break;
+    }
+}
+
+
+void IOWatermarkYOffset::EndElement(const wchar_t* name, HandlerStack* handlerStack)
+{
+    if (this->m_startElemName == name)
+    {
+        this->m_YOffset = NULL;
+        this->m_startElemName = L"";
+        handlerStack->pop();
+        delete this;
+    }
+}
+
+
+void IOWatermarkYOffset::Write(MdfStream& fd, WatermarkYOffset* yOffset, Version* version, const std::string& name)
+{
+    fd << tab() << startStr(name) << std::endl;
+    inctab();
+
+    fd << tab() << startStr(sOffset);
+    fd << DoubleToStr(yOffset->GetLength());
+    fd << endStr(sOffset) << std::endl;
+
+    IOWatermarkOffsetUnit::Write(fd, yOffset->GetUnit());
+
+    fd << tab() << startStr(sAlignment);
+    WatermarkYOffset::VerticalAlignment alignment = yOffset->GetAlignment();
+    if(alignment == WatermarkYOffset::Top)
+        fd << "Top"; // NOXLATE
+    else if(alignment == WatermarkYOffset::Bottom)
+        fd << "Bottom"; // NOXLATE
+    else     //Treat "Center" as default value
+        fd << "Center"; // NOXLATE
+    fd << endStr(sAlignment) << std::endl;
+
+    dectab();
+    fd << tab() << endStr(name) << std::endl;
+}

Added: trunk/MgDev/Common/MdfParser/IOWatermarkYOffset.h
===================================================================
--- trunk/MgDev/Common/MdfParser/IOWatermarkYOffset.h	                        (rev 0)
+++ trunk/MgDev/Common/MdfParser/IOWatermarkYOffset.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,48 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef _IOWATERMARKYOFFSET_H
+#define _IOWATERMARKYOFFSET_H
+
+#include "SAX2ElementHandler.h"
+#include "WatermarkYOffset.h"
+#include "Version.h"
+
+using namespace XERCES_CPP_NAMESPACE;
+using namespace MDFMODEL_NAMESPACE;
+
+BEGIN_NAMESPACE_MDFPARSER
+
+class IOWatermarkYOffset : public SAX2ElementHandler
+{
+    public:
+        IOWatermarkYOffset(Version& version);
+        IOWatermarkYOffset(WatermarkYOffset* yOffset, Version& version);
+        virtual ~IOWatermarkYOffset();
+
+        virtual void StartElement(const wchar_t* name, HandlerStack* handlerStack);
+        virtual void ElementChars(const wchar_t* ch);
+        virtual void EndElement(const wchar_t* name, HandlerStack* handlerStack);
+
+        static void Write(MdfStream& fd, WatermarkYOffset* xOffset, Version* version, const std::string& name);
+
+    private:
+        WatermarkYOffset* m_YOffset;
+};
+
+END_NAMESPACE_MDFPARSER
+#endif // _IOWATERMARKYOFFSET_H

Added: trunk/MgDev/Common/MdfParser/IOXYWatermarkPosition.cpp
===================================================================
--- trunk/MgDev/Common/MdfParser/IOXYWatermarkPosition.cpp	                        (rev 0)
+++ trunk/MgDev/Common/MdfParser/IOXYWatermarkPosition.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,109 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#include "stdafx.h"
+#include "IOXYWatermarkPosition.h"
+#include "IOWatermarkXOffset.h"
+#include "IOWatermarkYOffset.h"
+
+using namespace XERCES_CPP_NAMESPACE;
+using namespace MDFMODEL_NAMESPACE;
+using namespace MDFPARSER_NAMESPACE;
+
+CREATE_ELEMENT_MAP;
+ELEM_MAP_ENTRY(1, XYPosition);
+ELEM_MAP_ENTRY(2, XPosition);
+ELEM_MAP_ENTRY(3, YPosition);
+
+IOXYWatermarkPosition::IOXYWatermarkPosition(Version& version)
+: SAX2ElementHandler(version), m_position(NULL)
+{
+}
+
+
+IOXYWatermarkPosition::IOXYWatermarkPosition(XYWatermarkPosition* position, Version& version)
+: SAX2ElementHandler(version), m_position(position)
+{
+}
+
+
+IOXYWatermarkPosition::~IOXYWatermarkPosition()
+{
+    delete this->m_position;
+}
+
+
+void IOXYWatermarkPosition::StartElement(const wchar_t* name, HandlerStack* handlerStack)
+{
+    this->m_currElemName = name;
+    this->m_currElemId = _ElementIdFromName(name);
+
+    switch (this->m_currElemId)
+    {
+    case eXYPosition:
+        this->m_startElemName = name;
+        break;
+    case eXPosition:
+        {
+            WatermarkXOffset* xOffset = new WatermarkXOffset();
+            this->m_position->AdoptXPosition(xOffset);
+            IOWatermarkXOffset* IO = new IOWatermarkXOffset(xOffset, this->m_version);
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
+        break;
+    case eYPosition:
+        {
+            WatermarkYOffset* yOffset = new WatermarkYOffset();
+            this->m_position->AdoptYPosition(yOffset);
+            IOWatermarkYOffset* IO = new IOWatermarkYOffset(yOffset, this->m_version);
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
+        break;
+    }
+}
+
+
+void IOXYWatermarkPosition::ElementChars(const wchar_t* ch)
+{
+}
+
+
+void IOXYWatermarkPosition::EndElement(const wchar_t* name, HandlerStack* handlerStack)
+{
+    if (this->m_startElemName == name)
+    {
+        this->m_position = NULL;
+        this->m_startElemName = L"";
+        handlerStack->pop();
+        delete this;
+    }
+}
+
+
+void IOXYWatermarkPosition::Write(MdfStream& fd, XYWatermarkPosition* position, Version* version)
+{
+    fd << tab() << startStr(sXYPosition) << std::endl;
+    inctab();
+
+    IOWatermarkXOffset::Write(fd, position->GetXPosition(), version, sXPosition);
+    IOWatermarkYOffset::Write(fd, position->GetYPosition(), version, sYPosition);
+
+    dectab();
+    fd << tab() << endStr(sXYPosition) << std::endl;
+}

Added: trunk/MgDev/Common/MdfParser/IOXYWatermarkPosition.h
===================================================================
--- trunk/MgDev/Common/MdfParser/IOXYWatermarkPosition.h	                        (rev 0)
+++ trunk/MgDev/Common/MdfParser/IOXYWatermarkPosition.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,48 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef _IOXYWATERMARKPOSITION_H
+#define _IOXYWATERMARKPOSITION_H
+
+#include "SAX2ElementHandler.h"
+#include "XYWatermarkPosition.h"
+#include "Version.h"
+
+using namespace XERCES_CPP_NAMESPACE;
+using namespace MDFMODEL_NAMESPACE;
+
+BEGIN_NAMESPACE_MDFPARSER
+
+class IOXYWatermarkPosition : public SAX2ElementHandler
+{
+    public:
+        IOXYWatermarkPosition(Version& version);
+        IOXYWatermarkPosition(XYWatermarkPosition* position, Version& version);
+        virtual ~IOXYWatermarkPosition();
+
+        virtual void StartElement(const wchar_t* name, HandlerStack* handlerStack);
+        virtual void ElementChars(const wchar_t* ch);
+        virtual void EndElement(const wchar_t* name, HandlerStack* handlerStack);
+
+        static void Write(MdfStream& fd, XYWatermarkPosition* position, Version* version);
+
+    private:
+        XYWatermarkPosition* m_position;
+};
+
+END_NAMESPACE_MDFPARSER
+#endif // _IOXYWATERMARKPOSITION_H

Modified: trunk/MgDev/Common/MdfParser/MdfParser.vcproj
===================================================================
--- trunk/MgDev/Common/MdfParser/MdfParser.vcproj	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/MdfParser/MdfParser.vcproj	2010-09-17 08:00:59 UTC (rev 5139)
@@ -1015,6 +1015,14 @@
 			>
 		</File>
 		<File
+			RelativePath=".\IOTileWatermarkPosition.cpp"
+			>
+		</File>
+		<File
+			RelativePath=".\IOTileWatermarkPosition.h"
+			>
+		</File>
+		<File
 			RelativePath=".\IOUnknown.cpp"
 			>
 		</File>
@@ -1055,6 +1063,62 @@
 			>
 		</File>
 		<File
+			RelativePath=".\IOWatermarkAppearance.cpp"
+			>
+		</File>
+		<File
+			RelativePath=".\IOWatermarkAppearance.h"
+			>
+		</File>
+		<File
+			RelativePath=".\IOWatermarkDefinition.cpp"
+			>
+		</File>
+		<File
+			RelativePath=".\IOWatermarkDefinition.h"
+			>
+		</File>
+		<File
+			RelativePath=".\IOWatermarkInstance.cpp"
+			>
+		</File>
+		<File
+			RelativePath=".\IOWatermarkInstance.h"
+			>
+		</File>
+		<File
+			RelativePath=".\IOWatermarkOffsetUnit.cpp"
+			>
+		</File>
+		<File
+			RelativePath=".\IOWatermarkOffsetUnit.h"
+			>
+		</File>
+		<File
+			RelativePath=".\IOWatermarkXOffset.cpp"
+			>
+		</File>
+		<File
+			RelativePath=".\IOWatermarkXOffset.h"
+			>
+		</File>
+		<File
+			RelativePath=".\IOWatermarkYOffset.cpp"
+			>
+		</File>
+		<File
+			RelativePath=".\IOWatermarkYOffset.h"
+			>
+		</File>
+		<File
+			RelativePath=".\IOXYWatermarkPosition.cpp"
+			>
+		</File>
+		<File
+			RelativePath=".\IOXYWatermarkPosition.h"
+			>
+		</File>
+		<File
 			RelativePath=".\MdfParser.cpp"
 			>
 		</File>

Modified: trunk/MgDev/Common/MdfParser/SAX2Parser.cpp
===================================================================
--- trunk/MgDev/Common/MdfParser/SAX2Parser.cpp	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/MdfParser/SAX2Parser.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -27,6 +27,7 @@
 #include "PrintLayout/IOPrintLayoutDefinition.h"
 #include "PrintLayout/IOPrintLayoutElementDefinition.h"
 #include "PrintLayout/IOMapViewportDefinition.h"
+#include "IOWatermarkDefinition.h"
 
 using namespace XERCES_CPP_NAMESPACE;
 using namespace MDFMODEL_NAMESPACE;
@@ -83,6 +84,8 @@
         delete m_printLayout;
     if (m_mapViewport != NULL)
         delete m_mapViewport;
+    if (m_watermark != NULL)
+        delete m_watermark;
 }
 
 
@@ -97,6 +100,7 @@
     m_cSymbol = NULL;
     m_printLayout = NULL;
     m_mapViewport = NULL;
+    m_watermark = NULL;
     m_succeeded = false;
 }
 
@@ -249,7 +253,16 @@
     return NULL;
 }
 
+// Returns a reference to the parser's watermark definition
+// After this call the parser no longer owns the object.
+WatermarkDefinition* SAX2Parser::DetachWatermarkDefinition()
+{
+    WatermarkDefinition* ret = m_watermark;
+    m_watermark= NULL;
+    return ret;
+}
 
+
 bool SAX2Parser::GetSucceeded() const
 {
     return m_succeeded;
@@ -399,7 +412,22 @@
     fd.close();
 }
 
+void SAX2Parser::WriteToFile(std::string name, WatermarkDefinition* watermark, Version* version)
+{
+    std::ofstream fd;
+    fd.open(name.c_str());
+    if (fd.is_open())
+    {
+        zerotab();
+        fd << tab() << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl; // NOXLATE
 
+        if (NULL != watermark)
+            IOWatermarkDefinition::Write(fd, watermark, version);
+    }
+    fd.close();
+}
+
+
 std::string SAX2Parser::SerializeToXML(MapDefinition* map, Version* version)
 {
     MdfStringStream fd;
@@ -469,7 +497,17 @@
     return fd.str();
 }
 
+std::string SAX2Parser::SerializeToXML(WatermarkDefinition* watermark, Version* version)
+{
+    MdfStringStream fd;
 
+    if (NULL != watermark)
+        IOWatermarkDefinition::Write(fd, watermark, version);
+
+    return fd.str();
+}
+
+
 void SAX2Parser::startElement(const XMLCh* const uri,
                               const XMLCh* const localname,
                               const XMLCh* const qname,
@@ -490,7 +528,7 @@
         if (str == L"MapDefinition") // NOXLATE
         {
             // set the version
-            m_version = Version(1, 0, 0);
+            SetMapDefinitionVersion(attributes);
 
             _ASSERT(m_map == NULL); // otherwise we leak
             m_map = new MapDefinition(L"", L"");
@@ -573,6 +611,16 @@
             m_handlerStack->push(IO);
             IO->StartElement(str.c_str(), m_handlerStack);
         }
+        else if (str == L"WatermarkDefinition") //NOXLATE
+        {
+            // set the version
+            SetWatermarkDefinitionVersion(attributes);
+            _ASSERT(m_watermark == NULL); // otherwise we leak
+            m_watermark = new WatermarkDefinition();
+            IOWatermarkDefinition* IO = new IOWatermarkDefinition(m_watermark, m_version);
+            m_handlerStack->push(IO);
+            IO->StartElement(str.c_str(), m_handlerStack);
+        }
     }
     // Otherwise, if the stack has items on it, just pass the event through.
     else
@@ -622,7 +670,30 @@
     return m_version;
 }
 
+void SAX2Parser::SetMapDefinitionVersion(const Attributes& attributes)
+{
+    // check for a version attribute
+    int index = attributes.getIndex(W2X(L"version"));
+    const XMLCh* verValue = (index >= 0)? attributes.getValue(index) : NULL;
 
+    // according to the schema map definition elements require a version
+    // attribute, but users may generate XML which is missing this attribute
+    if (verValue)
+    {
+        std::wstring version = X2W(verValue);
+
+        if (_wcsicmp(version.c_str(), L"1.0.0") == 0)
+            m_version = MdfModel::Version(1, 0, 0);
+        else if (_wcsicmp(version.c_str(), L"1.1.0") == 0)
+            m_version = MdfModel::Version(1, 1, 0);
+    }
+    else
+    {
+        // assume the latest version if the attribute is missing
+        m_version = MdfModel::Version(1, 1, 0);
+    }
+}
+
 void SAX2Parser::SetLayerDefinitionVersion(const Attributes& attributes)
 {
     // check for a version attribute
@@ -714,6 +785,29 @@
     }
 }
 
+void SAX2Parser::SetWatermarkDefinitionVersion(const Attributes& attributes)
+{
+    //Although right now we only have 1.0.0 here, this function is still needed for future expandation.
+    // check for a version attribute
+    int index = attributes.getIndex(W2X(L"version"));
+    const XMLCh* verValue = (index >= 0)? attributes.getValue(index) : NULL;
+
+    // according to the schema layer definition elements require a version
+    // attribute, but users may generate XML which is missing this attribute
+    if (verValue)
+    {
+        std::wstring version = X2W(verValue);
+
+        if (_wcsicmp(version.c_str(), L"1.0.0") == 0)
+            m_version = MdfModel::Version(1, 0, 0);
+    }
+    else
+    {
+        // assume the latest version if the attribute is missing
+        m_version = MdfModel::Version(1, 0, 0);
+    }
+}
+
 MapDefinition* SAX2Parser::CreateClone(MapDefinition* map)
 {
     _ASSERT(NULL != map);
@@ -787,3 +881,17 @@
 
     return parser.DetachSymbolDefinition();
 }
+
+WatermarkDefinition* SAX2Parser::CreateClone(WatermarkDefinition* watermark)
+{
+    _ASSERT(NULL != watermark);
+    if (NULL == watermark)
+        return NULL;
+
+    SAX2Parser parser;
+    std::string xmlOfWD("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");   // NOXLATE
+    xmlOfWD.append(parser.SerializeToXML(watermark, NULL));
+    parser.ParseString(xmlOfWD.c_str(), xmlOfWD.size());
+
+    return parser.DetachWatermarkDefinition();
+}

Modified: trunk/MgDev/Common/MdfParser/SAX2Parser.h
===================================================================
--- trunk/MgDev/Common/MdfParser/SAX2Parser.h	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/MdfParser/SAX2Parser.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -27,6 +27,7 @@
 #include "PrintLayout/PrintLayoutDefinition.h"
 #include "PrintLayout/PrintLayoutElementDefinition.h"
 #include "PrintLayout/MapViewportDefinition.h"
+#include "WatermarkDefinition.h"
 
 // disable C4244 of XSerializeEngine about __w64 int assigned to unsigned long
 // disable C4267 of XmlScanner about size_t assigned to unsigned int
@@ -80,6 +81,7 @@
                          MapViewportDefinition* mapViewport,
                          MdfModel::Version* version);
         void WriteToFile(std::string name, SymbolDefinition* symbol, MdfModel::Version* version);
+        void WriteToFile(std::string name, WatermarkDefinition* watermark, MdfModel::Version* version);
 
         // Serialization functions for the various Definitions the parser supports
         std::string SerializeToXML(MapDefinition* map, MdfModel::Version* version);
@@ -87,6 +89,7 @@
         std::string SerializeToXML(SymbolDefinition* symbol, MdfModel::Version* version);
         std::string SerializeToXML(PrintLayoutDefinition* printLayout, MdfModel::Version* version);
         std::string SerializeToXML(PrintLayoutElementDefinition* printLayoutElem, MdfModel::Version* version);
+        std::string SerializeToXML(WatermarkDefinition* watermark, MdfModel::Version* version);
 
         // Detaches the most recently parsed object from the parser.
         // The calling method is then responsible for disposing the object,
@@ -102,6 +105,7 @@
         PrintLayoutDefinition* DetachPrintLayoutDefinition();
         PrintLayoutElementDefinition* DetachPrintLayoutElementDefinition();
         MapViewportDefinition* DetachMapViewportDefinition();
+        WatermarkDefinition* DetachWatermarkDefinition();
 
         // Creates a clone of the given map/layer/symbol/print layout/print layout element definition.
         // The object is serialized and parsed into a new object, which is returned.
@@ -110,6 +114,7 @@
         static SymbolDefinition* CreateClone(SymbolDefinition* symbol);
         static PrintLayoutDefinition* CreateClone(PrintLayoutDefinition* printLayout);
         static PrintLayoutElementDefinition* CreateClone(PrintLayoutElementDefinition* printLayoutElem);
+        static WatermarkDefinition* CreateClone(WatermarkDefinition* watermark);
 
         // Success State
         bool GetSucceeded() const;
@@ -143,10 +148,12 @@
 
     private:
         // Helper methods to extract version info
+        void SetMapDefinitionVersion(const Attributes& attributes);
         void SetLayerDefinitionVersion(const Attributes& attributes);
         void SetSymbolDefinitionVersion(const Attributes& attributes);
         void SetPrintLayoutDefinitionVersion(const Attributes& attributes);
         void SetPrintLayoutElementDefinitionVersion(const Attributes& attributes);
+        void SetWatermarkDefinitionVersion(const Attributes& attributes);
 
     protected:
         // The objects to be generated by the parser.
@@ -158,6 +165,7 @@
         CompoundSymbolDefinition* m_cSymbol;
         PrintLayoutDefinition* m_printLayout;
         MapViewportDefinition* m_mapViewport;
+        WatermarkDefinition* m_watermark;
 
         // Succeeded is true if the parse has succeeded. As of now,
         // there are very loose constraints on this boolean.

Added: trunk/MgDev/Common/PlatformBase/Exception/InvalidWatermarkDefinitionException.cpp
===================================================================
--- trunk/MgDev/Common/PlatformBase/Exception/InvalidWatermarkDefinitionException.cpp	                        (rev 0)
+++ trunk/MgDev/Common/PlatformBase/Exception/InvalidWatermarkDefinitionException.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,40 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#include "PlatformBase.h"
+
+IMPLEMENT_EXCEPTION_DEFAULTS(MgInvalidWatermarkDefinitionException, MgApplicationException)
+
+///////////////////////////////////////////////////////////////////////////////
+/// \brief
+/// Construct a MgInvalidWatermarkDefinitionException object.
+///
+MgInvalidWatermarkDefinitionException::MgInvalidWatermarkDefinitionException(CREFSTRING methodName,
+    INT32 lineNumber, CREFSTRING fileName, MgStringCollection* whatArguments,
+    CREFSTRING whyMessageId, MgStringCollection* whyArguments) throw() :
+    MgApplicationException(methodName, lineNumber, fileName,
+        whatArguments, whyMessageId, whyArguments)
+{
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \brief
+/// Destruct the object.
+///
+MgInvalidWatermarkDefinitionException::~MgInvalidWatermarkDefinitionException() throw()
+{
+}

Added: trunk/MgDev/Common/PlatformBase/Exception/InvalidWatermarkDefinitionException.h
===================================================================
--- trunk/MgDev/Common/PlatformBase/Exception/InvalidWatermarkDefinitionException.h	                        (rev 0)
+++ trunk/MgDev/Common/PlatformBase/Exception/InvalidWatermarkDefinitionException.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,71 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef MG_INVALID_WATERMARK_DEFINITION_EXCEPTION_H_
+#define MG_INVALID_WATERMARK_DEFINITION_EXCEPTION_H_
+
+/// \ingroup Exceptions_Module
+
+#include "PlatformBase.h"
+
+///////////////////////////////////////////////////////////////////////////////
+/// \brief
+/// Thrown when a watermark definition resource is invalid.
+///
+class MG_PLATFORMBASE_API MgInvalidWatermarkDefinitionException : public MgApplicationException
+{
+    DECLARE_CLASSNAME(MgInvalidWatermarkDefinitionException)
+
+EXTERNAL_API:
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Construct a MgInvalidWatermarkDefinitionException object.
+    ///
+    /// \param methodName
+    /// Name of the method where the exception occurred.
+    /// \param lineNumber
+    /// Line number where the exception occurred.
+    /// \param fileName
+    /// File name where the exception occurred.
+    /// \param whatArguments
+    /// Collection of arguments used to format the message that describes what the exception is.
+    /// \param whyMessageId
+    /// ID of the message that describes why the exception occurs.
+    /// \param whyArguments
+    /// Collection of arguments used to format the message that describes why the exception occurs.
+    ///
+    MgInvalidWatermarkDefinitionException(CREFSTRING methodName, INT32 lineNumber,
+        CREFSTRING fileName, MgStringCollection* whatArguments,
+        CREFSTRING whyMessageId, MgStringCollection* whyArguments) throw();
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Destructor for a MgInvalidWatermarkDefinitionException object.
+    ///
+    virtual ~MgInvalidWatermarkDefinitionException() throw();
+
+INTERNAL_API:
+
+    DECLARE_EXCEPTION_DEFAULTS(MgInvalidWatermarkDefinitionException)
+
+CLASS_ID:
+
+    static const INT32 m_cls_id = PlatformBase_Exception_MgInvalidWatermarkDefinitionException;
+};
+
+#endif

Modified: trunk/MgDev/Common/PlatformBase/MapLayer/MapBase.cpp
===================================================================
--- trunk/MgDev/Common/PlatformBase/MapLayer/MapBase.cpp	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/PlatformBase/MapLayer/MapBase.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -776,3 +776,55 @@
     throw new MgNotImplementedException(L"MgMapBase.GetService",
         __LINE__, __WFILE__, NULL, L"", NULL);
 }
+
+//static method to create the map definition
+MdfModel::MapDefinition* MgMapBase::GetMapDefinition(MgResourceService* svcResource, MgResourceIdentifier* resId)
+{
+    // get and parse the map definition
+    Ptr<MgByteReader> reader = svcResource->GetResourceContent(resId, L"");
+    Ptr<MgByteSink> sink = new MgByteSink(reader);
+    Ptr<MgByte> bytes = sink->ToBuffer();
+
+    assert(bytes->GetLength() > 0);
+
+    MdfParser::SAX2Parser parser;
+    parser.ParseString((const char*)bytes->Bytes(), bytes->GetLength());
+
+    if (!parser.GetSucceeded())
+    {
+        STRING errorMsg = parser.GetErrorMessage();
+        MgStringCollection arguments;
+        arguments.Add(errorMsg);
+        throw new MgInvalidMapDefinitionException(L"MgMapBase::GetMapDefinition", __LINE__, __WFILE__, &arguments, L"", NULL);
+    }
+
+    // detach the map definition from the parser - it's
+    // now the caller's responsibility to delete it
+    MdfModel::MapDefinition* mdef = parser.DetachMapDefinition();
+    assert(mdef != NULL);
+
+    return mdef;
+}
+
+//static method to create the map definition
+MdfModel::MapDefinition* MgMapBase::GetMapDefinition(CREFSTRING resourceContent)
+{
+    // get and parse the map definition
+    MdfParser::SAX2Parser parser;
+    parser.ParseString(resourceContent.c_str(), resourceContent.length());
+
+    if (!parser.GetSucceeded())
+    {
+        STRING errorMsg = parser.GetErrorMessage();
+        MgStringCollection arguments;
+        arguments.Add(errorMsg);
+        throw new MgInvalidMapDefinitionException(L"MgMapBase::GetMapDefinition", __LINE__, __WFILE__, &arguments, L"", NULL);
+    }
+
+    // detach the map definition from the parser - it's
+    // now the caller's responsibility to delete it
+    MdfModel::MapDefinition* mdef = parser.DetachMapDefinition();
+    assert(mdef != NULL);
+
+    return mdef;
+}

Modified: trunk/MgDev/Common/PlatformBase/MapLayer/MapBase.h
===================================================================
--- trunk/MgDev/Common/PlatformBase/MapLayer/MapBase.h	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/PlatformBase/MapLayer/MapBase.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -36,6 +36,10 @@
 #include "ReadOnlyLayerCollection.h"
 #include "SelectionBase.h"
 
+BEGIN_NAMESPACE_MDFMODEL
+class MapDefinition;
+END_NAMESPACE_MDFMODEL
+
 class MgPoint;
 class MgMapBase;
 template class MG_PLATFORMBASE_API Ptr<MgMapBase>;
@@ -549,6 +553,9 @@
 
 INTERNAL_API:
 
+    static MdfModel::MapDefinition* GetMapDefinition(MgResourceService* svcResource, MgResourceIdentifier* resId);
+    static MdfModel::MapDefinition* GetMapDefinition(CREFSTRING resourceContent);
+
     //////////////////////////////////////////////////////////////////
     /// \brief
     /// Serialize data to a TCP/IP stream.

Added: trunk/MgDev/Common/PlatformBase/MapLayer/Watermark.cpp
===================================================================
--- trunk/MgDev/Common/PlatformBase/MapLayer/Watermark.cpp	                        (rev 0)
+++ trunk/MgDev/Common/PlatformBase/MapLayer/Watermark.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,74 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#include "Watermark.h"
+#include "MdfModel.h"
+#include "SAX2Parser.h"
+
+using namespace std;
+
+//static method to create the watermark definition
+MdfModel::WatermarkDefinition* MgWatermark::GetWatermarkDefinition(MgResourceService* svcResource, MgResourceIdentifier* resId)
+{
+    // get and parse the watermark definition
+    Ptr<MgByteReader> reader = svcResource->GetResourceContent(resId, L"");
+    Ptr<MgByteSink> sink = new MgByteSink(reader);
+    Ptr<MgByte> bytes = sink->ToBuffer();
+
+    assert(bytes->GetLength() > 0);
+
+    MdfParser::SAX2Parser parser;
+    parser.ParseString((const char*)bytes->Bytes(), bytes->GetLength());
+
+    if (!parser.GetSucceeded())
+    {
+        STRING errorMsg = parser.GetErrorMessage();
+        MgStringCollection arguments;
+        arguments.Add(errorMsg);
+        throw new MgInvalidWatermarkDefinitionException(L"MgWatermark::GetWatermarkDefinition", __LINE__, __WFILE__, &arguments, L"", NULL);
+    }
+
+    // detach the watermark definition from the parser - it's
+    // now the caller's responsibility to delete it
+    MdfModel::WatermarkDefinition* wdef = parser.DetachWatermarkDefinition();
+    assert(wdef != NULL);
+
+    return wdef;
+}
+
+//static method to create the watermark definition
+MdfModel::WatermarkDefinition* MgWatermark::GetWatermarkDefinition(CREFSTRING resourceContent)
+{
+    // get and parse the watermark definition
+    MdfParser::SAX2Parser parser;
+    parser.ParseString(resourceContent.c_str(), resourceContent.length());
+
+    if (!parser.GetSucceeded())
+    {
+        STRING errorMsg = parser.GetErrorMessage();
+        MgStringCollection arguments;
+        arguments.Add(errorMsg);
+        throw new MgInvalidWatermarkDefinitionException(L"MgWatermark::GetWatermarkDefinition", __LINE__, __WFILE__, &arguments, L"", NULL);
+    }
+
+    // detach the watermark definition from the parser - it's
+    // now the caller's responsibility to delete it
+    MdfModel::WatermarkDefinition* wdef = parser.DetachWatermarkDefinition();
+    assert(wdef != NULL);
+
+    return wdef;
+}

Added: trunk/MgDev/Common/PlatformBase/MapLayer/Watermark.h
===================================================================
--- trunk/MgDev/Common/PlatformBase/MapLayer/Watermark.h	                        (rev 0)
+++ trunk/MgDev/Common/PlatformBase/MapLayer/Watermark.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,37 @@
+//
+//  Copyright (C) 2004-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef _MG_WATERMARK_H_
+#define _MG_WATERMARK_H_
+
+BEGIN_NAMESPACE_MDFMODEL
+class WatermarkDefinition;
+END_NAMESPACE_MDFMODEL
+
+//Currently the only reason MgWatermark exists is that 
+//the rendering service can get the WatermarkDefinition.
+//So it's only an internal API.
+
+class MG_PLATFORMBASE_API MgWatermark
+{
+INTERNAL_API:
+
+    static MdfModel::WatermarkDefinition* GetWatermarkDefinition(MgResourceService* svcResource, MgResourceIdentifier* resId);
+    static MdfModel::WatermarkDefinition* GetWatermarkDefinition(CREFSTRING resourceContent);
+};
+
+#endif

Modified: trunk/MgDev/Common/PlatformBase/PlatformBase.h
===================================================================
--- trunk/MgDev/Common/PlatformBase/PlatformBase.h	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/PlatformBase/PlatformBase.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -62,6 +62,7 @@
 #include "Exception/FeatureServiceException.h"
 #include "Exception/InvalidLayerDefinitionException.h"
 #include "Exception/InvalidMapDefinitionException.h"
+#include "Exception/InvalidWatermarkDefinitionException.h"
 #include "Exception/InvalidRepositoryNameException.h"
 #include "Exception/InvalidRepositoryTypeException.h"
 #include "Exception/InvalidResourceDataNameException.h"
@@ -162,5 +163,6 @@
 #include "MapLayer/MapCollection.h"
 #include "MapLayer/ReadOnlyLayerCollection.h"
 #include "MapLayer/SelectionBase.h"
+#include "MapLayer/Watermark.h"
 
 #endif

Modified: trunk/MgDev/Common/PlatformBase/PlatformBase.vcproj
===================================================================
--- trunk/MgDev/Common/PlatformBase/PlatformBase.vcproj	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/PlatformBase/PlatformBase.vcproj	2010-09-17 08:00:59 UTC (rev 5139)
@@ -1775,6 +1775,46 @@
 				>
 			</File>
 			<File
+				RelativePath=".\Exception\InvalidWatermarkDefinitionException.cpp"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|x64"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|x64"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath=".\Exception\InvalidWatermarkDefinitionException.h"
+				>
+			</File>
+			<File
 				RelativePath=".\Exception\LayerNotFoundException.cpp"
 				>
 				<FileConfiguration
@@ -4770,6 +4810,46 @@
 				RelativePath=".\MapLayer\SelectionBase.h"
 				>
 			</File>
+			<File
+				RelativePath=".\MapLayer\Watermark.cpp"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|x64"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|x64"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath=".\MapLayer\Watermark.h"
+				>
+			</File>
 		</Filter>
 		<File
 			RelativePath=".\PlatformBase.h"

Modified: trunk/MgDev/Common/PlatformBase/PlatformBaseBuild.cpp
===================================================================
--- trunk/MgDev/Common/PlatformBase/PlatformBaseBuild.cpp	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/PlatformBase/PlatformBaseBuild.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -42,6 +42,7 @@
 #include "Exception/FeatureServiceException.cpp"
 #include "Exception/InvalidMapDefinitionException.cpp"
 #include "Exception/InvalidLayerDefinitionException.cpp"
+#include "Exception/InvalidWatermarkDefinitionException.cpp"
 #include "Exception/InvalidRepositoryNameException.cpp"
 #include "Exception/InvalidRepositoryTypeException.cpp"
 #include "Exception/InvalidResourceDataNameException.cpp"
@@ -68,6 +69,7 @@
 #include "MapLayer/ObjectChange.cpp"
 #include "MapLayer/ReadOnlyLayerCollection.cpp"
 #include "MapLayer/SelectionBase.cpp"
+#include "MapLayer/Watermark.cpp"
 #include "Services/BaseServiceDefs.cpp"
 #include "Services/ClassDefinition.cpp"
 #include "Services/ClassDefinitionCollection.cpp"

Modified: trunk/MgDev/Common/PlatformBase/Services/PlatformBaseClassId.h
===================================================================
--- trunk/MgDev/Common/PlatformBase/Services/PlatformBaseClassId.h	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/PlatformBase/Services/PlatformBaseClassId.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -79,6 +79,7 @@
 #define PlatformBase_Exception_MgServiceNotAvailableException               PLATFORMBASE_EXCEPTION_ID+21
 #define PlatformBase_Exception_MgServiceNotSupportedException               PLATFORMBASE_EXCEPTION_ID+22
 #define PlatformBase_Exception_MgUserNotFoundException                      PLATFORMBASE_EXCEPTION_ID+23
+#define PlatformBase_Exception_MgInvalidWatermarkDefinitionException            PLATFORMBASE_EXCEPTION_ID+24
 
 // MapLayer API
 #define PlatformBase_MapLayer_MapBase                               PLATFORMBASE_MAPLAYER_ID+0

Modified: trunk/MgDev/Common/PlatformBase/Services/ResourceDefs.cpp
===================================================================
--- trunk/MgDev/Common/PlatformBase/Services/ResourceDefs.cpp	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/PlatformBase/Services/ResourceDefs.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -53,6 +53,7 @@
 const STRING MgResourceType::ApplicationDefinition  = L"ApplicationDefinition";
 const STRING MgResourceType::PrintLayoutDefinition  = L"PrintLayoutDefinition";
 const STRING MgResourceType::PrintLayoutElementDefinition   = L"PrintLayoutElementDefinition";
+const STRING MgResourceType::WatermarkDefinition    = L"WatermarkDefinition";
 
 
 const STRING MgResourceType::User                   = L"User";

Modified: trunk/MgDev/Common/PlatformBase/Services/ResourceDefs.h
===================================================================
--- trunk/MgDev/Common/PlatformBase/Services/ResourceDefs.h	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/PlatformBase/Services/ResourceDefs.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -282,7 +282,18 @@
     ///
     static const STRING PrintLayoutElementDefinition;        ///\if INTERNAL value("PrintLayoutElementDefinition") \endif
 
+    ////////////////////////////////////////////////////////////////
+    /// \brief
+    /// This resource is a watermark definition.
+    ///
+    /// \remarks
+    /// It represents the watermark rendered in map.
+    ///
+    /// \see \ref WatermarkDefinition_schema "WatermarkDefinition schema"
+    ///
+    static const STRING WatermarkDefinition;    ///\if INTERNAL value("WatermarkDefinition") \endif
 
+
 INTERNAL_API:
     static const STRING User;           /// User definition
     static const STRING Group;          /// Group definition

Modified: trunk/MgDev/Common/Renderers/AGGImageIO.h
===================================================================
--- trunk/MgDev/Common/Renderers/AGGImageIO.h	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/Renderers/AGGImageIO.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -15,6 +15,9 @@
 //  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
+#ifndef AGGIMAGEIO_H
+#define AGGIMAGEIO_H
+
 class RS_ByteData;
 
 class AGGImageIO
@@ -41,3 +44,5 @@
     static unsigned char* ReadFile(const RS_String& fname, size_t& len);
     static void UnmultiplyAlpha(unsigned int* argb, int len);
 };
+
+#endif      //AGGIMAGEIO_H

Modified: trunk/MgDev/Common/Renderers/AGGRenderer.cpp
===================================================================
--- trunk/MgDev/Common/Renderers/AGGRenderer.cpp	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/Renderers/AGGRenderer.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -62,6 +62,8 @@
 #include "DWFRSInputStream.h"
 #include "RSDWFInputStream.h"
 
+#include "RenderUtil.h"
+
 using namespace DWFToolkit;
 using namespace DWFCore;
 
@@ -2504,6 +2506,17 @@
 
 
 //////////////////////////////////////////////////////////////////////////////
+void AGGRenderer::DrawScreenRaster(unsigned char* data, int length,
+                                   RS_ImageFormat format, int native_width, int native_height,
+                                   double x, double y, double w, double h, double angledeg,
+                                   double alpha)
+{
+    RenderUtil::DrawScreenRaster(this, data, length, format, native_width, native_height,
+                                 x, y, w, h, angledeg, alpha);
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
 void AGGRenderer::DrawScreenRasterTransform(agg_context* cxt, unsigned char* data, int length,
                                             RS_ImageFormat format, int native_width, int native_height,
                                             double x, double y, double w, double h,

Modified: trunk/MgDev/Common/Renderers/AGGRenderer.h
===================================================================
--- trunk/MgDev/Common/Renderers/AGGRenderer.h	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/Renderers/AGGRenderer.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -183,6 +183,9 @@
     RENDERERS_API virtual void DrawScreenRaster(unsigned char* data, int length,
                                                 RS_ImageFormat format, int native_width, int native_height,
                                                 double x, double y, double w, double h, double angledeg);
+    RENDERERS_API virtual void DrawScreenRaster(unsigned char* data, int length,
+                                                RS_ImageFormat format, int native_width, int native_height,
+                                                double x, double y, double w, double h, double angledeg, double alpha);
     RENDERERS_API virtual void DrawScreenText(const RS_TextMetrics& tm, RS_TextDef& tdef, double insx, double insy, RS_F_Point* path, int npts, double param_position );
 
     RENDERERS_API virtual bool YPointsUp();

Modified: trunk/MgDev/Common/Renderers/DWFRenderer.cpp
===================================================================
--- trunk/MgDev/Common/Renderers/DWFRenderer.cpp	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/Renderers/DWFRenderer.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -66,6 +66,8 @@
 #include "AGGRenderer.h"
 #include "AGGImageIO.h"
 
+#include "RenderUtil.h"
+
 using namespace DWFToolkit;
 using namespace DWFCore;
 using namespace std;
@@ -2710,7 +2712,16 @@
     }
 }
 
+void DWFRenderer::DrawScreenRaster(unsigned char* data, int length,
+                                  RS_ImageFormat format, int native_width, int native_height,
+                                  double x, double y, double w, double h, double angleDeg,
+                                  double alpha)
+{
+    RenderUtil::DrawScreenRaster(this, data, length, format, native_width, native_height,
+                                 x, y, w, h, angleDeg, alpha);
+}
 
+
 void DWFRenderer::DrawScreenText(const RS_TextMetrics&  tm,
                                  RS_TextDef&      tdef,
                                  double           insx,

Modified: trunk/MgDev/Common/Renderers/DWFRenderer.h
===================================================================
--- trunk/MgDev/Common/Renderers/DWFRenderer.h	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/Renderers/DWFRenderer.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -178,6 +178,10 @@
     virtual void DrawScreenRaster(unsigned char* data, int length,
                                   RS_ImageFormat format, int native_width, int native_height,
                                   double x, double y, double w, double h, double angleDeg);
+    virtual void DrawScreenRaster(unsigned char* data, int length,
+                                  RS_ImageFormat format, int native_width, int native_height,
+                                  double x, double y, double w, double h, double angleDeg,
+                                  double alpha);
     virtual void DrawScreenText(const RS_TextMetrics& tm, RS_TextDef& tdef, double insx, double insy,
                                 RS_F_Point* path, int npts, double param_position);
 

Modified: trunk/MgDev/Common/Renderers/GDRenderer.cpp
===================================================================
--- trunk/MgDev/Common/Renderers/GDRenderer.cpp	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/Renderers/GDRenderer.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -56,6 +56,7 @@
 #include "complex_polygon_gd.h"
 
 #include "SymbolTrans.h"
+#include "RenderUtil.h"
 
 using namespace DWFToolkit;
 using namespace DWFCore;
@@ -2664,6 +2665,16 @@
 }
 
 
+void GDRenderer::DrawScreenRaster(unsigned char* data, int length,
+                                  RS_ImageFormat format, int native_width, int native_height,
+                                  double x, double y, double w, double h, double angleDeg,
+                                  double alpha)
+{
+    RenderUtil::DrawScreenRaster(this, data, length, format, native_width, native_height,
+                                 x, y, w, h, angleDeg, alpha);
+}
+
+
 void GDRenderer::DrawScreenText(const RS_TextMetrics& tm, RS_TextDef& tdef, double insx, double insy,
                                 RS_F_Point* path, int npts, double param_position)
 {

Modified: trunk/MgDev/Common/Renderers/GDRenderer.h
===================================================================
--- trunk/MgDev/Common/Renderers/GDRenderer.h	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/Renderers/GDRenderer.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -160,6 +160,10 @@
     virtual void DrawScreenRaster(unsigned char* data, int length,
                                   RS_ImageFormat format, int native_width, int native_height,
                                   double x, double y, double w, double h, double angleDeg);
+    virtual void DrawScreenRaster(unsigned char* data, int length,
+                                  RS_ImageFormat format, int native_width, int native_height,
+                                  double x, double y, double w, double h, double angleDeg,
+                                  double alpha);
     virtual void DrawScreenText(const RS_TextMetrics& tm, RS_TextDef& tdef, double insx, double insy,
                                 RS_F_Point* path, int npts, double param_position);
 

Modified: trunk/MgDev/Common/Renderers/KmlRenderer.cpp
===================================================================
--- trunk/MgDev/Common/Renderers/KmlRenderer.cpp	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/Renderers/KmlRenderer.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -23,6 +23,8 @@
 #include "UnicodeString.h"
 #include "PolygonUtils.h"
 
+#include "RenderUtil.h"
+
 const double ELEV_FACTOR = 0.1;
 
 
@@ -672,7 +674,16 @@
 {
 }
 
+void KmlRenderer::DrawScreenRaster(unsigned char* data, int length,
+                                  RS_ImageFormat format, int native_width, int native_height,
+                                  double x, double y, double w, double h, double angleDeg,
+                                  double alpha)
+{
+    RenderUtil::DrawScreenRaster(this, data, length, format, native_width, native_height,
+                                 x, y, w, h, angleDeg, alpha);
+}
 
+
 void KmlRenderer::DrawScreenText(const RS_TextMetrics&  /*tm*/,
                                  RS_TextDef&      /*tdef*/,
                                  double           /*insx*/,

Modified: trunk/MgDev/Common/Renderers/KmlRenderer.h
===================================================================
--- trunk/MgDev/Common/Renderers/KmlRenderer.h	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/Renderers/KmlRenderer.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -129,6 +129,10 @@
     virtual void DrawScreenRaster(unsigned char* data, int length,
                                   RS_ImageFormat format, int native_width, int native_height,
                                   double x, double y, double w, double h, double angleDeg);
+    virtual void DrawScreenRaster(unsigned char* data, int length,
+                                  RS_ImageFormat format, int native_width, int native_height,
+                                  double x, double y, double w, double h, double angleDeg,
+                                  double alpha);
     virtual void DrawScreenText(const RS_TextMetrics& tm, RS_TextDef& tdef, double insx, double insy,
                                 RS_F_Point* path, int npts, double param_position);
 

Added: trunk/MgDev/Common/Renderers/RenderUtil.cpp
===================================================================
--- trunk/MgDev/Common/Renderers/RenderUtil.cpp	                        (rev 0)
+++ trunk/MgDev/Common/Renderers/RenderUtil.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,78 @@
+//
+//  Copyright (C) 2007-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#include "stdafx.h"
+#include "RendererStyles.h"
+#include "AGGImageIO.h"
+#include "RenderUtil.h"
+
+void RenderUtil::DrawScreenRaster(SE_Renderer* render,
+                                 unsigned char* data, int length,
+                                 RS_ImageFormat format, int native_width, int native_height,
+                                 double x, double y, double w, double h, double angledeg,
+                                 double alpha)
+{
+    if (format == RS_ImageFormat_Unknown)
+        return;
+
+    if(alpha <= 0) return;
+
+    if(alpha >=1)
+    {
+        render->DrawScreenRaster(
+            data, length, format, native_width, native_height, 
+            x, y, w, h, angledeg);
+        return;
+    }
+
+    // if it's PNG, decode it and come back around
+    if (format == RS_ImageFormat_PNG)
+    {
+        unsigned int* decoded = AGGImageIO::DecodePNG(data, length, native_width, native_height);
+        if (decoded)
+        {
+            DrawScreenRaster(render, 
+                             (unsigned char*)decoded, 
+                             native_width * native_height * 4, 
+                             RS_ImageFormat_ARGB, 
+                             native_width, 
+                             native_height, 
+                             x, y, 
+                             w, h, 
+                             angledeg, alpha);
+        }
+
+        delete [] decoded;
+    }
+    else if(format == RS_ImageFormat_ABGR || format == RS_ImageFormat_ARGB)
+    {
+        //Set alpha value for each pixel
+        unsigned char* end = data + 4 * native_width * native_height;
+        for(unsigned char* pixel = data; pixel < end; pixel += 4)
+            pixel[3] = (unsigned char)((float)pixel[3] * (float)alpha);
+        render->DrawScreenRaster(
+            data, length, format, native_width, native_height, 
+            x, y, w, h, angledeg);
+    }
+    else
+    {
+        //TODO: Set alpha for other format
+        render->DrawScreenRaster(
+            data, length, format, native_width, native_height, 
+            x, y, w, h, angledeg);
+    }
+}

Added: trunk/MgDev/Common/Renderers/RenderUtil.h
===================================================================
--- trunk/MgDev/Common/Renderers/RenderUtil.h	                        (rev 0)
+++ trunk/MgDev/Common/Renderers/RenderUtil.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,39 @@
+//
+//  Copyright (C) 2007-2010 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef RENDERUTIL_H
+#define RENDERUTIL_H
+
+#include <vector>
+
+#include "SE_Renderer.h"
+
+class RenderUtil
+{
+
+public:
+    // Draw screen raster with alpha
+    // Alpha is a value between 0 and 1.
+    // 0 means completely transparent, while 1 means completely opaque.
+    static void DrawScreenRaster(SE_Renderer* render,
+                                 unsigned char* data, int length,
+                                 RS_ImageFormat format, int native_width, int native_height,
+                                 double x, double y, double w, double h, double angledeg,
+                                 double alpha);
+};
+
+#endif      //RENDERUTIL_H

Modified: trunk/MgDev/Common/Renderers/Renderers.vcproj
===================================================================
--- trunk/MgDev/Common/Renderers/Renderers.vcproj	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/Renderers/Renderers.vcproj	2010-09-17 08:00:59 UTC (rev 5139)
@@ -694,6 +694,14 @@
 			>
 		</File>
 		<File
+			RelativePath=".\RenderUtil.cpp"
+			>
+		</File>
+		<File
+			RelativePath=".\RenderUtil.h"
+			>
+		</File>
+		<File
 			RelativePath=".\stdafx.h"
 			>
 		</File>

Added: trunk/MgDev/Common/Schema/LayerDefinition-1.4.0.xsd
===================================================================
--- trunk/MgDev/Common/Schema/LayerDefinition-1.4.0.xsd	                        (rev 0)
+++ trunk/MgDev/Common/Schema/LayerDefinition-1.4.0.xsd	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,1242 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.4.0">
+  <xs:include schemaLocation="SymbolDefinition-1.1.0.xsd"/>
+  <xs:include schemaLocation="PlatformCommon-1.0.0.xsd"/>
+  <xs:include schemaLocation="WatermarkDefinition-1.0.0.xsd"/>
+  <xs:element name="LayerDefinition">
+    <xs:annotation>
+      <xs:documentation>The specification of the data source and stylization for a layer.</xs:documentation>
+    </xs:annotation>
+    <xs:complexType>
+      <xs:complexContent>
+        <xs:extension base="LayerDefinitionType">
+          <xs:attribute name="version" type="xs:string" use="required" fixed="1.4.0"/>
+        </xs:extension>
+      </xs:complexContent>
+    </xs:complexType>
+  </xs:element>
+  <xs:complexType name="LayerDefinitionType">
+    <xs:annotation>
+      <xs:documentation>Encapsulates the definition of a map layer.</xs:documentation>
+    </xs:annotation>
+    <xs:choice>
+      <xs:element name="DrawingLayerDefinition" type="DrawingLayerDefinitionType">
+        <xs:annotation>
+          <xs:documentation>A layer with a drawing (i.e., DWF) data source.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="VectorLayerDefinition" type="VectorLayerDefinitionType">
+        <xs:annotation>
+          <xs:documentation>A layer with a vector data source; and stylization specification for the datum's geometry types.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="GridLayerDefinition" type="GridLayerDefinitionType">
+        <xs:annotation>
+          <xs:documentation>A layer with a raster or grid data source.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+    </xs:choice>
+  </xs:complexType>
+  <xs:annotation>
+    <xs:documentation>******************** Common types for all layer types ********************</xs:documentation>
+  </xs:annotation>
+  <xs:complexType name="BaseLayerDefinitionType">
+    <xs:annotation>
+      <xs:documentation>Specifies common properties for all layer types.</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="ResourceId" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>Link to the drawing data source.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Opacity" default="1.0" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>Opacity at which to display the rendered data.</xs:documentation>
+        </xs:annotation>
+        <xs:simpleType>
+          <xs:restriction base="xs:double">
+            <xs:minInclusive value="0.0"/>
+            <xs:maxInclusive value="1.0"/>
+          </xs:restriction>
+        </xs:simpleType>
+      </xs:element>
+      <xs:element name="Watermarks" type="WatermarkInstanceCollectionType" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>A group of watermarks that is used in the current map.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:annotation>
+    <xs:documentation>******************** Drawing layer ********************</xs:documentation>
+  </xs:annotation>
+  <xs:complexType name="DrawingLayerDefinitionType">
+    <xs:annotation>
+      <xs:documentation>A layer with a drawing (i.e., DWF) data source.</xs:documentation>
+    </xs:annotation>
+    <xs:complexContent>
+      <xs:extension base="BaseLayerDefinitionType">
+        <xs:sequence>
+          <xs:element name="Sheet" type="xs:string">
+            <xs:annotation>
+              <xs:documentation>The sheet of the DWF to use.</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="LayerFilter" type="xs:string" minOccurs="0">
+            <xs:annotation>
+              <xs:documentation>The layers to show from the specified sheet.  Show all layers if this is not specified.</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="MinScale" type="xs:double" default="0.0" minOccurs="0">
+            <xs:annotation>
+              <xs:documentation>The zoomed in part of the scale range.  Defaults to 0 if not specified.  Inclusive.</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="MaxScale" type="xs:double" minOccurs="0">
+            <xs:annotation>
+              <xs:documentation>The zoomed out part of the scale range.  Defaults to the application's maximum value if not specified.  Exclusive.</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+        </xs:sequence>
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+  <xs:annotation>
+    <xs:documentation>******************** Vector layer ********************</xs:documentation>
+  </xs:annotation>
+  <xs:complexType name="VectorLayerDefinitionType">
+    <xs:annotation>
+      <xs:documentation>A layer with a vector data source; and stylization specification for the datum's geometry types.</xs:documentation>
+    </xs:annotation>
+    <xs:complexContent>
+      <xs:extension base="BaseLayerDefinitionType">
+        <xs:sequence>
+          <xs:element name="FeatureName" type="xs:string">
+            <xs:annotation>
+              <xs:documentation>Either a feature class or named extension.</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="FeatureNameType" type="FeatureNameType"/>
+          <xs:element name="Filter" type="xs:string" minOccurs="0">
+            <xs:annotation>
+              <xs:documentation>A boolean FDO expression that specifies which features to return.  No filter means pass all features through.</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="PropertyMapping" type="NameStringPairType" minOccurs="0" maxOccurs="unbounded">
+            <xs:annotation>
+              <xs:documentation>Specifies which properties to expose to the user and its corresponding friendly name.</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="Geometry" type="xs:string">
+            <xs:annotation>
+              <xs:documentation>Specifies the geometry property that should be used to get the geometries.</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="Url" type="xs:string" minOccurs="0">
+            <xs:annotation>
+              <xs:documentation>An optional URL associated with each feature.  This is a string FDO expression.</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="ToolTip" type="xs:string" minOccurs="0">
+            <xs:annotation>
+              <xs:documentation>The text to put into the tooltip for displayed features.  This is a string FDO expression.</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="VectorScaleRange" type="VectorScaleRangeType" maxOccurs="unbounded">
+            <xs:annotation>
+              <xs:documentation>The stylization to be applied to the features for a given scale range.</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+        </xs:sequence>
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+  <xs:simpleType name="FeatureNameType">
+    <xs:annotation>
+      <xs:documentation>Enumeration describing whether the features are coming from a feature class or named extension</xs:documentation>
+    </xs:annotation>
+    <xs:restriction base="xs:string">
+      <xs:enumeration value="FeatureClass"/>
+      <xs:enumeration value="NamedExtension"/>
+    </xs:restriction>
+  </xs:simpleType>
+  <xs:complexType name="VectorScaleRangeType">
+    <xs:annotation>
+      <xs:documentation>The stylization to be applied to the vector features for a given scale range.</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="MinScale" type="xs:double" default="0.0" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>The zoomed in part of the scale range.  Defaults to 0 if not specified.  Inclusive.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="MaxScale" type="xs:double" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>The zoomed out part of the scale range.  Defaults to the application's maximum value if not specified.  Exclusive.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:choice minOccurs="0" maxOccurs="unbounded">
+        <xs:annotation>
+          <xs:documentation>Note that where there is no style specified for a particular geometry type a default styling should be used.</xs:documentation>
+        </xs:annotation>
+        <xs:element name="AreaTypeStyle" type="AreaTypeStyleType">
+          <xs:annotation>
+            <xs:documentation>Style specification of a polygon geometry type.</xs:documentation>
+          </xs:annotation>
+        </xs:element>
+        <xs:element name="LineTypeStyle" type="LineTypeStyleType">
+          <xs:annotation>
+            <xs:documentation>Style specification of a line geometry type.</xs:documentation>
+          </xs:annotation>
+        </xs:element>
+        <xs:element name="PointTypeStyle" type="PointTypeStyleType">
+          <xs:annotation>
+            <xs:documentation>Style specification of a point geometry type.</xs:documentation>
+          </xs:annotation>
+        </xs:element>
+        <xs:element name="CompositeTypeStyle" type="CompositeTypeStyle">
+          <xs:annotation>
+            <xs:documentation>A composite style definition.</xs:documentation>
+          </xs:annotation>
+        </xs:element>
+      </xs:choice>
+      <xs:element name="ElevationSettings" type="ElevationSettingsType" minOccurs="0"/>
+      <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="ElevationSettingsType">
+    <xs:sequence>
+      <xs:element name="ZOffset" type="xs:string" minOccurs="0"/>
+      <xs:element name="ZExtrusion" type="xs:string" minOccurs="0"/>
+      <xs:element name="ZOffsetType" type="ElevationTypeType" default="RelativeToGround" minOccurs="0"/>
+      <xs:element name="Unit" type="LengthUnitType" default="Centimeters" minOccurs="0"/>
+      <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:simpleType name="ElevationTypeType">
+    <xs:annotation>
+      <xs:documentation>The possible interpretations of a z offset value.</xs:documentation>
+    </xs:annotation>
+    <xs:restriction base="xs:string">
+      <xs:enumeration value="RelativeToGround"/>
+      <xs:enumeration value="Absolute"/>
+    </xs:restriction>
+  </xs:simpleType>
+  <xs:complexType name="PointTypeStyleType">
+    <xs:annotation>
+      <xs:documentation>Style specification of a point geometry type.</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="DisplayAsText" type="xs:boolean">
+        <xs:annotation>
+          <xs:documentation>Create a text layer.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="AllowOverpost" type="xs:boolean">
+        <xs:annotation>
+          <xs:documentation>Allows labels from any map layer (including the current layer) to obscure features on the current layer.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="PointRule" type="PointRuleType" maxOccurs="unbounded">
+        <xs:annotation>
+          <xs:documentation>One or more PointRules defining the PointTypeStyle.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="ShowInLegend" type="xs:boolean" default="true" minOccurs="0"/>
+      <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="PointRuleType">
+    <xs:annotation>
+      <xs:documentation>Style rule for a point geometry type.</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="LegendLabel" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>The label for the Rule to be displayed in the legend.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Filter" type="xs:string" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>A filter for the Rule.  This is a boolean FDO expression.  Any features that pass this filter are styled using this rule's stylization.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Label" type="TextSymbolType" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>A label for the Rule.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:choice minOccurs="0">
+        <xs:element name="PointSymbolization2D" type="PointSymbolization2DType"/>
+      </xs:choice>
+      <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="PointSymbolizationType">
+    <xs:annotation>
+      <xs:documentation>Base point symbolization type.</xs:documentation>
+    </xs:annotation>
+  </xs:complexType>
+  <xs:complexType name="PointSymbolization2DType">
+    <xs:annotation>
+      <xs:documentation>The different types of point geometries.</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:choice>
+        <xs:element name="Mark" type="MarkSymbolType">
+          <xs:annotation>
+            <xs:documentation>A predefined shape such as a square or circle.</xs:documentation>
+          </xs:annotation>
+        </xs:element>
+        <xs:element name="Image" type="ImageSymbolType">
+          <xs:annotation>
+            <xs:documentation>A raster or image symbol.  Note that these do not scale well, but sometimes this is all that you have.  Supported formats are application specific.</xs:documentation>
+          </xs:annotation>
+        </xs:element>
+        <xs:element name="Font" type="FontSymbolType">
+          <xs:annotation>
+            <xs:documentation>A symbol specified using a font character.</xs:documentation>
+          </xs:annotation>
+        </xs:element>
+        <xs:element name="W2D" type="W2DSymbolType">
+          <xs:annotation>
+            <xs:documentation>A vector symbol defined using a W2D stream.</xs:documentation>
+          </xs:annotation>
+        </xs:element>
+        <xs:element name="Block" type="BlockSymbolType">
+          <xs:annotation>
+            <xs:documentation>A vector symbol specifed from a block.</xs:documentation>
+          </xs:annotation>
+        </xs:element>
+      </xs:choice>
+      <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="LineTypeStyleType">
+    <xs:annotation>
+      <xs:documentation>Style specification of a line geometry type.</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="LineRule" type="LineRuleType" maxOccurs="unbounded">
+        <xs:annotation>
+          <xs:documentation>Rules to define a theme.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="ShowInLegend" type="xs:boolean" default="true" minOccurs="0"/>
+      <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="LineRuleType">
+    <xs:annotation>
+      <xs:documentation>Style rule for a line geometry type.</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="LegendLabel" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>The label for the Rule to be displayed in the legend.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Filter" type="xs:string" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>A filter for the Rule.  This is a boolean FDO expression.  Any features that pass this filter are styled using this rule's stylization.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Label" type="TextSymbolType" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>A label for the Rule.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:choice minOccurs="0" maxOccurs="unbounded">
+        <xs:element name="LineSymbolization2D" type="StrokeType"/>
+      </xs:choice>
+      <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="AreaSymbolizationType">
+    <xs:annotation>
+      <xs:documentation>Symbolization characteristics for areas.</xs:documentation>
+    </xs:annotation>
+  </xs:complexType>
+  <xs:complexType name="AreaSymbolizationFillType">
+    <xs:annotation>
+      <xs:documentation>Describes the style of a polygon.</xs:documentation>
+    </xs:annotation>
+    <xs:complexContent>
+      <xs:extension base="AreaSymbolizationType">
+        <xs:sequence>
+          <xs:element name="Fill" type="FillType" minOccurs="0">
+            <xs:annotation>
+              <xs:documentation>The style of the polygon fill.</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="Stroke" type="StrokeType" minOccurs="0">
+            <xs:annotation>
+              <xs:documentation>The style of the polygon edge.</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+        </xs:sequence>
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+  <xs:complexType name="AreaTypeStyleType">
+    <xs:annotation>
+      <xs:documentation>Style specification of a polygon geometry type.</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="AreaRule" type="AreaRuleType" maxOccurs="unbounded">
+        <xs:annotation>
+          <xs:documentation>Rules to define a theme.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="ShowInLegend" type="xs:boolean" default="true" minOccurs="0"/>
+      <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="AreaRuleType">
+    <xs:annotation>
+      <xs:documentation>Style rule for an area geometry type.</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="LegendLabel" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>The label for the Rule to be displayed in the legend.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Filter" type="xs:string" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>A filter for the Rule.  This is a boolean FDO expression.  Any features that pass this filter are styled using this rule's stylization.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Label" type="TextSymbolType" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>A label for the Rule.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:choice>
+        <xs:element name="AreaSymbolization2D" type="AreaSymbolizationFillType">
+          <xs:annotation>
+            <xs:documentation>The stylization of the polygon geometry.</xs:documentation>
+          </xs:annotation>
+        </xs:element>
+      </xs:choice>
+      <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="StrokeType">
+    <xs:annotation>
+      <xs:documentation>Encapsulates the stylization of a line.</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="LineStyle" type="xs:string"/>
+      <xs:element name="Thickness" type="xs:string"/>
+      <xs:element name="Color" type="xs:string"/>
+      <xs:element name="Unit" type="LengthUnitType">
+        <xs:annotation>
+          <xs:documentation>Unit of measurement that the thickness is specified in</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="SizeContext" type="SizeContextType">
+        <xs:annotation>
+          <xs:documentation>Whether the sizes are with respect to the earth or the user's display device.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="FillType">
+    <xs:annotation>
+      <xs:documentation>Encapsulates the stylization of a polygon's fill.</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="FillPattern" type="xs:string"/>
+      <xs:element name="ForegroundColor" type="xs:string"/>
+      <xs:element name="BackgroundColor" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>The background color.  Not applicable to solid fills.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:simpleType name="BackgroundStyleType">
+    <xs:annotation>
+      <xs:documentation>The possible background styles of a TextSymbol.</xs:documentation>
+    </xs:annotation>
+    <xs:restriction base="xs:string">
+      <xs:enumeration value="Transparent"/>
+      <xs:enumeration value="Opaque"/>
+      <xs:enumeration value="Ghosted"/>
+    </xs:restriction>
+  </xs:simpleType>
+  <xs:simpleType name="SizeContextType">
+    <xs:annotation>
+      <xs:documentation>Whether the sizes are specified as sizes on the earth or on the user's display device.</xs:documentation>
+    </xs:annotation>
+    <xs:restriction base="xs:string">
+      <xs:enumeration value="MappingUnits"/>
+      <xs:enumeration value="DeviceUnits"/>
+    </xs:restriction>
+  </xs:simpleType>
+  <xs:simpleType name="LengthUnitType">
+    <xs:annotation>
+      <xs:documentation>The measurement units that linear sizes are specified in.</xs:documentation>
+    </xs:annotation>
+    <xs:restriction base="xs:string">
+      <xs:enumeration value="Millimeters"/>
+      <xs:enumeration value="Centimeters"/>
+      <xs:enumeration value="Meters"/>
+      <xs:enumeration value="Kilometers"/>
+      <xs:enumeration value="Inches"/>
+      <xs:enumeration value="Feet"/>
+      <xs:enumeration value="Yards"/>
+      <xs:enumeration value="Miles"/>
+      <xs:enumeration value="Points"/>
+    </xs:restriction>
+  </xs:simpleType>
+  <xs:complexType name="TextSymbolType">
+    <xs:annotation>
+      <xs:documentation>Encapsulates the text label stylization used to label features, and for FontSymbols.</xs:documentation>
+    </xs:annotation>
+    <xs:complexContent>
+      <xs:extension base="SymbolType">
+        <xs:sequence>
+          <xs:element name="Text" type="xs:string">
+            <xs:annotation>
+              <xs:documentation>The text of the TextSymbol.  This is a string FDO expression.</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="FontName" type="xs:string">
+            <xs:annotation>
+              <xs:documentation>The font to use.</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="ForegroundColor" type="xs:string">
+            <xs:annotation>
+              <xs:documentation>The color of the text.</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="BackgroundColor" type="xs:string">
+            <xs:annotation>
+              <xs:documentation>The text background color.</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="BackgroundStyle" type="BackgroundStyleType">
+            <xs:annotation>
+              <xs:documentation>The background style</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="HorizontalAlignment" type="xs:string" default="'Center'" minOccurs="0">
+            <xs:annotation>
+              <xs:documentation>A string FDO expression for the horizontal alignment.  Must evaluate to one of the HorizontalAlignmentType enums.  Only applicable to text styles.</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="VerticalAlignment" type="xs:string" default="'Baseline'" minOccurs="0">
+            <xs:annotation>
+              <xs:documentation>A string FDO expression for the vertical alignment.  Must evaluate to one of the VerticalAlignmentType enums.  Only applicable to text and line styles.</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="Bold" type="xs:string" default="false" minOccurs="0">
+            <xs:annotation>
+              <xs:documentation>Specifies if the label should be in a bold font.</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="Italic" type="xs:string" default="false" minOccurs="0">
+            <xs:annotation>
+              <xs:documentation>Specifies if the font should be italicized.</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="Underlined" type="xs:string" default="false" minOccurs="0">
+            <xs:annotation>
+              <xs:documentation>Specifies if the text should be underlined.</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="AdvancedPlacement" minOccurs="0">
+            <xs:annotation>
+              <xs:documentation>Optional element which specifies that a more advanced labeling algorithm should be used with the AJAX viewer.</xs:documentation>
+            </xs:annotation>
+            <xs:complexType>
+              <xs:sequence>
+                <xs:element name="ScaleLimit" type="xs:double" minOccurs="0">
+                  <xs:annotation>
+                    <xs:documentation>The maximum amount any label is allowed to shrink in order to fit into the feature.  For example, 0.8 means that the label can shrink until it is 80% of the original size.  1.0 means that the label cannot shrink.  If not specified, the application should assume 1.0.  If set to 0.0 or less then the advanced placement option is disabled.</xs:documentation>
+                  </xs:annotation>
+                </xs:element>
+              </xs:sequence>
+            </xs:complexType>
+          </xs:element>
+          <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+        </xs:sequence>
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+  <xs:complexType name="SymbolType">
+    <xs:annotation>
+      <xs:documentation>Defines common properties for all symbols.</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="Unit" type="LengthUnitType">
+        <xs:annotation>
+          <xs:documentation>The units that the sizes are specified in.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="SizeContext" type="SizeContextType">
+        <xs:annotation>
+          <xs:documentation>Whether the sizes are with respect to the earth or the user's display device.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="SizeX" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>Width of the symbol.  This is a double FDO expression.  Does not apply to font symbols.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="SizeY" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>Height of the symbol.  This is a double FDO expression.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Rotation" type="xs:string" default="0.0" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>Amount to rotate the symbol in degrees.  This is a double FDO expression.  Does not apply to line labels.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="MaintainAspect" type="xs:boolean" default="true" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>Hint for the UI only.  When the user enters a constant size for the width or height, the other dimension should be adjusted accordingly.  Does not apply to font symbols or labels.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="InsertionPointX" type="xs:string" default="0.5" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>X offset for the symbol specified in symbol space.  Does not apply to labels.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="InsertionPointY" type="xs:double" default="0.5" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>Y offset for the symbol specified in symbol space.  Does not apply to labels.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="MarkSymbolType">
+    <xs:annotation>
+      <xs:documentation>Stylization of a predefined shape (ShapeType).</xs:documentation>
+    </xs:annotation>
+    <xs:complexContent>
+      <xs:extension base="SymbolType">
+        <xs:sequence>
+          <xs:element name="Shape" type="ShapeType"/>
+          <xs:element name="Fill" type="FillType" minOccurs="0">
+            <xs:annotation>
+              <xs:documentation>No fill is drawn if not specified.</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="Edge" type="StrokeType" minOccurs="0">
+            <xs:annotation>
+              <xs:documentation>No edge is drawn if not specified.</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+        </xs:sequence>
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+  <xs:complexType name="NameStringPairType">
+    <xs:annotation>
+      <xs:documentation>Used by vector layer definition to hold properties that can be displayed to the end user, and the friendly name to display it as.</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="Name" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>The name of the property to expose.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Value" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>The name to show the end user.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:simpleType name="ShapeType">
+    <xs:annotation>
+      <xs:documentation>SLD supports square, circle, triangle, star, cross, and X.</xs:documentation>
+    </xs:annotation>
+    <xs:restriction base="xs:string">
+      <xs:enumeration value="Square"/>
+      <xs:enumeration value="Circle"/>
+      <xs:enumeration value="Triangle"/>
+      <xs:enumeration value="Star"/>
+      <xs:enumeration value="Cross"/>
+      <xs:enumeration value="X"/>
+    </xs:restriction>
+  </xs:simpleType>
+  <xs:complexType name="ImageSymbolType">
+    <xs:annotation>
+      <xs:documentation>Symbols that are comprised of a raster.</xs:documentation>
+    </xs:annotation>
+    <xs:complexContent>
+      <xs:extension base="SymbolType">
+        <xs:sequence>
+          <xs:choice>
+            <xs:element name="Image">
+              <xs:annotation>
+                <xs:documentation>Reference to the image.</xs:documentation>
+              </xs:annotation>
+              <xs:complexType>
+                <xs:sequence>
+                  <xs:element name="ResourceId">
+                    <xs:annotation>
+                      <xs:documentation>The reference to the resource.</xs:documentation>
+                    </xs:annotation>
+                  </xs:element>
+                  <xs:element name="LibraryItemName" minOccurs="0">
+                    <xs:annotation>
+                      <xs:documentation>If ResourceId specifies a library, this identifies the name of a library item.</xs:documentation>
+                    </xs:annotation>
+                  </xs:element>
+                </xs:sequence>
+              </xs:complexType>
+            </xs:element>
+            <xs:element name="Content" type="xs:hexBinary">
+              <xs:annotation>
+                <xs:documentation>BinHex data for image.</xs:documentation>
+              </xs:annotation>
+            </xs:element>
+          </xs:choice>
+          <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+        </xs:sequence>
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+  <xs:complexType name="FontSymbolType">
+    <xs:annotation>
+      <xs:documentation>Symbols that are specified by a font and character.</xs:documentation>
+    </xs:annotation>
+    <xs:complexContent>
+      <xs:extension base="SymbolType">
+        <xs:sequence>
+          <xs:element name="FontName" type="xs:string">
+            <xs:annotation>
+              <xs:documentation>If the font is not installed, the actual font used is application dependent.</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="Character" type="xs:string"/>
+          <xs:element name="Bold" type="xs:boolean" minOccurs="0"/>
+          <xs:element name="Italic" type="xs:boolean" minOccurs="0"/>
+          <xs:element name="Underlined" type="xs:boolean" minOccurs="0"/>
+          <xs:element name="ForegroundColor" type="xs:string"/>
+          <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+        </xs:sequence>
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+  <xs:complexType name="W2DSymbolType">
+    <xs:annotation>
+      <xs:documentation>A symbol using a W2D stream.</xs:documentation>
+    </xs:annotation>
+    <xs:complexContent>
+      <xs:extension base="SymbolType">
+        <xs:sequence>
+          <xs:element name="W2DSymbol">
+            <xs:complexType>
+              <xs:sequence>
+                <xs:element name="ResourceId">
+                  <xs:annotation>
+                    <xs:documentation>The reference to the symbol library.</xs:documentation>
+                  </xs:annotation>
+                </xs:element>
+                <xs:element name="LibraryItemName">
+                  <xs:annotation>
+                    <xs:documentation>The W2D stream in the symbol library.</xs:documentation>
+                  </xs:annotation>
+                </xs:element>
+              </xs:sequence>
+            </xs:complexType>
+          </xs:element>
+          <xs:element name="FillColor" type="xs:string" minOccurs="0">
+            <xs:annotation>
+              <xs:documentation>If specified all polygon fills in the symbol are drawn in this color.</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="LineColor" type="xs:string" minOccurs="0">
+            <xs:annotation>
+              <xs:documentation>If specified all lines in the symbol are drawn in this color.</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="TextColor" type="xs:string" minOccurs="0">
+            <xs:annotation>
+              <xs:documentation>If specified all text in the symbol is drawn in this color.</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+        </xs:sequence>
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+  <xs:complexType name="BlockSymbolType">
+    <xs:annotation>
+      <xs:documentation>A block symbol.</xs:documentation>
+    </xs:annotation>
+    <xs:complexContent>
+      <xs:extension base="SymbolType">
+        <xs:sequence>
+          <xs:element name="DrawingName" type="xs:string"/>
+          <xs:element name="BlockName" type="xs:string"/>
+          <xs:element name="BlockColor" type="xs:string" minOccurs="0">
+            <xs:annotation>
+              <xs:documentation>Static color.</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="LayerColor" type="xs:string" minOccurs="0">
+            <xs:annotation>
+              <xs:documentation>Static color.</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+        </xs:sequence>
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+  <xs:complexType name="CompositeTypeStyle">
+    <xs:annotation>
+      <xs:documentation>A style specification consisting of composite rules.</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="CompositeRule" type="CompositeRule" maxOccurs="unbounded">
+        <xs:annotation>
+          <xs:documentation>One or more CompositeRules defining the CompositeTypeStyle.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="ShowInLegend" type="xs:boolean" default="true" minOccurs="0"/>
+      <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="CompositeRule">
+    <xs:annotation>
+      <xs:documentation>A style rule containing a composite symbolization.</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="LegendLabel" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>The label for the Rule to be displayed in the legend.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Filter" type="xs:string" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>A filter for the Rule.  This is a boolean FDO expression.  Any features that pass this filter are styled using this rule's stylization.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="CompositeSymbolization" type="CompositeSymbolization">
+        <xs:annotation>
+          <xs:documentation>The symbolization for the Rule.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="CompositeSymbolization">
+    <xs:annotation>
+      <xs:documentation>Stylization attributes of a point, line, or area feature.</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="SymbolInstance" type="SymbolInstance" minOccurs="0" maxOccurs="unbounded">
+        <xs:annotation>
+          <xs:documentation>The symbol instances used for stylization.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="ThemeLabel">
+    <xs:annotation>
+      <xs:documentation>Provides legend labeling information for a theme.</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="Description" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>The legend description for the theme.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="CategoryFormat" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>The default legend format to use for each category in the theme.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="Override">
+    <xs:annotation>
+      <xs:documentation>A parameter override.</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="SymbolName" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>The name of the symbol definition containing the parameter being overridden.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="ParameterIdentifier" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>The identifier of the parameter being overridden.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="ParameterValue" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>The override value for the parameter.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="ThemeLabel" type="ThemeLabel" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>An optional theme label for this override.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="ParameterOverrides">
+    <xs:annotation>
+      <xs:documentation>A collection of parameter overrides.</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="Override" type="Override" minOccurs="0" maxOccurs="unbounded"/>
+      <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:simpleType name="UsageContextType">
+    <xs:annotation>
+      <xs:documentation>Enumerates the allowed UsageContext values.</xs:documentation>
+    </xs:annotation>
+    <xs:restriction base="xs:string">
+      <xs:enumeration value="Unspecified"/>
+      <xs:enumeration value="Point"/>
+      <xs:enumeration value="Line"/>
+      <xs:enumeration value="Area"/>
+    </xs:restriction>
+  </xs:simpleType>
+  <xs:simpleType name="GeometryContextType">
+    <xs:annotation>
+      <xs:documentation>Enumerates the allowed GeometryContext values.</xs:documentation>
+    </xs:annotation>
+    <xs:restriction base="xs:string">
+      <xs:enumeration value="Unspecified"/>
+      <xs:enumeration value="Point"/>
+      <xs:enumeration value="LineString"/>
+      <xs:enumeration value="Polygon"/>
+    </xs:restriction>
+  </xs:simpleType>
+  <xs:complexType name="SymbolInstance">
+    <xs:annotation>
+      <xs:documentation>An instance of a symbol.</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:choice>
+        <xs:element name="ResourceId" type="xs:string">
+          <xs:annotation>
+            <xs:documentation>A library reference to an existing SymbolDefinition, either simple or compound.</xs:documentation>
+          </xs:annotation>
+        </xs:element>
+        <xs:element name="SimpleSymbolDefinition" type="SimpleSymbolDefinition">
+          <xs:annotation>
+            <xs:documentation>An inlined SimpleSymbolDefinition.</xs:documentation>
+          </xs:annotation>
+        </xs:element>
+        <xs:element name="CompoundSymbolDefinition" type="CompoundSymbolDefinition">
+          <xs:annotation>
+            <xs:documentation>An inlined CompoundSymbolDefinition.</xs:documentation>
+          </xs:annotation>
+        </xs:element>
+      </xs:choice>
+      <xs:element name="ParameterOverrides" type="ParameterOverrides">
+        <xs:annotation>
+          <xs:documentation>Specifies all parameter overrides for this symbol instance.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="ScaleX" type="xs:string" default="1.0" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>The additional amount to scale the symbol horizontally in symbol space.  Defaults to 1 if not specified.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="ScaleY" type="xs:string" default="1.0" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>The additional amount to scale the symbol vertically in symbol space.  Defaults to 1 if not specified.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="InsertionOffsetX" type="xs:string" default="0.0" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>Specifies the additional amount to offset the symbol horizontally, in mm in device units, after scaling and rotation have been applied.  Applies only to point symbols.  Defaults to 0 if not specified.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="InsertionOffsetY" type="xs:string" default="0.0" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>Specifies the additional amount to offset the symbol vertically, in mm in device units, after scaling and rotation have been applied.  Applies only to point symbols.  Defaults to 0 if not specified.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="SizeContext" type="SizeContextType" default="DeviceUnits" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>Specifies whether the symbol sizes are with respect to the map or the user's display device.  Defaults to device units.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="DrawLast" type="xs:string" default="false" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>Boolean value which specifies whether the symbol is drawn as part of a final rendering pass (e.g. for labeling).  This must evaluate to True or False (default).</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="CheckExclusionRegion" type="xs:string" default="false" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>Boolean value which specifies whether to render this symbol only if its graphical extent does not overlap the exclusion region.  If the positioning algorithm generates multiple candidate symbol positions and this setting is True, then only the first non-overlapping candidate is rendered.  This must evaluate to True or False (default).</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="AddToExclusionRegion" type="xs:string" default="false" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>Boolean value which specifies whether the graphical extent for this symbol instance is added to the exclusion region (if it is rendered).  Symbols which check the exclusion region will not draw on top of this symbol.  This must evaluate to True or False (default).</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="PositioningAlgorithm" type="xs:string" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>Specifies the algorithm used to generate candidate positions for the symbol.  If specified this must evaluate to one of: Default, EightSurrounding, or PathLabels.  Default means generate one position using the feature geometry (used for normal rendering).  EightSurrounding means generate eight candidate labels surrounding the feature geometry (used when labeling point features).  PathLabels means generate periodic labels which follow the feature geometry (used when labeling linestring features).</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="RenderingPass" type="xs:string" default="0" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>The optional rendering pass in which this symbol instance draws.  If specified this must be greater than or equal to zero.  Defaults to 0.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="UsageContext" type="UsageContextType" default="Unspecified" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>Specifies which usage in the symbol should be the active one.  Defaults to Unspecified.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="GeometryContext" type="GeometryContextType" default="Unspecified" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>Specifies which geometry type this symbol instance applies to.  Defaults to Unspecified.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:annotation>
+    <xs:documentation>******************** Grid layer ********************</xs:documentation>
+  </xs:annotation>
+  <xs:complexType name="GridLayerDefinitionType">
+    <xs:annotation>
+      <xs:documentation>A layer for raster or grid data.</xs:documentation>
+    </xs:annotation>
+    <xs:complexContent>
+      <xs:extension base="BaseLayerDefinitionType">
+        <xs:sequence>
+          <xs:element name="FeatureName" type="xs:string"/>
+          <xs:element name="Geometry" type="xs:string">
+            <xs:annotation>
+              <xs:documentation>Specifies the geometry property that should be used to get the geometries.</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="Filter" type="xs:string" minOccurs="0">
+            <xs:annotation>
+              <xs:documentation>A boolean FDO expression that specifies which features to return.  No filter means pass all features through.</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="GridScaleRange" type="GridScaleRangeType" maxOccurs="unbounded"/>
+          <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+        </xs:sequence>
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+  <xs:complexType name="ChannelBandType">
+    <xs:annotation>
+      <xs:documentation>Defines how to scale numbers into a color channel.</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="Band" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>Name of the band.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="LowBand" type="xs:double" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>Default is low value found in band.  Band values less than this are snapped to this number.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="HighBand" type="xs:double" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>Default is high value found in band.  Band values greater than this are snapped to this number.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="LowChannel" type="xs:unsignedByte" default="0" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>Default is 0.  Range is 0:255.  LowBand is mapped to this number.  LowChannel can be greater than HighChannel.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="HighChannel" type="xs:unsignedByte" default="255" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>Default is 255.  Range is 0:255.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="GridColorBandsType">
+    <xs:annotation>
+      <xs:documentation>Specifies a color using distinct RGB values.</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="RedBand" type="ChannelBandType"/>
+      <xs:element name="GreenBand" type="ChannelBandType"/>
+      <xs:element name="BlueBand" type="ChannelBandType"/>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="GridColorType">
+    <xs:annotation>
+      <xs:documentation>The color to use for a grid rule.</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:choice minOccurs="0">
+        <xs:element name="ExplicitColor" type="xs:string">
+          <xs:annotation>
+            <xs:documentation>Explicit ARGB color.</xs:documentation>
+          </xs:annotation>
+        </xs:element>
+        <xs:element name="Band" type="xs:string"/>
+        <xs:element name="Bands" type="GridColorBandsType"/>
+      </xs:choice>
+      <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="GridColorRuleType">
+    <xs:annotation>
+      <xs:documentation>Encapsulate a style for a grid source.</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="LegendLabel" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>The label for the Rule to be displayed in the legend.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Filter" type="xs:string" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>A filter for the Rule.  This is a boolean FDO expression.  Any features that pass this filter are styled using this rule's stylization.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Label" type="TextSymbolType" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>A label for the Rule.  Does not apply to GridColorRule.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Color" type="GridColorType"/>
+      <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="HillShadeType">
+    <xs:annotation>
+      <xs:documentation>Specifies how to shade given a band and a light source.</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="Band" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>Name of the band used for the computation.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Azimuth" type="xs:double">
+        <xs:annotation>
+          <xs:documentation>Azimuth of the sun in degrees.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Altitude" type="xs:double">
+        <xs:annotation>
+          <xs:documentation>Altitude of the sun in degrees.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="ScaleFactor" type="xs:double" default="1.0" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>The scale factor applied to the band prior to computing hillshade.  Defaults to 1 if not specified.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="GridColorStyleType">
+    <xs:annotation>
+      <xs:documentation>Specifies how to style each pixel.</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="HillShade" type="HillShadeType" minOccurs="0"/>
+      <xs:element name="TransparencyColor" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>If a pixel color prior to factoring in HillShade is this value then the pixel is transparent.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="BrightnessFactor" type="xs:double" default="0.0" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>Default is 0.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="ContrastFactor" type="xs:double" default="0.0" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>Default is 0.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="ColorRule" type="GridColorRuleType" minOccurs="0" maxOccurs="unbounded"/>
+      <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="GridSurfaceStyleType">
+    <xs:annotation>
+      <xs:documentation>Specifies how to calculate pixel elevations.</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="Band" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>Band to use for 3D data.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="ZeroValue" type="xs:double" default="0.0" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>Determines which input value is mapped to zero elevation.  Defaults to 0 if not specified.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="ScaleFactor" type="xs:double" default="1.0" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>Determines how to scale the inputs into a consistent elevation.  Defaults to 1 if not specified.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="DefaultColor" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>The default color to use if no ColorStyle is defined at a pixel.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="GridScaleRangeType">
+    <xs:annotation>
+      <xs:documentation>The stylization for a specified scale range.</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="MinScale" type="xs:double" default="0.0" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>The zoomed in part of the scale range.  Defaults to 0 if not specified.  Inclusive.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="MaxScale" type="xs:double" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>The zoomed out part of the scale range.  Defaults to the application's maximum value if not specified.  Exclusive.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="SurfaceStyle" type="GridSurfaceStyleType" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>Defines the height field of the grid.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="ColorStyle" type="GridColorStyleType" minOccurs="0"/>
+      <xs:element name="RebuildFactor" type="xs:double">
+        <xs:annotation>
+          <xs:documentation>When the user has zoomed in by this amount, a request for more detailed raster data is made.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+</xs:schema>

Added: trunk/MgDev/Common/Schema/MapDefinition-1.1.0.xsd
===================================================================
--- trunk/MgDev/Common/Schema/MapDefinition-1.1.0.xsd	                        (rev 0)
+++ trunk/MgDev/Common/Schema/MapDefinition-1.1.0.xsd	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,231 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.1.0">
+  <xs:include schemaLocation="WatermarkDefinition-1.0.0.xsd"/>
+  <xs:complexType name="Box2DType">
+    <xs:annotation>
+      <xs:documentation>Box2D encapsulates the the coordinates of a box in 2-D space</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="MinX" type="xs:double">
+        <xs:annotation>
+          <xs:documentation>Minimum x-coordinate</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="MaxX" type="xs:double">
+        <xs:annotation>
+          <xs:documentation>Maximum x-coordinate</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="MinY" type="xs:double">
+        <xs:annotation>
+          <xs:documentation>Minimum y-coordinate</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="MaxY" type="xs:double">
+        <xs:annotation>
+          <xs:documentation>Maximum y-coordinate</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="BaseMapLayerType">
+    <xs:annotation>
+      <xs:documentation>BaseMapLayerType encapsulates the properties of a BaseMapLayer.</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="Name" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>Name of the MapLayer</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="ResourceId" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>ResourceId of the MapLayer</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Selectable" type="xs:boolean">
+        <xs:annotation>
+          <xs:documentation>Whether or not the Layer can be selected</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="ShowInLegend" type="xs:boolean">
+        <xs:annotation>
+          <xs:documentation>Whether or not the Layer should be shown in the legend</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="LegendLabel" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>Label to be shown for the Layer in the legend</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="ExpandInLegend" type="xs:boolean">
+        <xs:annotation>
+          <xs:documentation>Whether or not the Layer should be expanded in the legend.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="MapLayerType">
+    <xs:annotation>
+      <xs:documentation>MapLayerType encapsulates the properties of a map layer, including its group and options about how it should be displayed.</xs:documentation>
+    </xs:annotation>
+    <xs:complexContent>
+      <xs:extension base="BaseMapLayerType">
+        <xs:sequence>
+          <xs:element name="Visible" type="xs:boolean">
+            <xs:annotation>
+              <xs:documentation>Whether this layer's visiblity should be visible or not when it first comes into range</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="Group" type="xs:string">
+            <xs:annotation>
+              <xs:documentation>Group of which the MapLayer is a member of</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+        </xs:sequence>
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+  <xs:complexType name="MapLayerGroupCommonType">
+    <xs:annotation>
+      <xs:documentation>MapLayerGroupCommonType is a common subclass of MapLayerGroupCommonType and BaseMapLayerGroupCommonType</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="Name" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>The name of this LayerGroup</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Visible" type="xs:boolean">
+        <xs:annotation>
+          <xs:documentation>Whether this group's visiblity should be visible or not when it first comes into range</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="ShowInLegend" type="xs:boolean">
+        <xs:annotation>
+          <xs:documentation>Whether or not the LayerGroup should be shown in the legend</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="ExpandInLegend" type="xs:boolean">
+        <xs:annotation>
+          <xs:documentation>Whether or not the LayerGroup should be initially expanded in the legend</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="LegendLabel" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>Label to be shown for the LayerGroup in the legend</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="MapLayerGroupType">
+    <xs:annotation>
+      <xs:documentation>MapLayerGroupType encapsulates the properties of a MapLayerGroup.  Its extension to MapLayerGroupCommonType is that the MapLayerGroup itself can also be in a MapLayerGroup.</xs:documentation>
+    </xs:annotation>
+    <xs:complexContent>
+      <xs:extension base="MapLayerGroupCommonType">
+        <xs:sequence>
+          <xs:element name="Group" type="xs:string">
+            <xs:annotation>
+              <xs:documentation>The group that contains the MapLayerGroup</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+        </xs:sequence>
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+  <xs:complexType name="BaseMapLayerGroupCommonType">
+    <xs:annotation>
+      <xs:documentation>BaseMapLayerGroupCommonType encapsulates the properties of a BaseMapLayerGroup. It extends MapLayerGroupCommonType by holding the layers in the group.  The base map layer groups defines what layers are used to render a tile set in the HTML viewer.</xs:documentation>
+    </xs:annotation>
+    <xs:complexContent>
+      <xs:extension base="MapLayerGroupCommonType">
+        <xs:sequence>
+          <xs:element name="BaseMapLayer" type="BaseMapLayerType" minOccurs="0" maxOccurs="unbounded">
+            <xs:annotation>
+              <xs:documentation>The layers that are part of this group. The order of the layers represents the draw order, layers first is the list are drawn over top of layers later in the list.</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+        </xs:sequence>
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+  <xs:complexType name="MapDefinitionType">
+    <xs:annotation>
+      <xs:documentation>MapDefinitionType encapsulates a MapDefinition, which houses a collection of MapLayers and their groups.</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="Name" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>The name of the MapDefinition</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="CoordinateSystem" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>The coordinate system as WKT used by the MapDefinition</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Extents" type="Box2DType">
+        <xs:annotation>
+          <xs:documentation>A bounding box around the area of the MapDefinition</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="BackgroundColor" type="xs:hexBinary">
+        <xs:annotation>
+          <xs:documentation>The background color to be used with the MapDefinition</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Metadata" type="xs:string" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>Metadata regarding the MapDefinition</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="MapLayer" type="MapLayerType" minOccurs="0" maxOccurs="unbounded">
+        <xs:annotation>
+          <xs:documentation>Zero or more MapLayers that make up the MapDefinition. The order of the layers represents the draw order, layers first is the list are drawn over top of layers later in the list.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="MapLayerGroup" type="MapLayerGroupType" minOccurs="0" maxOccurs="unbounded">
+        <xs:annotation>
+          <xs:documentation>Zero or more MapLayerGroups that make up the MapDefinition</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="BaseMapDefinition" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>The base map.</xs:documentation>
+        </xs:annotation>
+        <xs:complexType>
+          <xs:sequence>
+            <xs:element name="FiniteDisplayScale" type="xs:double" maxOccurs="unbounded">
+              <xs:annotation>
+                <xs:documentation>The display scales that the base map layers will have tiles available. Applies to the HTML viewer.</xs:documentation>
+              </xs:annotation>
+            </xs:element>
+            <xs:element name="BaseMapLayerGroup" type="BaseMapLayerGroupCommonType" minOccurs="0" maxOccurs="unbounded">
+              <xs:annotation>
+                <xs:documentation>A group of layers that is used to compose a tiled layer in the HTML viewer</xs:documentation>
+              </xs:annotation>
+            </xs:element>
+          </xs:sequence>
+        </xs:complexType>
+      </xs:element>
+      <xs:element name="Watermarks" type="WatermarkInstanceCollectionType" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>A group of watermarks that is used in the current map.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:element name="MapDefinition">
+    <xs:annotation>
+      <xs:documentation>A MapDefinition defines the collection of layers, groupings of layers, and base map</xs:documentation>
+    </xs:annotation>
+    <xs:complexType>
+      <xs:complexContent>
+        <xs:extension base="MapDefinitionType">
+          <xs:attribute name="version" type="xs:string" use="required" fixed="1.1.0"/>
+        </xs:extension>
+      </xs:complexContent>
+    </xs:complexType>
+  </xs:element>
+</xs:schema>

Added: trunk/MgDev/Common/Schema/WatermarkDefinition-1.0.0.xsd
===================================================================
--- trunk/MgDev/Common/Schema/WatermarkDefinition-1.0.0.xsd	                        (rev 0)
+++ trunk/MgDev/Common/Schema/WatermarkDefinition-1.0.0.xsd	2010-09-17 08:00:59 UTC (rev 5139)
@@ -0,0 +1,312 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.0.0">
+  <xs:include schemaLocation="SymbolDefinition-1.1.0.xsd"/>
+  <xs:element name="WatermarkDefinition">
+    <xs:annotation>
+      <xs:documentation>The specification of the watermark.</xs:documentation>
+    </xs:annotation>
+    <xs:complexType>
+      <xs:complexContent>
+        <xs:extension base="WatermarkDefinitionType">
+          <xs:attribute name="version" type="xs:string" use="required" fixed="1.0.0"/>
+        </xs:extension>
+      </xs:complexContent>
+    </xs:complexType>
+  </xs:element>
+  <xs:simpleType name="UnitType">
+    <xs:annotation>
+      <xs:documentation>Unit for watermark</xs:documentation>
+    </xs:annotation>
+    <xs:restriction base="xs:string">
+      <xs:enumeration value="Inches"/>
+      <xs:enumeration value="Centimeters"/>
+      <xs:enumeration value="Millimeters"/>
+      <xs:enumeration value="Pixels"/>
+      <xs:enumeration value="Points"/>
+    </xs:restriction>
+  </xs:simpleType>
+  <xs:simpleType name="HorizontalAlignmentType">
+    <xs:annotation>
+      <xs:documentation>Horizontal alignment for watermark</xs:documentation>
+    </xs:annotation>
+    <xs:restriction base="xs:string">
+      <xs:enumeration value="Left"/>
+      <xs:enumeration value="Center"/>
+      <xs:enumeration value="Right"/>
+    </xs:restriction>
+  </xs:simpleType>
+  <xs:complexType name="HorizontalPositionType">
+    <xs:annotation>
+      <xs:documentation>Horizontal position of watermark</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="Offset" type="xs:double" default="0">
+        <xs:annotation>
+          <xs:documentation>Horizontal offset</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Unit" type="UnitType" default="Points">
+        <xs:annotation>
+          <xs:documentation>Unit for horizontal offset</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Alignment" type="HorizontalAlignmentType" default="Center">
+        <xs:annotation>
+          <xs:documentation>Horizontal alignment</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:simpleType name="VerticalAlignmentType">
+    <xs:annotation>
+      <xs:documentation>Vertical alignment for watermark</xs:documentation>
+    </xs:annotation>
+    <xs:restriction base="xs:string">
+      <xs:enumeration value="Top"/>
+      <xs:enumeration value="Center"/>
+      <xs:enumeration value="Bottom"/>
+    </xs:restriction>
+  </xs:simpleType>
+  <xs:complexType name="VerticalPositionType">
+    <xs:annotation>
+      <xs:documentation>Vertical position of watermark</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="Offset" type="xs:double" default="0">
+        <xs:annotation>
+          <xs:documentation>Vertical offset</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Unit" type="UnitType" default="Points">
+        <xs:annotation>
+          <xs:documentation>Vertical for horizontal offset</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Alignment" type="VerticalAlignmentType"  default="Center">
+        <xs:annotation>
+          <xs:documentation>Vertical alignment</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="PositionType" abstract="true">
+    <xs:annotation>
+      <xs:documentation>Abstract position type for watermark.</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="XYPositionType">
+    <xs:annotation>
+      <xs:documentation>X/Y position</xs:documentation>
+    </xs:annotation>
+    <xs:complexContent>
+      <xs:extension base="PositionType">
+        <xs:sequence>
+          <xs:element name="XPosition" type="HorizontalPositionType">
+            <xs:annotation>
+              <xs:documentation>X position</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="YPosition" type="VerticalPositionType">
+            <xs:annotation>
+              <xs:documentation>Y position</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+        </xs:sequence>
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+  <xs:complexType name="TilePositionType">
+    <xs:annotation>
+      <xs:documentation>TiledPosition</xs:documentation>
+    </xs:annotation>
+    <xs:complexContent>
+      <xs:extension base="PositionType">
+        <xs:sequence>
+          <xs:element name="TileWidth" type="xs:double" default="150">
+            <xs:annotation>
+              <xs:documentation>Width of tile</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="TileHeight" type="xs:double" default="150">
+            <xs:annotation>
+              <xs:documentation>Height of tile</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="HorizontalPosition" type="HorizontalPositionType">
+            <xs:annotation>
+              <xs:documentation>Horizontal position within tile</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="VerticalPosition" type="VerticalPositionType">
+            <xs:annotation>
+              <xs:documentation>Vertical position within tile</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+        </xs:sequence>
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+  <xs:complexType name="WatermarkAppearanceType">
+    <xs:annotation>
+      <xs:documentation>Appearance of watermark</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="Transparency" minOccurs="0" default="0">
+        <xs:annotation>
+          <xs:documentation>The transparency of watermark (0 -100). The default value is 0 (opaque).</xs:documentation>
+        </xs:annotation>
+        <xs:simpleType>
+          <xs:restriction base="xs:double">
+            <xs:minInclusive value="0"/>
+            <xs:maxInclusive value="100"/>
+          </xs:restriction>
+        </xs:simpleType>
+      </xs:element>
+      <xs:element name="Rotation" minOccurs="0" default="0">
+        <xs:annotation>
+          <xs:documentation>The rotation of watermark (0-360). The default value is 0</xs:documentation>
+        </xs:annotation>
+        <xs:simpleType>
+          <xs:restriction base="xs:double">
+            <xs:minInclusive value="0"/>
+            <xs:maxInclusive value="360"/>
+          </xs:restriction>
+        </xs:simpleType>
+      </xs:element>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="WatermarkDefinitionType">
+    <xs:annotation>
+      <xs:documentation>Watermark definition contains content and position of watermark</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="WatermarkSource">
+        <xs:annotation>
+          <xs:documentation>Content source of watermark</xs:documentation>
+        </xs:annotation>
+        <xs:complexType>
+          <xs:choice>
+            <xs:element name="SimpleSymbolDefinition" type="SimpleSymbolDefinition">
+              <xs:annotation>
+                <xs:documentation>An inlined SimpleSymbolDefinition.</xs:documentation>
+              </xs:annotation>
+            </xs:element>
+            <xs:element name="CompoundSymbolDefinition" type="CompoundSymbolDefinition">
+              <xs:annotation>
+                <xs:documentation>An inlined CompoundSymbolDefinition.</xs:documentation>
+              </xs:annotation>
+            </xs:element>
+          </xs:choice>
+        </xs:complexType>
+      </xs:element>
+      <xs:element name="Appearance" type="WatermarkAppearanceType">
+        <xs:annotation>
+          <xs:documentation>The appearance of watermark.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Position">
+        <xs:annotation>
+          <xs:documentation>Position of watermark</xs:documentation>
+        </xs:annotation>
+        <xs:complexType>
+          <xs:choice>
+            <xs:element name="XYPosition" type="XYPositionType">
+              <xs:annotation>
+                <xs:documentation>A X-Y position</xs:documentation>
+              </xs:annotation>
+            </xs:element>
+            <xs:element name="TilePosition" type="TilePositionType">
+              <xs:annotation>
+                <xs:documentation>Tile position.</xs:documentation>
+              </xs:annotation>
+            </xs:element>
+          </xs:choice>
+        </xs:complexType>
+      </xs:element>
+      <xs:element name="ExtendedData" type="ExtendedDataType" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:simpleType name="UsageType">
+    <xs:annotation>
+      <xs:documentation>The situation that watermark can be used.</xs:documentation>
+    </xs:annotation>
+    <xs:restriction base="xs:string">
+      <xs:enumeration value="WMS">
+        <xs:annotation>
+          <xs:documentation>Watermark can show in WMS.</xs:documentation>
+        </xs:annotation>
+      </xs:enumeration>
+      <xs:enumeration value="Viewer">
+        <xs:annotation>
+          <xs:documentation>Watermark can show in AJAX viewer or Fusion viewer.</xs:documentation>
+        </xs:annotation>
+      </xs:enumeration>
+      <xs:enumeration value="ALL">
+        <xs:annotation>
+          <xs:documentation>Watermark can show in all situation.</xs:documentation>
+        </xs:annotation>
+      </xs:enumeration>
+    </xs:restriction>
+  </xs:simpleType>
+  <xs:complexType name="WatermarkType">
+    <xs:annotation>
+      <xs:documentation>Watermark instance used in map definition / layer definition.</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="Name" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>The name of watermark.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="ResourceId" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>A reference to an existing watermark definition.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Usage" type="UsageType" minOccurs="0" default="ALL">
+        <xs:annotation>
+          <xs:documentation>The situation that watermark can be used. The default value is ALL.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="AppearanceOverrides" type="WatermarkAppearanceType" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>The configuration here will override appearance configuration in watermark definition</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="PositionOverrides" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>The configuration here will override position configuration in watermark definition</xs:documentation>
+        </xs:annotation>
+        <xs:complexType>
+          <xs:choice>
+            <xs:element name="XYPosition" type="XYPositionType">
+              <xs:annotation>
+                <xs:documentation>A X-Y position</xs:documentation>
+              </xs:annotation>
+            </xs:element>
+            <xs:element name="TilePosition" type="TilePositionType">
+              <xs:annotation>
+                <xs:documentation>Tile position.</xs:documentation>
+              </xs:annotation>
+            </xs:element>
+          </xs:choice>
+        </xs:complexType>
+      </xs:element>
+      <xs:element name="ExtendedData" type="ExtendedDataType" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="WatermarkInstanceCollectionType">
+    <xs:annotation>
+      <xs:documentation>A collection of watermark used by map or layer.</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="Watermark" type="WatermarkType" minOccurs="0" maxOccurs="unbounded">
+        <xs:annotation>
+          <xs:documentation>A single watermark in the map definition or layer definition.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+    </xs:sequence>
+  </xs:complexType>
+</xs:schema>

Modified: trunk/MgDev/Common/Stylization/DefaultStylizer.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/DefaultStylizer.cpp	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/Stylization/DefaultStylizer.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -228,7 +228,18 @@
     m_styleEngine->ClearCache();
 }
 
+void DefaultStylizer::StylizeWatermark(Renderer* renderer,
+                                       MdfModel::WatermarkDefinition* watermark,
+                                       INT32 drawWidth,
+                                       INT32 drawHeight,
+                                       INT32 saveWidth,
+                                       INT32 saveHeight)
+{
+    m_styleEngine->StylizeWatermark((SE_Renderer*)renderer, watermark, drawWidth, drawHeight, saveWidth, saveHeight);
+    m_styleEngine->ClearCache();
+}
 
+
 //////////////////////////////////////////////////////////////////////////////
 int DefaultStylizer::StylizeVLHelper(MdfModel::VectorLayerDefinition* layer,
                                      MdfModel::VectorScaleRange*      scaleRange,

Modified: trunk/MgDev/Common/Stylization/DefaultStylizer.h
===================================================================
--- trunk/MgDev/Common/Stylization/DefaultStylizer.h	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/Stylization/DefaultStylizer.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -59,6 +59,13 @@
                                                      CSysTransformer*                  xformer,
                                                      double                            mapScale);
 
+    STYLIZATION_API virtual void StylizeWatermark(Renderer* renderer,
+                                                  MdfModel::WatermarkDefinition* watermark,
+                                                  INT32 drawWidth,
+                                                  INT32 drawHeight,
+                                                  INT32 saveWidth,
+                                                  INT32 saveHeight);
+
     STYLIZATION_API virtual void SetGeometryAdapter(FdoGeometryType type, GeometryAdapter* stylizer);
 
 private:

Modified: trunk/MgDev/Common/Stylization/SE_RenderProxies.h
===================================================================
--- trunk/MgDev/Common/Stylization/SE_RenderProxies.h	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/Stylization/SE_RenderProxies.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -161,6 +161,7 @@
     double position[2];
     double extent[2];
     double angleRad; // radians CCW
+    double opacity;
 };
 
 

Modified: trunk/MgDev/Common/Stylization/SE_Renderer.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/SE_Renderer.cpp	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/Stylization/SE_Renderer.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -485,7 +485,7 @@
                 xform.transform(rp->position[0], rp->position[1], x, y);
                 double angleDeg = (rp->angleRad + angleRad) * M_180PI;
 
-                DrawScreenRaster(imgData.data, imgData.size, imgData.format, imgData.width, imgData.height, x, y, rp->extent[0], rp->extent[1], angleDeg);
+                DrawScreenRaster(imgData.data, imgData.size, imgData.format, imgData.width, imgData.height, x, y, rp->extent[0], rp->extent[1], angleDeg, rp->opacity);
             }
         }
     }
@@ -673,7 +673,6 @@
     return ret;
 }
 
-
 //////////////////////////////////////////////////////////////////////////////
 // Indicates whether rendering optimization is used by this renderer.  For example, if we are rendering text and
 // optimization is turned on, then text is rendered as a simple line when it is very small.

Modified: trunk/MgDev/Common/Stylization/SE_Renderer.h
===================================================================
--- trunk/MgDev/Common/Stylization/SE_Renderer.h	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/Stylization/SE_Renderer.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -87,6 +87,13 @@
     virtual void DrawScreenRaster(unsigned char* data, int length,
                                   RS_ImageFormat format, int native_width, int native_height,
                                   double x, double y, double w, double h, double angleDeg) = 0;
+    // Draw screen raster with alpha
+    // Alpha is a value between 0 and 1.
+    // 0 means completely transparent, while 1 means completely opaque.
+    virtual void DrawScreenRaster(unsigned char* data, int length,
+                                  RS_ImageFormat format, int native_width, int native_height,
+                                  double x, double y, double w, double h, double angleDeg,
+                                  double alpha) = 0;
     virtual void DrawScreenText(const RS_TextMetrics& tm, RS_TextDef& tdef, double insx, double insy,
                                 RS_F_Point* path, int npts, double param_position) = 0;
 

Modified: trunk/MgDev/Common/Stylization/SE_SymbolDefProxies.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/SE_SymbolDefProxies.cpp	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/Stylization/SE_SymbolDefProxies.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -527,6 +527,8 @@
 
     ret->angleRad = fmod(angleDeg.evaluate(ctx->exec), 360.0) * M_PI180;
 
+    ret->opacity = opacity.evaluate(ctx->exec);
+
     SE_Matrix rxf;
     rxf.rotate(ret->angleRad);
     rxf.translate(ret->position[0], ret->position[1]);

Modified: trunk/MgDev/Common/Stylization/SE_SymbolDefProxies.h
===================================================================
--- trunk/MgDev/Common/Stylization/SE_SymbolDefProxies.h	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/Stylization/SE_SymbolDefProxies.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -150,9 +150,12 @@
     SE_Double extent[2];
     SE_Boolean sizeScalable;
     SE_Double angleDeg; // degrees CCW
+    SE_Double opacity;
 
     SE_INLINE SE_Raster() : ownPtr(false)
-    {}
+    {
+        opacity.value = opacity.defValue = 1;
+    }
 
     ~SE_Raster()
     {

Modified: trunk/MgDev/Common/Stylization/Stylization.h
===================================================================
--- trunk/MgDev/Common/Stylization/Stylization.h	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/Stylization/Stylization.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -69,6 +69,16 @@
 #include "Text.h"
 #include "Override.h"
 
+#include "WatermarkDefinition.h"
+#include "WatermarkAppearance.h"
+#include "WatermarkInstance.h"
+#include "WatermarkPosition.h"
+#include "XYWatermarkPosition.h"
+#include "TileWatermarkPosition.h"
+#include "WatermarkXOffset.h"
+#include "WatermarkYOffset.h"
+#include "WatermarkOffsetUnit.h"
+
 #include "Base64.h"
 
 // FDO headers

Modified: trunk/MgDev/Common/Stylization/StylizationEngine.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/StylizationEngine.cpp	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/Stylization/StylizationEngine.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -199,7 +199,557 @@
     #endif
 }
 
+// opaque is a double between 0 and 1.
+// 0 means totally transparent, while 1 means totally opaque.
+// The caller should be responsible for validating opaque value.
+inline unsigned int TransparentColor(unsigned int argb, double opaque)
+{
+    //unsigned int alpha = (unsigned int)(((argb >> 24) & 0xFF) * opaque);
+    return argb & 0xFFFFFF 
+        | (((unsigned int)(((argb >> 24) & 0xFF)* opaque)) << 24);
+}
 
+// Unit can't be Pixels.
+// The caller should be responsible for not input pixel
+inline double GetUnitPerMeter(WatermarkOffset::WatermarkOffsetUnit unit)
+{
+    switch(unit)
+    {
+    case WatermarkOffset::Centimeters:
+        return LengthConverter::MetersToUnit(MdfModel::Centimeters, 1);
+        break;
+    case WatermarkOffset::Inches:
+        return LengthConverter::MetersToUnit(MdfModel::Inches, 1);
+        break;
+    case WatermarkOffset::Millimeters:
+        return LengthConverter::MetersToUnit(MdfModel::Millimeters, 1);
+        break;
+    case WatermarkOffset::Points:
+        return LengthConverter::MetersToUnit(MdfModel::Points, 1);
+        break;
+    default:
+        return 1;
+        break;
+    }
+}
+
+void StylizationEngine::StylizeWatermark(SE_Renderer* se_renderer,
+                                         WatermarkDefinition* watermark,
+                                         INT32 drawWidth,
+                                         INT32 drawHeight,
+                                         INT32 saveWidth,
+                                         INT32 saveHeight)
+{
+    m_serenderer = se_renderer;
+    m_reader = NULL;
+
+    double drawingScale = m_serenderer->GetDrawingScale();
+
+    // get tooltip and url for the layer
+    SE_String seTip;
+    SE_String seUrl;
+    if (se_renderer->SupportsTooltips())
+        m_visitor->ParseStringExpression(L"", seTip, L"");
+    if (se_renderer->SupportsHyperlinks())
+        m_visitor->ParseStringExpression(L"", seUrl, L"");
+    
+    std::auto_ptr<SE_Rule> rule(new SE_Rule());
+
+    //Translate watermark source into SE_SymbolInstance list.
+    //As the source is adopted into symbol, we need to detach them after the rendering is done.
+    std::auto_ptr<CompositeSymbolization> symbols(new CompositeSymbolization());
+
+    std::auto_ptr<SymbolInstance> instance(new SymbolInstance());
+    instance->AdoptSymbolDefinition(watermark->GetSource());
+    instance->SetUsageContext(SymbolInstance::ucPoint);
+    symbols->GetSymbolCollection()->Adopt(instance.release());
+
+    m_visitor->Convert(rule->symbolInstances, symbols.get());
+    _ASSERT(rule->symbolInstances.size() == 1u);
+    
+    // Translate appearance (transparency / rotation) into symbol instance
+    // Prepare values
+    double transparency = watermark->GetAppearance()->GetTransparency();
+    transparency = (transparency < 0) ? 0 : ((transparency > 100) ? 100 : transparency);
+    double opacity = 1 - transparency / 100;
+    double rotation = watermark->GetAppearance()->GetRotation();
+    rotation = (rotation < 0) ? 0 : ((rotation > 360) ? 360 : rotation);
+
+    SE_SymbolInstance* sym = rule->symbolInstances[0];
+    size_t nStyles = sym->styles.size();
+    for (size_t styleIx=0; styleIx<nStyles; ++styleIx)
+    {
+        SE_PointStyle* style = (SE_PointStyle*)(sym->styles[styleIx]);
+        style->angleDeg.value = style->angleDeg.defValue = style->angleDeg.defValue + rotation;
+        if(style->symbol.size() == 0) continue;
+        
+        if(1 - opacity < 0.0001) continue;    //The opaque is 1.
+        size_t nPrimitives = style->symbol.size();
+        for (size_t primitiveIx=0; primitiveIx<nPrimitives; ++primitiveIx)
+        {
+            SE_Primitive* primitive = style->symbol[primitiveIx];
+            SE_Text* textPri = dynamic_cast<SE_Text*>(primitive);
+            SE_Polygon* polygonPri = dynamic_cast<SE_Polygon*>(primitive);
+            SE_Polyline* linePri = dynamic_cast<SE_Polyline*>(primitive);
+            SE_Raster* rasterPri = dynamic_cast<SE_Raster*>(primitive);
+            if(textPri)
+            {
+                //Text need to change color
+                textPri->textColor.value.argb = textPri->textColor.defValue.argb
+                    = TransparentColor(textPri->textColor.defValue.argb, opacity);
+                textPri->ghostColor.value.argb = textPri->ghostColor.defValue.argb
+                    = TransparentColor(textPri->ghostColor.defValue.argb, opacity);
+                textPri->frameLineColor.value.argb = textPri->frameLineColor.defValue.argb
+                    = TransparentColor(textPri->frameLineColor.defValue.argb, opacity);
+                textPri->frameFillColor.value.argb = textPri->frameFillColor.defValue.argb
+                    = TransparentColor(textPri->frameFillColor.defValue.argb, opacity);
+            }
+            else if(linePri)
+            {
+                linePri->color.value.argb = linePri->color.defValue.argb
+                    = TransparentColor(linePri->color.defValue.argb, opacity);
+                if(polygonPri)
+                {
+                    polygonPri->fill.value.argb = polygonPri->fill.defValue.argb
+                        = TransparentColor(polygonPri->fill.defValue.argb, opacity);
+                }
+            }
+            else if(rasterPri)
+            {
+                rasterPri->opacity.value = rasterPri->opacity.defValue = opacity;
+            }
+        }
+    }
+    
+    //Prepare some rendering context variable
+    double mm2sud = m_serenderer->GetScreenUnitsPerMillimeterDevice();
+    double mm2suw = m_serenderer->GetScreenUnitsPerMillimeterWorld();
+    double px2su  = m_serenderer->GetScreenUnitsPerPixel();
+    bool yUp = m_serenderer->YPointsUp();
+
+    // the factor to convert screen units to mapping units
+    double su2wu = 0.001 / (mm2suw * m_serenderer->GetMetersPerUnit());
+
+    //Prepare the position list
+    XYWatermarkPosition* xyPosition = dynamic_cast<XYWatermarkPosition*>(
+        watermark->GetPosition());
+    TileWatermarkPosition* tilePosition = dynamic_cast<TileWatermarkPosition*>(
+        watermark->GetPosition());
+    WatermarkXOffset::HorizontalAlignment hAlignment = WatermarkXOffset::Center;
+    WatermarkYOffset::VerticalAlignment vAlignment = WatermarkYOffset::Center;
+    WatermarkOffset::WatermarkOffsetUnit hUnit, vUnit;
+    double suPerhUnit, suPervUnit, xOffset, yOffset;
+    if(xyPosition)
+    {
+        hAlignment = xyPosition->GetXPosition()->GetAlignment();
+        vAlignment = xyPosition->GetYPosition()->GetAlignment();
+        hUnit = xyPosition->GetXPosition()->GetUnit();
+        vUnit = xyPosition->GetYPosition()->GetUnit();
+        xOffset = xyPosition->GetXPosition()->GetLength();      //In watermark unit
+        yOffset = xyPosition->GetYPosition()->GetLength();      //In watermark unit
+    }
+    else if(tilePosition)
+    {
+        hAlignment = tilePosition->GetHorizontalPosition()->GetAlignment();
+        vAlignment = tilePosition->GetVerticalPosition()->GetAlignment();
+        hUnit = tilePosition->GetHorizontalPosition()->GetUnit();
+        vUnit = tilePosition->GetVerticalPosition()->GetUnit();
+        xOffset = tilePosition->GetHorizontalPosition()->GetLength();      //In watermark unit
+        yOffset = tilePosition->GetVerticalPosition()->GetLength();        //In watermark unit
+    }
+    double pixelPerMeterDevice = 1000*mm2sud/px2su;
+    suPerhUnit = ((hUnit == WatermarkOffset::Pixels) 
+                    ? 1
+                    : pixelPerMeterDevice / GetUnitPerMeter(hUnit)) * px2su;
+    suPervUnit = ((vUnit == WatermarkOffset::Pixels) 
+                    ? 1
+                    : pixelPerMeterDevice / GetUnitPerMeter(vUnit)) * px2su;
+    xOffset *= suPerhUnit;      //In screen unit
+    yOffset *= suPervUnit;      //In screen unit
+
+
+    std::vector<double> watermarkPosList;
+    if(xyPosition)
+    {
+        switch(hAlignment)
+        {
+        case WatermarkXOffset::Right:
+            xOffset = saveWidth - xOffset;
+            break;
+        case WatermarkXOffset::Left:
+            break;
+        default:
+            xOffset += saveWidth/2;
+            break;
+        }
+        switch(vAlignment)
+        {
+        case WatermarkYOffset::Bottom:
+            yOffset = yUp ? yOffset : saveHeight - yOffset;
+            break;
+        case WatermarkYOffset::Top:
+            yOffset = yUp ? saveHeight - yOffset : yOffset;
+            break;
+        default:
+            yOffset = saveHeight/2 + (yUp ? yOffset : (-yOffset));
+            break;
+        }
+        xOffset *= drawWidth / saveWidth;
+        yOffset *= drawHeight / saveHeight;
+        double mapPosX, mapPosY;
+        m_serenderer->ScreenToWorldPoint(xOffset, yOffset, mapPosX, mapPosY);
+        watermarkPosList.push_back(mapPosX);
+        watermarkPosList.push_back(mapPosY);
+    }
+    else if(tilePosition)
+    {
+        double tileWidth = tilePosition->GetTileWidth()*px2su, 
+            tileHeight = tilePosition->GetTileHeight()*px2su;
+        switch(hAlignment)
+        {
+        case WatermarkXOffset::Right:
+            xOffset = tileWidth - xOffset;
+            break;
+        case WatermarkXOffset::Left:
+            break;
+        default:
+            xOffset += tileWidth/2;
+            break;
+        }
+        switch(vAlignment)
+        {
+        case WatermarkYOffset::Bottom:
+            yOffset = yUp ? yOffset : tileHeight - yOffset;
+            break;
+        case WatermarkYOffset::Top:
+            yOffset = yUp ? tileHeight - yOffset : yOffset;
+            break;
+        default:
+            yOffset = tileHeight/2 + (yUp ? yOffset : (-yOffset));
+            break;
+        }
+        double drawPosX, drawPosY, mapPosX, mapPosY;
+        for(int i = 0; i<= (int)(saveWidth/tileWidth); i++)
+        {
+            for(int j = 0; j <= (int)(saveHeight/tileHeight); j++)
+            {
+                drawPosX = i*tileWidth+xOffset;
+                drawPosY = yUp ? (saveHeight-(j+1)*tileHeight+yOffset) : j*tileHeight+yOffset;
+                xOffset *= drawWidth / saveWidth;
+                yOffset *= drawHeight / saveHeight;
+                m_serenderer->ScreenToWorldPoint(drawPosX, drawPosY, mapPosX, mapPosY);
+                watermarkPosList.push_back(mapPosX);
+                watermarkPosList.push_back(mapPosY);
+            }
+        }
+    }
+
+    // we always start with rendering pass 0
+    int symbolRenderingPass = 0;
+    int nextSymbolRenderingPass = -1;
+
+    // main loop over feature data
+    int numPasses = 0;
+    while (symbolRenderingPass >= 0)
+    {
+        ++numPasses;
+
+        // create an expression engine with our custom functions
+        // NOTE: We must create a new engine with each rendering pass.  The engine
+        //       stores a weak reference to the RS_FeatureReader's internal
+        //       FdoIFeatureReader, and this internal reader is different for each
+        //       pass.
+        FdoPtr<FdoExpressionEngine> exec = ExpressionHelper::GetExpressionEngine(se_renderer, NULL);
+
+        std::auto_ptr<LineBuffer> spLB;
+        size_t nPos = watermarkPosList.size();
+        for (size_t posIx=0; posIx<nPos; posIx+=2)
+        {
+            //Get geometry
+            LineBuffer* lb = LineBufferPool::NewLineBuffer(
+                m_pool, 8, FdoDimensionality_Z);
+            spLB.reset(lb);
+            lb->MoveTo(watermarkPosList[posIx], watermarkPosList[posIx+1]);
+            // tell line buffer the current drawing scale (used for arc tessellation)
+            lb->SetDrawingScale(drawingScale);
+
+            //Render line buffer
+            
+            // -------------------------------------------------------------------------
+            //
+            // Here's a description of how the transforms work for point symbols.
+            //
+            // =============
+            // Point Symbols
+            // =============
+            //
+            // For point symbols we have the following transform stack:
+            //
+            //   [T_fe] [S_mm] [T_si] [R_pu] [S_si] [T_pu] {Geom}
+            //
+            // where:
+            //   T_pu = point usage origin offset (a translation)
+            //   S_si = symbol instance scaling
+            //   R_pu = point usage rotation
+            //   T_si = symbol instance insertion offset
+            //   S_mm = scaling converting mm to screen units (also includes inverting y, if necessary)
+            //   T_fe = translation to the point feature
+            //
+            // This can be rewritten as:
+            //
+            //   [T_fe] [T_si*] [R_pu*] [T_pu*] [S_mm] [S_si] {Geom}
+            //
+            // where:
+            //   T_si* = symbol instance insertion offset, using offsets scaled by S_mm
+            //   R_pu* = point usage rotation, with angle accounting for y-up or y-down
+            //   T_pu* = point usage origin offset, using offsets scaled by S_mm and S_si
+            //
+            // We store [S_mm] [S_si] in xformScale below, and apply it to the symbol geometry
+            // during symbol evaluation.  The remaining transforms get applied in SE_Renderer::
+            // ProcessPoint.
+            // -------------------------------------------------------------------------
+
+            // TODO: Obey the indices - get rid of the indices altogther - single pass!
+
+            // For now always clip using the new stylization - the performance impact of not
+            // clipping is too high.  We also need a better approach to clipping.  Instead
+            // of clipping the feature geometry we need to calculate where to start/stop
+            // drawing symbols.
+            bool bClip = true;  //m_serenderer->RequiresClipping();
+            double clipOffsetSU = 0.0;
+
+            // Make a pass over all the instances.  During this pass we:
+            // - evaluate the active styles
+            // - compute the overall clip offset
+
+            SE_Matrix xformScale;
+            xformScale.scale(sym->scale[0].evaluate(exec),
+                             sym->scale[1].evaluate(exec));
+
+            // The symbol geometry needs to be inverted if the y coordinate in the renderer
+            // points down.  This is so that in symbol definitions y points up consistently
+            // no matter what the underlying renderer is doing.  Normally we could just apply
+            // the world to screen transform to everything, but in some cases we only apply
+            // it to the position of the symbol and then offset the symbol geometry from
+            // there - so the symbol geometry needs to be pre-inverted.
+            double mm2suX = (sym->sizeContext == MappingUnits)? mm2suw : mm2sud;
+            double mm2suY = yUp? mm2suX : -mm2suX;
+            xformScale.scale(mm2suX, mm2suY);
+
+            // initialize the style evaluation context
+            SE_EvalContext evalCtx;
+            evalCtx.exec = exec;
+            evalCtx.mm2su = mm2suX;
+            evalCtx.mm2sud = mm2sud;
+            evalCtx.mm2suw = mm2suw;
+            evalCtx.px2su = px2su;
+            evalCtx.pool = m_pool;
+            evalCtx.fonte = m_serenderer->GetRSFontEngine();
+            evalCtx.xform = &xformScale;
+            evalCtx.resources = m_resources;
+
+            // iterate over all styles in the instance
+            for (size_t styIx=0; styIx<nStyles; ++styIx)
+            {
+                SE_Style* style = sym->styles[styIx];
+
+                // process the symbol rendering pass - negative rendering passes are
+                // rendered with pass 0
+                int symbolRenderPass = style->renderPass.evaluate(exec);
+                if (symbolRenderPass < 0)
+                    symbolRenderPass = 0;
+
+                // if the rendering pass for the style doesn't match the current pass
+                // then don't render using it
+                if (symbolRenderPass != symbolRenderingPass)
+                    continue;
+
+                // evaluate the style (all expressions inside it) and convert to a
+                // constant screen space render style
+                style->evaluate(&evalCtx);
+            }
+
+            // Adjust the offset according to watermark position
+            // For example, the watermark is on top/left, the original offset is enough.
+            // However, if the watermark is on bottom/right, the symbols has to be added
+            // an offset to make the bottom/right of their bounds to be the position.
+            RS_F_Point bounds[4];
+            bounds[0].x = bounds[3].x = +DBL_MAX;
+            bounds[1].x = bounds[2].x = -DBL_MAX;
+            bounds[0].y = bounds[1].y = +DBL_MAX;
+            bounds[2].y = bounds[3].y = -DBL_MAX;
+            for (size_t styIx=0; styIx<nStyles; ++styIx)
+            {
+                SE_RenderPointStyle* ptStyle = (SE_RenderPointStyle*)(
+                    sym->styles[styIx]->rstyle);
+                SE_Matrix xformStyle;
+
+                // point usage offset (already scaled)
+                xformStyle.translate(ptStyle->offset[0], ptStyle->offset[1]);
+                // point usage rotation - assume geometry angle is zero
+                xformStyle.rotate(ptStyle->angleRad);
+                // compute the offset
+                for (int i=0; i<4; ++i)
+                {
+                    // account for the style-specific transform
+                    RS_F_Point pt = ptStyle->bounds[i];
+                    xformStyle.transform(pt.x, pt.y);
+                    bounds[0].x = bounds[3].x = rs_min(bounds[0].x, pt.x);
+                    bounds[1].x = bounds[2].x = rs_max(bounds[2].x, pt.x);
+                    bounds[0].y = bounds[1].y = rs_min(bounds[0].y, pt.y);
+                    bounds[2].y = bounds[3].y = rs_max(bounds[2].y, pt.y);
+                }
+            }
+            // bounds[0].x is left, bounds[1].x is right
+            switch(hAlignment)
+            {
+            case WatermarkXOffset::Right:
+                sym->absOffset[0].value = sym->absOffset[0].defValue 
+                                        = -bounds[1].x / mm2suX;
+                break;
+            case WatermarkXOffset::Left:
+                sym->absOffset[0].value = sym->absOffset[0].defValue 
+                                        = -bounds[0].x / mm2suX;
+                break;
+            default:
+                sym->absOffset[0].value = sym->absOffset[0].defValue 
+                                        = -(bounds[0].x + bounds[1].x) / 2 / mm2suX;
+                break;
+            }
+            // bounds[1].y is bottom, bounds[2].y is top
+            switch(vAlignment)
+            {
+            case WatermarkYOffset::Bottom:
+                sym->absOffset[1].value = sym->absOffset[1].defValue 
+                                        = (yUp ? (-bounds[1].y) : bounds[1].y) / mm2suY;
+                break;
+            case WatermarkYOffset::Top:
+                sym->absOffset[1].value = sym->absOffset[1].defValue 
+                                        = (yUp ? (-bounds[2].y) : bounds[2].y) / mm2suY;
+                break;
+            default:
+                sym->absOffset[1].value = sym->absOffset[1].defValue 
+                    = (yUp ? -1: 1)*((bounds[1].y + bounds[2].y) / 2 / mm2suY);
+                break;
+            }
+
+            // prepare the geometry on which we will apply the styles
+
+            if (bClip)
+            {
+                // compute offset to apply to the clipping bounds
+                for (size_t styIx=0; styIx<nStyles; ++styIx)
+                {
+                    SE_Style* style = sym->styles[styIx];
+                    double styleClipOffsetSU = GetClipOffset(sym, style, exec, mm2suX, mm2suY);
+                    clipOffsetSU = rs_max(styleClipOffsetSU, clipOffsetSU);
+                }
+
+                // compute the clip region to use - start with the map request extents
+                RS_Bounds clip = m_serenderer->GetBounds();
+
+                // add one pixel's worth to handle any roundoff
+                clipOffsetSU += px2su;
+
+                // limit the offset to something reasonable
+                if (clipOffsetSU > MAX_CLIPOFFSET_IN_MM * mm2sud)
+                    clipOffsetSU = MAX_CLIPOFFSET_IN_MM * mm2sud;
+
+                // expand clip region by the offset
+                double clipOffsetWU = clipOffsetSU * su2wu;
+                clip.minx -= clipOffsetWU;
+                clip.miny -= clipOffsetWU;
+                clip.maxx += clipOffsetWU;
+                clip.maxy += clipOffsetWU;
+
+                // clip geometry to given extents
+                LineBuffer* lbc = lb->Clip(clip, LineBuffer::ctAGF, m_pool);
+                if (lbc != lb)
+                {
+                    // if the clipped buffer is NULL (completely clipped) just move on to
+                    // the next feature
+                    if (!lbc) continue;
+
+                    // otherwise continue processing with the clipped buffer
+                    lb = lbc;
+                    spLB.reset(lb);
+                }
+            }
+
+            // Make another pass over all the instances.  During this pass we:
+            // - compute the next symbol rendering pass
+            // - apply the styles to the geometry (original or clipped)
+
+            // initialize the style application context
+            SE_Matrix xformTrans;
+            xformTrans.translate(sym->absOffset[0].evaluate(exec) * mm2suX,
+                                 sym->absOffset[1].evaluate(exec) * mm2suY);
+
+            SE_ApplyContext applyCtx;
+            applyCtx.geometry = lb;
+            applyCtx.renderer = m_serenderer;
+            applyCtx.xform = &xformTrans;
+
+            for (size_t styIx=0; styIx<nStyles; ++styIx)
+            {
+                SE_Style* style = sym->styles[styIx];
+
+                // process the symbol rendering pass - negative rendering passes are
+                // rendered with pass 0
+                int symbolRenderPass = style->renderPass.evaluate(exec);
+                if (symbolRenderPass < 0)
+                    symbolRenderPass = 0;
+
+                // If the rendering pass for the style doesn't match the current pass
+                // then don't render using it.
+                if (symbolRenderPass != symbolRenderingPass)
+                {
+                    // if the style's rendering pass is greater than the current pass,
+                    // then update nextRenderingPass to account for it
+                    if (symbolRenderPass > symbolRenderingPass)
+                    {
+                        // update nextRenderingPass if it hasn't yet been set, or if
+                        // the style's pass is less than the current next pass
+                        if (nextSymbolRenderingPass == -1 || symbolRenderPass < nextSymbolRenderingPass)
+                            nextSymbolRenderingPass = symbolRenderPass;
+                    }
+
+                    continue;
+                }
+
+                // TODO: why are these in the symbol instance?
+                style->rstyle->addToExclusionRegion = sym->addToExclusionRegion.evaluate(exec);
+                style->rstyle->checkExclusionRegion = sym->checkExclusionRegion.evaluate(exec);
+                style->rstyle->drawLast = sym->drawLast.evaluate(exec);
+
+                const wchar_t* positioningAlgo = sym->positioningAlgorithm.evaluate(exec);
+                if (wcslen(positioningAlgo) > 0)
+                {
+                    LayoutCustomLabel(positioningAlgo, &applyCtx, style->rstyle, mm2suX);
+                }
+                else
+                {
+                    // apply the style to the geometry using the renderer
+                    style->apply(&applyCtx);
+                }
+            }
+
+
+            if(spLB.get())
+                LineBufferPool::FreeLineBuffer(m_pool, spLB.release());
+        }
+        // switch to the next symbol rendering pass
+        symbolRenderingPass = nextSymbolRenderingPass;
+        nextSymbolRenderingPass = -1;
+    }
+
+    // Detach symbol definition from the created composite symbol so that
+    // it will not be finalized when composite symbol is finalized. 
+    // The code is sure there is only one symbol instance.
+    _ASSERT(symbols->GetSymbolCollection()->GetCount() == 1);
+    symbols->GetSymbolCollection()->GetAt(0)->OrphanSymbolDefinition();
+}
+
 void StylizationEngine::Stylize(RS_FeatureReader* reader,
                                 FdoExpressionEngine* exec,
                                 LineBuffer* geometry,
@@ -798,7 +1348,10 @@
     }
     else if (wcscmp(positioningAlgo, L"MultipleHighwayShields") == 0)
     {
-        SE_PositioningAlgorithms::MultipleHighwaysShields(applyCtx, rstyle, mm2su, m_reader, m_resources);
+        if(m_reader)
+        {
+            SE_PositioningAlgorithms::MultipleHighwaysShields(applyCtx, rstyle, mm2su, m_reader, m_resources);
+        }
     }
     else if (wcscmp(positioningAlgo, L"Default") == 0)
     {

Modified: trunk/MgDev/Common/Stylization/StylizationEngine.h
===================================================================
--- trunk/MgDev/Common/Stylization/StylizationEngine.h	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/Stylization/StylizationEngine.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -69,6 +69,14 @@
                             CancelStylization                cancel,
                             void*                            userData);
 
+    //Stylize the supplied watermark
+    void StylizeWatermark(SE_Renderer* se_renderer,
+                          WatermarkDefinition* watermark,
+                          INT32 drawWidth,
+                          INT32 drawHeight,
+                          INT32 saveWidth,
+                          INT32 saveHeight);
+
     // Stylizes the current feature on the reader using the supplied composite type style.
     void Stylize(RS_FeatureReader* reader,
                  FdoExpressionEngine* exec,

Modified: trunk/MgDev/Common/Stylization/Stylizer.h
===================================================================
--- trunk/MgDev/Common/Stylization/Stylizer.h	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Common/Stylization/Stylizer.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -76,6 +76,16 @@
                                      double                            mapScale) = 0;
 
     ///<summary>
+    /// Stylizes a watermark.
+    ///</summary>
+    virtual void StylizeWatermark(Renderer* renderer,
+                                  MdfModel::WatermarkDefinition* watermark,
+                                  INT32 drawWidth,
+                                  INT32 drawHeight,
+                                  INT32 saveWidth,
+                                  INT32 saveHeight) = 0;
+
+    ///<summary>
     /// Allows a user to set a custom stylization object for a given geometry type.
     ///</summary>
     virtual void SetGeometryAdapter(FdoGeometryType type, GeometryAdapter* stylizer) = 0;

Modified: trunk/MgDev/Server/src/Services/Rendering/FeatureInfoRenderer.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Rendering/FeatureInfoRenderer.cpp	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Server/src/Services/Rendering/FeatureInfoRenderer.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -287,7 +287,15 @@
     }
 }
 
+void FeatureInfoRenderer::DrawScreenRaster(unsigned char* data, int length,
+                                  RS_ImageFormat format, int native_width, int native_height,
+                                  double x, double y, double w, double h, double angleDeg,
+                                  double alpha)
+{
+    DrawScreenRaster(data, length, format, native_width, native_height, x, y, w, h, angleDeg);
+}
 
+
 void FeatureInfoRenderer::DrawScreenText(const RS_TextMetrics& tm, RS_TextDef& tdef, double insx, double insy,
                                          RS_F_Point* path, int npts, double param_position)
 {

Modified: trunk/MgDev/Server/src/Services/Rendering/FeatureInfoRenderer.h
===================================================================
--- trunk/MgDev/Server/src/Services/Rendering/FeatureInfoRenderer.h	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Server/src/Services/Rendering/FeatureInfoRenderer.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -148,6 +148,10 @@
     virtual void DrawScreenRaster(unsigned char* data, int length,
                                   RS_ImageFormat format, int native_width, int native_height,
                                   double x, double y, double w, double h, double angleDeg);
+    virtual void DrawScreenRaster(unsigned char* data, int length,
+                                  RS_ImageFormat format, int native_width, int native_height,
+                                  double x, double y, double w, double h, double angleDeg,
+                                  double alpha);
     virtual void DrawScreenText(const RS_TextMetrics& tm, RS_TextDef& tdef, double insx, double insy,
                                 RS_F_Point* path, int npts, double param_position);
 

Modified: trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -267,7 +267,7 @@
     baseGroup->SetVisible(true);
 
     // call the internal helper API to do all the stylization overhead work
-    ret = RenderMapInternal(map, NULL, roLayers, dr.get(), width, height, format, scale, extent, true, true);
+    ret = RenderMapInternal(map, NULL, roLayers, dr.get(), width, height, width, height, format, scale, extent, true, true, false);
 
     // restore the base group's visibility
     baseGroup->SetVisible(groupVisible);
@@ -361,7 +361,7 @@
     }
 
     // call the internal helper API to do all the stylization overhead work
-    ret = RenderMapInternal(map, selection, roLayers, dr.get(), width, height, scale, extent, false, options);
+    ret = RenderMapInternal(map, selection, roLayers, dr.get(), width, height, width, height, scale, extent, false, options, true);
 
     MG_CATCH_AND_THROW(L"MgServerRenderingService.RenderDynamicOverlay")
 
@@ -530,7 +530,7 @@
     auto_ptr<SE_Renderer> dr(CreateRenderer(drawWidth, drawHeight, bgcolor, false));
 
     // call the internal helper API to do all the stylization overhead work
-    ret = RenderMapInternal(map, selection, NULL, dr.get(), width, height, format, scale, b, false, bKeepSelection);
+    ret = RenderMapInternal(map, selection, NULL, dr.get(), drawWidth, drawHeight, width, height, format, scale, b, false, bKeepSelection, true);
 
     MG_CATCH_AND_THROW(L"MgServerRenderingService.RenderMap")
 
@@ -622,7 +622,7 @@
     auto_ptr<SE_Renderer> dr(CreateRenderer(width, height, bgcolor, bClip));
 
     // call the internal helper API to do all the stylization overhead work
-    ret = RenderMapInternal(map, selection, NULL, dr.get(), width, height, format, scale, b, false, bKeepSelection);
+    ret = RenderMapInternal(map, selection, NULL, dr.get(), width, height, width, height, format, scale, b, false, bKeepSelection, true);
 
     MG_CATCH_AND_THROW(L"MgServerRenderingService.RenderMap")
 
@@ -781,20 +781,22 @@
                                                           MgSelection* selection,
                                                           MgReadOnlyLayerCollection* roLayers,
                                                           SE_Renderer* dr,
+                                                          INT32 drawWidth,
+                                                          INT32 drawHeight,
                                                           INT32 saveWidth,
                                                           INT32 saveHeight,
                                                           CREFSTRING format,
                                                           double scale,
                                                           RS_Bounds& b,
                                                           bool expandExtents,
-                                                          bool bKeepSelection)
+                                                          bool bKeepSelection,
+                                                          bool renderingWatermark)
 {
     MgRenderingOptions options(format, MgRenderingOptions::RenderSelection |
         MgRenderingOptions::RenderLayers | (bKeepSelection? MgRenderingOptions::KeepSelection : 0), NULL);
-    return RenderMapInternal(map, selection, roLayers, dr, saveWidth, saveHeight, scale, b, expandExtents, &options);
+    return RenderMapInternal(map, selection, roLayers, dr, drawWidth, drawHeight, saveWidth, saveHeight, scale, b, expandExtents, &options, renderingWatermark);
 }
 
-
 ///////////////////////////////////////////////////////////////////////////////
 // called from (indirectly):
 //      RenderMap(complete), RenderMap(extent)(roLayers == NULL)
@@ -807,12 +809,15 @@
                                                           MgSelection* selection,
                                                           MgReadOnlyLayerCollection* roLayers,
                                                           SE_Renderer* dr,
+                                                          INT32 drawWidth,
+                                                          INT32 drawHeight,
                                                           INT32 saveWidth,
                                                           INT32 saveHeight,
                                                           double scale,
                                                           RS_Bounds& b,
                                                           bool expandExtents,
-                                                          MgRenderingOptions* options)
+                                                          MgRenderingOptions* options,
+                                                          bool renderingWatermark)
 {
     // set the map scale to the requested scale
     map->SetViewScale(scale);
@@ -935,6 +940,128 @@
             }
         }
 
+        if(renderingWatermark)
+        {
+            //Rendering watermark
+            Ptr<MgStringCollection> watermarkIds = new MgStringCollection(); //ID list to load watermark definition
+            auto_ptr<WatermarkInstanceCollection> watermarkInstances(
+                new WatermarkInstanceCollection());     //Watermark list to render
+            auto_ptr<WatermarkInstanceCollection> tempWatermarkInstances(
+                new WatermarkInstanceCollection());    //Used to reverse list
+            auto_ptr<WatermarkInstance> tempInstance;
+
+            //Get watermark instance in map
+            Ptr<MgResourceIdentifier> mapId = map->GetMapDefinition();
+            if(mapId.p)
+            {
+                auto_ptr<MapDefinition> mdef(
+                    MgMapBase::GetMapDefinition(m_svcResource, mapId));
+                WatermarkInstanceCollection* mapWatermarks = mdef->GetWatermarks();
+                for(int i = mapWatermarks->GetCount()-1; i>=0; i--)
+                    tempWatermarkInstances->Adopt(mapWatermarks->OrphanAt(i));
+                for(int i = tempWatermarkInstances->GetCount()-1; i>=0; i--)
+                {
+                    tempInstance.reset(tempWatermarkInstances->OrphanAt(i));
+                    if(!tempInstance.get()) continue;
+                    if(((map->GetWatermarkUsage() & MgMap::Viewer) != 0
+                        && (tempInstance->GetUsage() & WatermarkInstance::Viewer) == 0) 
+                        || ((map->GetWatermarkUsage() & MgMap::WMS) != 0
+                        && (tempInstance->GetUsage() & WatermarkInstance::WMS) == 0))
+                        continue;
+                    bool alreadyInList = false;
+                    for(int j = watermarkInstances->GetCount()-1; j >=0; j--)
+                    {
+                        if(tempInstance->Equals(watermarkInstances->GetAt(j)))
+                        {
+                            alreadyInList = true;
+                            break;
+                        }
+                    }
+                    if(!alreadyInList)
+                    {
+                        watermarkIds->Add(tempInstance->GetWatermarkResourceID().c_str());
+                        watermarkInstances->Adopt(tempInstance.release());
+                    }
+                }
+            }
+
+            //Get watermark instance in layer
+            const int layerCount = tempLayers->GetCount();
+            auto_ptr<LayerDefinition> ldf;
+            for(int i = 0; i < layerCount; i++)
+            {
+                Ptr<MgLayerBase> mapLayer(tempLayers->GetItem(i));
+
+                //The layer resource content should be set during stylization.
+                if(mapLayer->GetLayerResourceContent() == L"")
+                    continue;
+
+                ldf.reset(MgLayerBase::GetLayerDefinition(mapLayer->GetLayerResourceContent()));
+                
+                WatermarkInstanceCollection* layerWatermarks = ldf->GetWatermarks();
+                for(int j = layerWatermarks->GetCount()-1; j>=0; j--)
+                    tempWatermarkInstances->Adopt(layerWatermarks->OrphanAt(j));
+                for(int j = tempWatermarkInstances->GetCount()-1; j>=0; j--)
+                {
+                    tempInstance.reset(tempWatermarkInstances->OrphanAt(j));
+                    if(!tempInstance.get()) continue;
+                    if(((map->GetWatermarkUsage() & MgMap::Viewer) != 0
+                        && (tempInstance->GetUsage() & WatermarkInstance::Viewer) == 0) 
+                        || ((map->GetWatermarkUsage() & MgMap::WMS) != 0
+                        && (tempInstance->GetUsage() & WatermarkInstance::WMS) == 0))
+                        continue;
+                    bool alreadyInList = false;
+                    for(int k = watermarkInstances->GetCount()-1; k >=0; k--)
+                    {
+                        if(tempInstance->Equals(watermarkInstances->GetAt(k)))
+                        {
+                            alreadyInList = true;
+                            break;
+                        }
+                    }
+                    if(!alreadyInList)
+                    {
+                        watermarkIds->Add(tempInstance->GetWatermarkResourceID().c_str());
+                        watermarkInstances->Adopt(tempInstance.release());
+                    }
+                }
+            }
+            assert(tempWatermarkInstances->GetCount() == 0);
+
+            //Load watermark source
+            if(watermarkIds->GetCount() != 0)
+            {
+                Ptr<MgStringCollection> wdefs = m_svcResource->GetResourceContents(watermarkIds, NULL);
+                for(int i = watermarkIds->GetCount() - 1; i >= 0; i--)
+                {
+                    for(int j = watermarkInstances->GetCount() - 1; j >= 0; j--)
+                    {
+                        WatermarkInstance* instance = watermarkInstances->GetAt(j);
+                        if(instance->GetWatermarkResourceID() == watermarkIds->GetItem(i))
+                        {
+                            instance->AdoptWatermarkDefinition(
+                                MgWatermark::GetWatermarkDefinition(wdefs->GetItem(i)));
+                        }
+                    }
+                }
+            }
+
+            for(int i = watermarkInstances->GetCount()-1; i>=0; i--)
+            {
+                WatermarkInstance* instance = watermarkInstances->GetAt(i);
+                WatermarkDefinition* wdef = instance->GetWatermarkDefinition();
+                if(instance->GetPositionOverride())
+                {
+                    wdef->AdoptPosition(instance->OrphanPositionOverride());
+                }
+                if(instance->GetAppearanceOverride())
+                {
+                    wdef->AdoptAppearance(instance->GetAppearanceOverride());
+                }
+                ds.StylizeWatermark(dr, wdef, drawWidth, drawHeight, saveWidth, saveHeight);
+            }
+        }
+
     MG_CATCH(L"MgServerRenderingService.RenderMapInternal")
 
     dr->EndMap();

Modified: trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.h
===================================================================
--- trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.h	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.h	2010-09-17 08:00:59 UTC (rev 5139)
@@ -169,24 +169,30 @@
                                     MgSelection* selection,
                                     MgReadOnlyLayerCollection* roLayers,
                                     SE_Renderer* dr,
+                                    INT32 drawWidth,
+                                    INT32 drawHeight,
                                     INT32 saveWidth,
                                     INT32 saveHeight,
                                     CREFSTRING format,
                                     double scale,
                                     RS_Bounds& b,
                                     bool expandExtents,
-                                    bool bKeepSelection);
+                                    bool bKeepSelection,
+                                    bool renderingWatermark);
 
     MgByteReader* RenderMapInternal(MgMap* map,
                                     MgSelection* selection,
                                     MgReadOnlyLayerCollection* roLayers,
                                     SE_Renderer* dr,
+                                    INT32 drawWidth,
+                                    INT32 drawHeight,
                                     INT32 saveWidth,
                                     INT32 saveHeight,
                                     double scale,
                                     RS_Bounds& b,
                                     bool expandExtents,
-                                    MgRenderingOptions* options);
+                                    MgRenderingOptions* options,
+                                    bool renderingWatermark);
 
     void RenderForSelection(MgMap* map,
                          MgStringCollection* layerNames,

Modified: trunk/MgDev/Web/src/HttpHandler/HttpWmsGetMap.cpp
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/HttpWmsGetMap.cpp	2010-09-17 07:57:46 UTC (rev 5138)
+++ trunk/MgDev/Web/src/HttpHandler/HttpWmsGetMap.cpp	2010-09-17 08:00:59 UTC (rev 5139)
@@ -172,6 +172,7 @@
             // Get a map object corresponding to the request parameters
             Ptr<MgMap> map = MgWmsMapUtil::GetMap(wms, m_layerDefIds, m_bbox, m_crs,
                 m_width, m_height, resourceService);
+            map->SetWatermarkUsage(MgMap::WMS);
 
             // Get the image format
             // Note: should be valid, since this mapping has already happened



More information about the mapguide-commits mailing list