[Libreoffice-commits] core.git: Branch 'private/mst/sw_redlinehide_2' - 7 commits - sw/inc sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Aug 13 16:43:11 UTC 2018


 sw/inc/node.hxx                                         |    2 
 sw/source/core/doc/DocumentContentOperationsManager.cxx |   37 +++++++++-------
 sw/source/core/docnode/ndsect.cxx                       |    7 ++-
 sw/source/core/docnode/ndtbl.cxx                        |   12 ++++-
 sw/source/core/docnode/node.cxx                         |   32 +++++++++++--
 sw/source/core/docnode/nodes.cxx                        |   10 ++--
 sw/source/core/graphic/ndgrf.cxx                        |    2 
 sw/source/core/inc/txtfrm.hxx                           |   10 ++--
 sw/source/core/text/itratr.cxx                          |   11 +++-
 sw/source/core/text/redlnitr.cxx                        |    3 -
 sw/source/core/text/txtfrm.cxx                          |   17 +++++--
 sw/source/core/txtnode/ndtxt.cxx                        |    3 -
 sw/source/core/txtnode/thints.cxx                       |    2 
 sw/source/core/undo/untbl.cxx                           |    2 
 14 files changed, 102 insertions(+), 48 deletions(-)

New commits:
commit 2deb7b123988058da3fee05642d3d3687096f8cd
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Mon Aug 13 18:18:40 2018 +0200
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Mon Aug 13 18:34:35 2018 +0200

    sw_redlinehide_2: try to keep the pLastNode updated if it's deleted...
    
    Change-Id: Ied4ca532b336cacf3c4a8d96b9e75dcbaf47ba29

diff --git a/sw/inc/node.hxx b/sw/inc/node.hxx
index 1b0d7ad140db..ccded8e5eaf5 100644
--- a/sw/inc/node.hxx
+++ b/sw/inc/node.hxx
@@ -417,7 +417,7 @@ public:
     /** Method deletes all views of document for the node. The content-
         frames are removed from the respective layout.
     */
-    void DelFrames(SwRootFrame const* pLayout);
+    void DelFrames(SwRootFrame const* pLayout, bool fromDtor = false);
 
     /** @return count of elements of node content. Default is 1.
        There are differences between text node and formula node. */
diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx
index 0d97e9febba9..9175a1b076be 100644
--- a/sw/source/core/docnode/node.cxx
+++ b/sw/source/core/docnode/node.cxx
@@ -1320,7 +1320,7 @@ void SwContentNode::MakeFramesForAdjacentContentNode(SwContentNode& rNode)
  * Deletes all Views from the Doc for this Node.
  * The ContentFrames are removed from the corresponding Layout.
  */
