summaryrefslogtreecommitdiff
path: root/emfio/qa
diff options
context:
space:
mode:
authorBartosz Kosiorek <gang65@poczta.onet.pl>2021-06-24 18:58:39 +0200
committerBartosz Kosiorek <gang65@poczta.onet.pl>2021-07-01 23:50:31 +0200
commit574dc1e8ff6ea4214fefd91216fca5146a4ff13e (patch)
treefb64a4c43f46109af7b11c616e76af563f5606fe /emfio/qa
parenta1e03b970f49efbfacb7888d31ecd944750a5956 (diff)
EMF+ tdf#142995 tdf#142997 tdf#143076 Add alignment support for DrawString
With this commit, real size of the text is used to make proper horizontal alignment. Additionally vertical alignment is added and fix for Center alignment was applied Change-Id: I17d9fd7de7f00f5e69f99c5b09061eb6059be67e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117794 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
Diffstat (limited to 'emfio/qa')
-rw-r--r--emfio/qa/cppunit/emf/EmfImportTest.cxx92
-rw-r--r--emfio/qa/cppunit/emf/data/TestDrawStringAlign.emfbin0 -> 1720 bytes
2 files changed, 92 insertions, 0 deletions
diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx
index 34288bcf61eb..63e1d575803b 100644
--- a/emfio/qa/cppunit/emf/EmfImportTest.cxx
+++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx
@@ -47,6 +47,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools, public unotest:
void testPolyPolygon();
void TestDrawString();
+ void TestDrawStringAlign();
void TestDrawStringTransparent();
void TestDrawStringWithBrush();
void TestDrawLine();
@@ -87,6 +88,7 @@ public:
CPPUNIT_TEST_SUITE(Test);
CPPUNIT_TEST(testPolyPolygon);
CPPUNIT_TEST(TestDrawString);
+ CPPUNIT_TEST(TestDrawStringAlign);
CPPUNIT_TEST(TestDrawStringTransparent);
CPPUNIT_TEST(TestDrawStringWithBrush);
CPPUNIT_TEST(TestDrawLine);
@@ -210,6 +212,96 @@ void Test::TestDrawString()
#endif
}
+void Test::TestDrawStringAlign()
+{
+#if HAVE_MORE_FONTS
+ // EMF+ DrawString with alignment (StringAlignmentNear, StringAlignmentFar, StringAlignmentCenter)
+ // It seems Arial font is replaced with Liberation Sans. These numbers are valid for Liberation Sans.
+ Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestDrawStringAlign.emf");
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence.getLength()));
+ drawinglayer::Primitive2dXmlDump dumper;
+ xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequence));
+ CPPUNIT_ASSERT(pDocument);
+
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/transform", 9);
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/transform[1]/textsimpleportion",
+ "width", "12");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/transform[1]/textsimpleportion",
+ "height", "12");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/transform[1]/textsimpleportion",
+ "x", "12");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/transform[1]/textsimpleportion",
+ "y", "22");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/transform[1]/textsimpleportion",
+ "text", "HLVT");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/transform[1]/textsimpleportion",
+ "fontcolor", "#000000");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/transform[1]/textsimpleportion",
+ "familyname", "ARIAL");
+
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/transform[2]/textsimpleportion",
+ "width", "12");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/transform[2]/textsimpleportion",
+ "height", "12");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/transform[2]/textsimpleportion",
+ "x", "143");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/transform[2]/textsimpleportion",
+ "y", "22");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/transform[2]/textsimpleportion",
+ "text", "HCVT");
+
+ // TODO Make the position of the text the same across the platforms (Arial vs Liberation Sans).
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/transform[3]/textsimpleportion",
+ "x", "276");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/transform[3]/textsimpleportion",
+ "y", "22");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/transform[3]/textsimpleportion",
+ "text", "HRVT");
+
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/transform[4]/textsimpleportion",
+ "x", "12");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/transform[4]/textsimpleportion",
+ "y", "66");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/transform[4]/textsimpleportion",
+ "text", "HLVC");
+
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/transform[5]/textsimpleportion",
+ "x", "142");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/transform[5]/textsimpleportion",
+ "y", "66");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/transform[5]/textsimpleportion",
+ "text", "HCVC");
+
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/transform[6]/textsimpleportion",
+ "x", "274");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/transform[6]/textsimpleportion",
+ "y", "66");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/transform[6]/textsimpleportion",
+ "text", "HRVC");
+
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/transform[7]/textsimpleportion",
+ "x", "12");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/transform[7]/textsimpleportion",
+ "y", "110");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/transform[7]/textsimpleportion",
+ "text", "HLVB");
+
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/transform[8]/textsimpleportion",
+ "x", "143");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/transform[8]/textsimpleportion",
+ "y", "110");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/transform[8]/textsimpleportion",
+ "text", "HCVB");
+
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/transform[9]/textsimpleportion",
+ "x", "275");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/transform[9]/textsimpleportion",
+ "y", "110");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/transform[9]/textsimpleportion",
+ "text", "HRVB");
+#endif
+}
+
void Test::TestDrawStringTransparent()
{
#if HAVE_MORE_FONTS
diff --git a/emfio/qa/cppunit/emf/data/TestDrawStringAlign.emf b/emfio/qa/cppunit/emf/data/TestDrawStringAlign.emf
new file mode 100644
index 000000000000..bc3a33c61fc2
--- /dev/null
+++ b/emfio/qa/cppunit/emf/data/TestDrawStringAlign.emf
Binary files differ