diff options
author | László Németh <nemeth@numbertext.org> | 2024-10-15 22:50:15 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2024-10-16 11:29:32 +0200 |
commit | 1fb6de02709a5f420f21ebd683915da50ce0d198 (patch) | |
tree | 74421285e8cf8dd29a0e80eb13a564e7a8dfed0f /sw/qa | |
parent | c8549fa3204802daec8597ba0f9f4f7ef23d5cd2 (diff) |
tdf#163149 sw smart justify: fix line shrinking at image wrapping
Limited line width at image wrap could result negative nSpaceAdd
value, i.e. paragraph line with extra letter spacing instead of
line shrinking.
Regression from commit 17eaebee279772b6062ae3448012133897fc71bb
"tdf#119908 sw smart justify: fix justification by shrinking".
Change-Id: I76cc3004d246ff7af441ca9a92eaa8fc7b09f01b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174985
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/extras/layout/data/tdf163149.docx | bin | 0 -> 14982 bytes | |||
-rw-r--r-- | sw/qa/extras/layout/layout3.cxx | 46 |
2 files changed, 46 insertions, 0 deletions
diff --git a/sw/qa/extras/layout/data/tdf163149.docx b/sw/qa/extras/layout/data/tdf163149.docx Binary files differnew file mode 100644 index 000000000000..efe0c65451a7 --- /dev/null +++ b/sw/qa/extras/layout/data/tdf163149.docx diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx index 7f62a3a9d6b8..2699f4d31d48 100644 --- a/sw/qa/extras/layout/layout3.cxx +++ b/sw/qa/extras/layout/layout3.cxx @@ -485,6 +485,52 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf161810) } } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf163149) +{ + createSwDoc("tdf163149.docx"); + // Ensure that all text portions are calculated before testing. + SwDoc* pDoc = getSwDoc(); + SwDocShell* pShell = pDoc->GetDocShell(); + + // Dump the rendering of the first page as an XML file. + std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); + MetafileXmlDump dumper; + + xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); + CPPUNIT_ASSERT(pXmlDoc); + + // Find the text array action for the second non-empty (shrunk) line + bool bFirst = true; + for (size_t nAction = 0; nAction < xMetaFile->GetActionSize(); nAction++) + { + auto pAction = xMetaFile->GetAction(nAction); + if (pAction->GetType() == MetaActionType::TEXTARRAY) + { + auto pTextArrayAction = static_cast<MetaTextArrayAction*>(pAction); + auto pDXArray = pTextArrayAction->GetDXArray(); + + // skip empty paragraphs + if (pDXArray.size() <= 1) + continue; + + // skip first non-empty line + if (bFirst) + { + bFirst = false; + continue; + } + + // There should be 46 chars on the second line + CPPUNIT_ASSERT_EQUAL(size_t(46), pDXArray.size()); + + // Assert we are using the expected position for the last char + // This was 4673, now 4163, according to the fixed space shrinking + CPPUNIT_ASSERT_LESS(sal_Int32(4200), pDXArray[45]); + break; + } + } +} + CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf132599_always) { uno::Reference<linguistic2::XHyphenator> xHyphenator = LinguMgr::GetHyphenator(); |