desktop/source/lib/init.cxx                           |   20 --------------
 sw/qa/core/layout/data/floattable-deleted-anchor.docx |binary
 sw/qa/core/layout/flycnt.cxx                          |   25 ++++++++++++++++++
 sw/source/core/text/frmform.cxx                       |   13 ++++++++-
 4 files changed, 37 insertions(+), 21 deletions(-)

New commits:
commit 73bada774ef37efd5a4498ccc083b1358314557d
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Wed Apr 26 11:44:43 2023 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Wed Apr 26 14:58:51 2023 +0200

    sw floattable, crashtesting: fix PDF export of fdo72790-1.docx, part 3
    
    Converting the bugdoc to PDF crashed Writer layout since commit
    ce3308a926f036b87515b8cd97d2b197063dc77a (tdf#61594 sw floattable:
    import floating tables as split flys by default, 2023-04-12).
    
    Part 1 already fixed the crash, but a layout loop remains. The current
    problem is that we could have a document of 3 pages where the last page
    had no anchor for the fly frame, so it took the anchor from the previous
    page, but this lead to negative frame heights and at the end an empty
    3rd page.
    
    To fix the problem:
    
    1) Make sure SwTextFrame::FormatAdjust() doesn't break the invariant
       that only the last frame of a floattable anchor has text content.
    
    2) Make sure SwTextFrame::AdjustFollow_() doesn't join a frame that
       still hosts non-last split flys.
    
    With this, we have exactly 3 anchor frames (in a flow frame chain) for
    the 3 pages and the 3rd page looks correct. The original document still
    needs more work to fix the layout loop, though.
    
    Change-Id: I2fc9c4728fdf191ac5b5b435a10d553a699bae75
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151048
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins

diff --git a/sw/qa/core/layout/data/floattable-deleted-anchor.docx 
b/sw/qa/core/layout/data/floattable-deleted-anchor.docx
new file mode 100644
index 000000000000..cab5b68ff94d
Binary files /dev/null and 
b/sw/qa/core/layout/data/floattable-deleted-anchor.docx differ
diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx
index bd3e98a38a62..1ad1443dd392 100644
--- a/sw/qa/core/layout/flycnt.cxx
+++ b/sw/qa/core/layout/flycnt.cxx
@@ -737,6 +737,31 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyTableRowKeep)
     auto pCell3 = dynamic_cast<SwCellFrame*>(pRow3->GetLower());
     CPPUNIT_ASSERT(pCell3->GetFollowCell());
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testSplitFlyDeletedAnchor)
+{
+    // Given a document with a floating table that spans over 3 pages:
+    createSwDoc("floattable-deleted-anchor.docx");
+
+    // When laying out that document:
+    calcLayout();
+
+    // Then make sure that there are 3 anchors for the 3 pages:
+    SwDoc* pDoc = getSwDoc();
+    SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+    auto pPage1 = dynamic_cast<SwPageFrame*>(pLayout->Lower());
+    CPPUNIT_ASSERT(pPage1);
+    SwFrame* pBody1 = pPage1->GetLower();
+    CPPUNIT_ASSERT(pBody1);
+    auto pAnchor1 = dynamic_cast<SwTextFrame*>(pBody1->GetLower()->GetNext());
+    CPPUNIT_ASSERT(pAnchor1);
+    SwTextFrame* pAnchor2 = pAnchor1->GetFollow();
+    CPPUNIT_ASSERT(pAnchor2);
+    SwTextFrame* pAnchor3 = pAnchor2->GetFollow();
+    // Without the accompanying fix in place, this test would have failed, the 
fly frame on the 3rd
+    // page was anchored to a text frame on the 2nd page, leading to a 
negative frame height.
+    CPPUNIT_ASSERT(pAnchor3);
+}
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/text/frmform.cxx b/sw/source/core/text/frmform.cxx
index 2f3024f1bb0a..912047487a64 100644
--- a/sw/source/core/text/frmform.cxx
+++ b/sw/source/core/text/frmform.cxx
@@ -633,6 +633,13 @@ void SwTextFrame::AdjustFollow_( SwTextFormatter &rLine,
         while( GetFollow() && GetFollow()->GetFollow() &&
                nNewOfst >= GetFollow()->GetFollow()->GetOffset() )
         {
+            if (HasNonLastSplitFlyDrawObj())
+            {
+                // A non-last split fly is anchored to us, don't move content 
from the last frame to
+                // this one and don't join.
+                return;
+            }
+
             JoinFrame();
         }
     }
@@ -1109,7 +1116,11 @@ void SwTextFrame::FormatAdjust( SwTextFormatter &rLine,
         // AdjustFollow might execute JoinFrame() because of this.
         // Else, nEnd is the end of the last line in the Master.
         TextFrameIndex nOld = nEnd;
-        nEnd = rLine.GetEnd();
+        // Make sure content from the last floating table anchor is not 
shifted to previous anchors.
+        if (!HasNonLastSplitFlyDrawObj())
+        {
+            nEnd = rLine.GetEnd();
+        }
         if( GetFollow() )
         {
             if( nNew && nOld < nEnd )
commit 4348f878284b53fa4e8ca670a8461a30ad0cba70
Author:     Tor Lillqvist <t...@collabora.com>
AuthorDate: Wed Apr 26 13:03:16 2023 +0300
Commit:     Tor Lillqvist <t...@collabora.com>
CommitDate: Wed Apr 26 14:58:48 2023 +0200

    Bin leftover dead code
    
    Change-Id: Ie0583d52b01bba92e6fc41f0fee3fd4732f1d479
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151054
    Tested-by: Jenkins
    Reviewed-by: Tor Lillqvist <t...@collabora.com>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index bd9ecf36cd1d..af31b1829163 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -7868,26 +7868,6 @@ static void lo_destroy(LibreOfficeKit* pThis)
     SAL_INFO("lok", "LO Destroy Done");
 }
 
-#ifdef IOS
-
-// Used by the unmaintained LibreOfficeLight app. Once that has been retired, 
get rid of this, too.
-
-__attribute__((visibility("default")))
-void temporaryHackToInvokeCallbackHandlers(LibreOfficeKitDocument* pThis)
-{
-    SolarMutexGuard aGuard;
-    LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
-
-    int nOrigViewId = doc_getView(pThis);
-
-    if (nOrigViewId >= 0 && pDocument->mpCallbackFlushHandlers[nOrigViewId])
-    {
-        pDocument->mpCallbackFlushHandlers[nOrigViewId]->Invoke();
-    }
-}
-
-#endif
-
 } // extern "C"
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to