summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2023-06-15 10:10:38 +0200
committerAndras Timar <andras.timar@collabora.com>2023-06-23 18:49:12 +0200
commita341c8ab8f2c6bb11a2564d0a4c9f30f504ba516 (patch)
treee594215703c21a5c4afd2cf0546a0ac6f9e3382a
parent66d92943fd2ec8b9e4068326785455102a8bae35 (diff)
tdf#155833: apply transform to image even if target is equal to viewbox
Change-Id: Ie820528384d096c6a332e2abd0095f68c7f64a0f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153103 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> (cherry picked from commit 6dce36484bfcac711251710697dca961fd77ca20) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153082 Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153153
-rw-r--r--svgio/qa/cppunit/SvgImportTest.cxx13
-rw-r--r--svgio/qa/cppunit/data/tdf155833.svg31
-rw-r--r--svgio/source/svgreader/svgimagenode.cxx60
3 files changed, 70 insertions, 34 deletions
diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx
index ce9329b1a21a..16975f06f0b2 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -402,6 +402,19 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf45771)
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "familyname", "Times New Roman");
}
+CPPUNIT_TEST_FIXTURE(Test, testTdf155833)
+{
+ Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/tdf155833.svg");
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence.getLength()));
+
+ drawinglayer::Primitive2dXmlDump dumper;
+ xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequence);
+
+ CPPUNIT_ASSERT (pDocument);
+
+ assertXPath(pDocument, "/primitive2D/transform/mask/transform/transform/transform/transform/transform/bitmap", 1);
+}
+
CPPUNIT_TEST_FIXTURE(Test, testTdf97941)
{
//Check tspan fontsize when using relative units
diff --git a/svgio/qa/cppunit/data/tdf155833.svg b/svgio/qa/cppunit/data/tdf155833.svg
new file mode 100644
index 000000000000..8cc908424af0
--- /dev/null
+++ b/svgio/qa/cppunit/data/tdf155833.svg
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ width="32.677876mm"
+ height="32.677876mm"
+ viewBox="0 0 32.677876 32.677876"
+ version="1.1"
+ id="svg1126"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:svg="http://www.w3.org/2000/svg">
+ <g
+ id="layer1"
+ transform="translate(-80.317197,-107.43993)">
+ <g
+ id="g18033"
+ transform="matrix(0.35277777,0,0,-0.35277777,71.799819,211.06676)">
+ <g
+ id="g18041"
+ transform="matrix(92.88,0,0,92.88,24.14375,201.11516)">
+ <image
+ width="1"
+ height="1"
+ transform="matrix(1,0,0,-1,0,1)"
+ xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIEAAACBCAYAAADnoNlQAAAABHNCSVQICAgIfAhkiAAAAUJJREFUeJzt3EENAkEQRcG3aMAjMpYzBgjqSDCyWJhbZ5IqBf/w0sc+6rzaxnN6wLpzesC62/QA5okAESACEgGJgERAIiARkAhIBCQCEgGJgERAIiARkAhIBCQCEgGJgERAIiARkAhIBCQCEgGJgERAIiARkAhIBCQCEgGJgERAIiARkAiojvv12+at7aPP9IRlO211CRABIiARkAhIBCQCEgGJgERAIiARkAhIBCQCEgGJgERAIiARkAhIBCQCEgGJgERAIiARkAhIBCQCEgGJgERAIiARkAhIBCQCEgGJgERAdVzvtnlr22t6wLrnd3rBOpcAESACEgGJgERAIiARkAhIBCQCEgGJgERAIiARkAhIBCQCEgGJgERAIiARkAhIBCQCEgGJgERAIiARkAhIBCQCEgGJgERAIiARkAhIBFR/ALUM7y9VYLsAAAAASUVORK5CYII="
+ id="image18043" />
+ </g>
+ </g>
+ </g>
+</svg>
diff --git a/svgio/source/svgreader/svgimagenode.cxx b/svgio/source/svgreader/svgimagenode.cxx
index ed7b81cef61a..19c8c9404541 100644
--- a/svgio/source/svgreader/svgimagenode.cxx
+++ b/svgio/source/svgreader/svgimagenode.cxx
@@ -310,45 +310,37 @@ namespace svgio::svgreader
if(aNewTarget.empty())
return;
- if(aTarget.equal(aViewBox))
- {
- // just add to rTarget
- rTarget.append(aNewTarget);
- }
- else
- {
- // create mapping
- const SvgAspectRatio& rRatio = maSvgAspectRatio;
+ // create mapping
+ const SvgAspectRatio& rRatio = maSvgAspectRatio;
- // even when ratio is not set, use the defaults
- // let mapping be created from SvgAspectRatio
- const basegfx::B2DHomMatrix aEmbeddingTransform(rRatio.createMapping(aTarget, aViewBox));
+ // even when ratio is not set, use the defaults
+ // let mapping be created from SvgAspectRatio
+ const basegfx::B2DHomMatrix aEmbeddingTransform(rRatio.createMapping(aTarget, aViewBox));
- if(!aEmbeddingTransform.isIdentity())
- {
- const drawinglayer::primitive2d::Primitive2DReference xRef(
- new drawinglayer::primitive2d::TransformPrimitive2D(
- aEmbeddingTransform,
- std::move(aNewTarget)));
-
- aNewTarget = drawinglayer::primitive2d::Primitive2DContainer { xRef };
- }
+ if(!aEmbeddingTransform.isIdentity())
+ {
+ const drawinglayer::primitive2d::Primitive2DReference xRef(
+ new drawinglayer::primitive2d::TransformPrimitive2D(
+ aEmbeddingTransform,
+ std::move(aNewTarget)));
- if(!rRatio.isMeetOrSlice())
- {
- // need to embed in MaskPrimitive2D to ensure clipping
- const drawinglayer::primitive2d::Primitive2DReference xMask(
- new drawinglayer::primitive2d::MaskPrimitive2D(
- basegfx::B2DPolyPolygon(
- basegfx::utils::createPolygonFromRect(aTarget)),
- std::move(aNewTarget)));
-
- aNewTarget = drawinglayer::primitive2d::Primitive2DContainer { xMask };
- }
+ aNewTarget = drawinglayer::primitive2d::Primitive2DContainer { xRef };
+ }
- // embed and add to rTarget, take local extra-transform into account
- pStyle->add_postProcess(rTarget, std::move(aNewTarget), getTransform());
+ if(!rRatio.isMeetOrSlice())
+ {
+ // need to embed in MaskPrimitive2D to ensure clipping
+ const drawinglayer::primitive2d::Primitive2DReference xMask(
+ new drawinglayer::primitive2d::MaskPrimitive2D(
+ basegfx::B2DPolyPolygon(
+ basegfx::utils::createPolygonFromRect(aTarget)),
+ std::move(aNewTarget)));
+
+ aNewTarget = drawinglayer::primitive2d::Primitive2DContainer { xMask };
}
+
+ // embed and add to rTarget, take local extra-transform into account
+ pStyle->add_postProcess(rTarget, std::move(aNewTarget), getTransform());
}
} // end of namespace svgio::svgreader