sw/source/core/txtnode/ndtxt.cxx |   20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

New commits:
commit 5dbf1cbc9bfc0e930edc470e93bf27148635dd5f
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Tue Dec 13 20:35:07 2022 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Fri Dec 16 13:31:13 2022 +0000

    (related: tdf#149595) sw: also re-sort SwSortedObjs on SwPageFrame
    
    ... if SwTextNode content changes; for the unit test here we get:
    
      Error: elements in iterator range [first, last) are not partitioned by
      the predicate __comp and value __val.
    
    Also, the SwTextNode may have multiple text frames on multiple pages.
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144108
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit c684301352bcca709bc8d1c99e0f08e7096e9716)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144131
    Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
    (cherry picked from commit 2033a23379c0eb9d6de41c7b1473769fda2cc632)
    
    Change-Id: I05d4276e4b4b94fe3cd2cdfda3418ad51fa08f5f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144288
    Tested-by: Michael Stahl <michael.st...@allotropia.de>
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index ed1e19bd5ce7..ce533a220bd9 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -64,6 +64,7 @@
 #include <txtfrm.hxx>
 #include <ftnfrm.hxx>
 #include <ftnboss.hxx>
+#include <pagefrm.hxx>
 #include <rootfrm.hxx>
 #include <pagedesc.hxx>
 #include <expfld.hxx>
@@ -1533,10 +1534,21 @@ void SwTextNode::Update(
 
     //Any drawing objects anchored into this text node may be sorted by their
     //anchor position which may have changed here, so resort them
-    SwContentFrame* pContentFrame = 
getLayoutFrame(GetDoc()->getIDocumentLayoutAccess().GetCurrentLayout());
-    SwSortedObjs* pSortedObjs = pContentFrame ? pContentFrame->GetDrawObjs() : 
nullptr;
-    if (pSortedObjs)
-        pSortedObjs->UpdateAll();
+    SwIterator<SwTextFrame, SwTextNode, sw::IteratorMode::UnwrapMulti> 
iter(*this);
+    for (SwTextFrame* pFrame = iter.First(); pFrame; pFrame = iter.Next())
+    {
+        SwSortedObjs * pSortedObjs(pFrame->GetDrawObjs());
+        if (pSortedObjs)
+        {
+            pSortedObjs->UpdateAll();
+        }
+        // also sort the objs on the page frame
+        pSortedObjs = pFrame->FindPageFrame()->GetSortedObjs();
+        if (pSortedObjs) // doesn't exist yet if called for inserting as-char 
fly
+        {
+            pSortedObjs->UpdateAll();
+        }
+    }
 
     // Update the paragraph signatures.
     if (SwEditShell* pEditShell = GetDoc()->GetEditShell())

Reply via email to