[mapguide-commits] r1248 - trunk/MgDev/Common/MdfParser

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Fri Mar 16 00:48:09 EDT 2007


Author: ronnielouie
Date: 2007-03-16 00:48:08 -0400 (Fri, 16 Mar 2007)
New Revision: 1248

Modified:
   trunk/MgDev/Common/MdfParser/IOAreaRule.cpp
   trunk/MgDev/Common/MdfParser/IOAreaRule.h
   trunk/MgDev/Common/MdfParser/IOAreaSymbolization2D.cpp
   trunk/MgDev/Common/MdfParser/IOAreaSymbolization2D.h
   trunk/MgDev/Common/MdfParser/IOAreaTypeStyle.cpp
   trunk/MgDev/Common/MdfParser/IOAreaTypeStyle.h
   trunk/MgDev/Common/MdfParser/IOLineRule.cpp
   trunk/MgDev/Common/MdfParser/IOLineRule.h
   trunk/MgDev/Common/MdfParser/IOLineSymbolization2D.cpp
   trunk/MgDev/Common/MdfParser/IOLineSymbolization2D.h
   trunk/MgDev/Common/MdfParser/IOLineTypeStyle.cpp
   trunk/MgDev/Common/MdfParser/IOLineTypeStyle.h
   trunk/MgDev/Common/MdfParser/IOMarkSymbol.cpp
   trunk/MgDev/Common/MdfParser/IOMarkSymbol.h
   trunk/MgDev/Common/MdfParser/IOPointRule.cpp
   trunk/MgDev/Common/MdfParser/IOPointRule.h
   trunk/MgDev/Common/MdfParser/IOPointSymbolization2D.cpp
   trunk/MgDev/Common/MdfParser/IOPointSymbolization2D.h
   trunk/MgDev/Common/MdfParser/IOPointTypeStyle.cpp
   trunk/MgDev/Common/MdfParser/IOPointTypeStyle.h
   trunk/MgDev/Common/MdfParser/IOStroke.cpp
   trunk/MgDev/Common/MdfParser/IOStroke.h
   trunk/MgDev/Common/MdfParser/IOVectorLayerDefinition.cpp
   trunk/MgDev/Common/MdfParser/IOVectorScaleRange.cpp
   trunk/MgDev/Common/MdfParser/IOVectorScaleRange.h
Log:
When writing to a previous version layer definition, only those elements that are defined in that version's schema should be output.  This submission handles the SizeContext which is new to the Stroke type in LayerDefinition-1.1.0.xsd.

Modified: trunk/MgDev/Common/MdfParser/IOAreaRule.cpp
===================================================================
--- trunk/MgDev/Common/MdfParser/IOAreaRule.cpp	2007-03-16 00:10:53 UTC (rev 1247)
+++ trunk/MgDev/Common/MdfParser/IOAreaRule.cpp	2007-03-16 04:48:08 UTC (rev 1248)
@@ -108,7 +108,7 @@
     }
 }
 
-void IOAreaRule::Write(MdfStream &fd, AreaRule *areaRule)
+void IOAreaRule::Write(MdfStream &fd, AreaRule *areaRule, Version *version)
 {
     fd << tab() << "<AreaRule>" << std::endl;  // NOXLATE
     inctab();
@@ -137,7 +137,7 @@
     //Property: Symbolization
     AreaSymbolization2D *symbolization = areaRule->GetSymbolization();
     IOAreaSymbolization2D *IO = new IOAreaSymbolization2D();
-    IO->Write(fd, symbolization);
+    IO->Write(fd, symbolization, version);
     delete IO;
 
         // Write any previously found unknown XML

Modified: trunk/MgDev/Common/MdfParser/IOAreaRule.h
===================================================================
--- trunk/MgDev/Common/MdfParser/IOAreaRule.h	2007-03-16 00:10:53 UTC (rev 1247)
+++ trunk/MgDev/Common/MdfParser/IOAreaRule.h	2007-03-16 04:48:08 UTC (rev 1248)
@@ -21,6 +21,7 @@
 #include "SAX2ElementHandler.h"
 #include "AreaRule.h"
 #include "AreaTypeStyle.h"
+#include "Version.h"
 
 using namespace XERCES_CPP_NAMESPACE;
 using namespace MDFMODEL_NAMESPACE;
@@ -37,7 +38,7 @@
         IOAreaRule();
         IOAreaRule(AreaTypeStyle * areaTypeStyle);
         ~IOAreaRule();
-        void Write(MdfStream &fd, AreaRule *areaRule);
+        void Write(MdfStream &fd, AreaRule *areaRule, Version *version = NULL);
 
         virtual void StartElement(const wchar_t *name, HandlerStack *handlerStack);
         virtual void ElementChars(const wchar_t *ch);

Modified: trunk/MgDev/Common/MdfParser/IOAreaSymbolization2D.cpp
===================================================================
--- trunk/MgDev/Common/MdfParser/IOAreaSymbolization2D.cpp	2007-03-16 00:10:53 UTC (rev 1247)
+++ trunk/MgDev/Common/MdfParser/IOAreaSymbolization2D.cpp	2007-03-16 04:48:08 UTC (rev 1248)
@@ -109,7 +109,7 @@
     }
 }
 
