sw/qa/extras/layout/data/tdf150606-1-min.odt |binary
 sw/qa/extras/layout/layout.cxx               |   65 +++++++++++++++++++++++++++
 sw/source/core/layout/fly.cxx                |    6 ++
 3 files changed, 70 insertions(+), 1 deletion(-)

New commits:
commit 560b94971b656914d17c9d1befdad2dbd3f1119a
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Thu Jun 1 12:45:20 2023 +0200
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Fri Jun 23 22:50:29 2023 +0200

    tdf#150606 sw: layout: leave follow SwTabFrame invalid in columns
    
    With the minimised bugdoc, on Undo, some 12 or so pages are created, and
    the end of the deleted table is shown in the document view.
    
    So first the last pages are layouted, and then once those are done
    layout proceeds from page 1.
    
    The problem is that on page 9, a table remains in the 2nd column of the
    section, and there is nothing in the 1st column and on pages 5-8.
    
    This is because ::CalcContent() is the last thing that formats the table
    on page 9, and it explicitly disables MoveBwd() for follow tables via
    m_bLockBackMove.
    
    That appears to be intentional but because it's already been there since
    initial CVS import it's unclear why; it might be based on the assumption
    that a previous column would have moved over rows from the follow table
    already.
    
    Try to encourage the table to try to MoveBwd() at a later time, when
    it's being formatted from the SwLayAction::FormatContent_() loop, which
    appears to help.
    
    (somehow regression from commit 723728cd358693b8f4bc9d913541aa4479f2bd48)
    
    Change-Id: I421525269948aa58888f5302e6db234c89230f00
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152485
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit 5a739d98d0efa5be2130b7d758d494012abc87b3)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152446
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sw/qa/extras/layout/data/tdf150606-1-min.odt 
b/sw/qa/extras/layout/data/tdf150606-1-min.odt
new file mode 100644
index 000000000000..63bd1ceb0a5b
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf150606-1-min.odt differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 587fa4d4294e..d4979120be0e 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -1200,6 +1200,71 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, 
testRedlineFlysInHeader)
     }
 }
 
+#if !defined(MACOSX)
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf150606)
+{
+    createSwDoc("tdf150606-1-min.odt");
+
+    SwXTextDocument* pTextDoc = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
+    CPPUNIT_ASSERT(pTextDoc);
+    SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+
+    xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+
+    assertXPath(pXmlDoc, "/root/page[1]/body/section/column[1]/body/tab", 1);
+    assertXPath(pXmlDoc, "/root/page[1]/body/section/column[2]/body/tab", 1);
+    assertXPath(pXmlDoc, "/root/page[1]/body/section/column", 2);
+    assertXPath(pXmlDoc, "/root/page[2]/body/section/column[1]/body/tab", 1);
+    assertXPath(pXmlDoc, "/root/page[2]/body/section/column[2]/body/tab", 1);
+    assertXPath(pXmlDoc, "/root/page[2]/body/section/column", 2);
+    assertXPath(pXmlDoc, "/root/page[3]/body/section/column[1]/body/tab", 1);
+    assertXPath(pXmlDoc, "/root/page[3]/body/section/column[2]/body/tab", 1);
+    assertXPath(pXmlDoc, "/root/page[3]/body/section/column", 2);
+    assertXPath(pXmlDoc, "/root/page[4]/body/section/column[1]/body/tab", 1);
+    assertXPath(pXmlDoc, "/root/page[4]/body/section/column[2]/body/tab", 1);
+    assertXPath(pXmlDoc, "/root/page[4]/body/section/column", 2);
+    // on page 5 the table is split across balanced columns
+    assertXPath(pXmlDoc, "/root/page[5]/body/section/column[1]/body/tab", 1);
+    assertXPath(pXmlDoc, "/root/page[5]/body/section/column[2]/body/tab", 1);
+    assertXPath(pXmlDoc, "/root/page[5]/body/section/column", 2);
+    assertXPath(pXmlDoc, "/root/page", 5);
+
+    pWrtShell->Down(false, 1);
+    dispatchCommand(mxComponent, ".uno:DeleteTable", {});
+
+    discardDumpedLayout();
+    pXmlDoc = parseLayoutDump();
+
+    assertXPath(pXmlDoc, "/root/page[1]/body/section/column/body/tab", 0);
+    assertXPath(pXmlDoc, "/root/page", 1);
+
+    pWrtShell->Undo();
+    Scheduler::ProcessEventsToIdle();
+
+    discardDumpedLayout();
+    pXmlDoc = parseLayoutDump();
+
+    assertXPath(pXmlDoc, "/root/page[1]/body/section/column[1]/body/tab", 1);
+    assertXPath(pXmlDoc, "/root/page[1]/body/section/column[2]/body/tab", 1);
+    assertXPath(pXmlDoc, "/root/page[1]/body/section/column", 2);
+    assertXPath(pXmlDoc, "/root/page[2]/body/section/column[1]/body/tab", 1);
+    assertXPath(pXmlDoc, "/root/page[2]/body/section/column[2]/body/tab", 1);
+    assertXPath(pXmlDoc, "/root/page[2]/body/section/column", 2);
+    assertXPath(pXmlDoc, "/root/page[3]/body/section/column[1]/body/tab", 1);
+    assertXPath(pXmlDoc, "/root/page[3]/body/section/column[2]/body/tab", 1);
+    assertXPath(pXmlDoc, "/root/page[3]/body/section/column", 2);
+    assertXPath(pXmlDoc, "/root/page[4]/body/section/column[1]/body/tab", 1);
+    assertXPath(pXmlDoc, "/root/page[4]/body/section/column[2]/body/tab", 1);
+    assertXPath(pXmlDoc, "/root/page[4]/body/section/column", 2);
+    // on page 5 the table is split across balanced columns
+    // (problem was that there were empty pages and table was on page 10)
+    assertXPath(pXmlDoc, "/root/page[5]/body/section/column[1]/body/tab", 1);
+    assertXPath(pXmlDoc, "/root/page[5]/body/section/column[2]/body/tab", 1);
+    assertXPath(pXmlDoc, "/root/page[5]/body/section/column", 2);
+    assertXPath(pXmlDoc, "/root/page", 5);
+}
+#endif
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf137025)
 {
     // Check the padding of the textbox
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index 09834d7defd0..d1d023dbf3ed 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -1679,8 +1679,12 @@ void CalcContent( SwLayoutFrame *pLay, bool bNoColl )
             }
             if ( pFrame->IsTabFrame() )
             {
-                if ( static_cast<SwTabFrame*>(pFrame)->IsFollow() )
+                if (static_cast<SwTabFrame*>(pFrame)->m_bLockBackMove)
+                {
+                    assert(static_cast<SwTabFrame*>(pFrame)->IsFollow());
                     static_cast<SwTabFrame*>(pFrame)->m_bLockBackMove = false;
+                    pFrame->InvalidatePos();
+                }
             }
 
             pFrame = bPrevInvalid ? pTmpPrev : pFrame->FindNext();

Reply via email to