summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2022-11-02 22:48:35 +0100
committerTomaž Vajngerl <quikee@gmail.com>2023-04-07 12:35:19 +0200
commitbaf9a9b40d6fbe62fbe1c024c5d808631432da84 (patch)
tree832632c254292a5fe928a9edc2d523718fa556f8 /sd
parentd0add4a3a16b40b45029a88845c0beccc58d6330 (diff)
add a test for "fit to frame" text rendering
Change-Id: If304f12e1f1fbe3afea4885975302b77b428567f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142187 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149933 Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sd')
-rw-r--r--sd/qa/unit/data/odg/FitToFrameText.odgbin0 -> 11847 bytes
-rw-r--r--sd/qa/unit/layout-tests.cxx28
2 files changed, 28 insertions, 0 deletions
diff --git a/sd/qa/unit/data/odg/FitToFrameText.odg b/sd/qa/unit/data/odg/FitToFrameText.odg
new file mode 100644
index 000000000000..e65b0a3a2102
--- /dev/null
+++ b/sd/qa/unit/data/odg/FitToFrameText.odg
Binary files differ
diff --git a/sd/qa/unit/layout-tests.cxx b/sd/qa/unit/layout-tests.cxx
index f34e2fb136f2..a6ac4e0c1612 100644
--- a/sd/qa/unit/layout-tests.cxx
+++ b/sd/qa/unit/layout-tests.cxx
@@ -291,6 +291,34 @@ CPPUNIT_TEST_FIXTURE(SdLayoutTest, testBnc480256)
xDocShRef->DoClose();
}
+CPPUNIT_TEST_FIXTURE(SdLayoutTest, testFitToFrameTextFitting)
+{
+ // This test checks that the text fitting is working correctly when
+ // the textbox is set to "fit to frame" by stretching the text to or
+ // near the textbox boundary. The problem is especially complicated
+ // when the font size is set to a higher number (like 999)
+ //
+ // The text fitting behaviour when "fit by frame" is enabled is to
+ // always fit the text into the text box (without forcing the text
+ // into new line) by shrinking or expanding the text horizontally
+ // and vertically.
+
+ sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odg/FitToFrameText.odg"), PPTX);
+
+ std::shared_ptr<GDIMetaFile> xMetaFile = xDocShRef->GetPreviewMetaFile();
+ MetafileXmlDump dumper;
+
+ xmlDocUniquePtr pXmlDoc = XmlTestTools::dumpAndParse(dumper, *xMetaFile);
+ CPPUNIT_ASSERT(pXmlDoc);
+
+ assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray[1]", "x", "0");
+ assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray[1]", "y", "406");
+ assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray[1]/dxarray", "first", "114");
+#ifndef _WIN32 // Windows seems to differ in text layouting, so ignore for now
+ assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray[1]/dxarray", "last", "7010");
+#endif
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */