sw/qa/extras/ooxmlexport/data/tdf149313.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport12.cxx   |    2 ++
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx   |   13 +++++++++++++
 writerfilter/source/dmapper/DomainMapper.cxx |   14 ++++++++++++--
 4 files changed, 27 insertions(+), 2 deletions(-)

New commits:
commit a4ab155ae15e9e6d4deb157634f8b86c87fcbde4
Author:     Vasily Melenchuk <vasily.melenc...@cib.de>
AuthorDate: Thu Jun 16 12:16:33 2022 +0300
Commit:     Thorsten Behrens <thorsten.behr...@allotropia.de>
CommitDate: Tue Jul 12 21:16:48 2022 +0200

    tdf#149313: DOCX import: improved conditions for removeparagraph
    
    Quite complex conditions to define if current paragraph can be
    removed for document were forcing to keep paragraphs after page
    break with only section definition. Usually these pars are removed,
    but since tdf#103975 fix they were kept.
    
    It looks like to resolve that problem will be enough to ensure
    current break is a column break: they are bit different and
    processed in a different way unlike other break types.
    
    So this condition part instead of "do not remove par with section
    info after any break" it is right now "do not remove par after
    column break".
    
    Change-Id: Ib6290dc6254430883a598bef3ecd1f7ab7063922
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135969
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <justin_l...@sil.org>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf149313.docx 
b/sw/qa/extras/ooxmlexport/data/tdf149313.docx
new file mode 100644
index 000000000000..4c0c454b42a6
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf149313.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
index 5573a1b1adf2..d027706de65d 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
@@ -689,6 +689,8 @@ DECLARE_OOXMLEXPORT_TEST(testTdf112202, 
"090716_Studentische_Arbeit_VWS.docx")
     assertXPath(pXmlDoc, "/root/page[3]/header/tab", 1);
     assertXPath(pXmlDoc, "/root/page[3]/header/tab/row/cell/txt/Text", 0);
     assertXPath(pXmlDoc, "/root/page[3]/header//anchored", 0);
+    // tdf#149313: ensure 3rd page does not have extra empty paragraph at top
+    assertXPathContent(pXmlDoc, "/root/page[3]/body//txt", "AUFGABENSTELLUNG");
 
     // page 4 header: 1 table, 1 paragraph, with text
     assertXPath(pXmlDoc, "/root/page[4]/header/txt", 1);
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index 496a7cfaed02..93ad3abf2da6 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -1018,6 +1018,19 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf149200)
     CPPUNIT_ASSERT_EQUAL(OUString("dark1"), getXPath(pXmlDoc, 
"/w:document/w:body/w:p[1]/w:r[1]/w:rPr/w:color", "themeColor"));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf149313, "tdf149313.docx")
+{
+    // only 2, but not 3 pages in document
+    CPPUNIT_ASSERT_EQUAL(2, getPages());
+
+    xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+    // And ensure that pages are with correct sections (have correct 
dimensions)
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(4989), getXPath(pXmlDoc, 
"/root/page[1]/infos/bounds", "height").toInt32());
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(4989), getXPath(pXmlDoc, 
"/root/page[1]/infos/bounds", "width").toInt32());
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(4989), getXPath(pXmlDoc, 
"/root/page[2]/infos/bounds", "height").toInt32());
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(8000), getXPath(pXmlDoc, 
"/root/page[2]/infos/bounds", "width").toInt32());
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf135923, "tdf135923-min.docx")
 {
     uno::Reference<text::XText> xShape(getShape(1), uno::UNO_QUERY);
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index 713412ccfa94..d940d09ffd34 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3892,13 +3892,23 @@ 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();
+            // Also do not remove here column breaks: they are treated in a 
different way and place.
+            bool bIsColumnBreak = false;
+            if (pContext->isSet(PROP_BREAK_TYPE))
+            {
+                const uno::Any aBreakType = 
pContext->getProperty(PROP_BREAK_TYPE)->second;
+                bIsColumnBreak =
+                    aBreakType == style::BreakType_COLUMN_BEFORE ||
+                    aBreakType == style::BreakType_COLUMN_AFTER ||
+                    aBreakType == style::BreakType_COLUMN_BOTH;
+            }
+
             bool bRemove = (!m_pImpl->GetParaChanged() && 
m_pImpl->GetRemoveThisPara()) ||
                            (!m_pImpl->GetParaChanged() && 
m_pImpl->GetParaSectpr()
                             && !bSingleParagraphAfterRedline
+                            && !bIsColumnBreak
                             && !m_pImpl->GetParaHadField()
                             && 
(!m_pImpl->GetIsDummyParaAddedForTableInSectionPage())
-                            && !( pSectionContext && 
pSectionContext->GetBreakType() != -1 && pContext && 
pContext->isSet(PROP_BREAK_TYPE) )
                             && !m_pImpl->GetIsPreviousParagraphFramed()
                             && !m_pImpl->HasTopAnchoredObjects()
                             && !m_pImpl->IsParaWithInlineObject());

Reply via email to