summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2016-12-20 15:54:18 +0300
committerJustin Luth <justin_luth@sil.org>2016-12-22 10:26:25 +0000
commit2a08419ef27afe756402eb18ffd2434a476c9bc5 (patch)
tree88bc848fceed8aaa2154b6adc19bdf3a46057068
parentb422df6e85c8a1cc232561189a69725c33dfbcd1 (diff)
tdf#104710 bRemove: only prevent w/BREAK_TYPE for defined Sections
fixes regression from fix for bug 103975 which prevented removal of empty paragraphs if there was a page/column break. This patch adds the requirement that there is also a defined SectionBreak. I did a bad thing with unit test rhbz988516 (which was re-used as the unit test for bug 103975). I didn't first check in MSWord to see how many pages it really ought to have, and when it started round-tripping with 3 pages I was happy. Well, the proper page count according to MSO is 2 (a hard page/break and Section/newPage combine to form a single pagebreak). Undoing the regression fixes that too. The regression was commit 7b250d56981f78e77454a2a3fd670731b2358e75 Change-Id: I15e9df2d260954f02a9e183d9f48c1d267494b49 Reviewed-on: https://gerrit.libreoffice.org/32236 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Reviewed-by: Justin Luth <justin_luth@sil.org> (cherry picked from commit e37563c304e52f1d2385868c9b33e0145493d2bd) Reviewed-on: https://gerrit.libreoffice.org/32328
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport9.cxx4
-rwxr-xr-xsw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakB.docxbin0 -> 13971 bytes
-rwxr-xr-xsw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakC.docxbin0 -> 13955 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx56
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx3
-rw-r--r--writerfilter/source/dmapper/PropertyMap.hxx2
6 files changed, 62 insertions, 3 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 8bf2b5b1383c..2668d34efba2 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -81,13 +81,13 @@ DECLARE_OOXMLEXPORT_TEST(testRhbz988516, "rhbz988516.docx")
{
// The problem was that the list properties of the footer leaked into body
CPPUNIT_ASSERT_EQUAL(OUString(), getProperty<OUString>(getParagraph(1), "NumberingStyleName"));
- CPPUNIT_ASSERT_EQUAL(OUString("Enclosure 3"), getParagraph(3)->getString());
+ CPPUNIT_ASSERT_EQUAL(OUString("Enclosure 3"), getParagraph(2)->getString());
CPPUNIT_ASSERT_EQUAL(OUString(), getProperty<OUString>(getParagraph(2), "NumberingStyleName"));
CPPUNIT_ASSERT_EQUAL(OUString(), getProperty<OUString>(getParagraph(3), "NumberingStyleName"));
CPPUNIT_ASSERT_EQUAL(OUString(), getProperty<OUString>(getParagraph(4), "NumberingStyleName"));
// tdf#103975 The problem was that an empty paragraph with page break info was removed.
- CPPUNIT_ASSERT_EQUAL( 3, getPages() );
+ CPPUNIT_ASSERT_EQUAL( 2, getPages() );
}
DECLARE_OOXMLEXPORT_TEST(testTdf103389, "tdf103389.docx")
diff --git a/sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakB.docx b/sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakB.docx
new file mode 100755
index 000000000000..a7b880d00e60
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakB.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakC.docx b/sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakC.docx
new file mode 100755
index 000000000000..52767abb8ce3
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakC.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 14be1f844911..eb45e2270a87 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -130,6 +130,62 @@ DECLARE_SW_IMPORT_TEST(testMathMalformedXml, "math-malformed_xml.docx", FailTest
CPPUNIT_ASSERT(!mxComponent.is());
}
+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.
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index f79ad82402f6..0a4041cfd495 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3276,10 +3276,11 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len)
// If the paragraph contains only the section properties and it has
// no runs, we should not create a paragraph for it in Writer, unless that would remove the whole section.
+ SectionPropertyMap* pSectionContext = m_pImpl->GetSectionContext();
bool bRemove = !m_pImpl->GetParaChanged() && m_pImpl->GetParaSectpr()
&& !bSingleParagraph
- && !( pContext && pContext->isSet(PROP_BREAK_TYPE) )
&& !m_pImpl->GetIsDummyParaAddedForTableInSection()
+ && !( pSectionContext && pSectionContext->GetBreakType() != -1 && pContext && pContext->isSet(PROP_BREAK_TYPE) )
&& !m_pImpl->GetIsPreviousParagraphFramed();
const bool bNoNumbering = bRemove || (!m_pImpl->GetParaChanged() && m_pImpl->GetParaSectpr() && bSingleParagraph);
diff --git a/writerfilter/source/dmapper/PropertyMap.hxx b/writerfilter/source/dmapper/PropertyMap.hxx
index efee54294c4f..9fe090273150 100644
--- a/writerfilter/source/dmapper/PropertyMap.hxx
+++ b/writerfilter/source/dmapper/PropertyMap.hxx
@@ -312,6 +312,8 @@ public:
void SetPageNumber( sal_Int32 nSet ) { m_nPageNumber = nSet; }
void SetPageNumberType(sal_Int32 nSet) { m_nPageNumberType = nSet; }
void SetBreakType( sal_Int32 nSet ) { m_nBreakType = nSet; }
+ // GetBreakType returns -1 if the breakType has not yet been identified for the section
+ sal_Int32 GetBreakType() { return m_nBreakType; }
void SetLeftMargin( sal_Int32 nSet ) { m_nLeftMargin = nSet; }
sal_Int32 GetLeftMargin() { return m_nLeftMargin; }