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

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Sat Aug 1 07:20:17 UTC 2020


 sw/source/core/docnode/finalthreadmanager.cxx       |   28 
 sw/source/core/docnode/ndnum.cxx                    |   46 -
 sw/source/core/docnode/ndsect.cxx                   |  194 +++---
 sw/source/core/docnode/ndtbl.cxx                    |  229 +++----
 sw/source/core/docnode/ndtbl1.cxx                   |  618 ++++++++++----------
 sw/source/core/docnode/node.cxx                     |  182 ++---
 sw/source/core/docnode/nodes.cxx                    |   86 +-
 sw/source/core/docnode/retrievedinputstreamdata.cxx |   34 -
 sw/source/core/docnode/section.cxx                  |  174 ++---
 sw/source/core/docnode/threadmanager.cxx            |   20 
 10 files changed, 806 insertions(+), 805 deletions(-)

New commits:
commit aa703bc1253454f3783ea6314928505925a1b247
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Jul 30 10:34:16 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sat Aug 1 09:19:31 2020 +0200

    loplugin:flatten in sw/core/docnode
    
    Change-Id: Id0b37a9060ab77ecfd8c4aa2b340ab7b958ba109
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99897
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sw/source/core/docnode/finalthreadmanager.cxx b/sw/source/core/docnode/finalthreadmanager.cxx
index 80ddd75c3da9..506d054b47e2 100644
--- a/sw/source/core/docnode/finalthreadmanager.cxx
+++ b/sw/source/core/docnode/finalthreadmanager.cxx
@@ -318,26 +318,26 @@ void SAL_CALL FinalThreadManager::cancelAllJobs()
         maThreads.clear();
     }
 
-    if ( !aThreads.empty() )
-    {
-        osl::MutexGuard aGuard(maMutex);
+    if ( aThreads.empty() )
+        return;
 
-        if ( mpCancelJobsThread == nullptr )
+    osl::MutexGuard aGuard(maMutex);
+
+    if ( mpCancelJobsThread == nullptr )
+    {
+        mpCancelJobsThread.reset(new CancelJobsThread( aThreads ));
+        if ( !mpCancelJobsThread->create() )
         {
-            mpCancelJobsThread.reset(new CancelJobsThread( aThreads ));
-            if ( !mpCancelJobsThread->create() )
+            mpCancelJobsThread.reset();
+            for (auto const& elem : aThreads)
             {
-                mpCancelJobsThread.reset();
-                for (auto const& elem : aThreads)
-                {
-                    elem->cancel();
-                }
-                aThreads.clear();
+                elem->cancel();
             }
+            aThreads.clear();
         }
-        else
-            mpCancelJobsThread->addJobs( aThreads );
     }
+    else
+        mpCancelJobsThread->addJobs( aThreads );
 }
 
 // css::frame::XTerminateListener
diff --git a/sw/source/core/docnode/ndnum.cxx b/sw/source/core/docnode/ndnum.cxx
index 1e8e75256a04..d5fbe435d6bd 100644
--- a/sw/source/core/docnode/ndnum.cxx
+++ b/sw/source/core/docnode/ndnum.cxx
@@ -40,36 +40,36 @@ void SwNodes::UpdateOutlineNode(SwNode & rNd)
 {
     SwTextNode * pTextNd = rNd.GetTextNode();
 
-    if (pTextNd && pTextNd->IsOutlineStateChanged())
-    {
-        bool bFound = m_pOutlineNodes->find(pTextNd) != m_pOutlineNodes->end();
+    if (!(pTextNd && pTextNd->IsOutlineStateChanged()))
+        return;
+
+    bool bFound = m_pOutlineNodes->find(pTextNd) != m_pOutlineNodes->end();
 
-        if (pTextNd->IsOutline())
+    if (pTextNd->IsOutline())
+    {
+        if (! bFound)
         {
-            if (! bFound)
+            // assure that text is in the correct nodes array
+            if ( &(pTextNd->GetNodes()) == this )
             {
-                // assure that text is in the correct nodes array
-                if ( &(pTextNd->GetNodes()) == this )
-                {
-                    m_pOutlineNodes->insert(pTextNd);
-                }
-                else
-                {
-                    OSL_FAIL( "<SwNodes::UpdateOutlineNode(..)> - given text node isn't in the correct nodes array. This is a serious defect" );
-                }
+                m_pOutlineNodes->insert(pTextNd);
+            }
+            else
+            {
+                OSL_FAIL( "<SwNodes::UpdateOutlineNode(..)> - given text node isn't in the correct nodes array. This is a serious defect" );
             }
         }
-        else
-        {
-            if (bFound)
-                m_pOutlineNodes->erase(pTextNd);
-        }
+    }
+    else
+    {
+        if (bFound)
+            m_pOutlineNodes->erase(pTextNd);
+    }
 
-        pTextNd->UpdateOutlineState();
+    pTextNd->UpdateOutlineState();
 
-        // update the structure fields
-        GetDoc()->getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::Chapter )->UpdateFields();
-    }
+    // update the structure fields
+    GetDoc()->getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::Chapter )->UpdateFields();
 }
 
 void SwNodes::UpdateOutlineIdx( const SwNode& rNd )
diff --git a/sw/source/core/docnode/ndsect.cxx b/sw/source/core/docnode/ndsect.cxx
index 1c85a27a4853..a8658f99cf7b 100644
--- a/sw/source/core/docnode/ndsect.cxx
+++ b/sw/source/core/docnode/ndsect.cxx
@@ -750,29 +750,29 @@ void SwDoc::UpdateSection( size_t const nPos, SwSectionData & rNewData,
 void sw_DeleteFootnote( SwSectionNode *pNd, sal_uLong nStt, sal_uLong nEnd )
 {
     SwFootnoteIdxs& rFootnoteArr = pNd->GetDoc()->GetFootnoteIdxs();
-    if( !rFootnoteArr.empty() )
-    {
-        size_t nPos = 0;
-        rFootnoteArr.SeekEntry( SwNodeIndex( *pNd ), &nPos );
-        SwTextFootnote* pSrch;
+    if( rFootnoteArr.empty() )
+        return;
 
-        // Delete all succeeding Footnotes
-        while( nPos < rFootnoteArr.size() &&
-            SwTextFootnote_GetIndex( (pSrch = rFootnoteArr[ nPos ]) ) <= nEnd )
-        {
-            // If the Nodes are not deleted, they need to deregister at the Pages
-            // (delete Frames) or else they will remain there (Undo does not delete them!)
-            pSrch->DelFrames(nullptr);
-            ++nPos;
-        }
+    size_t nPos = 0;
+    rFootnoteArr.SeekEntry( SwNodeIndex( *pNd ), &nPos );
+    SwTextFootnote* pSrch;
 
-        while( nPos-- &&
-            SwTextFootnote_GetIndex( (pSrch = rFootnoteArr[ nPos ]) ) >= nStt )
-        {
-            // If the Nodes are not deleted, they need to deregister at the Pages
-            // (delete Frames) or else they will remain there (Undo does not delete them!)
-            pSrch->DelFrames(nullptr);
-        }
+    // Delete all succeeding Footnotes
+    while( nPos < rFootnoteArr.size() &&
+        SwTextFootnote_GetIndex( (pSrch = rFootnoteArr[ nPos ]) ) <= nEnd )
+    {
+        // If the Nodes are not deleted, they need to deregister at the Pages
+        // (delete Frames) or else they will remain there (Undo does not delete them!)
+        pSrch->DelFrames(nullptr);
+        ++nPos;
+    }
+
+    while( nPos-- &&
+        SwTextFootnote_GetIndex( (pSrch = rFootnoteArr[ nPos ]) ) >= nStt )
+    {
+        // If the Nodes are not deleted, they need to deregister at the Pages
+        // (delete Frames) or else they will remain there (Undo does not delete them!)
+        pSrch->DelFrames(nullptr);
     }
 }
 
@@ -1027,92 +1027,67 @@ void SwSectionNode::MakeFramesForAdjacentContentNode(const SwNodeIndex & rIdx)
 {
     // Take my successive or preceding ContentFrame
     SwNodes& rNds = GetNodes();
-    if( rNds.IsDocNodes() && rNds.GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell() )
+    if( !(rNds.IsDocNodes() && rNds.GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell()) )
+        return;
+
+    if( GetSection().IsHidden() || IsContentHidden() )
     {
-        if( GetSection().IsHidden() || IsContentHidden() )
+        SwNodeIndex aIdx( *EndOfSectionNode() );
+        SwContentNode* pCNd = rNds.GoNextSection( &aIdx, true, false );
+        if( !pCNd )
         {
-            SwNodeIndex aIdx( *EndOfSectionNode() );
-            SwContentNode* pCNd = rNds.GoNextSection( &aIdx, true, false );
-            if( !pCNd )
-            {
-                aIdx = *this;
-                pCNd = SwNodes::GoPrevSection(&aIdx, true, false);
-                if (!pCNd)
-                    return;
-            }
-            pCNd = aIdx.GetNode().GetContentNode();
-            pCNd->MakeFramesForAdjacentContentNode(static_cast<SwContentNode&>(rIdx.GetNode()));
+            aIdx = *this;
+            pCNd = SwNodes::GoPrevSection(&aIdx, true, false);
+            if (!pCNd)
+                return;
         }
-        else
+        pCNd = aIdx.GetNode().GetContentNode();
+        pCNd->MakeFramesForAdjacentContentNode(static_cast<SwContentNode&>(rIdx.GetNode()));
+    }
+    else
+    {
+        SwNode2Layout aNode2Layout( *this, rIdx.GetIndex() );
+        SwFrame *pFrame;
+        while( nullptr != (pFrame = aNode2Layout.NextFrame()) )
         {
-            SwNode2Layout aNode2Layout( *this, rIdx.GetIndex() );
-            SwFrame *pFrame;
-            while( nullptr != (pFrame = aNode2Layout.NextFrame()) )
+            OSL_ENSURE( pFrame->IsSctFrame(), "Depend of Section not a Section." );
+            if (pFrame->getRootFrame()->IsHideRedlines()
+                && !rIdx.GetNode().IsCreateFrameWhenHidingRedlines())
             {
-                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 );
+                continue;
+            }
+            SwFrame *pNew = rIdx.GetNode().GetContentNode()->MakeFrame( pFrame );
 
-                SwSectionNode* pS = rIdx.GetNode().FindSectionNode();
+            SwSectionNode* pS = rIdx.GetNode().FindSectionNode();
 
-                // Assure that node is not inside a table, which is inside the
-                // found section.
-                if ( pS )
+            // Assure that node is not inside a table, which is inside the
+            // found section.
+            if ( pS )
+            {
+                SwTableNode* pTableNode = rIdx.GetNode().FindTableNode();
+                if ( pTableNode &&
+                     pTableNode->GetIndex() > pS->GetIndex() )
                 {
-                    SwTableNode* pTableNode = rIdx.GetNode().FindTableNode();
-                    if ( pTableNode &&
-                         pTableNode->GetIndex() > pS->GetIndex() )
-                    {
-                        pS = nullptr;
-                    }
+                    pS = nullptr;
                 }
+            }
 
-                // if the node is in a section, the sectionframe now
-                // has to be created...
-                // boolean to control <Init()> of a new section frame.
-                bool bInitNewSect = false;
-                if( pS )
+            // if the node is in a section, the sectionframe now
+            // has to be created...
+            // boolean to control <Init()> of a new section frame.
+            bool bInitNewSect = false;
+            if( pS )
+            {
+                SwSectionFrame *pSct = new SwSectionFrame( pS->GetSection(), pFrame );
+                // prepare <Init()> of new section frame.
+                bInitNewSect = true;
+                SwLayoutFrame* pUp = pSct;
+                while( pUp->Lower() )  // for columned sections
                 {
-                    SwSectionFrame *pSct = new SwSectionFrame( pS->GetSection(), pFrame );
-                    // prepare <Init()> of new section frame.
-                    bInitNewSect = true;
-                    SwLayoutFrame* pUp = pSct;
-                    while( pUp->Lower() )  // for columned sections
-                    {
-                        OSL_ENSURE( pUp->Lower()->IsLayoutFrame(),"Who's in there?" );
-                        pUp = static_cast<SwLayoutFrame*>(pUp->Lower());
-                    }
-                    pNew->Paste( pUp );
-                    // #i27138#
-                    // notify accessibility paragraphs objects about changed
-                    // CONTENT_FLOWS_FROM/_TO relation.
-                    // Relation CONTENT_FLOWS_FROM for next paragraph will change
-                    // and relation CONTENT_FLOWS_TO for previous paragraph will change.
-                    if ( pNew->IsTextFrame() )
-                    {
-                        SwViewShell* pViewShell( pNew->getRootFrame()->GetCurrShell() );
-                        if ( pViewShell && pViewShell->GetLayout() &&
-                             pViewShell->GetLayout()->IsAnyShellAccessible() )
-                        {
-                            pViewShell->InvalidateAccessibleParaFlowRelation(
-                                dynamic_cast<SwTextFrame*>(pNew->FindNextCnt( true )),
-                                dynamic_cast<SwTextFrame*>(pNew->FindPrevCnt()) );
-                        }
-                    }
-                    pNew = pSct;
+                    OSL_ENSURE( pUp->Lower()->IsLayoutFrame(),"Who's in there?" );
+                    pUp = static_cast<SwLayoutFrame*>(pUp->Lower());
                 }
-
-                // If a Node got Frames attached before or after
-                if ( rIdx < GetIndex() )
-                    // the new one precedes me
-                    pNew->Paste( pFrame->GetUpper(), pFrame );
-                else
-                    // the new one succeeds me
-                    pNew->Paste( pFrame->GetUpper(), pFrame->GetNext() );
+                pNew->Paste( pUp );
                 // #i27138#
                 // notify accessibility paragraphs objects about changed
                 // CONTENT_FLOWS_FROM/_TO relation.
@@ -1129,9 +1104,34 @@ void SwSectionNode::MakeFramesForAdjacentContentNode(const SwNodeIndex & rIdx)
                             dynamic_cast<SwTextFrame*>(pNew->FindPrevCnt()) );
                     }
                 }
-                if ( bInitNewSect )
-                    static_cast<SwSectionFrame*>(pNew)->Init();
+                pNew = pSct;
+            }
+
+            // If a Node got Frames attached before or after
+            if ( rIdx < GetIndex() )
+                // the new one precedes me
+                pNew->Paste( pFrame->GetUpper(), pFrame );
+            else
+                // the new one succeeds me
+                pNew->Paste( pFrame->GetUpper(), pFrame->GetNext() );
+            // #i27138#
+            // notify accessibility paragraphs objects about changed
+            // CONTENT_FLOWS_FROM/_TO relation.
+            // Relation CONTENT_FLOWS_FROM for next paragraph will change
+            // and relation CONTENT_FLOWS_TO for previous paragraph will change.
+            if ( pNew->IsTextFrame() )
+            {
+                SwViewShell* pViewShell( pNew->getRootFrame()->GetCurrShell() );
+                if ( pViewShell && pViewShell->GetLayout() &&
+                     pViewShell->GetLayout()->IsAnyShellAccessible() )
+                {
+                    pViewShell->InvalidateAccessibleParaFlowRelation(
+                        dynamic_cast<SwTextFrame*>(pNew->FindNextCnt( true )),
+                        dynamic_cast<SwTextFrame*>(pNew->FindPrevCnt()) );
+                }
             }
+            if ( bInitNewSect )
+                static_cast<SwSectionFrame*>(pNew)->Init();
         }
     }
 }
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index b6cf2ff3d685..5f7e1d6ee3d3 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -901,29 +901,29 @@ static void lcl_RemoveBreaks(SwContentNode & rNode, SwTableFormat *const pTableF
     SwTextNode & rTextNode = *rNode.GetTextNode();
     // remove PageBreaks/PageDesc/ColBreak
     SfxItemSet const* pSet = rTextNode.GetpSwAttrSet();
-    if (pSet)
+    if (!pSet)
+        return;
+
+    const SfxPoolItem* pItem;
+    if (SfxItemState::SET == pSet->GetItemState(RES_BREAK, false, &pItem))
     {
-        const SfxPoolItem* pItem;
-        if (SfxItemState::SET == pSet->GetItemState(RES_BREAK, false, &pItem))
+        if (pTableFormat)
         {
-            if (pTableFormat)
-            {
-                pTableFormat->SetFormatAttr(*pItem);
-            }
-            rTextNode.ResetAttr(RES_BREAK);
-            pSet = rTextNode.GetpSwAttrSet();
+            pTableFormat->SetFormatAttr(*pItem);
         }
+        rTextNode.ResetAttr(RES_BREAK);
+        pSet = rTextNode.GetpSwAttrSet();
+    }
 
-        if (pSet
-            && (SfxItemState::SET == pSet->GetItemState(RES_PAGEDESC, false, &pItem))
-            && static_cast<SwFormatPageDesc const*>(pItem)->GetPageDesc())
+    if (pSet
+        && (SfxItemState::SET == pSet->GetItemState(RES_PAGEDESC, false, &pItem))
+        && static_cast<SwFormatPageDesc const*>(pItem)->GetPageDesc())
+    {
+        if (pTableFormat)
         {
-            if (pTableFormat)
-            {
-                pTableFormat->SetFormatAttr(*pItem);
-            }
-            rTextNode.ResetAttr(RES_PAGEDESC);
+            pTableFormat->SetFormatAttr(*pItem);
         }
+        rTextNode.ResetAttr(RES_PAGEDESC);
     }
 }
 