-void IOAreaSymbolization2D::Write(MdfStream &fd, AreaSymbolization2D * areaSymbolization)
+void IOAreaSymbolization2D::Write(MdfStream &fd, AreaSymbolization2D * areaSymbolization, Version* version)
 {
     fd << tab() << "<AreaSymbolization2D>" << std::endl; // NOXLATE
     inctab();
@@ -120,7 +120,7 @@
 
     //Property: Edge
     if (areaSymbolization != NULL && areaSymbolization->GetEdge() != NULL)
-        IOStroke::Write(fd, areaSymbolization->GetEdge(), "Stroke"); // NOXLATE
+        IOStroke::Write(fd, areaSymbolization->GetEdge(), "Stroke", version); // NOXLATE
 
     // Write any previously found unknown XML
     if (areaSymbolization != NULL && !areaSymbolization->GetUnknownXml().empty())

Modified: trunk/MgDev/Common/MdfParser/IOAreaSymbolization2D.h
===================================================================
--- trunk/MgDev/Common/MdfParser/IOAreaSymbolization2D.h	2007-03-16 00:10:53 UTC (rev 1247)
+++ trunk/MgDev/Common/MdfParser/IOAreaSymbolization2D.h	2007-03-16 04:48:08 UTC (rev 1248)
@@ -21,6 +21,7 @@
 #include "SAX2ElementHandler.h"
 #include "AreaSymbolization2D.h"
 #include "AreaRule.h"
+#include "Version.h"
 
 using namespace XERCES_CPP_NAMESPACE;
 using namespace MDFMODEL_NAMESPACE;
@@ -36,7 +37,7 @@
         IOAreaSymbolization2D();
         IOAreaSymbolization2D(AreaRule * areaRule);
         ~IOAreaSymbolization2D();
-        void Write(MdfStream &fd, AreaSymbolization2D * areaSymbolization);
+        void Write(MdfStream &fd, AreaSymbolization2D * areaSymbolization, Version *version = NULL);
 
         virtual void StartElement(const wchar_t *name, HandlerStack *handlerStack);
         virtual void ElementChars(const wchar_t *ch);

Modified: trunk/MgDev/Common/MdfParser/IOAreaTypeStyle.cpp
===================================================================
--- trunk/MgDev/Common/MdfParser/IOAreaTypeStyle.cpp	2007-03-16 00:10:53 UTC (rev 1247)
+++ trunk/MgDev/Common/MdfParser/IOAreaTypeStyle.cpp	2007-03-16 04:48:08 UTC (rev 1248)
@@ -93,7 +93,7 @@
     }
 }
 
