svgio/qa/cppunit/SvgImportTest.cxx  |   35 +++++++++++++++++++++++++++++++++++
 svgio/qa/cppunit/data/tdf156569.svg |    4 ++++
 svgio/source/svgreader/svgtools.cxx |   17 +++++++----------
 3 files changed, 46 insertions(+), 10 deletions(-)

New commits:
commit 434885a3a9630050a6c88c1294841f0da3ea6a7b
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Tue Sep 5 13:09:40 2023 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed Sep 6 12:24:29 2023 +0200

    tdf#156569: '%' can be in the middle of the string
    
    For an unknown reason Jenkins fails on windows with
    
    Test name: testTdf156569::TestBody
    equality assertion failed
    - Expected: 1
    - Actual  : 0
    - In <>, XPath '/primitive2D/transform/textsimpleportion[1]' number of 
nodes is incorrect
    
    but it doesn't fail on master branch
    
    Change-Id: I5d6ab57c17ab2cbce4d3df629a91a006fad2198d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156564
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    (cherry picked from commit 78534e6fa741e3cb9cb756bea527400c34adbdf3)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156548

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index 06a5cfb63328..624918559940 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -1783,6 +1783,41 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf156283)
     assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", 
"dx2", "63");
 }
 
+#if !defined(_WIN32)
+CPPUNIT_TEST_FIXTURE(Test, testTdf156569)
+{
+    Primitive2DSequence aSequence = 
parseSvg(u"/svgio/qa/cppunit/data/tdf156569.svg");
+    CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence.getLength()));
+
+    drawinglayer::Primitive2dXmlDump dumper;
+    xmlDocUniquePtr pDocument = 
dumper.dumpAndParse(Primitive2DContainer(aSequence));
+
+    CPPUNIT_ASSERT (pDocument);
+
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", 
"width", "16");
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", 
"height", "16");
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "x", 
"0");
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "y", 
"20");
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", 
"text", "ABC");
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", 
"dx0", "40");
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", 
"dx1", "80");
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", 
"dx2", "91");
+
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", 
"width", "16");
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", 
"height", "16");
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "x", 
"0");
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "y", 
"30");
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", 
"text", "ABC");
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", 
"dx0", "40");
+
+    // Without the fix in place, this test would have failed with
+    // - Expected: 80
+    // - Actual  : 51
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", 
"dx1", "80");
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", 
"dx2", "91");
+}
+#endif
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf156837)
 {
     Primitive2DSequence aSequence = 
parseSvg(u"/svgio/qa/cppunit/data/tdf156837.svg");
diff --git a/svgio/qa/cppunit/data/tdf156569.svg 
b/svgio/qa/cppunit/data/tdf156569.svg
new file mode 100644
index 000000000000..ea9b3f513a0b
--- /dev/null
+++ b/svgio/qa/cppunit/data/tdf156569.svg
@@ -0,0 +1,4 @@
+<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg";>
+    <text x="0,40,80" y="20%">ABC</text>
+    <text x="0 40% 80%" y="30%">ABC</text>
+</svg>
diff --git a/svgio/source/svgreader/svgtools.cxx 
b/svgio/source/svgreader/svgtools.cxx
index 9fb930a53467..92befcbd70d9 100644
--- a/svgio/source/svgreader/svgtools.cxx
+++ b/svgio/source/svgreader/svgtools.cxx
@@ -293,7 +293,13 @@ namespace svgio::svgreader
             {
                 const sal_Unicode aCharA(rCandidate[nPos]);
 
-                if(nPos + 1 < nLen)
+                if('%' == aCharA)
+                {
+                    // percent used, relative to current
+                    nPos++;
+                    aRetval = SvgUnit::percent;
+                }
+                else if(nPos + 1 < nLen)
                 {
                     const sal_Unicode aCharB(rCandidate[nPos + 1]);
                     bool bTwoCharValid(false);
@@ -374,15 +380,6 @@ namespace svgio::svgreader
                         nPos += 2;
                     }
                 }
-                else
-                {
-                    if('%' == aCharA)
-                    {
-                        // percent used, relative to current
-                        nPos++;
-                        aRetval = SvgUnit::percent;
-                    }
-                }
             }
 
             return aRetval;

Reply via email to