diff options
author | Chr. Rossmanith <ChrRossmanith@gmx.de> | 2014-10-03 13:51:00 +0200 |
---|---|---|
committer | Thorsten Behrens <thb@documentfoundation.org> | 2014-10-10 21:58:26 +0000 |
commit | 5e27d23d7e665cc0aeac8fc9ea2236bf8bc088ff (patch) | |
tree | e77133435f0ecdbb3a2bf0999ee8a49194f00ac6 | |
parent | 96adec2fd56d1ca09d679c0966567c674d812dfb (diff) |
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@documentfoundation.org>
Tested-by: Thorsten Behrens <thb@documentfoundation.org>
-rw-r--r-- | filter/source/svg/svgreader.cxx | 16 |
1 files 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<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 |