LibreOffice Module svl (master) 1
|
#include <undo.hxx>
Public Member Functions | |
SfxUndoManager (size_t nMaxUndoActionCount=20) | |
virtual | ~SfxUndoManager () |
void | SetMaxUndoActionCount (size_t nMaxUndoActionCount) |
size_t | GetMaxUndoActionCount () const |
virtual void | AddUndoAction (std::unique_ptr< SfxUndoAction > pAction, bool bTryMerg=false) |
virtual size_t | GetUndoActionCount (bool const i_currentLevel=CurrentLevel) const |
OUString | GetUndoActionComment (size_t nNo=0, bool const i_currentLevel=CurrentLevel) const |
SfxUndoAction * | GetUndoAction (size_t nNo=0) const |
OUString | GetUndoActionsInfo () const |
Get info about all undo actions (comment, view shell id, etc.) More... | |
virtual size_t | GetRedoActionCount (bool const i_currentLevel=CurrentLevel) const |
OUString | GetRedoActionComment (size_t nNo=0, bool const i_currentLevel=CurrentLevel) const |
SfxUndoAction * | GetRedoAction (size_t nNo=0) const |
OUString | GetRedoActionsInfo () const |
Get info about all redo actions (comment, view shell id, etc.) More... | |
virtual bool | Undo () |
virtual bool | Redo () |
virtual void | Clear () |
Clears both the Redo and the Undo stack. More... | |
virtual void | ClearRedo () |
Clears the Redo stack. More... | |
void | Reset () |
leaves any possible open list action (<member>IsInListAction</member>), and clears both the Undo and the Redo stack. More... | |
bool | IsDoing () const |
determines whether an Undo or Redo is currently running More... | |
size_t | GetRepeatActionCount () const |
OUString | GetRepeatActionComment (SfxRepeatTarget &rTarget) const |
bool | Repeat (SfxRepeatTarget &rTarget) |
bool | CanRepeat (SfxRepeatTarget &rTarget) const |
virtual void | EnterListAction (const OUString &rComment, const OUString &rRepeatComment, sal_uInt16 nId, ViewShellId nViewShellId) |
Inserts a ListUndoAction and sets its UndoArray as current. More... | |
size_t | LeaveListAction () |
Leaves the list action entered with EnterListAction. More... | |
size_t | LeaveAndMergeListAction () |
Leaves the list action entered with EnterListAction, and forcefully merges the previous action on the stack into the newly created list action. More... | |
bool | IsInListAction () const |
determines whether we're within a ListAction context, i.e. a LeaveListAction/LeaveAndMergeListAction call is pending More... | |
size_t | GetListActionDepth () const |
Determines how many nested list actions are currently open. More... | |
void | RemoveLastUndoAction () |
Clears the redo stack and removes the top undo action. More... | |
void | EnableUndo (bool bEnable) |
enables (true) or disables (false) recording of undo actions More... | |
bool | IsUndoEnabled () const |
returns true if undo is currently enabled. More... | |
void | AddUndoListener (SfxUndoListener &i_listener) |
Adds a new listener to be notified about changes in the UndoManager's state. More... | |
void | RemoveUndoListener (SfxUndoListener &i_listener) |
bool | IsEmptyActions () const |
UndoStackMark | MarkTopUndoAction () |
marks the current top-level element of the Undo stack, and returns a unique ID for it More... | |
void | RemoveMark (UndoStackMark const i_mark) |
removes a mark given by its ID. More... | |
bool | HasTopUndoActionMark (UndoStackMark const i_mark) |
determines whether the top action on the Undo stack has a given mark More... | |
void | RemoveOldestUndoAction () |
removes the oldest Undo actions from the stack More... | |
void | dumpAsXml (xmlTextWriterPtr pWriter) const |
Static Public Attributes | |
static bool const | CurrentLevel = true |
static bool const | TopLevel = false |
Protected Member Functions | |
bool | UndoWithContext (SfxUndoContext &i_context) |
bool | RedoWithContext (SfxUndoContext &i_context) |
void | ImplClearRedo_NoLock (bool const i_currentLevel) |
void | ClearAllLevels () |
clears all undo actions on the current level, plus all undo actions on superordinate levels, as soon as those levels are reached. More... | |
virtual void | EmptyActionsChanged () |
Private Member Functions | |
size_t | ImplLeaveListAction (const bool i_merge, ::svl::undo::impl::UndoManagerGuard &i_guard) |
bool | ImplAddUndoAction_NoNotify (std::unique_ptr< SfxUndoAction > pAction, bool bTryMerge, bool bClearRedo, ::svl::undo::impl::UndoManagerGuard &i_guard) |
void | ImplClearRedo (::svl::undo::impl::UndoManagerGuard &i_guard, bool const i_currentLevel) |
void | ImplClearUndo (::svl::undo::impl::UndoManagerGuard &i_guard) |
void | ImplClearCurrentLevel_NoNotify (::svl::undo::impl::UndoManagerGuard &i_guard) |
size_t | ImplGetRedoActionCount_Lock (bool const i_currentLevel=CurrentLevel) const |
bool | ImplIsUndoEnabled_Lock () const |
bool | ImplIsInListAction_Lock () const |
void | ImplEnableUndo_Lock (bool const i_enable) |
bool | ImplUndo (SfxUndoContext *i_contextOrNull) |
bool | ImplRedo (SfxUndoContext *i_contextOrNull) |
void | ImplCheckEmptyActions () |
bool | ImplIsEmptyActions () const |
Private Attributes | |
std::unique_ptr< SfxUndoManager_Data > | m_xData |
Friends | |
class | ::svl::undo::impl::LockGuard |
SfxUndoManager::SfxUndoManager | ( | size_t | nMaxUndoActionCount = 20 | ) |
Definition at line 339 of file undo.cxx.
References ImplIsEmptyActions(), and m_xData.
|
virtual |
Definition at line 584 of file undo.cxx.
References ImplAddUndoAction_NoNotify(), m_xData, and SfxUndoListener::undoActionAdded().
void SfxUndoManager::AddUndoListener | ( | SfxUndoListener & | i_listener | ) |
bool SfxUndoManager::CanRepeat | ( | SfxRepeatTarget & | rTarget | ) | const |
|
virtual |
Clears both the Redo and the Undo stack.
Will assert and bail out when called while within a list action (<member>IsInListAction</member>).
Definition at line 435 of file undo.cxx.
References SfxUndoListener::cleared(), ImplClearCurrentLevel_NoNotify(), ImplIsInListAction_Lock(), m_xData, and SAL_WARN_IF.
|
protected |
clears all undo actions on the current level, plus all undo actions on superordinate levels, as soon as those levels are reached.
If no list action is active currently, i.e. we're on the top level already, this method is equivalent to ->Clear.
Otherwise, the Undo actions on the current level are removed. Upon leaving the current list action, all undo actions on the then-current level are removed, too. This is continued until the top level is reached.
Definition at line 448 of file undo.cxx.
References SfxUndoListener::cleared(), ImplClearCurrentLevel_NoNotify(), ImplIsInListAction_Lock(), and m_xData.
|
virtual |
Clears the Redo stack.
Will assert and bail out when called while within a list action (<member>IsInListAction</member>).
Definition at line 471 of file undo.cxx.
References CurrentLevel, ImplClearRedo_NoLock(), IsInListAction(), and SAL_WARN_IF.
void SfxUndoManager::dumpAsXml | ( | xmlTextWriterPtr | pWriter | ) | const |
Definition at line 1151 of file undo.cxx.
References GetRedoActionCount(), GetUndoActionCount(), i, m_xData, SfxUndoArray::maUndoActions, and SfxUndoArray::nCurUndoAction.
|
protectedvirtual |
Definition at line 1262 of file undo.cxx.
Referenced by ImplCheckEmptyActions().
void SfxUndoManager::EnableUndo | ( | bool | bEnable | ) |
enables (true) or disables (false) recording of undo actions
If undo actions are added while undo is disabled, they are deleted. Disabling undo does not clear the current undo buffer!
Multiple calls to EnableUndo
are not cumulative. That is, calling EnableUndo( false )
twice, and then calling EnableUndo( true )
means that Undo is enable afterwards.
Definition at line 351 of file undo.cxx.
References ImplEnableUndo_Lock(), and m_xData.
|
virtual |
Inserts a ListUndoAction and sets its UndoArray as current.
Definition at line 916 of file undo.cxx.
References ImplAddUndoAction_NoNotify(), ImplIsUndoEnabled_Lock(), SfxUndoListener::listActionEntered(), m_xData, and nId.
size_t SfxUndoManager::GetListActionDepth | ( | ) | const |
Determines how many nested list actions are currently open.
Definition at line 951 of file undo.cxx.
References m_xData, and SfxUndoArray::pFatherUndoArray.
size_t SfxUndoManager::GetMaxUndoActionCount | ( | ) | const |
SfxUndoAction * SfxUndoManager::GetRedoAction | ( | size_t | nNo = 0 | ) | const |
Definition at line 758 of file undo.cxx.
References m_xData, SfxUndoArray::maUndoActions, and SfxUndoArray::nCurUndoAction.
OUString SfxUndoManager::GetRedoActionComment | ( | size_t | nNo = 0 , |
bool const | i_currentLevel = CurrentLevel |
||
) | const |
Definition at line 771 of file undo.cxx.
References m_xData, SfxUndoArray::maUndoActions, and SfxUndoArray::nCurUndoAction.
|
virtual |
Definition at line 744 of file undo.cxx.
References ImplGetRedoActionCount_Lock(), and m_xData.
Referenced by dumpAsXml(), and GetRedoActionsInfo().
OUString SfxUndoManager::GetRedoActionsInfo | ( | ) | const |
Get info about all redo actions (comment, view shell id, etc.)
Definition at line 1221 of file undo.cxx.
References GetRedoActionCount(), i, lcl_ActionToJson(), m_xData, SfxUndoArray::maUndoActions, nCount, SfxUndoArray::nCurUndoAction, and nIndex.
OUString SfxUndoManager::GetRepeatActionComment | ( | SfxRepeatTarget & | rTarget | ) | const |
size_t SfxUndoManager::GetRepeatActionCount | ( | ) | const |
SfxUndoAction * SfxUndoManager::GetUndoAction | ( | size_t | nNo = 0 | ) | const |
OUString SfxUndoManager::GetUndoActionComment | ( | size_t | nNo = 0 , |
bool const | i_currentLevel = CurrentLevel |
||
) | const |
Definition at line 606 of file undo.cxx.
References m_xData, SfxUndoArray::maUndoActions, and SfxUndoArray::nCurUndoAction.
|
virtual |
Definition at line 598 of file undo.cxx.
References m_xData, and SfxUndoArray::nCurUndoAction.
Referenced by dumpAsXml(), and GetUndoActionsInfo().
OUString SfxUndoManager::GetUndoActionsInfo | ( | ) | const |
Get info about all undo actions (comment, view shell id, etc.)
Definition at line 1204 of file undo.cxx.
References GetUndoActionCount(), i, lcl_ActionToJson(), m_xData, SfxUndoArray::maUndoActions, and SfxUndoArray::nCurUndoAction.
bool SfxUndoManager::HasTopUndoActionMark | ( | UndoStackMark const | i_mark | ) |
determines whether the top action on the Undo stack has a given mark
Definition at line 1119 of file undo.cxx.
References MarkedUndoAction::aMarks, and m_xData.
|
private |
Definition at line 533 of file undo.cxx.
References CurrentLevel, ImplCheckEmptyActions(), ImplClearRedo(), ImplGetRedoActionCount_Lock(), ImplIsUndoEnabled_Lock(), m_xData, and SfxUndoAction::Merge().
Referenced by AddUndoAction(), and EnterListAction().
|
private |
Definition at line 1252 of file undo.cxx.
References EmptyActionsChanged(), ImplIsEmptyActions(), and m_xData.
Referenced by ImplAddUndoAction_NoNotify(), ImplClearCurrentLevel_NoNotify(), ImplClearRedo(), ImplClearUndo(), ImplRedo(), RemoveLastUndoAction(), RemoveOldestUndoAction(), and SetMaxUndoActionCount().
|
private |
Definition at line 418 of file undo.cxx.
References ImplCheckEmptyActions(), m_xData, and MARK_INVALID.
Referenced by Clear(), ClearAllLevels(), LeaveListAction(), and Reset().
|
private |
Definition at line 515 of file undo.cxx.
References SfxUndoListener::clearedRedo(), CurrentLevel, ImplCheckEmptyActions(), m_xData, SfxUndoArray::maUndoActions, SfxUndoArray::nCurUndoAction, SfxUndoArray::Remove(), TopLevel, and while().
Referenced by ImplAddUndoAction_NoNotify(), ImplClearRedo_NoLock(), ImplLeaveListAction(), and ImplRedo().
|
protected |
Definition at line 464 of file undo.cxx.
References ImplClearRedo(), and m_xData.
Referenced by ClearRedo().
|
private |
Definition at line 503 of file undo.cxx.
References ImplCheckEmptyActions(), and m_xData.
Referenced by ImplUndo().
|
private |
Definition at line 359 of file undo.cxx.
References m_xData.
Referenced by EnableUndo(), svl::undo::impl::LockGuard::LockGuard(), Reset(), and svl::undo::impl::LockGuard::~LockGuard().
|
private |
Definition at line 751 of file undo.cxx.
References m_xData, SfxUndoArray::maUndoActions, and SfxUndoArray::nCurUndoAction.
Referenced by GetRedoActionCount(), and ImplAddUndoAction_NoNotify().
|
inlineprivate |
Definition at line 1247 of file undo.cxx.
References m_xData.
Referenced by ImplCheckEmptyActions(), ImplLeaveListAction(), IsEmptyActions(), and SfxUndoManager().
|
private |
Definition at line 945 of file undo.cxx.
References m_xData.
Referenced by Clear(), ClearAllLevels(), ImplLeaveListAction(), ImplRedo(), ImplUndo(), IsInListAction(), and LeaveListAction().
|
private |
Definition at line 374 of file undo.cxx.
References m_xData.
Referenced by EnterListAction(), ImplAddUndoAction_NoNotify(), ImplLeaveListAction(), IsUndoEnabled(), and Reset().
|
private |
Definition at line 994 of file undo.cxx.
References CurrentLevel, ENSURE_OR_RETURN, SfxListUndoAction::GetComment(), ImplClearRedo(), ImplIsEmptyActions(), ImplIsInListAction_Lock(), ImplIsUndoEnabled_Lock(), SfxUndoArray::Insert(), SfxUndoListener::listActionCancelled(), SfxUndoListener::listActionLeft(), m_xData, SfxUndoArray::maUndoActions, n, SfxUndoArray::nCurUndoAction, SAL_WARN, SAL_WARN_IF, and SfxListUndoAction::SetComment().
Referenced by LeaveAndMergeListAction(), LeaveListAction(), and Reset().
|
private |
Definition at line 796 of file undo.cxx.
References SfxUndoListener::actionRedone(), CurrentLevel, SfxUndoAction::GetComment(), ImplCheckEmptyActions(), ImplClearRedo(), ImplIsInListAction_Lock(), IsDoing(), m_xData, SfxUndoAction::Redo(), SfxUndoAction::RedoWithContext(), and SAL_WARN.
Referenced by Redo(), and RedoWithContext().
|
private |
Definition at line 671 of file undo.cxx.
References SfxUndoListener::actionUndone(), SfxUndoAction::GetComment(), SfxUndoContext::GetUndoOffset(), ImplClearUndo(), ImplIsInListAction_Lock(), IsDoing(), m_xData, SAL_WARN, SfxUndoAction::Undo(), and SfxUndoAction::UndoWithContext().
Referenced by Undo(), and UndoWithContext().
bool SfxUndoManager::IsDoing | ( | ) | const |
determines whether an Undo or Redo is currently running
Definition at line 652 of file undo.cxx.
References m_xData.
Referenced by ImplRedo(), and ImplUndo().
bool SfxUndoManager::IsEmptyActions | ( | ) | const |
Definition at line 1240 of file undo.cxx.
References ImplIsEmptyActions(), and m_xData.
bool SfxUndoManager::IsInListAction | ( | ) | const |
determines whether we're within a ListAction context, i.e. a LeaveListAction/LeaveAndMergeListAction call is pending
Definition at line 938 of file undo.cxx.
References ImplIsInListAction_Lock(), and m_xData.
Referenced by ClearRedo(), MarkTopUndoAction(), RemoveOldestUndoAction(), and Reset().
bool SfxUndoManager::IsUndoEnabled | ( | ) | const |
size_t SfxUndoManager::LeaveAndMergeListAction | ( | ) |
Leaves the list action entered with EnterListAction, and forcefully merges the previous action on the stack into the newly created list action.
Say you have an Undo action A on the stack, then call EnterListAction, followed by one or more calls to AddUndoAction, followed by a call to LeaveAndMergeListAction. In opposite to LeaveListAction, your Undo stack will now still contain one undo action: the newly created list action, whose first child is the original A, whose other children are those you added via AddUndoAction, and whose comment is the same as the comment of A.
Effectively, this means that all actions added between EnterListAction and LeaveAndMergeListAction are hidden from the user.
Definition at line 987 of file undo.cxx.
References ImplLeaveListAction(), and m_xData.
size_t SfxUndoManager::LeaveListAction | ( | ) |
Leaves the list action entered with EnterListAction.
Definition at line 967 of file undo.cxx.
References SfxUndoListener::cleared(), ImplClearCurrentLevel_NoNotify(), ImplIsInListAction_Lock(), ImplLeaveListAction(), m_xData, and nCount.
UndoStackMark SfxUndoManager::MarkTopUndoAction | ( | ) |
marks the current top-level element of the Undo stack, and returns a unique ID for it
Definition at line 1068 of file undo.cxx.
References IsInListAction(), m_xData, and SAL_WARN_IF.
|
virtual |
Definition at line 784 of file undo.cxx.
References ImplRedo().
|
protected |
Definition at line 790 of file undo.cxx.
References ImplRedo().
void SfxUndoManager::RemoveLastUndoAction | ( | ) |
Clears the redo stack and removes the top undo action.
clears the redo stack and removes the top undo action
Definition at line 631 of file undo.cxx.
References ENSURE_OR_RETURN_VOID, ImplCheckEmptyActions(), m_xData, and nPos.
void SfxUndoManager::RemoveMark | ( | UndoStackMark const | i_mark | ) |
removes a mark given by its ID.
After the call, the mark ID is invalid.
Definition at line 1089 of file undo.cxx.
References MarkedUndoAction::aMarks, i, m_xData, MARK_INVALID, and SAL_WARN.
void SfxUndoManager::RemoveOldestUndoAction | ( | ) |
removes the oldest Undo actions from the stack
Definition at line 1136 of file undo.cxx.
References ImplCheckEmptyActions(), IsInListAction(), and m_xData.
void SfxUndoManager::RemoveUndoListener | ( | SfxUndoListener & | i_listener | ) |
bool SfxUndoManager::Repeat | ( | SfxRepeatTarget & | rTarget | ) |
Definition at line 870 of file undo.cxx.
References SfxUndoAction::CanRepeat(), m_xData, SfxUndoAction::Repeat(), and rTarget.
void SfxUndoManager::Reset | ( | void | ) |
leaves any possible open list action (<member>IsInListAction</member>), and clears both the Undo and the Redo stack.
Effectively, calling this method is equivalent to while ( IsInListAction() ) LeaveListAction();
, followed by Clear()
. The only difference to this calling sequence is that Reset is an atomic operation, also resulting in only one notification.
Definition at line 479 of file undo.cxx.
References ImplClearCurrentLevel_NoNotify(), ImplEnableUndo_Lock(), ImplIsUndoEnabled_Lock(), ImplLeaveListAction(), IsInListAction(), m_xData, and SfxUndoListener::resetAll().
void SfxUndoManager::SetMaxUndoActionCount | ( | size_t | nMaxUndoActionCount | ) |
Definition at line 379 of file undo.cxx.
References ImplCheckEmptyActions(), m_xData, and nPos.
|
virtual |
Definition at line 659 of file undo.cxx.
References ImplUndo().
|
protected |
Definition at line 665 of file undo.cxx.
References ImplUndo().
|
friend |
|
static |
Definition at line 194 of file undo.hxx.
Referenced by ClearRedo(), ImplAddUndoAction_NoNotify(), ImplClearRedo(), ImplLeaveListAction(), and ImplRedo().
|
private |
Definition at line 192 of file undo.hxx.
Referenced by AddUndoAction(), AddUndoListener(), CanRepeat(), Clear(), ClearAllLevels(), dumpAsXml(), EnableUndo(), EnterListAction(), GetListActionDepth(), GetMaxUndoActionCount(), GetRedoAction(), GetRedoActionComment(), GetRedoActionCount(), GetRedoActionsInfo(), GetRepeatActionComment(), GetRepeatActionCount(), GetUndoAction(), GetUndoActionComment(), GetUndoActionCount(), GetUndoActionsInfo(), HasTopUndoActionMark(), ImplAddUndoAction_NoNotify(), ImplCheckEmptyActions(), ImplClearCurrentLevel_NoNotify(), ImplClearRedo(), ImplClearRedo_NoLock(), ImplClearUndo(), ImplEnableUndo_Lock(), ImplGetRedoActionCount_Lock(), ImplIsEmptyActions(), ImplIsInListAction_Lock(), ImplIsUndoEnabled_Lock(), ImplLeaveListAction(), ImplRedo(), ImplUndo(), IsDoing(), IsEmptyActions(), IsInListAction(), IsUndoEnabled(), LeaveAndMergeListAction(), LeaveListAction(), MarkTopUndoAction(), RemoveLastUndoAction(), RemoveMark(), RemoveOldestUndoAction(), RemoveUndoListener(), Repeat(), Reset(), SetMaxUndoActionCount(), and SfxUndoManager().
|
static |
Definition at line 195 of file undo.hxx.
Referenced by ImplClearRedo().