summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-08-14 15:47:41 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-08-15 08:37:04 +0200
commit619a6fc90d9682d859e43e5297d32a0f98738c0f (patch)
treee83fefa2eda16086e363349809192b7765985c01 /sc
parent0f2f719ccd5544eb37d1aacb0a50c317ae963e50 (diff)
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.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/chgtrack.hxx28
-rw-r--r--sc/source/core/tool/chgtrack.cxx53
2 files changed, 20 insertions, 61 deletions
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(