[Libreoffice-commits] core.git: sw/source

Tor Lillqvist tml at collabora.com
Wed Dec 20 08:00:11 UTC 2017


 sw/source/core/docnode/nodes.cxx |   82 +++++++++++++++++++--------------------
 1 file changed, 40 insertions(+), 42 deletions(-)

New commits:
commit ae71020598362784b39eb4f67178166754db6fe0
Author: Tor Lillqvist <tml at collabora.com>
Date:   Tue Dec 19 16:38:05 2017 +0200

    Remove unnecessary nested block level
    
    Change-Id: I06fb2d13bf39d636151396a2cbac35b3403ffe39
    Reviewed-on: https://gerrit.libreoffice.org/46798
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tor Lillqvist <tml at collabora.com>

diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx
index 79c8076c11b1..510cbd938e33 100644
--- a/sw/source/core/docnode/nodes.cxx
+++ b/sw/source/core/docnode/nodes.cxx
@@ -2212,57 +2212,55 @@ void SwNodes::ForEach( const SwNodeIndex& rStart, const SwNodeIndex& rEnd,
 
 void SwNodes::RemoveNode( sal_uLong nDelPos, sal_uLong nSz, bool bDel )
 {
-    {
 #ifndef NDEBUG
-        SwNode *const pFirst((*this)[nDelPos]);
+    SwNode *const pFirst((*this)[nDelPos]);
 #endif
-        for (sal_uLong nCnt = 0; nCnt < nSz; nCnt++)
-        {
-            SwNode* pNode = ((*this)[ nDelPos + nCnt ]);
-            SwTextNode * pTextNd = pNode->GetTextNode();
+    for (sal_uLong nCnt = 0; nCnt < nSz; nCnt++)
+    {
+        SwNode* pNode = ((*this)[ nDelPos + nCnt ]);
+        SwTextNode * pTextNd = pNode->GetTextNode();
 
-            if (pTextNd)
+        if (pTextNd)
+        {
+            pTextNd->RemoveFromList();
+            // remove RndStdIds::FLY_AS_CHAR *before* adjusting SwNodeIndex
+            // so their anchor still points to correct node when deleted!
+            // NOTE: this will call RemoveNode() recursively!
+            // so adjust our indexes to account for removed nodes
+            sal_uLong const nPos = pTextNd->GetIndex();
+            SwpHints *const pHints(pTextNd->GetpSwpHints());
+            if (pHints)
             {
-                pTextNd->RemoveFromList();
-                // remove RndStdIds::FLY_AS_CHAR *before* adjusting SwNodeIndex
-                // so their anchor still points to correct node when deleted!
-                // NOTE: this will call RemoveNode() recursively!
-                // so adjust our indexes to account for removed nodes
-                sal_uLong const nPos = pTextNd->GetIndex();
-                SwpHints *const pHints(pTextNd->GetpSwpHints());
-                if (pHints)
+                std::vector<SwTextAttr*> flys;
+                for (size_t i = 0; i < pHints->Count(); ++i)
                 {
-                    std::vector<SwTextAttr*> flys;
-                    for (size_t i = 0; i < pHints->Count(); ++i)
+                    SwTextAttr *const pHint(pHints->Get(i));
+                    if (RES_TXTATR_FLYCNT == pHint->Which())
                     {
-                        SwTextAttr *const pHint(pHints->Get(i));
-                        if (RES_TXTATR_FLYCNT == pHint->Which())
-                        {
-                            flys.push_back(pHint);
-                        }
+                        flys.push_back(pHint);
                     }
-                    for (SwTextAttr * pHint : flys)
-                    {
-                        pTextNd->DeleteAttribute(pHint);
-                    }   // pHints may be dead now
-                    sal_uLong const nDiff = nPos - pTextNd->GetIndex();
-                    if (nDiff)
-                    {
-                        nDelPos -= nDiff;
-                    }
-                    assert(pTextNd == (*this)[nDelPos + nCnt]);
-                    assert(pFirst == (*this)[nDelPos]);
                 }
+                for (SwTextAttr * pHint : flys)
+                {
+                    pTextNd->DeleteAttribute(pHint);
+                }   // pHints may be dead now
+                sal_uLong const nDiff = nPos - pTextNd->GetIndex();
+                if (nDiff)
+                {
+                    nDelPos -= nDiff;
+                }
+                assert(pTextNd == (*this)[nDelPos + nCnt]);
+                assert(pFirst == (*this)[nDelPos]);
             }
-            SwTableNode* pTableNode = pNode->GetTableNode();
-            if (pTableNode)
-            {
-                // The node that is deleted is a table node.
-                // Need to make sure that all the redlines that are
-                // related to this table are removed from the
-                // 'Extra Redlines' array
-                pTableNode->RemoveRedlines();
-            }
+        }
+        SwTableNode* pTableNode = pNode->GetTableNode();
+        if (pTableNode)
+        {
+            // The node that is deleted is a table node.
+            // Need to make sure that all the redlines that are
+            // related to this table are removed from the
+            // 'Extra Redlines' array
+            pTableNode->RemoveRedlines();
         }
     }
 


More information about the Libreoffice-commits mailing list