officecfg/registry/schema/org/openoffice/Office/Compatibility.xcs | 6 sw/inc/IDocumentSettingAccess.hxx | 2 sw/inc/strings.hrc | 1 sw/inc/viewsh.hxx | 2 sw/qa/extras/layout/data/tdf167583.fodt | 168 ++++++++++ sw/qa/extras/layout/data/tdf88752.fodt | 4 sw/qa/extras/layout/layout5.cxx | 17 + sw/qa/extras/ooxmlexport/ooxmlexport25.cxx | 31 + sw/qa/extras/ww8export/ww8export4.cxx | 32 + sw/source/core/doc/DocumentSettingManager.cxx | 17 - sw/source/core/inc/DocumentSettingManager.hxx | 1 sw/source/core/text/itrform2.cxx | 6 sw/source/core/view/viewsh.cxx | 13 sw/source/filter/ww8/docxexport.cxx | 5 sw/source/filter/ww8/wrtww8.cxx | 2 sw/source/filter/ww8/ww8par.cxx | 4 sw/source/ui/config/optcomp.cxx | 6 sw/source/uibase/uno/SwXDocumentSettings.cxx | 15 sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx | 2 sw/source/writerfilter/dmapper/SettingsTable.cxx | 8 sw/source/writerfilter/dmapper/SettingsTable.hxx | 3 21 files changed, 339 insertions(+), 6 deletions(-)
New commits: commit 2745e97d3d21cc91747d51ca4b68f53ac219211e Author: Jonathan Clark <jonat...@libreoffice.org> AuthorDate: Fri Jul 18 22:04:10 2025 -0600 Commit: Jonathan Clark <jonat...@libreoffice.org> CommitDate: Tue Jul 22 21:45:46 2025 +0200 tdf#167583 sw: Add ADJUST_TABLE_LINE_HEIGHTS_TO_GRID_HEIGHT compat flag Adds a new compatibility flag to emulate the MSO CT_Compat_adjustLineHeightInTable / fDontAdjustLineHeightInTable compat flags. Layout support for this compatibility flag was implemented previously, but was mapped to a different compatibility flag. This change also updates the previous implementation so that it uses the new flag. Change-Id: Ia07ef35c32716069e049733f16a465d165d584a1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188104 Reviewed-by: Jonathan Clark <jonat...@libreoffice.org> Tested-by: Jenkins diff --git a/officecfg/registry/schema/org/openoffice/Office/Compatibility.xcs b/officecfg/registry/schema/org/openoffice/Office/Compatibility.xcs index fecd8b23ffec..a566cd6d9b76 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Compatibility.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Compatibility.xcs @@ -194,6 +194,12 @@ </info> <value>false</value> </prop> + <prop oor:name="AdjustTableLineHeightsToGridHeight" oor:type="xs:boolean" oor:nillable="false"> + <info> + <desc>Fix line heights for text inside tables to the text grid line height</desc> + </info> + <value>true</value> + </prop> </group> </templates> <component> diff --git a/sw/inc/IDocumentSettingAccess.hxx b/sw/inc/IDocumentSettingAccess.hxx index 902f23b72a87..79884c24b17b 100644 --- a/sw/inc/IDocumentSettingAccess.hxx +++ b/sw/inc/IDocumentSettingAccess.hxx @@ -147,6 +147,8 @@ enum class DocumentSettingId BALANCE_SPACES_AND_IDEOGRAPHIC_SPACES, // tdf#37153 Word-compatibility: force top-alignment for cells containing a floating shape FORCE_TOP_ALIGNMENT_IN_CELL_WITH_FLOATING_ANCHOR, + // tdf#167583 optionally apply text grid line height to table contents + ADJUST_TABLE_LINE_HEIGHTS_TO_GRID_HEIGHT, }; /** Provides access to settings of a document diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc index 139028fb46a5..a4d0ab8e6bae 100644 --- a/sw/inc/strings.hrc +++ b/sw/inc/strings.hrc @@ -1536,6 +1536,7 @@ #define STR_COMPAT_OPT_IGNORETABSANDBLANKSFORLINECALCULATION NC_("STR_COMPAT_OPT_IGNORETABSANDBLANKSFORLINECALCULATION", "Make whitespace character height not affect line height") #define STR_COMPAT_OPT_UNDERLINETRAILINGSPACE NC_("STR_COMPAT_OPT_UNDERLINETRAILINGSPACE", "Underline Word-compatible trailing blanks") #define STR_COMPAT_OPT_BALANCESPACESANDIDEOGRAPHICSPACES NC_("STR_COMPAT_OPT_BALANCESPACESANDIDEOGRAPHICSPACES", "Adjust spaces to half the width of ideographic spaces, using Word-compatible rules") +#define STR_COMPAT_OPT_ADJUSTTABLELINEHEIGHTSTOGRIDHEIGHT NC_("STR_COMPAT_OPT_ADJUSTTABLELINEHEIGHTSTOGRIDHEIGHT", "Adjust line heights to grid height in table") #define STR_TABLE_PANEL_ALIGN_AUTO NC_("sidebartableedit|alignautolabel", "Automatic") #define STR_TABLE_PANEL_ALIGN_LEFT NC_("sidebartableedit|alignleftlabel", "Left") diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx index 32181a1e08ba..b8c2f55a2210 100644 --- a/sw/inc/viewsh.hxx +++ b/sw/inc/viewsh.hxx @@ -475,6 +475,8 @@ public: SW_DLLPUBLIC void SetBalanceSpacesAndIdeographicSpaces(bool bValue); + SW_DLLPUBLIC void SetAdjustTableLineHeightsToGridHeight(bool bValue); + // DOCUMENT COMPATIBILITY FLAGS END // Calls Idle-formatter of Layout. diff --git a/sw/qa/extras/layout/data/tdf167583.fodt b/sw/qa/extras/layout/data/tdf167583.fodt new file mode 100644 index 000000000000..f90f0f1f0483 --- /dev/null +++ b/sw/qa/extras/layout/data/tdf167583.fodt @@ -0,0 +1,168 @@ +<?xml version='1.0' encoding='UTF-8'?> +<office:document 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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:c alcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext: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:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:rpt="http://openoffice.org/2005/report" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form: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:officeooo="http://openoffice.org/2009/office" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns: meta:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" office:version="1.4" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:meta><meta:creation-date>2025-05-14T04:57:23.071662402</meta:creation-date><dc:date>2025-05-14T05:02:33.172712761</dc:date><meta:editing-duration>PT4M40S</meta:editing-duration><meta:editing-cycles>6</meta:editing-cycles><meta:generator>LibreOfficeDev/25.8.0.0.alpha1$Linux_X86_64 LibreOffice_project/31ff0b537424ed3c4132293a8456c763c98fc869</meta:generator><meta:document-statistic meta:table-count="1" meta:image-count="0" meta:object-count="0" meta:page-count="1" meta:paragraph-count="6" meta:word-count="9" meta:character-count="25" meta:non-whitespace-character-count="22"/></office:meta> + <office:settings> + <config:config-item-set config:name="ooo:configuration-settings"> + </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"/> + <style:font-face style:name="Noto Sans1" svg:font-family="'Noto Sans'" style:font-family-generic="system" style:font-pitch="variable"/> + <style:font-face style:name="Noto Serif CJK SC" svg:font-family="'Noto Serif CJK SC'" style:font-family-generic="system" style:font-pitch="variable"/> + </office:font-face-decls> + <office:styles> + <style:default-style style:family="graphic"> + <style:graphic-properties svg:stroke-color="#3465a4" draw:fill-color="#729fcf" fo:wrap-option="no-wrap" draw:shadow-offset-x="0.1181in" draw:shadow-offset-y="0.1181in" draw:start-line-spacing-horizontal="0.1114in" draw:start-line-spacing-vertical="0.1114in" draw:end-line-spacing-horizontal="0.1114in" draw:end-line-spacing-vertical="0.1114in" style:writing-mode="lr-tb" style:flow-with-text="false"/> + <style:paragraph-properties style:text-autospace="ideograph-alpha" style:line-break="strict" loext:tab-stop-distance="0in" style:font-independent-line-spacing="false"> + <style:tab-stops/> + </style:paragraph-properties> + <style:text-properties style:use-window-font-color="true" loext:opacity="0%" style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="en" fo:country="US" style:letter-kerning="true" style:font-name-asian="Noto Serif CJK SC" style:font-size-asian="10.5pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Noto Sans1" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN"/> + </style:default-style> + <style:default-style style:family="paragraph"> + <style:paragraph-properties fo:orphans="2" fo:widows="2" fo:hyphenation-ladder-count="no-limit" fo:hyphenation-keep="auto" loext:hyphenation-keep-type="column" loext:hyphenation-keep-line="false" style:text-autospace="ideograph-alpha" style:punctuation-wrap="hanging" style:line-break="strict" style:tab-stop-distance="0.4925in" style:writing-mode="page"/> + <style:text-properties style:use-window-font-color="true" loext:opacity="0%" style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="en" fo:country="US" style:letter-kerning="true" style:font-name-asian="Noto Serif CJK SC" style:font-size-asian="10.5pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Noto Sans1" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN" fo:hyphenate="false" fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2" loext:hyphenation-no-caps="false" loext:hyphenation-no-last-word="false" loext:hyphenation-word-char-count="5" loext:hyphenation-zone="no-limit"/> + </style:default-style> + <style:default-style style:family="table"> + <style:table-properties table:border-model="collapsing"/> + </style:default-style> + <style:default-style style:family="table-row"> + <style:table-row-properties fo:keep-together="auto"/> + </style:default-style> + <style:style style:name="Standard" style:family="paragraph" style:class="text"> + <style:text-properties fo:font-size="48pt"/> + </style:style> + <style:style style:name="Table_20_Contents" style:display-name="Table Contents" style:family="paragraph" style:parent-style-name="Standard" style:class="extra"> + <style:paragraph-properties fo:orphans="0" fo:widows="0" text:number-lines="false" text:line-number="0"/> + </style:style> + <text:outline-style style:name="Outline"> + <text:outline-level-style text:level="1" loext:num-list-format="%1%" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="2" loext:num-list-format="%2%" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="3" loext:num-list-format="%3%" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="4" loext:num-list-format="%4%" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="5" loext:num-list-format="%5%" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="6" loext:num-list-format="%6%" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="7" loext:num-list-format="%7%" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="8" loext:num-list-format="%8%" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="9" loext:num-list-format="%9%" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="10" loext:num-list-format="%10%" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + </text:outline-style> + <text:notes-configuration text:note-class="footnote" style:num-format="1" text:start-value="0" text:footnotes-position="page" text:start-numbering-at="document"/> + <text:notes-configuration text:note-class="endnote" style:num-format="i" text:start-value="0"/> + <text:linenumbering-configuration text:number-lines="false" text:offset="0.1965in" style:num-format="1" text:number-position="left" text:increment="5"/> + </office:styles> + <office:automatic-styles> + <style:style style:name="Table1" style:family="table"> + <style:table-properties style:width="6.6931in" table:align="margins"/> + </style:style> + <style:style style:name="Table1.A" style:family="table-column"> + <style:table-column-properties style:column-width="6.6931in" style:rel-column-width="65535*"/> + </style:style> + <style:style style:name="Table1.1" style:family="table-row"/> + <style:style style:name="Table1.A1" style:family="table-cell"> + <style:table-cell-properties fo:padding="0.0382in" fo:border="0.5pt solid #000000"/> + </style:style> + <style:style style:name="Table1.A2" style:family="table-cell"> + <style:table-cell-properties fo:padding="0.0382in" fo:border-left="0.5pt solid #000000" fo:border-right="0.5pt solid #000000" fo:border-top="none" fo:border-bottom="0.5pt solid #000000"/> + </style:style> + <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Standard"> + <style:text-properties/> + </style:style> + <style:style style:name="P2" style:family="paragraph" style:parent-style-name="Table_20_Contents"> + <style:text-properties/> + </style:style> + <style:page-layout style:name="pm1"> + <style:page-layout-properties fo:page-width="8.2681in" fo:page-height="11.6929in" style:num-format="1" style:print-orientation="portrait" fo:margin-top="0.7874in" fo:margin-bottom="0.7874in" fo:margin-left="0.7874in" fo:margin-right="0.7874in" style:writing-mode="lr-tb" style:layout-grid-color="#c0c0c0" style:layout-grid-lines="8" style:layout-grid-base-height="1.111in" style:layout-grid-ruby-height="0.139in" style:layout-grid-mode="line" style:layout-grid-ruby-below="false" style:layout-grid-print="false" style:layout-grid-display="false" style:footnote-max-height="0in" loext:margin-gutter="0in"> + <style:footnote-sep style:width="0.0071in" style:distance-before-sep="0.0398in" style:distance-after-sep="0.0398in" style:line-style="solid" style:adjustment="left" style:rel-width="25%" style:color="#000000"/> + </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:background-size="full"/> + </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:sequence-decls> + <text:sequence-decl text:display-outline-level="0" text:name="Illustration"/> + <text:sequence-decl text:display-outline-level="0" text:name="Table"/> + <text:sequence-decl text:display-outline-level="0" text:name="Text"/> + <text:sequence-decl text:display-outline-level="0" text:name="Drawing"/> + <text:sequence-decl text:display-outline-level="0" text:name="Figure"/> + </text:sequence-decls> + <text:p text:style-name="P1">Test grid with table</text:p> + <table:table table:name="Table1" table:style-name="Table1"> + <table:table-column table:style-name="Table1.A"/> + <table:table-row table:style-name="Table1.1"> + <table:table-cell table:style-name="Table1.A1" office:value-type="string"> + <text:p text:style-name="P2">A</text:p> + </table:table-cell> + </table:table-row> + <table:table-row table:style-name="Table1.1"> + <table:table-cell table:style-name="Table1.A2" office:value-type="string"> + <text:p text:style-name="P2">B</text:p> + </table:table-cell> + </table:table-row> + <table:table-row table:style-name="Table1.1"> + <table:table-cell table:style-name="Table1.A2" office:value-type="string"> + <text:p text:style-name="P2">C</text:p> + </table:table-cell> + </table:table-row> + <table:table-row table:style-name="Table1.1"> + <table:table-cell table:style-name="Table1.A2" office:value-type="string"> + <text:p text:style-name="P2">D</text:p> + </table:table-cell> + </table:table-row> + <table:table-row table:style-name="Table1.1"> + <table:table-cell table:style-name="Table1.A2" office:value-type="string"> + <text:p text:style-name="P2">E</text:p> + </table:table-cell> + </table:table-row> + </table:table> + <text:p text:style-name="P1"/> + </office:text> + </office:body> +</office:document> diff --git a/sw/qa/extras/layout/data/tdf88752.fodt b/sw/qa/extras/layout/data/tdf88752.fodt index 7e1768704868..e9c1ef88acbb 100644 --- a/sw/qa/extras/layout/data/tdf88752.fodt +++ b/sw/qa/extras/layout/data/tdf88752.fodt @@ -3,7 +3,7 @@ <office:meta><meta:creation-date>2025-05-14T04:57:23.071662402</meta:creation-date><dc:date>2025-05-14T05:02:33.172712761</dc:date><meta:editing-duration>PT4M40S</meta:editing-duration><meta:editing-cycles>6</meta:editing-cycles><meta:generator>LibreOfficeDev/25.8.0.0.alpha1$Linux_X86_64 LibreOffice_project/31ff0b537424ed3c4132293a8456c763c98fc869</meta:generator><meta:document-statistic meta:table-count="1" meta:image-count="0" meta:object-count="0" meta:page-count="1" meta:paragraph-count="6" meta:word-count="9" meta:character-count="25" meta:non-whitespace-character-count="22"/></office:meta> <office:settings> <config:config-item-set config:name="ooo:configuration-settings"> - <config:config-item config:name="MsWordCompGridMetrics" config:type="boolean">true</config:config-item> + <config:config-item config:name="AdjustTableLineHeightsToGridHeight" config:type="boolean">false</config:config-item> </config:config-item-set> </office:settings> <office:font-face-decls> @@ -166,4 +166,4 @@ <text:p text:style-name="P1"/> </office:text> </office:body> -</office:document> \ No newline at end of file +</office:document> diff --git a/sw/qa/extras/layout/layout5.cxx b/sw/qa/extras/layout/layout5.cxx index 7a1678a43823..151b4e3da50c 100644 --- a/sw/qa/extras/layout/layout5.cxx +++ b/sw/qa/extras/layout/layout5.cxx @@ -1674,6 +1674,23 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter5, testTdf88752) CPPUNIT_ASSERT_LESS(sal_Int32(1690), nHeight); } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter5, testTdf167583) +{ + createSwDoc("tdf167583.fodt"); + auto pXmlDoc = parseLayoutDump(); + + // Verifies that the ADJUST_TABLE_LINE_HEIGHTS_TO_GRID_HEIGHT compat flag defaults to true + // Otherwise, this test would have failed with + // - Expected: 2 + // - Actual : 1 + assertXPath(pXmlDoc, "/root/page", 2); + + auto nHeight = getXPath(pXmlDoc, "/root/page[1]//row[3]//txt/infos/bounds", "height").toInt32(); + + CPPUNIT_ASSERT_GREATER(sal_Int32(3400), nHeight); + CPPUNIT_ASSERT_LESS(sal_Int32(3500), nHeight); +} + CPPUNIT_TEST_FIXTURE(SwLayoutWriter5, testTdf166652) { createSwDoc("line-spacing-80percent.fodt"); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx index 41de7a9c4925..3e2e4ec82ecc 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx @@ -213,6 +213,37 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf167297) fnVerify(); } +CPPUNIT_TEST_FIXTURE(Test, testTdf167583) +{ + createSwDoc(); + + auto fnVerify = [&](bool bExpected) { + auto xFactory = mxComponent.queryThrow<lang::XMultiServiceFactory>(); + auto xSettings = xFactory->createInstance(u"com.sun.star.document.Settings"_ustr); + CPPUNIT_ASSERT_EQUAL( + bExpected, getProperty<bool>(xSettings, u"AdjustTableLineHeightsToGridHeight"_ustr)); + }; + + // By default, a Writer doc has the compat option set + fnVerify(true); + + // Check that the value is persisted across save-reload + saveAndReload(mpFilter); + fnVerify(true); + + // Unset the compat flag + { + auto xFactory = mxComponent.queryThrow<lang::XMultiServiceFactory>(); + uno::Reference<beans::XPropertySet> xSettings( + xFactory->createInstance(u"com.sun.star.document.Settings"_ustr), uno::UNO_QUERY); + xSettings->setPropertyValue(u"AdjustTableLineHeightsToGridHeight"_ustr, uno::Any(false)); + } + + fnVerify(false); + saveAndReload(mpFilter); + fnVerify(false); +} + } // end of anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/qa/extras/ww8export/ww8export4.cxx b/sw/qa/extras/ww8export/ww8export4.cxx index f9aad0a27f1a..059136cfa681 100644 --- a/sw/qa/extras/ww8export/ww8export4.cxx +++ b/sw/qa/extras/ww8export/ww8export4.cxx @@ -795,6 +795,38 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf167297) fnVerify(); } +CPPUNIT_TEST_FIXTURE(Test, testTdf167583) +{ + createSwDoc(); + + auto fnVerify = [&](bool bExpected) + { + auto xFactory = mxComponent.queryThrow<lang::XMultiServiceFactory>(); + auto xSettings = xFactory->createInstance(u"com.sun.star.document.Settings"_ustr); + CPPUNIT_ASSERT_EQUAL( + bExpected, getProperty<bool>(xSettings, u"AdjustTableLineHeightsToGridHeight"_ustr)); + }; + + // By default, a Writer doc has the compat option set + fnVerify(true); + + // Check that the value is persisted across save-reload + saveAndReload(mpFilter); + fnVerify(true); + + // Unset the compat flag + { + auto xFactory = mxComponent.queryThrow<lang::XMultiServiceFactory>(); + uno::Reference<beans::XPropertySet> xSettings( + xFactory->createInstance(u"com.sun.star.document.Settings"_ustr), uno::UNO_QUERY); + xSettings->setPropertyValue(u"AdjustTableLineHeightsToGridHeight"_ustr, uno::Any(false)); + } + + fnVerify(false); + saveAndReload(mpFilter); + fnVerify(false); +} + } // end of anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/doc/DocumentSettingManager.cxx b/sw/source/core/doc/DocumentSettingManager.cxx index bd2dba7f7454..e448e8c0fda2 100644 --- a/sw/source/core/doc/DocumentSettingManager.cxx +++ b/sw/source/core/doc/DocumentSettingManager.cxx @@ -112,7 +112,8 @@ sw::DocumentSettingManager::DocumentSettingManager(SwDoc &rDoc) mbMinRowHeightInclBorder(false), mbMsWordCompGridMetrics(false), // tdf#129808 mbNoClippingWithWrapPolygon(false), - mbBalanceSpacesAndIdeographicSpaces(false) + mbBalanceSpacesAndIdeographicSpaces(false), + mbAdjustTableLineHeightsToGridHeight(true) // tdf#167583 // COMPATIBILITY FLAGS END { @@ -149,6 +150,7 @@ sw::DocumentSettingManager::DocumentSettingManager(SwDoc &rDoc) mbMsWordCompGridMetrics = aOptions.get(u"MsWordCompGridMetrics"_ustr); mbIgnoreTabsAndBlanksForLineCalculation = aOptions.get(u"IgnoreTabsAndBlanksForLineCalculation"_ustr); mbBalanceSpacesAndIdeographicSpaces = aOptions.get(u"BalanceSpacesAndIdeographicSpaces"_ustr); + mbAdjustTableLineHeightsToGridHeight = aOptions.get(u"AdjustTableLineHeightsToGridHeight"_ustr); } else { @@ -169,6 +171,7 @@ sw::DocumentSettingManager::DocumentSettingManager(SwDoc &rDoc) mbSubtractFlys = false; mbEmptyDbFieldHidesPara = true; mbUseVariableWidthNBSP = false; + mbAdjustTableLineHeightsToGridHeight = true; } // COMPATIBILITY FLAGS END @@ -286,6 +289,8 @@ bool sw::DocumentSettingManager::get(/*[in]*/ DocumentSettingId id) const return mbBalanceSpacesAndIdeographicSpaces; case DocumentSettingId::FORCE_TOP_ALIGNMENT_IN_CELL_WITH_FLOATING_ANCHOR: return mbForceTopAlignmentInCellWithFloatingAnchor; + case DocumentSettingId::ADJUST_TABLE_LINE_HEIGHTS_TO_GRID_HEIGHT: + return mbAdjustTableLineHeightsToGridHeight; default: OSL_FAIL("Invalid setting id"); } @@ -626,6 +631,9 @@ void sw::DocumentSettingManager::set(/*[in]*/ DocumentSettingId id, /*[in]*/ boo case DocumentSettingId::FORCE_TOP_ALIGNMENT_IN_CELL_WITH_FLOATING_ANCHOR: mbForceTopAlignmentInCellWithFloatingAnchor = value; break; + case DocumentSettingId::ADJUST_TABLE_LINE_HEIGHTS_TO_GRID_HEIGHT: + mbAdjustTableLineHeightsToGridHeight = value; + break; default: OSL_FAIL("Invalid setting id"); } @@ -810,6 +818,7 @@ void sw::DocumentSettingManager::ReplaceCompatibilityOptions(const DocumentSetti mbMsWordUlTrailSpace = rSource.mbMsWordUlTrailSpace; mbBalanceSpacesAndIdeographicSpaces = rSource.mbBalanceSpacesAndIdeographicSpaces; mbForceTopAlignmentInCellWithFloatingAnchor = rSource.mbForceTopAlignmentInCellWithFloatingAnchor; + mbAdjustTableLineHeightsToGridHeight = rSource.mbAdjustTableLineHeightsToGridHeight; } sal_uInt32 sw::DocumentSettingManager::Getn32DummyCompatibilityOptions1() const @@ -1224,6 +1233,12 @@ void sw::DocumentSettingManager::dumpAsXml(xmlTextWriterPtr pWriter) const BAD_CAST(OString::boolean(mbForceTopAlignmentInCellWithFloatingAnchor).getStr())); (void)xmlTextWriterEndElement(pWriter); + (void)xmlTextWriterStartElement(pWriter, BAD_CAST("mbAdjustTableLineHeightsToGridHeight")); + (void)xmlTextWriterWriteAttribute( + pWriter, BAD_CAST("value"), + BAD_CAST(OString::boolean(mbAdjustTableLineHeightsToGridHeight).getStr())); + (void)xmlTextWriterEndElement(pWriter); + (void)xmlTextWriterEndElement(pWriter); } diff --git a/sw/source/core/inc/DocumentSettingManager.hxx b/sw/source/core/inc/DocumentSettingManager.hxx index bb2d9ddf83a9..54d916350bdc 100644 --- a/sw/source/core/inc/DocumentSettingManager.hxx +++ b/sw/source/core/inc/DocumentSettingManager.hxx @@ -193,6 +193,7 @@ class DocumentSettingManager final : bool mbMsWordUlTrailSpace : 1 = false; bool mbBalanceSpacesAndIdeographicSpaces : 1 = false; // tdf#88908 bool mbForceTopAlignmentInCellWithFloatingAnchor : 1 = false; // tdf#37153 + bool mbAdjustTableLineHeightsToGridHeight : 1 = true; // tdf#167583 public: diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index 2d19e046430f..a426886d3011 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -2242,10 +2242,10 @@ void SwTextFormatter::CalcRealHeight( bool bNewLine ) SwTextGridItem const*const pGrid(GetGridItem(m_pFrame->FindPageFrame())); if ( pGrid && GetInfo().SnapToGrid() ) { - // tdf#88752: Grid base height is ignored for table rows in compat mode + // tdf#88752 tdf#167583: Grid base height is conditionally ignored for tables if (m_pFrame->IsInTab() - && m_pFrame->GetDoc().getIDocumentSettingAccess().get( - DocumentSettingId::MS_WORD_COMP_GRID_METRICS)) + && !m_pFrame->GetDoc().getIDocumentSettingAccess().get( + DocumentSettingId::ADJUST_TABLE_LINE_HEIGHTS_TO_GRID_HEIGHT)) { m_pCurr->SetRealHeight(nLineHeight); return; diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx index 4923d03db45b..a264b15976d6 100644 --- a/sw/source/core/view/viewsh.cxx +++ b/sw/source/core/view/viewsh.cxx @@ -1185,6 +1185,19 @@ void SwViewShell::SetBalanceSpacesAndIdeographicSpaces(bool bValue) } } +void SwViewShell::SetAdjustTableLineHeightsToGridHeight(bool bValue) +{ + IDocumentSettingAccess& rIDSA = getIDocumentSettingAccess(); + if (rIDSA.get(DocumentSettingId::ADJUST_TABLE_LINE_HEIGHTS_TO_GRID_HEIGHT) != bValue) + { + SwWait aWait(*GetDoc()->GetDocShell(), true); + rIDSA.set(DocumentSettingId::ADJUST_TABLE_LINE_HEIGHTS_TO_GRID_HEIGHT, bValue); + const SwInvalidateFlags nInv = SwInvalidateFlags::PrtArea | SwInvalidateFlags::Pos + | SwInvalidateFlags::Size | SwInvalidateFlags::Table; + lcl_InvalidateAllContent(*this, nInv); + } +} + void SwViewShell::Reformat() { SwWait aWait( *GetDoc()->GetDocShell(), true ); diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index 87d906b75970..a9427a4c9fd6 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -1093,6 +1093,11 @@ WriteCompat(SwDoc const& rDoc, ::sax_fastparser::FSHelperPtr const& rpFS) -> voi } if (rIDSA.get(DocumentSettingId::MS_WORD_UL_TRAIL_SPACE)) rpFS->singleElementNS(XML_w, XML_ulTrailSpace); + + if (rIDSA.get(DocumentSettingId::ADJUST_TABLE_LINE_HEIGHTS_TO_GRID_HEIGHT)) + { + rpFS->singleElementNS(XML_w, XML_adjustLineHeightInTable); + } } void DocxExport::WriteSettings() diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index e844bd6b2ad8..91f74fc27b12 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -574,6 +574,8 @@ static void WriteDop( WW8Export& rWrt ) rDop.fExpShRtn = !rWrt.m_rDoc.getIDocumentSettingAccess().get(DocumentSettingId::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK); // #i56856# rDop.fDntBlnSbDbWid = !rWrt.m_rDoc.getIDocumentSettingAccess().get( DocumentSettingId::BALANCE_SPACES_AND_IDEOGRAPHIC_SPACES); // tdf#88908 + rDop.fDontAdjustLineHeightInTable = !rWrt.m_rDoc.getIDocumentSettingAccess().get( + DocumentSettingId::ADJUST_TABLE_LINE_HEIGHTS_TO_GRID_HEIGHT); IDocumentSettingAccess& rIDSA = rWrt.m_rDoc.getIDocumentSettingAccess(); rDop.fDontBreakWrappedTables = rIDSA.get(DocumentSettingId::DO_NOT_BREAK_WRAPPED_TABLES); diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index d75c81056e37..f10985d689c4 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -1887,6 +1887,10 @@ void SwWW8ImplReader::ImportDop() DocumentSettingId::MIN_ROW_HEIGHT_INCL_BORDER, true); // use Word-compatible CJK text grid metrics m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::MS_WORD_COMP_GRID_METRICS, true); + // tdf#167583 + m_rDoc.getIDocumentSettingAccess().set( + DocumentSettingId::ADJUST_TABLE_LINE_HEIGHTS_TO_GRID_HEIGHT, + !m_xWDop->fDontAdjustLineHeightInTable); // Import Default Tabs tools::Long nDefTabSiz = m_xWDop->dxaTab; diff --git a/sw/source/ui/config/optcomp.cxx b/sw/source/ui/config/optcomp.cxx index 11ae04c2e50b..1ccd38690923 100644 --- a/sw/source/ui/config/optcomp.cxx +++ b/sw/source/ui/config/optcomp.cxx @@ -68,6 +68,7 @@ constexpr std::pair<OUString, TranslateId> options_list[]{ { u"IgnoreTabsAndBlanksForLineCalculation"_ustr, STR_COMPAT_OPT_IGNORETABSANDBLANKSFORLINECALCULATION }, { u"MsWordUlTrailSpace"_ustr, STR_COMPAT_OPT_UNDERLINETRAILINGSPACE }, { u"BalanceSpacesAndIdeographicSpaces"_ustr, STR_COMPAT_OPT_BALANCESPACESANDIDEOGRAPHICSPACES }, + { u"AdjustTableLineHeightsToGridHeight"_ustr, STR_COMPAT_OPT_ADJUSTTABLELINEHEIGHTSTOGRIDHEIGHT }, }; // DocumentSettingId, negate? @@ -99,6 +100,7 @@ std::pair<DocumentSettingId, bool> DocumentSettingForOption(const OUString& opti { u"IgnoreTabsAndBlanksForLineCalculation"_ustr, { DocumentSettingId::IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION, false } }, { u"MsWordUlTrailSpace"_ustr, { DocumentSettingId::MS_WORD_UL_TRAIL_SPACE, false } }, { u"BalanceSpacesAndIdeographicSpaces"_ustr, { DocumentSettingId::BALANCE_SPACES_AND_IDEOGRAPHIC_SPACES, false } }, + { u"AdjustTableLineHeightsToGridHeight"_ustr, { DocumentSettingId::ADJUST_TABLE_LINE_HEIGHTS_TO_GRID_HEIGHT, false } }, }; return map.at(option); } @@ -354,6 +356,10 @@ bool SwCompatibilityOptPage::FillItemSet( SfxItemSet* ) m_pWrtShell->SetBalanceSpacesAndIdeographicSpaces(bChecked); break; + case DocumentSettingId::ADJUST_TABLE_LINE_HEIGHTS_TO_GRID_HEIGHT: + m_pWrtShell->SetAdjustTableLineHeightsToGridHeight(bChecked); + break; + default: break; } diff --git a/sw/source/uibase/uno/SwXDocumentSettings.cxx b/sw/source/uibase/uno/SwXDocumentSettings.cxx index 89cdb980007c..9bb0e6940b2e 100644 --- a/sw/source/uibase/uno/SwXDocumentSettings.cxx +++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx @@ -170,6 +170,7 @@ enum SwDocumentSettingsPropertyHandles HANDLE_MS_WORD_UL_TRAIL_SPACE, HANDLE_BALANCE_SPACES_AND_IDEOGRAPHIC_SPACES, HANDLE_FORCE_TOP_ALIGNMENT_IN_CELL_WITH_FLOATING_ANCHOR, + HANDLE_ADJUST_TABLE_LINE_HEIGHTS_TO_GRID_HEIGHT, }; } @@ -286,6 +287,7 @@ static rtl::Reference<MasterPropertySetInfo> lcl_createSettingsInfo() { u"MsWordUlTrailSpace"_ustr, HANDLE_MS_WORD_UL_TRAIL_SPACE, cppu::UnoType<bool>::get(), 0 }, { u"BalanceSpacesAndIdeographicSpaces"_ustr, HANDLE_BALANCE_SPACES_AND_IDEOGRAPHIC_SPACES, cppu::UnoType<bool>::get(), 0 }, { u"ForceTopAlignmentInCellWithFloatingAnchor"_ustr, HANDLE_FORCE_TOP_ALIGNMENT_IN_CELL_WITH_FLOATING_ANCHOR, cppu::UnoType<bool>::get(), 0 }, + { u"AdjustTableLineHeightsToGridHeight"_ustr, HANDLE_ADJUST_TABLE_LINE_HEIGHTS_TO_GRID_HEIGHT, cppu::UnoType<bool>::get(), 0 }, /* * As OS said, we don't have a view when we need to set this, so I have to @@ -1240,6 +1242,13 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf DocumentSettingId::FORCE_TOP_ALIGNMENT_IN_CELL_WITH_FLOATING_ANCHOR, bTmp); } break; + case HANDLE_ADJUST_TABLE_LINE_HEIGHTS_TO_GRID_HEIGHT: + if (bool bTmp; rValue >>= bTmp) + { + mpDoc->getIDocumentSettingAccess().set( + DocumentSettingId::ADJUST_TABLE_LINE_HEIGHTS_TO_GRID_HEIGHT, bTmp); + } + break; default: throw UnknownPropertyException(OUString::number(rInfo.mnHandle)); } @@ -1869,6 +1878,12 @@ void SwXDocumentSettings::_getSingleValue( const comphelper::PropertyInfo & rInf DocumentSettingId::FORCE_TOP_ALIGNMENT_IN_CELL_WITH_FLOATING_ANCHOR); } break; + case HANDLE_ADJUST_TABLE_LINE_HEIGHTS_TO_GRID_HEIGHT: + { + rValue <<= mpDoc->getIDocumentSettingAccess().get( + DocumentSettingId::ADJUST_TABLE_LINE_HEIGHTS_TO_GRID_HEIGHT); + } + break; default: throw UnknownPropertyException(OUString::number(rInfo.mnHandle)); } diff --git a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx index e5c9e913e619..5bf5f5d25cbf 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx +++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx @@ -10003,6 +10003,8 @@ void DomainMapper_Impl::ApplySettingsTable() xSettings->setPropertyValue(u"ForceTopAlignmentInCellWithFloatingAnchor"_ustr, uno::Any(true)); + xSettings->setPropertyValue(u"AdjustTableLineHeightsToGridHeight"_ustr, + uno::Any(m_pSettingsTable->GetAdjustLineHeightInTable())); } catch(const uno::Exception&) { diff --git a/sw/source/writerfilter/dmapper/SettingsTable.cxx b/sw/source/writerfilter/dmapper/SettingsTable.cxx index 6cb991955af2..f0d18ada3689 100644 --- a/sw/source/writerfilter/dmapper/SettingsTable.cxx +++ b/sw/source/writerfilter/dmapper/SettingsTable.cxx @@ -415,6 +415,9 @@ void SettingsTable::lcl_sprm(Sprm& rSprm) case NS_ooxml::LN_CT_Compat_doNotVertAlignCellWithSp: m_bDoNotVertAlignCellWithSp = nIntValue != 0; break; + case NS_ooxml::LN_CT_Compat_adjustLineHeightInTable: + m_bAdjustLineHeightInTable = nIntValue != 0; + break; default: { #ifdef DBG_UTIL @@ -820,6 +823,11 @@ bool SettingsTable::GetDoNotVertAlignCellWithSp() const return m_bDoNotVertAlignCellWithSp; } +bool SettingsTable::GetAdjustLineHeightInTable() const +{ + return m_bAdjustLineHeightInTable; +} + }//namespace dmapper } //namespace writerfilter diff --git a/sw/source/writerfilter/dmapper/SettingsTable.hxx b/sw/source/writerfilter/dmapper/SettingsTable.hxx index 0b322bea1b54..28fd7cebb112 100644 --- a/sw/source/writerfilter/dmapper/SettingsTable.hxx +++ b/sw/source/writerfilter/dmapper/SettingsTable.hxx @@ -109,6 +109,8 @@ public: bool GetDoNotVertAlignCellWithSp() const; + bool GetAdjustLineHeightInTable() const; + private: // Properties virtual void lcl_attribute(Id Name, const Value& val) override; @@ -171,6 +173,7 @@ private: bool m_bEndnoteIsCollectAtSectionEnd = false; /// Don't vertically align table cells containing shapes bool m_bDoNotVertAlignCellWithSp = false; // tdf#37153 + bool m_bAdjustLineHeightInTable = false; // tdf#167583 }; typedef tools::SvRef<SettingsTable> SettingsTablePtr; }