-void IOAreaTypeStyle::Write(MdfStream &fd, AreaTypeStyle * areaTypeStyle)
+void IOAreaTypeStyle::Write(MdfStream &fd, AreaTypeStyle * areaTypeStyle, Version *version)
 {
     fd << tab() << "<AreaTypeStyle>" << std::endl; // NOXLATE
     inctab();
@@ -102,7 +102,7 @@
     for (int x = 0; x < areaTypeStyle->GetRules()->GetCount(); x++)
     {
         IOAreaRule *IO = new IOAreaRule();
-        IO->Write(fd, static_cast<AreaRule*>(areaTypeStyle->GetRules()->GetAt(x)));
+        IO->Write(fd, static_cast<AreaRule*>(areaTypeStyle->GetRules()->GetAt(x)), version);
         delete IO;
     }
 

Modified: trunk/MgDev/Common/MdfParser/IOAreaTypeStyle.h
===================================================================
--- trunk/MgDev/Common/MdfParser/IOAreaTypeStyle.h	2007-03-16 00:10:53 UTC (rev 1247)
+++ trunk/MgDev/Common/MdfParser/IOAreaTypeStyle.h	2007-03-16 04:48:08 UTC (rev 1248)
@@ -21,6 +21,7 @@
 #include "SAX2ElementHandler.h"
 #include "AreaTypeStyle.h"
 #include "VectorScaleRange.h"
+#include "Version.h"
 
 using namespace XERCES_CPP_NAMESPACE;
 using namespace MDFMODEL_NAMESPACE;
@@ -36,7 +37,7 @@
         IOAreaTypeStyle();
         IOAreaTypeStyle(VectorScaleRange * scaleRange);
         ~IOAreaTypeStyle();
-        void Write(MdfStream &fd, AreaTypeStyle * areaTypeStyle);
+        void Write(MdfStream &fd, AreaTypeStyle * areaTypeStyle, Version *version = NULL);
 
         virtual void StartElement(const wchar_t *name, HandlerStack *handlerStack);
         virtual void ElementChars(const wchar_t *ch);

Modified: trunk/MgDev/Common/MdfParser/IOLineRule.cpp
===================================================================
--- trunk/MgDev/Common/MdfParser/IOLineRule.cpp	2007-03-16 00:10:53 UTC (rev 1247)
+++ trunk/MgDev/Common/MdfParser/IOLineRule.cpp	2007-03-16 04:48:08 UTC (rev 1248)
@@ -108,7 +108,7 @@
     }
 }
 
-void IOLineRule::Write(MdfStream &fd, LineRule *lineRule)
+void IOLineRule::Write(MdfStream &fd, LineRule *lineRule, Version *version)
 {
     fd << tab() << "<LineRule>" << std::endl; // NOXLATE
     inctab();
@@ -137,7 +137,7 @@
     for (int x = 0; x < lineRule->GetSymbolizations()->GetCount(); x++)
     {
         IOLineSymbolization2D *IO = new IOLineSymbolization2D();
-        IO->Write(fd, lineRule->GetSymbolizations()->GetAt(x));
+        IO->Write(fd, lineRule->GetSymbolizations()->GetAt(x), version);
         delete IO;
     }
 

Modified: trunk/MgDev/Common/MdfParser/IOLineRule.h
===================================================================
--- trunk/MgDev/Common/MdfParser/IOLineRule.h	2007-03-16 00:10:53 UTC (rev 1247)
+++ trunk/MgDev/Common/MdfParser/IOLineRule.h	2007-03-16 04:48:08 UTC (rev 1248)
@@ -21,6 +21,7 @@
 #include "SAX2ElementHandler.h"
 #include "LineRule.h"
 #include "LineTypeStyle.h"
+#include "Version.h"
 
 using namespace XERCES_CPP_NAMESPACE;
 using namespace MDFMODEL_NAMESPACE;
@@ -36,7 +37,7 @@
         IOLineRule();
         IOLineRule(LineTypeStyle * lineTypeStyle);
         ~IOLineRule();
-        void Write(MdfStream &fd, LineRule *lineRule);
+        void Write(MdfStream &fd, LineRule *lineRule, Version *version = NULL);
 
         virtual void StartElement(const wchar_t *name, HandlerStack *handlerStack);
         virtual void ElementChars(const wchar_t *ch);

Modified: trunk/MgDev/Common/MdfParser/IOLineSymbolization2D.cpp
===================================================================
--- trunk/MgDev/Common/MdfParser/IOLineSymbolization2D.cpp	2007-03-16 00:10:53 UTC (rev 1247)
+++ trunk/MgDev/Common/MdfParser/IOLineSymbolization2D.cpp	2007-03-16 04:48:08 UTC (rev 1248)
@@ -29,6 +29,7 @@
 ELEM_MAP_ENTRY(3, Thickness);
 ELEM_MAP_ENTRY(4, Color);
 ELEM_MAP_ENTRY(5, Unit);
+ELEM_MAP_ENTRY(6, SizeContext);
 
 IOLineSymbolization2D::IOLineSymbolization2D()
 {
@@ -80,6 +81,13 @@
         LengthUnit unit = LengthConverter::EnglishToUnit(ch);
         this->_lineSymbolization->GetStroke()->SetUnit(unit);
     }
+    else if (m_currElemName == L"SizeContext") // NOXLATE
+    {
+        if (::wcscmp(ch, L"MappingUnits") == 0) // NOXLATE
+            this->_lineSymbolization->GetStroke()->SetSizeContext(MdfModel::MappingUnits);
+        else if (::wcscmp(ch, L"DeviceUnits") == 0) // NOXLATE
+            this->_lineSymbolization->GetStroke()->SetSizeContext(MdfModel::DeviceUnits);
+    }
 }
 
 void IOLineSymbolization2D::EndElement(const wchar_t *name, HandlerStack *handlerStack)
