diff options
author | Armin Le Grand <alg@apache.org> | 2013-01-23 09:27:24 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-06-13 21:00:33 +0100 |
commit | 0061af795047deb92c4b43ec191ad6ffd97d0b64 (patch) | |
tree | 6cf5df0880e4dc5b2699926d57dfe6214bb7f746 /svgio | |
parent | cppcheck: fix return statement followed by break (diff) | |
download | core-0061af795047deb92c4b43ec191ad6ffd97d0b64.tar.gz core-0061af795047deb92c4b43ec191ad6ffd97d0b64.zip |
Resolves: #i121656# Some more cleanups for SVG import
also const as const can
(cherry picked from commit bb9ad24b16add4888c4b1fadac5252b95a72f04f)
Conflicts:
svgio/inc/svgio/svgreader/svgstyleattributes.hxx
svgio/source/svgreader/svgstyleattributes.cxx
svgio/source/svgreader/svgtoken.cxx
Change-Id: If236eb8b1e0193c43229ea6dc496eb3a8fd20c42
Related: #i121656# removed const for return-by-value
(cherry picked from commit aa85e31b3162cd4b18c818bf0af1a854cb05c57d)
Conflicts:
svgio/inc/svgio/svgreader/svgstyleattributes.hxx
svgio/source/svgreader/svgstyleattributes.cxx
Change-Id: Ief43c478ea3000d114487918875e9a201dd827bc
Diffstat (limited to 'svgio')
-rw-r--r-- | svgio/inc/svgio/svgreader/svgnode.hxx | 30 | ||||
-rw-r--r-- | svgio/inc/svgio/svgreader/svgstyleattributes.hxx | 22 | ||||
-rw-r--r-- | svgio/inc/svgio/svgreader/svgtoken.hxx | 1 | ||||
-rw-r--r-- | svgio/source/svgreader/svgclippathnode.cxx | 2 | ||||
-rw-r--r-- | svgio/source/svgreader/svgimagenode.cxx | 2 | ||||
-rw-r--r-- | svgio/source/svgreader/svgmarkernode.cxx | 2 | ||||
-rw-r--r-- | svgio/source/svgreader/svgmasknode.cxx | 2 | ||||
-rw-r--r-- | svgio/source/svgreader/svgnode.cxx | 109 | ||||
-rw-r--r-- | svgio/source/svgreader/svgpatternnode.cxx | 2 | ||||
-rw-r--r-- | svgio/source/svgreader/svgstyleattributes.cxx | 43 | ||||
-rw-r--r-- | svgio/source/svgreader/svgtoken.cxx | 2 | ||||
-rw-r--r-- | svgio/source/svgreader/svgusenode.cxx | 2 | ||||
-rw-r--r-- | svgio/source/svguno/xsvgparser.cxx | 7 |
13 files changed, 186 insertions, 40 deletions
diff --git a/svgio/inc/svgio/svgreader/svgnode.hxx b/svgio/inc/svgio/svgreader/svgnode.hxx index 759859bd395c..2aa28165fe4e 100644 --- a/svgio/inc/svgio/svgreader/svgnode.hxx +++ b/svgio/inc/svgio/svgreader/svgnode.hxx @@ -56,6 +56,29 @@ namespace svgio XmlSpace_preserve }; + // display property (see SVG 1.1. 11.5), not inheritable + enum Display // #i121656# + { + Display_inline, // the default + Display_block, + Display_list_item, + Display_run_in, + Display_compact, + Display_marker, + Display_table, + Display_inline_table, + Display_table_row_group, + Display_table_header_group, + Display_table_footer_group, + Display_table_row, + Display_table_column_group, + Display_table_column, + Display_table_cell, + Display_table_caption, + Display_none, + Display_inherit + }; + class SvgNode : private boost::noncopyable, public InfoProvider { private: @@ -77,6 +100,9 @@ namespace svgio /// XmlSpace value XmlSpace maXmlSpace; + /// Display value #i121656# + Display maDisplay; + /// CSS styles SvgStyleAttributeVector maCssStyleVector; @@ -119,6 +145,10 @@ namespace svgio XmlSpace getXmlSpace() const; void setXmlSpace(XmlSpace eXmlSpace = XmlSpace_notset) { maXmlSpace = eXmlSpace; } + /// Display access #i121656# + Display getDisplay() const { return maDisplay; } + void setDisplay(Display eDisplay = Display_inherit) { maDisplay = eDisplay; } + /// alternative parent void setAlternativeParent(const SvgNode* pAlternativeParent = 0) { mpAlternativeParent = pAlternativeParent; } }; diff --git a/svgio/inc/svgio/svgreader/svgstyleattributes.hxx b/svgio/inc/svgio/svgreader/svgstyleattributes.hxx index fe290aed6d37..a84fd4648e98 100644 --- a/svgio/inc/svgio/svgreader/svgstyleattributes.hxx +++ b/svgio/inc/svgio/svgreader/svgstyleattributes.hxx @@ -287,11 +287,11 @@ namespace svgio void setStopColor(const SvgPaint& rStopColor) { maStopColor = rStopColor; } /// stroke-width content - const SvgNumber getStrokeWidth() const; + SvgNumber getStrokeWidth() const; void setStrokeWidth(const SvgNumber& rStrokeWidth = SvgNumber()) { maStrokeWidth = rStrokeWidth; } /// stop opacity content - const SvgNumber getStopOpacity() const; + SvgNumber getStopOpacity() const; void setStopOpacity(const SvgNumber& rStopOpacity = SvgNumber()) { maStopOpacity = rStopOpacity; } /// access to evtl. set fill gradient @@ -311,7 +311,7 @@ namespace svgio void setSvgPatternNodeStroke(const SvgPatternNode* pNew) { mpSvgPatternNodeStroke = pNew; } /// fill opacity content - const SvgNumber getFillOpacity() const; + SvgNumber getFillOpacity() const; void setFillOpacity(const SvgNumber& rFillOpacity = SvgNumber()) { maFillOpacity = rFillOpacity; } /// fill rule content @@ -327,7 +327,7 @@ namespace svgio void setStrokeDasharraySet(bool bNew) { mbStrokeDasharraySet = bNew; } /// StrokeDashOffset content - const SvgNumber getStrokeDashOffset() const; + SvgNumber getStrokeDashOffset() const; void setStrokeDashOffset(const SvgNumber& rStrokeDashOffset = SvgNumber()) { maStrokeDashOffset = rStrokeDashOffset; } /// StrokeLinecap content @@ -339,11 +339,11 @@ namespace svgio void setStrokeLinejoin(const StrokeLinejoin aStrokeLinejoin = StrokeLinejoin_notset) { maStrokeLinejoin = aStrokeLinejoin; } /// StrokeMiterLimit content - const SvgNumber getStrokeMiterLimit() const; + SvgNumber getStrokeMiterLimit() const; void setStrokeMiterLimit(const SvgNumber& rStrokeMiterLimit = SvgNumber()) { maStrokeMiterLimit = rStrokeMiterLimit; } /// StrokeOpacity content - const SvgNumber getStrokeOpacity() const; + SvgNumber getStrokeOpacity() const; void setStrokeOpacity(const SvgNumber& rStrokeOpacity = SvgNumber()) { maStrokeOpacity = rStrokeOpacity; } /// Font content @@ -351,7 +351,7 @@ namespace svgio void setFontFamily(const SvgStringVector& rSvgStringVector = SvgStringVector()) { maFontFamily = rSvgStringVector; } /// FontSize content - const SvgNumber getFontSize() const; + SvgNumber getFontSize() const; void setFontSize(const SvgNumber& rFontSize = SvgNumber()) { maFontSize = rFontSize; } /// FontStretch content @@ -388,7 +388,7 @@ namespace svgio void setColor(const SvgPaint& rColor) { maColor = rColor; } /// Opacity content - const SvgNumber getOpacity() const { return maOpacity; } + SvgNumber getOpacity() const { return maOpacity; } void setOpacity(const SvgNumber& rOpacity = SvgNumber()) { maOpacity = rOpacity; } // Title content @@ -408,17 +408,17 @@ namespace svgio void setMaskXLink(const OUString& rNew) { maMaskXLink = rNew; } // MarkerStartXLink content - const OUString getMarkerStartXLink() const; + OUString getMarkerStartXLink() const; const SvgMarkerNode* accessMarkerStartXLink() const; void setMarkerStartXLink(const OUString& rNew) { maMarkerStartXLink = rNew; } // MarkerMidXLink content - const OUString getMarkerMidXLink() const; + OUString getMarkerMidXLink() const; const SvgMarkerNode* accessMarkerMidXLink() const; void setMarkerMidXLink(const OUString& rNew) { maMarkerMidXLink = rNew; } // MarkerEndXLink content - const OUString getMarkerEndXLink() const; + OUString getMarkerEndXLink() const; const SvgMarkerNode* accessMarkerEndXLink() const; void setMarkerEndXLink(const OUString& rNew) { maMarkerEndXLink = rNew; } diff --git a/svgio/inc/svgio/svgreader/svgtoken.hxx b/svgio/inc/svgio/svgreader/svgtoken.hxx index 9e81c9d1697f..2e1f8c43b036 100644 --- a/svgio/inc/svgio/svgreader/svgtoken.hxx +++ b/svgio/inc/svgio/svgreader/svgtoken.hxx @@ -40,6 +40,7 @@ namespace svgio SVGTokenViewBox, SVGTokenTransform, SVGTokenStyle, + SVGTokenDisplay, // #i121656# SVGTokenD, SVGTokenX, SVGTokenY, diff --git a/svgio/source/svgreader/svgclippathnode.cxx b/svgio/source/svgreader/svgclippathnode.cxx index 16a126e2dfd3..f536f5ea3d84 100644 --- a/svgio/source/svgreader/svgclippathnode.cxx +++ b/svgio/source/svgreader/svgclippathnode.cxx @@ -128,7 +128,7 @@ namespace svgio void SvgClipPathNode::apply(drawinglayer::primitive2d::Primitive2DSequence& rContent) const { - if(rContent.hasElements()) + if(rContent.hasElements() && Display_none != getDisplay()) { const drawinglayer::geometry::ViewInformation2D aViewInformation2D; drawinglayer::primitive2d::Primitive2DSequence aClipTarget; diff --git a/svgio/source/svgreader/svgimagenode.cxx b/svgio/source/svgreader/svgimagenode.cxx index 7c7de6b6493e..31788f58155e 100644 --- a/svgio/source/svgreader/svgimagenode.cxx +++ b/svgio/source/svgreader/svgimagenode.cxx @@ -255,7 +255,7 @@ namespace svgio { const SvgNode* mpXLink = getDocument().findSvgNodeById(maXLink); - if(mpXLink) + if(mpXLink && Display_none != mpXLink->getDisplay()) { mpXLink->decomposeSvgNode(aNewTarget, true); diff --git a/svgio/source/svgreader/svgmarkernode.cxx b/svgio/source/svgreader/svgmarkernode.cxx index e79b0f07c3ad..fdbb8bd68655 100644 --- a/svgio/source/svgreader/svgmarkernode.cxx +++ b/svgio/source/svgreader/svgmarkernode.cxx @@ -182,7 +182,7 @@ namespace svgio const drawinglayer::primitive2d::Primitive2DSequence& SvgMarkerNode::getMarkerPrimitives() const { - if(!aPrimitives.hasElements()) + if(!aPrimitives.hasElements() && Display_none != getDisplay()) { decomposeSvgNode(const_cast< SvgMarkerNode* >(this)->aPrimitives, true); } diff --git a/svgio/source/svgreader/svgmasknode.cxx b/svgio/source/svgreader/svgmasknode.cxx index 831cf3990e9c..d0f3f29ee2eb 100644 --- a/svgio/source/svgreader/svgmasknode.cxx +++ b/svgio/source/svgreader/svgmasknode.cxx @@ -194,7 +194,7 @@ namespace svgio void SvgMaskNode::apply(drawinglayer::primitive2d::Primitive2DSequence& rTarget) const { - if(rTarget.hasElements()) + if(rTarget.hasElements() && Display_none != getDisplay()) { drawinglayer::primitive2d::Primitive2DSequence aMaskTarget; diff --git a/svgio/source/svgreader/svgnode.cxx b/svgio/source/svgreader/svgnode.cxx index ff44050c0473..8e955465f0c6 100644 --- a/svgio/source/svgreader/svgnode.cxx +++ b/svgio/source/svgreader/svgnode.cxx @@ -144,6 +144,7 @@ namespace svgio mpId(0), mpClass(0), maXmlSpace(XmlSpace_notset), + maDisplay(Display_inline), maCssStyleVector() { OSL_ENSURE(SVGTokenUnknown != maType, "SvgNode with unknown type created (!)"); @@ -225,6 +226,104 @@ namespace svgio } break; } + case SVGTokenDisplay: + { + if(aContent.getLength()) + { + static rtl::OUString aStrInline(rtl::OUString::createFromAscii("inline")); + static rtl::OUString aStrBlock(rtl::OUString::createFromAscii("block")); + static rtl::OUString aStrList_item(rtl::OUString::createFromAscii("list-item")); + static rtl::OUString aStrRun_in(rtl::OUString::createFromAscii("run-in")); + static rtl::OUString aStrCompact(rtl::OUString::createFromAscii("compact")); + static rtl::OUString aStrMarker(rtl::OUString::createFromAscii("marker")); + static rtl::OUString aStrTable(rtl::OUString::createFromAscii("table")); + static rtl::OUString aStrInline_table(rtl::OUString::createFromAscii("inline-table")); + static rtl::OUString aStrTable_row_group(rtl::OUString::createFromAscii("table-row-group")); + static rtl::OUString aStrTable_header_group(rtl::OUString::createFromAscii("table-header-group")); + static rtl::OUString aStrTable_footer_group(rtl::OUString::createFromAscii("table-footer-group")); + static rtl::OUString aStrTable_row(rtl::OUString::createFromAscii("table-row")); + static rtl::OUString aStrTable_column_group(rtl::OUString::createFromAscii("table-column-group")); + static rtl::OUString aStrTable_column(rtl::OUString::createFromAscii("table-column")); + static rtl::OUString aStrTable_cell(rtl::OUString::createFromAscii("table-cell")); + static rtl::OUString aStrTable_caption(rtl::OUString::createFromAscii("table-caption")); + static rtl::OUString aStrNone(rtl::OUString::createFromAscii("none")); + static rtl::OUString aStrInherit(rtl::OUString::createFromAscii("inherit")); + + if(aContent.match(aStrInline)) + { + setDisplay(Display_inline); + } + else if(aContent.match(aStrNone)) + { + setDisplay(Display_none); + } + else if(aContent.match(aStrInherit)) + { + setDisplay(Display_inherit); + } + else if(aContent.match(aStrBlock)) + { + setDisplay(Display_block); + } + else if(aContent.match(aStrList_item)) + { + setDisplay(Display_list_item); + } + else if(aContent.match(aStrRun_in)) + { + setDisplay(Display_run_in); + } + else if(aContent.match(aStrCompact)) + { + setDisplay(Display_compact); + } + else if(aContent.match(aStrMarker)) + { + setDisplay(Display_marker); + } + else if(aContent.match(aStrTable)) + { + setDisplay(Display_table); + } + else if(aContent.match(aStrInline_table)) + { + setDisplay(Display_inline_table); + } + else if(aContent.match(aStrTable_row_group)) + { + setDisplay(Display_table_row_group); + } + else if(aContent.match(aStrTable_header_group)) + { + setDisplay(Display_table_header_group); + } + else if(aContent.match(aStrTable_footer_group)) + { + setDisplay(Display_table_footer_group); + } + else if(aContent.match(aStrTable_row)) + { + setDisplay(Display_table_row); + } + else if(aContent.match(aStrTable_column_group)) + { + setDisplay(Display_table_column_group); + } + else if(aContent.match(aStrTable_column)) + { + setDisplay(Display_table_column); + } + else if(aContent.match(aStrTable_cell)) + { + setDisplay(Display_table_cell); + } + else if(aContent.match(aStrTable_caption)) + { + setDisplay(Display_table_caption); + } + } + break; + } default: { break; @@ -234,6 +333,11 @@ namespace svgio void SvgNode::decomposeSvgNode(drawinglayer::primitive2d::Primitive2DSequence& rTarget, bool bReferenced) const { + if(Display_none == getDisplay()) + { + return; + } + if(!bReferenced) { if(SVGTokenDefs == getType() || @@ -253,6 +357,9 @@ namespace svgio // also not directly used are Markers and Patterns, only indirecty used // by reference + + // #i121656# also do not decompose nodes which have display="none" set + // as property return; } } @@ -267,7 +374,7 @@ namespace svgio { SvgNode* pCandidate = rChildren[a]; - if(pCandidate) + if(pCandidate && Display_none != pCandidate->getDisplay()) { drawinglayer::primitive2d::Primitive2DSequence aNewTarget; diff --git a/svgio/source/svgreader/svgpatternnode.cxx b/svgio/source/svgreader/svgpatternnode.cxx index 229a7c6246a3..522f02428ed5 100644 --- a/svgio/source/svgreader/svgpatternnode.cxx +++ b/svgio/source/svgreader/svgpatternnode.cxx @@ -269,7 +269,7 @@ namespace svgio const drawinglayer::primitive2d::Primitive2DSequence& SvgPatternNode::getPatternPrimitives() const { - if(!aPrimitives.hasElements()) + if(!aPrimitives.hasElements() && Display_none != getDisplay()) { decomposeSvgNode(const_cast< SvgPatternNode* >(this)->aPrimitives, true); } diff --git a/svgio/source/svgreader/svgstyleattributes.cxx b/svgio/source/svgreader/svgstyleattributes.cxx index 140107f5d604..7b8a8a59cc1a 100644 --- a/svgio/source/svgreader/svgstyleattributes.cxx +++ b/svgio/source/svgreader/svgstyleattributes.cxx @@ -1070,6 +1070,18 @@ namespace svgio aSource = drawinglayer::primitive2d::Primitive2DSequence(&xRef, 1); } + if(pTransform) + { + // create embedding group element with transformation. This applies the given + // transformation to the graphical content, but *not* to mask and/or clip (as needed) + const drawinglayer::primitive2d::Primitive2DReference xRef( + new drawinglayer::primitive2d::TransformPrimitive2D( + *pTransform, + aSource)); + + aSource = drawinglayer::primitive2d::Primitive2DSequence(&xRef, 1); + } + if(getClipPathXLink().getLength()) { // try to access linked ClipPath @@ -1096,17 +1108,6 @@ namespace svgio if(aSource.hasElements()) // test again, applied mask may have lead to empty geometry { - if(pTransform) - { - // create embedding group element with transformation - const drawinglayer::primitive2d::Primitive2DReference xRef( - new drawinglayer::primitive2d::TransformPrimitive2D( - *pTransform, - aSource)); - - aSource = drawinglayer::primitive2d::Primitive2DSequence(&xRef, 1); - } - // append to current target drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(rTarget, aSource); } @@ -1951,7 +1952,7 @@ namespace svgio return 0; } - const SvgNumber SvgStyleAttributes::getStrokeWidth() const + SvgNumber SvgStyleAttributes::getStrokeWidth() const { if(mbIsClipPathContent) { @@ -1973,7 +1974,7 @@ namespace svgio return SvgNumber(1.0); } - const SvgNumber SvgStyleAttributes::getStopOpacity() const + SvgNumber SvgStyleAttributes::getStopOpacity() const { if(maStopOpacity.isSet()) { @@ -1984,7 +1985,7 @@ namespace svgio return SvgNumber(1.0); } - const SvgNumber SvgStyleAttributes::getFillOpacity() const + SvgNumber SvgStyleAttributes::getFillOpacity() const { if(mbIsClipPathContent) { @@ -2047,7 +2048,7 @@ namespace svgio return maStrokeDasharray; } - const SvgNumber SvgStyleAttributes::getStrokeDashOffset() const + SvgNumber SvgStyleAttributes::getStrokeDashOffset() const { if(maStrokeDashOffset.isSet()) { @@ -2101,7 +2102,7 @@ namespace svgio return StrokeLinejoin_miter; } - const SvgNumber SvgStyleAttributes::getStrokeMiterLimit() const + SvgNumber SvgStyleAttributes::getStrokeMiterLimit() const { if(maStrokeMiterLimit.isSet()) { @@ -2119,7 +2120,7 @@ namespace svgio return SvgNumber(4.0); } - const SvgNumber SvgStyleAttributes::getStrokeOpacity() const + SvgNumber SvgStyleAttributes::getStrokeOpacity() const { if(maStrokeOpacity.isSet()) { @@ -2155,7 +2156,7 @@ namespace svgio return maFontFamily; } - const SvgNumber SvgStyleAttributes::getFontSize() const + SvgNumber SvgStyleAttributes::getFontSize() const { if(maFontSize.isSet()) { @@ -2351,7 +2352,7 @@ namespace svgio return 0; } - const OUString SvgStyleAttributes::getMarkerStartXLink() const + OUString SvgStyleAttributes::getMarkerStartXLink() const { if(maMarkerStartXLink.getLength()) { @@ -2383,7 +2384,7 @@ namespace svgio return mpMarkerStartXLink; } - const OUString SvgStyleAttributes::getMarkerMidXLink() const + OUString SvgStyleAttributes::getMarkerMidXLink() const { if(maMarkerMidXLink.getLength()) { @@ -2415,7 +2416,7 @@ namespace svgio return mpMarkerMidXLink; } - const OUString SvgStyleAttributes::getMarkerEndXLink() const + OUString SvgStyleAttributes::getMarkerEndXLink() const { if(maMarkerEndXLink.getLength()) { diff --git a/svgio/source/svgreader/svgtoken.cxx b/svgio/source/svgreader/svgtoken.cxx index cbb171b51d14..e40208527171 100644 --- a/svgio/source/svgreader/svgtoken.cxx +++ b/svgio/source/svgreader/svgtoken.cxx @@ -30,6 +30,7 @@ namespace svgio static OUString aSVGStrViewBox(OUString::createFromAscii("viewBox")); static OUString aSVGStrTransform(OUString::createFromAscii("transform")); static OUString aSVGStrStyle(OUString::createFromAscii("style")); + static OUString aSVGStrDisplay(OUString::createFromAscii("display")); // #i121656# static OUString aSVGStrD(OUString::createFromAscii("d")); static OUString aSVGStrX(OUString::createFromAscii("x")); static OUString aSVGStrY(OUString::createFromAscii("y")); @@ -173,6 +174,7 @@ namespace svgio aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrViewBox, SVGTokenViewBox)); aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrTransform, SVGTokenTransform)); aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrStyle, SVGTokenStyle)); + aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrDisplay, SVGTokenDisplay)); // #i121656# aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrD, SVGTokenD)); aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrX, SVGTokenX)); aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrY, SVGTokenY)); diff --git a/svgio/source/svgreader/svgusenode.cxx b/svgio/source/svgreader/svgusenode.cxx index 1768a176a989..4db965af6fb2 100644 --- a/svgio/source/svgreader/svgusenode.cxx +++ b/svgio/source/svgreader/svgusenode.cxx @@ -145,7 +145,7 @@ namespace svgio // try to access link to content const SvgNode* mpXLink = getDocument().findSvgNodeById(maXLink); - if(mpXLink) + if(mpXLink && Display_none != mpXLink->getDisplay()) { // decompose childs drawinglayer::primitive2d::Primitive2DSequence aNewTarget; diff --git a/svgio/source/svguno/xsvgparser.cxx b/svgio/source/svguno/xsvgparser.cxx index 1ee5a23d4fce..bafeb0e625d1 100644 --- a/svgio/source/svguno/xsvgparser.cxx +++ b/svgio/source/svguno/xsvgparser.cxx @@ -162,7 +162,12 @@ namespace svgio for(sal_uInt32 a(0); a < nCount; a++) { - rResults[a]->decomposeSvgNode(aRetval, false); + SvgNode* pCandidate = rResults[a]; + + if(Display_none != pCandidate->getDisplay()) + { + pCandidate->decomposeSvgNode(aRetval, false); + } } } else |