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 <xiscofauli@libreoffice.org>
diff --git a/svgio/inc/svgstyleattributes.hxx b/svgio/inc/svgstyleattributes.hxx
index 6078194..4516773 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 13dff82..51c66e5 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 74dc154..0ef81f9 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 7d5a2fc..02bc391 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 869b071..731df59 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