tdf#133370 docx export: don't export unseen columnbreak
A compatibility option indicates whether a column break
is treated as a page break when there are no columns.
(Currently true only for DOCX). Don't export this column
break when compat is off, because it WILL show up as
a page-break in Word and LO when loaded.
In theory, the RTF and DOC code that converts these
into page-breaks on import could now be removed, but I
can't think of any reason why that would be of benefit.
testColumnBreak_ColumnCountIsZero in ooxmlexport4
covers the situation where docx MUST round-trip these.
Change-Id: I5c17e43d90469bdb86087c61dadf48a9440f7b96
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94799
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
diff --git a/sw/qa/extras/ooxmlexport/data/tdf133370_columnBreak.odt b/sw/qa/extras/ooxmlexport/data/tdf133370_columnBreak.odt
new file mode 100644
index 0000000..1848638
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf133370_columnBreak.odt
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
index dedad4d..08bbc76 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
@@ -33,6 +33,12 @@ DECLARE_OOXMLEXPORT_TEST(testTdf133334_followPgStyle, "tdf133334_followPgStyle.o
CPPUNIT_ASSERT_EQUAL(2, getPages());
}
DECLARE_OOXMLEXPORT_TEST(testTdf133370_columnBreak, "tdf133370_columnBreak.odt")
{
// Since non-DOCX formats ignores column breaks in non-column situtations, don't export to docx.
CPPUNIT_ASSERT_EQUAL(1, getPages());
}
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/docxexport.hxx b/sw/source/filter/ww8/docxexport.hxx
index 04d29c2..74336b7 100644
--- a/sw/source/filter/ww8/docxexport.hxx
+++ b/sw/source/filter/ww8/docxexport.hxx
@@ -131,8 +131,6 @@ public:
/// Access to the sections/headers/footres.
virtual MSWordSections& Sections() const override;
virtual bool SupportsOneColumnBreak() const override { return true; }
virtual bool FieldsQuoted() const override { return true; }
virtual bool AddSectionBreaksForTOX() const override { return true; }
diff --git a/sw/source/filter/ww8/rtfexport.hxx b/sw/source/filter/ww8/rtfexport.hxx
index 77f4244..0c0d35d 100644
--- a/sw/source/filter/ww8/rtfexport.hxx
+++ b/sw/source/filter/ww8/rtfexport.hxx
@@ -58,8 +58,6 @@ public:
/// Access to the Rtf Sdr exporter.
RtfSdrExport& SdrExporter() const;
bool SupportsOneColumnBreak() const override { return false; }
bool FieldsQuoted() const override { return true; }
bool AddSectionBreaksForTOX() const override { return false; }
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index 8c66df7..8753314 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -677,9 +677,6 @@ public:
/// Access to the sections/headers/footres.
virtual MSWordSections& Sections() const = 0;
/// Determines if column break with one column should be exported or not.
virtual bool SupportsOneColumnBreak() const = 0;
/// Determines if the import filter already quoted fields or not.
virtual bool FieldsQuoted() const = 0;
@@ -1020,8 +1017,6 @@ public:
virtual bool AllowPostponedTextInTable() const override { return false; }
virtual bool SupportsOneColumnBreak() const override { return false; }
virtual bool FieldsQuoted() const override { return false; }
virtual bool AddSectionBreaksForTOX() const override { return false; }
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index a9a9151..4b913d9 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -3867,7 +3867,8 @@ void AttributeOutputBase::FormatBreak( const SvxFormatBreakItem& rBreak )
[[fallthrough]];
case SvxBreak::ColumnAfter:
case SvxBreak::ColumnBoth:
if ( GetExport().Sections().CurrentNumberOfColumns( *GetExport().m_pDoc ) > 1 || GetExport().SupportsOneColumnBreak() )
if ( GetExport().m_pDoc->getIDocumentSettingAccess().get( DocumentSettingId::TREAT_SINGLE_COLUMN_BREAK_AS_PAGE_BREAK )
|| GetExport().Sections().CurrentNumberOfColumns( *GetExport().m_pDoc ) > 1 )
{
nC = msword::ColumnBreak;
}