tdf#161721 sw: text formatting: TabOverMargin not crazy enough

Word will use a center or right tab position in the margin without
limiting it, and even put text after it.

Change-Id: Ibae5758467620f355544963acb7941689fae2602
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169517
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Tested-by: Jenkins
This commit is contained in:
Michael Stahl 2024-06-25 13:28:12 +02:00
parent af0042ba65
commit 78705c3b97
2 changed files with 11 additions and 3 deletions

View file

@ -567,8 +567,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf158658b)
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
// Word 2013 puts all tabs and the field following into one line
// but also puts the field off the page, while in Writer it's
// aligned to the right margin; should be good enough for now...
// and also puts the field off the page
assertXPath(pXmlDoc, "/root/page[1]/footer/txt[1]/SwParaPortion/SwLineLayout"_ostr, 1);
assertXPath(
pXmlDoc,
@ -578,6 +577,10 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf158658b)
pXmlDoc,
"/root/page[1]/footer/txt[1]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::TabRight']"_ostr,
1);
assertXPath(
pXmlDoc,
"/root/page[1]/footer/txt[1]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::TabRight']"_ostr,
"width"_ostr, u"4446"_ustr); // was very small: 24
assertXPath(
pXmlDoc,
"/root/page[1]/footer/txt[1]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::TabLeft']"_ostr,

View file

@ -175,7 +175,12 @@ SwTabPortion *SwTextFormatter::NewTabPortion( SwTextFormatInfo &rInf, bool bAuto
// since up till now these were just treated as automatic tabstops.
eAdj = SvxTabAdjust::Right;
bAbsoluteNextPos = true;
nNextPos = rInf.Width();
// TODO: unclear if old Word has an upper limit for center/right
// tabs, UI allows setting 55.87cm max which is still one line
if (!bTabOverMargin || o3tl::toTwips(558, o3tl::Length::mm) < nNextPos)
{
nNextPos = rInf.Width();
}
}
bAutoTabStop = false;
}