[Libreoffice-commits] core.git: filter/source

Chr. Rossmanith ChrRossmanith at gmx.de
Fri Oct 10 14:58:49 PDT 2014


 filter/source/svg/svgreader.cxx |   16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

New commits:
commit 5e27d23d7e665cc0aeac8fc9ea2236bf8bc088ff
Author: Chr. Rossmanith <ChrRossmanith at gmx.de>
Date:   Fri Oct 3 13:51:00 2014 +0200

    fdo#65864: dont't traverse defs-nodes when in shape writing mode
    
    Relevant for opening svg images via File->Open:
    Children of the <defs> element should be interpreted only during the
    style collecting step. Collecting <path> elements from clip paths
    during the shape writing step leads to unwanted black polygons.
    
    Change-Id: I73598134c9be2877e975a7e756541ec3026fe768
    Reviewed-on: https://gerrit.libreoffice.org/11793
    Reviewed-by: Thorsten Behrens <thb at documentfoundation.org>
    Tested-by: Thorsten Behrens <thb at documentfoundation.org>

diff --git a/filter/source/svg/svgreader.cxx b/filter/source/svg/svgreader.cxx
index da2ae3d..44df957 100644
--- a/filter/source/svg/svgreader.cxx
+++ b/filter/source/svg/svgreader.cxx
@@ -53,6 +53,7 @@ using namespace ::com::sun::star;
 
 namespace svgi
 {
+    enum SvgiVisitorCaller {STYLE_ANNOTATOR, SHAPE_WRITER, STYLE_WRITER};
 namespace
 {
 
@@ -78,7 +79,8 @@ template<typename Func> void visitChildren(const Func& rFunc,
     element's attributes, if any
  */
 template<typename Func> void visitElements(Func& rFunc,
-                                           const uno::Reference<xml::dom::XElement> xElem)
+                                           const uno::Reference<xml::dom::XElement> xElem,
+                                           SvgiVisitorCaller eCaller)
 {
     if( xElem->hasAttributes() )
         rFunc(xElem,xElem->getAttributes());
@@ -89,6 +91,9 @@ template<typename Func> void visitElements(Func& rFunc,
     rFunc.push();
 
     // recurse over children
+    if (eCaller == SHAPE_WRITER && xElem->getTagName() == "defs") {
+        return;
+    }
     uno::Reference<xml::dom::XNodeList> xChildren( xElem->getChildNodes() );
     const sal_Int32 nNumNodes( xChildren->getLength() );
     for( sal_Int32 i=0; i<nNumNodes; ++i )
@@ -97,7 +102,8 @@ template<typename Func> void visitElements(Func& rFunc,
             visitElements( rFunc,
                            uno::Reference<xml::dom::XElement>(
                                xChildren->item(i),
-                               uno::UNO_QUERY_THROW) );
+                               uno::UNO_QUERY_THROW),
+                           eCaller );
     }
 
     // children processing done
@@ -1170,7 +1176,7 @@ static void annotateStyles( StatePool&                                        rS
                             const uno::Reference<xml::sax::XDocumentHandler>& xDocHdl )
 {
     AnnotatingVisitor aVisitor(rStatePool,rStateMap,rInitialState,xDocHdl);
-    visitElements(aVisitor, xElem);
+    visitElements(aVisitor, xElem, STYLE_ANNOTATOR);
 }
 
 struct ShapeWritingVisitor
@@ -1706,7 +1712,7 @@ static void writeShapes( StatePool&                                        rStat
                          const uno::Reference<xml::sax::XDocumentHandler>& xDocHdl )
 {
     ShapeWritingVisitor aVisitor(rStatePool,rStateMap,xDocHdl);
-    visitElements(aVisitor, xElem);
+    visitElements(aVisitor, xElem, SHAPE_WRITER);
 }
 
 } // namespace
@@ -1822,7 +1828,7 @@ static void writeOfficeStyles(  StateMap&
                                 const uno::Reference<xml::sax::XDocumentHandler>& xDocHdl )
 {
     OfficeStylesWritingVisitor aVisitor( rStateMap, xDocHdl );
-    visitElements( aVisitor, xElem );
+    visitElements( aVisitor, xElem, STYLE_WRITER );
 }
 
 #if OSL_DEBUG_LEVEL > 2


More information about the Libreoffice-commits mailing list