summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2024-03-26 14:13:21 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2024-03-27 08:51:49 +0100
commitd6d502f41346b021d369c27c9ed969d75d680986 (patch)
treef5dc976c7960fa23991810d84056939b215df880
parenttdf#129905 tdf#160365 sw: don't always draw text boundary on frames (diff)
downloadcore-d6d502f41346b021d369c27c9ed969d75d680986.tar.gz
core-d6d502f41346b021d369c27c9ed969d75d680986.zip
tdf#160373: Iterate over all parents to check whether it's a clipPath content
Change-Id: I383ec264e4c88ebcee2ae6a839b762bba8abfc12 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165347 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> (cherry picked from commit 261985b6936ede212852e806c4b140ea634a5af3) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165318 Reviewed-by: Stéphane Guillou <stephane.guillou@libreoffice.org>
-rw-r--r--svgio/inc/svgstyleattributes.hxx9
-rw-r--r--svgio/qa/cppunit/SvgImportTest.cxx14
-rw-r--r--svgio/qa/cppunit/data/tdf160373.svg14
-rw-r--r--svgio/source/svgreader/svgstyleattributes.cxx36
4 files changed, 55 insertions, 18 deletions
diff --git a/svgio/inc/svgstyleattributes.hxx b/svgio/inc/svgstyleattributes.hxx
index 4e55ab3fc644..1b5db09eb687 100644
--- a/svgio/inc/svgstyleattributes.hxx
+++ b/svgio/inc/svgstyleattributes.hxx
@@ -241,10 +241,6 @@ namespace svgio::svgreader
mutable std::vector<sal_uInt16> maResolvingParent;
- // defines if this attributes are part of a ClipPath. If yes,
- // rough geometry will be created on decomposition by patching
- // values for fill, stroke, strokeWidth and others
- bool mbIsClipPathContent : 1;
// #121221# Defines if evtl. an empty array *is* set
bool mbStrokeDasharraySet : 1;
@@ -316,6 +312,11 @@ namespace svgio::svgreader
SvgStyleAttributes(SvgNode& rOwner);
~SvgStyleAttributes();
+ // Check if this attribute is part of a ClipPath.
+ // If so, rough geometry will be created on decomposition by patching
+ // values for fill, stroke, strokeWidth and others
+ bool isClipPathContent() const;
+
/// fill content
bool isFillSet() const; // #i125258# ask if fill is a direct hard attribute (no hierarchy)
const basegfx::BColor* getFill() const;
diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx
index 90b62bcce7ff..262c5cadcc68 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -441,6 +441,20 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf156168)
assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke[4]/line", "color", "#00ff00");
}
+CPPUNIT_TEST_FIXTURE(Test, testTdf160373)
+{
+ Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/tdf160373.svg");
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence.getLength()));
+
+ drawinglayer::Primitive2dXmlDump dumper;
+ xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequence);
+
+ CPPUNIT_ASSERT (pDocument);
+
+ // Without the fix in place, nothing would be displayed
+ assertXPath(pDocument, "/primitive2D/transform/transform/polypolygoncolor", "color", "#0000ff");
+}
+
CPPUNIT_TEST_FIXTURE(Test, testTdf129356)
{
Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/tdf129356.svg");
diff --git a/svgio/qa/cppunit/data/tdf160373.svg b/svgio/qa/cppunit/data/tdf160373.svg
new file mode 100644
index 000000000000..73b18bb2ea61
--- /dev/null
+++ b/svgio/qa/cppunit/data/tdf160373.svg
@@ -0,0 +1,14 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='503.75pt' height='503.25pt' viewBox='0 0 503.75 503.25'>
+<defs>
+ <style type='text/css'><![CDATA[
+ rect { fill: none; }
+ ]]></style>
+</defs>
+ <clipPath id='cpMC4wMHw1MDMuNzV8MC4wMHw1MDMuMjU='>
+ <rect x='0.00' y='0.00' width='503.75' height='503.25' />
+ </clipPath>
+<g clip-path='url(#cpMC4wMHw1MDMuNzV8MC4wMHw1MDMuMjU=)'>
+<rect class="r5" x="10" y="0" height="50" width="50" style="fill:blue"></rect>
+</g>
+</svg>
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx b/svgio/source/svgreader/svgstyleattributes.cxx
index b0fd42303976..826f00b6687a 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -1292,18 +1292,9 @@ namespace svgio::svgreader
maBaselineShift(BaselineShift::Baseline),
maBaselineShiftNumber(0),
maDominantBaseline(DominantBaseline::Auto),
- maResolvingParent(31, 0),
- mbIsClipPathContent(SVGToken::ClipPathNode == mrOwner.getType()),
+ maResolvingParent(32, 0),
mbStrokeDasharraySet(false)
{
- const SvgStyleAttributes* pParentStyle = getParentStyle();
- if(!mbIsClipPathContent)
- {
- if(pParentStyle)
- {
- mbIsClipPathContent = pParentStyle->mbIsClipPathContent;
- }
- }
}
SvgStyleAttributes::~SvgStyleAttributes()
@@ -1995,10 +1986,27 @@ namespace svgio::svgreader
}
}
+ bool SvgStyleAttributes::isClipPathContent() const
+ {
+ if (SVGToken::ClipPathNode == mrOwner.getType())
+ return true;
+
+ const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
+ if (pSvgStyleAttributes && maResolvingParent[31] < nStyleDepthLimit)
+ {
+ ++maResolvingParent[31];
+ bool ret = pSvgStyleAttributes->isClipPathContent();
+ --maResolvingParent[31];
+ return ret;
+ }
+
+ return false;
+ }
+
// #i125258# ask if fill is a direct hard attribute (no hierarchy)
bool SvgStyleAttributes::isFillSet() const
{
- if(mbIsClipPathContent)
+ if(isClipPathContent())
{
return false;
}
@@ -2032,7 +2040,7 @@ namespace svgio::svgreader
{
return &maFill.getBColor();
}
- else if(mbIsClipPathContent)
+ else if(isClipPathContent())
{
const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
@@ -2056,7 +2064,7 @@ namespace svgio::svgreader
const basegfx::BColor* pFill = pSvgStyleAttributes->getFill();
--maResolvingParent[0];
- if(mbIsClipPathContent)
+ if(isClipPathContent())
{
if (pFill)
{
@@ -2259,7 +2267,7 @@ namespace svgio::svgreader
return ret;
}
- if(mbIsClipPathContent)
+ if(isClipPathContent())
{
return SvgNumber(0.0);
}