sw/qa/extras/ooxmlexport/data/tdf153592_columnBreaks.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx                |    9 +++++++++
 writerfilter/source/dmapper/DomainMapper.cxx              |    6 +++---
 3 files changed, 12 insertions(+), 3 deletions(-)

New commits:
commit 4bbc9a09c99a818496a4b9752cf3496fde11ccf7
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Mon Feb 13 13:35:47 2023 -0500
Commit:     Justin Luth <jl...@mail.com>
CommitDate: Wed Mar 8 17:12:53 2023 +0000

    tdf#153592 writerfilter: don't defer breaks into shapes/comments
    
    When starting a pargraph, we already had a clause to avoid
    deferring page and column breaks when we were in a shape
    or a comment. These clauses are also necessary
    in the other sections of the code where we defer these breaks.
    
    The provided test proves the two shape cases in lcl_utext.
    I just took IsInComments along for the ride,
    as it certainly would apply in that case as well.
    
    make CppunitTest_sw_ooxmlexport18 
CPPUNIT_TEST_NAME=testTdf153592_columnBreaks
    
    ooxmlexport4's testTdf81345_045Original proves that it is
    also needed in lcl_text. However, it is such a complex document
    that I wasn't confident that a unit test would be stable enough.
    
    Change-Id: I2de15341d3e756bf47fcd85b868a849c8a2419cd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146939
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146965
    Tested-by: Justin Luth <jl...@mail.com>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf153592_columnBreaks.docx 
b/sw/qa/extras/ooxmlexport/data/tdf153592_columnBreaks.docx
new file mode 100644
index 000000000000..ea6acac29b5b
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf153592_columnBreaks.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index 06dc588a37c7..d5121944c354 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -93,6 +93,15 @@ DECLARE_OOXMLEXPORT_TEST(testTdf153613_sdtAfterPgBreak, 
"tdf153613_sdtAfterPgBre
     CPPUNIT_ASSERT_EQUAL(2, getPages());
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf153592_columnBreaks)
+{
+    loadAndSave("tdf153592_columnBreaks.docx");
+
+    xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+    // The two column breaks were lost on import. (I wouldn't complain if they 
were at 3,5)
+    assertXPath(pXmlDoc, "//w:br", 2);
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf149551_mongolianVert)
 {
     // Given a docx document with a shape with vert="mongolianVert".
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index 46060b2d9950..d7879ba5e402 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3770,7 +3770,7 @@ void DomainMapper::lcl_text(const sal_uInt8 * data_, 
size_t len)
             m_pImpl->appendTextPortion("\n", pContext);
         }
 
-        if (!m_pImpl->GetFootnoteContext())
+        if (!m_pImpl->GetFootnoteContext() && !m_pImpl->IsInShape() && 
!m_pImpl->IsInComments())
         {
             if (m_pImpl->isBreakDeferred(PAGE_BREAK))
                 m_pImpl->GetTopContext()->Insert(PROP_BREAK_TYPE, 
uno::Any(style::BreakType_PAGE_BEFORE));
@@ -4092,7 +4092,7 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, 
size_t len)
             const bool bSingleParagraphAfterRedline = 
m_pImpl->GetIsFirstParagraphInSection(/*bAfterRedline=*/true) &&
                     m_pImpl->GetIsLastParagraphInSection();
             PropertyMapPtr pContext = 
m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH);
-            if (!m_pImpl->GetFootnoteContext())
+            if (!m_pImpl->GetFootnoteContext() && !m_pImpl->IsInShape() && 
!m_pImpl->IsInComments())
             {
                 if (m_pImpl->isBreakDeferred(PAGE_BREAK))
                 {
@@ -4168,7 +4168,7 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, 
size_t len)
         {
             // GetTopContext() is changed by inserted breaks, but we want to 
keep the current context
             PropertyMapPtr pContext = m_pImpl->GetTopContext();
-            if (!m_pImpl->GetFootnoteContext())
+            if (!m_pImpl->GetFootnoteContext() && !m_pImpl->IsInShape() && 
!m_pImpl->IsInComments())
             {
                 if (m_pImpl->isBreakDeferred(PAGE_BREAK))
                 {

Reply via email to