summaryrefslogtreecommitdiff
path: root/svgio/source
diff options
context:
space:
mode:
authorArmin Le Grand <alg@apache.org>2013-01-23 09:27:24 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-06-13 21:00:33 +0100
commit0061af795047deb92c4b43ec191ad6ffd97d0b64 (patch)
tree6cf5df0880e4dc5b2699926d57dfe6214bb7f746 /svgio/source
parentf321d9519fc067977b003109373ad36a2fc4c97e (diff)
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/source')
-rw-r--r--svgio/source/svgreader/svgclippathnode.cxx2
-rw-r--r--svgio/source/svgreader/svgimagenode.cxx2
-rw-r--r--svgio/source/svgreader/svgmarkernode.cxx2
-rw-r--r--svgio/source/svgreader/svgmasknode.cxx2
-rw-r--r--svgio/source/svgreader/svgnode.cxx109
-rw-r--r--svgio/source/svgreader/svgpatternnode.cxx2
-rw-r--r--svgio/source/svgreader/svgstyleattributes.cxx43
-rw-r--r--svgio/source/svgreader/svgtoken.cxx2
-rw-r--r--svgio/source/svgreader/svgusenode.cxx2
-rw-r--r--svgio/source/svguno/xsvgparser.cxx7
10 files changed, 144 insertions, 29 deletions
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