[Libreoffice-commits] core.git: svgio/qa test/source

Xisco Fauli anistenis at gmail.com
Tue Feb 9 07:11:03 UTC 2016


 svgio/qa/cppunit/SvgImportTest.cxx         |   24 ++++++++++++++++++++++++
 svgio/qa/cppunit/data/FontsizeKeywords.svg |   14 ++++++++++++++
 test/source/primitive2dxmldump.cxx         |   16 ++++++++++++++++
 3 files changed, 54 insertions(+)

New commits:
commit 805b328858e2d1414e7a9e7701c42a41ede2a617
Author: Xisco Fauli <anistenis at gmail.com>
Date:   Sun Feb 7 19:25:20 2016 +0100

    SVGIO: Add import test for Fontsize keywords
    
    Change-Id: I042a1deeec1c07f73f09ddd2fb71b9d2eba6b8c6
    Reviewed-on: https://gerrit.libreoffice.org/22187
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
    Reviewed-by: jan iversen <jani at documentfoundation.org>

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx
index d065e0f..be071dd 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -40,6 +40,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools
 
     void testStyles();
     void testTdf87309();
+    void testFontsizeKeywords();
 
     Primitive2DSequence parseSvg(const char* aSource);
 
@@ -50,6 +51,7 @@ public:
     CPPUNIT_TEST_SUITE(Test);
     CPPUNIT_TEST(testStyles);
     CPPUNIT_TEST(testTdf87309);
+    CPPUNIT_TEST(testFontsizeKeywords);
     CPPUNIT_TEST_SUITE_END();
 };
 
@@ -150,6 +152,28 @@ void Test::testTdf87309()
     assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "color", "#000000");
 }
 
+void Test::testFontsizeKeywords()
+{
+    Primitive2DSequence aSequenceFontsizeKeywords = parseSvg("/svgio/qa/cppunit/data/FontsizeKeywords.svg");
+    CPPUNIT_ASSERT_EQUAL(1, (int)aSequenceFontsizeKeywords.getLength());
+
+    Primitive2dXmlDump dumper;
+    xmlDocPtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequenceFontsizeKeywords));
+
+    CPPUNIT_ASSERT (pDocument);
+
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "height", "9");
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "height", "11");
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "height", "13");
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[4]", "height", "16");
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[5]", "height", "19");
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[6]", "height", "23");
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[7]", "height", "27");
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[8]", "height", "13");
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[9]", "height", "19");
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[10]", "height", "16");
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 }
diff --git a/svgio/qa/cppunit/data/FontsizeKeywords.svg b/svgio/qa/cppunit/data/FontsizeKeywords.svg
new file mode 100644
index 0000000..c0a5cae
--- /dev/null
+++ b/svgio/qa/cppunit/data/FontsizeKeywords.svg
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg height="600" width="400" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+
+<text x="5" y="15" font-size="xx-small">Sample</text>
+<text x="5" y="50" font-size="x-small">Sample</text>
+<text x="5" y="100" font-size="small">Sample</text>
+<text x="5" y="150" font-size="medium">Sample</text>
+<text x="5" y="200" font-size="large">Sample</text>
+<text x="5" y="250" font-size="x-large">Sample</text>
+<text x="5" y="300" font-size="xx-large">Sample</text>
+<text x="5" y="350" font-size="smaller">Sample</text>
+<text x="5" y="400" font-size="larger">Sample</text>
+<text x="5" y="450" font-size="initial">Sample</text>
+</svg>
diff --git a/test/source/primitive2dxmldump.cxx b/test/source/primitive2dxmldump.cxx
index 4a99677..940dea0 100644
--- a/test/source/primitive2dxmldump.cxx
+++ b/test/source/primitive2dxmldump.cxx
@@ -21,6 +21,7 @@
 #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
 #include <drawinglayer/primitive2d/hiddengeometryprimitive2d.hxx>
 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
+#include <drawinglayer/primitive2d/textprimitive2d.hxx>
 
 #include <drawinglayer/attribute/lineattribute.hxx>
 
@@ -166,6 +167,21 @@ void Primitive2dXmlDump::decomposeAndWrite(
             }
             break;
 
+            case PRIMITIVE2D_ID_TEXTSIMPLEPORTIONPRIMITIVE2D:
+            {
+                const TextSimplePortionPrimitive2D* pTextSimplePortionPrimitive2D = dynamic_cast<const TextSimplePortionPrimitive2D*>(pBasePrimitive);
+                rWriter.startElement("textsimpleportion");
+
+                basegfx::B2DVector aScale, aTranslate;
+                double fRotate, fShearX;
+                if(pTextSimplePortionPrimitive2D->getTextTransform().decompose(aScale, aTranslate, fRotate, fShearX))
+                {
+                    rWriter.attribute("height", aScale.getY());
+                }
+                rWriter.endElement();
+            }
+            break;
+
             default:
             {
                 rWriter.element(OUStringToOString(sCurrentElementTag, RTL_TEXTENCODING_UTF8));


More information about the Libreoffice-commits mailing list