sc/inc/chgtrack.hxx              |   28 ++------------------
 sc/inc/detfunc.hxx               |    4 +-
 sc/source/core/tool/chgtrack.cxx |   53 ++++++++++++---------------------------
 sc/source/core/tool/detfunc.cxx  |   22 ++++++++--------
 4 files changed, 33 insertions(+), 74 deletions(-)

New commits:
commit d5f9675c2dba0c2e8993078946ee669e1d61b086
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Mon Aug 13 09:55:51 2018 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Aug 15 08:37:15 2018 +0200

    loplugin:returnconstant in ScDetectiveFunc
    
    Change-Id: Id6eef7772b32a93d43d0417c5b6e24d9189c4e73
    Reviewed-on: https://gerrit.libreoffice.org/58955
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sc/inc/detfunc.hxx b/sc/inc/detfunc.hxx
index a91871560445..e0afe1ce8eb0 100644
--- a/sc/inc/detfunc.hxx
+++ b/sc/inc/detfunc.hxx
@@ -80,12 +80,12 @@ class SC_DLLPUBLIC ScDetectiveFunc
     bool        HasError( const ScRange& rRange, ScAddress& rErrPos );
 
                 /// called from DrawEntry/DrawAlienEntry and InsertObject
-    bool        InsertArrow( SCCOL nCol, SCROW nRow,
+    void        InsertArrow( SCCOL nCol, SCROW nRow,
                                 SCCOL nRefStartCol, SCROW nRefStartRow,
                                 SCCOL nRefEndCol, SCROW nRefEndRow,
                                 bool bFromOtherTab, bool bRed,
                                 ScDetectiveData& rData );
-    bool        InsertToOtherTab( SCCOL nStartCol, SCROW nStartRow,
+    void        InsertToOtherTab( SCCOL nStartCol, SCROW nStartRow,
                                 SCCOL nEndCol, SCROW nEndRow, bool bRed,
                                 ScDetectiveData& rData );
 
diff --git a/sc/source/core/tool/detfunc.cxx b/sc/source/core/tool/detfunc.cxx
index a356ee396c09..c45e0e4a13ab 100644
--- a/sc/source/core/tool/detfunc.cxx
+++ b/sc/source/core/tool/detfunc.cxx
@@ -438,7 +438,7 @@ bool ScDetectiveFunc::IsNonAlienArrow( const SdrObject* 
pObject )
 
 //  InsertXXX: called from DrawEntry/DrawAlienEntry and InsertObject
 
-bool ScDetectiveFunc::InsertArrow( SCCOL nCol, SCROW nRow,
+void ScDetectiveFunc::InsertArrow( SCCOL nCol, SCROW nRow,
                                 SCCOL nRefStartCol, SCROW nRefStartRow,
                                 SCCOL nRefEndCol, SCROW nRefEndRow,
                                 bool bFromOtherTab, bool bRed,
@@ -517,10 +517,9 @@ bool ScDetectiveFunc::InsertArrow( SCCOL nCol, SCROW nRow,
     pData->meType = ScDrawObjData::DetectiveArrow;
 
     Modified();
-    return true;
 }
 
-bool ScDetectiveFunc::InsertToOtherTab( SCCOL nStartCol, SCROW nStartRow,
+void ScDetectiveFunc::InsertToOtherTab( SCCOL nStartCol, SCROW nStartRow,
                                 SCCOL nEndCol, SCROW nEndRow, bool bRed,
                                 ScDetectiveData& rData )
 {
@@ -583,7 +582,6 @@ bool ScDetectiveFunc::InsertToOtherTab( SCCOL nStartCol, 
SCROW nStartRow,
     pData->maEnd.SetInvalid();
 
     Modified();
-    return true;
 }
 
 //  DrawEntry:      formula from this spreadsheet,
@@ -604,10 +602,11 @@ bool ScDetectiveFunc::DrawEntry( SCCOL nCol, SCROW nRow,
     bool bError = HasError( rRef, aErrorPos );
     bool bAlien = ( rRef.aEnd.Tab() < nTab || rRef.aStart.Tab() > nTab );
 
-    return InsertArrow( nCol, nRow,
-                        rRef.aStart.Col(), rRef.aStart.Row(),
-                        rRef.aEnd.Col(), rRef.aEnd.Row(),
-                        bAlien, bError, rData );
+    InsertArrow( nCol, nRow,
+                 rRef.aStart.Col(), rRef.aStart.Row(),
+                 rRef.aEnd.Col(), rRef.aEnd.Row(),
+                 bAlien, bError, rData );
+    return true;
 }
 
 bool ScDetectiveFunc::DrawAlienEntry( const ScRange& rRef,
@@ -619,9 +618,10 @@ bool ScDetectiveFunc::DrawAlienEntry( const ScRange& rRef,
     ScAddress aErrorPos;
     bool bError = HasError( rRef, aErrorPos );
 
-    return InsertToOtherTab( rRef.aStart.Col(), rRef.aStart.Row(),
-                                rRef.aEnd.Col(), rRef.aEnd.Row(),
-                                bError, rData );
+    InsertToOtherTab( rRef.aStart.Col(), rRef.aStart.Row(),
+                      rRef.aEnd.Col(), rRef.aEnd.Row(),
+                      bError, rData );
+    return true;
 }
 
 void ScDetectiveFunc::DrawCircle( SCCOL nCol, SCROW nRow, ScDetectiveData& 
rData )
commit 619a6fc90d9682d859e43e5297d32a0f98738c0f
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Aug 14 15:47:41 2018 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Aug 15 08:37:04 2018 +0200

    convert ScChangeActionCellListEntry to std::vector
    
    no need for a linked list where each cell contains a single pointer
    
    Change-Id: I5353b178ddf3c6a69762edc23612995efd81fb41
    Reviewed-on: https://gerrit.libreoffice.org/58987
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sc/inc/chgtrack.hxx b/sc/inc/chgtrack.hxx
index ef7a237645c2..9f554ff9c347 100644
--- a/sc/inc/chgtrack.hxx
+++ b/sc/inc/chgtrack.hxx
@@ -174,27 +174,6 @@ public:
 // this is only for the XML Export in the hxx
 class ScChangeActionContent;
 
-class ScChangeActionCellListEntry
-{
-    friend class ScChangeAction;
-    friend class ScChangeActionDel;
-    friend class ScChangeActionMove;
-    friend class ScChangeTrack;
-
-    ScChangeActionCellListEntry*    pNext;
-    ScChangeActionContent*          pContent;
-
-    ScChangeActionCellListEntry(
-        ScChangeActionContent* pContentP,
-        ScChangeActionCellListEntry* pNextP )
-        :   pNext( pNextP ),
-            pContent( pContentP )
-        {}
-
-public:
-    DECL_FIXEDMEMPOOL_NEWDEL( ScChangeActionCellListEntry )
-};
-
 class ScChangeAction
 {
     friend class ScChangeTrack;
@@ -453,7 +432,7 @@ class ScChangeActionDel : public ScChangeAction
     friend void ScChangeAction::Accept();
 
     ScChangeTrack*      pTrack;
-    ScChangeActionCellListEntry* pFirstCell;
+    std::vector<ScChangeActionContent*> mvCells;
     ScChangeActionIns*  pCutOff;        // cut insert
     short               nCutOff;        // +: start  -: end
     ScChangeActionDelMoveEntry* pLinkMove;
@@ -528,7 +507,7 @@ class ScChangeActionMove : public ScChangeAction
 
     ScBigRange          aFromRange;
     ScChangeTrack*      pTrack;
-    ScChangeActionCellListEntry* pFirstCell;
+    std::vector<ScChangeActionContent*> mvCells;
     sal_uLong               nStartLastCut;  // for PasteCut undo
     sal_uLong               nEndLastCut;
 
@@ -538,7 +517,6 @@ class ScChangeActionMove : public ScChangeAction
         : ScChangeAction( SC_CAT_MOVE, rToRange ),
             aFromRange( rFromRange ),
             pTrack( pTrackP ),
-            pFirstCell( nullptr ),
             nStartLastCut(0),
             nEndLastCut(0)
         {}
@@ -957,7 +935,7 @@ class ScChangeTrack : public utl::ConfigurationListener
         const ScAddress& rPos, const ScCellValue& rCell, const ScDocument* 
pFromDoc );
 
     void                DeleteCellEntries(
-                                    ScChangeActionCellListEntry*&,
+                                    std::vector<ScChangeActionContent*>&,
                                     const ScChangeAction* pDeletor );
 
                                 // Reject action and all dependent actions,
diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx
index 77f09a9105a5..bd22f2a5381d 100644
--- a/sc/source/core/tool/chgtrack.cxx
+++ b/sc/source/core/tool/chgtrack.cxx
@@ -50,7 +50,6 @@
 #include <memory>
 #include <boost/property_tree/json_parser.hpp>
 
-IMPL_FIXEDMEMPOOL_NEWDEL( ScChangeActionCellListEntry )
 IMPL_FIXEDMEMPOOL_NEWDEL( ScChangeActionLinkEntry )
 
 ScChangeAction::ScChangeAction( ScChangeActionType eTypeP, const ScRange& 
rRange )
@@ -602,15 +601,13 @@ void ScChangeAction::RejectRestoreContents( 
ScChangeTrack* pTrack,
         SCCOL nDx, SCROW nDy )
 {
     // Construct list of Contents
-    ScChangeActionCellListEntry* pListContents = nullptr;
+    std::vector<ScChangeActionContent*> aContentsList;
     for ( ScChangeActionLinkEntry* pL = pLinkDeleted; pL; pL = pL->GetNext() )
     {
         ScChangeAction* p = pL->GetAction();
         if ( p && p->GetType() == SC_CAT_CONTENT )
         {
-            ScChangeActionCellListEntry* pE = new ScChangeActionCellListEntry(
-                static_cast<ScChangeActionContent*>(p), pListContents );
-            pListContents = pE;
+            aContentsList.push_back(static_cast<ScChangeActionContent*>(p) );
         }
     }
     SetState( SC_CAS_REJECTED ); // Before UpdateReference for Move
@@ -619,16 +616,11 @@ void ScChangeAction::RejectRestoreContents( 
ScChangeTrack* pTrack,
 
     // Work through list of Contents and delete
     ScDocument* pDoc = pTrack->GetDocument();
-    ScChangeActionCellListEntry* pE = pListContents;
-    while ( pE )
+    for (ScChangeActionContent* pContent : aContentsList)
     {
-        if ( !pE->pContent->IsDeletedIn() &&
-                pE->pContent->GetBigRange().aStart.IsValid( pDoc ) )
-            pE->pContent->PutNewValueToDoc( pDoc, nDx, nDy );
-        ScChangeActionCellListEntry* pNextEntry;
-        pNextEntry = pE->pNext;
-        delete pE;
-        pE = pNextEntry;
+        if ( !pContent->IsDeletedIn() &&
+                pContent->GetBigRange().aStart.IsValid( pDoc ) )
+            pContent->PutNewValueToDoc( pDoc, nDx, nDy );
     }
     DeleteCellEntries(); // Remove generated ones
 }
@@ -782,7 +774,6 @@ ScChangeActionDel::ScChangeActionDel( const ScRange& rRange,
         :
         ScChangeAction( SC_CAT_NONE, rRange ),
         pTrack( pTrackP ),
-        pFirstCell( nullptr ),
         pCutOff( nullptr ),
         nCutOff( 0 ),
         pLinkMove( nullptr ),
@@ -821,7 +812,6 @@ ScChangeActionDel::ScChangeActionDel(
     const ScChangeActionType eTypeP, const SCCOLROW nD, ScChangeTrack* 
pTrackP) : // which of nDx and nDy is set depends on the type
     ScChangeAction(eTypeP, aBigRangeP, nActionNumber, nRejectingNumber, 
eStateP, aDateTimeP, aUserP, sComment),
     pTrack( pTrackP ),
-    pFirstCell( nullptr ),
     pCutOff( nullptr ),
     nCutOff( 0 ),
     pLinkMove( nullptr ),
@@ -846,14 +836,12 @@ ScChangeActionDel::~ScChangeActionDel()
 
 void ScChangeActionDel::AddContent( ScChangeActionContent* pContent )
 {
-    ScChangeActionCellListEntry* pE = new ScChangeActionCellListEntry(
-        pContent, pFirstCell );
-    pFirstCell = pE;
+    mvCells.push_back(pContent);
 }
 
 void ScChangeActionDel::DeleteCellEntries()
 {
-    pTrack->DeleteCellEntries( pFirstCell, this );
+    pTrack->DeleteCellEntries( mvCells, this );
 }
 
 bool ScChangeActionDel::IsBaseDelete() const
@@ -1154,7 +1142,6 @@ ScChangeActionMove::ScChangeActionMove(
     ScChangeAction(SC_CAT_MOVE, aToBigRange, nActionNumber, nRejectingNumber, 
eStateP, aDateTimeP, aUserP, sComment),
     aFromRange(aFromBigRange),
     pTrack( pTrackP ),
-    pFirstCell( nullptr ),
     nStartLastCut(0),
     nEndLastCut(0)
 {
@@ -1167,14 +1154,12 @@ ScChangeActionMove::~ScChangeActionMove()
 
 void ScChangeActionMove::AddContent( ScChangeActionContent* pContent )
 {
-    ScChangeActionCellListEntry* pE = new ScChangeActionCellListEntry(
-        pContent, pFirstCell );
-    pFirstCell = pE;
+    mvCells.push_back(pContent);
 }
 
 void ScChangeActionMove::DeleteCellEntries()
 {
-    pTrack->DeleteCellEntries( pFirstCell, this );
+    pTrack->DeleteCellEntries( mvCells, this );
 }
 
 void ScChangeActionMove::UpdateReference( const ScChangeTrack* /* pTrack */,
@@ -2848,21 +2833,17 @@ void ScChangeTrack::AppendInsert( const ScRange& 
rRange, bool bEndOfList )
     Append( pAct );
 }
 
-void ScChangeTrack::DeleteCellEntries( ScChangeActionCellListEntry*& pCellList,
+void ScChangeTrack::DeleteCellEntries( std::vector<ScChangeActionContent*>& 
rCellList,
         const ScChangeAction* pDeletor )
 {
-    ScChangeActionCellListEntry* pE = pCellList;
-    while ( pE )
+    for (ScChangeActionContent* pContent : rCellList)
     {
-        ScChangeActionCellListEntry* pNext = pE->pNext;
-        pE->pContent->RemoveDeletedIn( pDeletor );
-        if ( IsGenerated( pE->pContent->GetActionNumber() ) &&
-                !pE->pContent->IsDeletedIn() )
-            DeleteGeneratedDelContent( pE->pContent );
-        delete pE;
-        pE = pNext;
+        pContent->RemoveDeletedIn( pDeletor );
+        if ( IsGenerated( pContent->GetActionNumber() ) &&
+                !pContent->IsDeletedIn() )
+            DeleteGeneratedDelContent( pContent );
     }
-    pCellList = nullptr;
+    rCellList.clear();
 }
 
 ScChangeActionContent* ScChangeTrack::GenerateDelContent(
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to