svgio/inc/svgstyleattributes.hxx              |    3 ++-
 svgio/qa/cppunit/SvgImportTest.cxx            |    6 +++++-
 svgio/qa/cppunit/data/tdf156834.svg           |    3 ++-
 svgio/source/svgreader/svgcharacternode.cxx   |    1 +
 svgio/source/svgreader/svgstyleattributes.cxx |    4 ++++
 5 files changed, 14 insertions(+), 3 deletions(-)

New commits:
commit f0d6b3e727448abb4428587bdf9b9c839b28e6f4
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Mon Feb 5 14:54:04 2024 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon Feb 5 16:44:05 2024 +0100

    tdf#159566: match 'central' dominant-baseline to 'middle'
    
    Inkscape also does it the same way
    
    Change-Id: I3e1cea091e7314886bbc9135c55698892239bec7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163006
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/svgio/inc/svgstyleattributes.hxx b/svgio/inc/svgstyleattributes.hxx
index 60781942667b..4516773e83a6 100644
--- a/svgio/inc/svgstyleattributes.hxx
+++ b/svgio/inc/svgstyleattributes.hxx
@@ -166,7 +166,8 @@ namespace svgio::svgreader
         {
             Auto,
             Middle,
-            Hanging
+            Hanging,
+            Central
         };
 
         enum class Visibility
diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index 13dff82187f3..51c66e52452a 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -780,7 +780,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf156834)
 
     CPPUNIT_ASSERT (pDocument);
 
-    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion"_ostr, 3);
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion"_ostr, 4);
     assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]"_ostr, 
"text"_ostr, "Auto");
     assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]"_ostr, 
"x"_ostr, "30");
     assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]"_ostr, 
"y"_ostr, "20");
@@ -792,6 +792,10 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf156834)
     assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]"_ostr, 
"text"_ostr, "Hanging");
     assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]"_ostr, 
"x"_ostr, "30");
     assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]"_ostr, 
"y"_ostr, "94");
+
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[4]"_ostr, 
"text"_ostr, "Central");
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[4]"_ostr, 
"x"_ostr, "30");
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[4]"_ostr, 
"y"_ostr, "116");
 }
 
 CPPUNIT_TEST_FIXTURE(Test, testTdf104339)
diff --git a/svgio/qa/cppunit/data/tdf156834.svg 
b/svgio/qa/cppunit/data/tdf156834.svg
index 74dc1548186e..0ef81f9a6acf 100644
--- a/svgio/qa/cppunit/data/tdf156834.svg
+++ b/svgio/qa/cppunit/data/tdf156834.svg
@@ -1,7 +1,8 @@
 <svg viewBox="0 0 200 120" xmlns="http://www.w3.org/2000/svg";>
-  <path d="M20,20 L180,20 M20,50 L180,50 M20,80 L180,80" stroke="grey" />
+  <path d="M20,20 L180,20 M20,50 L180,50 M20,80 L180,80 M20,110 L180,110" 
stroke="grey" />
 
   <text dominant-baseline="auto" x="30" y="20" font-size="20">Auto</text>
   <text dominant-baseline="middle" x="30" y="50" font-size="20">Middle</text>
   <text dominant-baseline="Hanging" x="30" y="80" font-size="20">Hanging</text>
+  <text dominant-baseline="central" x="30" y="110" 
font-size="20">Central</text>
 </svg>
diff --git a/svgio/source/svgreader/svgcharacternode.cxx 
b/svgio/source/svgreader/svgcharacternode.cxx
index 7d5a2fcb9feb..02bc3911a3b8 100644
--- a/svgio/source/svgreader/svgcharacternode.cxx
+++ b/svgio/source/svgreader/svgcharacternode.cxx
@@ -287,6 +287,7 @@ namespace svgio::svgreader
                 switch(aDominantBaseline)
                 {
                     case DominantBaseline::Middle:
+                    case DominantBaseline::Central:
                     {
                         aPosition.setY(aPosition.getY() - aRange.getCenterY());
                         break;
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx 
b/svgio/source/svgreader/svgstyleattributes.cxx
index 869b071dade7..731df59aeebf 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -1969,6 +1969,10 @@ namespace svgio::svgreader
                         {
                             setDominantBaseline(DominantBaseline::Hanging);
                         }
+                        else 
if(o3tl::equalsIgnoreAsciiCase(o3tl::trim(aContent), u"central"))
+                        {
+                            setDominantBaseline(DominantBaseline::Central);
+                        }
                         else
                         {
                             // no DominantBaseline

Reply via email to