summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <jluth@mail.com>2023-05-13 22:17:07 -0400
committerJustin Luth <jluth@mail.com>2023-05-16 00:59:52 +0200
commit67d4fe32713070be5688eef2da9377a91e2f6b81 (patch)
tree1d97254204899e6f536ef75584a63873a881427c
parenta9d60aba81305bf86024df707eb694d1cabc9a1d (diff)
tdf#144362 doc/x export: different columns mean new section
The situation causing this may have become more likely in 7.4.0. I think that tdf#149313 might have caused a regression in the unit test that I found that exhibited the problem, so I am adding another one. make CppunitTest_sw_ooxmlexport9 CPPUNIT_TEST_NAME=testTdf97648_relativeWidth make CppunitTest_sw_ooxmlexport9 CPPUNIT_TEST_NAME=testTdf144362 Change-Id: I8e668ac7bfb01a8704634a3e16243be7298bd1ee Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151731 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com>
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf144362.odtbin0 -> 10328 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport9.cxx26
-rw-r--r--sw/source/filter/ww8/wrtw8sty.cxx8
-rw-r--r--sw/source/filter/ww8/wrtww8.hxx2
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx25
5 files changed, 55 insertions, 6 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf144362.odt b/sw/qa/extras/ooxmlexport/data/tdf144362.odt
new file mode 100644
index 000000000000..9c161dbdeb7f
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf144362.odt
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index fc4a1c9f1445..0dbad12503bf 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -529,6 +529,32 @@ DECLARE_OOXMLEXPORT_TEST(testTdf97648_relativeWidth, "tdf97648_relativeWidth.doc
CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::RIGHT, getProperty<sal_Int16>(getShape(3), "HoriOrient"));
CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::LEFT, getProperty<sal_Int16>(getShape(4), "HoriOrient"));
}
+
+ uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xSections(xTextSectionsSupplier->getTextSections(),
+ uno::UNO_QUERY);
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xSections->getCount());
+
+ uno::Reference<beans::XPropertySet> xTextSection(xSections->getByIndex(2), uno::UNO_QUERY);
+ uno::Reference<text::XTextColumns> xTextColumns
+ = getProperty<uno::Reference<text::XTextColumns>>(xTextSection, "TextColumns");
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount());
+}
+
+DECLARE_OOXMLEXPORT_TEST(testTdf144362, "tdf144362.odt")
+{
+ uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xSections(xTextSectionsSupplier->getTextSections(),
+ uno::UNO_QUERY);
+
+ // This is difference OK: tdf#107837 extra section added on export to preserve balanced columns.
+ CPPUNIT_ASSERT_GREATEREQUAL(sal_Int32(2), xSections->getCount());
+
+ uno::Reference<beans::XPropertySet> xTextSection(xSections->getByIndex(1), uno::UNO_QUERY);
+ uno::Reference<text::XTextColumns> xTextColumns
+ = getProperty<uno::Reference<text::XTextColumns>>(xTextSection, "TextColumns");
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount());
}
DECLARE_OOXMLEXPORT_TEST(testTdf104061_tableSectionColumns,"tdf104061_tableSectionColumns.docx")
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
index 8e0bcdde91a1..cf62d9ded167 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -1114,10 +1114,10 @@ sal_uInt16 MSWordSections::CurrentNumberOfColumns( const SwDoc &rDoc ) const
if ( m_aSects.empty() )
return 1;
- return NumberOfColumns( rDoc, m_aSects.back() );
+ return GetFormatCol(rDoc, m_aSects.back()).GetNumCols();
}
-sal_uInt16 MSWordSections::NumberOfColumns( const SwDoc &rDoc, const WW8_SepInfo& rInfo )
+const SwFormatCol& MSWordSections::GetFormatCol(const SwDoc &rDoc, const WW8_SepInfo& rInfo)
{
const SwPageDesc* pPd = rInfo.pPageDesc;
if ( !pPd )
@@ -1131,9 +1131,7 @@ sal_uInt16 MSWordSections::NumberOfColumns( const SwDoc &rDoc, const WW8_SepInfo
if ( rInfo.pSectionFormat && reinterpret_cast<SwSectionFormat*>(sal_IntPtr(-1)) != rInfo.pSectionFormat )
aSet.Put( rInfo.pSectionFormat->GetFormatAttr( RES_COL ) );
- const SwFormatCol& rCol = aSet.Get( RES_COL );
- const SwColumns& rColumns = rCol.GetColumns();
- return rColumns.size();
+ return aSet.Get(RES_COL);
}
const WW8_SepInfo* MSWordSections::CurrentSectionInfo()
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index 87aa2298f0a8..7266bb8e91d4 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -223,7 +223,7 @@ public:
sal_uInt16 CurrentNumberOfColumns( const SwDoc &rDoc ) const;
/// Number of columns of the provided WW8_SepInfo.
- static sal_uInt16 NumberOfColumns( const SwDoc &rDoc, const WW8_SepInfo& rInfo );
+ static const SwFormatCol& GetFormatCol(const SwDoc &rDoc, const WW8_SepInfo& rInfo);
bool DocumentIsProtected() const { return mbDocumentIsProtected; }
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 4ba85a21bbee..8d7603f2d9a7 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -602,6 +602,31 @@ void MSWordExportBase::OutputSectionBreaks( const SfxItemSet *pSet, const SwNode
bNewPageDesc |= SetCurrentPageDescFromNode( rNd );
}
}
+
+ // If the columns are different in LO's adjacent sections, create a new MS section
+ if (!bNewPageDesc && pBreak->GetBreak() == SvxBreak::PageBefore
+ && Sections().CurrentSectionInfo())
+ {
+ const SwSectionFormat* pSectionFormat = MSWordExportBase::GetSectionFormat(rNd);
+ if (pSectionFormat)
+ {
+ const SwFormatCol& rNewSect = pSectionFormat->GetFormatAttr(RES_COL);
+ const SwFormatCol& rPrevSect
+ = MSWordSections::GetFormatCol(m_rDoc,
+ *Sections().CurrentSectionInfo());
+ if (rNewSect.GetNumCols() != rPrevSect.GetNumCols()
+ || !rNewSect.IsOrtho() || !rPrevSect.IsOrtho()
+ || rNewSect.GetLineStyle() != rPrevSect.GetLineStyle()
+ || rNewSect.GetLineWidth() != rPrevSect.GetLineWidth()
+ || rNewSect.GetLineColor() != rPrevSect.GetLineColor()
+ || rNewSect.GetLineHeight() != rPrevSect.GetLineHeight()
+ || rNewSect.GetLineAdj() != rPrevSect.GetLineAdj())
+ {
+ bNewPageDesc = true;
+ }
+ }
+ }
+
if ( !bNewPageDesc )
AttrOutput().OutputItem( *pBreak );
}