sw/qa/extras/layout/data/tdf130088.docx |binary
 sw/qa/extras/layout/layout3.cxx         |   21 +++++++++++++++++++++
 2 files changed, 21 insertions(+)

New commits:
commit c1803de8a093739d189be54b2d9bd5634e9e79ee
Author:     László Németh <nem...@numbertext.org>
AuthorDate: Thu Nov 16 23:48:03 2023 +0100
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Fri Nov 17 09:33:06 2023 +0100

    tdf#119908 sw smart justify: add unit test
    
    Follow-up to commit 17eaebee279772b6062ae3448012133897fc71bb
    "tdf#119908 sw smart justify: fix justification by shrinking".
    
    Change-Id: I88cc7876c06729f81b9d61fed7456be801dc6373
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159525
    Tested-by: László Németh <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>

diff --git a/sw/qa/extras/layout/data/tdf130088.docx 
b/sw/qa/extras/layout/data/tdf130088.docx
new file mode 100644
index 000000000000..8d5a7a604b5e
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf130088.docx differ
diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx
index b390e6e38b9c..11a9c0191d24 100644
--- a/sw/qa/extras/layout/layout3.cxx
+++ b/sw/qa/extras/layout/layout3.cxx
@@ -172,6 +172,27 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf128966)
     xmlXPathFreeObject(pXmlObj);
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf119908)
+{
+    createSwDoc("tdf130088.docx");
+    // Ensure that all text portions are calculated before testing.
+    SwXTextDocument* pTextDoc = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
+    CPPUNIT_ASSERT(pTextDoc);
+    SwViewShell* pViewShell
+        = 
pTextDoc->GetDocShell()->GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell();
+    CPPUNIT_ASSERT(pViewShell);
+    pViewShell->Reformat();
+
+    xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+    // Keep real width of the exceeding line portions to calculate shrinking
+    sal_Int32 nPortionWidth
+        = getXPath(pXmlDoc, 
"/root/page/body/txt[1]/SwParaPortion/SwLineLayout[2]/SwLinePortion[2]",
+                   "width")
+              .toInt32();
+    // This was 5806 (not real portion width, but stripped to the line width)
+    CPPUNIT_ASSERT_GREATER(sal_Int32(5840), nPortionWidth);
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf106234)
 {
     createSwDoc("tdf106234.fodt");

Reply via email to