Author: alg Date: Fri Jul 18 09:00:39 2014 New Revision: 1611567 URL: http://svn.apache.org/r1611567 Log: i125258 reworked some of the style hierarchy stuff
Modified: openoffice/branches/AOO410/main/svgio/ (props changed) openoffice/branches/AOO410/main/svgio/inc/svgio/svgreader/svgnode.hxx openoffice/branches/AOO410/main/svgio/inc/svgio/svgreader/svgstyleattributes.hxx openoffice/branches/AOO410/main/svgio/inc/svgio/svgreader/svgstylenode.hxx openoffice/branches/AOO410/main/svgio/inc/svgio/svgreader/svgsvgnode.hxx openoffice/branches/AOO410/main/svgio/source/svgreader/svggnode.cxx openoffice/branches/AOO410/main/svgio/source/svgreader/svggradientnode.cxx openoffice/branches/AOO410/main/svgio/source/svgreader/svgnode.cxx openoffice/branches/AOO410/main/svgio/source/svgreader/svgstyleattributes.cxx openoffice/branches/AOO410/main/svgio/source/svgreader/svgstylenode.cxx openoffice/branches/AOO410/main/svgio/source/svgreader/svgsvgnode.cxx openoffice/branches/AOO410/main/svgio/source/svgreader/svgtitledescnode.cxx Propchange: openoffice/branches/AOO410/main/svgio/ ------------------------------------------------------------------------------ Merged /openoffice/trunk/main/svgio:r1610953 Modified: openoffice/branches/AOO410/main/svgio/inc/svgio/svgreader/svgnode.hxx URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/svgio/inc/svgio/svgreader/svgnode.hxx?rev=1611567&r1=1611566&r2=1611567&view=diff ============================================================================== --- openoffice/branches/AOO410/main/svgio/inc/svgio/svgreader/svgnode.hxx (original) +++ openoffice/branches/AOO410/main/svgio/inc/svgio/svgreader/svgnode.hxx Fri Jul 18 09:00:39 2014 @@ -130,6 +130,9 @@ namespace svgio virtual void parseAttribute(const rtl::OUString& rTokenName, SVGToken aSVGToken, const rtl::OUString& aContent); virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DSequence& rTarget, bool bReferenced) const; + /// #125258# tell if this node is allowed to have a parent style (e.g. defs do not) + virtual bool supportsParentStyle() const; + /// basic data read access SVGToken getType() const { return maType; } const SvgDocument& getDocument() const { return mrDocument; } Modified: openoffice/branches/AOO410/main/svgio/inc/svgio/svgreader/svgstyleattributes.hxx URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/svgio/inc/svgio/svgreader/svgstyleattributes.hxx?rev=1611567&r1=1611566&r2=1611567&view=diff ============================================================================== --- openoffice/branches/AOO410/main/svgio/inc/svgio/svgreader/svgstyleattributes.hxx (original) +++ openoffice/branches/AOO410/main/svgio/inc/svgio/svgreader/svgstyleattributes.hxx Fri Jul 18 09:00:39 2014 @@ -286,6 +286,7 @@ namespace svgio ~SvgStyleAttributes(); /// fill content + bool isFillSet() const; // #125258# ask if fill is a direct hard attribute (no hierarchy) const basegfx::BColor* getFill() const; void setFill(const SvgPaint& rFill) { maFill = rFill; } Modified: openoffice/branches/AOO410/main/svgio/inc/svgio/svgreader/svgstylenode.hxx URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/svgio/inc/svgio/svgreader/svgstylenode.hxx?rev=1611567&r1=1611566&r2=1611567&view=diff ============================================================================== --- openoffice/branches/AOO410/main/svgio/inc/svgio/svgreader/svgstylenode.hxx (original) +++ openoffice/branches/AOO410/main/svgio/inc/svgio/svgreader/svgstylenode.hxx Fri Jul 18 09:00:39 2014 @@ -47,6 +47,9 @@ namespace svgio SvgNode* pParent); virtual ~SvgStyleNode(); + /// #125258# tell if this node is allowed to have a parent style (e.g. defs do not) + virtual bool supportsParentStyle() const; + virtual void parseAttribute(const rtl::OUString& rTokenName, SVGToken aSVGToken, const rtl::OUString& aContent); void addCssStyleSheet(const rtl::OUString& aContent); Modified: openoffice/branches/AOO410/main/svgio/inc/svgio/svgreader/svgsvgnode.hxx URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/svgio/inc/svgio/svgreader/svgsvgnode.hxx?rev=1611567&r1=1611566&r2=1611567&view=diff ============================================================================== --- openoffice/branches/AOO410/main/svgio/inc/svgio/svgreader/svgsvgnode.hxx (original) +++ openoffice/branches/AOO410/main/svgio/inc/svgio/svgreader/svgsvgnode.hxx Fri Jul 18 09:00:39 2014 @@ -46,6 +46,13 @@ namespace svgio SvgNumber maHeight; SvgNumber maVersion; + /// #125258# bitfield + bool mbStyleAttributesInitialized : 1; + + // #125258# on-demand init hard attributes when this is the outmost svg element + // and more (see implementation) + void initializeStyleAttributes(); + public: SvgSvgNode( SvgDocument& rDocument, Modified: openoffice/branches/AOO410/main/svgio/source/svgreader/svggnode.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/svgio/source/svgreader/svggnode.cxx?rev=1611567&r1=1611566&r2=1611567&view=diff ============================================================================== --- openoffice/branches/AOO410/main/svgio/source/svgreader/svggnode.cxx (original) +++ openoffice/branches/AOO410/main/svgio/source/svgreader/svggnode.cxx Fri Jul 18 09:00:39 2014 @@ -50,9 +50,18 @@ namespace svgio const SvgStyleAttributes* SvgGNode::getSvgStyleAttributes() const { - static rtl::OUString aClassStr(rtl::OUString::createFromAscii("g")); + if(SVGTokenDefs == getType()) + { + // #125258# call parent for SVGTokenDefs + return SvgNode::getSvgStyleAttributes(); + } + else + { + // #125258# for SVGTokenG take CssStyles into account + static rtl::OUString aClassStr(rtl::OUString::createFromAscii("g")); - return checkForCssStyle(aClassStr, maSvgStyleAttributes); + return checkForCssStyle(aClassStr, maSvgStyleAttributes); + } } void SvgGNode::parseAttribute(const rtl::OUString& rTokenName, SVGToken aSVGToken, const rtl::OUString& aContent) @@ -90,22 +99,31 @@ namespace svgio void SvgGNode::decomposeSvgNode(drawinglayer::primitive2d::Primitive2DSequence& rTarget, bool bReferenced) const { - const SvgStyleAttributes* pStyle = getSvgStyleAttributes(); - - if(pStyle) + if(SVGTokenDefs == getType()) { - const double fOpacity(pStyle->getOpacity().getNumber()); + // #125258# no decompose needed for defs element, call parent for SVGTokenDefs + SvgNode::decomposeSvgNode(rTarget, bReferenced); + } + else + { + // #125258# for SVGTokenG decompose childs + const SvgStyleAttributes* pStyle = getSvgStyleAttributes(); - if(fOpacity > 0.0 && Display_none != getDisplay()) + if(pStyle) { - drawinglayer::primitive2d::Primitive2DSequence aContent; - - // decompose childs - SvgNode::decomposeSvgNode(aContent, bReferenced); + const double fOpacity(pStyle->getOpacity().getNumber()); - if(aContent.hasElements()) + if(fOpacity > 0.0 && Display_none != getDisplay()) { - pStyle->add_postProcess(rTarget, aContent, getTransform()); + drawinglayer::primitive2d::Primitive2DSequence aContent; + + // decompose childs + SvgNode::decomposeSvgNode(aContent, bReferenced); + + if(aContent.hasElements()) + { + pStyle->add_postProcess(rTarget, aContent, getTransform()); + } } } } Modified: openoffice/branches/AOO410/main/svgio/source/svgreader/svggradientnode.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/svgio/source/svgreader/svggradientnode.cxx?rev=1611567&r1=1611566&r2=1611567&view=diff ============================================================================== --- openoffice/branches/AOO410/main/svgio/source/svgreader/svggradientnode.cxx (original) +++ openoffice/branches/AOO410/main/svgio/source/svgreader/svggradientnode.cxx Fri Jul 18 09:00:39 2014 @@ -61,6 +61,7 @@ namespace svgio maXLink(), mpXLink(0) { + OSL_ENSURE(aType == SVGTokenLinearGradient || aType == SVGTokenRadialGradient, "SvgGradientNode should ony be used for Linear and Radial gradient (!)"); } SvgGradientNode::~SvgGradientNode() Modified: openoffice/branches/AOO410/main/svgio/source/svgreader/svgnode.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/svgio/source/svgreader/svgnode.cxx?rev=1611567&r1=1611566&r2=1611567&view=diff ============================================================================== --- openoffice/branches/AOO410/main/svgio/source/svgreader/svgnode.cxx (original) +++ openoffice/branches/AOO410/main/svgio/source/svgreader/svgnode.cxx Fri Jul 18 09:00:39 2014 @@ -36,6 +36,12 @@ namespace svgio { namespace svgreader { + /// #125258# + bool SvgNode::supportsParentStyle() const + { + return true; + } + const SvgStyleAttributes* SvgNode::getSvgStyleAttributes() const { return 0; Modified: openoffice/branches/AOO410/main/svgio/source/svgreader/svgstyleattributes.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/svgio/source/svgreader/svgstyleattributes.cxx?rev=1611567&r1=1611566&r2=1611567&view=diff ============================================================================== --- openoffice/branches/AOO410/main/svgio/source/svgreader/svgstyleattributes.cxx (original) +++ openoffice/branches/AOO410/main/svgio/source/svgreader/svgstyleattributes.cxx Fri Jul 18 09:00:39 2014 @@ -219,7 +219,7 @@ namespace svgio return getCssStyleParent(); } - if(mrOwner.getParent()) + if(mrOwner.supportsParentStyle() && mrOwner.getParent()) { return mrOwner.getParent()->getSvgStyleAttributes(); } @@ -1880,6 +1880,21 @@ namespace svgio } } + // #125258# ask if fill is a direct hard attribute (no hierarchy) + bool SvgStyleAttributes::isFillSet() const + { + if(mbIsClipPathContent) + { + return false; + } + else if(maFill.isSet()) + { + return true; + } + + return false; + } + const basegfx::BColor* SvgStyleAttributes::getFill() const { if(mbIsClipPathContent) Modified: openoffice/branches/AOO410/main/svgio/source/svgreader/svgstylenode.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/svgio/source/svgreader/svgstylenode.cxx?rev=1611567&r1=1611566&r2=1611567&view=diff ============================================================================== --- openoffice/branches/AOO410/main/svgio/source/svgreader/svgstylenode.cxx (original) +++ openoffice/branches/AOO410/main/svgio/source/svgreader/svgstylenode.cxx Fri Jul 18 09:00:39 2014 @@ -49,6 +49,19 @@ namespace svgio } } + // #125258# no parent when we are a CssStyle holder to break potential loops because + // when using CssStyles we jump uncontrolled inside the node tree hierarchy + bool SvgStyleNode::supportsParentStyle() const + { + if(isTextCss()) + { + return false; + } + + // call parent + return SvgNode::supportsParentStyle(); + } + void SvgStyleNode::parseAttribute(const rtl::OUString& rTokenName, SVGToken aSVGToken, const rtl::OUString& aContent) { // call parent Modified: openoffice/branches/AOO410/main/svgio/source/svgreader/svgsvgnode.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/svgio/source/svgreader/svgsvgnode.cxx?rev=1611567&r1=1611566&r2=1611567&view=diff ============================================================================== --- openoffice/branches/AOO410/main/svgio/source/svgreader/svgsvgnode.cxx (original) +++ openoffice/branches/AOO410/main/svgio/source/svgreader/svgsvgnode.cxx Fri Jul 18 09:00:39 2014 @@ -49,12 +49,50 @@ namespace svgio maY(), maWidth(), maHeight(), - maVersion() + maVersion(), + mbStyleAttributesInitialized(false) // #125258# { - if(!getParent()) + } + + // #125258# + void SvgSvgNode::initializeStyleAttributes() + { + if(!mbStyleAttributesInitialized) { - // initial fill is black - maSvgStyleAttributes.setFill(SvgPaint(basegfx::BColor(0.0, 0.0, 0.0), true, true)); + // #125258# determine if initial values need to be initialized with hard values + // for the case that this is the outmost SVG statement and it has no parent + // stale (CssStyle for svg may be defined) + bool bSetInitialValues(true); + + if(getParent()) + { + // #125258# no initial values when it's a SVG element embedded in SVG + bSetInitialValues = false; + } + + if(bSetInitialValues) + { + const SvgStyleAttributes* pStyles = getSvgStyleAttributes(); + + if(pStyles && pStyles->getParentStyle()) + { + // #125258# no initial values when SVG has a parent style (probably CssStyle) + bSetInitialValues = false; + } + } + + if(bSetInitialValues) + { + // #125258# only set if not yet initialized (SvgSvgNode::parseAttribute is already done, + // just setting may revert an already set valid value) + if(!maSvgStyleAttributes.isFillSet()) + { + // #125258# initial fill is black (see SVG1.1 spec) + maSvgStyleAttributes.setFill(SvgPaint(basegfx::BColor(0.0, 0.0, 0.0), true, true)); + } + } + + mbStyleAttributesInitialized = true; } } @@ -65,7 +103,10 @@ namespace svgio const SvgStyleAttributes* SvgSvgNode::getSvgStyleAttributes() const { - return &maSvgStyleAttributes; + // #125258# svg node can vahe CssStyles, too, so check for it here + static rtl::OUString aClassStr(rtl::OUString::createFromAscii("svg")); + + return checkForCssStyle(aClassStr, maSvgStyleAttributes); } void SvgSvgNode::parseAttribute(const rtl::OUString& rTokenName, SVGToken aSVGToken, const rtl::OUString& aContent) @@ -251,6 +292,11 @@ namespace svgio { drawinglayer::primitive2d::Primitive2DSequence aSequence; + // #125258# check now if we need to init some style settings locally. Do not do this + // in the constructor, there is not yet informatikon e.g. about existing CssStyles. + // Here all nodes are read and interpreted + const_cast< SvgSvgNode* >(this)->initializeStyleAttributes(); + // decompose childs SvgNode::decomposeSvgNode(aSequence, bReferenced); Modified: openoffice/branches/AOO410/main/svgio/source/svgreader/svgtitledescnode.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/svgio/source/svgreader/svgtitledescnode.cxx?rev=1611567&r1=1611566&r2=1611567&view=diff ============================================================================== --- openoffice/branches/AOO410/main/svgio/source/svgreader/svgtitledescnode.cxx (original) +++ openoffice/branches/AOO410/main/svgio/source/svgreader/svgtitledescnode.cxx Fri Jul 18 09:00:39 2014 @@ -37,6 +37,7 @@ namespace svgio : SvgNode(aType, rDocument, pParent), maText() { + OSL_ENSURE(aType == SVGTokenTitle || aType == SVGTokenDesc, "SvgTitleDescNode should ony be used for Title and Desc (!)"); } SvgTitleDescNode::~SvgTitleDescNode()