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

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Thu Jul 30 08:00:29 UTC 2020


 sc/source/core/data/attarray.cxx         |  524 ++++++++++-----------
 sc/source/core/data/bcaslot.cxx          |   22 
 sc/source/core/data/column.cxx           |  202 ++++----
 sc/source/core/data/column3.cxx          |  112 ++--
 sc/source/core/data/column4.cxx          |  122 ++---
 sc/source/core/data/compressedarray.cxx  |  200 ++++----
 sc/source/core/data/conditio.cxx         |  152 +++---
 sc/source/core/data/dociter.cxx          |   48 -
 sc/source/core/data/documen2.cxx         |  134 ++---
 sc/source/core/data/documen3.cxx         |  180 +++----
 sc/source/core/data/documen5.cxx         |  124 ++---
 sc/source/core/data/documen7.cxx         |   48 -
 sc/source/core/data/documen8.cxx         |   96 +--
 sc/source/core/data/documen9.cxx         |  138 ++---
 sc/source/core/data/document.cxx         |  754 +++++++++++++++----------------
 sc/source/core/data/documentimport.cxx   |   28 -
 sc/source/core/data/dpdimsave.cxx        |   30 -
 sc/source/core/data/dpobject.cxx         |  186 +++----
 sc/source/core/data/dpoutput.cxx         |  262 +++++-----
 sc/source/core/data/dpoutputgeometry.cxx |   30 -
 sc/source/core/data/dpsave.cxx           |   28 -
 sc/source/core/data/dptabres.cxx         |  514 ++++++++++-----------
 sc/source/core/data/dptabsrc.cxx         |   92 +--
 sc/source/core/data/drwlayer.cxx         |  180 +++----
 sc/source/core/data/formulacell.cxx      |  212 ++++----
 sc/source/core/data/funcdesc.cxx         |   86 +--
 sc/source/core/data/global.cxx           |   30 -
 sc/source/core/data/markarr.cxx          |  168 +++---
 sc/source/core/data/markdata.cxx         |   64 +-
 sc/source/core/data/markmulti.cxx        |   28 -
 sc/source/core/data/patattr.cxx          |   58 +-
 sc/source/core/data/postit.cxx           |  176 +++----
 sc/source/core/data/stlpool.cxx          |   74 +--
 sc/source/core/data/subtotalparam.cxx    |   30 -
 sc/source/core/data/table1.cxx           |   28 -
 sc/source/core/data/table2.cxx           |  296 ++++++------
 sc/source/core/data/table4.cxx           |  348 +++++++-------
 sc/source/core/data/table5.cxx           |   64 +-
 sc/source/core/data/table7.cxx           |   30 -
 39 files changed, 2949 insertions(+), 2949 deletions(-)

