diff options
author | Joren De Cuyper <jorendc@libreoffice.org> | 2014-07-15 00:02:44 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2014-07-15 07:34:50 +0000 |
commit | 5bd241b99b76ae7f4b3c1d4f2bcbaf7c487bb339 (patch) | |
tree | df4adefcb3aae2ebcaae44b1aa7e4b40fe991c60 | |
parent | abc28ffc04067eb24840fbf564c311aaee10f84d (diff) |
fdo#50114 ingore flowRoot element during svg import
This element is not specified in any released svg specification.
It might be mentioned in svg1.2 but since this is not yet released/
or will even not be released ever -> ignore it.
Change-Id: Iaf5a392893070fda9e7a420bc951c8565bcfb37f
Reviewed-on: https://gerrit.libreoffice.org/10312
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r-- | svgio/inc/svgio/svgreader/svgdocumenthandler.hxx | 2 | ||||
-rw-r--r-- | svgio/inc/svgio/svgreader/svgtoken.hxx | 2 | ||||
-rw-r--r-- | svgio/source/svgreader/svgdocumenthandler.cxx | 27 | ||||
-rw-r--r-- | svgio/source/svgreader/svgtoken.cxx | 3 |
4 files changed, 33 insertions, 1 deletions
diff --git a/svgio/inc/svgio/svgreader/svgdocumenthandler.hxx b/svgio/inc/svgio/svgreader/svgdocumenthandler.hxx index 7269e3fa23b1..86566894ed5b 100644 --- a/svgio/inc/svgio/svgreader/svgdocumenthandler.hxx +++ b/svgio/inc/svgio/svgreader/svgdocumenthandler.hxx @@ -41,6 +41,8 @@ namespace svgio // text collector string stack for css styles std::vector< OUString > maCssContents; + bool bSkip; + public: SvgDocHdl(const OUString& rAbsolutePath); virtual ~SvgDocHdl(); diff --git a/svgio/inc/svgio/svgreader/svgtoken.hxx b/svgio/inc/svgio/svgreader/svgtoken.hxx index fa6986e82be8..4596fb2118d0 100644 --- a/svgio/inc/svgio/svgreader/svgtoken.hxx +++ b/svgio/inc/svgio/svgreader/svgtoken.hxx @@ -178,6 +178,8 @@ namespace svgio SVGTokenText, SVGTokenBaselineShift, + SVGTokenFlowRoot, + SVGTokenLast }; diff --git a/svgio/source/svgreader/svgdocumenthandler.cxx b/svgio/source/svgreader/svgdocumenthandler.cxx index 25772aa7b3c1..3817612099d6 100644 --- a/svgio/source/svgreader/svgdocumenthandler.cxx +++ b/svgio/source/svgreader/svgdocumenthandler.cxx @@ -137,7 +137,8 @@ namespace svgio SvgDocHdl::SvgDocHdl(const OUString& aAbsolutePath) : maDocument(aAbsolutePath), mpTarget(0), - maCssContents() + maCssContents(), + bSkip(false) { } @@ -167,8 +168,11 @@ namespace svgio void SvgDocHdl::startElement( const OUString& aName, const uno::Reference< xml::sax::XAttributeList >& xAttribs ) throw (xml::sax::SAXException, uno::RuntimeException, std::exception) { + if (bSkip) + return; if(!aName.isEmpty()) { + const SVGToken aSVGToken(StrToSVGToken(aName)); switch(aSVGToken) @@ -364,6 +368,13 @@ namespace svgio break; } + // ignore FlowRoot and child nodes + case SVGTokenFlowRoot: + { + bSkip = true; + break; + } + default: { /// invalid token, ignore @@ -388,6 +399,13 @@ namespace svgio SvgStyleNode* pCssStyle(SVGTokenStyle == aSVGToken ? static_cast< SvgStyleNode* >(mpTarget) : 0); SvgTitleDescNode* pSvgTitleDescNode(SVGTokenTitle == aSVGToken || SVGTokenDesc == aSVGToken ? static_cast< SvgTitleDescNode* >(mpTarget) : 0); + // if we are in skipping mode and we reach the flowRoot end tag: stop skipping mode + if(bSkip && aSVGToken == SVGTokenFlowRoot) + bSkip = false; + // we are in skipping mode: do nothing until we found the flowRoot end tag + else if(bSkip) + return; + switch(aSVGToken) { /// valid tokens for which a new one was created @@ -457,6 +475,13 @@ namespace svgio } break; } + + case SVGTokenFlowRoot: + { + bSkip = false; + break; + } + default: { /// invalid token, ignore diff --git a/svgio/source/svgreader/svgtoken.cxx b/svgio/source/svgreader/svgtoken.cxx index 337a26d39fa6..db494b12bfea 100644 --- a/svgio/source/svgreader/svgtoken.cxx +++ b/svgio/source/svgreader/svgtoken.cxx @@ -160,6 +160,8 @@ namespace svgio static OUString aSVGStrText("text"); static OUString aSVGStrBaselineShift("baseline-shift"); + static OUString aSVGStrFlowRoot("flowRoot"); + SVGToken StrToSVGToken(const OUString& rStr) { typedef boost::unordered_map< OUString, SVGToken, OUStringHash,::std::equal_to< OUString > > SVGTokenMapper; @@ -302,6 +304,7 @@ namespace svgio aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrText, SVGTokenText)); aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrBaselineShift, SVGTokenBaselineShift)); + aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrFlowRoot, SVGTokenFlowRoot)); } const SVGTokenMapper::const_iterator aResult(aSVGTokenMapperList.find(rStr.startsWith("svg:") ? rStr.copy(4) : rStr)); |