@@ -4138,28 +4138,28 @@ void SwDoc::ChkBoxNumFormat( SwTableBox& rBox, bool bCallUpdate )
             bChgd = false;
     }
 
-    if( bChgd )
+    if( !bChgd )
+        return;
+
+    if( pUndo )
     {
-        if( pUndo )
-        {
-            pUndo->SetBox( rBox );
-            GetIDocumentUndoRedo().AppendUndo(std::move(pUndo));
-            GetIDocumentUndoRedo().EndUndo( SwUndoId::END, nullptr );
-        }
+        pUndo->SetBox( rBox );
+        GetIDocumentUndoRedo().AppendUndo(std::move(pUndo));
+        GetIDocumentUndoRedo().EndUndo( SwUndoId::END, nullptr );
+    }
 
-        const SwTableNode* pTableNd = rBox.GetSttNd()->FindTableNode();
-        if( bCallUpdate )
-        {
-            SwTableFormulaUpdate aTableUpdate( &pTableNd->GetTable() );
-            getIDocumentFieldsAccess().UpdateTableFields( &aTableUpdate );
+    const SwTableNode* pTableNd = rBox.GetSttNd()->FindTableNode();
+    if( bCallUpdate )
+    {
+        SwTableFormulaUpdate aTableUpdate( &pTableNd->GetTable() );
+        getIDocumentFieldsAccess().UpdateTableFields( &aTableUpdate );
 
-            // TL_CHART2: update charts (when cursor leaves cell and
-            // automatic update is enabled)
-            if (AUTOUPD_FIELD_AND_CHARTS == GetDocumentSettingManager().getFieldUpdateFlags(true))
-                pTableNd->GetTable().UpdateCharts();
-        }
-        getIDocumentState().SetModified();
+        // TL_CHART2: update charts (when cursor leaves cell and
+        // automatic update is enabled)
+        if (AUTOUPD_FIELD_AND_CHARTS == GetDocumentSettingManager().getFieldUpdateFlags(true))
+            pTableNd->GetTable().UpdateCharts();
     }
+    getIDocumentState().SetModified();
 }
 
 void SwDoc::SetTableBoxFormulaAttrs( SwTableBox& rBox, const SfxItemSet& rSet )
@@ -4193,77 +4193,76 @@ void SwDoc::ClearLineNumAttrs( SwPosition const & rPos )
     SwContentNode *pNode = aPam.GetContentNode();
     if ( nullptr == pNode )
         return ;
-    if( pNode->IsTextNode() )
+    if( !pNode->IsTextNode() )
+        return;
+
+    SwTextNode * pTextNode = pNode->GetTextNode();
+    if (!(pTextNode && pTextNode->IsNumbered()
+        && pTextNode->GetText().isEmpty()))
+        return;
+
+    const SfxPoolItem* pFormatItem = nullptr;
+    SfxItemSet rSet( pTextNode->GetDoc()->GetAttrPool(),
+                svl::Items<RES_PARATR_BEGIN, RES_PARATR_END - 1>{});
+    pTextNode->SwContentNode::GetAttr( rSet );
+    if ( SfxItemState::SET != rSet.GetItemState( RES_PARATR_NUMRULE , false , &pFormatItem ) )
+        return;
+
+    SwUndoDelNum * pUndo;
+    if( GetIDocumentUndoRedo().DoesUndo() )
     {
-        SwTextNode * pTextNode = pNode->GetTextNode();
-        if (pTextNode && pTextNode->IsNumbered()
-            && pTextNode->GetText().isEmpty())
-        {
-            const SfxPoolItem* pFormatItem = nullptr;
-            SfxItemSet rSet( pTextNode->GetDoc()->GetAttrPool(),
-                        svl::Items<RES_PARATR_BEGIN, RES_PARATR_END - 1>{});
-            pTextNode->SwContentNode::GetAttr( rSet );
-            if ( SfxItemState::SET == rSet.GetItemState( RES_PARATR_NUMRULE , false , &pFormatItem ) )
-            {
-                SwUndoDelNum * pUndo;
-                if( GetIDocumentUndoRedo().DoesUndo() )
-                {
-                    GetIDocumentUndoRedo().ClearRedo();
-                    pUndo = new SwUndoDelNum( aPam );
-                    GetIDocumentUndoRedo().AppendUndo( std::unique_ptr<SwUndo>(pUndo) );
-                }
-                else
-                    pUndo = nullptr;
-                SwRegHistory aRegH( pUndo ? pUndo->GetHistory() : nullptr );
-                aRegH.RegisterInModify( pTextNode , *pTextNode );
-                if ( pUndo )
-                    pUndo->AddNode( *pTextNode );
-                std::unique_ptr<SfxStringItem> pNewItem(static_cast<SfxStringItem*>(pFormatItem->Clone()));
-                pNewItem->SetValue(OUString());
-                rSet.Put( std::move(pNewItem) );
-                pTextNode->SetAttr( rSet );
-            }
-        }
+        GetIDocumentUndoRedo().ClearRedo();
+        pUndo = new SwUndoDelNum( aPam );
+        GetIDocumentUndoRedo().AppendUndo( std::unique_ptr<SwUndo>(pUndo) );
     }
