diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-10-05 10:31:26 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-10-05 13:28:20 +0200 |
commit | cb2f30897ca5d9ced5b4a4d801af6f0a22c98cc0 (patch) | |
tree | 7d36228b2635acfe774500d885011c7c233f5c0b | |
parent | c26e13307fae1be23ab7e019ab7d82bacad04155 (diff) |
Related: tdf#120287 sw layout, TabOverMargin: fix too wide tab portion
What happened is:
- the paragraph was split into two lines, at the correct position
- but then the first line checked how wide the tab portion can be, and
there it concluded that it has a lot of space, so the tab portion was
1418 twips wide, instead of the expected "almost zero" 69
The root of the problem was that first the text break was determined
using the TabOverMargin rules (more horizontal space), but later a check
validated the result ignoring the TabOverMargin flag (less horizontal
space). Fix this inconsistency by using GetLineWidth() in
SwTextPortion::Format_() instead of manual calculation.
Change-Id: Iaa7144341dfeaa8d177716dd87165598f11fd573
Reviewed-on: https://gerrit.libreoffice.org/61403
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins
-rw-r--r-- | sw/qa/extras/layout/data/tdf120287b.fodt | 45 | ||||
-rw-r--r-- | sw/qa/extras/layout/layout.cxx | 12 | ||||
-rw-r--r-- | sw/source/core/text/portxt.cxx | 3 |
3 files changed, 59 insertions, 1 deletions
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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:settings> + <config:config-item-set config:name="ooo:configuration-settings"> + <config:config-item config:name="TabOverMargin" config:type="boolean">true</config:config-item> + <config:config-item config:name="PrinterIndependentLayout" config:type="string">high-resolution</config:config-item> + <config:config-item config:name="TabOverflow" config:type="boolean">false</config:config-item> + </config:config-item-set> + </office:settings> + <office:font-face-decls> + <style:font-face style:name="Liberation Serif" svg:font-family="'Liberation Serif'" style:font-family-generic="roman" style:font-pitch="variable"/> + </office:font-face-decls> + <office:styles> + <style:default-style style:family="paragraph"> + <style:text-properties style:use-window-font-color="true" style:font-name="Liberation Serif" fo:font-size="16pt" style:font-size-asian="12pt" style:language-asian="none" style:country-asian="none" style:font-size-complex="12pt" style:language-complex="none" style:country-complex="none" fo:hyphenate="false" fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2"/> + </style:default-style> + <style:style style:name="Standard" style:family="paragraph" style:class="text"> + <style:text-properties style:use-window-font-color="true" style:font-name="Liberation Serif" fo:font-family="'Liberation Serif'" style:font-family-generic="roman" style:font-pitch="variable" fo:font-size="10pt" fo:hyphenate="true" fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2"/> + </style:style> + <style:style style:name="Para" style:family="paragraph" style:parent-style-name="Standard"> + <style:paragraph-properties fo:margin-left="1.251cm" fo:margin-right="0cm" fo:margin-top="0cm" fo:margin-bottom="0.141cm" loext:contextual-spacing="false" fo:line-height="0.388cm" fo:text-align="justify" style:justify-single-word="false" fo:text-indent="-1.251cm" style:auto-text-indent="false"> + <style:tab-stops> + <style:tab-stop style:position="9.751cm" style:type="right"/> + </style:tab-stops> + </style:paragraph-properties> + </style:style> + </office:styles> + <office:automatic-styles> + <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Para" style:master-page-name="Page"> + <style:paragraph-properties fo:margin-left="1.251cm" fo:margin-right="2.499cm" fo:text-align="start" style:justify-single-word="false" fo:text-indent="-1.251cm" style:auto-text-indent="false"/> + </style:style> + <style:page-layout style:name="pm1" style:page-usage="mirrored"> + <style:page-layout-properties fo:page-width="14.801cm" fo:page-height="21.001cm" fo:margin-top="1.101cm" fo:margin-bottom="1cm" fo:margin-left="1.9cm" fo:margin-right="1.9cm"/> + </style:page-layout> + </office:automatic-styles> + <office:master-styles> + <style:master-page style:name="Page" style:page-layout-name="pm1"> + </style:master-page> + </office:master-styles> + <office:body> + <office:text> + <text:p text:style-name="P1">b)<text:tab/>Lorem ipsum dolor sit amet, consetetur sadips<text:tab/>1 2 3 4 5 6 78a b c d e sed diam</text:p> + </office:text> + </office:body> +</office:document> 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<SwFieldPortion*>(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 |