@@ -98,7 +106,7 @@
     }
 }
 
-void IOLineSymbolization2D::Write(MdfStream &fd, LineSymbolization2D *lineSymbolization)
+void IOLineSymbolization2D::Write(MdfStream &fd, LineSymbolization2D *lineSymbolization, Version *version)
 {
     //Property: Stroke
     if (lineSymbolization->GetStroke())
@@ -127,6 +135,32 @@
         fd << EncodeString(*str);
         fd << endStr(sUnit) << std::endl; 
 
+        //Property: SizeContext
+        // Only write SizeContext if the version is not less than 1.1
+        bool bWriteSizeContext = true;
+        if (version != NULL)
+        {
+            int nMajor = version->GetMajor();
+            int nMinor = version->GetMinor();
+            double scalerMajorMinorVersion = ( (double)version->GetMajor() ) * 1.0 + ( (double)version->GetMinor() ) * 0.1;
+
+            bWriteSizeContext = (scalerMajorMinorVersion >= 1.1);
+        }
+
+        if (bWriteSizeContext)
+        {
+            fd << tab() << "<SizeContext>"; // NOXLATE
+            if(lineSymbolization->GetStroke()->GetSizeContext() == MdfModel::MappingUnits)
+            {
+                fd << "MappingUnits"; // NOXLATE
+            }
+            else
+            {
+                fd << "DeviceUnits"; // NOXLATE
+            }
+            fd << "</SizeContext>" << std::endl; // NOXLATE
+        }
+
         // Write any previously found unknown XML
         if (!lineSymbolization->GetUnknownXml().empty())
         {

Modified: trunk/MgDev/Common/MdfParser/IOLineSymbolization2D.h
===================================================================
--- trunk/MgDev/Common/MdfParser/IOLineSymbolization2D.h	2007-03-16 00:10:53 UTC (rev 1247)
+++ trunk/MgDev/Common/MdfParser/IOLineSymbolization2D.h	2007-03-16 04:48:08 UTC (rev 1248)
@@ -21,6 +21,7 @@
 #include "SAX2ElementHandler.h"
 #include "LineSymbolization2D.h"
 #include "LineRule.h"
+#include "Version.h"
 
 using namespace XERCES_CPP_NAMESPACE;
 using namespace MDFMODEL_NAMESPACE;
@@ -37,7 +38,7 @@
         IOLineSymbolization2D();
         IOLineSymbolization2D(LineRule * lineRule);
         ~IOLineSymbolization2D();
-        void Write(MdfStream &fd, LineSymbolization2D *lineSymbolization);
+        void Write(MdfStream &fd, LineSymbolization2D *lineSymbolization, Version *version = NULL);
 
         virtual void StartElement(const wchar_t *name, HandlerStack *handlerStack);
         virtual void ElementChars(const wchar_t *ch);

Modified: trunk/MgDev/Common/MdfParser/IOLineTypeStyle.cpp
===================================================================
--- trunk/MgDev/Common/MdfParser/IOLineTypeStyle.cpp	2007-03-16 00:10:53 UTC (rev 1247)
+++ trunk/MgDev/Common/MdfParser/IOLineTypeStyle.cpp	2007-03-16 04:48:08 UTC (rev 1248)
@@ -93,7 +93,7 @@
     }
 }
 
