sw/qa/extras/ooxmlexport/ooxmlexport9.cxx | 4 sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakB.docx |binary sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakC.docx |binary sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 56 +++++++++++++ writerfilter/source/dmapper/DomainMapper.cxx | 3 writerfilter/source/dmapper/PropertyMap.hxx | 2 6 files changed, 62 insertions(+), 3 deletions(-)
New commits: commit e37563c304e52f1d2385868c9b33e0145493d2bd Author: Justin Luth <justin_l...@sil.org> Date: Tue Dec 20 15:54:18 2016 +0300 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 <c...@libreoffice.org> Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> Reviewed-by: Justin Luth <justin_l...@sil.org> diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx index 1e20ff4..002d064 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 0000000..a7b880d Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakB.docx 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 0000000..52767ab Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakC.docx differ diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 14be1f8..eb45e22 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 f79ad82..0a4041c 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 efee542..9fe0902 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; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits