Kaydet (Commit) 0158333f authored tarafından Marcel Metz's avatar Marcel Metz Kaydeden (comit) Eike Rathke

Replace ScChangeTrackMsgStack with std::stack< ScChangeTrackMsgInfo* >

üst 6ea8ea45
...@@ -30,11 +30,11 @@ ...@@ -30,11 +30,11 @@
#define SC_CHGTRACK_HXX #define SC_CHGTRACK_HXX
#include <deque> #include <deque>
#include <stack>
#include <tools/string.hxx> #include <tools/string.hxx>
#include <tools/datetime.hxx> #include <tools/datetime.hxx>
#include <tools/table.hxx> #include <tools/table.hxx>
#include <tools/stack.hxx>
#include <tools/mempool.hxx> #include <tools/mempool.hxx>
#include <tools/link.hxx> #include <tools/link.hxx>
#include <unotools/options.hxx> #include <unotools/options.hxx>
...@@ -689,8 +689,6 @@ enum ScChangeActionContentCellType ...@@ -689,8 +689,6 @@ enum ScChangeActionContentCellType
SC_CACCT_MATREF SC_CACCT_MATREF
}; };
class Stack;
class ScChangeActionContent : public ScChangeAction class ScChangeActionContent : public ScChangeAction
{ {
friend class ScChangeTrack; friend class ScChangeTrack;
...@@ -779,7 +777,7 @@ class ScChangeActionContent : public ScChangeAction ...@@ -779,7 +777,7 @@ class ScChangeActionContent : public ScChangeAction
// pRejectActions!=NULL: reject actions get // pRejectActions!=NULL: reject actions get
// stacked, no SetNewValue, no Append // stacked, no SetNewValue, no Append
sal_Bool Select( ScDocument*, ScChangeTrack*, sal_Bool Select( ScDocument*, ScChangeTrack*,
sal_Bool bOldest, Stack* pRejectActions ); sal_Bool bOldest, ::std::stack<ScChangeActionContent*>* pRejectActions );
void PutValueToDoc( ScBaseCell*, const String&, void PutValueToDoc( ScBaseCell*, const String&,
ScDocument*, SCsCOL nDx, SCsROW nDy ) const; ScDocument*, SCsCOL nDx, SCsROW nDy ) const;
...@@ -901,8 +899,6 @@ public: ...@@ -901,8 +899,6 @@ public:
// --- ScChangeActionReject ------------------------------------------------- // --- ScChangeActionReject -------------------------------------------------
class Stack;
class ScChangeActionReject : public ScChangeAction class ScChangeActionReject : public ScChangeAction
{ {
friend class ScChangeTrack; friend class ScChangeTrack;
...@@ -955,7 +951,7 @@ struct ScChangeTrackMsgInfo ...@@ -955,7 +951,7 @@ struct ScChangeTrackMsgInfo
// MsgQueue for notification via ModifiedLink // MsgQueue for notification via ModifiedLink
typedef std::deque<ScChangeTrackMsgInfo*> ScChangeTrackMsgQueue; typedef std::deque<ScChangeTrackMsgInfo*> ScChangeTrackMsgQueue;
DECLARE_STACK( ScChangeTrackMsgStack, ScChangeTrackMsgInfo* ) typedef std::stack<ScChangeTrackMsgInfo*> ScChangeTrackMsgStack;
enum ScChangeTrackMergeState enum ScChangeTrackMergeState
{ {
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#include <tools/shl.hxx> // SHL_CALC #include <tools/shl.hxx> // SHL_CALC
#include <tools/stack.hxx>
#include <tools/rtti.hxx> #include <tools/rtti.hxx>
#include <svl/zforlist.hxx> #include <svl/zforlist.hxx>
#include <svl/itemset.hxx> #include <svl/itemset.hxx>
...@@ -53,13 +52,9 @@ ...@@ -53,13 +52,9 @@
#include "globstr.hrc" #include "globstr.hrc"
#include <stack>
#define SC_CHGTRACK_CXX #define SC_CHGTRACK_CXX
#include "chgtrack.hxx" #include "chgtrack.hxx"
DECLARE_STACK( ScChangeActionStack, ScChangeAction* )
const sal_uInt16 nMemPoolChangeActionCellListEntry = (0x2000 - 64) / sizeof(ScChangeActionCellListEntry); const sal_uInt16 nMemPoolChangeActionCellListEntry = (0x2000 - 64) / sizeof(ScChangeActionCellListEntry);
IMPL_FIXEDMEMPOOL_NEWDEL( ScChangeActionCellListEntry, nMemPoolChangeActionCellListEntry, nMemPoolChangeActionCellListEntry ) IMPL_FIXEDMEMPOOL_NEWDEL( ScChangeActionCellListEntry, nMemPoolChangeActionCellListEntry, nMemPoolChangeActionCellListEntry )
...@@ -1520,7 +1515,7 @@ sal_Bool ScChangeActionContent::Reject( ScDocument* pDoc ) ...@@ -1520,7 +1515,7 @@ sal_Bool ScChangeActionContent::Reject( ScDocument* pDoc )
sal_Bool ScChangeActionContent::Select( ScDocument* pDoc, ScChangeTrack* pTrack, sal_Bool ScChangeActionContent::Select( ScDocument* pDoc, ScChangeTrack* pTrack,
sal_Bool bOldest, Stack* pRejectActions ) sal_Bool bOldest, ::std::stack<ScChangeActionContent*>* pRejectActions )
{ {
if ( !aBigRange.IsValid( pDoc ) ) if ( !aBigRange.IsValid( pDoc ) )
return false; return false;
...@@ -1565,7 +1560,7 @@ sal_Bool ScChangeActionContent::Select( ScDocument* pDoc, ScChangeTrack* pTrack, ...@@ -1565,7 +1560,7 @@ sal_Bool ScChangeActionContent::Select( ScDocument* pDoc, ScChangeTrack* pTrack,
pNew->SetRejectAction( bOldest ? GetActionNumber() : pEnd->GetActionNumber() ); pNew->SetRejectAction( bOldest ? GetActionNumber() : pEnd->GetActionNumber() );
pNew->SetState( SC_CAS_ACCEPTED ); pNew->SetState( SC_CAS_ACCEPTED );
if ( pRejectActions ) if ( pRejectActions )
pRejectActions->Push( pNew ); pRejectActions->push( pNew );
else else
{ {
pNew->SetNewValue( pDoc->GetCell( rPos ), pDoc ); pNew->SetNewValue( pDoc->GetCell( rPos ), pDoc );
...@@ -2147,11 +2142,16 @@ void ScChangeTrack::ClearMsgQueue() ...@@ -2147,11 +2142,16 @@ void ScChangeTrack::ClearMsgQueue()
delete pBlockModifyMsg; delete pBlockModifyMsg;
pBlockModifyMsg = NULL; pBlockModifyMsg = NULL;
} }
ScChangeTrackMsgInfo* pMsgInfo; while ( !aMsgStackTmp.empty() )
while ( ( pMsgInfo = aMsgStackTmp.Pop() ) != NULL ) {
delete pMsgInfo; delete aMsgStackTmp.top();
while ( ( pMsgInfo = aMsgStackFinal.Pop() ) != NULL ) aMsgStackTmp.pop();
delete pMsgInfo; }
while ( !aMsgStackFinal.empty() )
{
delete aMsgStackFinal.top();
aMsgStackFinal.pop();
}
ScChangeTrackMsgQueue::iterator itQueue; ScChangeTrackMsgQueue::iterator itQueue;
for ( itQueue = aMsgQueue.begin(); itQueue != aMsgQueue.end(); ++itQueue) for ( itQueue = aMsgQueue.begin(); itQueue != aMsgQueue.end(); ++itQueue)
...@@ -2218,7 +2218,7 @@ void ScChangeTrack::StartBlockModify( ScChangeTrackMsgType eMsgType, ...@@ -2218,7 +2218,7 @@ void ScChangeTrack::StartBlockModify( ScChangeTrackMsgType eMsgType,
if ( aModifiedLink.IsSet() ) if ( aModifiedLink.IsSet() )
{ {
if ( pBlockModifyMsg ) if ( pBlockModifyMsg )
aMsgStackTmp.Push( pBlockModifyMsg ); // Block im Block aMsgStackTmp.push( pBlockModifyMsg ); // Block im Block
pBlockModifyMsg = new ScChangeTrackMsgInfo; pBlockModifyMsg = new ScChangeTrackMsgInfo;
pBlockModifyMsg->eMsgType = eMsgType; pBlockModifyMsg->eMsgType = eMsgType;
pBlockModifyMsg->nStartAction = nStartAction; pBlockModifyMsg->nStartAction = nStartAction;
...@@ -2236,19 +2236,20 @@ void ScChangeTrack::EndBlockModify( sal_uLong nEndAction ) ...@@ -2236,19 +2236,20 @@ void ScChangeTrack::EndBlockModify( sal_uLong nEndAction )
{ {
pBlockModifyMsg->nEndAction = nEndAction; pBlockModifyMsg->nEndAction = nEndAction;
// Blocks in Blocks aufgeloest // Blocks in Blocks aufgeloest
aMsgStackFinal.Push( pBlockModifyMsg ); aMsgStackFinal.push( pBlockModifyMsg );
} }
else else
delete pBlockModifyMsg; delete pBlockModifyMsg;
pBlockModifyMsg = aMsgStackTmp.Pop(); // evtl. Block im Block pBlockModifyMsg = aMsgStackTmp.top(); // evtl. Block im Block
aMsgStackTmp.pop();
} }
if ( !pBlockModifyMsg ) if ( !pBlockModifyMsg )
{ {
sal_Bool bNew = false; sal_Bool bNew = false;
ScChangeTrackMsgInfo* pMsg; while ( !aMsgStackFinal.empty() )
while ( ( pMsg = aMsgStackFinal.Pop() ) != NULL )
{ {
aMsgQueue.push_back( pMsg ); aMsgQueue.push_back( aMsgStackFinal.top() );
aMsgStackFinal.pop();
bNew = sal_True; bNew = sal_True;
} }
if ( bNew ) if ( bNew )
...@@ -3850,10 +3851,15 @@ void ScChangeTrack::GetDependents( ScChangeAction* pAct, ...@@ -3850,10 +3851,15 @@ void ScChangeTrack::GetDependents( ScChangeAction* pAct,
sal_Bool bIsDelete = pAct->IsDeleteType(); sal_Bool bIsDelete = pAct->IsDeleteType();
sal_Bool bIsMasterDelete = ( bListMasterDelete && pAct->IsMasterDelete() ); sal_Bool bIsMasterDelete = ( bListMasterDelete && pAct->IsMasterDelete() );
const ScChangeAction* pCur = pAct; const ScChangeAction* pCur = NULL;
ScChangeActionStack* pStack = new ScChangeActionStack; ::std::stack<ScChangeAction*> cStack;
do cStack.push(pAct);
while ( !cStack.empty() )
{ {
pCur = cStack.top();
cStack.pop();
if ( pCur->IsInsertType() ) if ( pCur->IsInsertType() )
{ {
const ScChangeActionLinkEntry* pL = pCur->GetFirstDependentEntry(); const ScChangeActionLinkEntry* pL = pCur->GetFirstDependentEntry();
...@@ -3867,7 +3873,7 @@ void ScChangeTrack::GetDependents( ScChangeAction* pAct, ...@@ -3867,7 +3873,7 @@ void ScChangeTrack::GetDependents( ScChangeAction* pAct,
sal_uLong n = p->GetActionNumber(); sal_uLong n = p->GetActionNumber();
if ( !IsGenerated( n ) && rTable.Insert( n, p ) ) if ( !IsGenerated( n ) && rTable.Insert( n, p ) )
if ( p->HasDependent() ) if ( p->HasDependent() )
pStack->Push( p ); cStack.push( p );
} }
else else
{ {
...@@ -3915,7 +3921,7 @@ void ScChangeTrack::GetDependents( ScChangeAction* pAct, ...@@ -3915,7 +3921,7 @@ void ScChangeTrack::GetDependents( ScChangeAction* pAct,
if ( !IsGenerated( n ) && rTable.Insert( n, p ) ) if ( !IsGenerated( n ) && rTable.Insert( n, p ) )
if ( p->HasDeleted() || if ( p->HasDeleted() ||
p->GetType() == SC_CAT_CONTENT ) p->GetType() == SC_CAT_CONTENT )
pStack->Push( p ); cStack.push( p );
} }
else else
{ {
...@@ -3946,7 +3952,7 @@ void ScChangeTrack::GetDependents( ScChangeAction* pAct, ...@@ -3946,7 +3952,7 @@ void ScChangeTrack::GetDependents( ScChangeAction* pAct,
// nur ein TopContent einer Kette ist in LinkDeleted // nur ein TopContent einer Kette ist in LinkDeleted
if ( bAllFlat && (p->HasDeleted() || if ( bAllFlat && (p->HasDeleted() ||
p->GetType() == SC_CAT_CONTENT) ) p->GetType() == SC_CAT_CONTENT) )
pStack->Push( p ); cStack.push( p );
} }
pL = pL->GetNext(); pL = pL->GetNext();
} }
...@@ -3963,7 +3969,7 @@ void ScChangeTrack::GetDependents( ScChangeAction* pAct, ...@@ -3963,7 +3969,7 @@ void ScChangeTrack::GetDependents( ScChangeAction* pAct,
sal_uLong n = p->GetActionNumber(); sal_uLong n = p->GetActionNumber();
if ( !IsGenerated( n ) && rTable.Insert( n, p ) ) if ( !IsGenerated( n ) && rTable.Insert( n, p ) )
if ( p->HasDependent() || p->HasDeleted() ) if ( p->HasDependent() || p->HasDeleted() )
pStack->Push( p ); cStack.push( p );
} }
else else
{ {
...@@ -4007,7 +4013,7 @@ void ScChangeTrack::GetDependents( ScChangeAction* pAct, ...@@ -4007,7 +4013,7 @@ void ScChangeTrack::GetDependents( ScChangeAction* pAct,
sal_uLong n = p->GetActionNumber(); sal_uLong n = p->GetActionNumber();
if ( !IsGenerated( n ) && rTable.Insert( n, p ) ) if ( !IsGenerated( n ) && rTable.Insert( n, p ) )
if ( p->HasDependent() ) if ( p->HasDependent() )
pStack->Push( p ); cStack.push( p );
} }
else else
rTable.Insert( p->GetActionNumber(), p ); rTable.Insert( p->GetActionNumber(), p );
...@@ -4022,11 +4028,10 @@ void ScChangeTrack::GetDependents( ScChangeAction* pAct, ...@@ -4022,11 +4028,10 @@ void ScChangeTrack::GetDependents( ScChangeAction* pAct,
ScChangeAction* p = GetAction( ScChangeAction* p = GetAction(
((ScChangeActionReject*)pCur)->GetRejectAction() ); ((ScChangeActionReject*)pCur)->GetRejectAction() );
if ( p != pAct && !rTable.Get( p->GetActionNumber() ) ) if ( p != pAct && !rTable.Get( p->GetActionNumber() ) )
pStack->Push( p ); cStack.push( p );
}
} }
} }
} while ( ( pCur = pStack->Pop() ) != NULL );
delete pStack;
} }
...@@ -4071,7 +4076,7 @@ sal_Bool ScChangeTrack::SelectContent( ScChangeAction* pAct, sal_Bool bOldest ) ...@@ -4071,7 +4076,7 @@ sal_Bool ScChangeTrack::SelectContent( ScChangeAction* pAct, sal_Bool bOldest )
if ( pContent->HasDependent() ) if ( pContent->HasDependent() )
{ {
sal_Bool bOk = sal_True; sal_Bool bOk = sal_True;
Stack aRejectActions; ::std::stack<ScChangeActionContent*> aRejectActions;
const ScChangeActionLinkEntry* pL = pContent->GetFirstDependentEntry(); const ScChangeActionLinkEntry* pL = pContent->GetFirstDependentEntry();
while ( pL ) while ( pL )
{ {
...@@ -4096,8 +4101,10 @@ sal_Bool ScChangeTrack::SelectContent( ScChangeAction* pAct, sal_Bool bOldest ) ...@@ -4096,8 +4101,10 @@ sal_Bool ScChangeTrack::SelectContent( ScChangeAction* pAct, sal_Bool bOldest )
// now the matrix is inserted and new content values are ready // now the matrix is inserted and new content values are ready
ScChangeActionContent* pNew; ScChangeActionContent* pNew;
while ( ( pNew = (ScChangeActionContent*) aRejectActions.Pop() ) != NULL ) while ( !aRejectActions.empty() )
{ {
pNew = aRejectActions.top();
aRejectActions.pop();
ScAddress aPos( pNew->GetBigRange().aStart.MakeAddress() ); ScAddress aPos( pNew->GetBigRange().aStart.MakeAddress() );
pNew->SetNewValue( pDoc->GetCell( aPos ), pDoc ); pNew->SetNewValue( pDoc->GetCell( aPos ), pDoc );
Append( pNew ); Append( pNew );
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#define SC_XCLEXPCHANGETRACK_HXX #define SC_XCLEXPCHANGETRACK_HXX
#include <tools/datetime.hxx> #include <tools/datetime.hxx>
#include <tools/stack.hxx>
#include <rtl/uuid.h> #include <rtl/uuid.h>
#include "bigrange.hxx" #include "bigrange.hxx"
#include "chgtrack.hxx" #include "chgtrack.hxx"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment