svgio/qa/cppunit/SvgImportTest.cxx      |   13 ++++++
 svgio/qa/cppunit/data/tdf155833.svg     |   31 ++++++++++++++++
 svgio/source/svgreader/svgimagenode.cxx |   60 +++++++++++++-------------------
 3 files changed, 70 insertions(+), 34 deletions(-)

New commits:
commit 472d7ce57bdf1473538dda23c9328d44cdf816c8
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Thu Jun 15 10:10:38 2023 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Thu Jun 15 12:39:16 2023 +0200

    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 <xiscofa...@libreoffice.org>

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index bdfbfcccb911..7184c5fa500b 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -423,6 +423,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

Reply via email to