[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-1+backports' - sw/source

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Thu May 7 11:11:25 UTC 2020


 sw/source/core/doc/DocumentContentOperationsManager.cxx |   36 +++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)

New commits:
commit c6fbffea11aee015f941403f6613b964b01c1947
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Mon May 4 14:22:09 2020 +0200
Commit:     Michael Stahl <michael.stahl at cib.de>
CommitDate: Thu May 7 13:10:53 2020 +0200

    tdf#132187 sw: fix creation of frames on end node in CopyWithFlyInFly()
    
    The problem is that the rInsPos node is included in the range passed to
    MakeFrames(), but it already has a frame, so now it has 2 and that
    means the next call to MakeFrames() in this position will create all the
    frames twice.
    
    This is tricky because while in practice there is currently only one
    layout in theory there could be multiple, and then it could happen that
    RecreateStartTextFrames() will destroy the node's frame in one layout
    but not the other, while MakeFrames() always works on all layouts.
    
    Fix this by checking if all the existing frames survive
    RecreateStartTextFrames() and if it's not the case (like in tdf#130685)
    explicitly delete all the frames and including the node in MakeFrames().
    
    (regression from 166b5010b402a41b192b1659093a25acf9065fd9)
    
    Change-Id: I1bba11da053fe1c6359b2f76f3a352e44c6a2a1d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93416
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>
    (cherry picked from commit 49f26e7dae550aff6ca90b3cda7f89e11ac8cfd4)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93375
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    (cherry picked from commit d8bea028093fe3d4c0c0af0afad20c2c03bb9855)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93538
    Tested-by: Michael Stahl <michael.stahl at cib.de>

diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 693b965b3b9b..b3243bd0e624 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -3324,6 +3324,7 @@ void DocumentContentOperationsManager::CopyWithFlyInFly(
 
     {
         bool bEndIsEqualEndPos = rInsPos == rRg.aEnd;
+        bool isRecreateEndNode(false);
         --aSavePos;
         SaveRedlEndPosForRestore aRedlRest( rInsPos, 0 );
 
@@ -3334,7 +3335,40 @@ void DocumentContentOperationsManager::CopyWithFlyInFly(
         {   // recreate from previous node (could be merged now)
             if (SwTextNode *const pNode = aSavePos.GetNode().GetTextNode())
             {
+                std::unordered_set<SwTextFrame*> frames;
+                SwTextNode *const pEndNode = rInsPos.GetNode().GetTextNode();
+                if (pEndNode)
+                {
+                    SwIterator<SwTextFrame, SwTextNode, sw::IteratorMode::UnwrapMulti> aIter(*pEndNode);
+                    for (SwTextFrame* pFrame = aIter.First(); pFrame; pFrame = aIter.Next())
+                    {
+                        if (pFrame->getRootFrame()->IsHideRedlines())
+                        {
+                            frames.insert(pFrame);
+                        }
+                    }
+                }
                 sw::RecreateStartTextFrames(*pNode);
+                if (!frames.empty())
+                {   // tdf#132187 check if the end node needs new frames
+                    SwIterator<SwTextFrame, SwTextNode, sw::IteratorMode::UnwrapMulti> aIter(*pEndNode);
+                    for (SwTextFrame* pFrame = aIter.First(); pFrame; pFrame = aIter.Next())
+                    {
+                        if (pFrame->getRootFrame()->IsHideRedlines())
+                        {
+                            auto const it = frames.find(pFrame);
+                            if (it != frames.end())
+                            {
+                                frames.erase(it);
+                            }
+                        }
+                    }
+                    if (!frames.empty()) // existing frame was deleted
+                    {   // all layouts because MakeFrames recreates all layouts
+                        pEndNode->DelFrames(nullptr);
+                        isRecreateEndNode = true;
+                    }
+                }
             }
         }
         bool const isAtStartOfSection(aSavePos.GetNode().IsStartNode());
@@ -3346,7 +3380,7 @@ void DocumentContentOperationsManager::CopyWithFlyInFly(
             // if it was the first node in the document so that MakeFrames()
             // will find the existing (wasn't deleted) frame on it
             SwNodeIndex const end(rInsPos,
-                    (rInsPos.GetNode().IsEndNode() || isAtStartOfSection)
+                    (!isRecreateEndNode || isAtStartOfSection)
                     ? 0 : +1);
             ::MakeFrames(pDest, aSavePos, end);
         }


More information about the Libreoffice-commits mailing list