diff options
Diffstat (limited to 'sc/source/ui/view/tabvwshb.cxx')
-rw-r--r-- | sc/source/ui/view/tabvwshb.cxx | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/sc/source/ui/view/tabvwshb.cxx b/sc/source/ui/view/tabvwshb.cxx index c6d9b004b9ba..b13707a8378b 100644 --- a/sc/source/ui/view/tabvwshb.cxx +++ b/sc/source/ui/view/tabvwshb.cxx @@ -61,9 +61,11 @@ #include <sfx2/viewfrm.hxx> #include <svtools/soerr.hxx> #include <svl/rectitem.hxx> +#include <svl/slstitm.hxx> #include <svl/whiter.hxx> #include <unotools/moduleoptions.hxx> #include <sot/exchange.hxx> +#include <tools/diagnose_ex.h> #include "tabvwsh.hxx" #include "globstr.hrc" @@ -487,5 +489,98 @@ void ScTabViewShell::GetDrawInsState(SfxItemSet &rSet) } +//------------------------------------------------------------------ + +void ScTabViewShell::ExecuteUndo(SfxRequest& rReq) +{ + SfxShell* pSh = GetViewData()->GetDispatcher().GetShell(0); + ::svl::IUndoManager* pUndoManager = pSh->GetUndoManager(); + + const SfxItemSet* pReqArgs = rReq.GetArgs(); + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + + USHORT nSlot = rReq.GetSlot(); + switch ( nSlot ) + { + case SID_UNDO: + case SID_REDO: + if ( pUndoManager ) + { + BOOL bIsUndo = ( nSlot == SID_UNDO ); + + USHORT nCount = 1; + const SfxPoolItem* pItem; + if ( pReqArgs && pReqArgs->GetItemState( nSlot, TRUE, &pItem ) == SFX_ITEM_SET ) + nCount = ((const SfxUInt16Item*)pItem)->GetValue(); + + // lock paint for more than one cell undo action (not for editing within a cell) + BOOL bLockPaint = ( nCount > 1 && pUndoManager == GetUndoManager() ); + if ( bLockPaint ) + pDocSh->LockPaint(); + + try + { + for (USHORT i=0; i<nCount; i++) + { + if ( bIsUndo ) + pUndoManager->Undo(); + else + pUndoManager->Redo(); + } + } + catch ( const uno::Exception& ) + { + // no need to handle. By definition, the UndoManager handled this by clearing the + // Undo/Redo stacks + } + + if ( bLockPaint ) + pDocSh->UnlockPaint(); + + GetViewFrame()->GetBindings().InvalidateAll(sal_False); + } + break; +// default: +// GetViewFrame()->ExecuteSlot( rReq ); + } +} + +void ScTabViewShell::GetUndoState(SfxItemSet &rSet) +{ + SfxShell* pSh = GetViewData()->GetDispatcher().GetShell(0); + ::svl::IUndoManager* pUndoManager = pSh->GetUndoManager(); + + SfxWhichIter aIter(rSet); + USHORT nWhich = aIter.FirstWhich(); + while ( nWhich ) + { + switch (nWhich) + { + case SID_GETUNDOSTRINGS: + case SID_GETREDOSTRINGS: + { + SfxStringListItem aStrLst( nWhich ); + if ( pUndoManager ) + { + List* pList = aStrLst.GetList(); + BOOL bIsUndo = ( nWhich == SID_GETUNDOSTRINGS ); + size_t nCount = bIsUndo ? pUndoManager->GetUndoActionCount() : pUndoManager->GetRedoActionCount(); + for (size_t i=0; i<nCount; i++) + pList->Insert( new String( bIsUndo ? pUndoManager->GetUndoActionComment(i) : + pUndoManager->GetRedoActionComment(i) ), + LIST_APPEND ); + } + rSet.Put( aStrLst ); + } + break; + default: + // get state from sfx view frame + GetViewFrame()->GetSlotState( nWhich, NULL, &rSet ); + } + + nWhich = aIter.NextWhich(); + } +} + |