diff --git a/sw/qa/extras/layout/data/tdf163720.fodt b/sw/qa/extras/layout/data/tdf163720.fodt new file mode 100644 index 000000000000..7f0fccef95ef --- /dev/null +++ b/sw/qa/extras/layout/data/tdf163720.fodt @@ -0,0 +1,209 @@ + + + + 2024-06-25T00:07:44en-US2024-08-23T15:57:05.0758847893PT2M32SLibreOfficeDev/25.2.0.0.alpha0$Linux_X86_64 LibreOffice_project/715b5c430e14609b15d18a5a607f13b9476b3c2d15.0000 + + + 0 + 0 + 22631 + 13418 + true + false + + + false + true + true + + false + 0 + false + true + true + true + true + false + 0 + true + false + true + true + false + true + true + true + true + true + false + true + true + false + true + false + false + true + true + true + true + true + false + false + false + true + true + high-resolution + true + 451526 + false + true + false + + + true + + true + false + true + true + true + false + false + 0 + true + false + false + true + true + true + true + true + false + false + true + false + true + true + true + false + true + HP-LaserJet-P1005 + true + false + false + 0 + false + true + 4gH+/0hQLUxhc2VySmV0LVAxMDA1AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQ1VQUzpIUC1MYXNlckpldC1QMTAwNQAAAAAAAAAAAAAWAAMAvQAAAAAAAQAEAAhSAAAEdAAASm9iRGF0YSAxCnByaW50ZXI9SFAtTGFzZXJKZXQtUDEwMDUKb3JpZW50YXRpb249UG9ydHJhaXQKY29waWVzPTEKY29sbGF0ZT1mYWxzZQptYXJnaW5hZGp1c3RtZW50PTAsMCwnMCwwCmNvbG9yZGVwdGg9MjQKY29sb3JkZXZpY2U9MApQUERDb250ZXh0RGF0YQpEdXBsZXg6Tm9uZQBJbnB1dFNsb3Q6QXV0bwBQYWdlU2l6ZTpBNAAAEgBDT01QQVRfRFVQTEVYX01PREUPAER1cGxleE1vZGU6Ok9mZgwAUFJJTlRFUl9OQU1FEQBIUC1MYXNlckpldC1QMTAwNQsARFJJVkVSX05BTUUWAENVUFM6SFAtTGFzZXJKZXQtUDEwMDU= + false + false + true + true + true + false + true + 1 + false + false + false + true + false + false + true + false + false + true + false + true + false + + false + 576075 + true + false + false + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + …… Horatio was was referenced throughout the Complaint and in each of the causes of action in the Complaints. + + + diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx index ebec9da48e4f..49c04eecbaab 100644 --- a/sw/qa/extras/layout/layout3.cxx +++ b/sw/qa/extras/layout/layout3.cxx @@ -405,6 +405,44 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf162220) assertXPath(pXmlDoc, "/root/page/body/txt[1]/SwParaPortion/SwLineLayout[1]/SwGluePortion"); } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf163720) +{ + uno::Reference xHyphenator = LinguMgr::GetHyphenator(); + if (!xHyphenator->hasLocale(lang::Locale(u"en"_ustr, u"US"_ustr, OUString()))) + return; + + createSwDoc("tdf163720.fodt"); + // Ensure that all text portions are calculated before testing. + SwDocShell* pShell = getSwDocShell(); + + // Dump the rendering of the first page as an XML file. + std::shared_ptr xMetaFile = pShell->GetPreviewMetaFile(); + MetafileXmlDump dumper; + + xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); + CPPUNIT_ASSERT(pXmlDoc); + + // Find the first text array action + for (size_t nAction = 0; nAction < xMetaFile->GetActionSize(); nAction++) + { + auto pAction = xMetaFile->GetAction(nAction); + if (pAction->GetType() == MetaActionType::TEXTARRAY) + { + auto pTextArrayAction = static_cast(pAction); + auto pDXArray = pTextArrayAction->GetDXArray(); + + // There should be 101 chars on the first line + CPPUNIT_ASSERT_EQUAL(size_t(101), pDXArray.size()); + + // Assert we are using the expected position for the last char + // This was 10093, now 10003, according to the less shrinking, + // than needed for the extra hyphen glyph at hyphenation + CPPUNIT_ASSERT_LESS(sal_Int32(10010), sal_Int32(pDXArray[100])); + break; + } + } +} + CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf162725) { createSwDoc("tdf162725.fodt"); diff --git a/sw/source/core/text/itradj.cxx b/sw/source/core/text/itradj.cxx index 286b4f3a1718..893f08392ef9 100644 --- a/sw/source/core/text/itradj.cxx +++ b/sw/source/core/text/itradj.cxx @@ -476,7 +476,10 @@ void SwTextAdjuster::CalcNewBlock( SwLineLayout *pCurrent, { tools::Long nSpaceAdd = nGluePortionWidth / sal_Int32(nGluePortion); // shrink, if not shrunk line width exceed the set line width - if ( pCurrent->ExtraShrunkWidth() > 0 ) + // i.e. if pCurrent->ExtraShrunkWidth() > 0 + // tdf#163720 but at hyphenated lines, still nBreakWidth contains the correct + // not shrunk line width (ExtraShrunkWidth + hyphen length), so use that + if ( pCurrent->ExtraShrunkWidth() > nBreakWidth ) nBreakWidth = pCurrent->ExtraShrunkWidth(); // shrink, if portions exceed the line width tools::Long nSpaceSub = ( nBreakWidth > pCurrent->Width() )