summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/qa/extras/layout/data/tdf163149.docxbin0 -> 14982 bytes
-rw-r--r--sw/qa/extras/layout/layout3.cxx46
-rw-r--r--sw/source/core/text/itradj.cxx5
3 files changed, 50 insertions, 1 deletions
diff --git a/sw/qa/extras/layout/data/tdf163149.docx b/sw/qa/extras/layout/data/tdf163149.docx
new file mode 100644
index 000000000000..efe0c65451a7
--- /dev/null
+++ b/sw/qa/extras/layout/data/tdf163149.docx
Binary files differ
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();
diff --git a/sw/source/core/text/itradj.cxx b/sw/source/core/text/itradj.cxx
index be004457b407..286b4f3a1718 100644
--- a/sw/source/core/text/itradj.cxx
+++ b/sw/source/core/text/itradj.cxx
@@ -482,7 +482,10 @@ void SwTextAdjuster::CalcNewBlock( SwLineLayout *pCurrent,
tools::Long nSpaceSub = ( nBreakWidth > pCurrent->Width() )
? (nBreakWidth - pCurrent->Width()) * SPACING_PRECISION_FACTOR /
sal_Int32(nGluePortion) + LONG_MAX/2
- : 0;
+ : ( nSpaceAdd < 0 )
+ // shrink, if portions exceed the line width available before an image
+ ? -nSpaceAdd + LONG_MAX/2
+ : 0;
// i60594
if( rSI.CountKashida() && !bSkipKashida )