diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2023-05-25 08:18:02 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2023-05-31 13:48:05 +0200 |
commit | 6ffce19cff873a3d90bb02b4a702cd06498fabb5 (patch) | |
tree | a4532fb55df17fa90e45c1c299eead6f7a56ef3a /sw | |
parent | 53b99e785cf5506fdbdd3d896154a2b1ad6e9aac (diff) |
sw floattable: handle <w:doNotBreakWrappedTables> in the DOCX filter
<w:doNotBreakWrappedTables> primarily appears in documents imported from
RTF, unless \nobrkwrptbl is specified there (which, confusingly, means
to do split floating tables).
(cherry picked from commit f5dc52dc9a068fec3323c3089929a81675b0d1ba)
Conflicts:
sw/qa/filter/ww8/ww8.cxx
Change-Id: I1891b89787719805e6c87045dee3c63c68ed2940
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152296
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/filter/ww8/ww8.cxx | 22 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxexport.cxx | 13 |
2 files changed, 32 insertions, 3 deletions
diff --git a/sw/qa/filter/ww8/ww8.cxx b/sw/qa/filter/ww8/ww8.cxx index 0c29e3fbd10f..fd7b07ff59bf 100644 --- a/sw/qa/filter/ww8/ww8.cxx +++ b/sw/qa/filter/ww8/ww8.cxx @@ -24,6 +24,7 @@ #include <IDocumentLayoutAccess.hxx> #include <rootfrm.hxx> #include <pagefrm.hxx> +#include <IDocumentSettingAccess.hxx> namespace { @@ -280,6 +281,27 @@ CPPUNIT_TEST_FIXTURE(Test, testWrapThroughLayoutInCell) // i.e. layoutInCell was disabled, leading to bad layout in Word. assertXPath(pXmlDoc, "//wp:anchor", "layoutInCell", "1"); } + +CPPUNIT_TEST_FIXTURE(Test, testDoNotBreakWrappedTables) +{ + // Given a document with the DO_NOT_BREAK_WRAPPED_TABLES compat mode enabled: + createSwDoc(); + SwDoc* pDoc = getSwDoc(); + IDocumentSettingAccess& rIDSA = pDoc->getIDocumentSettingAccess(); + rIDSA.set(DocumentSettingId::DO_NOT_BREAK_WRAPPED_TABLES, true); + + // When saving to docx: + save("Office Open XML Text"); + + // Then make sure the compat flag is serialized: + xmlDocUniquePtr pXmlDoc = parseExport("word/settings.xml"); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1 + // - Actual : 0 + // - XPath '/w:settings/w:compat/w:doNotBreakWrappedTables' number of nodes is incorrect + // i.e. <w:doNotBreakWrappedTables> was not written. + assertXPath(pXmlDoc, "/w:settings/w:compat/w:doNotBreakWrappedTables", 1); +} } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index 838d49a9b84d..b9c75140b7f6 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -1001,7 +1001,8 @@ static auto WriteCompat(SwDoc const& rDoc, ::sax_fastparser::FSHelperPtr const& rpFS, sal_Int32 & rTargetCompatibilityMode) -> void { - if (!rDoc.getIDocumentSettingAccess().get(DocumentSettingId::ADD_EXT_LEADING)) + const IDocumentSettingAccess& rIDSA = rDoc.getIDocumentSettingAccess(); + if (!rIDSA.get(DocumentSettingId::ADD_EXT_LEADING)) { rpFS->singleElementNS(XML_w, XML_noLeading); if (rTargetCompatibilityMode > 14) @@ -1010,13 +1011,19 @@ WriteCompat(SwDoc const& rDoc, ::sax_fastparser::FSHelperPtr const& rpFS, } } // Do not justify lines with manual break - if (rDoc.getIDocumentSettingAccess().get(DocumentSettingId::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK)) + if (rIDSA.get(DocumentSettingId::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK)) { rpFS->singleElementNS(XML_w, XML_doNotExpandShiftReturn); } // tdf#146515 export "Use printer metrics for document formatting" - if (!rDoc.getIDocumentSettingAccess().get(DocumentSettingId::USE_VIRTUAL_DEVICE)) + if (!rIDSA.get(DocumentSettingId::USE_VIRTUAL_DEVICE)) rpFS->singleElementNS(XML_w, XML_usePrinterMetrics); + + if (rIDSA.get(DocumentSettingId::DO_NOT_BREAK_WRAPPED_TABLES)) + { + // Map the DoNotBreakWrappedTables compat flag to <w:doNotBreakWrappedTables>. + rpFS->singleElementNS(XML_w, XML_doNotBreakWrappedTables); + } } void DocxExport::WriteSettings() |