diff options
author | Armin Le Grand <alg@apache.org> | 2012-05-04 14:16:22 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-03-13 11:22:20 +0000 |
commit | eceecd4a3806f64c2e8fb0a3bcdcc43e1384779f (patch) | |
tree | e8c81552d7e3a1374a903cf5ca522a6eb77853e3 /svgio/source/svgreader/svgdocumenthandler.cxx | |
parent | cc22c25de9be13596960b8af6c6f40fc2e3fd27d (diff) |
Related: #i119125# corrected gradient rendering
and added stuff to add Title and Description to primitives for later usage
Conflicts:
drawinglayer/Library_drawinglayer.mk
drawinglayer/inc/drawinglayer/primitive2d/svggradientprimitive2d.hxx
svgio/Package_inc.mk
svx/source/sdr/contact/viewcontactofsdrobj.cxx
Change-Id: I301c9f5f4ae0efc02d937cd3f56018e27c94a630
Diffstat (limited to 'svgio/source/svgreader/svgdocumenthandler.cxx')
-rw-r--r-- | svgio/source/svgreader/svgdocumenthandler.cxx | 138 |
1 files changed, 86 insertions, 52 deletions
diff --git a/svgio/source/svgreader/svgdocumenthandler.cxx b/svgio/source/svgreader/svgdocumenthandler.cxx index 9cad386043fb..29c40b30cd30 100644 --- a/svgio/source/svgreader/svgdocumenthandler.cxx +++ b/svgio/source/svgreader/svgdocumenthandler.cxx @@ -43,6 +43,7 @@ #include <svgio/svgreader/svgmasknode.hxx> #include <svgio/svgreader/svgmarkernode.hxx> #include <svgio/svgreader/svgpatternnode.hxx> +#include <svgio/svgreader/svgtitledescnode.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -246,6 +247,15 @@ namespace svgio break; } + /// title and description + case SVGTokenTitle: + case SVGTokenDesc: + { + /// new node for Title and/or Desc + mpTarget = new SvgTitleDescNode(aSVGToken, maDocument, mpTarget); + break; + } + /// gradients case SVGTokenLinearGradient: case SVGTokenRadialGradient: @@ -360,6 +370,7 @@ namespace svgio const SVGToken aSVGToken(StrToSVGToken(aName)); SvgNode* pWhitespaceCheck(SVGTokenText == aSVGToken ? mpTarget : 0); SvgStyleNode* pCssStyle(SVGTokenStyle == aSVGToken ? static_cast< SvgStyleNode* >(mpTarget) : 0); + SvgTitleDescNode* pSvgTitleDescNode(SVGTokenTitle == aSVGToken || SVGTokenDesc == aSVGToken ? static_cast< SvgTitleDescNode* >(mpTarget) : 0); switch(aSVGToken) { @@ -382,6 +393,10 @@ namespace svgio case SVGTokenRect: case SVGTokenImage: + /// title and description + case SVGTokenTitle: + case SVGTokenDesc: + /// gradients case SVGTokenLinearGradient: case SVGTokenRadialGradient: @@ -432,6 +447,23 @@ namespace svgio } } + if(pSvgTitleDescNode && mpTarget) + { + const rtl::OUString aText(pSvgTitleDescNode->getText()); + + if(aText.getLength()) + { + if(SVGTokenTitle == aSVGToken) + { + mpTarget->parseAttribute(getStrTitle(), aSVGToken, aText); + } + else // if(SVGTokenDesc == aSVGToken) + { + mpTarget->parseAttribute(getStrDesc(), aSVGToken, aText); + } + } + } + if(pCssStyle && pCssStyle->isTextCss()) { // css style parsing @@ -457,72 +489,74 @@ namespace svgio void SvgDocHdl::characters( const ::rtl::OUString& aChars ) throw (xml::sax::SAXException, uno::RuntimeException) { - if(mpTarget) - { - const sal_uInt32 nLength(aChars.getLength()); + const sal_uInt32 nLength(aChars.getLength()); - if(nLength && - (SVGTokenText == mpTarget->getType() || - SVGTokenTspan == mpTarget->getType() || - SVGTokenTextPath == mpTarget->getType() || - SVGTokenStyle == mpTarget->getType())) + if(mpTarget && nLength) + { + switch(mpTarget->getType()) { - switch(mpTarget->getType()) + case SVGTokenText: + case SVGTokenTspan: + case SVGTokenTextPath: { - case SVGTokenText: - case SVGTokenTspan: - case SVGTokenTextPath: - { - const SvgNodeVector& rChilds = mpTarget->getChildren(); - SvgCharacterNode* pTarget = 0; + const SvgNodeVector& rChilds = mpTarget->getChildren(); + SvgCharacterNode* pTarget = 0; - if(rChilds.size()) - { - pTarget = dynamic_cast< SvgCharacterNode* >(rChilds[rChilds.size() - 1]); - } + if(rChilds.size()) + { + pTarget = dynamic_cast< SvgCharacterNode* >(rChilds[rChilds.size() - 1]); + } - if(pTarget) - { - // concatenate to current character span - pTarget->concatenate(aChars); - } - else - { - // add character span as simplified tspan (no arguments) - // as direct child of SvgTextNode/SvgTspanNode/SvgTextPathNode - new SvgCharacterNode(maDocument, mpTarget, aChars); - } - break; + if(pTarget) + { + // concatenate to current character span + pTarget->concatenate(aChars); } - case SVGTokenStyle: + else { - SvgStyleNode& rSvgStyleNode = static_cast< SvgStyleNode& >(*mpTarget); + // add character span as simplified tspan (no arguments) + // as direct child of SvgTextNode/SvgTspanNode/SvgTextPathNode + new SvgCharacterNode(maDocument, mpTarget, aChars); + } + break; + } + case SVGTokenStyle: + { + SvgStyleNode& rSvgStyleNode = static_cast< SvgStyleNode& >(*mpTarget); - if(rSvgStyleNode.isTextCss()) + if(rSvgStyleNode.isTextCss()) + { + // collect characters for css style + if(maCssContents.size()) { - // collect characters for css style - if(maCssContents.size()) - { - const ::rtl::OUString aTrimmedChars(aChars.trim()); + const ::rtl::OUString aTrimmedChars(aChars.trim()); - if(aTrimmedChars.getLength()) - { - std::vector< rtl::OUString >::iterator aString(maCssContents.end() - 1); - (*aString) += aTrimmedChars; - } - } - else + if(aTrimmedChars.getLength()) { - OSL_ENSURE(false, "Closing CssStyle, but no collector string on stack (!)"); + std::vector< rtl::OUString >::iterator aString(maCssContents.end() - 1); + (*aString) += aTrimmedChars; } } - break; - } - default: - { - // characters not used by a known node - break; + else + { + OSL_ENSURE(false, "Closing CssStyle, but no collector string on stack (!)"); + } } + break; + } + case SVGTokenTitle: + case SVGTokenDesc: + { + SvgTitleDescNode& rSvgTitleDescNode = static_cast< SvgTitleDescNode& >(*mpTarget); + + // add text directly to SvgTitleDescNode + rSvgTitleDescNode.concatenate(aChars); + break; + } + default: + { + // characters not used by a known node + break; } } } |