summaryrefslogtreecommitdiff
path: root/svgio/qa
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2024-03-27 11:38:44 +0100
committerAndras Timar <andras.timar@collabora.com>2024-04-15 12:36:23 +0200
commitee36f0456c6308d10085d79b0d211b70f97388b7 (patch)
tree59b803df003f43626ff3cfd277774091d9337fc8 /svgio/qa
parenta6b07a445a1f84b9510b5b694cc12229e87b596a (diff)
tdf#160386: Add support for switch element
For now, only use language tag, meaning if there is a file like in the unittest with <text systemLanguage="en-us">Howdy!</text> <text systemLanguage="en-gb">Wotcha!</text> <text systemLanguage="en-au">G'day!</text> <text systemLanguage="en">Hello!</text> "Hello!" with be displayed in a en_AU system locale This patch partially reverts 13a41e7a12598c7896d6dc8d34aba6af5b80b83c "tdf#150124: do nothing when parent is of unkown type" making 0dfd8288a87b58e503bb3a41be6137485fbf3f68 "ofz#60384 Direct-leak" no longer necessary Change-Id: Ifc73bc69aa997088dc0a2b11d7d30446303fa3b3 Change-Id: I885ef0f2c44b86196881fe55a963db2e5c7eb1be Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165394 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165438
Diffstat (limited to 'svgio/qa')
-rw-r--r--svgio/qa/cppunit/SvgImportTest.cxx23
-rw-r--r--svgio/qa/cppunit/data/tdf160386.svg16
2 files changed, 39 insertions, 0 deletions
diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx
index 75d42adf4397..2ec9df26418f 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -39,6 +39,7 @@ protected:
void checkRectPrimitive(Primitive2DSequence const & rPrimitive);
Primitive2DSequence parseSvg(std::u16string_view aSource);
+ xmlDocUniquePtr dumpAndParseSvg(std::u16string_view aSource);
};
Primitive2DSequence Test::parseSvg(std::u16string_view aSource)
@@ -60,6 +61,17 @@ Primitive2DSequence Test::parseSvg(std::u16string_view aSource)
return xSvgParser->getDecomposition(aInputStream, aPath);
}
+xmlDocUniquePtr Test::dumpAndParseSvg(std::u16string_view aSource)
+{
+ Primitive2DSequence aSequence = parseSvg(aSource);
+
+ drawinglayer::Primitive2dXmlDump dumper;
+ xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequence);
+
+ CPPUNIT_ASSERT (pDocument);
+ return pDocument;
+}
+
void Test::checkRectPrimitive(Primitive2DSequence const & rPrimitive)
{
drawinglayer::Primitive2dXmlDump dumper;
@@ -401,6 +413,17 @@ CPPUNIT_TEST_FIXTURE(Test, testFontsizeRelative)
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]"_ostr, "familyname"_ostr, "DejaVu Serif");
}
+CPPUNIT_TEST_FIXTURE(Test, testTdf160386)
+{
+ xmlDocUniquePtr pDocument = dumpAndParseSvg(u"/svgio/qa/cppunit/data/tdf160386.svg");
+
+ // Without the fix in place, this test would have failed with
+ // - Expected: 1
+ // - Actual : 11
+ assertXPath(pDocument, "/primitive2D/transform/textsimpleportion"_ostr, 1);
+ assertXPath(pDocument, "/primitive2D/transform/textsimpleportion"_ostr, "text"_ostr, "Hello!");
+}
+
CPPUNIT_TEST_FIXTURE(Test, testTdf145896)
{
Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/tdf145896.svg");
diff --git a/svgio/qa/cppunit/data/tdf160386.svg b/svgio/qa/cppunit/data/tdf160386.svg
new file mode 100644
index 000000000000..1644b0d15514
--- /dev/null
+++ b/svgio/qa/cppunit/data/tdf160386.svg
@@ -0,0 +1,16 @@
+<svg viewBox="0 -20 100 50" xmlns="http://www.w3.org/2000/svg">
+ <switch font-family="DejaVu Sans">
+ <text systemLanguage="ar">مرحبا</text>
+ <text systemLanguage="de,nl">Hallo!</text>
+ <text systemLanguage="en-us">Howdy!</text>
+ <text systemLanguage="en-gb">Wotcha!</text>
+ <text systemLanguage="en-au">G'day!</text>
+ <text systemLanguage="en">Hello!</text>
+ <text systemLanguage="es">Hola!</text>
+ <text systemLanguage="fr">Bonjour!</text>
+ <text systemLanguage="ja">こんにちは</text>
+ <text systemLanguage="ru">Привет!</text>
+ <text>☺</text>
+ </switch>
+</svg>
+