[Libreoffice-commits] core.git: svgio/qa svgio/source
Xisco Fauli
anistenis at gmail.com
Fri Feb 19 06:28:39 UTC 2016
svgio/qa/cppunit/SvgImportTest.cxx | 17 +++++++++++++++++
svgio/qa/cppunit/data/FontsizeRelative.svg | 5 +++++
svgio/source/svgreader/svgstyleattributes.cxx | 14 ++++++++++++++
3 files changed, 36 insertions(+)
New commits:
commit 324014c997ab90f5777f772a46e6faf887a00832
Author: Xisco Fauli <anistenis at gmail.com>
Date: Thu Feb 18 01:27:17 2016 +0100
SVGIO: Fix problem when relative font-size depends on its...
... parent's font-size
Change-Id: I13943923c401a5a06b3aa51181fd75292534e888
Reviewed-on: https://gerrit.libreoffice.org/22452
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin at gmail.com>
diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx
index 7870188..e5d2b03 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -42,6 +42,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools
void testTdf87309();
void testFontsizeKeywords();
void testFontsizePercentage();
+ void testFontsizeRelative();
void testTdf45771();
void testTdf97941();
void testTdf85770();
@@ -63,6 +64,7 @@ public:
CPPUNIT_TEST(testTdf87309);
CPPUNIT_TEST(testFontsizeKeywords);
CPPUNIT_TEST(testFontsizePercentage);
+ CPPUNIT_TEST(testFontsizeRelative);
CPPUNIT_TEST(testTdf45771);
CPPUNIT_TEST(testTdf97941);
CPPUNIT_TEST(testTdf85770);
@@ -197,6 +199,7 @@ void Test::testFontsizeKeywords()
void Test::testFontsizePercentage()
{
+ //Check when font-size uses percentage and defined globally
Primitive2DSequence aSequenceFontsizePercentage = parseSvg("/svgio/qa/cppunit/data/FontsizePercentage.svg");
CPPUNIT_ASSERT_EQUAL(1, (int)aSequenceFontsizePercentage.getLength());
@@ -208,6 +211,20 @@ void Test::testFontsizePercentage()
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "height", "16");
}
+void Test::testFontsizeRelative()
+{
+ //Check when font-size uses relative units (em,ex) and it's based on its parent's font-size
+ Primitive2DSequence aSequenceFontsizeRelative = parseSvg("/svgio/qa/cppunit/data/FontsizeRelative.svg");
+ CPPUNIT_ASSERT_EQUAL(1, (int)aSequenceFontsizeRelative.getLength());
+
+ Primitive2dXmlDump dumper;
+ xmlDocPtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequenceFontsizeRelative));
+
+ CPPUNIT_ASSERT (pDocument);
+
+ assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "height", "50");
+}
+
void Test::testTdf45771()
{
//Check text fontsize when using relative units
diff --git a/svgio/qa/cppunit/data/FontsizeRelative.svg b/svgio/qa/cppunit/data/FontsizeRelative.svg
new file mode 100644
index 0000000..339e663
--- /dev/null
+++ b/svgio/qa/cppunit/data/FontsizeRelative.svg
@@ -0,0 +1,5 @@
+<?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">
+<g font-size="5px">
+ <text x="150" y="150" font-size="10em">Sample</text>
+</g>
+</svg>
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx b/svgio/source/svgreader/svgstyleattributes.cxx
index a6ad68d..fb750fe 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -2402,6 +2402,20 @@ namespace svgio
return SvgNumber(
maFontSizeNumber.getNumber() * aDefaultSize / 100.0, Unit_px, true);
}
+ else if((Unit_em == maFontSizeNumber.getUnit()) || (Unit_ex == maFontSizeNumber.getUnit()))
+ {
+ const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
+
+ if(pSvgStyleAttributes)
+ {
+ const SvgNumber aParentNumber = pSvgStyleAttributes->getFontSizeNumber();
+
+ return SvgNumber(
+ aParentNumber.getNumber() * maFontSizeNumber.getNumber(),
+ aParentNumber.getUnit(),
+ true);
+ }
+ }
return maFontSizeNumber;
}
More information about the Libreoffice-commits
mailing list