svgio/qa/cppunit/SvgImportTest.cxx       |   33 +++++++++++++++++++++++++++++++
 svgio/qa/cppunit/data/tdf156569.svg      |    4 +++
 svgio/source/svgreader/svgtools.cxx      |   17 ++++++---------
 sw/inc/unodraw.hxx                       |    3 --
 sw/source/core/unocore/unocrsrhelper.cxx |   17 ++++-----------
 5 files changed, 50 insertions(+), 24 deletions(-)

New commits:
commit 12f271ac519dfb018395b9680f082c183cd3dd14
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Tue Sep 5 13:09:40 2023 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Sep 5 16:30:23 2023 +0200

    tdf#156569: '%' can be in the middle of the string
    
    Change-Id: I5d6ab57c17ab2cbce4d3df629a91a006fad2198d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156564
    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 0450d3617e11..c0792504cfba 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -1787,6 +1787,39 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf156283)
     assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", 
"dx2", "63");
 }
 
+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");
+}
+
 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 9cc805757544..999de3075336 100644
--- a/svgio/source/svgreader/svgtools.cxx
+++ b/svgio/source/svgreader/svgtools.cxx
@@ -446,7 +446,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);
@@ -527,15 +533,6 @@ namespace svgio::svgreader
                         nPos += 2;
                     }
                 }
-                else
-                {
-                    if('%' == aCharA)
-                    {
-                        // percent used, relative to current
-                        nPos++;
-                        aRetval = SvgUnit::percent;
-                    }
-                }
             }
 
             return aRetval;
commit e1247697aff263fa3098edb6fd78e0c47b5ab026
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Sep 5 12:21:12 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Sep 5 16:30:18 2023 +0200

    DRY use existing method in SwXShape rather than open-coding
    
    Change-Id: I1dc66d4161411998ab36e454ad168cada2dc7a23
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156561
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/inc/unodraw.hxx b/sw/inc/unodraw.hxx
index 02deab879ee5..5d31bbb9bb48 100644
--- a/sw/inc/unodraw.hxx
+++ b/sw/inc/unodraw.hxx
@@ -146,8 +146,6 @@ class SwXShape : public SwXShapeBaseClass
 
     bool                        m_bDescriptor;
 
-    SvxShape*               GetSvxShape();
-
     /** method to determine top group object */
     SdrObject* GetTopGroupObj( SvxShape* _pSvxShape = nullptr );
 
@@ -246,6 +244,7 @@ public:
     SwShapeDescriptor_Impl*     GetDescImpl() {return m_pImpl.get();}
     SwFrameFormat* GetFrameFormat() const;
     const css::uno::Reference< css::uno::XAggregation >& 
GetAggregationInterface() const {return m_xShapeAgg;}
+    SvxShape*               GetSvxShape();
 
     // helper
     static void AddExistingShapeToFormat( SdrObject const & _rObj );
diff --git a/sw/source/core/unocore/unocrsrhelper.cxx 
b/sw/source/core/unocore/unocrsrhelper.cxx
index 54dd3df5d695..d68169643f81 100644
--- a/sw/source/core/unocore/unocrsrhelper.cxx
+++ b/sw/source/core/unocore/unocrsrhelper.cxx
@@ -148,19 +148,12 @@ void GetSelectableFromAny(uno::Reference<uno::XInterface> 
const& xIfc,
     SwXShape *const pShape(comphelper::getFromUnoTunnel<SwXShape>(xTunnel));
     if (pShape)
     {
-        uno::Reference<uno::XAggregation> const xAgg(
-                pShape->GetAggregationInterface());
-        if (xAgg.is())
+        if (SvxShape * pSvxShape = pShape->GetSvxShape())
         {
-            SvxShape *const pSvxShape(
-                    comphelper::getFromUnoTunnel<SvxShape>(xTunnel));
-            if (pSvxShape)
-            {
-                SdrObject *const pSdrObject = pSvxShape->GetSdrObject();
-                if (pSdrObject)
-                {   // hmm... needs view to verify it's in right doc...
-                    o_rSdrObjects.push_back(pSdrObject);
-                }
+            SdrObject *const pSdrObject = pSvxShape->GetSdrObject();
+            if (pSdrObject)
+            {   // hmm... needs view to verify it's in right doc...
+                o_rSdrObjects.push_back(pSdrObject);
             }
         }
         return;

Reply via email to