diff options
author | Noel Grandin <noel@peralex.com> | 2012-08-15 13:57:45 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-08-16 18:44:05 +0200 |
commit | aa2d9729bdac0173349a5f76e2346b8335de565f (patch) | |
tree | f0a0ff15f77151ae98d3d9435001dcf45b52b7ff /svx | |
parent | replace LIST_APPEND usage with CONTAINER_APPEND (diff) | |
download | core-aa2d9729bdac0173349a5f76e2346b8335de565f.tar.gz core-aa2d9729bdac0173349a5f76e2346b8335de565f.zip |
Convert pUndoStack in SdrModel class from Container to std::deque
Change-Id: I59425c7d1e8603f45d193ae5e3498f8671510bc5
Diffstat (limited to 'svx')
-rw-r--r-- | svx/inc/svx/svdmodel.hxx | 7 | ||||
-rw-r--r-- | svx/source/svdraw/svdmodel.cxx | 27 |
2 files changed, 20 insertions, 14 deletions
diff --git a/svx/inc/svx/svdmodel.hxx b/svx/inc/svx/svdmodel.hxx index 39daffeb9d98..2f1ad6b4a1f1 100644 --- a/svx/inc/svx/svdmodel.hxx +++ b/svx/inc/svx/svdmodel.hxx @@ -52,6 +52,7 @@ class OutputDevice; #include "svx/svxdllapi.h" #include <rtl/ref.hxx> +#include <deque> #if defined(UNX) || defined(WNT) #define DEGREE_CHAR ((sal_Unicode)176) /* 0xB0 = Ansi */ @@ -191,7 +192,7 @@ protected: rtl::Reference< SfxStyleSheetBasePool > mxStyleSheetPool; SfxStyleSheet* pDefaultStyleSheet; sfx2::LinkManager* pLinkManager; // LinkManager - Container* pUndoStack; + std::deque<SfxUndoAction*>* pUndoStack; Container* pRedoStack; SdrUndoGroup* pAktUndoGroup; // Fuer mehrstufige sal_uInt16 nUndoLevel; // Undo-Klammerung @@ -575,8 +576,8 @@ public: sal_uIntPtr GetMaxUndoActionCount() const { return nMaxUndoCount; } void ClearUndoBuffer(); // UndoAction(0) ist die aktuelle (also die zuletzt eingegangene) - sal_uIntPtr GetUndoActionCount() const { return pUndoStack!=NULL ? pUndoStack->Count() : 0; } - const SfxUndoAction* GetUndoAction(sal_uIntPtr nNum) const { return (SfxUndoAction*)(pUndoStack!=NULL ? pUndoStack->GetObject(nNum) : NULL); } + sal_uIntPtr GetUndoActionCount() const { return pUndoStack!=NULL ? pUndoStack->size() : 0; } + const SfxUndoAction* GetUndoAction(sal_uIntPtr nNum) const { return (SfxUndoAction*)(pUndoStack!=NULL ? (*pUndoStack)[nNum] : NULL); } // RedoAction(0) ist die aktuelle (also die des letzten Undo) sal_uIntPtr GetRedoActionCount() const { return pRedoStack!=NULL ? pRedoStack->Count() : 0; } const SfxUndoAction* GetRedoAction(sal_uIntPtr nNum) const { return (SfxUndoAction*)(pRedoStack!=NULL ? pRedoStack->GetObject(nNum) : NULL); } diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx index 6a3de9e5d8a3..d3c0c380e7dc 100644 --- a/svx/source/svdraw/svdmodel.cxx +++ b/svx/source/svdraw/svdmodel.cxx @@ -404,8 +404,9 @@ void SdrModel::SetMaxUndoActionCount(sal_uIntPtr nAnz) if (nAnz<1) nAnz=1; nMaxUndoCount=nAnz; if (pUndoStack!=NULL) { - while (pUndoStack->Count()>nMaxUndoCount) { - delete (SfxUndoAction*) pUndoStack->Remove(pUndoStack->Count()); + while (pUndoStack->size()>nMaxUndoCount) { + delete pUndoStack->back(); + pUndoStack->pop_back(); } } } @@ -413,8 +414,9 @@ void SdrModel::SetMaxUndoActionCount(sal_uIntPtr nAnz) void SdrModel::ClearUndoBuffer() { if (pUndoStack!=NULL) { - while (pUndoStack->Count()!=0) { - delete (SfxUndoAction*) pUndoStack->Remove(pUndoStack->Count()-1); + while (!pUndoStack->empty()) { + delete pUndoStack->back(); + pUndoStack->pop_back(); } delete pUndoStack; pUndoStack=NULL; @@ -445,7 +447,9 @@ bool SdrModel::Undo() pDo->Undo(); if(pRedoStack==NULL) pRedoStack=new Container(1024,16,16); - pRedoStack->Insert(pUndoStack->Remove((sal_uIntPtr)0),(sal_uIntPtr)0); + SfxUndoAction* p = pUndoStack->front(); + pUndoStack->pop_front(); + pRedoStack->Insert(p,(sal_uIntPtr)0); mbUndoEnabled = bWasUndoEnabled; } } @@ -468,8 +472,8 @@ bool SdrModel::Redo() mbUndoEnabled = false; pDo->Redo(); if(pUndoStack==NULL) - pUndoStack=new Container(1024,16,16); - pUndoStack->Insert(pRedoStack->Remove((sal_uIntPtr)0),(sal_uIntPtr)0); + pUndoStack=new std::deque<SfxUndoAction*>; + pUndoStack->push_front((SfxUndoAction*) pRedoStack->Remove((sal_uIntPtr)0)); mbUndoEnabled = bWasUndoEnabled; } } @@ -510,11 +514,12 @@ void SdrModel::ImpPostUndoAction(SdrUndoAction* pUndo) else { if (pUndoStack==NULL) - pUndoStack=new Container(1024,16,16); - pUndoStack->Insert(pUndo,(sal_uIntPtr)0); - while (pUndoStack->Count()>nMaxUndoCount) + pUndoStack=new std::deque<SfxUndoAction*>; + pUndoStack->push_front(pUndo); + while (pUndoStack->size()>nMaxUndoCount) { - delete (SfxUndoAction*)pUndoStack->Remove(pUndoStack->Count()-1); + delete pUndoStack->back(); + pUndoStack->pop_back(); } if (pRedoStack!=NULL) pRedoStack->Clear(); |