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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Aug 16 17:30:23 UTC 2018


 sw/source/core/layout/wsfrm.cxx |   25 +++++++++++++++++++------
 sw/source/core/text/itratr.cxx  |   18 ++++++++++--------
 2 files changed, 29 insertions(+), 14 deletions(-)

New commits:
commit 8a418f283047d3675b5847ed50ec07df879405ca
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Thu Aug 16 18:59:10 2018 +0200
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Thu Aug 16 18:59:10 2018 +0200

    sw_redlinehide_2: force SwAttrIter::GetNextAttr to make progress
    
    ... and skip over the redline if the start position is at the beginning
    of it.
    
    Change-Id: Ib12b459b12d49e1443257ce398963ab3ec64f2a5

diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx
index 82bdc5910d1b..4134c73f1b90 100644
--- a/sw/source/core/text/itratr.cxx
+++ b/sw/source/core/text/itratr.cxx
@@ -442,7 +442,8 @@ static void InsertCharAttrs(SfxPoolItem const** pAttrs, SfxItemSet const& rItems
 // if return false: portion ends at start of redline, indexes unchanged
 // if return true: portion end not known (past end of redline), indexes point to first hint past end of redline
 bool CanSkipOverRedline(SwRangeRedline const& rRedline,
-        size_t & rStartIndex, size_t & rEndIndex)
+        size_t & rStartIndex, size_t & rEndIndex,
+        bool const isTheAnswerYes)
 {
     size_t nStartIndex(rStartIndex);
     size_t nEndIndex(rEndIndex);
@@ -499,7 +500,7 @@ bool CanSkipOverRedline(SwRangeRedline const& rRedline,
                 case RES_TXTATR_CJK_RUBY:
                 case RES_TXTATR_INPUTFIELD:
                     {
-                        return false; // always break
+                        if (!isTheAnswerYes) return false; // always break
                     }
                     break;
                 // these are guaranteed not to overlap
@@ -589,7 +590,7 @@ bool CanSkipOverRedline(SwRangeRedline const& rRedline,
                 case RES_TXTATR_CJK_RUBY:
                 case RES_TXTATR_INPUTFIELD:
                     {
-                        return false;
+                        if (!isTheAnswerYes) return false;
                     }
                     break;
                 case RES_TXTATR_AUTOFMT:
@@ -610,7 +611,7 @@ bool CanSkipOverRedline(SwRangeRedline const& rRedline,
                             }
                             if (!isFound)
                             {
-                                return false;
+                                if (!isTheAnswerYes) return false;
                             }
                         }
                         SfxItemSet const& rSet((pAttr->Which() == RES_TXTATR_CHARFMT)
@@ -646,7 +647,7 @@ bool CanSkipOverRedline(SwRangeRedline const& rRedline,
     // if we didn't find a matching start for any end, then it really ends inside
     if (!activeCharFmts.empty())
     {
-        return false;
+        if (!isTheAnswerYes) return false;
     }
     for (size_t i = 0; i < SAL_N_ELEMENTS(activeCharAttrsStart); ++i)
     {
@@ -654,7 +655,7 @@ bool CanSkipOverRedline(SwRangeRedline const& rRedline,
 //        assert(!activeCharAttrsStart[i] || activeCharAttrsStart[i]->GetItemPool()->IsItemPoolable(*activeCharAttrsStart[i]));
         if (activeCharAttrsStart[i] != activeCharAttrsEnd[i])
         {
-            return false;
+            if (!isTheAnswerYes) return false;
         }
     }
     rStartIndex = nStartIndex;
@@ -738,8 +739,9 @@ TextFrameIndex SwAttrIter::GetNextAttr() const
             if (redline.second.first)
             {
                 assert(m_pMergedPara);
-                if (CanSkipOverRedline(*redline.second.first, nStartIndex, nEndIndex))
-                {
+                if (CanSkipOverRedline(*redline.second.first,
+                        nStartIndex, nEndIndex, m_nPosition == redline.first))
+                {   // if current position is start of the redline, must skip!
                     nActRedline += redline.second.second;
                     if (&redline.second.first->End()->nNode.GetNode() != pTextNode)
                     {
commit ec3de4663dbe5462978df2bf63e6fd9b1f1bf6e4
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Thu Aug 16 18:55:08 2018 +0200
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Thu Aug 16 18:55:08 2018 +0200

    sw_redlinehide_2: subtlety in UnHideRedlines, delete all flys ...
    
    ... even on nodes that have no extents any more because they were all
    deleted while the redlines were hidden.
    
    Change-Id: Id6595520b1d5db030c26905b62033db68969532c

diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index 1d308a50e937..8bb1b0407f72 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -4302,21 +4302,34 @@ static void UnHideRedlines(SwRootFrame & rLayout,
                             // the new text frames don't exist yet, so at this point
                             // we can only delete the footnote frames so they don't
                             // point to the merged SwTextFrame any more...
-                            SwTextNode const* pNode(&rTextNode);
-                            for (auto const& rExtent : pMergedPara->extents)
+                            assert(&rTextNode == pMergedPara->pFirstNode);
+                            // iterate over nodes, not extents: if a node has
+                            // no extents now but did have extents initially,
+                            // its flys need their frames deleted too!
+                            int nLevel(0);
+                            for (sal_uLong j = rTextNode.GetIndex() + 1;
+                                 j <= pMergedPara->pLastNode->GetIndex(); ++j)
                             {
-                                if (rExtent.pNode != pNode)
+                                SwNode *const pNode(rTextNode.GetNodes()[j]);
+                                if (pNode->IsStartNode())
+                                {
+                                    ++nLevel;
+                                }
+                                else if (pNode->IsEndNode())
+                                {
+                                    --nLevel;
+                                }
+                                else if (nLevel == 0 && pNode->IsTextNode())
                                 {
-                                    sw::RemoveFootnotesForNode(*pFrame, *rExtent.pNode, nullptr);
+                                    sw::RemoveFootnotesForNode(*pFrame, *pNode->GetTextNode(), nullptr);
                                     // similarly, remove the anchored flys
-                                    if (auto const pFlys = rExtent.pNode->GetAnchoredFlys())
+                                    if (auto const pFlys = pNode->GetAnchoredFlys())
                                     {
                                         for (SwFrameFormat * pFormat : *pFlys)
                                         {
                                             pFormat->DelFrames(/*&rLayout*/);
                                         }
                                     }
-                                    pNode = rExtent.pNode;
                                 }
                             }
                             // rely on AppendAllObjs call at the end to add


More information about the Libreoffice-commits mailing list