sw/qa/core/text/data/tabovermargin-section.fodt | 50 ++++++++++++++++++++++++ sw/qa/core/text/text.cxx | 14 ++++++ sw/source/core/text/txttab.cxx | 7 ++- 3 files changed, 70 insertions(+), 1 deletion(-)
New commits: commit 3c54bbc15c8076aa9caaa27642045cb38d4a6b35 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Mon Apr 12 21:06:52 2021 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Thu Apr 15 16:07:24 2021 +0200 tdf#132393 sw: disable TabOverMargin layout flag inside sections Regression from commit bdfc6363d66aa079512cc8008996b633f693fed1 (n#793998 sw: add TabOverMargin compat mode, 2013-01-08), the problem is that currently adding an alphabetical index generates document model where tab positions are explicitly over the margin and users expect that the page numbers are still visible, even for Word documents. Fix the problem by disabling this mode inside sections. Long-term we may want to fix the ToX generator to create a more sane document model and then this flag can be handled even inside sections. (cherry picked from commit e1cc5041cfb7272eb96f174e1c64285420397588) Conflicts: sw/qa/core/text/text.cxx Change-Id: Ic91ac36e703d59e4711a009db1f921e456bf8645 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114039 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sw/qa/core/text/data/tabovermargin-section.fodt b/sw/qa/core/text/data/tabovermargin-section.fodt new file mode 100644 index 000000000000..6fd39c471228 --- /dev/null +++ b/sw/qa/core/text/data/tabovermargin-section.fodt @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="UTF-8"?> +<office:document xmlns:officeooo="http://openoffice.org/2009/office" xmlns:css3t="http://www.w3.org/TR/css3-text/" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rpt="http://openoffice.org/2005/report" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns :config:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="ur n:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:xforms="http://www.w3.org/2002/xforms" office:version="1.3" 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-set> + </office:settings> + <office:styles> + <style:default-style style:family="paragraph"> + </style:default-style> + </office:styles> + <office:automatic-styles> + <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Index_20_1"> + <style:paragraph-properties> + <style:tab-stops> + <style:tab-stop style:position="17.59cm" style:type="right" style:leader-style="dotted" style:leader-text="."/> + </style:tab-stops> + </style:paragraph-properties> + </style:style> + <style:style style:name="Sect1" style:family="section"> + <style:section-properties style:editable="false"> + <style:columns fo:column-count="2" fo:column-gap="0cm"> + <style:column style:rel-width="32767*" fo:start-indent="0cm" fo:end-indent="0cm"/> + <style:column style:rel-width="32768*" fo:start-indent="0cm" fo:end-indent="0cm"/> + </style:columns> + </style:section-properties> + </style:style> + <style:page-layout style:name="pm1"> + <style:page-layout-properties fo:page-width="21.59cm" fo:page-height="27.94cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" fo:background-color="#ffffff" style:writing-mode="lr-tb" style:layout-grid-color="#c0c0c0" style:layout-grid-lines="37" style:layout-grid-base-height="0.635cm" style:layout-grid-ruby-height="0cm" style:layout-grid-mode="none" style:layout-grid-ruby-below="false" style:layout-grid-print="false" style:layout-grid-display="false" style:layout-grid-base-width="0.423cm" style:layout-grid-snap-to="true" draw:fill="solid" draw:fill-color="#ffffff" draw:opacity="0%" style:footnote-max-height="0cm" loext:margin-gutter="0cm"> + </style:page-layout-properties> + <style:header-style/> + <style:footer-style/> + </style:page-layout> + <style:style style:name="dp1" style:family="drawing-page"> + <style:drawing-page-properties draw:fill="solid" draw:background-size="full" draw:fill-color="#ffffff" draw:opacity="0%"/> + </style:style> + </office:automatic-styles> + <office:master-styles> + <style:master-page style:name="Standard" style:page-layout-name="pm1" draw:style-name="dp1"/> + </office:master-styles> + <office:body> + <office:text> + <text:p>before</text:p> + <text:section text:style-name="Sect1" text:name="Section1"> + <text:p text:style-name="P1">hello<text:tab/>1</text:p> + </text:section> + <text:p>after</text:p> + </office:text> + </office:body> +</office:document> diff --git a/sw/qa/core/text/text.cxx b/sw/qa/core/text/text.cxx index 6122bab09911..7d0495cbb69c 100644 --- a/sw/qa/core/text/text.cxx +++ b/sw/qa/core/text/text.cxx @@ -69,6 +69,20 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testSemiTransparentText) assertXPath(pXmlDoc, "//floattransparent"); } +CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testTabOverMarginSection) +{ + createSwDoc(DATA_DIRECTORY, "tabovermargin-section.fodt"); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + sal_Int32 nWidth + = getXPath(pXmlDoc, "//Text[@nType='PortionType::TabRight']", "nWidth").toInt32(); + // Without the accompanying fix in place, this test would have failed with: + // - Expected less than: 5000 + // - Actual : 9372 + // i.e. the tab portion width was not the expected 4386, but much larger, so the number after + // the tab portion was not visible. + CPPUNIT_ASSERT_LESS(static_cast<sal_Int32>(5000), nWidth); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/text/txttab.cxx b/sw/source/core/text/txttab.cxx index e62fd8d17b87..6fb56a1ffa6f 100644 --- a/sw/source/core/text/txttab.cxx +++ b/sw/source/core/text/txttab.cxx @@ -436,7 +436,12 @@ bool SwTabPortion::PreFormat( SwTextFormatInfo &rInf ) bool SwTabPortion::PostFormat( SwTextFormatInfo &rInf ) { - const bool bTabOverMargin = rInf.GetTextFrame()->GetDoc().getIDocumentSettingAccess().get(DocumentSettingId::TAB_OVER_MARGIN); + bool bTabOverMargin = rInf.GetTextFrame()->GetDoc().getIDocumentSettingAccess().get( + DocumentSettingId::TAB_OVER_MARGIN); + + if (rInf.GetTextFrame()->IsInSct()) + bTabOverMargin = false; + // If the tab position is larger than the right margin, it gets scaled down by default. // However, if compat mode enabled, we allow tabs to go over the margin: the rest of the paragraph is not broken into lines. const sal_uInt16 nRight = bTabOverMargin ? GetTabPos() : std::min(GetTabPos(), rInf.Width()); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits