[PATCH] SVG: text elements and graphic elements should not share style ids

Chr. Rossmanith Chr.Rossmanith at gmx.de
Sun Apr 29 13:12:29 PDT 2012


---
 filter/source/svg/gfxtypes.hxx  |    8 ++++++--
 filter/source/svg/svgreader.cxx |    7 +++++++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/filter/source/svg/gfxtypes.hxx b/filter/source/svg/gfxtypes.hxx
index 24c4cbd..daca2be 100644
--- a/filter/source/svg/gfxtypes.hxx
+++ b/filter/source/svg/gfxtypes.hxx
@@ -173,10 +173,11 @@ struct State
         maTransform(),
         maViewport(),
         maViewBox(),
+        mbIsText(false),
         maFontFamily(), // app-default
         mnFontSize(0),
-        maFontStyle(RTL_CONSTASCII_USTRINGPARAM("normal")),
-        maFontVariant(RTL_CONSTASCII_USTRINGPARAM("normal")),
+        maFontStyle("normal"),
+        maFontVariant("normal"),
         mnFontWeight(400.0),
         meTextAnchor(BEFORE),
         meTextDisplayAlign(BEFORE),
@@ -211,6 +212,7 @@ struct State
     basegfx::B2DRange           maViewport;
     basegfx::B2DRange           maViewBox;
 
+    bool                        mbIsText;
     rtl::OUString               maFontFamily;
     /** Absolute: xx-small=6.94 | x-small=8.33 | small=10 | medium=12 | large=14.4 | x-large=17.28 | xx-large=20.736
 
@@ -263,6 +265,7 @@ inline bool operator==(const State& rLHS, const State& rRHS )
         rLHS.maTransform==rRHS.maTransform &&
         rLHS.maViewport==rRHS.maViewport &&
         rLHS.maViewBox==rRHS.maViewBox &&
+        rLHS.mbIsText==rRHS.mbIsText &&
         rLHS.maFontFamily==rRHS.maFontFamily &&
         rLHS.mnFontSize==rRHS.mnFontSize &&
         rLHS.maFontStyle==rRHS.maFontStyle &&
@@ -309,6 +312,7 @@ struct StateHash
             ^  size_t(rState.maViewport.getHeight())
             ^  size_t(rState.maViewBox.getWidth())
             ^  size_t(rState.maViewBox.getHeight())
+            ^  size_t(rState.mbIsText)
             ^  size_t(rState.maFontFamily.hashCode())
             ^  size_t(rState.mnFontSize)
             ^  size_t(rState.maFontStyle.hashCode())
diff --git a/filter/source/svg/svgreader.cxx b/filter/source/svg/svgreader.cxx
index dfb33c8..2c0c09b 100644
--- a/filter/source/svg/svgreader.cxx
+++ b/filter/source/svg/svgreader.cxx
@@ -521,8 +521,12 @@ struct AnnotatingVisitor
         rtl::Reference<SvXMLAttributeList> xAttrs( new SvXMLAttributeList() );
         uno::Reference<xml::sax::XAttributeList> xUnoAttrs( xAttrs.get() );
 
+        if (XML_TEXT == nTagId)
+            rState.mbIsText = true;
         std::pair<StatePool::iterator,
                   bool> aRes = mrStates.insert(rState);
+        SAL_INFO ("svg", "size " << mrStates.size() << "   id " <<  const_cast<State&>(*aRes.first).mnStyleId);
+
         if( !aRes.second )
             return false; // not written
 
@@ -530,6 +534,8 @@ struct AnnotatingVisitor
 
         // mnStyleId does not take part in hashing/comparison
         const_cast<State&>(*aRes.first).mnStyleId = mnCurrStateId;
+        SAL_INFO ("svg", " --> " <<  const_cast<State&>(*aRes.first).mnStyleId);
+
         mrStateMap.insert(std::make_pair(
                               mnCurrStateId,
                               rState));
@@ -750,6 +756,7 @@ struct AnnotatingVisitor
 
     void writeStyle(const uno::Reference<xml::dom::XElement>& xElem, const sal_Int32 nTagId)
     {
+        SAL_INFO ("svg", "writeStyle xElem " << xElem->getTagName());
         sal_Int32 nEmulatedStyleId=0;
         if( maCurrState.maDashArray.size() &&
             maCurrState.meStrokeType != NONE )
-- 
1.7.9.5


--------------040309060009030401070907--


More information about the LibreOffice mailing list