New commits:
commit 75f398b22ae14dcf442abf6b1c92a50509565ae5
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Jul 29 16:12:20 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Jul 30 09:59:39 2020 +0200

    loplugin:flatten in sc/core/data
    
    Change-Id: I9ffe58d68172c6fe9c76000c01c0c67a03967146
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99699
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx
index a4c57ca4f0b0..8174eeb84bbb 100644
--- a/sc/source/core/data/attarray.cxx
+++ b/sc/source/core/data/attarray.cxx
@@ -52,24 +52,24 @@ ScAttrArray::ScAttrArray( SCCOL nNewCol, SCTAB nNewTab, ScDocument* pDoc, ScAttr
     nTab( nNewTab ),
     pDocument( pDoc )
 {
-    if ( nCol != -1 && pDefaultColAttrArray && !pDefaultColAttrArray->mvData.empty())
+    if ( !(nCol != -1 && pDefaultColAttrArray && !pDefaultColAttrArray->mvData.empty()))
+        return;
+
+    ScAddress aAdrStart( nCol, 0, nTab );
+    ScAddress aAdrEnd( nCol, 0, nTab );
+    mvData.resize( pDefaultColAttrArray->mvData.size() );
+    for ( size_t nIdx = 0; nIdx < pDefaultColAttrArray->mvData.size(); ++nIdx )
     {
-        ScAddress aAdrStart( nCol, 0, nTab );
-        ScAddress aAdrEnd( nCol, 0, nTab );
-        mvData.resize( pDefaultColAttrArray->mvData.size() );
-        for ( size_t nIdx = 0; nIdx < pDefaultColAttrArray->mvData.size(); ++nIdx )
+        mvData[nIdx].nEndRow = pDefaultColAttrArray->mvData[nIdx].nEndRow;
+        ScPatternAttr aNewPattern( *(pDefaultColAttrArray->mvData[nIdx].pPattern) );
+        mvData[nIdx].pPattern = &pDocument->GetPool()->Put( aNewPattern );
+        bool bNumFormatChanged = false;
+        if ( ScGlobal::CheckWidthInvalidate( bNumFormatChanged,
+             mvData[nIdx].pPattern->GetItemSet(), pDocument->GetDefPattern()->GetItemSet() ) )
         {
-            mvData[nIdx].nEndRow = pDefaultColAttrArray->mvData[nIdx].nEndRow;
-            ScPatternAttr aNewPattern( *(pDefaultColAttrArray->mvData[nIdx].pPattern) );
-            mvData[nIdx].pPattern = &pDocument->GetPool()->Put( aNewPattern );
-            bool bNumFormatChanged = false;
-            if ( ScGlobal::CheckWidthInvalidate( bNumFormatChanged,
-                 mvData[nIdx].pPattern->GetItemSet(), pDocument->GetDefPattern()->GetItemSet() ) )
-            {
-                aAdrStart.SetRow( nIdx ? mvData[nIdx-1].nEndRow+1 : 0 );
-                aAdrEnd.SetRow( mvData[nIdx].nEndRow );
-                pDocument->InvalidateTextWidth( &aAdrStart, &aAdrEnd, bNumFormatChanged );
-            }
+            aAdrStart.SetRow( nIdx ? mvData[nIdx-1].nEndRow+1 : 0 );
+            aAdrEnd.SetRow( mvData[nIdx].nEndRow );
+            pDocument->InvalidateTextWidth( &aAdrStart, &aAdrEnd, bNumFormatChanged );
         }
     }
 }
@@ -625,73 +625,73 @@ const ScPatternAttr* ScAttrArray::SetPatternAreaImpl(SCROW nStartRow, SCROW nEnd
 
 void ScAttrArray::ApplyStyleArea( SCROW nStartRow, SCROW nEndRow, const ScStyleSheet& rStyle )
 {
-    if (pDocument->ValidRow(nStartRow) && pDocument->ValidRow(nEndRow))
+    if (!(pDocument->ValidRow(nStartRow) && pDocument->ValidRow(nEndRow)))
+        return;
+
+    SetDefaultIfNotInit();
+    SCSIZE nPos;
+    SCROW nStart=0;
+    if (!Search( nStartRow, nPos ))
     {
-        SetDefaultIfNotInit();
-        SCSIZE nPos;
-        SCROW nStart=0;
-        if (!Search( nStartRow, nPos ))
-        {
-            OSL_FAIL("Search Failure");
-            return;
-        }
+        OSL_FAIL("Search Failure");
+        return;
+    }
 
-        ScAddress aAdrStart( nCol, 0, nTab );
-        ScAddress aAdrEnd  ( nCol, 0, nTab );
+    ScAddress aAdrStart( nCol, 0, nTab );
+    ScAddress aAdrEnd  ( nCol, 0, nTab );
 
-        do
-        {
-            const ScPatternAttr* pOldPattern = mvData[nPos].pPattern;
-            std::unique_ptr<ScPatternAttr> pNewPattern(new ScPatternAttr(*pOldPattern));
-            pNewPattern->SetStyleSheet(const_cast<ScStyleSheet*>(&rStyle));
-            SCROW nY1 = nStart;
-            SCROW nY2 = mvData[nPos].nEndRow;
-            nStart = mvData[nPos].nEndRow + 1;
+    do
+    {
+        const ScPatternAttr* pOldPattern = mvData[nPos].pPattern;
+        std::unique_ptr<ScPatternAttr> pNewPattern(new ScPatternAttr(*pOldPattern));
+        pNewPattern->SetStyleSheet(const_cast<ScStyleSheet*>(&rStyle));
+        SCROW nY1 = nStart;
+        SCROW nY2 = mvData[nPos].nEndRow;
+        nStart = mvData[nPos].nEndRow + 1;
 
-            if ( *pNewPattern == *pOldPattern )
-            {
-                // keep the original pattern (might be default)
-                // pNewPattern is deleted below
-                nPos++;
-            }
-            else if ( nY1 < nStartRow || nY2 > nEndRow )
-            {
-                if (nY1 < nStartRow) nY1=nStartRow;
-                if (nY2 > nEndRow) nY2=nEndRow;
-                SetPatternArea( nY1, nY2, std::move(pNewPattern), true );
-                Search( nStart, nPos );
-            }
-            else
+        if ( *pNewPattern == *pOldPattern )
+        {
+            // keep the original pattern (might be default)
+            // pNewPattern is deleted below
+            nPos++;
+        }
+        else if ( nY1 < nStartRow || nY2 > nEndRow )
+        {
+            if (nY1 < nStartRow) nY1=nStartRow;
+            if (nY2 > nEndRow) nY2=nEndRow;
+            SetPatternArea( nY1, nY2, std::move(pNewPattern), true );
+            Search( nStart, nPos );
+        }
+        else
+        {
+            if ( nCol != -1 )
             {
-                if ( nCol != -1 )
+                // ensure attributing changes text width of cell; otherwise
+                // there aren't (yet) template format changes
+                const SfxItemSet& rNewSet = pNewPattern->GetItemSet();
+                const SfxItemSet& rOldSet = pOldPattern->GetItemSet();
+
+                bool bNumFormatChanged;
+                if ( ScGlobal::CheckWidthInvalidate( bNumFormatChanged,
+                        rNewSet, rOldSet ) )
                 {
-                    // ensure attributing changes text width of cell; otherwise
-                    // there aren't (yet) template format changes
-                    const SfxItemSet& rNewSet = pNewPattern->GetItemSet();
-                    const SfxItemSet& rOldSet = pOldPattern->GetItemSet();
-
-                    bool bNumFormatChanged;
-                    if ( ScGlobal::CheckWidthInvalidate( bNumFormatChanged,
-                            rNewSet, rOldSet ) )
-                    {
-                        aAdrStart.SetRow( nPos ? mvData[nPos-1].nEndRow+1 : 0 );
-                        aAdrEnd  .SetRow( mvData[nPos].nEndRow );
-                        pDocument->InvalidateTextWidth( &aAdrStart, &aAdrEnd, bNumFormatChanged );
-                    }
+                    aAdrStart.SetRow( nPos ? mvData[nPos-1].nEndRow+1 : 0 );
+                    aAdrEnd  .SetRow( mvData[nPos].nEndRow );
+                    pDocument->InvalidateTextWidth( &aAdrStart, &aAdrEnd, bNumFormatChanged );
                 }
-
-                pDocument->GetPool()->Remove(*mvData[nPos].pPattern);
-                mvData[nPos].pPattern = &pDocument->GetPool()->Put(*pNewPattern);
-                if (Concat(nPos))
-                    Search(nStart, nPos);
-                else
-                    nPos++;
             }
-        }
-        while ((nStart <= nEndRow) && (nPos < mvData.size()));
 
-        pDocument->SetStreamValid(nTab, false);
+            pDocument->GetPool()->Remove(*mvData[nPos].pPattern);
+            mvData[nPos].pPattern = &pDocument->GetPool()->Put(*pNewPattern);
+            if (Concat(nPos))
+                Search(nStart, nPos);
+            else
+                nPos++;
+        }
     }
+    while ((nStart <= nEndRow) && (nPos < mvData.size()));
+
+    pDocument->SetStreamValid(nTab, false);
 
 #if DEBUG_SC_TESTATTRARRAY
     TestData();
@@ -723,121 +723,121 @@ void ScAttrArray::ApplyLineStyleArea( SCROW nStartRow, SCROW nEndRow,
     if ( bColorOnly && !pLine )
         return;
 
-    if (pDocument->ValidRow(nStartRow) && pDocument->ValidRow(nEndRow))
+    if (!(pDocument->ValidRow(nStartRow) && pDocument->ValidRow(nEndRow)))
+        return;
+
+    SCSIZE nPos;
+    SCROW nStart=0;
+    SetDefaultIfNotInit();
+    if (!Search( nStartRow, nPos ))
     {
-        SCSIZE nPos;
-        SCROW nStart=0;
-        SetDefaultIfNotInit();
-        if (!Search( nStartRow, nPos ))
-        {
-            OSL_FAIL("Search failure");
-            return;
-        }
+        OSL_FAIL("Search failure");
+        return;
+    }
 
-        do
-        {
-            const ScPatternAttr*    pOldPattern = mvData[nPos].pPattern;
-            const SfxItemSet&       rOldSet = pOldPattern->GetItemSet();
-            const SfxPoolItem*      pBoxItem = nullptr;
-            SfxItemState            eState = rOldSet.GetItemState( ATTR_BORDER, true, &pBoxItem );
-            const SfxPoolItem*      pTLBRItem = nullptr;
-            SfxItemState            eTLBRState = rOldSet.GetItemState( ATTR_BORDER_TLBR, true, &pTLBRItem );
-            const SfxPoolItem*      pBLTRItem = nullptr;
-            SfxItemState            eBLTRState = rOldSet.GetItemState( ATTR_BORDER_BLTR, true, &pBLTRItem );
+    do
+    {
+        const ScPatternAttr*    pOldPattern = mvData[nPos].pPattern;
+        const SfxItemSet&       rOldSet = pOldPattern->GetItemSet();
+        const SfxPoolItem*      pBoxItem = nullptr;
+        SfxItemState            eState = rOldSet.GetItemState( ATTR_BORDER, true, &pBoxItem );
+        const SfxPoolItem*      pTLBRItem = nullptr;
+        SfxItemState            eTLBRState = rOldSet.GetItemState( ATTR_BORDER_TLBR, true, &pTLBRItem );
+        const SfxPoolItem*      pBLTRItem = nullptr;
+        SfxItemState            eBLTRState = rOldSet.GetItemState( ATTR_BORDER_BLTR, true, &pBLTRItem );
 
-            if ( (SfxItemState::SET == eState) || (SfxItemState::SET == eTLBRState) || (SfxItemState::SET == eBLTRState) )
-            {
-                std::unique_ptr<ScPatternAttr> pNewPattern(new ScPatternAttr(*pOldPattern));
-                SfxItemSet&     rNewSet = pNewPattern->GetItemSet();
-                SCROW           nY1 = nStart;
-                SCROW           nY2 = mvData[nPos].nEndRow;
+        if ( (SfxItemState::SET == eState) || (SfxItemState::SET == eTLBRState) || (SfxItemState::SET == eBLTRState) )
+        {
+            std::unique_ptr<ScPatternAttr> pNewPattern(new ScPatternAttr(*pOldPattern));
+            SfxItemSet&     rNewSet = pNewPattern->GetItemSet();
+            SCROW           nY1 = nStart;
+            SCROW           nY2 = mvData[nPos].nEndRow;
 
-                std::unique_ptr<SvxBoxItem>  pNewBoxItem( pBoxItem ? static_cast<SvxBoxItem*>(pBoxItem->Clone()) : nullptr);
-                std::unique_ptr<SvxLineItem> pNewTLBRItem( pTLBRItem ? static_cast<SvxLineItem*>(pTLBRItem->Clone()) : nullptr);
-                std::unique_ptr<SvxLineItem> pNewBLTRItem(pBLTRItem ? static_cast<SvxLineItem*>(pBLTRItem->Clone()) : nullptr);
+            std::unique_ptr<SvxBoxItem>  pNewBoxItem( pBoxItem ? static_cast<SvxBoxItem*>(pBoxItem->Clone()) : nullptr);
+            std::unique_ptr<SvxLineItem> pNewTLBRItem( pTLBRItem ? static_cast<SvxLineItem*>(pTLBRItem->Clone()) : nullptr);
+            std::unique_ptr<SvxLineItem> pNewBLTRItem(pBLTRItem ? static_cast<SvxLineItem*>(pBLTRItem->Clone()) : nullptr);
 
-                // fetch line and update attributes with parameters
+            // fetch line and update attributes with parameters
 
-                if ( !pLine )
+            if ( !pLine )
+            {
+                if( pNewBoxItem )
                 {
+                    if ( pNewBoxItem->GetTop() )    pNewBoxItem->SetLine( nullptr, SvxBoxItemLine::TOP );
+                    if ( pNewBoxItem->GetBottom() ) pNewBoxItem->SetLine( nullptr, SvxBoxItemLine::BOTTOM );
+                    if ( pNewBoxItem->GetLeft() )   pNewBoxItem->SetLine( nullptr, SvxBoxItemLine::LEFT );
+                    if ( pNewBoxItem->GetRight() )  pNewBoxItem->SetLine( nullptr, SvxBoxItemLine::RIGHT );
+                }
+                if( pNewTLBRItem && pNewTLBRItem->GetLine() )
+                    pNewTLBRItem->SetLine( nullptr );
+                if( pNewBLTRItem && pNewBLTRItem->GetLine() )
+                    pNewBLTRItem->SetLine( nullptr );
+            }
+            else
+            {
+                if ( bColorOnly )
+                {
+                    Color aColor( pLine->GetColor() );
                     if( pNewBoxItem )
                     {
-                        if ( pNewBoxItem->GetTop() )    pNewBoxItem->SetLine( nullptr, SvxBoxItemLine::TOP );
-                        if ( pNewBoxItem->GetBottom() ) pNewBoxItem->SetLine( nullptr, SvxBoxItemLine::BOTTOM );
-                        if ( pNewBoxItem->GetLeft() )   pNewBoxItem->SetLine( nullptr, SvxBoxItemLine::LEFT );
-                        if ( pNewBoxItem->GetRight() )  pNewBoxItem->SetLine( nullptr, SvxBoxItemLine::RIGHT );
+                        SetLineColor( pNewBoxItem->GetTop(),    aColor );
+                        SetLineColor( pNewBoxItem->GetBottom(), aColor );
+                        SetLineColor( pNewBoxItem->GetLeft(),   aColor );
+                        SetLineColor( pNewBoxItem->GetRight(),   aColor );
                     }
-                    if( pNewTLBRItem && pNewTLBRItem->GetLine() )
-                        pNewTLBRItem->SetLine( nullptr );
-                    if( pNewBLTRItem && pNewBLTRItem->GetLine() )
-                        pNewBLTRItem->SetLine( nullptr );
+                    if( pNewTLBRItem )
+                        SetLineColor( pNewTLBRItem->GetLine(), aColor );
+                    if( pNewBLTRItem )
+                        SetLineColor( pNewBLTRItem->GetLine(), aColor );
                 }
                 else
                 {
-                    if ( bColorOnly )
-                    {
-                        Color aColor( pLine->GetColor() );
-                        if( pNewBoxItem )
-                        {
-                            SetLineColor( pNewBoxItem->GetTop(),    aColor );
-                            SetLineColor( pNewBoxItem->GetBottom(), aColor );
-                            SetLineColor( pNewBoxItem->GetLeft(),   aColor );
-                            SetLineColor( pNewBoxItem->GetRight(),   aColor );
-                        }
-                        if( pNewTLBRItem )
-                            SetLineColor( pNewTLBRItem->GetLine(), aColor );
-                        if( pNewBLTRItem )
-                            SetLineColor( pNewBLTRItem->GetLine(), aColor );
-                    }
-                    else
+                    if( pNewBoxItem )
                     {
-                        if( pNewBoxItem )
-                        {
-                            SetLine( pNewBoxItem->GetTop(),    pLine );
-                            SetLine( pNewBoxItem->GetBottom(), pLine );
-                            SetLine( pNewBoxItem->GetLeft(),   pLine );
-                            SetLine( pNewBoxItem->GetRight(),   pLine );
-                        }
-                        if( pNewTLBRItem )
-                            SetLine( pNewTLBRItem->GetLine(), pLine );
-                        if( pNewBLTRItem )
-                            SetLine( pNewBLTRItem->GetLine(), pLine );
+                        SetLine( pNewBoxItem->GetTop(),    pLine );
+                        SetLine( pNewBoxItem->GetBottom(), pLine );
+                        SetLine( pNewBoxItem->GetLeft(),   pLine );
+                        SetLine( pNewBoxItem->GetRight(),   pLine );
                     }
+                    if( pNewTLBRItem )
+                        SetLine( pNewTLBRItem->GetLine(), pLine );
+                    if( pNewBLTRItem )
+                        SetLine( pNewBLTRItem->GetLine(), pLine );
                 }
-                if( pNewBoxItem )   rNewSet.Put( *pNewBoxItem );
-                if( pNewTLBRItem )  rNewSet.Put( *pNewTLBRItem );
-                if( pNewBLTRItem )  rNewSet.Put( *pNewBLTRItem );
-
-                nStart = mvData[nPos].nEndRow + 1;
+            }
+            if( pNewBoxItem )   rNewSet.Put( *pNewBoxItem );
+            if( pNewTLBRItem )  rNewSet.Put( *pNewTLBRItem );
+            if( pNewBLTRItem )  rNewSet.Put( *pNewBLTRItem );
 
-                if ( nY1 < nStartRow || nY2 > nEndRow )
-                {
-                    if (nY1 < nStartRow) nY1=nStartRow;
-                    if (nY2 > nEndRow) nY2=nEndRow;
-                    SetPatternArea( nY1, nY2, std::move(pNewPattern), true );
-                    Search( nStart, nPos );
-                }
-                else
-                {
-                    // remove from pool ?
-                    pDocument->GetPool()->Remove(*mvData[nPos].pPattern);
-                    mvData[nPos].pPattern =
-                                &pDocument->GetPool()->Put(std::move(pNewPattern));
+            nStart = mvData[nPos].nEndRow + 1;
 
-                    if (Concat(nPos))
-                        Search(nStart, nPos);
-                    else
-                        nPos++;
-                }
+            if ( nY1 < nStartRow || nY2 > nEndRow )
+            {
+                if (nY1 < nStartRow) nY1=nStartRow;
+                if (nY2 > nEndRow) nY2=nEndRow;
+                SetPatternArea( nY1, nY2, std::move(pNewPattern), true );
+                Search( nStart, nPos );
             }
             else
             {
-                nStart = mvData[nPos].nEndRow + 1;
-                nPos++;
+                // remove from pool ?
+                pDocument->GetPool()->Remove(*mvData[nPos].pPattern);
+                mvData[nPos].pPattern =
+                            &pDocument->GetPool()->Put(std::move(pNewPattern));
+
+                if (Concat(nPos))
+                    Search(nStart, nPos);
+                else
+                    nPos++;
             }
         }
-        while ((nStart <= nEndRow) && (nPos < mvData.size()));
+        else
+        {
+            nStart = mvData[nPos].nEndRow + 1;
+            nPos++;
+        }
     }
+    while ((nStart <= nEndRow) && (nPos < mvData.size()));
 }
 
 void ScAttrArray::ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCache* pCache, ScEditDataArray* pDataArray, bool* const pIsChanged )
@@ -846,77 +846,77 @@ void ScAttrArray::ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCac
     TestData();
 #endif
 
-    if (pDocument->ValidRow(nStartRow) && pDocument->ValidRow(nEndRow))
+    if (!(pDocument->ValidRow(nStartRow) && pDocument->ValidRow(nEndRow)))
+        return;
+
+    SCSIZE nPos;
+    SCROW nStart=0;
+    SetDefaultIfNotInit();
+    if (!Search( nStartRow, nPos ))
     {
-        SCSIZE nPos;
-        SCROW nStart=0;
-        SetDefaultIfNotInit();
-        if (!Search( nStartRow, nPos ))
-        {
-            OSL_FAIL("Search Failure");
-            return;
-        }
+        OSL_FAIL("Search Failure");
+        return;
+    }
 
-        ScAddress aAdrStart( nCol, 0, nTab );
-        ScAddress aAdrEnd  ( nCol, 0, nTab );
+    ScAddress aAdrStart( nCol, 0, nTab );
+    ScAddress aAdrEnd  ( nCol, 0, nTab );
 
-        do
+    do
+    {
+        const ScPatternAttr* pOldPattern = mvData[nPos].pPattern;
+        const ScPatternAttr* pNewPattern = static_cast<const ScPatternAttr*>( &pCache->ApplyTo( *pOldPattern ) );
+        if (pNewPattern != pOldPattern)
         {
-            const ScPatternAttr* pOldPattern = mvData[nPos].pPattern;
-            const ScPatternAttr* pNewPattern = static_cast<const ScPatternAttr*>( &pCache->ApplyTo( *pOldPattern ) );
-            if (pNewPattern != pOldPattern)
-            {
-                SCROW nY1 = nStart;
-                SCROW nY2 = mvData[nPos].nEndRow;
-                nStart = mvData[nPos].nEndRow + 1;
+            SCROW nY1 = nStart;
+            SCROW nY2 = mvData[nPos].nEndRow;
+            nStart = mvData[nPos].nEndRow + 1;
 
-                if(pIsChanged)
-                    *pIsChanged = true;
+            if(pIsChanged)
+                *pIsChanged = true;
 
-                if ( nY1 < nStartRow || nY2 > nEndRow )
-                {
-                    if (nY1 < nStartRow) nY1=nStartRow;
-                    if (nY2 > nEndRow) nY2=nEndRow;
-                    SetPatternArea( nY1, nY2, pNewPattern, false, pDataArray );
-                    Search( nStart, nPos );
-                }
-                else
+            if ( nY1 < nStartRow || nY2 > nEndRow )
+            {
+                if (nY1 < nStartRow) nY1=nStartRow;
+                if (nY2 > nEndRow) nY2=nEndRow;
+                SetPatternArea( nY1, nY2, pNewPattern, false, pDataArray );
+                Search( nStart, nPos );
+            }
+            else
+            {
+                if ( nCol != -1 )
                 {
-                    if ( nCol != -1 )
+                    // ensure attributing changes text-width of cell
+
+                    const SfxItemSet& rNewSet = pNewPattern->GetItemSet();
+                    const SfxItemSet& rOldSet = pOldPattern->GetItemSet();
+
+                    bool bNumFormatChanged;
+                    if ( ScGlobal::CheckWidthInvalidate( bNumFormatChanged,
+                            rNewSet, rOldSet ) )
                     {
-                        // ensure attributing changes text-width of cell
-
-                        const SfxItemSet& rNewSet = pNewPattern->GetItemSet();
-                        const SfxItemSet& rOldSet = pOldPattern->GetItemSet();
-
-                        bool bNumFormatChanged;
-                        if ( ScGlobal::CheckWidthInvalidate( bNumFormatChanged,
-                                rNewSet, rOldSet ) )
-                        {
-                            aAdrStart.SetRow( nPos ? mvData[nPos-1].nEndRow+1 : 0 );
-                            aAdrEnd  .SetRow( mvData[nPos].nEndRow );
-                            pDocument->InvalidateTextWidth( &aAdrStart, &aAdrEnd, bNumFormatChanged );
-                        }
+                        aAdrStart.SetRow( nPos ? mvData[nPos-1].nEndRow+1 : 0 );
+                        aAdrEnd  .SetRow( mvData[nPos].nEndRow );
+                        pDocument->InvalidateTextWidth( &aAdrStart, &aAdrEnd, bNumFormatChanged );
                     }
-
-                    pDocument->GetPool()->Remove(*mvData[nPos].pPattern);
-                    mvData[nPos].pPattern = pNewPattern;
-                    if (Concat(nPos))
-                        Search(nStart, nPos);
-                    else
-                        ++nPos;
                 }
-            }
-            else
-            {
-                nStart = mvData[nPos].nEndRow + 1;
-                ++nPos;
+
+                pDocument->GetPool()->Remove(*mvData[nPos].pPattern);
+                mvData[nPos].pPattern = pNewPattern;
+                if (Concat(nPos))
+                    Search(nStart, nPos);
+                else
+                    ++nPos;
             }
         }
-        while (nStart <= nEndRow);
-
-        pDocument->SetStreamValid(nTab, false);
+        else
+        {
+            nStart = mvData[nPos].nEndRow + 1;
+            ++nPos;
+        }
     }
+    while (nStart <= nEndRow);
+
+    pDocument->SetStreamValid(nTab, false);
 
 #if DEBUG_SC_TESTATTRARRAY
     TestData();
@@ -971,55 +971,55 @@ static void lcl_MergeDeep( SfxItemSet& rMergeSet, const SfxItemSet& rSource )
 void ScAttrArray::MergePatternArea( SCROW nStartRow, SCROW nEndRow,
                                     ScMergePatternState& rState, bool bDeep ) const
 {
-    if (pDocument->ValidRow(nStartRow) && pDocument->ValidRow(nEndRow))
+    if (!(pDocument->ValidRow(nStartRow) && pDocument->ValidRow(nEndRow)))
+        return;
+
+    SCSIZE nPos = 0;
+    SCROW nStart=0;
+    if ( !mvData.empty() && !Search( nStartRow, nPos ) )
     {
-        SCSIZE nPos = 0;
-        SCROW nStart=0;
-        if ( !mvData.empty() && !Search( nStartRow, nPos ) )
-        {
-            OSL_FAIL("Search failure");
-            return;
-        }
+        OSL_FAIL("Search failure");
+        return;
+    }
 
-        do
+    do
+    {
+        // similar patterns must not be repeated
+        const ScPatternAttr* pPattern = nullptr;
+        if ( !mvData.empty() )
+            pPattern = mvData[nPos].pPattern;
+        else
+            pPattern = pDocument->GetDefPattern();
+        if ( pPattern != rState.pOld1 && pPattern != rState.pOld2 )
         {
-            // similar patterns must not be repeated
-            const ScPatternAttr* pPattern = nullptr;
-            if ( !mvData.empty() )
-                pPattern = mvData[nPos].pPattern;
-            else
-                pPattern = pDocument->GetDefPattern();
-            if ( pPattern != rState.pOld1 && pPattern != rState.pOld2 )
+            const SfxItemSet& rThisSet = pPattern->GetItemSet();
+            if (rState.pItemSet)
             {
-                const SfxItemSet& rThisSet = pPattern->GetItemSet();
-                if (rState.pItemSet)
-                {
-                    rState.mbValidPatternId = false;
-                    if (bDeep)
-                        lcl_MergeDeep( *rState.pItemSet, rThisSet );
-                    else
-                        rState.pItemSet->MergeValues( rThisSet );
-                }
+                rState.mbValidPatternId = false;
+                if (bDeep)
+                    lcl_MergeDeep( *rState.pItemSet, rThisSet );
                 else
-                {
-                    // first pattern - copied from parent
-                    rState.pItemSet = std::make_unique<SfxItemSet>( *rThisSet.GetPool(), rThisSet.GetRanges() );
-                    rState.pItemSet->Set( rThisSet, bDeep );
-                    rState.mnPatternId = pPattern->GetKey();
-                }
-
-                rState.pOld2 = rState.pOld1;
-                rState.pOld1 = pPattern;
+                    rState.pItemSet->MergeValues( rThisSet );
             }
-
-            if ( !mvData.empty() )
-                nStart = mvData[nPos].nEndRow + 1;
             else
-                nStart = pDocument->MaxRow() + 1;
-            ++nPos;
+            {
+                // first pattern - copied from parent
+                rState.pItemSet = std::make_unique<SfxItemSet>( *rThisSet.GetPool(), rThisSet.GetRanges() );
+                rState.pItemSet->Set( rThisSet, bDeep );
+                rState.mnPatternId = pPattern->GetKey();
+            }
+
+            rState.pOld2 = rState.pOld1;
+            rState.pOld1 = pPattern;
         }
-        while (nStart <= nEndRow);
+
+        if ( !mvData.empty() )
+            nStart = mvData[nPos].nEndRow + 1;
+        else
+            nStart = pDocument->MaxRow() + 1;
+        ++nPos;
     }
+    while (nStart <= nEndRow);
 }
 
 // assemble border
diff --git a/sc/source/core/data/bcaslot.cxx b/sc/source/core/data/bcaslot.cxx
index c3a92bf7d187..fb80a7bdb17c 100644
--- a/sc/source/core/data/bcaslot.cxx
+++ b/sc/source/core/data/bcaslot.cxx
@@ -1059,18 +1059,18 @@ void ScBroadcastAreaSlotMachine::EnterBulkBroadcast()
 
 void ScBroadcastAreaSlotMachine::LeaveBulkBroadcast( SfxHintId nHintId )
 {
-    if (nInBulkBroadcast > 0)
+    if (nInBulkBroadcast <= 0)
+        return;
+
+    if (--nInBulkBroadcast == 0)
     {
-        if (--nInBulkBroadcast == 0)
-        {
-            ScBroadcastAreasBulk().swap( aBulkBroadcastAreas);
-            bool bBroadcasted = BulkBroadcastGroupAreas( nHintId );
-            // Trigger the "final" tracking.
-            if (pDoc->IsTrackFormulasPending())
-                pDoc->FinalTrackFormulas( nHintId );
-            else if (bBroadcasted)
-                pDoc->TrackFormulas( nHintId );
-        }
+        ScBroadcastAreasBulk().swap( aBulkBroadcastAreas);
+        bool bBroadcasted = BulkBroadcastGroupAreas( nHintId );
+        // Trigger the "final" tracking.
+        if (pDoc->IsTrackFormulasPending())
+            pDoc->FinalTrackFormulas( nHintId );
+        else if (bBroadcasted)
+            pDoc->TrackFormulas( nHintId );
     }
 }
 
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 61011da9aeae..34be6086f10e 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -464,22 +464,22 @@ void ScColumn::ClearSelectionItems( const sal_uInt16* pWhich,const ScMarkData& r
     SCROW nTop;
     SCROW nBottom;
 
-    if (pAttrArray)
+    if (!pAttrArray)
+        return;
+
+    if (rMark.IsMultiMarked() )
     {
-        if (rMark.IsMultiMarked() )
+        ScMultiSelIter aMultiIter( rMark.GetMultiSelData(), nCol );
+        while (aMultiIter.Next( nTop, nBottom ))
+            pAttrArray->ClearItems(nTop, nBottom, pWhich);
+    }
+    else if (rMark.IsMarked())
+    {
+        ScRange aRange;
+        rMark.GetMarkArea(aRange);
+        if (aRange.aStart.Col() <= nCol && nCol <= aRange.aEnd.Col())
         {
-            ScMultiSelIter aMultiIter( rMark.GetMultiSelData(), nCol );
-            while (aMultiIter.Next( nTop, nBottom ))
-                pAttrArray->ClearItems(nTop, nBottom, pWhich);
-        }
-        else if (rMark.IsMarked())
-        {
-            ScRange aRange;
-            rMark.GetMarkArea(aRange);
-            if (aRange.aStart.Col() <= nCol && nCol <= aRange.aEnd.Col())
-            {
-                pAttrArray->ClearItems(aRange.aStart.Row(), aRange.aEnd.Row(), pWhich);
-            }
+            pAttrArray->ClearItems(aRange.aStart.Row(), aRange.aEnd.Row(), pWhich);
         }
     }
 }
@@ -1489,29 +1489,29 @@ class CopyByCloneHandler
             }
         }
 
-        if (bCloneString)
-        {
-            svl::SharedString aStr = rSrcCell.GetString();
-            if (aStr.isEmpty())
-                // Don't create empty string cells.
-                return;
+        if (!bCloneString)
+            return;
 
-            if (rSrcCell.IsMultilineResult())
-            {
-                // Clone as an edit text object.
-                EditEngine& rEngine = mrDestCol.GetDoc()->GetEditEngine();
-                rEngine.SetText(aStr.getString());
-                maDestPos.miCellPos =
-                    mrDestCol.GetCellStore().set(maDestPos.miCellPos, nRow, rEngine.CreateTextObject().release());
-            }
-            else
-            {
-                maDestPos.miCellPos =
-                    mrDestCol.GetCellStore().set(maDestPos.miCellPos, nRow, aStr);
-            }
+        svl::SharedString aStr = rSrcCell.GetString();
+        if (aStr.isEmpty())
+            // Don't create empty string cells.
+            return;
 
-            setDefaultAttrToDest(nRow);
+        if (rSrcCell.IsMultilineResult())
+        {
+            // Clone as an edit text object.
+            EditEngine& rEngine = mrDestCol.GetDoc()->GetEditEngine();
+            rEngine.SetText(aStr.getString());
+            maDestPos.miCellPos =
+                mrDestCol.GetCellStore().set(maDestPos.miCellPos, nRow, rEngine.CreateTextObject().release());
         }
+        else
+        {
+            maDestPos.miCellPos =
+                mrDestCol.GetCellStore().set(maDestPos.miCellPos, nRow, aStr);
+        }
+
+        setDefaultAttrToDest(nRow);
     }
 
 public:
@@ -1531,28 +1531,28 @@ public:
 
     ~CopyByCloneHandler()
     {
-        if (mpDestPos)
-        {
-            // If broadcasters were setup in the same column,
-            // maDestPos.miBroadcasterPos doesn't match
-            // mrDestCol.maBroadcasters because it is never passed anywhere.
-            // Assign a corresponding iterator before copying all over.
-            // Otherwise this may result in wrongly copying a singular
-            // iterator.
+        if (!mpDestPos)
+            return;
 
-            {
-                /* XXX Using a temporary ColumnBlockPosition just for
-                 * initializing from ScColumn::maBroadcasters.begin() is ugly,
-                 * on the other hand we don't want to expose
-                 * ScColumn::maBroadcasters to the outer world and have a
-                 * getter. */
-                sc::ColumnBlockPosition aTempBlock;
-                mrDestCol.InitBlockPosition(aTempBlock);
-                maDestPos.miBroadcasterPos = aTempBlock.miBroadcasterPos;
-            }
+        // If broadcasters were setup in the same column,
+        // maDestPos.miBroadcasterPos doesn't match
+        // mrDestCol.maBroadcasters because it is never passed anywhere.
+        // Assign a corresponding iterator before copying all over.
+        // Otherwise this may result in wrongly copying a singular
+        // iterator.
 
-            *mpDestPos = maDestPos;
+        {
+            /* XXX Using a temporary ColumnBlockPosition just for
+             * initializing from ScColumn::maBroadcasters.begin() is ugly,
+             * on the other hand we don't want to expose
+             * ScColumn::maBroadcasters to the outer world and have a
+             * getter. */
+            sc::ColumnBlockPosition aTempBlock;
+            mrDestCol.InitBlockPosition(aTempBlock);
+            maDestPos.miBroadcasterPos = aTempBlock.miBroadcasterPos;
         }
+
+        *mpDestPos = maDestPos;
     }
 
     void setStartListening( bool b )
@@ -1731,29 +1731,29 @@ void ScColumn::CopyToColumn(
             pAttrArray->CopyArea( nRow1, nRow2, 0, *rColumn.pAttrArray);
     }
 
-    if ((nFlags & InsertDeleteFlags::CONTENTS) != InsertDeleteFlags::NONE)
-    {
-        if (bAsLink)
-        {
-            CopyAsLinkHandler aFunc(*this, rColumn, rCxt.getBlockPosition(rColumn.nTab, rColumn.nCol), nFlags);
-            aFunc.setStartListening(rCxt.isStartListening());
-            sc::ParseBlock(maCells.begin(), maCells, aFunc, nRow1, nRow2);
-        }
-        else
-        {
-            // Compare the ScDocumentPool* to determine if we are copying
-            // within the same document. If not, re-intern shared strings.
-            svl::SharedStringPool* pSharedStringPool =
-                (GetDoc()->GetPool() != rColumn.GetDoc()->GetPool()) ?
-                &rColumn.GetDoc()->GetSharedStringPool() : nullptr;
-            CopyByCloneHandler aFunc(*this, rColumn, rCxt.getBlockPosition(rColumn.nTab, rColumn.nCol), nFlags,
-                    pSharedStringPool, bGlobalNamesToLocal);
-            aFunc.setStartListening(rCxt.isStartListening());
-            sc::ParseBlock(maCells.begin(), maCells, aFunc, nRow1, nRow2);
-        }
+    if ((nFlags & InsertDeleteFlags::CONTENTS) == InsertDeleteFlags::NONE)
+        return;
 
-        rColumn.CellStorageModified();
+    if (bAsLink)
+    {
+        CopyAsLinkHandler aFunc(*this, rColumn, rCxt.getBlockPosition(rColumn.nTab, rColumn.nCol), nFlags);
+        aFunc.setStartListening(rCxt.isStartListening());
+        sc::ParseBlock(maCells.begin(), maCells, aFunc, nRow1, nRow2);
+    }
+    else
+    {
+        // Compare the ScDocumentPool* to determine if we are copying
+        // within the same document. If not, re-intern shared strings.
+        svl::SharedStringPool* pSharedStringPool =
+            (GetDoc()->GetPool() != rColumn.GetDoc()->GetPool()) ?
+            &rColumn.GetDoc()->GetSharedStringPool() : nullptr;
+        CopyByCloneHandler aFunc(*this, rColumn, rCxt.getBlockPosition(rColumn.nTab, rColumn.nCol), nFlags,
+                pSharedStringPool, bGlobalNamesToLocal);
+        aFunc.setStartListening(rCxt.isStartListening());
+        sc::ParseBlock(maCells.begin(), maCells, aFunc, nRow1, nRow2);
     }
+
+    rColumn.CellStorageModified();
 }
 
 void ScColumn::UndoToColumn(
@@ -2281,41 +2281,41 @@ class UpdateRefOnNonCopy
 
         sc::RefUpdateResult aRes = pCode->AdjustReferenceOnMove(*mpCxt, aOldPos, aPos);
 
-        if (aRes.mbReferenceModified || aRes.mbNameModified || bRecalcOnMove)
-        {
-            sc::AutoCalcSwitch aACSwitch(mpCxt->mrDoc, false);
+        if (!(aRes.mbReferenceModified || aRes.mbNameModified || bRecalcOnMove))
+            return;
 
-            if (aRes.mbNameModified)
-                recompileTokenArray(*pTop);
+        sc::AutoCalcSwitch aACSwitch(mpCxt->mrDoc, false);
 
-            // Perform end-listening, start-listening, and dirtying on all
-            // formula cells in the group.
+        if (aRes.mbNameModified)
+            recompileTokenArray(*pTop);
 
-            // Make sure that the start and end listening contexts share the
-            // same block position set, else an invalid iterator may ensue.
-            auto pPosSet = std::make_shared<sc::ColumnBlockPositionSet>(mpCxt->mrDoc);
+        // Perform end-listening, start-listening, and dirtying on all
+        // formula cells in the group.
 
-            sc::StartListeningContext aStartCxt(mpCxt->mrDoc, pPosSet);
-            sc::EndListeningContext aEndCxt(mpCxt->mrDoc, pPosSet, pOldCode.get());
+        // Make sure that the start and end listening contexts share the
+        // same block position set, else an invalid iterator may ensue.
+        auto pPosSet = std::make_shared<sc::ColumnBlockPositionSet>(mpCxt->mrDoc);
 
-            aEndCxt.setPositionDelta(
-                ScAddress(-mpCxt->mnColDelta, -mpCxt->mnRowDelta, -mpCxt->mnTabDelta));
+        sc::StartListeningContext aStartCxt(mpCxt->mrDoc, pPosSet);
+        sc::EndListeningContext aEndCxt(mpCxt->mrDoc, pPosSet, pOldCode.get());
 
-            for (; pp != ppEnd; ++pp)
-            {
-                ScFormulaCell* p = *pp;
-                p->EndListeningTo(aEndCxt);
-                p->StartListeningTo(aStartCxt);
-                p->SetDirty();
-            }
-
-            mbUpdated = true;
+        aEndCxt.setPositionDelta(
+            ScAddress(-mpCxt->mnColDelta, -mpCxt->mnRowDelta, -mpCxt->mnTabDelta));
 
-            // Move from clipboard is Cut&Paste, then do not copy the original
-            // positions' formula cells to the Undo document.
-            if (!mbClipboardSource || !bCellMoved)
-                fillUndoDoc(aOldPos, rGroup.mnLength, *pOldCode);
+        for (; pp != ppEnd; ++pp)
+        {
+            ScFormulaCell* p = *pp;
+            p->EndListeningTo(aEndCxt);
+            p->StartListeningTo(aStartCxt);
+            p->SetDirty();
         }
+
+        mbUpdated = true;
+
+        // Move from clipboard is Cut&Paste, then do not copy the original
+        // positions' formula cells to the Undo document.
+        if (!mbClipboardSource || !bCellMoved)
+            fillUndoDoc(aOldPos, rGroup.mnLength, *pOldCode);
     }
 
     void fillUndoDoc( const ScAddress& rOldPos, SCROW nLength, const ScTokenArray& rOldCode )
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 0f4f3d8e76ab..011caea06a13 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -343,21 +343,21 @@ void ScColumn::StartListeningUnshared( const std::vector<SCROW>& rNewSharedRows
 {
     assert(rNewSharedRows.empty() || rNewSharedRows.size() == 2 || rNewSharedRows.size() == 4);
     ScDocument* pDoc = GetDoc();
-    if (!rNewSharedRows.empty() && !pDoc->IsDelayedFormulaGrouping())
+    if (rNewSharedRows.empty() || pDoc->IsDelayedFormulaGrouping())
+        return;
+
+    auto pPosSet = std::make_shared<sc::ColumnBlockPositionSet>(*pDoc);
+    sc::StartListeningContext aStartCxt(*pDoc, pPosSet);
+    sc::EndListeningContext aEndCxt(*pDoc, pPosSet);
+    if (rNewSharedRows.size() >= 2)
     {
-        auto pPosSet = std::make_shared<sc::ColumnBlockPositionSet>(*pDoc);
-        sc::StartListeningContext aStartCxt(*pDoc, pPosSet);
-        sc::EndListeningContext aEndCxt(*pDoc, pPosSet);
-        if (rNewSharedRows.size() >= 2)
-        {
-            if(!pDoc->CanDelayStartListeningFormulaCells( this, rNewSharedRows[0], rNewSharedRows[1]))
-                StartListeningFormulaCells(aStartCxt, aEndCxt, rNewSharedRows[0], rNewSharedRows[1]);
-        }
-        if (rNewSharedRows.size() >= 4)
-        {
-            if(!pDoc->CanDelayStartListeningFormulaCells( this, rNewSharedRows[2], rNewSharedRows[3]))
-                StartListeningFormulaCells(aStartCxt, aEndCxt, rNewSharedRows[2], rNewSharedRows[3]);
-        }
+        if(!pDoc->CanDelayStartListeningFormulaCells( this, rNewSharedRows[0], rNewSharedRows[1]))
+            StartListeningFormulaCells(aStartCxt, aEndCxt, rNewSharedRows[0], rNewSharedRows[1]);
+    }
+    if (rNewSharedRows.size() >= 4)
+    {
+        if(!pDoc->CanDelayStartListeningFormulaCells( this, rNewSharedRows[2], rNewSharedRows[3]))
+            StartListeningFormulaCells(aStartCxt, aEndCxt, rNewSharedRows[2], rNewSharedRows[3]);
     }
 }
 
@@ -693,53 +693,53 @@ void ScColumn::AttachNewFormulaCells( const sc::CellStoreType::position_type& aP
     JoinNewFormulaCell(aPosLast, *pCell2);
 
     ScDocument* pDocument = GetDoc();
-    if (!pDocument->IsClipOrUndo() && !pDocument->IsInsertingFromOtherDoc())
+    if (pDocument->IsClipOrUndo() || pDocument->IsInsertingFromOtherDoc())
+        return;
+
+    const bool bShared = pCell1->IsShared() || pCell2->IsShared();
+    if (bShared)
     {
-        const bool bShared = pCell1->IsShared() || pCell2->IsShared();
-        if (bShared)
+        const SCROW nTopRow = (pCell1->IsShared() ? pCell1->GetSharedTopRow() : pCell1->aPos.Row());
+        const SCROW nBotRow = (pCell2->IsShared() ?
+                pCell2->GetSharedTopRow() + pCell2->GetSharedLength() - 1 : pCell2->aPos.Row());
+        if (rNewSharedRows.empty())
         {
-            const SCROW nTopRow = (pCell1->IsShared() ? pCell1->GetSharedTopRow() : pCell1->aPos.Row());
-            const SCROW nBotRow = (pCell2->IsShared() ?
-                    pCell2->GetSharedTopRow() + pCell2->GetSharedLength() - 1 : pCell2->aPos.Row());
-            if (rNewSharedRows.empty())
-            {
-                rNewSharedRows.push_back( nTopRow);
-                rNewSharedRows.push_back( nBotRow);
-            }
-            else if (rNewSharedRows.size() == 2)
-            {
-                // Combine into one span.
-                if (rNewSharedRows[0] > nTopRow)
-                    rNewSharedRows[0] = nTopRow;
-                if (rNewSharedRows[1] < nBotRow)
-                    rNewSharedRows[1] = nBotRow;
-            }
-            else if (rNewSharedRows.size() == 4)
-            {
-                // Merge into one span.
-                // The original two spans are ordered from top to bottom.
-                std::vector<SCROW> aRows(2);
-                aRows[0] = std::min( rNewSharedRows[0], nTopRow);
-                aRows[1] = std::max( rNewSharedRows[3], nBotRow);
-                rNewSharedRows.swap( aRows);
-            }
-            else
-            {
-                assert(!"rNewSharedRows?");
-            }
+            rNewSharedRows.push_back( nTopRow);
+            rNewSharedRows.push_back( nBotRow);
         }
-        StartListeningUnshared( rNewSharedRows);
-
-        sc::StartListeningContext aCxt(*pDocument);
-        ScFormulaCell** pp = &sc::formula_block::at(*aPos.first->data, aPos.second);
-        ScFormulaCell** ppEnd = pp + nLength;
-        for (; pp != ppEnd; ++pp)
+        else if (rNewSharedRows.size() == 2)
         {
-            if (!bShared)
-                (*pp)->StartListeningTo(aCxt);
-            if (!pDocument->IsCalcingAfterLoad())
-                (*pp)->SetDirty();
+            // Combine into one span.
+            if (rNewSharedRows[0] > nTopRow)
+                rNewSharedRows[0] = nTopRow;
+            if (rNewSharedRows[1] < nBotRow)
+                rNewSharedRows[1] = nBotRow;
         }
+        else if (rNewSharedRows.size() == 4)
+        {
+            // Merge into one span.
+            // The original two spans are ordered from top to bottom.
+            std::vector<SCROW> aRows(2);
+            aRows[0] = std::min( rNewSharedRows[0], nTopRow);
+            aRows[1] = std::max( rNewSharedRows[3], nBotRow);
+            rNewSharedRows.swap( aRows);
+        }
+        else
+        {
+            assert(!"rNewSharedRows?");
+        }
+    }
+    StartListeningUnshared( rNewSharedRows);
+
+    sc::StartListeningContext aCxt(*pDocument);
+    ScFormulaCell** pp = &sc::formula_block::at(*aPos.first->data, aPos.second);
+    ScFormulaCell** ppEnd = pp + nLength;
+    for (; pp != ppEnd; ++pp)
+    {
+        if (!bShared)
+            (*pp)->StartListeningTo(aCxt);
+        if (!pDocument->IsCalcingAfterLoad())
+            (*pp)->SetDirty();
     }
 }
 
diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index 06f4684a5acd..d3a2d3db6a53 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -286,26 +286,26 @@ void ScColumn::CopyOneCellFromClip( sc::CopyFromClipContext& rCxt, SCROW nRow1,
     }
 
     const ScPostIt* pNote = rCxt.getSingleCellNote(nColOffset);
-    if (pNote && (nFlags & (InsertDeleteFlags::NOTE | InsertDeleteFlags::ADDNOTES)) != InsertDeleteFlags::NONE)
-    {
-        // Duplicate the cell note over the whole pasted range.
-
-        ScDocument* pClipDoc = rCxt.getClipDoc();
-        const ScAddress aSrcPos = pClipDoc->GetClipParam().getWholeRange().aStart;
-        std::vector<ScPostIt*> aNotes;
-        ScAddress aDestPos(nCol, nRow1, nTab);
-        aNotes.reserve(nDestSize);
-        for (size_t i = 0; i < nDestSize; ++i)
-        {
-            bool bCloneCaption = (nFlags & InsertDeleteFlags::NOCAPTIONS) == InsertDeleteFlags::NONE;
-            aNotes.push_back(pNote->Clone(aSrcPos, *pDocument, aDestPos, bCloneCaption).release());
-            aDestPos.IncRow();
-        }
+    if (!(pNote && (nFlags & (InsertDeleteFlags::NOTE | InsertDeleteFlags::ADDNOTES)) != InsertDeleteFlags::NONE))
+        return;
 
-        pBlockPos->miCellNotePos =
-            maCellNotes.set(
-                pBlockPos->miCellNotePos, nRow1, aNotes.begin(), aNotes.end());
+    // Duplicate the cell note over the whole pasted range.
+
+    ScDocument* pClipDoc = rCxt.getClipDoc();
+    const ScAddress aSrcPos = pClipDoc->GetClipParam().getWholeRange().aStart;
+    std::vector<ScPostIt*> aNotes;
+    ScAddress aDestPos(nCol, nRow1, nTab);
+    aNotes.reserve(nDestSize);
+    for (size_t i = 0; i < nDestSize; ++i)
+    {
+        bool bCloneCaption = (nFlags & InsertDeleteFlags::NOCAPTIONS) == InsertDeleteFlags::NONE;
+        aNotes.push_back(pNote->Clone(aSrcPos, *pDocument, aDestPos, bCloneCaption).release());
+        aDestPos.IncRow();
     }
+
+    pBlockPos->miCellNotePos =
+        maCellNotes.set(
+            pBlockPos->miCellNotePos, nRow1, aNotes.begin(), aNotes.end());
 }
 
 void ScColumn::SetValues( const SCROW nRow, const std::vector<double>& rVals )
@@ -834,37 +834,37 @@ public:
         ScTokenArray* pCode = pTop->GetCode();
         bool bRecompile = pCode->HasOpCodes(mrOps);
 
-        if (bRecompile)
+        if (!bRecompile)
+            return;
+
+        // Get the formula string.
+        OUString aFormula = pTop->GetFormula(mrCompileFormulaCxt);
+        sal_Int32 n = aFormula.getLength();
+        if (pTop->GetMatrixFlag() != ScMatrixMode::NONE && n > 0)
         {
-            // Get the formula string.
-            OUString aFormula = pTop->GetFormula(mrCompileFormulaCxt);
-            sal_Int32 n = aFormula.getLength();
-            if (pTop->GetMatrixFlag() != ScMatrixMode::NONE && n > 0)
-            {
-                if (aFormula[0] == '{' && aFormula[n-1] == '}')
-                    aFormula = aFormula.copy(1, n-2);
-            }
+            if (aFormula[0] == '{' && aFormula[n-1] == '}')
+                aFormula = aFormula.copy(1, n-2);
+        }
 
-            if (rEntry.mbShared)
-            {
-                ScFormulaCell** pp = rEntry.mpCells;
-                ScFormulaCell** ppEnd = pp + rEntry.mnLength;
-                for (; pp != ppEnd; ++pp)
-                {
-                    ScFormulaCell* p = *pp;
-                    p->EndListeningTo(mrEndListenCxt);
-                    mpDoc->RemoveFromFormulaTree(p);
-                }
-            }
-            else
+        if (rEntry.mbShared)
+        {
+            ScFormulaCell** pp = rEntry.mpCells;
+            ScFormulaCell** ppEnd = pp + rEntry.mnLength;
+            for (; pp != ppEnd; ++pp)
             {
-                rEntry.mpCell->EndListeningTo(mrEndListenCxt);
-                mpDoc->RemoveFromFormulaTree(rEntry.mpCell);
+                ScFormulaCell* p = *pp;
+                p->EndListeningTo(mrEndListenCxt);
+                mpDoc->RemoveFromFormulaTree(p);
             }
-
-            pCode->Clear();
-            pTop->SetHybridFormula(aFormula, mpDoc->GetGrammar());
         }
+        else
+        {
+            rEntry.mpCell->EndListeningTo(mrEndListenCxt);
+            mpDoc->RemoveFromFormulaTree(rEntry.mpCell);
+        }
+
+        pCode->Clear();
+        pTop->SetHybridFormula(aFormula, mpDoc->GetGrammar());
     }
 };
 
@@ -1550,24 +1550,24 @@ void ScColumn::EndListeningIntersectedGroups(
 
     aPos = maCells.position(it, nRow2);
     it = aPos.first;
-    if (it->type == sc::element_type_formula)
-    {
-        ScFormulaCell* pFC = sc::formula_block::at(*it->data, aPos.second);
-        ScFormulaCellGroupRef xGroup = pFC->GetCellGroup();
-        if (xGroup)
-        {
-            if (!pFC->IsSharedTop())
-                // End listening.
-                pFC->EndListeningTo(rCxt);
+    if (it->type != sc::element_type_formula)
+        return;
 
-            if (pGroupPos)
-            {
-                // Record the position of the bottom cell of the group.
-                ScAddress aPosLast = xGroup->mpTopCell->aPos;
-                aPosLast.IncRow(xGroup->mnLength-1);
-                pGroupPos->push_back(aPosLast);
-            }
-        }
+    ScFormulaCell* pFC = sc::formula_block::at(*it->data, aPos.second);
+    ScFormulaCellGroupRef xGroup = pFC->GetCellGroup();
+    if (!xGroup)
+        return;
+
+    if (!pFC->IsSharedTop())
+        // End listening.
+        pFC->EndListeningTo(rCxt);
+
+    if (pGroupPos)
+    {
+        // Record the position of the bottom cell of the group.
+        ScAddress aPosLast = xGroup->mpTopCell->aPos;
+        aPosLast.IncRow(xGroup->mnLength-1);
+        pGroupPos->push_back(aPosLast);
     }
 }
 
diff --git a/sc/source/core/data/compressedarray.cxx b/sc/source/core/data/compressedarray.cxx
index 914a6c52eb1f..6a3d41598ad7 100644
--- a/sc/source/core/data/compressedarray.cxx
+++ b/sc/source/core/data/compressedarray.cxx
@@ -69,124 +69,124 @@ size_t ScCompressedArray<A,D>::Search( A nAccess ) const
 template< typename A, typename D >
 void ScCompressedArray<A,D>::SetValue( A nStart, A nEnd, const D& rValue )
 {
-    if (0 <= nStart && nStart <= nMaxAccess && 0 <= nEnd && nEnd <= nMaxAccess
-            && nStart <= nEnd)
+    if (!(0 <= nStart && nStart <= nMaxAccess && 0 <= nEnd && nEnd <= nMaxAccess
+            && nStart <= nEnd))
+        return;
+
+    if ((nStart == 0) && (nEnd == nMaxAccess))
+        Reset( rValue);
+    else
     {
-        if ((nStart == 0) && (nEnd == nMaxAccess))
-            Reset( rValue);
-        else
+        // Create a temporary copy in case we got a reference passed that
+        // points to a part of the array to be reallocated.
+        D aNewVal( rValue);
+        size_t nNeeded = nCount + 2;
+        if (nLimit < nNeeded)
         {
-            // Create a temporary copy in case we got a reference passed that
-            // points to a part of the array to be reallocated.
-            D aNewVal( rValue);
-            size_t nNeeded = nCount + 2;
+            nLimit *= 1.5;
             if (nLimit < nNeeded)
-            {
-                nLimit *= 1.5;
-                if (nLimit < nNeeded)
-                    nLimit = nNeeded;
-                std::unique_ptr<DataEntry[]> pNewData(new DataEntry[nLimit]);
-                memcpy( pNewData.get(), pData.get(), nCount*sizeof(DataEntry));
-                pData = std::move(pNewData);
-            }
+                nLimit = nNeeded;
+            std::unique_ptr<DataEntry[]> pNewData(new DataEntry[nLimit]);
+            memcpy( pNewData.get(), pData.get(), nCount*sizeof(DataEntry));
+            pData = std::move(pNewData);
+        }
 
-            size_t ni;          // number of leading entries
-            size_t nInsert;     // insert position (nMaxAccess+1 := no insert)
-            bool bCombined = false;
-            bool bSplit = false;
-            if (nStart > 0)
-            {
-                // skip leading
-                ni = this->Search( nStart);
+        size_t ni;          // number of leading entries
+        size_t nInsert;     // insert position (nMaxAccess+1 := no insert)
+        bool bCombined = false;
+        bool bSplit = false;
+        if (nStart > 0)
+        {
+            // skip leading
+            ni = this->Search( nStart);
 
-                nInsert = nMaxAccess+1;
-                if (!(pData[ni].aValue == aNewVal))
-                {
-                    if (ni == 0 || (pData[ni-1].nEnd < nStart - 1))
-                    {   // may be a split or a simple insert or just a shrink,
-                        // row adjustment is done further down
-                        if (pData[ni].nEnd > nEnd)
-                            bSplit = true;
-                        ni++;
-                        nInsert = ni;
-                    }
-                    else if (ni > 0 && pData[ni-1].nEnd == nStart - 1)
-                        nInsert = ni;
-                }
-                if (ni > 0 && pData[ni-1].aValue == aNewVal)
-                {   // combine
-                    pData[ni-1].nEnd = nEnd;
-                    nInsert = nMaxAccess+1;
-                    bCombined = true;
+            nInsert = nMaxAccess+1;
+            if (!(pData[ni].aValue == aNewVal))
+            {
+                if (ni == 0 || (pData[ni-1].nEnd < nStart - 1))
+                {   // may be a split or a simple insert or just a shrink,
+                    // row adjustment is done further down
+                    if (pData[ni].nEnd > nEnd)
+                        bSplit = true;
+                    ni++;
+                    nInsert = ni;
                 }
+                else if (ni > 0 && pData[ni-1].nEnd == nStart - 1)
+                    nInsert = ni;
             }
-            else
-            {
-                nInsert = 0;
-                ni = 0;
+            if (ni > 0 && pData[ni-1].aValue == aNewVal)
+            {   // combine
+                pData[ni-1].nEnd = nEnd;
+                nInsert = nMaxAccess+1;
+                bCombined = true;
             }
+        }
+        else
+        {
+            nInsert = 0;
+            ni = 0;
+        }
 
-            size_t nj = ni;     // stop position of range to replace
-            while (nj < nCount && pData[nj].nEnd <= nEnd)
-                nj++;
-            if (!bSplit)
-            {
-                if (nj < nCount && pData[nj].aValue == aNewVal)
-                {   // combine
-                    if (ni > 0)
-                    {
-                        if (pData[ni-1].aValue == aNewVal)
-                        {   // adjacent entries
-                            pData[ni-1].nEnd = pData[nj].nEnd;
-                            nj++;
-                        }
-                        else if (ni == nInsert)
-                            pData[ni-1].nEnd = nStart - 1;   // shrink
+        size_t nj = ni;     // stop position of range to replace
+        while (nj < nCount && pData[nj].nEnd <= nEnd)
+            nj++;
+        if (!bSplit)
+        {
+            if (nj < nCount && pData[nj].aValue == aNewVal)
+            {   // combine
+                if (ni > 0)
+                {
+                    if (pData[ni-1].aValue == aNewVal)
+                    {   // adjacent entries
+                        pData[ni-1].nEnd = pData[nj].nEnd;
+                        nj++;
                     }
-                    nInsert = nMaxAccess+1;
-                    bCombined = true;
+                    else if (ni == nInsert)
+                        pData[ni-1].nEnd = nStart - 1;   // shrink
                 }
-                else if (ni > 0 && ni == nInsert)
-                    pData[ni-1].nEnd = nStart - 1;   // shrink
+                nInsert = nMaxAccess+1;
+                bCombined = true;
+            }
+            else if (ni > 0 && ni == nInsert)
+                pData[ni-1].nEnd = nStart - 1;   // shrink
+        }
+        if (ni < nj)
+        {   // remove middle entries
+            if (!bCombined)
+            {   // replace one entry
+                pData[ni].nEnd = nEnd;
+                pData[ni].aValue = aNewVal;
+                ni++;
+                nInsert = nMaxAccess+1;
             }
             if (ni < nj)
-            {   // remove middle entries
-                if (!bCombined)
-                {   // replace one entry
-                    pData[ni].nEnd = nEnd;
-                    pData[ni].aValue = aNewVal;
-                    ni++;
-                    nInsert = nMaxAccess+1;
-                }
-                if (ni < nj)
-                {   // remove entries
-                    memmove( pData.get() + ni, pData.get() + nj,
-                            (nCount - nj) * sizeof(DataEntry));
-                    nCount -= nj - ni;
-                }
+            {   // remove entries
+                memmove( pData.get() + ni, pData.get() + nj,
+                        (nCount - nj) * sizeof(DataEntry));
+                nCount -= nj - ni;
             }
+        }
 
-            if (nInsert < static_cast<size_t>(nMaxAccess+1))
-            {   // insert or append new entry
-                if (nInsert <= nCount)
+        if (nInsert < static_cast<size_t>(nMaxAccess+1))
+        {   // insert or append new entry
+            if (nInsert <= nCount)
+            {
+                if (!bSplit)
+                    memmove( pData.get() + nInsert + 1, pData.get() + nInsert,
+                            (nCount - nInsert) * sizeof(DataEntry));
+                else
                 {
-                    if (!bSplit)
-                        memmove( pData.get() + nInsert + 1, pData.get() + nInsert,
-                                (nCount - nInsert) * sizeof(DataEntry));
-                    else
-                    {
-                        memmove( pData.get() + nInsert + 2, pData.get() + nInsert,
-                                (nCount - nInsert) * sizeof(DataEntry));
-                        pData[nInsert+1] = pData[nInsert-1];
-                        nCount++;
-                    }
+                    memmove( pData.get() + nInsert + 2, pData.get() + nInsert,
+                            (nCount - nInsert) * sizeof(DataEntry));
+                    pData[nInsert+1] = pData[nInsert-1];
+                    nCount++;
                 }
-                if (nInsert)
-                    pData[nInsert-1].nEnd = nStart - 1;
-                pData[nInsert].nEnd = nEnd;
-                pData[nInsert].aValue = aNewVal;
-                nCount++;
             }
+            if (nInsert)
+                pData[nInsert-1].nEnd = nStart - 1;
+            pData[nInsert].nEnd = nEnd;
+            pData[nInsert].aValue = aNewVal;
+            nCount++;
         }
     }
 }
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index b18b68e1fc68..94a8dd4be086 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -311,24 +311,24 @@ void ScConditionEntry::SimplifyCompiledFormula( std::unique_ptr<ScTokenArray>& r
                                                 bool& rIsStr,
                                                 OUString& rStrVal )
 {
-    if ( rFormula->GetLen() == 1 )
+    if ( rFormula->GetLen() != 1 )
+        return;
+
+    // Single (constant number)?
+    FormulaToken* pToken = rFormula->FirstToken();
+    if ( pToken->GetOpCode() != ocPush )
+        return;
+
+    if ( pToken->GetType() == svDouble )
     {
-        // Single (constant number)?
-        FormulaToken* pToken = rFormula->FirstToken();
-        if ( pToken->GetOpCode() == ocPush )
-        {
-            if ( pToken->GetType() == svDouble )
-            {
-                rVal = pToken->GetDouble();
-                rFormula.reset();             // Do not remember as formula
-            }
-            else if ( pToken->GetType() == svString )
-            {
-                rIsStr = true;
-                rStrVal = pToken->GetString().getString();
-                rFormula.reset();             // Do not remember as formula
-            }
-        }
+        rVal = pToken->GetDouble();
+        rFormula.reset();             // Do not remember as formula
+    }
+    else if ( pToken->GetType() == svString )
+    {
+        rIsStr = true;
+        rStrVal = pToken->GetString().getString();
+        rFormula.reset();             // Do not remember as formula
     }
 }
 
@@ -392,23 +392,23 @@ void ScConditionEntry::Compile( const OUString& rExpr1, const OUString& rExpr2,
  */
 void ScConditionEntry::MakeCells( const ScAddress& rPos )
 {
-    if ( !mpDoc->IsClipOrUndo() ) // Never calculate in the Clipboard!
+    if ( mpDoc->IsClipOrUndo() ) // Never calculate in the Clipboard!
+        return;
+
+    if ( pFormula1 && !pFCell1 && !bRelRef1 )
     {
-        if ( pFormula1 && !pFCell1 && !bRelRef1 )
-        {
-            // pFCell1 will hold a flat-copied ScTokenArray sharing ref-counted
-            // code tokens with pFormula1
-            pFCell1.reset( new ScFormulaCell(mpDoc, rPos, *pFormula1) );
-            pFCell1->StartListeningTo( mpDoc );
-        }
+        // pFCell1 will hold a flat-copied ScTokenArray sharing ref-counted
+        // code tokens with pFormula1
+        pFCell1.reset( new ScFormulaCell(mpDoc, rPos, *pFormula1) );
+        pFCell1->StartListeningTo( mpDoc );
+    }
 
-        if ( pFormula2 && !pFCell2 && !bRelRef2 )
-        {
-            // pFCell2 will hold a flat-copied ScTokenArray sharing ref-counted
-            // code tokens with pFormula2
-            pFCell2.reset( new ScFormulaCell(mpDoc, rPos, *pFormula2) );
-            pFCell2->StartListeningTo( mpDoc );
-        }
+    if ( pFormula2 && !pFCell2 && !bRelRef2 )
+    {
+        // pFCell2 will hold a flat-copied ScTokenArray sharing ref-counted
+        // code tokens with pFormula2
+        pFCell2.reset( new ScFormulaCell(mpDoc, rPos, *pFormula2) );
+        pFCell2->StartListeningTo( mpDoc );
     }
 }
 
@@ -755,58 +755,58 @@ static bool lcl_GetCellContent( ScRefCellValue& rCell, bool bIsStr1, double& rAr
 
 void ScConditionEntry::FillCache() const
 {
-    if(!mpCache)
-    {
-        const ScRangeList& rRanges = pCondFormat->GetRange();
-        mpCache.reset(new ScConditionEntryCache);
-        size_t nListCount = rRanges.size();
-        for( size_t i = 0; i < nListCount; i++ )
+    if(mpCache)
+        return;
+
+    const ScRangeList& rRanges = pCondFormat->GetRange();
+    mpCache.reset(new ScConditionEntryCache);
+    size_t nListCount = rRanges.size();
+    for( size_t i = 0; i < nListCount; i++ )
+    {
+        const ScRange & rRange = rRanges[i];
+        SCROW nRow = rRange.aEnd.Row();
+        SCCOL nCol = rRange.aEnd.Col();
+        SCCOL nColStart = rRange.aStart.Col();
+        SCROW nRowStart = rRange.aStart.Row();
+        SCTAB nTab = rRange.aStart.Tab();
+
+        // temporary fix to workaround slow duplicate entry
+        // conditions, prevent to use a whole row
+        if(nRow == MAXROW)
         {
-            const ScRange & rRange = rRanges[i];
-            SCROW nRow = rRange.aEnd.Row();
-            SCCOL nCol = rRange.aEnd.Col();
-            SCCOL nColStart = rRange.aStart.Col();
-            SCROW nRowStart = rRange.aStart.Row();
-            SCTAB nTab = rRange.aStart.Tab();
-
-            // temporary fix to workaround slow duplicate entry
-            // conditions, prevent to use a whole row
-            if(nRow == MAXROW)
+            bool bShrunk = false;
+            mpDoc->ShrinkToUsedDataArea(bShrunk, nTab, nColStart, nRowStart,
+                    nCol, nRow, false);
+        }
+
+        for( SCROW r = nRowStart; r <= nRow; r++ )
+            for( SCCOL c = nColStart; c <= nCol; c++ )
             {
-                bool bShrunk = false;
-                mpDoc->ShrinkToUsedDataArea(bShrunk, nTab, nColStart, nRowStart,
-                        nCol, nRow, false);
-            }
+                ScRefCellValue aCell(*mpDoc, ScAddress(c, r, nTab));
+                if (aCell.isEmpty())
+                    continue;
 
-            for( SCROW r = nRowStart; r <= nRow; r++ )
-                for( SCCOL c = nColStart; c <= nCol; c++ )
+                double nVal = 0.0;
+                OUString aStr;
+                if (!lcl_GetCellContent(aCell, false, nVal, aStr, mpDoc))
                 {
-                    ScRefCellValue aCell(*mpDoc, ScAddress(c, r, nTab));
-                    if (aCell.isEmpty())
-                        continue;
+                    std::pair<ScConditionEntryCache::StringCacheType::iterator, bool> aResult =
+                        mpCache->maStrings.emplace(aStr, 1);
 
-                    double nVal = 0.0;
-                    OUString aStr;
-                    if (!lcl_GetCellContent(aCell, false, nVal, aStr, mpDoc))
-                    {
-                        std::pair<ScConditionEntryCache::StringCacheType::iterator, bool> aResult =
-                            mpCache->maStrings.emplace(aStr, 1);
-
-                        if(!aResult.second)
-                            aResult.first->second++;
-                    }
-                    else
-                    {
-                        std::pair<ScConditionEntryCache::ValueCacheType::iterator, bool> aResult =
-                            mpCache->maValues.emplace(nVal, 1);
+                    if(!aResult.second)
+                        aResult.first->second++;
+                }
+                else
+                {
+                    std::pair<ScConditionEntryCache::ValueCacheType::iterator, bool> aResult =
+                        mpCache->maValues.emplace(nVal, 1);
 
-                        if(!aResult.second)
-                            aResult.first->second++;
+                    if(!aResult.second)
+                        aResult.first->second++;
 
-                        ++(mpCache->nValueItems);
-                    }
+                    ++(mpCache->nValueItems);
                 }
-        }
+            }
     }
 }
 
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index eb110991140a..0fbbdadd4e18 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -80,21 +80,21 @@ static void ScAttrArray_IterGetNumberFormat( sal_uInt32& nFormat, const ScAttrAr
         SCROW& nAttrEndRow, const ScAttrArray* pNewArr, SCROW nRow,
         const ScDocument* pDoc, const ScInterpreterContext* pContext = nullptr )
 {
-    if ( rpArr != pNewArr || nAttrEndRow < nRow )
-    {
-        SCROW nRowStart = 0;
-        SCROW nRowEnd = pDoc->MaxRow();
-        const ScPatternAttr* pPattern = pNewArr->GetPatternRange( nRowStart, nRowEnd, nRow );
-        if( !pPattern )
-        {
-            pPattern = pDoc->GetDefPattern();
-            nRowEnd = pDoc->MaxRow();
-        }
+    if ( rpArr == pNewArr && nAttrEndRow >= nRow )
+        return;
 
-        nFormat = pPattern->GetNumberFormat( pContext ? pContext->GetFormatTable() : pDoc->GetFormatTable() );
-        rpArr = pNewArr;
-        nAttrEndRow = nRowEnd;
+    SCROW nRowStart = 0;
+    SCROW nRowEnd = pDoc->MaxRow();
+    const ScPatternAttr* pPattern = pNewArr->GetPatternRange( nRowStart, nRowEnd, nRow );
+    if( !pPattern )
+    {
+        pPattern = pDoc->GetDefPattern();
+        nRowEnd = pDoc->MaxRow();
     }
+
+    nFormat = pPattern->GetNumberFormat( pContext ? pContext->GetFormatTable() : pDoc->GetFormatTable() );
+    rpArr = pNewArr;
+    nAttrEndRow = nRowEnd;
 }
 
 ScValueIterator::ScValueIterator( ScDocument* pDocument, const ScRange& rRange,
@@ -1059,18 +1059,18 @@ ScQueryCellIterator::ScQueryCellIterator(ScDocument* pDocument, const ScInterpre
     nCol = maParam.nCol1;
     nRow = maParam.nRow1;
     SCSIZE i;
-    if (bMod) // Or else it's already inserted
+    if (!bMod) // Or else it's already inserted
+        return;
+
+    SCSIZE nCount = maParam.GetEntryCount();
+    for (i = 0; (i < nCount) && (maParam.GetEntry(i).bDoQuery); ++i)
     {
-        SCSIZE nCount = maParam.GetEntryCount();
-        for (i = 0; (i < nCount) && (maParam.GetEntry(i).bDoQuery); ++i)
-        {
-            ScQueryEntry& rEntry = maParam.GetEntry(i);
-            ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
-            sal_uInt32 nIndex = 0;
-            bool bNumber = mrContext.GetFormatTable()->IsNumberFormat(
-                rItem.maString.getString(), nIndex, rItem.mfVal);
-            rItem.meType = bNumber ? ScQueryEntry::ByValue : ScQueryEntry::ByString;
-        }
+        ScQueryEntry& rEntry = maParam.GetEntry(i);
+        ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
+        sal_uInt32 nIndex = 0;
+        bool bNumber = mrContext.GetFormatTable()->IsNumberFormat(
+            rItem.maString.getString(), nIndex, rItem.mfVal);
+        rItem.meType = bNumber ? ScQueryEntry::ByValue : ScQueryEntry::ByString;
     }
 }
 
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index d80e15dd1c34..9b966c8d5cf5 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -1273,85 +1273,85 @@ void ScDocument::GetCellChangeTrackNote( const ScAddress &aCellPos, OUString &aT
     //  Change-Tracking
     ScChangeTrack* pTrack = GetChangeTrack();
     ScChangeViewSettings* pSettings = GetChangeViewSettings();
-    if ( pTrack && pTrack->GetFirst() && pSettings && pSettings->ShowChanges())
+    if ( !(pTrack && pTrack->GetFirst() && pSettings && pSettings->ShowChanges()))
+        return;
+
+    const ScChangeAction* pFound = nullptr;
+    const ScChangeAction* pFoundContent = nullptr;
+    const ScChangeAction* pFoundMove = nullptr;
+    const ScChangeAction* pAction = pTrack->GetFirst();
+    while (pAction)
     {
-        const ScChangeAction* pFound = nullptr;
-        const ScChangeAction* pFoundContent = nullptr;
-        const ScChangeAction* pFoundMove = nullptr;
-        const ScChangeAction* pAction = pTrack->GetFirst();
-        while (pAction)
+        if ( pAction->IsVisible() &&
+             ScViewUtil::IsActionShown( *pAction, *pSettings, *this ) )
         {
-            if ( pAction->IsVisible() &&
-                 ScViewUtil::IsActionShown( *pAction, *pSettings, *this ) )
+            ScChangeActionType eType = pAction->GetType();
+            const ScBigRange& rBig = pAction->GetBigRange();
+            if ( rBig.aStart.Tab() == aCellPos.Tab())
             {
-                ScChangeActionType eType = pAction->GetType();
-                const ScBigRange& rBig = pAction->GetBigRange();
-                if ( rBig.aStart.Tab() == aCellPos.Tab())
+                ScRange aRange = rBig.MakeRange();
+                if ( eType == SC_CAT_DELETE_ROWS )
+                    aRange.aEnd.SetRow( aRange.aStart.Row() );
+                else if ( eType == SC_CAT_DELETE_COLS )
+                    aRange.aEnd.SetCol( aRange.aStart.Col() );
+                if ( aRange.In( aCellPos ) )
                 {
-                    ScRange aRange = rBig.MakeRange();
-                    if ( eType == SC_CAT_DELETE_ROWS )
-                        aRange.aEnd.SetRow( aRange.aStart.Row() );
-                    else if ( eType == SC_CAT_DELETE_COLS )
-                        aRange.aEnd.SetCol( aRange.aStart.Col() );
-                    if ( aRange.In( aCellPos ) )
+                    pFound = pAction;       // the last wins
+                    switch ( eType )
                     {
-                        pFound = pAction;       // the last wins
-                        switch ( eType )
-                        {
-                            case SC_CAT_CONTENT :
-                                pFoundContent = pAction;
-                            break;
-                            case SC_CAT_MOVE :
-                                pFoundMove = pAction;
+                        case SC_CAT_CONTENT :
+                            pFoundContent = pAction;
+                        break;
+                        case SC_CAT_MOVE :
+                            pFoundMove = pAction;
+                        break;
+                        default:
                             break;
-                            default:
-                                break;
-                        }
                     }
                 }
-                if ( eType == SC_CAT_MOVE )
-                {
-                    ScRange aRange =
-                        static_cast<const ScChangeActionMove*>(pAction)->
-                        GetFromRange().MakeRange();
-                    if ( aRange.In( aCellPos ) )
-                    {
-                        pFound = pAction;
-                    }
-                }
-            }
-            pAction = pAction->GetNext();
-        }
-        if ( pFound )
-        {
-            if ( pFoundContent && pFound->GetType() != SC_CAT_CONTENT )
-                pFound = pFoundContent;     // Content wins
-            if ( pFoundMove && pFound->GetType() != SC_CAT_MOVE &&
-                    pFoundMove->GetActionNumber() >
-                    pFound->GetActionNumber() )
-                pFound = pFoundMove;        // Move wins
-            //  for deleted columns: arrow on left side of row
-            if ( pFound->GetType() == SC_CAT_DELETE_COLS )
-                bLeftEdge = true;
-            DateTime aDT = pFound->GetDateTime();
-            aTrackText  = pFound->GetUser();
-            aTrackText += ", ";
-            aTrackText += ScGlobal::getLocaleDataPtr()->getDate(aDT);
-            aTrackText += " ";
-            aTrackText += ScGlobal::getLocaleDataPtr()->getTime(aDT);
-            aTrackText += ":\n";
-            OUString aComStr = pFound->GetComment();
-            if(!aComStr.isEmpty())
-            {
-                aTrackText += aComStr;
-                aTrackText += "\n( ";
             }
-            pFound->GetDescription( aTrackText, this );
-            if (!aComStr.isEmpty())
+            if ( eType == SC_CAT_MOVE )
             {
-                aTrackText += ")";
+                ScRange aRange =
+                    static_cast<const ScChangeActionMove*>(pAction)->
+                    GetFromRange().MakeRange();
+                if ( aRange.In( aCellPos ) )
+                {
+                    pFound = pAction;
+                }
             }
         }
+        pAction = pAction->GetNext();
+    }
+    if ( !pFound )
+        return;
+
+    if ( pFoundContent && pFound->GetType() != SC_CAT_CONTENT )
+        pFound = pFoundContent;     // Content wins
+    if ( pFoundMove && pFound->GetType() != SC_CAT_MOVE &&
+            pFoundMove->GetActionNumber() >
+            pFound->GetActionNumber() )
+        pFound = pFoundMove;        // Move wins
+    //  for deleted columns: arrow on left side of row
+    if ( pFound->GetType() == SC_CAT_DELETE_COLS )
+        bLeftEdge = true;
+    DateTime aDT = pFound->GetDateTime();
+    aTrackText  = pFound->GetUser();
+    aTrackText += ", ";
+    aTrackText += ScGlobal::getLocaleDataPtr()->getDate(aDT);
+    aTrackText += " ";
+    aTrackText += ScGlobal::getLocaleDataPtr()->getTime(aDT);
+    aTrackText += ":\n";
+    OUString aComStr = pFound->GetComment();
+    if(!aComStr.isEmpty())
+    {
+        aTrackText += aComStr;
+        aTrackText += "\n( ";
+    }
+    pFound->GetDescription( aTrackText, this );
+    if (!aComStr.isEmpty())
+    {
+        aTrackText += ")";
     }
 }
 
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index 9c4ae4601948..ae51c8d22b5c 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -788,45 +788,45 @@ void ScDocument::CopyUpdated( ScDocument* pPosDoc, ScDocument* pDestDoc )
 
 void ScDocument::CopyScenario( SCTAB nSrcTab, SCTAB nDestTab, bool bNewScenario )
 {
-    if (ValidTab(nSrcTab) && ValidTab(nDestTab) && nSrcTab < static_cast<SCTAB>(maTabs.size())
-                && nDestTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nSrcTab] && maTabs[nDestTab])
+    if (!(ValidTab(nSrcTab) && ValidTab(nDestTab) && nSrcTab < static_cast<SCTAB>(maTabs.size())
+                && nDestTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nSrcTab] && maTabs[nDestTab]))
+        return;
+
+    // Set flags correctly for active scenarios
+    // and write current values back to recently active scenarios
+    ScRangeList aRanges = *maTabs[nSrcTab]->GetScenarioRanges();
+
+    // nDestTab is the target table
+    for ( SCTAB nTab = nDestTab+1;
+            nTab< static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] && maTabs[nTab]->IsScenario();
+            nTab++ )
     {
-        // Set flags correctly for active scenarios
-        // and write current values back to recently active scenarios
-        ScRangeList aRanges = *maTabs[nSrcTab]->GetScenarioRanges();
-
-        // nDestTab is the target table
-        for ( SCTAB nTab = nDestTab+1;
-                nTab< static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] && maTabs[nTab]->IsScenario();
-                nTab++ )
+        if ( maTabs[nTab]->IsActiveScenario() ) // Even if it's the same scenario
         {
-            if ( maTabs[nTab]->IsActiveScenario() ) // Even if it's the same scenario
+            bool bTouched = false;
+            for ( size_t nR=0, nRangeCount = aRanges.size(); nR < nRangeCount && !bTouched; nR++ )
             {
-                bool bTouched = false;
-                for ( size_t nR=0, nRangeCount = aRanges.size(); nR < nRangeCount && !bTouched; nR++ )
-                {
-                    const ScRange& rRange = aRanges[ nR ];
-                    if ( maTabs[nTab]->HasScenarioRange( rRange ) )
-                        bTouched = true;
-                }
-                if (bTouched)
-                {
-                    maTabs[nTab]->SetActiveScenario(false);
-                    if ( maTabs[nTab]->GetScenarioFlags() & ScScenarioFlags::TwoWay )
-                        maTabs[nTab]->CopyScenarioFrom( maTabs[nDestTab].get() );
-                }
+                const ScRange& rRange = aRanges[ nR ];
+                if ( maTabs[nTab]->HasScenarioRange( rRange ) )
+                    bTouched = true;
+            }
+            if (bTouched)
+            {
+                maTabs[nTab]->SetActiveScenario(false);
+                if ( maTabs[nTab]->GetScenarioFlags() & ScScenarioFlags::TwoWay )
+                    maTabs[nTab]->CopyScenarioFrom( maTabs[nDestTab].get() );
             }
         }
+    }
 
-        maTabs[nSrcTab]->SetActiveScenario(true); // This is where it's from ...
-        if (!bNewScenario) // Copy data from the selected scenario
-        {
-            sc::AutoCalcSwitch aACSwitch(*this, false);
-            maTabs[nSrcTab]->CopyScenarioTo( maTabs[nDestTab].get() );
+    maTabs[nSrcTab]->SetActiveScenario(true); // This is where it's from ...
+    if (!bNewScenario) // Copy data from the selected scenario
+    {
+        sc::AutoCalcSwitch aACSwitch(*this, false);
+        maTabs[nSrcTab]->CopyScenarioTo( maTabs[nDestTab].get() );
 
-            sc::SetFormulaDirtyContext aCxt;
-            SetAllFormulasDirty(aCxt);
-        }
+        sc::SetFormulaDirtyContext aCxt;
+        SetAllFormulasDirty(aCxt);
     }
 }
 
@@ -929,29 +929,29 @@ void ScDocument::RemoveUnoObject( SfxListener& rObject )
 
 void ScDocument::BroadcastUno( const SfxHint &rHint )
 {
-    if (pUnoBroadcaster)
-    {
-        bInUnoBroadcast = true;
-        pUnoBroadcaster->Broadcast( rHint );
-        bInUnoBroadcast = false;
+    if (!pUnoBroadcaster)
+        return;
 
-        // During Broadcast notification, Uno objects can add to pUnoListenerCalls.
-        // The listener calls must be processed after completing the broadcast,
-        // because they can add or remove objects from pUnoBroadcaster.
+    bInUnoBroadcast = true;
+    pUnoBroadcaster->Broadcast( rHint );
+    bInUnoBroadcast = false;
 
-        if ( pUnoListenerCalls &&
-                rHint.GetId() == SfxHintId::DataChanged &&
-                !bInUnoListenerCall )
-        {
-            // Listener calls may lead to BroadcastUno calls again. The listener calls
-            // are not nested, instead the calls are collected in the list, and the
-            // outermost call executes them all.
-
-            ScChartLockGuard aChartLockGuard(this);
-            bInUnoListenerCall = true;
-            pUnoListenerCalls->ExecuteAndClear();
-            bInUnoListenerCall = false;
-        }
+    // During Broadcast notification, Uno objects can add to pUnoListenerCalls.
+    // The listener calls must be processed after completing the broadcast,
+    // because they can add or remove objects from pUnoBroadcaster.
+
+    if ( pUnoListenerCalls &&
+            rHint.GetId() == SfxHintId::DataChanged &&
+            !bInUnoListenerCall )
+    {
+        // Listener calls may lead to BroadcastUno calls again. The listener calls
+        // are not nested, instead the calls are collected in the list, and the
+        // outermost call executes them all.
+
+        ScChartLockGuard aChartLockGuard(this);
+        bInUnoListenerCall = true;
+        pUnoListenerCalls->ExecuteAndClear();
+        bInUnoListenerCall = false;
     }
 }
 
@@ -1516,50 +1516,50 @@ void ScDocument::GetFilterSelCount( SCCOL nCol, SCROW nRow, SCTAB nTab, SCSIZE&
 void ScDocument::GetFilterEntries(
     SCCOL nCol, SCROW nRow, SCTAB nTab, ScFilterEntries& rFilterEntries )
 {
-    if ( ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] && pDBCollection )
-    {
-        ScDBData* pDBData = pDBCollection->GetDBAtCursor(nCol, nRow, nTab, ScDBDataPortion::AREA);  //!??
-        if (pDBData)
-        {
-            pDBData->ExtendDataArea(this);
-            SCTAB nAreaTab;
-            SCCOL nStartCol;
-            SCROW nStartRow;
-            SCCOL nEndCol;
-            SCROW nEndRow;
-            pDBData->GetArea( nAreaTab, nStartCol, nStartRow, nEndCol, nEndRow );
+    if ( !(ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] && pDBCollection) )
+        return;
 
-            if (pDBData->HasHeader())
-                ++nStartRow;
+    ScDBData* pDBData = pDBCollection->GetDBAtCursor(nCol, nRow, nTab, ScDBDataPortion::AREA);  //!??
+    if (!pDBData)
+        return;
 
-            ScQueryParam aParam;
-            pDBData->GetQueryParam( aParam );
+    pDBData->ExtendDataArea(this);
+    SCTAB nAreaTab;
+    SCCOL nStartCol;
+    SCROW nStartRow;
+    SCCOL nEndCol;
+    SCROW nEndRow;
+    pDBData->GetArea( nAreaTab, nStartCol, nStartRow, nEndCol, nEndRow );
 
-            // Return all filter entries, if a filter condition is connected with a boolean OR
-            bool bFilter = true;
-            SCSIZE nEntryCount = aParam.GetEntryCount();
-            for ( SCSIZE i = 0; i < nEntryCount && aParam.GetEntry(i).bDoQuery; ++i )
-            {
-                ScQueryEntry& rEntry = aParam.GetEntry(i);
-                if ( rEntry.eConnect != SC_AND )
-                {
-                    bFilter = false;
-                    break;
-                }
-            }
+    if (pDBData->HasHeader())
+        ++nStartRow;
 
-            if ( bFilter )
-            {
-                maTabs[nTab]->GetFilteredFilterEntries( nCol, nStartRow, nEndRow, aParam, rFilterEntries );
-            }
-            else
-            {
-                maTabs[nTab]->GetFilterEntries( nCol, nStartRow, nEndRow, rFilterEntries );
-            }
+    ScQueryParam aParam;
+    pDBData->GetQueryParam( aParam );
 
-            sortAndRemoveDuplicates( rFilterEntries.maStrData, aParam.bCaseSens);
+    // Return all filter entries, if a filter condition is connected with a boolean OR
+    bool bFilter = true;
+    SCSIZE nEntryCount = aParam.GetEntryCount();
+    for ( SCSIZE i = 0; i < nEntryCount && aParam.GetEntry(i).bDoQuery; ++i )
+    {
+        ScQueryEntry& rEntry = aParam.GetEntry(i);
+        if ( rEntry.eConnect != SC_AND )
+        {
+            bFilter = false;
+            break;
         }
     }
+
+    if ( bFilter )
+    {
+        maTabs[nTab]->GetFilteredFilterEntries( nCol, nStartRow, nEndRow, aParam, rFilterEntries );
+    }
+    else
+    {
+        maTabs[nTab]->GetFilterEntries( nCol, nStartRow, nEndRow, rFilterEntries );
+    }
+
+    sortAndRemoveDuplicates( rFilterEntries.maStrData, aParam.bCaseSens);
 }
 
 /**
diff --git a/sc/source/core/data/documen5.cxx b/sc/source/core/data/documen5.cxx
index 631f60c863fa..598643b7f473 100644
--- a/sc/source/core/data/documen5.cxx
+++ b/sc/source/core/data/documen5.cxx
@@ -53,23 +53,23 @@ static void lcl_GetChartParameters( const uno::Reference< chart2::XChartDocument
     uno::Reference< chart2::data::XDataSource > xDataSource = xReceiver->getUsedData();
     uno::Reference< chart2::data::XDataProvider > xProvider = xChartDoc->getDataProvider();
 
-    if ( xProvider.is() )
-    {
-        const uno::Sequence< beans::PropertyValue > aArgs( xProvider->detectArguments( xDataSource ) );
+    if ( !xProvider.is() )
+        return;
 
-        for (const beans::PropertyValue& rProp : aArgs)
-        {
-            OUString aPropName(rProp.Name);
-
-            if ( aPropName == "CellRangeRepresentation" )
-                rProp.Value >>= rRanges;
-            else if ( aPropName == "DataRowSource" )
-                rDataRowSource = static_cast<chart::ChartDataRowSource>(ScUnoHelpFunctions::GetEnumFromAny( rProp.Value ));
-            else if ( aPropName == "HasCategories" )
-                rHasCategories = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
-            else if ( aPropName == "FirstCellAsLabel" )
-                rFirstCellAsLabel = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
-        }
+    const uno::Sequence< beans::PropertyValue > aArgs( xProvider->detectArguments( xDataSource ) );
+
+    for (const beans::PropertyValue& rProp : aArgs)
+    {
+        OUString aPropName(rProp.Name);
+
+        if ( aPropName == "CellRangeRepresentation" )
+            rProp.Value >>= rRanges;
+        else if ( aPropName == "DataRowSource" )
+            rDataRowSource = static_cast<chart::ChartDataRowSource>(ScUnoHelpFunctions::GetEnumFromAny( rProp.Value ));
+        else if ( aPropName == "HasCategories" )
+            rHasCategories = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
+        else if ( aPropName == "FirstCellAsLabel" )
+            rFirstCellAsLabel = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
     }
 }
 
@@ -77,23 +77,23 @@ static void lcl_SetChartParameters( const uno::Reference< chart2::data::XDataRec
             const OUString& rRanges, chart::ChartDataRowSource eDataRowSource,
             bool bHasCategories, bool bFirstCellAsLabel )
 {
-    if ( xReceiver.is() )
-    {
-        uno::Sequence< beans::PropertyValue > aArgs( 4 );
-        aArgs[0] = beans::PropertyValue(
-            "CellRangeRepresentation", -1,
-            uno::makeAny( rRanges ), beans::PropertyState_DIRECT_VALUE );
-        aArgs[1] = beans::PropertyValue(
-            "HasCategories", -1,
-            uno::makeAny( bHasCategories ), beans::PropertyState_DIRECT_VALUE );
-        aArgs[2] = beans::PropertyValue(
-            "FirstCellAsLabel", -1,
-            uno::makeAny( bFirstCellAsLabel ), beans::PropertyState_DIRECT_VALUE );
-        aArgs[3] = beans::PropertyValue(
-            "DataRowSource", -1,
-            uno::makeAny( eDataRowSource ), beans::PropertyState_DIRECT_VALUE );
-        xReceiver->setArguments( aArgs );
-    }
+    if ( !xReceiver.is() )
+        return;
+
+    uno::Sequence< beans::PropertyValue > aArgs( 4 );
+    aArgs[0] = beans::PropertyValue(
+        "CellRangeRepresentation", -1,
+        uno::makeAny( rRanges ), beans::PropertyState_DIRECT_VALUE );
+    aArgs[1] = beans::PropertyValue(
+        "HasCategories", -1,
+        uno::makeAny( bHasCategories ), beans::PropertyState_DIRECT_VALUE );
+    aArgs[2] = beans::PropertyValue(
+        "FirstCellAsLabel", -1,
+        uno::makeAny( bFirstCellAsLabel ), beans::PropertyState_DIRECT_VALUE );
+    aArgs[3] = beans::PropertyValue(
+        "DataRowSource", -1,
+        uno::makeAny( eDataRowSource ), beans::PropertyState_DIRECT_VALUE );
+    xReceiver->setArguments( aArgs );
 }
 
 bool ScDocument::HasChartAtPoint( SCTAB nTab, const Point& rPos, OUString& rName )
@@ -183,19 +183,19 @@ void ScDocument::GetChartRanges( const OUString& rChartName, ::std::vector< ScRa
 void ScDocument::SetChartRanges( const OUString& rChartName, const ::std::vector< ScRangeList >& rRangesVector )
 {
     uno::Reference< chart2::XChartDocument > xChartDoc( GetChartByName( rChartName ) );
-    if ( xChartDoc.is() )
+    if ( !xChartDoc.is() )
+        return;
+
+    sal_Int32 nCount = static_cast<sal_Int32>( rRangesVector.size() );
+    uno::Sequence< OUString > aRangeStrings(nCount);
+    for( sal_Int32 nN=0; nN<nCount; nN++ )
     {
-        sal_Int32 nCount = static_cast<sal_Int32>( rRangesVector.size() );
-        uno::Sequence< OUString > aRangeStrings(nCount);
-        for( sal_Int32 nN=0; nN<nCount; nN++ )
-        {
-            ScRangeList aScRangeList( rRangesVector[nN] );
-            OUString sRangeStr;
-            aScRangeList.Format( sRangeStr, ScRefFlags::RANGE_ABS_3D, *this, GetAddressConvention() );
-            aRangeStrings[nN]=sRangeStr;
-        }
-        ScChartHelper::SetChartRanges( xChartDoc, aRangeStrings );
+        ScRangeList aScRangeList( rRangesVector[nN] );
+        OUString sRangeStr;
+        aScRangeList.Format( sRangeStr, ScRefFlags::RANGE_ABS_3D, *this, GetAddressConvention() );
+        aRangeStrings[nN]=sRangeStr;
     }
+    ScChartHelper::SetChartRanges( xChartDoc, aRangeStrings );
 }
 
 void ScDocument::GetOldChartParameters( const OUString& rName,
@@ -365,26 +365,26 @@ void ScDocument::RestoreChartListener( const OUString& rName )
     // (called when a chart is saved, because then it might be swapped out and stop listening itself).
 
     uno::Reference< embed::XEmbeddedObject > xObject = FindOleObjectByName( rName );
-    if ( xObject.is() )
-    {
-        uno::Reference< util::XCloseable > xComponent = xObject->getComponent();
-        uno::Reference< chart2::XChartDocument > xChartDoc( xComponent, uno::UNO_QUERY );
-        uno::Reference< chart2::data::XDataReceiver > xReceiver( xComponent, uno::UNO_QUERY );
-        if ( xChartDoc.is() && xReceiver.is() && !xChartDoc->hasInternalDataProvider())
-        {
-            const uno::Sequence<OUString> aRepresentations( xReceiver->getUsedRangeRepresentations() );
-            ScRangeListRef aRanges = new ScRangeList;
-            for ( const auto& rRepresentation : aRepresentations )
-            {
-                ScRange aRange;
-                ScAddress::Details aDetails(GetAddressConvention(), 0, 0);
-                if ( aRange.ParseAny( rRepresentation, this, aDetails ) & ScRefFlags::VALID )
-                    aRanges->push_back( aRange );
-            }
+    if ( !xObject.is() )
+        return;
 
-            pChartListenerCollection->ChangeListening( rName, aRanges );
-        }
+    uno::Reference< util::XCloseable > xComponent = xObject->getComponent();
+    uno::Reference< chart2::XChartDocument > xChartDoc( xComponent, uno::UNO_QUERY );
+    uno::Reference< chart2::data::XDataReceiver > xReceiver( xComponent, uno::UNO_QUERY );
+    if ( !(xChartDoc.is() && xReceiver.is() && !xChartDoc->hasInternalDataProvider()))
+        return;
+
+    const uno::Sequence<OUString> aRepresentations( xReceiver->getUsedRangeRepresentations() );
+    ScRangeListRef aRanges = new ScRangeList;
+    for ( const auto& rRepresentation : aRepresentations )
+    {
+        ScRange aRange;
+        ScAddress::Details aDetails(GetAddressConvention(), 0, 0);
+        if ( aRange.ParseAny( rRepresentation, this, aDetails ) & ScRefFlags::VALID )
+            aRanges->push_back( aRange );
     }
+
+    pChartListenerCollection->ChangeListening( rName, aRanges );
 }
 
 void ScDocument::UpdateChartRef( UpdateRefMode eUpdateRefMode,
diff --git a/sc/source/core/data/documen7.cxx b/sc/source/core/data/documen7.cxx
index 1cd90e5a74ae..a950e903f121 100644
--- a/sc/source/core/data/documen7.cxx
+++ b/sc/source/core/data/documen7.cxx
@@ -470,32 +470,32 @@ void ScDocument::RemoveFromFormulaTrack( ScFormulaCell* pCell )
     ScFormulaCell* pPrev = pCell->GetPreviousTrack();
     assert(pPrev != pCell);                     // pointing to itself?!?
     // if the cell is first or somewhere in chain
-    if ( pPrev || pFormulaTrack == pCell )
+    if ( !(pPrev || pFormulaTrack == pCell) )
+        return;
+
+    ScFormulaCell* pNext = pCell->GetNextTrack();
+    assert(pNext != pCell);                 // pointing to itself?!?
+    if ( pPrev )
     {
-        ScFormulaCell* pNext = pCell->GetNextTrack();
-        assert(pNext != pCell);                 // pointing to itself?!?
-        if ( pPrev )
-        {
-            assert(pFormulaTrack != pCell);     // if this cell is also head something's wrong
-            pPrev->SetNextTrack( pNext );       // predecessor exists, set successor
-        }
-        else
-        {
-            pFormulaTrack = pNext;              // this cell was first cell
-        }
-        if ( pNext )
-        {
-            assert(pEOFormulaTrack != pCell);   // if this cell is also tail something's wrong
-            pNext->SetPreviousTrack( pPrev );   // successor exists, set predecessor
-        }
-        else
-        {
-            pEOFormulaTrack = pPrev;            // this cell was last cell
-        }
-        pCell->SetPreviousTrack( nullptr );
-        pCell->SetNextTrack( nullptr );
-        --nFormulaTrackCount;
+        assert(pFormulaTrack != pCell);     // if this cell is also head something's wrong
+        pPrev->SetNextTrack( pNext );       // predecessor exists, set successor
+    }
+    else
+    {
+        pFormulaTrack = pNext;              // this cell was first cell
     }
+    if ( pNext )
+    {
+        assert(pEOFormulaTrack != pCell);   // if this cell is also tail something's wrong
+        pNext->SetPreviousTrack( pPrev );   // successor exists, set predecessor
+    }
+    else
+    {
+        pEOFormulaTrack = pPrev;            // this cell was last cell
+    }
+    pCell->SetPreviousTrack( nullptr );
+    pCell->SetNextTrack( nullptr );
+    --nFormulaTrackCount;
 }
 
 bool ScDocument::IsInFormulaTrack( const ScFormulaCell* pCell ) const
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index 312df8333f3b..9a6c090e413e 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -162,20 +162,20 @@ void ScDocument::SetPrintOptions()
     if ( !mpPrinter ) GetPrinter(); // this sets mpPrinter
     OSL_ENSURE( mpPrinter, "Error in printer creation :-/" );
 
-    if ( mpPrinter )
-    {
-        SfxItemSet aOptSet( mpPrinter->GetOptions() );
+    if ( !mpPrinter )
+        return;
 
-        SfxPrinterChangeFlags nFlags = SfxPrinterChangeFlags::NONE;
-        if (officecfg::Office::Common::Print::Warning::PaperOrientation::get())
-            nFlags |= SfxPrinterChangeFlags::CHG_ORIENTATION;
-        if (officecfg::Office::Common::Print::Warning::PaperSize::get())
-            nFlags |= SfxPrinterChangeFlags::CHG_SIZE;
-        aOptSet.Put( SfxFlagItem( SID_PRINTER_CHANGESTODOC, static_cast<int>(nFlags) ) );
-        aOptSet.Put( SfxBoolItem( SID_PRINTER_NOTFOUND_WARN, officecfg::Office::Common::Print::Warning::NotFound::get() ) );
+    SfxItemSet aOptSet( mpPrinter->GetOptions() );
 
-        mpPrinter->SetOptions( aOptSet );
-    }
+    SfxPrinterChangeFlags nFlags = SfxPrinterChangeFlags::NONE;
+    if (officecfg::Office::Common::Print::Warning::PaperOrientation::get())
+        nFlags |= SfxPrinterChangeFlags::CHG_ORIENTATION;
+    if (officecfg::Office::Common::Print::Warning::PaperSize::get())
+        nFlags |= SfxPrinterChangeFlags::CHG_SIZE;
+    aOptSet.Put( SfxFlagItem( SID_PRINTER_CHANGESTODOC, static_cast<int>(nFlags) ) );
+    aOptSet.Put( SfxBoolItem( SID_PRINTER_NOTFOUND_WARN, officecfg::Office::Common::Print::Warning::NotFound::get() ) );
+
+    mpPrinter->SetOptions( aOptSet );
 }
 
 VirtualDevice* ScDocument::GetVirtualDevice_100th_mm()
@@ -842,21 +842,21 @@ void ScDocument::UpdateExternalRefLinks(weld::Window* pWin)
 
     pExternalRefMgr->enableDocTimer(true);
 
-    if (bAny)
-    {
-        TrackFormulas();
-        mpShell->Broadcast( SfxHint(SfxHintId::ScDataChanged) );
+    if (!bAny)
+        return;
 
-        // #i101960# set document modified, as in TrackTimeHdl for DDE links
-        if (!mpShell->IsModified())
+    TrackFormulas();
+    mpShell->Broadcast( SfxHint(SfxHintId::ScDataChanged) );
+
+    // #i101960# set document modified, as in TrackTimeHdl for DDE links
+    if (!mpShell->IsModified())
+    {
+        mpShell->SetModified();
+        SfxBindings* pBindings = GetViewBindings();
+        if (pBindings)
         {
-            mpShell->SetModified();
-            SfxBindings* pBindings = GetViewBindings();
-            if (pBindings)
-            {
-                pBindings->Invalidate( SID_SAVEDOC );
-                pBindings->Invalidate( SID_DOC_MODIFIED );
-            }
+            pBindings->Invalidate( SID_SAVEDOC );
+            pBindings->Invalidate( SID_DOC_MODIFIED );
         }
     }
 }
@@ -1116,36 +1116,36 @@ void ScDocument::UpdateRefAreaLinks( UpdateRefMode eUpdateRefMode,
         }
     }
 
-    if ( bAnyUpdate )
-    {
-        // #i52120# Look for duplicates (after updating all positions).
-        // If several links start at the same cell, the one with the lower index is removed
-        // (file format specifies only one link definition for a cell).
+    if ( !bAnyUpdate )
+        return;
 
-        sal_uInt16 nFirstIndex = 0;
-        while ( nFirstIndex < nCount )
+    // #i52120# Look for duplicates (after updating all positions).
+    // If several links start at the same cell, the one with the lower index is removed
+    // (file format specifies only one link definition for a cell).
+
+    sal_uInt16 nFirstIndex = 0;
+    while ( nFirstIndex < nCount )
+    {
+        bool bFound = false;
+        ::sfx2::SvBaseLink* pFirst = rLinks[nFirstIndex].get();
+        if (ScAreaLink* pFirstLink = dynamic_cast<ScAreaLink*>(pFirst))
         {
-            bool bFound = false;
-            ::sfx2::SvBaseLink* pFirst = rLinks[nFirstIndex].get();
-            if (ScAreaLink* pFirstLink = dynamic_cast<ScAreaLink*>(pFirst))
+            ScAddress aFirstPos = pFirstLink->GetDestArea().aStart;
+            for ( sal_uInt16 nSecondIndex = nFirstIndex + 1; nSecondIndex < nCount && !bFound; ++nSecondIndex )
             {
-                ScAddress aFirstPos = pFirstLink->GetDestArea().aStart;
-                for ( sal_uInt16 nSecondIndex = nFirstIndex + 1; nSecondIndex < nCount && !bFound; ++nSecondIndex )
+                ::sfx2::SvBaseLink* pSecond = rLinks[nSecondIndex].get();

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list