-void IOLineTypeStyle::Write(MdfStream &fd, LineTypeStyle *lineTypeStyle)
+void IOLineTypeStyle::Write(MdfStream &fd, LineTypeStyle *lineTypeStyle, Version *version)
 {
     fd << tab() << "<LineTypeStyle>" << std::endl; // NOXLATE
     inctab();
@@ -102,7 +102,7 @@
     for (int x = 0; x < lineTypeStyle->GetRules()->GetCount(); x++)
     {
         IOLineRule *IO = new IOLineRule();
-        IO->Write(fd, static_cast<LineRule*>(lineTypeStyle->GetRules()->GetAt(x)));
+        IO->Write(fd, static_cast<LineRule*>(lineTypeStyle->GetRules()->GetAt(x)), version);
         delete IO;
     }
 

Modified: trunk/MgDev/Common/MdfParser/IOLineTypeStyle.h
===================================================================
--- trunk/MgDev/Common/MdfParser/IOLineTypeStyle.h	2007-03-16 00:10:53 UTC (rev 1247)
+++ trunk/MgDev/Common/MdfParser/IOLineTypeStyle.h	2007-03-16 04:48:08 UTC (rev 1248)
@@ -21,6 +21,7 @@
 #include "SAX2ElementHandler.h"
 #include "LineTypeStyle.h"
 #include "VectorScaleRange.h"
+#include "Version.h"
 
 using namespace XERCES_CPP_NAMESPACE;
 using namespace MDFMODEL_NAMESPACE;
@@ -37,7 +38,7 @@
         IOLineTypeStyle();
         IOLineTypeStyle(VectorScaleRange * scaleRange);
         ~IOLineTypeStyle();
-        void Write(MdfStream &fd, LineTypeStyle *lineTypeStyle);
+        void Write(MdfStream &fd, LineTypeStyle *lineTypeStyle, Version *version);
 
         virtual void StartElement(const wchar_t *name, HandlerStack *handlerStack);
         virtual void ElementChars(const wchar_t *ch);

Modified: trunk/MgDev/Common/MdfParser/IOMarkSymbol.cpp
===================================================================
--- trunk/MgDev/Common/MdfParser/IOMarkSymbol.cpp	2007-03-16 00:10:53 UTC (rev 1247)
+++ trunk/MgDev/Common/MdfParser/IOMarkSymbol.cpp	2007-03-16 04:48:08 UTC (rev 1248)
@@ -130,7 +130,7 @@
     }
 }
 
-void IOMarkSymbol::Write(MdfStream &fd, MarkSymbol *symbol)
+void IOMarkSymbol::Write(MdfStream &fd, MarkSymbol *symbol, Version *version)
 {
     fd << tab() << "<Mark>" << std::endl; // NOXLATE
     inctab();
@@ -159,7 +159,7 @@
 
     //Property: Edge
     if (symbol->GetEdge() != NULL)
-        IOStroke::Write(fd, symbol->GetEdge(), "Edge"); // NOXLATE
+        IOStroke::Write(fd, symbol->GetEdge(), "Edge", version); // NOXLATE
 
     // Write any previously found unknown XML
     if (!symbol->GetUnknownXml().empty())

Modified: trunk/MgDev/Common/MdfParser/IOMarkSymbol.h
===================================================================
--- trunk/MgDev/Common/MdfParser/IOMarkSymbol.h	2007-03-16 00:10:53 UTC (rev 1247)
+++ trunk/MgDev/Common/MdfParser/IOMarkSymbol.h	2007-03-16 04:48:08 UTC (rev 1248)
@@ -40,7 +40,7 @@
         virtual void ElementChars(const wchar_t *ch);
         virtual void EndElement(const wchar_t *name, HandlerStack *handlerStack);
 
-        static void Write(MdfStream &fd, MarkSymbol *markSymbol);
+        static void Write(MdfStream &fd, MarkSymbol *markSymbol, Version *version = NULL);
 };
 
 END_NAMESPACE_MDFPARSER

Modified: trunk/MgDev/Common/MdfParser/IOPointRule.cpp
===================================================================
--- trunk/MgDev/Common/MdfParser/IOPointRule.cpp	2007-03-16 00:10:53 UTC (rev 1247)
+++ trunk/MgDev/Common/MdfParser/IOPointRule.cpp	2007-03-16 04:48:08 UTC (rev 1248)
@@ -108,7 +108,7 @@
     }
 }
 
-void IOPointRule::Write(MdfStream &fd, PointRule *pointRule)
+void IOPointRule::Write(MdfStream &fd, PointRule *pointRule, Version *version)
 {
     fd << tab() << "<PointRule>" << std::endl; // NOXLATE
     inctab();
@@ -138,7 +138,7 @@
     if (symbolization2d != NULL)
     {
         IOPointSymbolization2D *IO = new IOPointSymbolization2D();
-        IO->Write(fd, symbolization2d);
+        IO->Write(fd, symbolization2d, version);
         delete IO;
     }
 

Modified: trunk/MgDev/Common/MdfParser/IOPointRule.h
===================================================================
--- trunk/MgDev/Common/MdfParser/IOPointRule.h	2007-03-16 00:10:53 UTC (rev 1247)
+++ trunk/MgDev/Common/MdfParser/IOPointRule.h	2007-03-16 04:48:08 UTC (rev 1248)
@@ -21,6 +21,7 @@
 #include "SAX2ElementHandler.h"
 #include "PointRule.h"
 #include "PointTypeStyle.h"
+#include "Version.h"
 
 using namespace XERCES_CPP_NAMESPACE;
 using namespace MDFMODEL_NAMESPACE;
@@ -37,7 +38,7 @@
         IOPointRule();
         IOPointRule(PointTypeStyle * pointTypeStyle);
         ~IOPointRule();
-        void Write(MdfStream &fd, PointRule * pointRule);
+        void Write(MdfStream &fd, PointRule * pointRule, Version *version = NULL);
 
         virtual void StartElement(const wchar_t *name, HandlerStack *handlerStack);
         virtual void ElementChars(const wchar_t *ch);

Modified: trunk/MgDev/Common/MdfParser/IOPointSymbolization2D.cpp
===================================================================
--- trunk/MgDev/Common/MdfParser/IOPointSymbolization2D.cpp	2007-03-16 00:10:53 UTC (rev 1247)
+++ trunk/MgDev/Common/MdfParser/IOPointSymbolization2D.cpp	2007-03-16 04:48:08 UTC (rev 1248)
@@ -125,7 +125,7 @@
     }
 }
 
