diff --git a/sw/qa/extras/layout/data/tdf120287b.fodt b/sw/qa/extras/layout/data/tdf120287b.fodt
new file mode 100644
index 000000000000..137bb6c9d7ed
--- /dev/null
+++ b/sw/qa/extras/layout/data/tdf120287b.fodt
@@ -0,0 +1,45 @@
+
+
+
+
+ true
+ high-resolution
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ b)Lorem ipsum dolor sit amet, consetetur sadips1 2 3 4 5 6 78a b c d e sed diam
+
+
+
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 0233252ae88e..fbef817cd8fd 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -58,6 +58,7 @@ public:
void testTdf117187();
void testTdf119875();
void testTdf120287();
+ void testTdf120287b();
CPPUNIT_TEST_SUITE(SwLayoutWriter);
CPPUNIT_TEST(testRedlineFootnotes);
@@ -88,6 +89,7 @@ public:
CPPUNIT_TEST(testTdf117187);
CPPUNIT_TEST(testTdf119875);
CPPUNIT_TEST(testTdf120287);
+ CPPUNIT_TEST(testTdf120287b);
CPPUNIT_TEST_SUITE_END();
private:
@@ -2559,6 +2561,16 @@ void SwLayoutWriter::testTdf120287()
assertXPath(pXmlDoc, "/root/page/body/txt[1]/LineBreak", 1);
}
+void SwLayoutWriter::testTdf120287b()
+{
+ createDoc("tdf120287b.fodt");
+ xmlDocPtr pXmlDoc = parseLayoutDump();
+ // This was 1418, TabOverMargin did the right split of the paragraph to two
+ // lines, but then calculated a too large tab portion size on the first
+ // line.
+ assertXPath(pXmlDoc, "/root/page/body/txt[1]/Text[@nType='POR_TABRIGHT']", "nWidth", "17");
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwLayoutWriter);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/text/portxt.cxx b/sw/source/core/text/portxt.cxx
index 9fb3df006267..73bf691adfa1 100644
--- a/sw/source/core/text/portxt.cxx
+++ b/sw/source/core/text/portxt.cxx
@@ -397,7 +397,8 @@ bool SwTextPortion::Format_( SwTextFormatInfo &rInf )
! rInf.GetLast()->IsErgoSumPortion() &&
lcl_HasContent(*static_cast(rInf.GetLast()),rInf ) ) ) ) )
{
- if ( rInf.X() + aGuess.BreakWidth() <= rInf.Width() )
+ // GetLineWidth() takes care of DocumentSettingId::TAB_OVER_MARGIN.
+ if (aGuess.BreakWidth() <= rInf.GetLineWidth())
Width( aGuess.BreakWidth() );
else
// this actually should not happen