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 3b19b19c85ca6ff540e475e846c82ce83bc7f503
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Mon Feb 5 14:54:04 2024 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Tue Feb 6 13:05:02 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>
    (cherry picked from commit 358061b4a480ea763ea541094cef2112f917eb93)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163013
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163041

diff --git a/svgio/inc/svgstyleattributes.hxx b/svgio/inc/svgstyleattributes.hxx
index acd310adbf6d..4e55ab3fc644 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 b485aa16e38c..a97f5084cb38 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -760,7 +760,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf156834)
 
     CPPUNIT_ASSERT (pDocument);
 
-    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion", 3);
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion", 4);
     assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", 
"text", "Auto");
     assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "x", 
"30");
     assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "y", 
"20");
@@ -772,6 +772,10 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf156834)
     assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", 
"text", "Hanging");
     assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "x", 
"30");
     assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "y", 
"94");
+
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[4]", 
"text", "Central");
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[4]", "x", 
"30");
+    //assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[4]", 
"y", "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 022ba42bda9f..c7dafe81fff5 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 2953f42b5efc..b0fd42303976 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -1976,6 +1976,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