summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2017-04-11 21:01:45 +0300
committerJustin Luth <justin_luth@sil.org>2017-05-19 13:31:27 +0200
commitcee02e81cd3b55fb46eacf5db5713e8bf4363bcd (patch)
tree8e3bc5eddfc8d6ab18acd8ad278b5ccbc9b4eb27
parent5859c40d48108f2d0418ae073cf8df65da5b759c (diff)
ooxmlexport: roundtrip tdf#103975's unit tests
MS documentation for splitPgBreakAndParaMark only mentions page breaks, not column breaks. (Always Move Paragraph Mark to Page after a Page Break) This element specifies whether a page break shall automatically complete the line on which it appears, moving the end of the paragraph to a new line on the next page, or if it shall behave as true run-level content within its current paragraph. Typically, a page break defined using the br element is treated as run-level content, which means that although it delimits the end of the page, if there is no content after it within the current paragraph, that the paragraph shall also end on that page. This element, when present with a val attribute value of true (or equivalent), specifies that a page break shall always immediately end the current page, moving the paragraph mark which delimits the end of its parent paragraph to a new line on the next page. Note that this setting only affects the case where there is no run-level content after the page break within the paragraph - if any further run content appears in the paragraph it shall appear on subsequent lines on the next page I borrowed the !footnote code from the if newline ELSE section. It seemed appropriate to take the same precautions here. || bSingleParagraph was added specifically for COLUMN_BREAK. That is obsolete now, so removing. There is a lot of old code here that I have questions about. I tried to change as little as possible, but likely lots of the existing logic is just wrong. Change-Id: Ib988c6623acb2b6152118098b706314bfbfb99e3 Reviewed-on: https://gerrit.libreoffice.org/36421 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Justin Luth <justin_luth@sil.org>
-rwxr-xr-xsw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakB.docx (renamed from sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakB.docx)bin13971 -> 13971 bytes
-rwxr-xr-xsw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakC.docx (renamed from sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakC.docx)bin13955 -> 13955 bytes
-rwxr-xr-xsw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakD.docx (renamed from sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakD.docx)bin21482 -> 21482 bytes
-rwxr-xr-xsw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakE.docx (renamed from sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakE.docx)bin14047 -> 14047 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport9.cxx71
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx70
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx12
7 files changed, 80 insertions, 73 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakB.docx b/sw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakB.docx
index a7b880d00e60..a7b880d00e60 100755
--- a/sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakB.docx
+++ b/sw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakB.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakC.docx b/sw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakC.docx
index 52767abb8ce3..52767abb8ce3 100755
--- a/sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakC.docx
+++ b/sw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakC.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakD.docx b/sw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakD.docx
index 37c752499f08..37c752499f08 100755
--- a/sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakD.docx
+++ b/sw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakD.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakE.docx b/sw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakE.docx
index ac3eb9f7c7ff..ac3eb9f7c7ff 100755
--- a/sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakE.docx
+++ b/sw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakE.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 186f7a8d1eb9..d38a6ff46364 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -19,6 +19,7 @@
#include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
+#include <com/sun/star/style/BreakType.hpp>
#include <com/sun/star/style/PageStyleLayout.hpp>
#include <com/sun/star/text/HoriOrientation.hpp>
#include <com/sun/star/text/RelOrientation.hpp>
@@ -259,6 +260,76 @@ DECLARE_OOXMLEXPORT_TEST(testRhbz988516, "rhbz988516.docx")
CPPUNIT_ASSERT_EQUAL( 2, getPages() );
}
+DECLARE_OOXMLEXPORT_TEST(testTdf103975_notPageBreakB, "tdf103975_notPageBreakB.docx")
+{
+ // turn on View Formatting Marks to see these documents.
+ uno::Reference<beans::XPropertySet> xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(1), "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());
+
+ xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(2), "TextSection");
+ CPPUNIT_ASSERT(xTextSection.is());
+ xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount());
+
+ xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(3), "TextSection");
+ CPPUNIT_ASSERT(xTextSection.is());
+ xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount());
+
+ xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(4), "TextSection");
+ CPPUNIT_ASSERT(xTextSection.is());
+ xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount());
+
+ CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty<style::BreakType>(getParagraph(2), "BreakType"));
+ CPPUNIT_ASSERT_EQUAL( 4, getParagraphs() );
+ CPPUNIT_ASSERT_EQUAL( 1, getPages() );
+}
+
+DECLARE_OOXMLEXPORT_TEST(testTdf103975_notPageBreakC, "tdf103975_notPageBreakC.docx")
+{
+ // turn on View Formatting Marks to see these documents.
+ uno::Reference<beans::XPropertySet> xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(1), "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());
+
+ xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(2), "TextSection");
+ CPPUNIT_ASSERT(xTextSection.is());
+ xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount());
+
+ xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(3), "TextSection");
+ CPPUNIT_ASSERT(xTextSection.is());
+ xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount());
+
+ xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(4), "TextSection");
+ CPPUNIT_ASSERT(xTextSection.is());
+ xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount());
+
+ CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty<style::BreakType>(getParagraph(2), "BreakType"));
+ CPPUNIT_ASSERT_EQUAL( 4, getParagraphs() );
+ CPPUNIT_ASSERT_EQUAL( 1, getPages() );
+}
+
+DECLARE_OOXMLEXPORT_TEST(testTdf103975_notPageBreakD, "tdf103975_notPageBreakD.docx")
+{
+ // The problem was that the column break was moving outside of the columns, making a page break.
+ CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty<style::BreakType>(getParagraph(2), "BreakType"));
+ CPPUNIT_ASSERT_EQUAL( 1, getPages() );
+}
+
+DECLARE_OOXMLEXPORT_TEST(testTdf103975_notPageBreakE, "tdf103975_notPageBreakE.docx")
+{
+ // The problem was that the column break was getting lost.
+ CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty<style::BreakType>(getParagraph(2), "BreakType"));
+}
+
+
DECLARE_OOXMLEXPORT_TEST(testTdf103389, "tdf103389.docx")
{
xmlDocPtr pXmlDoc = parseExport("word/document.xml");
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 90e36f1ef593..dee3ad3d3596 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -26,7 +26,6 @@
#include <com/sun/star/drawing/PointSequenceSequence.hpp>
#include <com/sun/star/drawing/GraphicExportFilter.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/style/BreakType.hpp>
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <com/sun/star/text/HoriOrientation.hpp>
#include <com/sun/star/text/RelOrientation.hpp>
@@ -142,75 +141,6 @@ DECLARE_OOXMLIMPORT_TEST(testTdf103931, "tdf103931.docx")
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), xTextSections->getCount());
}
-DECLARE_OOXMLIMPORT_TEST(testTdf103975_notPageBreakB, "tdf103975_notPageBreakB.docx")
-{
- // turn on View Formatting Marks to see these documents.
- uno::Reference<beans::XPropertySet> xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(1), "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());
-
- xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(2), "TextSection");
- CPPUNIT_ASSERT(xTextSection.is());
- xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
- CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount());
-
- xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(3), "TextSection");
- CPPUNIT_ASSERT(xTextSection.is());
- xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
- CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount());
-
- xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(4), "TextSection");
- CPPUNIT_ASSERT(xTextSection.is());
- xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
- CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount());
-
- CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty<style::BreakType>(getParagraph(2), "BreakType"));
- CPPUNIT_ASSERT_EQUAL( 4, getParagraphs() );
- CPPUNIT_ASSERT_EQUAL( 1, getPages() );
-}
-
-DECLARE_OOXMLIMPORT_TEST(testTdf103975_notPageBreakC, "tdf103975_notPageBreakC.docx")
-{
- // turn on View Formatting Marks to see these documents.
- uno::Reference<beans::XPropertySet> xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(1), "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());
-
- xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(2), "TextSection");
- CPPUNIT_ASSERT(xTextSection.is());
- xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
- CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount());
-
- xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(3), "TextSection");
- CPPUNIT_ASSERT(xTextSection.is());
- xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
- CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount());
-
- xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(4), "TextSection");
- CPPUNIT_ASSERT(xTextSection.is());
- xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
- CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount());
-
- CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty<style::BreakType>(getParagraph(2), "BreakType"));
- CPPUNIT_ASSERT_EQUAL( 4, getParagraphs() );
- CPPUNIT_ASSERT_EQUAL( 1, getPages() );
-}
-
-DECLARE_OOXMLIMPORT_TEST(testTdf103975_notPageBreakD, "tdf103975_notPageBreakD.docx")
-{
- // The problem was that the column break was moving outside of the columns, making a page break.
- CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty<style::BreakType>(getParagraph(2), "BreakType"));
- CPPUNIT_ASSERT_EQUAL( 1, getPages() );
-}
-
-DECLARE_OOXMLIMPORT_TEST(testTdf103975_notPageBreakE, "tdf103975_notPageBreakE.docx")
-{
- // The problem was that the column break was getting lost.
- CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty<style::BreakType>(getParagraph(2), "BreakType"));
-}
-
DECLARE_OOXMLIMPORT_TEST(testN751017, "n751017.docx")
{
uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 2f3df2fa01fc..95db1c41a893 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3306,10 +3306,16 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len)
const bool bSingleParagraph = m_pImpl->GetIsFirstParagraphInSection() && m_pImpl->GetIsLastParagraphInSection();
PropertyMapPtr pContext = m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH);
- if (pContext && (m_pImpl->GetSettingsTable()->GetSplitPgBreakAndParaMark() || bSingleParagraph))
+ if (pContext && !pContext->GetFootnote().is())
{
if (m_pImpl->isBreakDeferred(PAGE_BREAK))
- pContext->Insert(PROP_BREAK_TYPE, uno::makeAny(style::BreakType_PAGE_BEFORE));
+ {
+ if (m_pImpl->GetSettingsTable()->GetSplitPgBreakAndParaMark())
+ {
+ pContext->Insert(PROP_BREAK_TYPE, uno::makeAny(style::BreakType_PAGE_BEFORE));
+ m_pImpl->clearDeferredBreaks();
+ }
+ }
else if (m_pImpl->isBreakDeferred(COLUMN_BREAK))
{
if ( m_pImpl->GetIsFirstParagraphInSection() || !m_pImpl->IsFirstRun() )
@@ -3320,8 +3326,8 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len)
}
pContext->Insert(PROP_BREAK_TYPE, uno::makeAny(style::BreakType_COLUMN_BEFORE));
+ m_pImpl->clearDeferredBreaks();
}
- m_pImpl->clearDeferredBreaks();
}
// If the paragraph contains only the section properties and it has