-void IOPointSymbolization2D::Write(MdfStream &fd, PointSymbolization2D *PointSymbolization2D)
+void IOPointSymbolization2D::Write(MdfStream &fd, PointSymbolization2D *PointSymbolization2D, Version *version)
 {
     fd << tab() << "<PointSymbolization2D>" << std::endl; // NOXLATE
     inctab();
@@ -137,7 +137,7 @@
     W2DSymbol* w2DSymbol = dynamic_cast<W2DSymbol*>(PointSymbolization2D->GetSymbol());
     BlockSymbol* blockSymbol = dynamic_cast<BlockSymbol*>(PointSymbolization2D->GetSymbol());
     if (markSymbol)
-        IOMarkSymbol::Write(fd, markSymbol);
+        IOMarkSymbol::Write(fd, markSymbol, version);
     else if (imageSymbol)
         IOImageSymbol::Write(fd, imageSymbol);
     else if (fontSymbol)

Modified: trunk/MgDev/Common/MdfParser/IOPointSymbolization2D.h
===================================================================
--- trunk/MgDev/Common/MdfParser/IOPointSymbolization2D.h	2007-03-16 00:10:53 UTC (rev 1247)
+++ trunk/MgDev/Common/MdfParser/IOPointSymbolization2D.h	2007-03-16 04:48:08 UTC (rev 1248)
@@ -22,6 +22,7 @@
 #include "PointSymbolization2D.h"
 #include "PointRule.h"
 #include "IOSymbol.h"
+#include "Version.h"
 
 using namespace XERCES_CPP_NAMESPACE;
 using namespace MDFMODEL_NAMESPACE;
@@ -39,7 +40,7 @@
         IOPointSymbolization2D();
         IOPointSymbolization2D(PointRule * pointRule);
         ~IOPointSymbolization2D();
-        void Write(MdfStream &fd, PointSymbolization2D * PointSymbolization2D);
+        void Write(MdfStream &fd, PointSymbolization2D * PointSymbolization2D, Version *version = NULL);
 
         virtual void StartElement(const wchar_t *name, HandlerStack *handlerStack);
         virtual void ElementChars(const wchar_t *ch);

Modified: trunk/MgDev/Common/MdfParser/IOPointTypeStyle.cpp
===================================================================
--- trunk/MgDev/Common/MdfParser/IOPointTypeStyle.cpp	2007-03-16 00:10:53 UTC (rev 1247)
+++ trunk/MgDev/Common/MdfParser/IOPointTypeStyle.cpp	2007-03-16 04:48:08 UTC (rev 1248)
@@ -98,7 +98,7 @@
     }
 }
 
