diff options
author | Ivan Timofeev <timofeev.i.s@gmail.com> | 2012-08-30 23:21:49 +0400 |
---|---|---|
committer | Ivan Timofeev <timofeev.i.s@gmail.com> | 2012-08-31 08:35:18 +0400 |
commit | 4deb9d4e0f29dd6947322aea665ee65ea8ef9ec4 (patch) | |
tree | a3c9ad5376a8424a242988c576ac112d956cadae /svx | |
parent | c050300a72f80ab838bd10f0cedd355048a2aaa5 (diff) |
SdrModel: make sure undo/redo stacks are not empty
most probably Undo() does not get called if there is no undo actions,
just to be on the safe side.
Change-Id: I3597698dbe8208916be94ebddd7260fbd7eadc74
Diffstat (limited to 'svx')
-rw-r--r-- | svx/inc/svx/svdmodel.hxx | 8 | ||||
-rw-r--r-- | svx/source/dialog/imapdlg.cxx | 4 | ||||
-rw-r--r-- | svx/source/svdraw/svdmodel.cxx | 16 |
3 files changed, 17 insertions, 11 deletions
diff --git a/svx/inc/svx/svdmodel.hxx b/svx/inc/svx/svdmodel.hxx index dd2919c6808d..77a4e02a0d45 100644 --- a/svx/inc/svx/svdmodel.hxx +++ b/svx/inc/svx/svdmodel.hxx @@ -575,13 +575,9 @@ public: void SetMaxUndoActionCount(sal_uIntPtr nAnz); 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->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->size() : 0; } - const SfxUndoAction* GetRedoAction(sal_uIntPtr nNum) const { return (SfxUndoAction*)(pRedoStack!=NULL ? (*pRedoStack)[nNum] : NULL); } + bool HasUndoActions() const; + bool HasRedoActions() const; bool Undo(); bool Redo(); bool Repeat(SfxRepeatTarget&); diff --git a/svx/source/dialog/imapdlg.cxx b/svx/source/dialog/imapdlg.cxx index 3fa0cb5e0de4..b70dc32cfd90 100644 --- a/svx/source/dialog/imapdlg.cxx +++ b/svx/source/dialog/imapdlg.cxx @@ -791,8 +791,8 @@ IMPL_LINK( SvxIMapDlg, StateHdl, IMapWindow*, pWnd ) aTbxIMapDlg1.EnableItem( TBI_POLYDELETE, !bDrawEnabled && pView->IsDeleteMarkedPointsPossible() ); // Undo/Redo - aTbxIMapDlg1.EnableItem( TBI_UNDO, pModel->GetUndoActionCount() > 0 ); - aTbxIMapDlg1.EnableItem( TBI_REDO, pModel->GetRedoActionCount() > 0 ); + aTbxIMapDlg1.EnableItem( TBI_UNDO, pModel->HasUndoActions() ); + aTbxIMapDlg1.EnableItem( TBI_REDO, pModel->HasRedoActions() ); if ( bPolyEdit ) { diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx index 14d45d61b962..9938a1f286b1 100644 --- a/svx/source/svdraw/svdmodel.cxx +++ b/svx/source/svdraw/svdmodel.cxx @@ -431,6 +431,16 @@ void SdrModel::ClearUndoBuffer() } } +bool SdrModel::HasUndoActions() const +{ + return pUndoStack && !pUndoStack->empty(); +} + +bool SdrModel::HasRedoActions() const +{ + return pRedoStack && !pRedoStack->empty(); +} + bool SdrModel::Undo() { bool bRet = false; @@ -440,7 +450,7 @@ bool SdrModel::Undo() } else { - SfxUndoAction* pDo=(SfxUndoAction*)GetUndoAction(0); + SfxUndoAction* pDo = HasUndoActions() ? pUndoStack->front() : NULL; if(pDo!=NULL) { const bool bWasUndoEnabled = mbUndoEnabled; @@ -466,7 +476,7 @@ bool SdrModel::Redo() } else { - SfxUndoAction* pDo=(SfxUndoAction*)GetRedoAction(0); + SfxUndoAction* pDo = HasRedoActions() ? pRedoStack->front() : NULL; if(pDo!=NULL) { const bool bWasUndoEnabled = mbUndoEnabled; @@ -492,7 +502,7 @@ bool SdrModel::Repeat(SfxRepeatTarget& rView) } else { - SfxUndoAction* pDo=(SfxUndoAction*)GetUndoAction(0); + SfxUndoAction* pDo = HasUndoActions() ? pUndoStack->front() : NULL; if(pDo!=NULL) { if(pDo->CanRepeat(rView)) |