summaryrefslogtreecommitdiff
path: root/include/svl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-07-12 09:42:07 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-07-13 08:39:15 +0200
commit2d71dd52b6d91660cda6cb8f9457463439f56e20 (patch)
treef894d34e604eee2db24978c85ba67b9da0a4d573 /include/svl
parentddef60b9c26b1d2990c6c49dbbda73e7831f21fb (diff)
merge IUndoManager into SfxUndoManager
SfxUndoManager is the only implementation of the IUnderManager "interface", and it lives in the same header. Plus this way we can get rid of some covariant parameters, which will make using std::unique_ptr easier. Change-Id: I6661b9876b18da830bead78794d237886cd3c5c9 Reviewed-on: https://gerrit.libreoffice.org/57317 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include/svl')
-rw-r--r--include/svl/undo.hxx240
1 files changed, 89 insertions, 151 deletions
diff --git a/include/svl/undo.hxx b/include/svl/undo.hxx
index e91aca41a69a..fea14a7b6bb1 100644
--- a/include/svl/undo.hxx
+++ b/include/svl/undo.hxx
@@ -181,122 +181,6 @@ protected:
};
-namespace svl
-{
- class SAL_NO_VTABLE SAL_DLLPUBLIC_RTTI IUndoManager
- {
- public:
- static bool const CurrentLevel = true;
- static bool const TopLevel = false;
-
- virtual ~IUndoManager() { };
-
- virtual void SetMaxUndoActionCount( size_t nMaxUndoActionCount ) = 0;
-
- virtual void AddUndoAction( SfxUndoAction *pAction, bool bTryMerg=false ) = 0;
-
- virtual size_t GetUndoActionCount( bool const i_currentLevel = CurrentLevel ) const = 0;
- virtual OUString GetUndoActionComment( size_t nNo=0, bool const i_currentLevel = CurrentLevel ) const = 0;
- virtual SfxUndoAction* GetUndoAction( size_t nNo=0 ) const = 0;
- /// Get info about all undo actions (comment, view shell id, etc.)
- virtual OUString GetUndoActionsInfo() const = 0;
-
- virtual size_t GetRedoActionCount( bool const i_currentLevel = CurrentLevel ) const = 0;
- virtual OUString GetRedoActionComment( size_t nNo=0, bool const i_currentLevel = CurrentLevel ) const = 0;
- virtual SfxUndoAction* GetRedoAction() const = 0;
- /// Get info about all redo actions (comment, view shell id, etc.)
- virtual OUString GetRedoActionsInfo() const = 0;
-
- virtual bool Undo() = 0;
- virtual bool Redo() = 0;
-
- /** clears both the Redo and the Undo stack.
-
- Will assert and bail out when called while within a list action (<member>IsInListAction</member>).
- */
- virtual void Clear() = 0;
-
- /** clears the Redo stack.
-
- Will assert and bail out when called while within a list action (<member>IsInListAction</member>).
- */
- virtual void ClearRedo() = 0;
-
- /** 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 <code>while ( IsInListAction() ) LeaveListAction();</code>,
- followed by <code>Clear()</code>. The only difference to this calling sequence is that Reset is an
- atomic operation, also resulting in only one notification.
- */
- virtual void Reset() = 0;
-
- /** determines whether an Undo or Redo is currently running
- */
- virtual bool IsDoing() const = 0;
-
- virtual size_t GetRepeatActionCount() const = 0;
- virtual OUString GetRepeatActionComment( SfxRepeatTarget &rTarget) const = 0;
- virtual bool Repeat( SfxRepeatTarget &rTarget ) = 0;
- virtual bool CanRepeat( SfxRepeatTarget &rTarget ) const = 0;
-
- virtual void EnterListAction(const OUString &rComment, const OUString& rRepeatComment, sal_uInt16 nId, ViewShellId nViewShellId) = 0;
-
- /** leaves the list action entered with EnterListAction
- @return the number of the sub actions in the list which has just been left. Note that in case no such
- actions exist, the list action does not contribute to the Undo stack, but is silently removed.
- */
- virtual size_t LeaveListAction() = 0;
-
- /** 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.
-
- @return the number of the sub actions in the list which has just been left. Note that in case no such
- actions exist, the list action does not contribute to the Undo stack, but is silently removed.
- */
- virtual size_t LeaveAndMergeListAction() = 0;
-
- /// determines whether we're within a ListAction context, i.e. a LeaveListAction/LeaveAndMergeListAction call is pending
- virtual bool IsInListAction() const = 0;
-
- /// determines how many nested list actions are currently open
- virtual size_t GetListActionDepth() const = 0;
-
- /** clears the redo stack and removes the top undo action */
- virtual void RemoveLastUndoAction() = 0;
-
- /** 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 <code>EnableUndo</code> are not cumulative. That is, calling <code>EnableUndo( false )</code>
- twice, and then calling <code>EnableUndo( true )</code> means that Undo is enable afterwards.
- */
- virtual void EnableUndo( bool bEnable ) = 0;
-
- // returns true if undo is currently enabled
- // This returns false if undo was disabled using EnableUndo( false ) and
- // also during the runtime of the Undo() and Redo() methods.
- virtual bool IsUndoEnabled() const = 0;
-
- /// adds a new listener to be notified about changes in the UndoManager's state
- virtual void AddUndoListener( SfxUndoListener& i_listener ) = 0;
- virtual void RemoveUndoListener( SfxUndoListener& i_listener ) = 0;
- virtual bool IsEmptyActions() const = 0;
- };
-}
-
-
namespace svl { namespace undo { namespace impl
{
class UndoManagerGuard;
@@ -304,46 +188,100 @@ namespace svl { namespace undo { namespace impl
} } }
struct SfxUndoManager_Data;
-class SVL_DLLPUBLIC SfxUndoManager : public ::svl::IUndoManager
+class SVL_DLLPUBLIC SfxUndoManager
{
std::unique_ptr< SfxUndoManager_Data >
m_xData;
public:
+ static bool const CurrentLevel = true;
+ static bool const TopLevel = false;
+
SfxUndoManager( size_t nMaxUndoActionCount = 20 );
- virtual ~SfxUndoManager() override;
-
- // IUndoManager overridables
- virtual void SetMaxUndoActionCount( size_t nMaxUndoActionCount ) override;
- virtual void AddUndoAction( SfxUndoAction *pAction, bool bTryMerg=false ) override;
- virtual size_t GetUndoActionCount( bool const i_currentLevel = CurrentLevel ) const override;
- virtual OUString GetUndoActionComment( size_t nNo=0, bool const i_currentLevel = CurrentLevel ) const override;
- virtual SfxUndoAction* GetUndoAction( size_t nNo=0 ) const override;
- OUString GetUndoActionsInfo() const override;
- virtual size_t GetRedoActionCount( bool const i_currentLevel = CurrentLevel ) const override;
- virtual OUString GetRedoActionComment( size_t nNo=0, bool const i_currentLevel = CurrentLevel ) const override;
- virtual SfxUndoAction* GetRedoAction() const override;
- OUString GetRedoActionsInfo() const override;
- virtual bool Undo() override;
- virtual bool Redo() override;
- virtual void Clear() override;
- virtual void ClearRedo() override;
- virtual void Reset() override;
- virtual bool IsDoing() const override;
- virtual size_t GetRepeatActionCount() const override;
- virtual OUString GetRepeatActionComment( SfxRepeatTarget &rTarget) const override;
- virtual bool Repeat( SfxRepeatTarget &rTarget ) override;
- virtual bool CanRepeat( SfxRepeatTarget &rTarget ) const override;
- virtual void EnterListAction(const OUString &rComment, const OUString& rRepeatComment, sal_uInt16 nId, ViewShellId nViewShellId) override;
- virtual size_t LeaveListAction() override;
- virtual size_t LeaveAndMergeListAction() override;
- virtual bool IsInListAction() const override;
- virtual size_t GetListActionDepth() const override;
- virtual void RemoveLastUndoAction() override;
- virtual void EnableUndo( bool bEnable ) override;
- virtual bool IsUndoEnabled() const override;
- virtual void AddUndoListener( SfxUndoListener& i_listener ) override;
- virtual void RemoveUndoListener( SfxUndoListener& i_listener ) override;
- virtual bool IsEmptyActions() const override;
+ virtual ~SfxUndoManager();
+
+ virtual void SetMaxUndoActionCount( size_t nMaxUndoActionCount );
+ virtual void AddUndoAction( SfxUndoAction *pAction, bool bTryMerg=false );
+ virtual size_t GetUndoActionCount( bool const i_currentLevel = CurrentLevel ) const;
+ virtual OUString GetUndoActionComment( size_t nNo=0, bool const i_currentLevel = CurrentLevel ) const;
+ virtual SfxUndoAction* GetUndoAction( size_t nNo=0 ) const;
+ /// Get info about all undo actions (comment, view shell id, etc.)
+ OUString GetUndoActionsInfo() const;
+ virtual size_t GetRedoActionCount( bool const i_currentLevel = CurrentLevel ) const;
+ virtual OUString GetRedoActionComment( size_t nNo=0, bool const i_currentLevel = CurrentLevel ) const;
+ virtual SfxUndoAction* GetRedoAction() const;
+ /// Get info about all redo actions (comment, view shell id, etc.)
+ OUString GetRedoActionsInfo() const;
+ virtual bool Undo();
+ virtual bool Redo();
+ /** Clears both the Redo and the Undo stack.
+ Will assert and bail out when called while within a list action (<member>IsInListAction</member>).
+ */
+ virtual void Clear();
+ /** Clears the Redo stack.
+ Will assert and bail out when called while within a list action (<member>IsInListAction</member>).
+ */
+ virtual void ClearRedo();
+ /** 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 <code>while ( IsInListAction() ) LeaveListAction();</code>,
+ followed by <code>Clear()</code>. The only difference to this calling sequence is that Reset is an
+ atomic operation, also resulting in only one notification.
+ */
+ virtual void Reset();
+ /** determines whether an Undo or Redo is currently running
+ */
+ virtual bool IsDoing() const;
+ virtual size_t GetRepeatActionCount() const;
+ virtual OUString GetRepeatActionComment( SfxRepeatTarget &rTarget) const;
+ virtual bool Repeat( SfxRepeatTarget &rTarget );
+ virtual bool CanRepeat( SfxRepeatTarget &rTarget ) const;
+ virtual void EnterListAction(const OUString &rComment, const OUString& rRepeatComment, sal_uInt16 nId, ViewShellId nViewShellId);
+ /** Leaves the list action entered with EnterListAction
+ @return the number of the sub actions in the list which has just been left. Note that in case no such
+ actions exist, the list action does not contribute to the Undo stack, but is silently removed.
+ */
+ virtual size_t LeaveListAction();
+
+ /** 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.
+
+ @return the number of the sub actions in the list which has just been left. Note that in case no such
+ actions exist, the list action does not contribute to the Undo stack, but is silently removed.
+ */
+ virtual size_t LeaveAndMergeListAction();
+ /// determines whether we're within a ListAction context, i.e. a LeaveListAction/LeaveAndMergeListAction call is pending
+ virtual bool IsInListAction() const;
+ /// Determines how many nested list actions are currently open
+ virtual size_t GetListActionDepth() const;
+ /** Clears the redo stack and removes the top undo action */
+ virtual void RemoveLastUndoAction();
+ /** 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 <code>EnableUndo</code> are not cumulative. That is, calling <code>EnableUndo( false )</code>
+ twice, and then calling <code>EnableUndo( true )</code> means that Undo is enable afterwards.
+ */
+ virtual void EnableUndo( bool bEnable );
+ /// returns true if undo is currently enabled.
+ /// This returns false if undo was disabled using EnableUndo( false ) and
+ /// also during the runtime of the Undo() and Redo() methods.
+ virtual bool IsUndoEnabled() const;
+ /// Adds a new listener to be notified about changes in the UndoManager's state
+ virtual void AddUndoListener( SfxUndoListener& i_listener );
+ virtual void RemoveUndoListener( SfxUndoListener& i_listener );
+ virtual bool IsEmptyActions() const;
/** marks the current top-level element of the Undo stack, and returns a unique ID for it