-void IOPointTypeStyle::Write(MdfStream &fd, PointTypeStyle *pointTypeStyle)
+void IOPointTypeStyle::Write(MdfStream &fd, PointTypeStyle *pointTypeStyle, Version *version)
 {
     fd << tab() << "<PointTypeStyle>" << std::endl; // NOXLATE
     inctab();
@@ -117,7 +117,7 @@
     for (int x = 0; x < pointTypeStyle->GetRules()->GetCount(); x++)
     {
         IOPointRule *IO = new IOPointRule();
-        IO->Write(fd, static_cast<PointRule*>(pointTypeStyle->GetRules()->GetAt(x)));
+        IO->Write(fd, static_cast<PointRule*>(pointTypeStyle->GetRules()->GetAt(x)), version);
         delete IO;
     }
 

Modified: trunk/MgDev/Common/MdfParser/IOPointTypeStyle.h
===================================================================
--- trunk/MgDev/Common/MdfParser/IOPointTypeStyle.h	2007-03-16 00:10:53 UTC (rev 1247)
+++ trunk/MgDev/Common/MdfParser/IOPointTypeStyle.h	2007-03-16 04:48:08 UTC (rev 1248)
@@ -21,6 +21,7 @@
 #include "SAX2ElementHandler.h"
 #include "PointTypeStyle.h"
 #include "VectorScaleRange.h"
+#include "Version.h"
 
 using namespace XERCES_CPP_NAMESPACE;
 using namespace MDFMODEL_NAMESPACE;
@@ -37,7 +38,7 @@
         IOPointTypeStyle();
         IOPointTypeStyle(VectorScaleRange * scaleRange);
         ~IOPointTypeStyle();
-        void Write(MdfStream &fd, PointTypeStyle * pointTypeStyle);
+        void Write(MdfStream &fd, PointTypeStyle * pointTypeStyle, Version *version = NULL);
 
         virtual void StartElement(const wchar_t *name, HandlerStack *handlerStack);
         virtual void ElementChars(const wchar_t *ch);

Modified: trunk/MgDev/Common/MdfParser/IOStroke.cpp
===================================================================
--- trunk/MgDev/Common/MdfParser/IOStroke.cpp	2007-03-16 00:10:53 UTC (rev 1247)
+++ trunk/MgDev/Common/MdfParser/IOStroke.cpp	2007-03-16 04:48:08 UTC (rev 1248)
@@ -111,7 +111,7 @@
     }
 }
 
-void IOStroke::Write(MdfStream &fd, Stroke *stroke, std::string name)
+void IOStroke::Write(MdfStream &fd, Stroke *stroke, std::string name, Version *version)
 {
     fd << tab() << "<" << name << ">" << std::endl; // NOXLATE
     inctab();
@@ -138,16 +138,30 @@
     fd << "</Unit>" << std::endl; // NOXLATE
 
     //Property: SizeContext
-    fd << tab() << "<SizeContext>"; // NOXLATE
-    if(stroke->GetSizeContext() == MdfModel::MappingUnits)
+    // Only write SizeContext if the version is not less than 1.1
+    bool bWriteSizeContext = true;
+    if (version != NULL)
     {
-        fd << "MappingUnits"; // NOXLATE
+        int nMajor = version->GetMajor();
+        int nMinor = version->GetMinor();
+        double scalerMajorMinorVersion = ( (double)version->GetMajor() ) * 1.0 + ( (double)version->GetMinor() ) * 0.1;
+
+        bWriteSizeContext = (scalerMajorMinorVersion >= 1.1);
     }
-    else
+
+    if (bWriteSizeContext)
     {
-        fd << "DeviceUnits"; // NOXLATE
+        fd << tab() << "<SizeContext>"; // NOXLATE
+        if(stroke->GetSizeContext() == MdfModel::MappingUnits)
+        {
+            fd << "MappingUnits"; // NOXLATE
+        }
+        else
+        {
+            fd << "DeviceUnits"; // NOXLATE
+        }
+        fd << "</SizeContext>" << std::endl; // NOXLATE
     }
-    fd << "</SizeContext>" << std::endl; // NOXLATE
         
     // Write any previously found unknown XML
     if (!stroke->GetUnknownXml().empty())

Modified: trunk/MgDev/Common/MdfParser/IOStroke.h
===================================================================
--- trunk/MgDev/Common/MdfParser/IOStroke.h	2007-03-16 00:10:53 UTC (rev 1247)
+++ trunk/MgDev/Common/MdfParser/IOStroke.h	2007-03-16 04:48:08 UTC (rev 1248)
@@ -20,6 +20,7 @@
 
 #include "SAX2ElementHandler.h"
 #include "Stroke.h"
+#include "Version.h"
 
 using namespace XERCES_CPP_NAMESPACE;
 using namespace MDFMODEL_NAMESPACE;
@@ -36,7 +37,7 @@
         IOStroke(std::wstring elementName);
         IOStroke(Stroke * stroke, std::wstring elementName);
         ~IOStroke();
-        static void Write(MdfStream &fd, Stroke *stroke, std::string name);
+        static void Write(MdfStream &fd, Stroke *stroke, std::string name, Version *version = NULL);
 
         virtual void StartElement(const wchar_t *name, HandlerStack *handlerStack);
         virtual void ElementChars(const wchar_t *ch);

Modified: trunk/MgDev/Common/MdfParser/IOVectorLayerDefinition.cpp
===================================================================
--- trunk/MgDev/Common/MdfParser/IOVectorLayerDefinition.cpp	2007-03-16 00:10:53 UTC (rev 1247)
+++ trunk/MgDev/Common/MdfParser/IOVectorLayerDefinition.cpp	2007-03-16 04:48:08 UTC (rev 1248)
@@ -232,7 +232,7 @@
     for (int x = 0; x < featureLayer->GetScaleRanges()->GetCount(); x++)
     {
         IOVectorScaleRange * IO = new IOVectorScaleRange();
-        IO->Write(fd, featureLayer->GetScaleRanges()->GetAt(x));
+        IO->Write(fd, featureLayer->GetScaleRanges()->GetAt(x), version);
         delete IO;
     }
 

Modified: trunk/MgDev/Common/MdfParser/IOVectorScaleRange.cpp
===================================================================
--- trunk/MgDev/Common/MdfParser/IOVectorScaleRange.cpp	2007-03-16 00:10:53 UTC (rev 1247)
+++ trunk/MgDev/Common/MdfParser/IOVectorScaleRange.cpp	2007-03-16 04:48:08 UTC (rev 1248)
@@ -140,7 +140,7 @@
     }
 }
 
