svgio/inc/svgcharacternode.hxx                |    1 
 svgio/qa/cppunit/SvgImportTest.cxx            |   20 +++++++++++
 svgio/qa/cppunit/data/tdf103888.svg           |   11 ++++++
 svgio/source/svgreader/svgcharacternode.cxx   |    5 --
 svgio/source/svgreader/svgdocumenthandler.cxx |   44 ++------------------------
 5 files changed, 34 insertions(+), 47 deletions(-)

New commits:
commit a42f5faac7c6d4590e632cf40e3ba9eb618e6f56
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Wed Sep 21 17:25:17 2022 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed Sep 21 21:04:40 2022 +0200

    tdf#103888: Do not add a gap at the end of each text portion
    
    I can't think of any situation where it's needed
    
    Change-Id: I1c2c6ec3d22eb9263f3c3c20793d9fe3926b8d78
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140351
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/svgio/inc/svgcharacternode.hxx b/svgio/inc/svgcharacternode.hxx
index b7a0a9a254c9..9558e7b752b9 100644
--- a/svgio/inc/svgcharacternode.hxx
+++ b/svgio/inc/svgcharacternode.hxx
@@ -141,7 +141,6 @@ namespace svgio::svgreader
             virtual const SvgStyleAttributes* getSvgStyleAttributes() const 
override;
             void 
decomposeText(drawinglayer::primitive2d::Primitive2DContainer& rTarget, 
SvgTextPosition& rSvgTextPosition) const;
             void whiteSpaceHandling();
-            void addGap();
             void concatenate(std::u16string_view rText);
 
             /// Text content
diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index 7db9c8335b1f..07a98f4a5a2f 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -73,6 +73,7 @@ class Test : public test::BootstrapFixture, public 
XmlTestTools
     void test123926();
     void test47446();
     void test47446b();
+    void testTdf103888();
     void testMaskText();
     void testTdf99994();
     void testTdf99115();
@@ -121,6 +122,7 @@ public:
     CPPUNIT_TEST(test123926);
     CPPUNIT_TEST(test47446);
     CPPUNIT_TEST(test47446b);
+    CPPUNIT_TEST(testTdf103888);
     CPPUNIT_TEST(testMaskText);
     CPPUNIT_TEST(testTdf99994);
     CPPUNIT_TEST(testTdf99115);
@@ -479,7 +481,7 @@ void Test::testTdf85770()
     assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", 
"height", "11");
     assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", 
"familyname", "Times New Roman");
     assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", 
"fontcolor", "#000000");
-    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", 
"text", "Start ");
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", 
"text", "Start");
     assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", 
"height", "11");
     assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", 
"familyname", "Times New Roman");
     assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", 
"fontcolor", "#000000");
@@ -846,6 +848,22 @@ void Test::test47446b()
 
 }
 
+void Test::testTdf103888()
+{
+    Primitive2DSequence aSequenceMaskText = 
parseSvg(u"/svgio/qa/cppunit/data/tdf103888.svg");
+    CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceMaskText.getLength()));
+
+    drawinglayer::Primitive2dXmlDump dumper;
+    xmlDocUniquePtr pDocument = 
dumper.dumpAndParse(Primitive2DContainer(aSequenceMaskText));
+
+    CPPUNIT_ASSERT (pDocument);
+
+    // Without the fix in place, this test would have failed here with number 
of nodes is incorrect
+    assertXPath(pDocument, 
"/primitive2D/transform/transform/textsimpleportion[1]", "text", "Her");
+    assertXPath(pDocument, 
"/primitive2D/transform/transform/textsimpleportion[2]", "text", "vor");
+    assertXPath(pDocument, 
"/primitive2D/transform/transform/textsimpleportion[3]", "text", "hebung");
+}
+
 void Test::testMaskText()
 {
     //Check that mask is applied on text
diff --git a/svgio/qa/cppunit/data/tdf103888.svg 
b/svgio/qa/cppunit/data/tdf103888.svg
new file mode 100644
index 000000000000..1663fa395e40
--- /dev/null
+++ b/svgio/qa/cppunit/data/tdf103888.svg
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+
+<svg xmlns="http://www.w3.org/2000/svg"; version="1.1"
+   width="75mm"
+   height="15mm"
+   viewBox="0 0 250 50">
+  <text
+  style="font-size:30px;font-family:sans-serif;fill:#000000;stroke:none"
+    x="20"
+    y="30">Her<tspan style="font-weight:bold">vor</tspan>hebung</text>
+</svg>
diff --git a/svgio/source/svgreader/svgcharacternode.cxx 
b/svgio/source/svgreader/svgcharacternode.cxx
index 0a4731b200d5..31376ee179a8 100644
--- a/svgio/source/svgreader/svgcharacternode.cxx
+++ b/svgio/source/svgreader/svgcharacternode.cxx
@@ -549,11 +549,6 @@ namespace svgio::svgreader
             }
         }
 