-void SwContentNode::DelFrames(SwRootFrame const*const pLayout)
+void SwContentNode::DelFrames(SwRootFrame const*const pLayout, bool const fromDtor)
 {
     if( !HasWriterListeners() )
         return;
@@ -1334,15 +1334,32 @@ void SwContentNode::DelFrames(SwRootFrame const*const pLayout)
         }
         if (pFrame->IsTextFrame())
         {
-            if (sw::MergedPara const* pMerged =
-                    static_cast<SwTextFrame const*>(pFrame)->GetMergedPara())
+            if (sw::MergedPara * pMerged =
+                    static_cast<SwTextFrame *>(pFrame)->GetMergedPara())
             {
                 if (this != pMerged->pFirstNode)
                 {
+                    if (fromDtor)
+                    {
+                        // pointer should have been updated to a different node
+                        assert(this != pMerged->pParaPropsNode);
+                        // manual update required i'm afraid...
+                        if (this == pMerged->pLastNode)
+                        {
+                            pMerged->pLastNode = GetNodes()[GetIndex()-1]->GetTextNode();
+                            // at first glance nothing guarantees this...
+                            // but the redline must end on a text-node...
+                            // so everything before this node that isn't a text
+                            // node should have been deleted already so that
+                            // there's a text node before.
+                            assert(pMerged->pLastNode->IsTextNode());
+                        }
+                        // avoid re-parenting mess (ModifyChangedHint)
+                        pMerged->listener.EndListening(this);
+                    }
                     continue; // don't delete
                 }
             }
-
         // #i27138#
         // notify accessibility paragraphs objects about changed
         // CONTENT_FLOWS_FROM/_TO relation.
diff --git a/sw/source/core/inc/txtfrm.hxx b/sw/source/core/inc/txtfrm.hxx
index 7797626e46e2..ef9f806d5710 100644
--- a/sw/source/core/inc/txtfrm.hxx
+++ b/sw/source/core/inc/txtfrm.hxx
@@ -394,9 +394,7 @@ public:
         { return GetFollow() && !GetFollow()->GetOfst(); }
 
     void SetMergedPara(std::unique_ptr<sw::MergedPara> p);
-#if 0
     sw::MergedPara      * GetMergedPara()       { return m_pMergedPara.get(); }
-#endif
     sw::MergedPara const* GetMergedPara() const { return m_pMergedPara.get(); }
 
     /// Returns the text portion we want to edit (for inline see underneath)
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index c3780bfd368d..f5aca5cc2c45 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -726,6 +726,7 @@ void UpdateMergedParaForInsert(MergedPara & rMerged,
 {
     assert(nIndex <= rNode.Len());
     assert(nIndex + nLen <= rNode.Len());
+    assert(rMerged.pFirstNode->GetIndex() <= rNode.GetIndex() && rNode.GetIndex() <= rMerged.pLastNode->GetIndex());
     OUStringBuffer text(rMerged.mergedText);
     sal_Int32 nTFIndex(0);
     bool bInserted(false);
@@ -760,7 +761,7 @@ void UpdateMergedParaForInsert(MergedPara & rMerged,
         }
         nTFIndex += it->nEnd - it->nStart;
     }
-    assert((bFoundNode || rMerged.extents.empty()) && "text node not found - why is it sending hints to us");
+//    assert((bFoundNode || rMerged.extents.empty()) && "text node not found - why is it sending hints to us");
     if (!bInserted)
     {   // must be in a gap
         rMerged.extents.emplace(itInsert, const_cast<SwTextNode*>(&rNode), nIndex, nIndex + nLen);
@@ -776,6 +777,7 @@ TextFrameIndex UpdateMergedParaForDelete(MergedPara & rMerged,
         SwTextNode const& rNode, sal_Int32 nIndex, sal_Int32 const nLen)
 {
     assert(nIndex <= rNode.Len());
+    assert(rMerged.pFirstNode->GetIndex() <= rNode.GetIndex() && rNode.GetIndex() <= rMerged.pLastNode->GetIndex());
     OUStringBuffer text(rMerged.mergedText);
     sal_Int32 nTFIndex(0);
     sal_Int32 nToDelete(nLen);
@@ -867,13 +869,13 @@ TextFrameIndex UpdateMergedParaForDelete(MergedPara & rMerged,
             ++it;
         }
     }
-    assert(nFoundNode != 0 && "text node not found - why is it sending hints to us");
+//    assert(nFoundNode != 0 && "text node not found - why is it sending hints to us");
     assert(nIndex - nDeleted <= rNode.Len());
     // if there's a remaining deletion, it must be in gap at the end of the node
 // can't do: might be last one in node was erased   assert(nLen == 0 || rMerged.empty() || (it-1)->nEnd <= nIndex);
     // note: if first node gets deleted then that must call DelFrames as
     // pFirstNode is never updated
-    if (nErased == nFoundNode)
+    if (nErased && nErased == nFoundNode)
     {   // all visible text from node was erased
         if (rMerged.pParaPropsNode == &rNode)
         {
@@ -881,7 +883,7 @@ TextFrameIndex UpdateMergedParaForDelete(MergedPara & rMerged,
                 ? rMerged.pFirstNode
                 : rMerged.extents.front().pNode;
         }
-        rMerged.listener.EndListening(&const_cast<SwTextNode&>(rNode));
+// NOPE must listen on all non-hidden nodes; particularly on pLastNode        rMerged.listener.EndListening(&const_cast<SwTextNode&>(rNode));
     }
     rMerged.mergedText = text.makeStringAndClear();
     return TextFrameIndex(nDeleted);
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 5bfb81123ced..4d797a3a8d44 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -263,8 +263,7 @@ SwTextNode::~SwTextNode()
     RemoveFromList();
 
     InitSwParaStatistics( false );
-
-    DelFrames(nullptr); // must be called here while it's still a SwTextNode
+    DelFrames(nullptr, true); // must be called here while it's still a SwTextNode
     DelFrames_TextNodePart();
 }
 
commit a5ff45c3b57ce07f7c89829a2dd84c078af530ff
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Mon Aug 13 18:05:03 2018 +0200
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Mon Aug 13 18:05:03 2018 +0200

    sw_redlinehide_2: fix infinite loop caused by SwAttrIter::Seek(0)
    
    The problem is if there is a delete redline that deletes the entire
    pFirstNode and ends in a different node, at the position where a
    hint starts; first m_pRedline->Seek() will be called with the wrong
    node, then the GetNextAttr() will call MapModelToView() and get 0
    back again...
    
    Change-Id: Ie3eb1250267429ea3e3f6281685c955a79d4e960

diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx
index 0eeeff080669..82bdc5910d1b 100644
--- a/sw/source/core/text/itratr.cxx
+++ b/sw/source/core/text/itratr.cxx
@@ -340,13 +340,16 @@ bool SwAttrIter::Seek(TextFrameIndex const nNewPos)
         assert(m_pRedline);
     }
 
-    if (!nNewPos || newPos.second < m_nPosition)
+    // sw_redlinehide: Seek(0) must move before the first character, which
+    // has a special case where the first node starts with delete redline.
+    if ((!nNewPos && (!m_pMergedPara || newPos.first != m_pTextNode))
+        || newPos.second < m_nPosition)
     {
         if (m_pMergedPara)
         {
-            if (m_pTextNode != m_pMergedPara->pFirstNode)
+            if (m_pTextNode != newPos.first)
             {
-                m_pTextNode = m_pMergedPara->pFirstNode;
+                m_pTextNode = newPos.first;
                 // sw_redlinehide: hope it's okay to use the current text node
                 // here; the AttrHandler shouldn't care about non-char items
                 InitFontAndAttrHandler(*m_pTextNode, m_pMergedPara->mergedText, nullptr);
@@ -410,7 +413,7 @@ bool SwAttrIter::Seek(TextFrameIndex const nNewPos)
     m_pFont->SetActual( m_pScriptInfo->WhichFont(nNewPos) );
 
     if( m_pRedline )
-        m_nChgCnt = m_nChgCnt + m_pRedline->Seek(*m_pFont, newPos.first->GetIndex(), newPos.second, m_nPosition);
+        m_nChgCnt = m_nChgCnt + m_pRedline->Seek(*m_pFont, m_pTextNode->GetIndex(), newPos.second, m_nPosition);
     m_nPosition = newPos.second;
 
     if( m_nPropFont )
commit 0825d1302ff970adc5c90d9ee945f60421726476
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Mon Aug 13 15:59:16 2018 +0200
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Mon Aug 13 15:59:16 2018 +0200

    sw_redlinehide_2: check merge flag in various MakeFrames
    
    Change-Id: I2d54ae4069c0c6813059f90a1003387512ee9ba1

diff --git a/sw/source/core/docnode/ndsect.cxx b/sw/source/core/docnode/ndsect.cxx
index add674689e85..b97188b316d8 100644
--- a/sw/source/core/docnode/ndsect.cxx
+++ b/sw/source/core/docnode/ndsect.cxx
@@ -1048,6 +1048,11 @@ void SwSectionNode::MakeFramesForAdjacentContentNode(const SwNodeIndex & rIdx)
             while( nullptr != (pFrame = aNode2Layout.NextFrame()) )
             {
                 OSL_ENSURE( pFrame->IsSctFrame(), "Depend of Section not a Section." );
+                if (pFrame->getRootFrame()->IsHideRedlines()
+                    && !rIdx.GetNode().IsCreateFrameWhenHidingRedlines())
+                {
+                    continue;
+                }
                 SwFrame *pNew = rIdx.GetNode().GetContentNode()->MakeFrame( pFrame );
 
                 SwSectionNode* pS = rIdx.GetNode().FindSectionNode();
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 629f1e75e2b9..19bb5403e4eb 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -2381,6 +2381,11 @@ void SwTableNode::MakeFramesForAdjacentContentNode(const SwNodeIndex & rIdx)
 
     while( nullptr != (pFrame = aNode2Layout.NextFrame()) )
     {
+        if (pFrame->getRootFrame()->IsHideRedlines()
+            && !pNode->IsCreateFrameWhenHidingRedlines())
+        {
+            continue;
+        }
         SwFrame *pNew = pNode->MakeFrame( pFrame );
         // Will the Node receive Frames before or after?
         if ( bBefore )
@@ -2408,6 +2413,11 @@ void SwTableNode::MakeOwnFrames(SwNodeIndex* pIdxBehind)
     SwNode2Layout aNode2Layout( *pNd, GetIndex() );
     while( nullptr != (pUpper = aNode2Layout.UpperFrame( pFrame, *this )) )
     {
+        if (pUpper->getRootFrame()->IsHideRedlines()
+            && !IsCreateFrameWhenHidingRedlines())
+        {
+            continue;
+        }
         SwTabFrame* pNew = MakeFrame( pUpper );
         pNew->Paste( pUpper, pFrame );
         // #i27138#
diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx
index 65e60ce15d63..0d97e9febba9 100644
--- a/sw/source/core/docnode/node.cxx
+++ b/sw/source/core/docnode/node.cxx
@@ -1290,6 +1290,11 @@ void SwContentNode::MakeFramesForAdjacentContentNode(SwContentNode& rNode)
 
     while( nullptr != (pUpper = aNode2Layout.UpperFrame( pFrame, rNode )) )
     {
+        if (pUpper->getRootFrame()->IsHideRedlines()
+            && !rNode.IsCreateFrameWhenHidingRedlines())
+        {
+            continue;
+        }
         SwFrame *pNew = rNode.MakeFrame( pUpper );
         pNew->Paste( pUpper, pFrame );
         // #i27138#
commit 315873281064d3a2cd02097a0adbd87a836035d0
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Mon Aug 13 14:01:49 2018 +0200
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Mon Aug 13 14:01:49 2018 +0200

    sw_redlinehide_2 make DelFrames arg non-defaulted
    
    Change-Id: I224422965d58c7d2fd85450fda06896a68f03f7e

diff --git a/sw/inc/node.hxx b/sw/inc/node.hxx
index 0e3d5aeb4692..1b0d7ad140db 100644
--- a/sw/inc/node.hxx
+++ b/sw/inc/node.hxx
@@ -417,7 +417,7 @@ public:
     /** Method deletes all views of document for the node. The content-
         frames are removed from the respective layout.
     */
-    void DelFrames(SwRootFrame const* pLayout = nullptr);
+    void DelFrames(SwRootFrame const* pLayout);
 
     /** @return count of elements of node content. Default is 1.
        There are differences between text node and formula node. */
diff --git a/sw/source/core/docnode/ndsect.cxx b/sw/source/core/docnode/ndsect.cxx
index 4b38cdf56004..add674689e85 100644
--- a/sw/source/core/docnode/ndsect.cxx
+++ b/sw/source/core/docnode/ndsect.cxx
@@ -936,7 +936,7 @@ SwSectionNode* SwNodes::InsertTextSection(SwNodeIndex const& rNdIdx,
             }
         }
         else if( pNd->IsContentNode() )
-            static_cast<SwContentNode*>(pNd)->DelFrames();
+            static_cast<SwContentNode*>(pNd)->DelFrames(nullptr);
     }
 
     sw_DeleteFootnote( pSectNd, nStart, nEnde );
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 323c5a247ab6..629f1e75e2b9 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -887,7 +887,7 @@ const SwTable* SwDoc::TextToTable( const SwInsertTableOptions& rInsTableOpts,
 static void lcl_RemoveBreaks(SwContentNode & rNode, SwTableFormat *const pTableFormat)
 {
     // delete old layout frames, new ones need to be created...
-    rNode.DelFrames();
+    rNode.DelFrames(nullptr);
 
     if (!rNode.IsTextNode())
     {
diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx
index b43e9e67d583..4aa473c4308e 100644
--- a/sw/source/core/docnode/nodes.cxx
+++ b/sw/source/core/docnode/nodes.cxx
@@ -493,7 +493,7 @@ bool SwNodes::MoveNodes( const SwNodeRange& aRange, SwNodes & rNodes,
 
                     if( bNewFrames )
                         // delete all frames
-                        pTableNd->DelFrames();
+                        pTableNd->DelFrames(nullptr);
                     if( &rNodes == this ) // move into self?
                     {
                         // move all Start/End/ContentNodes
@@ -794,7 +794,7 @@ bool SwNodes::MoveNodes( const SwNodeRange& aRange, SwNodes & rNodes,
             //Add special function to text node.
             {
                 if( bNewFrames && pCurrentNode->GetContentNode() )
-                    static_cast<SwContentNode*>(pCurrentNode)->DelFrames();
+                    static_cast<SwContentNode*>(pCurrentNode)->DelFrames(nullptr);
                 pCurrentNode->m_pStartOfSection = aSttNdStack[ nLevel ];
                 nInsPos++;
                 --aRg.aEnd;
@@ -804,7 +804,7 @@ bool SwNodes::MoveNodes( const SwNodeRange& aRange, SwNodes & rNodes,
         case SwNodeType::Ole:
             {
                 if( bNewFrames && pCurrentNode->GetContentNode() )
-                    static_cast<SwContentNode*>(pCurrentNode)->DelFrames();
+                    static_cast<SwContentNode*>(pCurrentNode)->DelFrames(nullptr);
 
                 pCurrentNode->m_pStartOfSection = aSttNdStack[ nLevel ];
                 nInsPos++;
@@ -1394,7 +1394,7 @@ void SwNodes::DelNodes( const SwNodeIndex & rStart, sal_uLong nCnt )
             if( pNd->IsContentNode() )
             {
                 static_cast<SwContentNode*>(pNd)->InvalidateNumRule();
-                static_cast<SwContentNode*>(pNd)->DelFrames();
+                static_cast<SwContentNode*>(pNd)->DelFrames(nullptr);
             }
         }
         RemoveNode( nSttIdx, nCnt, true );
@@ -1862,7 +1862,7 @@ void SwNodes::CopyNodes( const SwNodeRange& rRange,
                                             pDoc, aInsPos );
                 // frames are always created as default, so delete if needed
                 if( !bNewFrames )
-                    pNew->DelFrames();
+                    pNew->DelFrames(nullptr);
             }
             break;
 
diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx
index d0f5173645c0..0ff3cd1889de 100644
--- a/sw/source/core/graphic/ndgrf.cxx
+++ b/sw/source/core/graphic/ndgrf.cxx
@@ -306,7 +306,7 @@ SwGrfNode::~SwGrfNode()
     }
     //#39289# delete frames already here since the Frames' dtor needs the graphic for its StopAnimation
     if( HasWriterListeners() )
-        DelFrames();
+        DelFrames(nullptr);
 }
 
 /// allow reaction on change of content of GraphicObject
diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx
index 3e2049cf2337..9e0f631fa092 100644
--- a/sw/source/core/txtnode/thints.cxx
+++ b/sw/source/core/txtnode/thints.cxx
@@ -1405,7 +1405,7 @@ bool SwTextNode::InsertHint( SwTextAttr * const pAttr, const SetAttrMode nMode )
                     {
                         SwContentNode* pCNd = rNodes[ nSttIdx ]->GetContentNode();
                         if( nullptr != pCNd )
-                            pCNd->DelFrames();
+                            pCNd->DelFrames(nullptr);
                         else if (SwTableNode *const pTable = rNodes[nSttIdx]->GetTableNode())
                         {
                             pTable->DelFrames();
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index d8e8c75f90ae..1705d281a12c 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -528,7 +528,7 @@ SwTableNode* SwNodes::UndoTableToText( sal_uLong nSttNd, sal_uLong nEndNd,
         for( n = pTableNd->GetIndex() + 1; n < nTmpEnd; ++n )
         {
             if( ( pNd = (*this)[ n ] )->IsContentNode() )
-                static_cast<SwContentNode*>(pNd)->DelFrames();
+                static_cast<SwContentNode*>(pNd)->DelFrames(nullptr);
             pNd->m_pStartOfSection = pTableNd;
         }
     }
commit 8470d1271690d8db85a6d843f4dd7ddc7ff38d2f
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Mon Aug 13 13:38:55 2018 +0200
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Mon Aug 13 13:38:55 2018 +0200

    remove obsolete comment, todo rebase -i
    
    Change-Id: I6c5a6e7d204e239fc89340a11e7764e03172d846

diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx
index ed457c195156..65e60ce15d63 100644
--- a/sw/source/core/docnode/node.cxx
+++ b/sw/source/core/docnode/node.cxx
@@ -1314,8 +1314,6 @@ void SwContentNode::MakeFramesForAdjacentContentNode(SwContentNode& rNode)
 /**
  * Deletes all Views from the Doc for this Node.
  * The ContentFrames are removed from the corresponding Layout.
- *
- * An input param to identify if the acc table should be disposed.
  */
 void SwContentNode::DelFrames(SwRootFrame const*const pLayout)
 {
commit 932b7bc7e60cdacf9bfb2b2d9613e8154e65e848
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Mon Aug 13 13:35:42 2018 +0200
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Mon Aug 13 13:35:42 2018 +0200

    sw_redlinehide_2: SplitNode: move more code into restoreFunc
    
    In DocumentContentOperationsManager::SplitNode(), ensure that all
    redline updating is done in the restoreFunc.
    
    Change-Id: I918b8f24dcda0cc181cb0f33bb2ca170a14b0e98

diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 2f997aea27ec..58a4fe796c54 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -2945,22 +2945,29 @@ bool DocumentContentOperationsManager::SplitNode( const SwPosition &rPos, bool b
             {   // move all bookmarks, TOXMarks, FlyAtCnt
                 pContentStore->Restore(&m_rDoc, rPos.nNode.GetIndex()-1, 0, true, eMode);
             }
+            if (eMode & sw::mark::RestoreMode::NonFlys)
+            {
+                // To-Do - add 'SwExtraRedlineTable' also ?
+                if (m_rDoc.getIDocumentRedlineAccess().IsRedlineOn() ||
+                    (!m_rDoc.getIDocumentRedlineAccess().IsIgnoreRedline() &&
+                     !m_rDoc.getIDocumentRedlineAccess().GetRedlineTable().empty()))
+                {
+                    SwPaM aPam( rPos );
+                    aPam.SetMark();
+                    aPam.Move( fnMoveBackward );
+                    if (m_rDoc.getIDocumentRedlineAccess().IsRedlineOn())
+                    {
+                        m_rDoc.getIDocumentRedlineAccess().AppendRedline(
+                            new SwRangeRedline(nsRedlineType_t::REDLINE_INSERT, aPam), true);
+                    }
+                    else
+                    {
+                        m_rDoc.getIDocumentRedlineAccess().SplitRedline(aPam);
+                    }
+                }
+            }
         });
-    pNode = pNode->GetTextNode()->SplitContentNode(rPos, &restoreFunc);
-    if (pNode)
-    {
-        // To-Do - add 'SwExtraRedlineTable' also ?
-        if( m_rDoc.getIDocumentRedlineAccess().IsRedlineOn() || (!m_rDoc.getIDocumentRedlineAccess().IsIgnoreRedline() && !m_rDoc.getIDocumentRedlineAccess().GetRedlineTable().empty() ))
-        {
-            SwPaM aPam( rPos );
-            aPam.SetMark();
-            aPam.Move( fnMoveBackward );
-            if( m_rDoc.getIDocumentRedlineAccess().IsRedlineOn() )
-                m_rDoc.getIDocumentRedlineAccess().AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true);
-            else
-                m_rDoc.getIDocumentRedlineAccess().SplitRedline( aPam );
-        }
-    }
+    pNode->GetTextNode()->SplitContentNode(rPos, &restoreFunc);
 
     m_rDoc.getIDocumentState().SetModified();
     return true;
commit 03e97f6e86b0de0a2ccb9eca5de1a0350f0a5f7c
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Mon Aug 13 11:10:20 2018 +0200
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Mon Aug 13 11:10:20 2018 +0200

    sw_redlinehide_2: MapModelToView needs to work on hidden nodes...
    
    ... that have no extents as well; add a pointer to the last node that
    can be used for comparing.
    
    Change-Id: Ibe7a84b523bb5921b3ca7fed2e330c54d85c5498

diff --git a/sw/source/core/inc/txtfrm.hxx b/sw/source/core/inc/txtfrm.hxx
index 965b4f911647..7797626e46e2 100644
--- a/sw/source/core/inc/txtfrm.hxx
+++ b/sw/source/core/inc/txtfrm.hxx
@@ -926,14 +926,18 @@ struct MergedPara
     SwTextNode const* pParaPropsNode;
     /// except break attributes, those are taken from the first node
     SwTextNode *const pFirstNode;
+    /// mainly for sanity checks
+    SwTextNode const* pLastNode;
     MergedPara(SwTextFrame & rFrame, std::vector<Extent>&& rExtents,
             OUString const& rText,
-            SwTextNode const*const pProps, SwTextNode *const pFirst)
+            SwTextNode const*const pProps, SwTextNode *const pFirst,
+            SwTextNode const*const pLast)
         : listener(rFrame), extents(std::move(rExtents)), mergedText(rText)
-        , pParaPropsNode(pProps), pFirstNode(pFirst)
+        , pParaPropsNode(pProps), pFirstNode(pFirst), pLastNode(pLast)
     {
         assert(pParaPropsNode);
         assert(pFirstNode);
+        assert(pLastNode);
     }
 };
 
diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx
index 21de262420bf..09480c84852e 100644
--- a/sw/source/core/text/redlnitr.cxx
+++ b/sw/source/core/text/redlnitr.cxx
@@ -157,7 +157,8 @@ CheckParaRedlineMerge(SwTextFrame & rFrame, SwTextNode & rTextNode,
         }
     }
     auto pRet(o3tl::make_unique<sw::MergedPara>(rFrame, std::move(extents),
-                mergedText.makeStringAndClear(), pParaPropsNode, &rTextNode));
+                mergedText.makeStringAndClear(), pParaPropsNode, &rTextNode,
+                nodes.back()));
     for (SwTextNode * pTmp : nodes)
     {
         pRet->listener.StartListening(pTmp);
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index a548c55ed2cc..c3780bfd368d 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -909,10 +909,16 @@ MapViewToModel(MergedPara const& rMerged, TextFrameIndex const i_nIndex)
 
 TextFrameIndex MapModelToView(MergedPara const& rMerged, SwTextNode const*const pNode, sal_Int32 const nIndex)
 {
+    assert(rMerged.pFirstNode->GetIndex() <= pNode->GetIndex()
+        && pNode->GetIndex() <= rMerged.pLastNode->GetIndex());
     sal_Int32 nRet(0);
     bool bFoundNode(false);
     for (auto const& e : rMerged.extents)
     {
+        if (pNode->GetIndex() < e.pNode->GetIndex())
+        {
+            return TextFrameIndex(nRet);
+        }
         if (e.pNode == pNode)
         {
             if (e.nStart <= nIndex && nIndex <= e.nEnd)
@@ -943,7 +949,6 @@ TextFrameIndex MapModelToView(MergedPara const& rMerged, SwTextNode const*const
         assert(nIndex <= pNode->Len());
         return TextFrameIndex(0);
     }
-    assert(!"text node not found");
     return TextFrameIndex(COMPLETE_STRING);
 }
 


More information about the Libreoffice-commits mailing list