-void IOVectorScaleRange::Write(MdfStream &fd, VectorScaleRange *scaleRange)
+void IOVectorScaleRange::Write(MdfStream &fd, VectorScaleRange *scaleRange, Version* version)
 {
     fd << tab() << "<VectorScaleRange>" << std::endl; // NOXLATE
     inctab();
@@ -167,19 +167,19 @@
         if (dynamic_cast<AreaTypeStyle*>(scaleRange->GetFeatureTypeStyles()->GetAt(x)) != 0)
         {
             IOAreaTypeStyle * IO = new IOAreaTypeStyle();
-            IO->Write(fd, dynamic_cast<AreaTypeStyle*>(scaleRange->GetFeatureTypeStyles()->GetAt(x)));
+            IO->Write(fd, dynamic_cast<AreaTypeStyle*>(scaleRange->GetFeatureTypeStyles()->GetAt(x)), version);
             delete IO;
         }
         else if (dynamic_cast<LineTypeStyle*>(scaleRange->GetFeatureTypeStyles()->GetAt(x)) != 0)
         {
             IOLineTypeStyle * IO = new IOLineTypeStyle();
-            IO->Write(fd, dynamic_cast<LineTypeStyle*>(scaleRange->GetFeatureTypeStyles()->GetAt(x)));
+            IO->Write(fd, dynamic_cast<LineTypeStyle*>(scaleRange->GetFeatureTypeStyles()->GetAt(x)), version);
             delete IO;
         }
         else if (dynamic_cast<PointTypeStyle*>(scaleRange->GetFeatureTypeStyles()->GetAt(x)) != 0)
         {
             IOPointTypeStyle * IO = new IOPointTypeStyle();
-            IO->Write(fd, dynamic_cast<PointTypeStyle*>(scaleRange->GetFeatureTypeStyles()->GetAt(x)));
+            IO->Write(fd, dynamic_cast<PointTypeStyle*>(scaleRange->GetFeatureTypeStyles()->GetAt(x)), version);
             delete IO;
         }
         else if (dynamic_cast<CompositeTypeStyle*>(scaleRange->GetFeatureTypeStyles()->GetAt(x)) != 0)

Modified: trunk/MgDev/Common/MdfParser/IOVectorScaleRange.h
===================================================================
--- trunk/MgDev/Common/MdfParser/IOVectorScaleRange.h	2007-03-16 00:10:53 UTC (rev 1247)
+++ trunk/MgDev/Common/MdfParser/IOVectorScaleRange.h	2007-03-16 04:48:08 UTC (rev 1248)
@@ -21,6 +21,7 @@
 #include "SAX2ElementHandler.h"
 #include "VectorScaleRange.h"
 #include "VectorLayerDefinition.h"
+#include "Version.h"
 
 using namespace XERCES_CPP_NAMESPACE;
 using namespace MDFMODEL_NAMESPACE;
@@ -37,7 +38,7 @@
         IOVectorScaleRange();
         IOVectorScaleRange(VectorLayerDefinition * layer);
         ~IOVectorScaleRange();
-        void Write(MdfStream &fd, VectorScaleRange *scaleRange);
+        void Write(MdfStream &fd, VectorScaleRange *scaleRange, Version *version = NULL);
 
         virtual void StartElement(const wchar_t *name, HandlerStack *handlerStack);
         virtual void ElementChars(const wchar_t *ch);



More information about the mapguide-commits mailing list