+    else
+        pUndo = nullptr;
+    SwRegHistory aRegH( pUndo ? pUndo->GetHistory() : nullptr );
+    aRegH.RegisterInModify( pTextNode , *pTextNode );
+    if ( pUndo )
+        pUndo->AddNode( *pTextNode );
+    std::unique_ptr<SfxStringItem> pNewItem(static_cast<SfxStringItem*>(pFormatItem->Clone()));
+    pNewItem->SetValue(OUString());
+    rSet.Put( std::move(pNewItem) );
+    pTextNode->SetAttr( rSet );
 }
 
 void SwDoc::ClearBoxNumAttrs( const SwNodeIndex& rNode )
 {
-    SwStartNode* pSttNd;
-    if( nullptr != ( pSttNd = rNode.GetNode().
-                                FindSttNodeByType( SwTableBoxStartNode )) &&
-        2 == pSttNd->EndOfSectionIndex() - pSttNd->GetIndex() )
-    {
-        SwTableBox* pBox = pSttNd->FindTableNode()->GetTable().
-                            GetTableBox( pSttNd->GetIndex() );
-
-        const SfxPoolItem* pFormatItem = nullptr;
-        const SfxItemSet& rSet = pBox->GetFrameFormat()->GetAttrSet();
-        if( SfxItemState::SET == rSet.GetItemState( RES_BOXATR_FORMAT, false, &pFormatItem ) ||
-            SfxItemState::SET == rSet.GetItemState( RES_BOXATR_FORMULA, false ) ||
-            SfxItemState::SET == rSet.GetItemState( RES_BOXATR_VALUE, false ))
-        {
-            if (GetIDocumentUndoRedo().DoesUndo())
-            {
-                GetIDocumentUndoRedo().AppendUndo(std::make_unique<SwUndoTableNumFormat>(*pBox));
-            }
+    SwStartNode* pSttNd = rNode.GetNode().FindSttNodeByType( SwTableBoxStartNode );
+    if( nullptr == pSttNd ||
+        2 != pSttNd->EndOfSectionIndex() - pSttNd->GetIndex())
+        return;
 
-            SwFrameFormat* pBoxFormat = pBox->ClaimFrameFormat();
+    SwTableBox* pBox = pSttNd->FindTableNode()->GetTable().
+                        GetTableBox( pSttNd->GetIndex() );
 
-            // Keep TextFormats!
-            sal_uInt16 nWhich1 = RES_BOXATR_FORMAT;
-            if( pFormatItem && GetNumberFormatter()->IsTextFormat(
-                    static_cast<const SwTableBoxNumFormat*>(pFormatItem)->GetValue() ))
-                nWhich1 = RES_BOXATR_FORMULA;
-            else
-                // Just resetting Attributes is not enough
-                // Make sure that the Text is formatted accordingly
-                pBoxFormat->SetFormatAttr( *GetDfltAttr( RES_BOXATR_FORMAT ));
+    const SfxPoolItem* pFormatItem = nullptr;
+    const SfxItemSet& rSet = pBox->GetFrameFormat()->GetAttrSet();
+    if( !(SfxItemState::SET == rSet.GetItemState( RES_BOXATR_FORMAT, false, &pFormatItem ) ||
+        SfxItemState::SET == rSet.GetItemState( RES_BOXATR_FORMULA, false ) ||
+        SfxItemState::SET == rSet.GetItemState( RES_BOXATR_VALUE, false )))
+        return;
 
-            pBoxFormat->ResetFormatAttr( nWhich1, RES_BOXATR_VALUE );
-            getIDocumentState().SetModified();
-        }
+    if (GetIDocumentUndoRedo().DoesUndo())
+    {
+        GetIDocumentUndoRedo().AppendUndo(std::make_unique<SwUndoTableNumFormat>(*pBox));
     }
+
+    SwFrameFormat* pBoxFormat = pBox->ClaimFrameFormat();
+
+    // Keep TextFormats!
+    sal_uInt16 nWhich1 = RES_BOXATR_FORMAT;
+    if( pFormatItem && GetNumberFormatter()->IsTextFormat(
+            static_cast<const SwTableBoxNumFormat*>(pFormatItem)->GetValue() ))
+        nWhich1 = RES_BOXATR_FORMULA;
+    else
+        // Just resetting Attributes is not enough
+        // Make sure that the Text is formatted accordingly
+        pBoxFormat->SetFormatAttr( *GetDfltAttr( RES_BOXATR_FORMAT ));
+
+    pBoxFormat->ResetFormatAttr( nWhich1, RES_BOXATR_VALUE );
+    getIDocumentState().SetModified();
 }
 
 /**
@@ -4620,28 +4619,28 @@ std::unique_ptr<SwTableAutoFormat> SwDoc::DelTableStyle(const OUString& rName, b
 void SwDoc::ChgTableStyle(const OUString& rName, const SwTableAutoFormat& rNewFormat)
 {
     SwTableAutoFormat* pFormat = GetTableStyles().FindAutoFormat(rName);
-    if (pFormat)
-    {
-        SwTableAutoFormat aOldFormat = *pFormat;
-        *pFormat = rNewFormat;
-        pFormat->SetName(rName);
+    if (!pFormat)
+        return;
 
-        size_t nTableCount = GetTableFrameFormatCount(true);
-        for (size_t i=0; i < nTableCount; ++i)
-        {
-            SwFrameFormat* pFrameFormat = &GetTableFrameFormat(i, true);
-            SwTable* pTable = SwTable::FindTable(pFrameFormat);
-            if (pTable->GetTableStyleName() == rName)
-                GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(pTable->GetTableNode());
-        }
+    SwTableAutoFormat aOldFormat = *pFormat;
+    *pFormat = rNewFormat;
+    pFormat->SetName(rName);
 
-        getIDocumentState().SetModified();
+    size_t nTableCount = GetTableFrameFormatCount(true);
+    for (size_t i=0; i < nTableCount; ++i)
+    {
+        SwFrameFormat* pFrameFormat = &GetTableFrameFormat(i, true);
+        SwTable* pTable = SwTable::FindTable(pFrameFormat);
+        if (pTable->GetTableStyleName() == rName)
+            GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(pTable->GetTableNode());
+    }
 
-        if (GetIDocumentUndoRedo().DoesUndo())
-        {
-            GetIDocumentUndoRedo().AppendUndo(
-                std::make_unique<SwUndoTableStyleUpdate>(*pFormat, aOldFormat, this));
-        }
+    getIDocumentState().SetModified();
+
+    if (GetIDocumentUndoRedo().DoesUndo())
+    {
+        GetIDocumentUndoRedo().AppendUndo(
+            std::make_unique<SwUndoTableStyleUpdate>(*pFormat, aOldFormat, this));
     }
 }
 
diff --git a/sw/source/core/docnode/ndtbl1.cxx b/sw/source/core/docnode/ndtbl1.cxx
index 798d20bf98fa..c9c4cd96b9c2 100644
--- a/sw/source/core/docnode/ndtbl1.cxx
+++ b/sw/source/core/docnode/ndtbl1.cxx
@@ -256,20 +256,20 @@ static void lcl_CollectLines( std::vector<SwTableLine*> &rArr, const SwCursor& r
 
     // Remove lines, that have a common superordinate row.
     // (Not for row split)
-    if ( bRemoveLines )
+    if ( !bRemoveLines )
+        return;
+
+    for ( std::vector<SwTableLine*>::size_type i = 0; i < rArr.size(); ++i )
     {
-        for ( std::vector<SwTableLine*>::size_type i = 0; i < rArr.size(); ++i )
+        SwTableLine *pUpLine = rArr[i];
+        for ( std::vector<SwTableLine*>::size_type k = 0; k < rArr.size(); ++k )
         {
-            SwTableLine *pUpLine = rArr[i];
-            for ( std::vector<SwTableLine*>::size_type k = 0; k < rArr.size(); ++k )
+            if ( k != i && ::lcl_IsAnLower( pUpLine, rArr[k] ) )
             {
-                if ( k != i && ::lcl_IsAnLower( pUpLine, rArr[k] ) )
-                {
-                    rArr.erase( rArr.begin() + k );
-                    if ( k <= i )
-                        --i;
-                    --k;
-                }
+                rArr.erase( rArr.begin() + k );
+                if ( k <= i )
+                    --i;
+                --k;
             }
         }
     }
@@ -318,27 +318,27 @@ static void lcl_ProcessBoxSize(std::vector<std::unique_ptr<SwTableFormatCmp>>& r
 void SwDoc::SetRowSplit( const SwCursor& rCursor, const SwFormatRowSplit &rNew )
 {
     SwTableNode* pTableNd = rCursor.GetPoint()->nNode.GetNode().FindTableNode();
-    if( pTableNd )
-    {
-        std::vector<SwTableLine*> aRowArr; // For Lines collecting
-        ::lcl_CollectLines( aRowArr, rCursor, false );
-
-        if( !aRowArr.empty() )
-        {
-            if (GetIDocumentUndoRedo().DoesUndo())
-            {
-                GetIDocumentUndoRedo().AppendUndo(std::make_unique<SwUndoAttrTable>(*pTableNd));
-            }
+    if( !pTableNd )
+        return;
 
-            std::vector<std::unique_ptr<SwTableFormatCmp>> aFormatCmp;
-            aFormatCmp.reserve( std::max( 255, static_cast<int>(aRowArr.size()) ) );
+    std::vector<SwTableLine*> aRowArr; // For Lines collecting
+    ::lcl_CollectLines( aRowArr, rCursor, false );
 
-            for( auto pLn : aRowArr )
-                ::lcl_ProcessRowAttr( aFormatCmp, pLn, rNew );
+    if( aRowArr.empty() )
+        return;
 
-            getIDocumentState().SetModified();
-        }
+    if (GetIDocumentUndoRedo().DoesUndo())
+    {
+        GetIDocumentUndoRedo().AppendUndo(std::make_unique<SwUndoAttrTable>(*pTableNd));
     }
+
+    std::vector<std::unique_ptr<SwTableFormatCmp>> aFormatCmp;
+    aFormatCmp.reserve( std::max( 255, static_cast<int>(aRowArr.size()) ) );
+
+    for( auto pLn : aRowArr )
+        ::lcl_ProcessRowAttr( aFormatCmp, pLn, rNew );
+
+    getIDocumentState().SetModified();
 }
 
 std::unique_ptr<SwFormatRowSplit> SwDoc::GetRowSplit( const SwCursor& rCursor )
@@ -383,26 +383,26 @@ std::unique_ptr<SwFormatRowSplit> SwDoc::GetRowSplit( const SwCursor& rCursor )
 void SwDoc::SetRowHeight( const SwCursor& rCursor, const SwFormatFrameSize &rNew )
 {
     SwTableNode* pTableNd = rCursor.GetPoint()->nNode.GetNode().FindTableNode();
-    if( pTableNd )
-    {
-        std::vector<SwTableLine*> aRowArr; // For Lines collecting
-        ::lcl_CollectLines( aRowArr, rCursor, true );
+    if( !pTableNd )
+        return;
 
-        if( !aRowArr.empty() )
-        {
-            if (GetIDocumentUndoRedo().DoesUndo())
-            {
-                GetIDocumentUndoRedo().AppendUndo(std::make_unique<SwUndoAttrTable>(*pTableNd));
-            }
+    std::vector<SwTableLine*> aRowArr; // For Lines collecting
+    ::lcl_CollectLines( aRowArr, rCursor, true );
 
-            std::vector<std::unique_ptr<SwTableFormatCmp>> aFormatCmp;
-            aFormatCmp.reserve( std::max( 255, static_cast<int>(aRowArr.size()) ) );
-            for ( auto pLn : aRowArr )
-                ::lcl_ProcessRowSize( aFormatCmp, pLn, rNew );
+    if( aRowArr.empty() )
+        return;
 
-            getIDocumentState().SetModified();
-        }
+    if (GetIDocumentUndoRedo().DoesUndo())
+    {
+        GetIDocumentUndoRedo().AppendUndo(std::make_unique<SwUndoAttrTable>(*pTableNd));
     }
+
+    std::vector<std::unique_ptr<SwTableFormatCmp>> aFormatCmp;
+    aFormatCmp.reserve( std::max( 255, static_cast<int>(aRowArr.size()) ) );
+    for ( auto pLn : aRowArr )
+        ::lcl_ProcessRowSize( aFormatCmp, pLn, rNew );
+
+    getIDocumentState().SetModified();
 }
 
 std::unique_ptr<SwFormatFrameSize> SwDoc::GetRowHeight( const SwCursor& rCursor )
@@ -481,27 +481,27 @@ bool SwDoc::BalanceRowHeight( const SwCursor& rCursor, bool bTstOnly, const bool
 void SwDoc::SetRowBackground( const SwCursor& rCursor, const SvxBrushItem &rNew )
 {
     SwTableNode* pTableNd = rCursor.GetPoint()->nNode.GetNode().FindTableNode();
-    if( pTableNd )
-    {
-        std::vector<SwTableLine*> aRowArr; // For Lines collecting
-        ::lcl_CollectLines( aRowArr, rCursor, true );
-
-        if( !aRowArr.empty() )
-        {
-            if (GetIDocumentUndoRedo().DoesUndo())
-            {
-                GetIDocumentUndoRedo().AppendUndo(std::make_unique<SwUndoAttrTable>(*pTableNd));
-            }
+    if( !pTableNd )
+        return;
 
-            std::vector<std::unique_ptr<SwTableFormatCmp>> aFormatCmp;
-            aFormatCmp.reserve( std::max( 255, static_cast<int>(aRowArr.size()) ) );
+    std::vector<SwTableLine*> aRowArr; // For Lines collecting
+    ::lcl_CollectLines( aRowArr, rCursor, true );
 
-            for( auto pLn : aRowArr )
-                ::lcl_ProcessRowAttr( aFormatCmp, pLn, rNew );
+    if( aRowArr.empty() )
+        return;
 
-            getIDocumentState().SetModified();
-        }
+    if (GetIDocumentUndoRedo().DoesUndo())
+    {
+        GetIDocumentUndoRedo().AppendUndo(std::make_unique<SwUndoAttrTable>(*pTableNd));
     }
+
+    std::vector<std::unique_ptr<SwTableFormatCmp>> aFormatCmp;
+    aFormatCmp.reserve( std::max( 255, static_cast<int>(aRowArr.size()) ) );
+
+    for( auto pLn : aRowArr )
+        ::lcl_ProcessRowAttr( aFormatCmp, pLn, rNew );
+
+    getIDocumentState().SetModified();
 }
 
 bool SwDoc::GetRowBackground( const SwCursor& rCursor, std::unique_ptr<SvxBrushItem>& rToFill )
@@ -861,67 +861,67 @@ void SwDoc::SetTabLineStyle( const SwCursor& rCursor,
     SwSelUnions aUnions;
     ::MakeSelUnions( aUnions, pStart, pEnd );
 
-    if( !aUnions.empty() )
+    if( aUnions.empty() )
+        return;
+
+    SwTable& rTable = pTableNd->GetTable();
+    if (GetIDocumentUndoRedo().DoesUndo())
     {
-        SwTable& rTable = pTableNd->GetTable();
-        if (GetIDocumentUndoRedo().DoesUndo())
-        {
-            GetIDocumentUndoRedo().AppendUndo(std::make_unique<SwUndoAttrTable>(*pTableNd));
-        }
+        GetIDocumentUndoRedo().AppendUndo(std::make_unique<SwUndoAttrTable>(*pTableNd));
+    }
 
-        for( auto &rU : aUnions )
-        {
-            SwSelUnion *pUnion = &rU;
-            SwTabFrame *pTab = pUnion->GetTable();
-            std::vector<SwCellFrame*> aCellArr;
-            aCellArr.reserve( 255 );
-            ::lcl_CollectCells( aCellArr, pUnion->GetUnion(), pTab );
+    for( auto &rU : aUnions )
+    {
+        SwSelUnion *pUnion = &rU;
+        SwTabFrame *pTab = pUnion->GetTable();
+        std::vector<SwCellFrame*> aCellArr;
+        aCellArr.reserve( 255 );
+        ::lcl_CollectCells( aCellArr, pUnion->GetUnion(), pTab );
 
-            for ( auto pCell : aCellArr )
-            {
-                // Do not set anything by default in HeadlineRepeats
-                if ( pTab->IsFollow() && pTab->IsInHeadline( *pCell ) )
-                    continue;
+        for ( auto pCell : aCellArr )
+        {
+            // Do not set anything by default in HeadlineRepeats
+            if ( pTab->IsFollow() && pTab->IsInHeadline( *pCell ) )
+                continue;
 
-                const_cast<SwTableBox*>(pCell->GetTabBox())->ClaimFrameFormat();
-                SwFrameFormat *pFormat = pCell->GetFormat();
-                std::unique_ptr<SvxBoxItem> aBox(pFormat->GetBox().Clone());
+            const_cast<SwTableBox*>(pCell->GetTabBox())->ClaimFrameFormat();
+            SwFrameFormat *pFormat = pCell->GetFormat();
+            std::unique_ptr<SvxBoxItem> aBox(pFormat->GetBox().Clone());
 
-                if ( !pBorderLine && bSetLine )
-                {
-                    aBox.reset(::GetDfltAttr(RES_BOX)->Clone());
-                }
-                else
-                {
-                    if ( aBox->GetTop() )
-                        ::lcl_SetLineStyle( const_cast<SvxBorderLine*>(aBox->GetTop()),
-                                        pColor, pBorderLine );
-                    if ( aBox->GetBottom() )
-                        ::lcl_SetLineStyle( const_cast<SvxBorderLine*>(aBox->GetBottom()),
-                                        pColor, pBorderLine );
-                    if ( aBox->GetLeft() )
-                        ::lcl_SetLineStyle( const_cast<SvxBorderLine*>(aBox->GetLeft()),
-                                        pColor, pBorderLine );
-                    if ( aBox->GetRight() )
-                        ::lcl_SetLineStyle( const_cast<SvxBorderLine*>(aBox->GetRight()),
-                                        pColor, pBorderLine );
-                }
-                pFormat->SetFormatAttr( *aBox );
+            if ( !pBorderLine && bSetLine )
+            {
+                aBox.reset(::GetDfltAttr(RES_BOX)->Clone());
+            }
+            else
+            {
+                if ( aBox->GetTop() )
+                    ::lcl_SetLineStyle( const_cast<SvxBorderLine*>(aBox->GetTop()),
+                                    pColor, pBorderLine );
+                if ( aBox->GetBottom() )
+                    ::lcl_SetLineStyle( const_cast<SvxBorderLine*>(aBox->GetBottom()),
+                                    pColor, pBorderLine );
+                if ( aBox->GetLeft() )
+                    ::lcl_SetLineStyle( const_cast<SvxBorderLine*>(aBox->GetLeft()),
+                                    pColor, pBorderLine );
+                if ( aBox->GetRight() )
+                    ::lcl_SetLineStyle( const_cast<SvxBorderLine*>(aBox->GetRight()),
+                                    pColor, pBorderLine );
             }
+            pFormat->SetFormatAttr( *aBox );
         }
+    }
 
-        SwHTMLTableLayout *pTableLayout = rTable.GetHTMLTableLayout();
-        if( pTableLayout )
-        {
-            SwContentFrame* pFrame = rCursor.GetContentNode()->getLayoutFrame( rCursor.GetContentNode()->GetDoc()->getIDocumentLayoutAccess().GetCurrentLayout() );
-            SwTabFrame* pTabFrame = pFrame->ImplFindTabFrame();
+    SwHTMLTableLayout *pTableLayout = rTable.GetHTMLTableLayout();
+    if( pTableLayout )
+    {
+        SwContentFrame* pFrame = rCursor.GetContentNode()->getLayoutFrame( rCursor.GetContentNode()->GetDoc()->getIDocumentLayoutAccess().GetCurrentLayout() );
+        SwTabFrame* pTabFrame = pFrame->ImplFindTabFrame();
 
-            pTableLayout->BordersChanged(
-                pTableLayout->GetBrowseWidthByTabFrame( *pTabFrame ) );
-        }
-        ::ClearFEShellTabCols(*this, nullptr);
-        getIDocumentState().SetModified();
+        pTableLayout->BordersChanged(
+            pTableLayout->GetBrowseWidthByTabFrame( *pTabFrame ) );
     }
+    ::ClearFEShellTabCols(*this, nullptr);
+    getIDocumentState().SetModified();
 }
 
 void SwDoc::GetTabBorders( const SwCursor& rCursor, SfxItemSet& rSet )
@@ -937,257 +937,257 @@ void SwDoc::GetTabBorders( const SwCursor& rCursor, SfxItemSet& rSet )
     SwSelUnions aUnions;
     ::MakeSelUnions( aUnions, pStart, pEnd );
 
-    if( !aUnions.empty() )
-    {
-        SvxBoxItem     aSetBox    ( rSet.Get(RES_BOX    ) );
-        SvxBoxInfoItem aSetBoxInfo( rSet.Get(SID_ATTR_BORDER_INNER) );
+    if( aUnions.empty() )
+        return;
 
-        bool bTopSet      = false,
-             bBottomSet   = false,
-             bLeftSet     = false,
-             bRightSet    = false,
-             bHoriSet     = false,
-             bVertSet     = false,
-             bDistanceSet = false,
-             bRTLTab      = false;
+    SvxBoxItem     aSetBox    ( rSet.Get(RES_BOX    ) );
+    SvxBoxInfoItem aSetBoxInfo( rSet.Get(SID_ATTR_BORDER_INNER) );
 
-        aSetBoxInfo.ResetFlags();
+    bool bTopSet      = false,
+         bBottomSet   = false,
+         bLeftSet     = false,
+         bRightSet    = false,
+         bHoriSet     = false,
+         bVertSet     = false,
+         bDistanceSet = false,
+         bRTLTab      = false;
 
-        for ( SwSelUnions::size_type i = 0; i < aUnions.size(); ++i )
-        {
-            SwSelUnion *pUnion = &aUnions[i];
-            const SwTabFrame *pTab = pUnion->GetTable();
-            const SwRect &rUnion = pUnion->GetUnion();
-            const bool bFirst = i == 0;
-            const bool bLast  = (i == aUnions.size() - 1);
+    aSetBoxInfo.ResetFlags();
 
-            std::vector<SwCellFrame*> aCellArr;
-            aCellArr.reserve(255);
-            ::lcl_CollectCells( aCellArr, rUnion, const_cast<SwTabFrame*>(pTab) );
+    for ( SwSelUnions::size_type i = 0; i < aUnions.size(); ++i )
+    {
+        SwSelUnion *pUnion = &aUnions[i];
+        const SwTabFrame *pTab = pUnion->GetTable();
+        const SwRect &rUnion = pUnion->GetUnion();
+        const bool bFirst = i == 0;
+        const bool bLast  = (i == aUnions.size() - 1);
 
-            for ( auto pCell : aCellArr )
+        std::vector<SwCellFrame*> aCellArr;
+        aCellArr.reserve(255);
+        ::lcl_CollectCells( aCellArr, rUnion, const_cast<SwTabFrame*>(pTab) );
+
+        for ( auto pCell : aCellArr )
+        {
+            const bool bVert = pTab->IsVertical();
+            const bool bRTL = bRTLTab = pTab->IsRightToLeft();
+            bool bTopOver, bLeftOver, bRightOver, bBottomOver;
+            if ( bVert )
             {
-                const bool bVert = pTab->IsVertical();
-                const bool bRTL = bRTLTab = pTab->IsRightToLeft();
-                bool bTopOver, bLeftOver, bRightOver, bBottomOver;
-                if ( bVert )
-                {
-                    bTopOver = pCell->getFrameArea().Right() >= rUnion.Right();
-                    bLeftOver = pCell->getFrameArea().Top() <= rUnion.Top();
-                    bRightOver = pCell->getFrameArea().Bottom() >= rUnion.Bottom();
-                    bBottomOver = pCell->getFrameArea().Left() <= rUnion.Left();
-                }
-                else
-                {
-                    bTopOver = pCell->getFrameArea().Top() <= rUnion.Top();
-                    bLeftOver = pCell->getFrameArea().Left() <= rUnion.Left();
-                    bRightOver = pCell->getFrameArea().Right() >= rUnion.Right();
-                    bBottomOver = pCell->getFrameArea().Bottom() >= rUnion.Bottom();
-                }
+                bTopOver = pCell->getFrameArea().Right() >= rUnion.Right();
+                bLeftOver = pCell->getFrameArea().Top() <= rUnion.Top();
+                bRightOver = pCell->getFrameArea().Bottom() >= rUnion.Bottom();
+                bBottomOver = pCell->getFrameArea().Left() <= rUnion.Left();
+            }
+            else
+            {
+                bTopOver = pCell->getFrameArea().Top() <= rUnion.Top();
+                bLeftOver = pCell->getFrameArea().Left() <= rUnion.Left();
+                bRightOver = pCell->getFrameArea().Right() >= rUnion.Right();
+                bBottomOver = pCell->getFrameArea().Bottom() >= rUnion.Bottom();
+            }
 
-                if ( bRTL )
-                {
-                    bool bTmp = bRightOver;
-                    bRightOver = bLeftOver;
-                    bLeftOver = bTmp;
-                }
+            if ( bRTL )
+            {
+                bool bTmp = bRightOver;
+                bRightOver = bLeftOver;
+                bLeftOver = bTmp;
+            }
 
-                const SwFrameFormat  *pFormat  = pCell->GetFormat();
-                const SvxBoxItem  &rBox  = pFormat->GetBox();
+            const SwFrameFormat  *pFormat  = pCell->GetFormat();
+            const SvxBoxItem  &rBox  = pFormat->GetBox();
 
-                // Top Border
-                if ( bFirst && bTopOver )
+            // Top Border
+            if ( bFirst && bTopOver )
+            {
+                if (aSetBoxInfo.IsValid(SvxBoxInfoItemValidFlags::TOP))
                 {
-                    if (aSetBoxInfo.IsValid(SvxBoxInfoItemValidFlags::TOP))
+                    if ( !bTopSet )
+                    {   bTopSet = true;
+                        aSetBox.SetLine( rBox.GetTop(), SvxBoxItemLine::TOP );
+                    }
+                    else if ((aSetBox.GetTop() && rBox.GetTop() &&
+                             (*aSetBox.GetTop() != *rBox.GetTop())) ||
+                             ((!aSetBox.GetTop()) != (!rBox.GetTop()))) // != expression is true, if one and only one of the two pointers is !0
                     {
-                        if ( !bTopSet )
-                        {   bTopSet = true;
-                            aSetBox.SetLine( rBox.GetTop(), SvxBoxItemLine::TOP );
-                        }
-                        else if ((aSetBox.GetTop() && rBox.GetTop() &&
-                                 (*aSetBox.GetTop() != *rBox.GetTop())) ||
-                                 ((!aSetBox.GetTop()) != (!rBox.GetTop()))) // != expression is true, if one and only one of the two pointers is !0
-                        {
-                            aSetBoxInfo.SetValid(SvxBoxInfoItemValidFlags::TOP, false );
-                            aSetBox.SetLine( nullptr, SvxBoxItemLine::TOP );
-                        }
+                        aSetBoxInfo.SetValid(SvxBoxInfoItemValidFlags::TOP, false );
+                        aSetBox.SetLine( nullptr, SvxBoxItemLine::TOP );
                     }
                 }
+            }
 
-                // Left Border
-                if ( bLeftOver )
+            // Left Border
+            if ( bLeftOver )
+            {
+                if (aSetBoxInfo.IsValid(SvxBoxInfoItemValidFlags::LEFT))
                 {
-                    if (aSetBoxInfo.IsValid(SvxBoxInfoItemValidFlags::LEFT))
+                    if ( !bLeftSet )
+                    {   bLeftSet = true;
+                        aSetBox.SetLine( rBox.GetLeft(), SvxBoxItemLine::LEFT );
+                    }
+                    else if ((aSetBox.GetLeft() && rBox.GetLeft() &&
+                             (*aSetBox.GetLeft() != *rBox.GetLeft())) ||
+                             ((!aSetBox.GetLeft()) != (!rBox.GetLeft())))
                     {
-                        if ( !bLeftSet )
-                        {   bLeftSet = true;
-                            aSetBox.SetLine( rBox.GetLeft(), SvxBoxItemLine::LEFT );
-                        }
-                        else if ((aSetBox.GetLeft() && rBox.GetLeft() &&
-                                 (*aSetBox.GetLeft() != *rBox.GetLeft())) ||
-                                 ((!aSetBox.GetLeft()) != (!rBox.GetLeft())))
-                        {
-                            aSetBoxInfo.SetValid(SvxBoxInfoItemValidFlags::LEFT, false );
-                            aSetBox.SetLine( nullptr, SvxBoxItemLine::LEFT );
-                        }
+                        aSetBoxInfo.SetValid(SvxBoxInfoItemValidFlags::LEFT, false );
+                        aSetBox.SetLine( nullptr, SvxBoxItemLine::LEFT );
                     }
                 }
-                else
+            }
+            else
+            {
+                if (aSetBoxInfo.IsValid(SvxBoxInfoItemValidFlags::VERT))
                 {
-                    if (aSetBoxInfo.IsValid(SvxBoxInfoItemValidFlags::VERT))
-                    {
-                        if ( !bVertSet )
-                        {   bVertSet = true;
-                            aSetBoxInfo.SetLine( rBox.GetLeft(), SvxBoxInfoItemLine::VERT );
-                        }
-                        else if ((aSetBoxInfo.GetVert() && rBox.GetLeft() &&
-                                 (*aSetBoxInfo.GetVert() != *rBox.GetLeft())) ||
-                                 ((!aSetBoxInfo.GetVert()) != (!rBox.GetLeft())))
-                        {   aSetBoxInfo.SetValid( SvxBoxInfoItemValidFlags::VERT, false );
-                            aSetBoxInfo.SetLine( nullptr, SvxBoxInfoItemLine::VERT );
-                        }
+                    if ( !bVertSet )
+                    {   bVertSet = true;
+                        aSetBoxInfo.SetLine( rBox.GetLeft(), SvxBoxInfoItemLine::VERT );
+                    }
+                    else if ((aSetBoxInfo.GetVert() && rBox.GetLeft() &&
+                             (*aSetBoxInfo.GetVert() != *rBox.GetLeft())) ||
+                             ((!aSetBoxInfo.GetVert()) != (!rBox.GetLeft())))
+                    {   aSetBoxInfo.SetValid( SvxBoxInfoItemValidFlags::VERT, false );
+                        aSetBoxInfo.SetLine( nullptr, SvxBoxInfoItemLine::VERT );
                     }
                 }
+            }
 
-                // Right Border
-                if ( aSetBoxInfo.IsValid(SvxBoxInfoItemValidFlags::RIGHT) && bRightOver )
+            // Right Border
+            if ( aSetBoxInfo.IsValid(SvxBoxInfoItemValidFlags::RIGHT) && bRightOver )
+            {
+                if ( !bRightSet )
+                {   bRightSet = true;
+                    aSetBox.SetLine( rBox.GetRight(), SvxBoxItemLine::RIGHT );
+                }
+                else if ((aSetBox.GetRight() && rBox.GetRight() &&
+                         (*aSetBox.GetRight() != *rBox.GetRight())) ||
+                         (!aSetBox.GetRight() != !rBox.GetRight()))
+                {   aSetBoxInfo.SetValid( SvxBoxInfoItemValidFlags::RIGHT, false );
+                    aSetBox.SetLine( nullptr, SvxBoxItemLine::RIGHT );
+                }
+            }
+
+            // Bottom Border
+            if ( bLast && bBottomOver )
+            {
+                if ( aSetBoxInfo.IsValid(SvxBoxInfoItemValidFlags::BOTTOM) )
                 {
-                    if ( !bRightSet )
-                    {   bRightSet = true;
-                        aSetBox.SetLine( rBox.GetRight(), SvxBoxItemLine::RIGHT );
+                    if ( !bBottomSet )
+                    {   bBottomSet = true;
+                        aSetBox.SetLine( rBox.GetBottom(), SvxBoxItemLine::BOTTOM );
                     }
-                    else if ((aSetBox.GetRight() && rBox.GetRight() &&
-                             (*aSetBox.GetRight() != *rBox.GetRight())) ||
-                             (!aSetBox.GetRight() != !rBox.GetRight()))
-                    {   aSetBoxInfo.SetValid( SvxBoxInfoItemValidFlags::RIGHT, false );
-                        aSetBox.SetLine( nullptr, SvxBoxItemLine::RIGHT );
+                    else if ((aSetBox.GetBottom() && rBox.GetBottom() &&
+                             (*aSetBox.GetBottom() != *rBox.GetBottom())) ||
+                             (!aSetBox.GetBottom() != !rBox.GetBottom()))
+                    {   aSetBoxInfo.SetValid( SvxBoxInfoItemValidFlags::BOTTOM, false );
+                        aSetBox.SetLine( nullptr, SvxBoxItemLine::BOTTOM );
                     }
                 }
-
-                // Bottom Border
-                if ( bLast && bBottomOver )
+            }
+            // In all Lines, except for the last one, the horizontal Line
+            // is taken from the Bottom Line.
+            else
+            {
+                if (aSetBoxInfo.IsValid(SvxBoxInfoItemValidFlags::HORI))
                 {
-                    if ( aSetBoxInfo.IsValid(SvxBoxInfoItemValidFlags::BOTTOM) )
+                    if ( !bHoriSet )
+                    {   bHoriSet = true;
+                        aSetBoxInfo.SetLine( rBox.GetBottom(), SvxBoxInfoItemLine::HORI );
+                    }
+                    else if ((aSetBoxInfo.GetHori() && rBox.GetBottom() &&
+                             (*aSetBoxInfo.GetHori() != *rBox.GetBottom())) ||
+                             ((!aSetBoxInfo.GetHori()) != (!rBox.GetBottom())))
                     {
-                        if ( !bBottomSet )
-                        {   bBottomSet = true;
-                            aSetBox.SetLine( rBox.GetBottom(), SvxBoxItemLine::BOTTOM );
-                        }
-                        else if ((aSetBox.GetBottom() && rBox.GetBottom() &&
-                                 (*aSetBox.GetBottom() != *rBox.GetBottom())) ||
-                                 (!aSetBox.GetBottom() != !rBox.GetBottom()))
-                        {   aSetBoxInfo.SetValid( SvxBoxInfoItemValidFlags::BOTTOM, false );
-                            aSetBox.SetLine( nullptr, SvxBoxItemLine::BOTTOM );
-                        }
+                        aSetBoxInfo.SetValid( SvxBoxInfoItemValidFlags::HORI, false );
+                        aSetBoxInfo.SetLine( nullptr, SvxBoxInfoItemLine::HORI );
                     }
                 }
-                // In all Lines, except for the last one, the horizontal Line
-                // is taken from the Bottom Line.
+            }
+
+            // Distance to text
+            if (aSetBoxInfo.IsValid(SvxBoxInfoItemValidFlags::DISTANCE))
+            {
+                if( !bDistanceSet ) // Set on first iteration
+                {
+                    bDistanceSet = true;
+                    for( SvxBoxItemLine k : o3tl::enumrange<SvxBoxItemLine>() )
+                        aSetBox.SetDistance( rBox.GetDistance( k ), k );
+                }
                 else
                 {
-                    if (aSetBoxInfo.IsValid(SvxBoxInfoItemValidFlags::HORI))
-                    {
-                        if ( !bHoriSet )
-                        {   bHoriSet = true;
-                            aSetBoxInfo.SetLine( rBox.GetBottom(), SvxBoxInfoItemLine::HORI );
-                        }
-                        else if ((aSetBoxInfo.GetHori() && rBox.GetBottom() &&
-                                 (*aSetBoxInfo.GetHori() != *rBox.GetBottom())) ||
-                                 ((!aSetBoxInfo.GetHori()) != (!rBox.GetBottom())))
+                    for( SvxBoxItemLine k : o3tl::enumrange<SvxBoxItemLine>() )
+                        if( aSetBox.GetDistance( k ) !=
+                            rBox.GetDistance( k ) )
                         {
-                            aSetBoxInfo.SetValid( SvxBoxInfoItemValidFlags::HORI, false );
-                            aSetBoxInfo.SetLine( nullptr, SvxBoxInfoItemLine::HORI );
+                            aSetBoxInfo.SetValid( SvxBoxInfoItemValidFlags::DISTANCE, false );
+                            aSetBox.SetAllDistances(0);
+                            break;
                         }
-                    }
-                }
-
-                // Distance to text
-                if (aSetBoxInfo.IsValid(SvxBoxInfoItemValidFlags::DISTANCE))
-                {
-                    if( !bDistanceSet ) // Set on first iteration
-                    {
-                        bDistanceSet = true;
-                        for( SvxBoxItemLine k : o3tl::enumrange<SvxBoxItemLine>() )
-                            aSetBox.SetDistance( rBox.GetDistance( k ), k );
-                    }
-                    else
-                    {
-                        for( SvxBoxItemLine k : o3tl::enumrange<SvxBoxItemLine>() )
-                            if( aSetBox.GetDistance( k ) !=
-                                rBox.GetDistance( k ) )
-                            {
-                                aSetBoxInfo.SetValid( SvxBoxInfoItemValidFlags::DISTANCE, false );
-                                aSetBox.SetAllDistances(0);
-                                break;
-                            }
-                    }
                 }
             }
         }
+    }
 
-        // fdo#62470 fix the reading for table format.
-        if ( bRTLTab )
-        {
-            SvxBoxItem     aTempBox    ( rSet.Get(RES_BOX    ) );
-            SvxBoxInfoItem aTempBoxInfo( rSet.Get(SID_ATTR_BORDER_INNER) );
+    // fdo#62470 fix the reading for table format.
+    if ( bRTLTab )
+    {
+        SvxBoxItem     aTempBox    ( rSet.Get(RES_BOX    ) );
+        SvxBoxInfoItem aTempBoxInfo( rSet.Get(SID_ATTR_BORDER_INNER) );
 
-            aTempBox.SetLine( aSetBox.GetRight(), SvxBoxItemLine::RIGHT);
-            aSetBox.SetLine( aSetBox.GetLeft(), SvxBoxItemLine::RIGHT);
-            aSetBox.SetLine( aTempBox.GetRight(), SvxBoxItemLine::LEFT);
+        aTempBox.SetLine( aSetBox.GetRight(), SvxBoxItemLine::RIGHT);
+        aSetBox.SetLine( aSetBox.GetLeft(), SvxBoxItemLine::RIGHT);
+        aSetBox.SetLine( aTempBox.GetRight(), SvxBoxItemLine::LEFT);
 
-            aTempBoxInfo.SetValid( SvxBoxInfoItemValidFlags::LEFT, aSetBoxInfo.IsValid(SvxBoxInfoItemValidFlags::LEFT) );
-            aSetBoxInfo.SetValid( SvxBoxInfoItemValidFlags::LEFT, aSetBoxInfo.IsValid(SvxBoxInfoItemValidFlags::RIGHT) );
-            aSetBoxInfo.SetValid( SvxBoxInfoItemValidFlags::RIGHT, aTempBoxInfo.IsValid(SvxBoxInfoItemValidFlags::LEFT) );
-        }
-
-        rSet.Put( aSetBox );
-        rSet.Put( aSetBoxInfo );
+        aTempBoxInfo.SetValid( SvxBoxInfoItemValidFlags::LEFT, aSetBoxInfo.IsValid(SvxBoxInfoItemValidFlags::LEFT) );
+        aSetBoxInfo.SetValid( SvxBoxInfoItemValidFlags::LEFT, aSetBoxInfo.IsValid(SvxBoxInfoItemValidFlags::RIGHT) );
+        aSetBoxInfo.SetValid( SvxBoxInfoItemValidFlags::RIGHT, aTempBoxInfo.IsValid(SvxBoxInfoItemValidFlags::LEFT) );
     }
+
+    rSet.Put( aSetBox );
+    rSet.Put( aSetBoxInfo );
 }
 
 void SwDoc::SetBoxAttr( const SwCursor& rCursor, const SfxPoolItem &rNew )
 {
     SwTableNode* pTableNd = rCursor.GetPoint()->nNode.GetNode().FindTableNode();
     SwSelBoxes aBoxes;
-    if( pTableNd && ::lcl_GetBoxSel( rCursor, aBoxes, true ) )
-    {
-        SwTable& rTable = pTableNd->GetTable();
-        if (GetIDocumentUndoRedo().DoesUndo())
-        {
-            GetIDocumentUndoRedo().AppendUndo( std::make_unique<SwUndoAttrTable>(*pTableNd) );
-        }
+    if( !(pTableNd && ::lcl_GetBoxSel( rCursor, aBoxes, true )) )
+        return;
 
-        std::vector<std::unique_ptr<SwTableFormatCmp>> aFormatCmp;
-        aFormatCmp.reserve(std::max<size_t>(255, aBoxes.size()));
-        for (size_t i = 0; i < aBoxes.size(); ++i)
-        {
-            SwTableBox *pBox = aBoxes[i];
+    SwTable& rTable = pTableNd->GetTable();
+    if (GetIDocumentUndoRedo().DoesUndo())
+    {
+        GetIDocumentUndoRedo().AppendUndo( std::make_unique<SwUndoAttrTable>(*pTableNd) );
+    }
 
-            SwFrameFormat *pNewFormat = SwTableFormatCmp::FindNewFormat( aFormatCmp, pBox->GetFrameFormat(), 0 );
-            if ( nullptr != pNewFormat )
-                pBox->ChgFrameFormat( static_cast<SwTableBoxFormat*>(pNewFormat) );
-            else
-            {
-                SwFrameFormat *pOld = pBox->GetFrameFormat();
-                SwFrameFormat *pNew = pBox->ClaimFrameFormat();
-                pNew->SetFormatAttr( rNew );
-                aFormatCmp.push_back(std::make_unique<SwTableFormatCmp>(pOld, pNew, 0));
-            }
+    std::vector<std::unique_ptr<SwTableFormatCmp>> aFormatCmp;
+    aFormatCmp.reserve(std::max<size_t>(255, aBoxes.size()));
+    for (size_t i = 0; i < aBoxes.size(); ++i)
+    {
+        SwTableBox *pBox = aBoxes[i];
 
-            pBox->SetDirectFormatting(true);
+        SwFrameFormat *pNewFormat = SwTableFormatCmp::FindNewFormat( aFormatCmp, pBox->GetFrameFormat(), 0 );
+        if ( nullptr != pNewFormat )
+            pBox->ChgFrameFormat( static_cast<SwTableBoxFormat*>(pNewFormat) );
+        else
+        {
+            SwFrameFormat *pOld = pBox->GetFrameFormat();
+            SwFrameFormat *pNew = pBox->ClaimFrameFormat();
+            pNew->SetFormatAttr( rNew );
+            aFormatCmp.push_back(std::make_unique<SwTableFormatCmp>(pOld, pNew, 0));
         }
 
-        SwHTMLTableLayout *pTableLayout = rTable.GetHTMLTableLayout();
-        if( pTableLayout )
-        {
-            SwContentFrame* pFrame = rCursor.GetContentNode()->getLayoutFrame( rCursor.GetContentNode()->GetDoc()->getIDocumentLayoutAccess().GetCurrentLayout() );
-            SwTabFrame* pTabFrame = pFrame->ImplFindTabFrame();
+        pBox->SetDirectFormatting(true);
+    }
 
-            pTableLayout->Resize(
-                pTableLayout->GetBrowseWidthByTabFrame( *pTabFrame ), true );
-        }
-        getIDocumentState().SetModified();
+    SwHTMLTableLayout *pTableLayout = rTable.GetHTMLTableLayout();
+    if( pTableLayout )
+    {
+        SwContentFrame* pFrame = rCursor.GetContentNode()->getLayoutFrame( rCursor.GetContentNode()->GetDoc()->getIDocumentLayoutAccess().GetCurrentLayout() );
+        SwTabFrame* pTabFrame = pFrame->ImplFindTabFrame();
+
+        pTableLayout->Resize(
+            pTableLayout->GetBrowseWidthByTabFrame( *pTabFrame ), true );
     }
+    getIDocumentState().SetModified();
 }
 
 bool SwDoc::GetBoxAttr( const SwCursor& rCursor, std::unique_ptr<SfxPoolItem>& rToFill )
diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx
index 171aa8454744..1c35410c49d5 100644
--- a/sw/source/core/docnode/node.cxx
+++ b/sw/source/core/docnode/node.cxx
@@ -109,29 +109,29 @@ static void SetParent( std::shared_ptr<const SfxItemSet>& rpAttrSet,
 
     const SwAttrSet* pParentSet = pParentFormat ? &pParentFormat->GetAttrSet() : nullptr;
 
-    if ( pParentSet != pAttrSet->GetParent() )
-    {
-        SwAttrSet aNewSet( *pAttrSet );
-        aNewSet.SetParent( pParentSet );
-        aNewSet.ClearItem( RES_FRMATR_STYLE_NAME );
-        aNewSet.ClearItem( RES_FRMATR_CONDITIONAL_STYLE_NAME );
-        OUString sVal;
+    if ( pParentSet == pAttrSet->GetParent() )
+        return;
 
-        if ( pParentFormat )
-        {
-            SwStyleNameMapper::FillProgName( pParentFormat->GetName(), sVal, SwGetPoolIdFromName::TxtColl );
-            const SfxStringItem aAnyFormatColl( RES_FRMATR_STYLE_NAME, sVal );
-            aNewSet.Put( aAnyFormatColl );
+    SwAttrSet aNewSet( *pAttrSet );
+    aNewSet.SetParent( pParentSet );
+    aNewSet.ClearItem( RES_FRMATR_STYLE_NAME );
+    aNewSet.ClearItem( RES_FRMATR_CONDITIONAL_STYLE_NAME );
+    OUString sVal;
 
-            if ( pConditionalFormat != pParentFormat )
-                SwStyleNameMapper::FillProgName( pConditionalFormat->GetName(), sVal, SwGetPoolIdFromName::TxtColl );
+    if ( pParentFormat )
+    {
+        SwStyleNameMapper::FillProgName( pParentFormat->GetName(), sVal, SwGetPoolIdFromName::TxtColl );
+        const SfxStringItem aAnyFormatColl( RES_FRMATR_STYLE_NAME, sVal );
+        aNewSet.Put( aAnyFormatColl );
 
-            const SfxStringItem aFormatColl( RES_FRMATR_CONDITIONAL_STYLE_NAME, sVal );
-            aNewSet.Put( aFormatColl );
-        }
+        if ( pConditionalFormat != pParentFormat )
+            SwStyleNameMapper::FillProgName( pConditionalFormat->GetName(), sVal, SwGetPoolIdFromName::TxtColl );
 
-        GetNewAutoStyle( rpAttrSet, rNode, aNewSet );
+        const SfxStringItem aFormatColl( RES_FRMATR_CONDITIONAL_STYLE_NAME, sVal );
+        aNewSet.Put( aFormatColl );
     }
+
+    GetNewAutoStyle( rpAttrSet, rNode, aNewSet );
 }
 
 static const SfxPoolItem* Put( std::shared_ptr<const SfxItemSet>& rpAttrSet,
@@ -291,20 +291,20 @@ SwNode::SwNode( const SwNodeIndex &rWhere, const SwNodeType nNdType )
 #endif
     , m_pStartOfSection( nullptr )
 {
-    if( rWhere.GetIndex() )
+    if( !rWhere.GetIndex() )
+        return;
+
+    SwNodes& rNodes = const_cast<SwNodes&> (rWhere.GetNodes());
+    SwNode* pNd = rNodes[ rWhere.GetIndex() -1 ];
+    rNodes.InsertNode( this, rWhere );
+    m_pStartOfSection = pNd->GetStartNode();
+    if( nullptr == m_pStartOfSection )
     {
-        SwNodes& rNodes = const_cast<SwNodes&> (rWhere.GetNodes());
-        SwNode* pNd = rNodes[ rWhere.GetIndex() -1 ];
-        rNodes.InsertNode( this, rWhere );
-        m_pStartOfSection = pNd->GetStartNode();
-        if( nullptr == m_pStartOfSection )
+        m_pStartOfSection = pNd->m_pStartOfSection;
+        if( pNd->GetEndNode() )     // Skip EndNode ? Section
         {
+            pNd = m_pStartOfSection;
             m_pStartOfSection = pNd->m_pStartOfSection;
-            if( pNd->GetEndNode() )     // Skip EndNode ? Section
-            {
-                pNd = m_pStartOfSection;
-                m_pStartOfSection = pNd->m_pStartOfSection;
-            }
         }
     }
 }
@@ -325,19 +325,19 @@ SwNode::SwNode( SwNodes& rNodes, sal_uLong nPos, const SwNodeType nNdType )
 #endif
     , m_pStartOfSection( nullptr )
 {
-    if( nPos )
+    if( !nPos )
+        return;
+
+    SwNode* pNd = rNodes[ nPos - 1 ];
+    rNodes.InsertNode( this, nPos );
+    m_pStartOfSection = pNd->GetStartNode();
+    if( nullptr == m_pStartOfSection )
     {
-        SwNode* pNd = rNodes[ nPos - 1 ];
-        rNodes.InsertNode( this, nPos );
-        m_pStartOfSection = pNd->GetStartNode();
-        if( nullptr == m_pStartOfSection )
+        m_pStartOfSection = pNd->m_pStartOfSection;
+        if( pNd->GetEndNode() )     // Skip EndNode ? Section!
         {
+            pNd = m_pStartOfSection;
             m_pStartOfSection = pNd->m_pStartOfSection;
-            if( pNd->GetEndNode() )     // Skip EndNode ? Section!
-            {
-                pNd = m_pStartOfSection;
-                m_pStartOfSection = pNd->m_pStartOfSection;
-            }
         }
     }
 }
@@ -1888,28 +1888,28 @@ bool SwContentNode::CanJoinPrev( SwNodeIndex* pIdx ) const
 
 void SwContentNode::SetCondFormatColl(SwFormatColl* pColl)
 {
-    if( (!pColl && m_pCondColl) || ( pColl && !m_pCondColl ) ||
-        ( pColl && pColl != m_pCondColl->GetRegisteredIn() ) )
-    {
-        SwFormatColl* pOldColl = GetCondFormatColl();
-        m_aCondCollListener.EndListeningAll();
-        if(pColl)
-            m_aCondCollListener.StartListening(pColl);
-        m_pCondColl = pColl;
-        if(GetpSwAttrSet())
-            AttrSetHandleHelper::SetParent(mpAttrSet, *this, &GetAnyFormatColl(), GetFormatColl());
+    if( !((!pColl && m_pCondColl) || ( pColl && !m_pCondColl ) ||
+        ( pColl && pColl != m_pCondColl->GetRegisteredIn() )) )
+        return;
 
-        if(!IsModifyLocked())
-        {
-            SwFormatChg aTmp1(pOldColl ? pOldColl : GetFormatColl());
-            SwFormatChg aTmp2(pColl ? pColl : GetFormatColl());
-            NotifyClients(&aTmp1, &aTmp2);
-        }
-        if(IsInCache())
-        {
-            SwFrame::GetCache().Delete(this);
-            SetInCache(false);
-        }
+    SwFormatColl* pOldColl = GetCondFormatColl();
+    m_aCondCollListener.EndListeningAll();
+    if(pColl)
+        m_aCondCollListener.StartListening(pColl);
+    m_pCondColl = pColl;
+    if(GetpSwAttrSet())
+        AttrSetHandleHelper::SetParent(mpAttrSet, *this, &GetAnyFormatColl(), GetFormatColl());
+
+    if(!IsModifyLocked())
+    {
+        SwFormatChg aTmp1(pOldColl ? pOldColl : GetFormatColl());
+        SwFormatChg aTmp2(pColl ? pColl : GetFormatColl());
+        NotifyClients(&aTmp1, &aTmp2);
+    }
+    if(IsInCache())
+    {
+        SwFrame::GetCache().Delete(this);
+        SetInCache(false);
     }
 }
 
@@ -2002,44 +2002,44 @@ bool SwContentNode::IsAnyCondition( SwCollCondition& rTmp ) const
 void SwContentNode::ChkCondColl()
 {
     // Check, just to be sure
-    if( RES_CONDTXTFMTCOLL == GetFormatColl()->Which() )
-    {
-        SwCollCondition aTmp( nullptr, Master_CollCondition::NONE, 0 );
-        const SwCollCondition* pCColl;
+    if( RES_CONDTXTFMTCOLL != GetFormatColl()->Which() )
+        return;
 
-        bool bDone = false;
+    SwCollCondition aTmp( nullptr, Master_CollCondition::NONE, 0 );
+    const SwCollCondition* pCColl;
 
-        if( IsAnyCondition( aTmp ))
-        {
-            pCColl = static_cast<SwConditionTextFormatColl*>(GetFormatColl())
-                ->HasCondition( aTmp );
+    bool bDone = false;
 
-            if (pCColl)
-            {
-                SetCondFormatColl( pCColl->GetTextFormatColl() );
-                bDone = true;
-            }
-        }
+    if( IsAnyCondition( aTmp ))
+    {
+        pCColl = static_cast<SwConditionTextFormatColl*>(GetFormatColl())
+            ->HasCondition( aTmp );
 
-        if (!bDone)
+        if (pCColl)
         {
-            if( IsTextNode() && static_cast<SwTextNode*>(this)->GetNumRule())
-            {
-                // Is at which Level in a list?
-                aTmp.SetCondition( Master_CollCondition::PARA_IN_LIST,
-                                static_cast<SwTextNode*>(this)->GetActualListLevel() );
-                pCColl = static_cast<SwConditionTextFormatColl*>(GetFormatColl())->
-                                HasCondition( aTmp );
-            }
-            else
-                pCColl = nullptr;
-
-            if( pCColl )
-                SetCondFormatColl( pCColl->GetTextFormatColl() );
-            else if( m_pCondColl )
-                SetCondFormatColl( nullptr );
+            SetCondFormatColl( pCColl->GetTextFormatColl() );
+            bDone = true;
         }
     }
+
+    if (bDone)
+        return;
+
+    if( IsTextNode() && static_cast<SwTextNode*>(this)->GetNumRule())
+    {
+        // Is at which Level in a list?
+        aTmp.SetCondition( Master_CollCondition::PARA_IN_LIST,
+                        static_cast<SwTextNode*>(this)->GetActualListLevel() );
+        pCColl = static_cast<SwConditionTextFormatColl*>(GetFormatColl())->
+                        HasCondition( aTmp );
+    }
+    else
+        pCColl = nullptr;
+
+    if( pCColl )
+        SetCondFormatColl( pCColl->GetTextFormatColl() );
+    else if( m_pCondColl )
+        SetCondFormatColl( nullptr );
 }
 
 // #i42921#
diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx
index 2486821850c1..ab69f31e1360 100644
--- a/sw/source/core/docnode/nodes.cxx
+++ b/sw/source/core/docnode/nodes.cxx
@@ -348,30 +348,32 @@ void SwNodes::ChgNode( SwNodeIndex const & rDelPos, sal_uLong nSz,
         bNewFrames = &GetDoc()->GetNodes() == &rNds &&
                     GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell();
 
-    if( bNewFrames )
+    if( !bNewFrames )
+        return;
+
+    // get the frames:
+    SwNodeIndex aIdx( *pPrevInsNd, 1 );
+    SwNodeIndex aFrameNdIdx( aIdx );
+    SwNode* pFrameNd = rNds.FindPrvNxtFrameNode( aFrameNdIdx,
+                                    rNds[ rInsPos.GetIndex() - 1 ] );
+
+    if( !pFrameNd )
+        return;
+
+    while( aIdx != rInsPos )
     {
-        // get the frames:
-        SwNodeIndex aIdx( *pPrevInsNd, 1 );
-        SwNodeIndex aFrameNdIdx( aIdx );
-        SwNode* pFrameNd = rNds.FindPrvNxtFrameNode( aFrameNdIdx,
-                                        rNds[ rInsPos.GetIndex() - 1 ] );
-
-        if( pFrameNd )
-            while( aIdx != rInsPos )
-            {
-                SwContentNode* pCNd = aIdx.GetNode().GetContentNode();
-                if( pCNd )
-                {
-                    if( pFrameNd->IsTableNode() )
-                        static_cast<SwTableNode*>(pFrameNd)->MakeFramesForAdjacentContentNode(aIdx);
-                    else if( pFrameNd->IsSectionNode() )
-                        static_cast<SwSectionNode*>(pFrameNd)->MakeFramesForAdjacentContentNode(aIdx);
-                    else
-                        static_cast<SwContentNode*>(pFrameNd)->MakeFramesForAdjacentContentNode(*pCNd);
-                    pFrameNd = pCNd;
-                }
-                ++aIdx;
-            }
+        SwContentNode* pCNd = aIdx.GetNode().GetContentNode();
+        if( pCNd )
+        {
+            if( pFrameNd->IsTableNode() )
+                static_cast<SwTableNode*>(pFrameNd)->MakeFramesForAdjacentContentNode(aIdx);
+            else if( pFrameNd->IsSectionNode() )
+                static_cast<SwSectionNode*>(pFrameNd)->MakeFramesForAdjacentContentNode(aIdx);
+            else
+                static_cast<SwContentNode*>(pFrameNd)->MakeFramesForAdjacentContentNode(*pCNd);
+            pFrameNd = pCNd;
+        }
+        ++aIdx;
     }
 }
 
@@ -2149,27 +2151,27 @@ void SwNodes::ForEach( sal_uLong nStart, sal_uLong nEnd,
     if( nEnd > m_nSize )
         nEnd = m_nSize;
 
-    if( nStart < nEnd )
+    if( nStart >= nEnd )
+        return;
+
+    sal_uInt16 cur = Index2Block( nStart );
+    BlockInfo** pp = m_ppInf.get() + cur;
+    BlockInfo* p = *pp;
+    sal_uInt16 nElem = sal_uInt16( nStart - p->nStart );
+    auto pElem = p->mvData.begin() + nElem;
+    nElem = p->nElem - nElem;
+    for(;;)
     {
-        sal_uInt16 cur = Index2Block( nStart );
-        BlockInfo** pp = m_ppInf.get() + cur;
-        BlockInfo* p = *pp;
-        sal_uInt16 nElem = sal_uInt16( nStart - p->nStart );
-        auto pElem = p->mvData.begin() + nElem;
-        nElem = p->nElem - nElem;
-        for(;;)
-        {
-            if( !(*fn)( static_cast<SwNode *>(*pElem++), pArgs ) || ++nStart >= nEnd )
-                break;
+        if( !(*fn)( static_cast<SwNode *>(*pElem++), pArgs ) || ++nStart >= nEnd )
+            break;
 
-            // next element
-            if( !--nElem )
-            {
-                // new block
-                p = *++pp;
-                pElem = p->mvData.begin();
-                nElem = p->nElem;
-            }
+        // next element
+        if( !--nElem )
+        {
+            // new block
+            p = *++pp;
+            pElem = p->mvData.begin();
+            nElem = p->nElem;
         }
     }
 }
diff --git a/sw/source/core/docnode/retrievedinputstreamdata.cxx b/sw/source/core/docnode/retrievedinputstreamdata.cxx
index b41125698981..4110b072d037 100644
--- a/sw/source/core/docnode/retrievedinputstreamdata.cxx
+++ b/sw/source/core/docnode/retrievedinputstreamdata.cxx
@@ -70,25 +70,25 @@ void SwRetrievedInputStreamDataManager::PushData(
 
     std::map< tDataKey, tData >::iterator aIter = maInputStreamData.find( nDataKey );
 
-    if ( aIter != maInputStreamData.end() )
-    {
-        // Fill data container.
-        (*aIter).second.mxInputStream = xInputStream;
-        (*aIter).second.mbIsStreamReadOnly = bIsStreamReadOnly;
+    if ( aIter == maInputStreamData.end() )
+        return;
 
-        // post user event to process the retrieved input stream data
-        if ( GetpApp() )
-        {
+    // Fill data container.
+    (*aIter).second.mxInputStream = xInputStream;
+    (*aIter).second.mbIsStreamReadOnly = bIsStreamReadOnly;
 
-            tDataKey* pDataKey = new tDataKey;
-            *pDataKey = nDataKey;
-            Application::PostUserEvent( LINK( this, SwRetrievedInputStreamDataManager, LinkedInputStreamReady ), pDataKey );
-        }
-        else
-        {
-            // no application available -> discard data
-            maInputStreamData.erase( aIter );
-        }
+    // post user event to process the retrieved input stream data
+    if ( GetpApp() )
+    {
+
+        tDataKey* pDataKey = new tDataKey;
+        *pDataKey = nDataKey;
+        Application::PostUserEvent( LINK( this, SwRetrievedInputStreamDataManager, LinkedInputStreamReady ), pDataKey );
+    }
+    else
+    {
+        // no application available -> discard data
+        maInputStreamData.erase( aIter );
     }
 }
 
diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx
index c1f078429fe6..51067dbd21d0 100644
--- a/sw/source/core/docnode/section.cxx
+++ b/sw/source/core/docnode/section.cxx
@@ -300,38 +300,38 @@ void SwSection::ImplSetHiddenFlag(bool const bTmpHidden, bool const bCondition)
 {
     SwSectionFormat* pFormat = GetFormat();
     OSL_ENSURE(pFormat, "ImplSetHiddenFlag: no format?");
-    if( pFormat )
-    {
-        const bool bHide = bTmpHidden && bCondition;
+    if( !pFormat )
+        return;
 
-        if (bHide) // should be hidden
+    const bool bHide = bTmpHidden && bCondition;
+
+    if (bHide) // should be hidden
+    {
+        if (!m_Data.IsHiddenFlag()) // is not hidden
         {
-            if (!m_Data.IsHiddenFlag()) // is not hidden
-            {
-                // Is the Parent hidden?
-                // This should be shown by the bHiddenFlag.
+            // Is the Parent hidden?
+            // This should be shown by the bHiddenFlag.
 
-                // Tell all Children that they are hidden
-                SwMsgPoolItem aMsgItem( RES_SECTION_HIDDEN );
-                pFormat->ModifyNotification( &aMsgItem, &aMsgItem );
+            // Tell all Children that they are hidden
+            SwMsgPoolItem aMsgItem( RES_SECTION_HIDDEN );
+            pFormat->ModifyNotification( &aMsgItem, &aMsgItem );
 
-                // Delete all Frames
-                pFormat->DelFrames();
-            }
+            // Delete all Frames
+            pFormat->DelFrames();
         }
-        else if (m_Data.IsHiddenFlag()) // show Nodes again
+    }
+    else if (m_Data.IsHiddenFlag()) // show Nodes again
+    {
+        // Show all Frames (Child Sections are accounted for by MakeFrames)
+        // Only if the Parent Section is not restricting us!
+        SwSection* pParentSect = pFormat->GetParentSection();
+        if( !pParentSect || !pParentSect->IsHiddenFlag() )
         {
-            // Show all Frames (Child Sections are accounted for by MakeFrames)
-            // Only if the Parent Section is not restricting us!
-            SwSection* pParentSect = pFormat->GetParentSection();
-            if( !pParentSect || !pParentSect->IsHiddenFlag() )
-            {
-                // Tell all Children that the Parent is not hidden anymore
-                SwMsgPoolItem aMsgItem( RES_SECTION_NOT_HIDDEN );
-                pFormat->ModifyNotification( &aMsgItem, &aMsgItem );
+            // Tell all Children that the Parent is not hidden anymore
+            SwMsgPoolItem aMsgItem( RES_SECTION_NOT_HIDDEN );
+            pFormat->ModifyNotification( &aMsgItem, &aMsgItem );
 
-                pFormat->MakeFrames();
-            }
+            pFormat->MakeFrames();
         }
     }
 }
@@ -631,41 +631,41 @@ SwSectionFormat::SwSectionFormat( SwFrameFormat* pDrvdFrame, SwDoc *pDoc )
 
 SwSectionFormat::~SwSectionFormat()
 {
-    if( !GetDoc()->IsInDtor() )
+    if( GetDoc()->IsInDtor() )
+        return;
+
+    SwSectionNode* pSectNd;
+    const SwNodeIndex* pIdx = GetContent( false ).GetContentIdx();
+    if( pIdx && &GetDoc()->GetNodes() == &pIdx->GetNodes() &&
+        nullptr != (pSectNd = pIdx->GetNode().GetSectionNode() ))
     {
-        SwSectionNode* pSectNd;
-        const SwNodeIndex* pIdx = GetContent( false ).GetContentIdx();
-        if( pIdx && &GetDoc()->GetNodes() == &pIdx->GetNodes() &&
-            nullptr != (pSectNd = pIdx->GetNode().GetSectionNode() ))
+        SwSection& rSect = pSectNd->GetSection();
+        // If it was a linked Section, we need to make all Child Links
+        // visible again
+        if( rSect.IsConnected() )
+            SwSection::MakeChildLinksVisible( *pSectNd );
+
+        // Check whether we need to be visible, before deleting the Nodes
+        if( rSect.IsHiddenFlag() )
         {
-            SwSection& rSect = pSectNd->GetSection();
-            // If it was a linked Section, we need to make all Child Links
-            // visible again
-            if( rSect.IsConnected() )
-                SwSection::MakeChildLinksVisible( *pSectNd );
-
-            // Check whether we need to be visible, before deleting the Nodes
-            if( rSect.IsHiddenFlag() )
+            SwSection* pParentSect = rSect.GetParent();
+            if( !pParentSect || !pParentSect->IsHiddenFlag() )
             {
-                SwSection* pParentSect = rSect.GetParent();
-                if( !pParentSect || !pParentSect->IsHiddenFlag() )
-                {
-                    // Make Nodes visible again
-                    rSect.SetHidden(false);
-                }
+                // Make Nodes visible again
+                rSect.SetHidden(false);
             }
-            // mba: test iteration; objects are removed while iterating
-            // use hint which allows to specify, if the content shall be saved or not
-            CallSwClientNotify( SwSectionFrameMoveAndDeleteHint( true ) );
-
-            // Raise the Section up
-            SwNodeRange aRg( *pSectNd, 0, *pSectNd->EndOfSectionNode() );
-            GetDoc()->GetNodes().SectionUp( &aRg );
         }
-        LockModify();
-        ResetFormatAttr( RES_CNTNT );
-        UnlockModify();
+        // mba: test iteration; objects are removed while iterating
+        // use hint which allows to specify, if the content shall be saved or not
+        CallSwClientNotify( SwSectionFrameMoveAndDeleteHint( true ) );
+
+        // Raise the Section up
+        SwNodeRange aRg( *pSectNd, 0, *pSectNd->EndOfSectionNode() );
+        GetDoc()->GetNodes().SectionUp( &aRg );
     }
+    LockModify();
+    ResetFormatAttr( RES_CNTNT );
+    UnlockModify();
 }
 
 SwSection * SwSectionFormat::GetSection() const
@@ -699,18 +699,18 @@ void SwSectionFormat::DelFrames()
         sal_uLong nStart = pSectNd->GetIndex()+1;
         sw_DeleteFootnote( pSectNd, nStart, nEnd );
     }
-    if( pIdx )
+    if( !pIdx )
+        return;
+
+    // Send Hint for PageDesc. Actually the Layout contained in the
+    // Paste of the Frame itself would need to do this. But that leads
+    // to subsequent errors, which we'd need to solve at run-time.
+    SwNodeIndex aNextNd( *pIdx );
+    SwContentNode* pCNd = GetDoc()->GetNodes().GoNextSection( &aNextNd, true, false );
+    if( pCNd )
     {
-        // Send Hint for PageDesc. Actually the Layout contained in the
-        // Paste of the Frame itself would need to do this. But that leads
-        // to subsequent errors, which we'd need to solve at run-time.
-        SwNodeIndex aNextNd( *pIdx );
-        SwContentNode* pCNd = GetDoc()->GetNodes().GoNextSection( &aNextNd, true, false );
-        if( pCNd )
-        {
-            const SfxPoolItem& rItem = pCNd->GetSwAttrSet().Get( RES_PAGEDESC );
-            pCNd->ModifyNotification( &rItem, &rItem );
-        }
+        const SfxPoolItem& rItem = pCNd->GetSwAttrSet().Get( RES_PAGEDESC );
+        pCNd->ModifyNotification( &rItem, &rItem );
     }
 }
 
@@ -886,29 +886,29 @@ void SwSectionFormat::GetChildSections( SwSections& rArr,
 {
     rArr.clear();
 
-    if( HasWriterListeners() )
-    {
-        SwIterator<SwSectionFormat,SwSectionFormat> aIter(*this);
-        const SwNodeIndex* pIdx;
-        for( SwSectionFormat* pLast = aIter.First(); pLast; pLast = aIter.Next() )
-            if( bAllSections ||
-                ( nullptr != ( pIdx = pLast->GetContent(false).
-                GetContentIdx()) && &pIdx->GetNodes() == &GetDoc()->GetNodes() ))
-            {
-                SwSection* pDummy = pLast->GetSection();
-                rArr.push_back( pDummy );
-            }
+    if( !HasWriterListeners() )
+        return;
 
-        // Do we need any sorting?
-        if( 1 < rArr.size() )
-            switch( eSort )
-            {
-            case SectionSort::Pos:
-                std::sort( rArr.begin(), rArr.end(), lcl_SectionCmpPos );
-                break;
-            case SectionSort::Not: break;
-            }
-    }
+    SwIterator<SwSectionFormat,SwSectionFormat> aIter(*this);
+    const SwNodeIndex* pIdx;
+    for( SwSectionFormat* pLast = aIter.First(); pLast; pLast = aIter.Next() )
+        if( bAllSections ||
+            ( nullptr != ( pIdx = pLast->GetContent(false).
+            GetContentIdx()) && &pIdx->GetNodes() == &GetDoc()->GetNodes() ))
+        {
+            SwSection* pDummy = pLast->GetSection();
+            rArr.push_back( pDummy );
+        }
+
+    // Do we need any sorting?
+    if( 1 < rArr.size() )
+        switch( eSort )
+        {
+        case SectionSort::Pos:
+            std::sort( rArr.begin(), rArr.end(), lcl_SectionCmpPos );
+            break;
+        case SectionSort::Not: break;
+        }
 }
 
 // See whether the Section is within the Nodes or the UndoNodes array
diff --git a/sw/source/core/docnode/threadmanager.cxx b/sw/source/core/docnode/threadmanager.cxx
index c2e7c46ed4a2..4834b25bfa17 100644
--- a/sw/source/core/docnode/threadmanager.cxx
+++ b/sw/source/core/docnode/threadmanager.cxx
@@ -211,18 +211,18 @@ IMPL_LINK_NOARG(ThreadManager, TryToStartNewThread, Timer *, void)
 {
     osl::MutexGuard aGuard(maMutex);
 
-    if ( !StartingOfThreadsSuspended() )
+    if ( StartingOfThreadsSuspended() )
+        return;
+
+    // Try to start thread from waiting ones
+    if ( !StartWaitingThread() )
     {
-        // Try to start thread from waiting ones
-        if ( !StartWaitingThread() )
+        // No success on starting thread
+        // If no more started threads exist, but still threads are waiting,
+        // setup Timer to start thread from waiting ones
+        if ( maStartedThreads.empty() && !maWaitingForStartThreads.empty() )
         {
-            // No success on starting thread
-            // If no more started threads exist, but still threads are waiting,
-            // setup Timer to start thread from waiting ones
-            if ( maStartedThreads.empty() && !maWaitingForStartThreads.empty() )
-            {
-                maStartNewThreadIdle.Start();
-            }
+            maStartNewThreadIdle.Start();
         }
     }
 }


More information about the Libreoffice-commits mailing list