undoapi: allow retrieving the count/comments of Undo/Redo actions both on the current and the top level

This commit is contained in:
Frank Schoenheit [fs] 2010-11-02 13:19:49 +01:00
parent d2e595727b
commit 861471d1da
2 changed files with 31 additions and 23 deletions

View file

@ -158,6 +158,12 @@ namespace svl
class SAL_NO_VTABLE IUndoManager
{
public:
enum
{
CurrentLevel = true,
TopLevel = false
};
virtual ~IUndoManager() { };
virtual void SetMaxUndoActionCount( USHORT nMaxUndoActionCount ) = 0;
@ -165,13 +171,13 @@ namespace svl
virtual void AddUndoAction( SfxUndoAction *pAction, BOOL bTryMerg=FALSE ) = 0;
virtual USHORT GetUndoActionCount() const = 0;
virtual USHORT GetUndoActionCount( bool const i_currentLevel = CurrentLevel ) const = 0;
virtual USHORT GetUndoActionId() const = 0;
virtual UniString GetUndoActionComment( USHORT nNo=0 ) const = 0;
virtual UniString GetUndoActionComment( USHORT nNo=0, bool const i_currentLevel = CurrentLevel ) const = 0;
virtual SfxUndoAction* GetUndoAction( USHORT nNo=0 ) const = 0;
virtual USHORT GetRedoActionCount() const = 0;
virtual UniString GetRedoActionComment( USHORT nNo=0 ) const = 0;
virtual USHORT GetRedoActionCount( bool const i_currentLevel = CurrentLevel ) const = 0;
virtual UniString GetRedoActionComment( USHORT nNo=0, bool const i_currentLevel = CurrentLevel ) const = 0;
virtual BOOL Undo() = 0;
virtual BOOL Redo() = 0;
@ -255,12 +261,12 @@ public:
virtual void SetMaxUndoActionCount( USHORT nMaxUndoActionCount );
virtual USHORT GetMaxUndoActionCount() const;
virtual void AddUndoAction( SfxUndoAction *pAction, BOOL bTryMerg=FALSE );
virtual USHORT GetUndoActionCount() const;
virtual USHORT GetUndoActionCount( bool const i_currentLevel = CurrentLevel ) const;
virtual USHORT GetUndoActionId() const;
virtual UniString GetUndoActionComment( USHORT nNo=0 ) const;
virtual UniString GetUndoActionComment( USHORT nNo=0, bool const i_currentLevel = CurrentLevel ) const;
virtual SfxUndoAction* GetUndoAction( USHORT nNo=0 ) const;
virtual USHORT GetRedoActionCount() const;
virtual UniString GetRedoActionComment( USHORT nNo=0 ) const;
virtual USHORT GetRedoActionCount( bool const i_currentLevel = CurrentLevel ) const;
virtual UniString GetRedoActionComment( USHORT nNo=0, bool const i_currentLevel = CurrentLevel ) const;
virtual BOOL Undo();
virtual BOOL Redo();
virtual void Clear();

View file

@ -399,25 +399,25 @@ void SfxUndoManager::AddUndoAction( SfxUndoAction *pAction, BOOL bTryMerge )
//------------------------------------------------------------------------
USHORT SfxUndoManager::GetUndoActionCount() const
USHORT SfxUndoManager::GetUndoActionCount( bool const i_currentLevel ) const
{
return m_pData->pActUndoArray->nCurUndoAction;
const SfxUndoArray* pUndoArray = i_currentLevel ? m_pData->pActUndoArray : m_pData->pUndoArray;
return pUndoArray->nCurUndoAction;
}
//------------------------------------------------------------------------
XubString SfxUndoManager::GetUndoActionComment( USHORT nNo ) const
XubString SfxUndoManager::GetUndoActionComment( USHORT nNo, bool const i_currentLevel ) const
{
DBG_ASSERT( nNo < m_pData->pActUndoArray->nCurUndoAction, "svl::SfxUndoManager::GetUndoActionComment(), illegal id!" );
if( nNo < m_pData->pActUndoArray->nCurUndoAction )
const SfxUndoArray* pUndoArray = i_currentLevel ? m_pData->pActUndoArray : m_pData->pUndoArray;
String sComment;
DBG_ASSERT( nNo < pUndoArray->nCurUndoAction, "svl::SfxUndoManager::GetUndoActionComment: illegal index!" );
if( nNo < pUndoArray->nCurUndoAction )
{
return m_pData->pActUndoArray->aUndoActions[m_pData->pActUndoArray->nCurUndoAction-1-nNo]->GetComment(); //!
}
else
{
XubString aEmpty;
return aEmpty;
sComment = pUndoArray->aUndoActions[ pUndoArray->nCurUndoAction - 1 - nNo ]->GetComment();
}
return sComment;
}
//------------------------------------------------------------------------
@ -534,16 +534,18 @@ BOOL SfxUndoManager::Undo()
//------------------------------------------------------------------------
USHORT SfxUndoManager::GetRedoActionCount() const
USHORT SfxUndoManager::GetRedoActionCount( bool const i_currentLevel ) const
{
return m_pData->pActUndoArray->aUndoActions.Count() - m_pData->pActUndoArray->nCurUndoAction; //!
const SfxUndoArray* pUndoArray = i_currentLevel ? m_pData->pActUndoArray : m_pData->pUndoArray;
return pUndoArray->aUndoActions.Count() - pUndoArray->nCurUndoAction;
}
//------------------------------------------------------------------------
XubString SfxUndoManager::GetRedoActionComment( USHORT nNo ) const
XubString SfxUndoManager::GetRedoActionComment( USHORT nNo, bool const i_currentLevel ) const
{
return m_pData->pActUndoArray->aUndoActions[m_pData->pActUndoArray->nCurUndoAction+nNo]->GetComment(); //!
const SfxUndoArray* pUndoArray = i_currentLevel ? m_pData->pActUndoArray : m_pData->pUndoArray;
return pUndoArray->aUndoActions[ pUndoArray->nCurUndoAction + nNo ]->GetComment();
}
//------------------------------------------------------------------------