Kaydet (Commit) 4605bd46 authored tarafından Justin Luth's avatar Justin Luth Kaydeden (comit) Miklos Vajna

tdf#103931 writerfilter breaktype: same for implicit and explicit

MSWord normally does NOT specify "nextPage" for the sectionBreak,
since that is the default type. That is imported as BreakType == -1.
However, Writer ALWAYS exports the section type name, which of
course is imported explicitly.
**There is an import hack that treats the very first -1 section as
continuous IF there are columns**. Since Writer explicitly defines
the section type, these documents import differently.

When Writer round-trips these types of files, they get totally
messed up in Writer, although they look fine in Word. So, treat
both implicit and explicit nextPage identically for
bTreatAsContinuous during import.

Another unit test demonstrated that headers/footers are lost when
treating as continuous, so preventing that situation now also.

This fix allows several import-only unit tests to round-trip.

Change-Id: I37fa861d82e8da564d28d8e9089fe0f2777650fb
Reviewed-on: https://gerrit.libreoffice.org/35013Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarJustin Luth <justin_luth@sil.org>
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst 3902bb7a
......@@ -13,6 +13,7 @@
#include <com/sun/star/drawing/XControlShape.hpp>
#include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
#include <com/sun/star/text/XPageCursor.hpp>
#include <com/sun/star/text/XTextColumns.hpp>
#include <com/sun/star/text/XTextFrame.hpp>
#include <com/sun/star/text/XTextFramesSupplier.hpp>
#include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
......@@ -340,6 +341,42 @@ DECLARE_OOXMLEXPORT_TEST(testTdf106001_2, "tdf106001-2.odt")
assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:rPr/w:w","val","600");
}
DECLARE_OOXMLEXPORT_TEST(testDefaultSectBreakCols, "default-sect-break-cols.docx")
{
// First problem: the first two paragraphs did not have their own text section, so the whole document had two columns.
uno::Reference<beans::XPropertySet> xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(1, "First."), "TextSection");
CPPUNIT_ASSERT(xTextSection.is());
uno::Reference<text::XTextColumns> xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount());
// Second problem: the page style had two columns, while it shouldn't have any.
uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY);
xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xPageStyle, "TextColumns");
CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount());
// Check for the Column Separator value.It should be FALSE as the document does not contain separator line.
bool bValue = getProperty< bool >(xTextColumns, "SeparatorLineIsOn");
CPPUNIT_ASSERT(!bValue) ;
}
DECLARE_OOXMLEXPORT_TEST(testMultiColumnSeparator, "multi-column-separator-with-line.docx")
{
uno::Reference<beans::XPropertySet> xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(1, "First data."), "TextSection");
CPPUNIT_ASSERT(xTextSection.is());
uno::Reference<text::XTextColumns> xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount());
// Check for the Column Separator value.It should be TRUE as the document contains separator line.
bool bValue = getProperty< bool >(xTextColumns, "SeparatorLineIsOn");
CPPUNIT_ASSERT(bValue);
}
DECLARE_OOXMLEXPORT_TEST(testUnbalancedColumns, "unbalanced-columns.docx")
{
uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xTextSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY);
// This was false, last section was balanced, but it's unbalanced in Word.
CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xTextSections->getByIndex(2), "DontBalanceTextColumns"));
}
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -671,23 +671,6 @@ DECLARE_OOXMLIMPORT_TEST(testGroupshapeSdt, "groupshape-sdt.docx")
CPPUNIT_ASSERT_EQUAL(sal_Int32(20), getProperty<sal_Int32>(getRun(getParagraphOfText(1, xShape->getText()), 1), "CharKerning"));
}
DECLARE_OOXMLIMPORT_TEST(testDefaultSectBreakCols, "default-sect-break-cols.docx")
{
// First problem: the first two paragraphs did not have their own text section, so the whole document had two columns.
uno::Reference<beans::XPropertySet> xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(1, "First."), "TextSection");
CPPUNIT_ASSERT(xTextSection.is());
uno::Reference<text::XTextColumns> xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount());
// Second problem: the page style had two columns, while it shouldn't have any.
uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY);
xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xPageStyle, "TextColumns");
CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount());
// Check for the Column Separator value.It should be FALSE as the document does not contain separator line.
bool bValue = getProperty< bool >(xTextColumns, "SeparatorLineIsOn");
CPPUNIT_ASSERT(!bValue) ;
}
void lcl_countTextFrames(css::uno::Reference< lang::XComponent >& xComponent,
sal_Int32 nExpected )
{
......@@ -764,17 +747,6 @@ DECLARE_OOXMLIMPORT_TEST(testTdf75573_lostTable, "tdf75573_lostTable.docx")
CPPUNIT_ASSERT_EQUAL_MESSAGE("# of pages", 3, getPages() );
}
DECLARE_OOXMLIMPORT_TEST(testMultiColumnSeparator, "multi-column-separator-with-line.docx")
{
uno::Reference<beans::XPropertySet> xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(1, "First data."), "TextSection");
CPPUNIT_ASSERT(xTextSection.is());
uno::Reference<text::XTextColumns> xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount());
// Check for the Column Separator value.It should be TRUE as the document contains separator line.
bool bValue = getProperty< bool >(xTextColumns, "SeparatorLineIsOn");
CPPUNIT_ASSERT(bValue);
}
DECLARE_OOXMLIMPORT_TEST(lineWpsOnly, "line-wps-only.docx")
{
uno::Reference<drawing::XShape> xShape = getShape(1);
......@@ -939,14 +911,6 @@ DECLARE_OOXMLIMPORT_TEST(testFdo76803, "fdo76803.docx")
CPPUNIT_ASSERT_EQUAL(double(0), aPolygon.getB2DPoint(3).getY());
}
DECLARE_OOXMLIMPORT_TEST(testUnbalancedColumns, "unbalanced-columns.docx")
{
uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xTextSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY);
// This was false, last section was balanced, but it's unbalanced in Word.
CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xTextSections->getByIndex(2), "DontBalanceTextColumns"));
}
DECLARE_OOXMLIMPORT_TEST(testUnbalancedColumnsCompat, "unbalanced-columns-compat.docx")
{
uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
......
......@@ -1181,8 +1181,9 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
// depending on the break type no page styles should be created
// If the section type is missing, but we have columns without new style info, then this should be
// handled as a continuous section break.
const bool bTreatAsContinuous = m_nBreakType == -1
const bool bTreatAsContinuous = (m_nBreakType == -1 || m_nBreakType == NS_ooxml::LN_Value_ST_SectionMark_nextPage)
&& m_nColumnCount > 0
&& !HasHeader(m_bTitlePage) && !HasFooter(m_bTitlePage)
&& (m_bIsFirstSection || m_sFollowPageStyleName.isEmpty() || (m_sFirstPageStyleName.isEmpty() && m_bTitlePage));
if(m_nBreakType == static_cast<sal_Int32>(NS_ooxml::LN_Value_ST_SectionMark_continuous) || bTreatAsContinuous)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment