[mapguide-commits] r4572 - trunk/MgDev/Common/Stylization

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Mon Feb 1 16:15:33 EST 2010


Author: waltweltonlair
Date: 2010-02-01 16:15:33 -0500 (Mon, 01 Feb 2010)
New Revision: 4572

Modified:
   trunk/MgDev/Common/Stylization/mtext_parser.cpp
Log:
Fix #1260 (MText stack code draws invalid line)

Fixed the logic in MTextParseInstance::Parse_S_OverUnder to correctly
handle underlines and overlines.


Modified: trunk/MgDev/Common/Stylization/mtext_parser.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/mtext_parser.cpp	2010-01-31 06:17:51 UTC (rev 4571)
+++ trunk/MgDev/Common/Stylization/mtext_parser.cpp	2010-02-01 21:15:33 UTC (rev 4572)
@@ -389,6 +389,13 @@
     if(eOldJustification != ATOM::Justification::keCentered)
         Run.Style().AddDelta(ATOM::JustificationStyleParticle(ATOM::Justification::keCentered));
 
+    // also get the current underline / overline settings
+    ATOM::UnderlineStyleParticle* pOldUnderline = (ATOM::UnderlineStyleParticle*)(Run.Style().GetDescriptionParticle(ATOM::StyleParticle::keUnderline));
+    ATOM::TextLine::Type eOldUnderline = (pOldUnderline != NULL)? pOldUnderline->Value() : ATOM::TextLine::keNone;
+
+    ATOM::OverlineStyleParticle* pOldOverline = (ATOM::OverlineStyleParticle*)(Run.Style().GetDescriptionParticle(ATOM::StyleParticle::keOverline));
+    ATOM::TextLine::Type eOldOverline = (pOldOverline != NULL)? pOldOverline->Value() : ATOM::TextLine::keNone;
+
     bool bHasNumer = sNumer.Length() > 0;
     bool bHasDenom = sDenom.Length() > 0;
 
@@ -411,7 +418,7 @@
 
             // Short-term hack, instead of relying on BorderLineStyleParticle.
             // See the OverlineStyleParticle in the corresponding code below for notes.
-            if(sDenom.Length() < sNumer.Length()) {
+            if(sDenom.Length() < sNumer.Length() && eOldUnderline != ATOM::TextLine::keSingle) {
                 Run.Style().AddDelta(ATOM::UnderlineStyleParticle(ATOM::TextLine::keSingle));
                 bNumerLine = true;
             }
@@ -435,6 +442,13 @@
         // Prepare for what follows
         //
 
+        // Disable any underline from the short-term hack
+        if(bNumerLine)
+        {
+            Run.Style().AddDelta(ATOM::UnderlineStyleParticle(eOldUnderline));
+            bNumerLine = false;
+        }
+
         // End of superscript
         Run.Location().AddSemantic(ATOM::ILocation::keEndSuperscript);
         // This location stuff is subject to some fiddling (part 2)
@@ -462,9 +476,9 @@
             // ... instead, we temporarily do this.  We assume, based on some use-case knowledge
             // of the stacked fraction, that these are likely to be numeric, and numbers are usually
             // fixed-width, even in variable-width fonts.
-            if(sDenom.Length() >= sNumer.Length()) {
-              Run.Style().AddDelta(ATOM::OverlineStyleParticle(ATOM::TextLine::keSingle));
-              bDenomLine = true;
+            if(sDenom.Length() >= sNumer.Length() && eOldOverline != ATOM::TextLine::keSingle) {
+                Run.Style().AddDelta(ATOM::OverlineStyleParticle(ATOM::TextLine::keSingle));
+                bDenomLine = true;
             }
         }
 
@@ -485,6 +499,13 @@
         // Prepare for what follows
         //
 
+        // Disable any overline from the short-term hack
+        if(bDenomLine)
+        {
+            Run.Style().AddDelta(ATOM::OverlineStyleParticle(eOldOverline));
+            bDenomLine = false;
+        }
+
         // End of subscript
         Run.Location().AddSemantic(ATOM::ILocation::keEndSubscript);
         // This location stuff is subject to some fiddling (part 4)
@@ -500,16 +521,9 @@
             // End the line
             // Removed, for now.  See above.
             //Run.Style().AddDelta(ATOM::TopBorderLineStyleParticle(ATOM::BorderLine::keNoBorder));
-            // ... instead, we disable the hacked Under/Over
-            if(bNumerLine)
-                Run.Style().AddDelta(ATOM::UnderlineStyleParticle(ATOM::TextLine::keNone));
-            if(bDenomLine)
-                Run.Style().AddDelta(ATOM::OverlineStyleParticle(ATOM::TextLine::keNone));
-
         }
     }
 
-
     if(eOldJustification != ATOM::Justification::keCentered)
         Run.Style().AddDelta(ATOM::JustificationStyleParticle(eOldJustification));
 



More information about the mapguide-commits mailing list