-        void SvgCharacterNode::addGap()
-        {
-            maText += " ";
-        }
-
         void SvgCharacterNode::concatenate(std::u16string_view rText)
         {
             maText += rText;
diff --git a/svgio/source/svgreader/svgdocumenthandler.cxx 
b/svgio/source/svgreader/svgdocumenthandler.cxx
index 288b0205397d..dc2dd6fa7c6b 100644
--- a/svgio/source/svgreader/svgdocumenthandler.cxx
+++ b/svgio/source/svgreader/svgdocumenthandler.cxx
@@ -55,7 +55,7 @@ namespace svgio::svgreader
 
 namespace
 {
-    svgio::svgreader::SvgCharacterNode* 
whiteSpaceHandling(svgio::svgreader::SvgNode const * pNode, 
svgio::svgreader::SvgCharacterNode* pLast)
+    void whiteSpaceHandling(svgio::svgreader::SvgNode const * pNode)
     {
         if(pNode)
         {
@@ -75,41 +75,6 @@ namespace
                             // clean whitespace in text span
                             svgio::svgreader::SvgCharacterNode* pCharNode = 
static_cast< svgio::svgreader::SvgCharacterNode* >(pCandidate);
                             pCharNode->whiteSpaceHandling();
-
-                            // pCharNode may have lost all text. If that's the 
case, ignore
-                            // as invalid character node
-                            if(!pCharNode->getText().isEmpty())
-                            {
-                                if(pLast)
-                                {
-                                    bool bAddGap(true);
-                                    static bool bNoGapsForBaselineShift(true); 
// loplugin:constvars:ignore
-
-                                    if(bNoGapsForBaselineShift)
-                                    {
-                                        // With this option a baseline shift 
between two char parts ('words')
-                                        // will not add a space 'gap' to the 
end of the (non-last) word. This
-                                        // seems to be the standard behaviour, 
see last bugdoc attached #122524#
-                                        const 
svgio::svgreader::SvgStyleAttributes* pStyleLast = 
pLast->getSvgStyleAttributes();
-                                        const 
svgio::svgreader::SvgStyleAttributes* pStyleCurrent = 
pCandidate->getSvgStyleAttributes();
-
-                                        if(pStyleLast && pStyleCurrent && 
pStyleLast->getBaselineShift() != pStyleCurrent->getBaselineShift())
-                                        {
-                                            bAddGap = false;
-                                        }
-                                    }
-
-                                    // add in-between whitespace (single 
space) to last
-                                    // known character node
-                                    if(bAddGap)
-                                    {
-                                        pLast->addGap();
-                                    }
-                                }
-
-                                // remember new last corrected character node
-                                pLast = pCharNode;
-                            }
                             break;
                         }
                         case SVGToken::Tspan:
@@ -117,7 +82,7 @@ namespace
                         case SVGToken::Tref:
                         {
                             // recursively clean whitespaces in subhierarchy
-                            pLast = whiteSpaceHandling(pCandidate, pLast);
+                            whiteSpaceHandling(pCandidate);
                             break;
                         }
                         default:
@@ -129,9 +94,8 @@ namespace
                 }
             }
         }
-
-        return pLast;
     }
+
 } // end anonymous namespace
 
         SvgDocHdl::SvgDocHdl(const OUString& aAbsolutePath)
@@ -548,7 +512,7 @@ namespace
             if(pWhitespaceCheck)
             {
                 // cleanup read strings
-                whiteSpaceHandling(pWhitespaceCheck, nullptr);
+                whiteSpaceHandling(pWhitespaceCheck);
             }
         }
 

Reply via email to