From 5e27d23d7e665cc0aeac8fc9ea2236bf8bc088ff Mon Sep 17 00:00:00 2001 From: "Chr. Rossmanith" Date: Fri, 3 Oct 2014 13:51:00 +0200 Subject: fdo#65864: dont't traverse defs-nodes when in shape writing mode Relevant for opening svg images via File->Open: Children of the element should be interpreted only during the style collecting step. Collecting 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 Tested-by: Thorsten Behrens --- filter/source/svg/svgreader.cxx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/filter/source/svg/svgreader.cxx b/filter/source/svg/svgreader.cxx index da2ae3d06e9f..44df957f8f83 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 void visitChildren(const Func& rFunc, element's attributes, if any */ template void visitElements(Func& rFunc, - const uno::Reference xElem) + const uno::Reference xElem, + SvgiVisitorCaller eCaller) { if( xElem->hasAttributes() ) rFunc(xElem,xElem->getAttributes()); @@ -89,6 +91,9 @@ template void visitElements(Func& rFunc, rFunc.push(); // recurse over children + if (eCaller == SHAPE_WRITER && xElem->getTagName() == "defs") { + return; + } uno::Reference xChildren( xElem->getChildNodes() ); const sal_Int32 nNumNodes( xChildren->getLength() ); for( sal_Int32 i=0; i void visitElements(Func& rFunc, visitElements( rFunc, uno::Reference( 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& 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& 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& xDocHdl ) { OfficeStylesWritingVisitor aVisitor( rStateMap, xDocHdl ); - visitElements( aVisitor, xElem ); + visitElements( aVisitor, xElem, STYLE_WRITER ); } #if OSL_DEBUG_LEVEL > 2 -- cgit v1.2.3