diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/editeng/editeng.hxx | 6 | ||||
-rw-r--r-- | include/editeng/outliner.hxx | 9 | ||||
-rw-r--r-- | include/framework/undomanagerhelper.hxx | 23 | ||||
-rw-r--r-- | include/sfx2/shell.hxx | 12 | ||||
-rw-r--r-- | include/svl/undo.hxx | 240 | ||||
-rw-r--r-- | include/svx/svdedxv.hxx | 2 | ||||
-rw-r--r-- | include/vcl/texteng.hxx | 10 |
7 files changed, 112 insertions, 190 deletions
diff --git a/include/editeng/editeng.hxx b/include/editeng/editeng.hxx index 52a052570dd0..a94cf2abd0fb 100644 --- a/include/editeng/editeng.hxx +++ b/include/editeng/editeng.hxx @@ -62,7 +62,7 @@ struct SpellPortion; typedef std::vector<SpellPortion> SpellPortions; } -namespace svl { class IUndoManager; } +class SfxUndoManager; namespace basegfx { class B2DPolyPolygon; } namespace editeng { struct MisspellRanges; @@ -337,8 +337,8 @@ public: void ShowParagraph( sal_Int32 nParagraph, bool bShow ); - ::svl::IUndoManager& GetUndoManager(); - ::svl::IUndoManager* SetUndoManager(::svl::IUndoManager* pNew); + SfxUndoManager& GetUndoManager(); + SfxUndoManager* SetUndoManager(SfxUndoManager* pNew); void UndoActionStart( sal_uInt16 nId ); void UndoActionStart(sal_uInt16 nId, const ESelection& rSel); void UndoActionEnd(); diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx index c0d4a9a82437..d534b8862771 100644 --- a/include/editeng/outliner.hxx +++ b/include/editeng/outliner.hxx @@ -87,11 +87,8 @@ class OutlinerViewShell; enum class CharCompressType; enum class TransliterationFlags; class SvxFieldData; +class SfxUndoManager; -namespace svl -{ - class IUndoManager; -} namespace com { namespace sun { namespace star { namespace linguistic2 { class XSpellChecker1; class XHyphenator; @@ -881,8 +878,8 @@ public: ErrCode Read( SvStream& rInput, const OUString& rBaseURL, EETextFormat, SvKeyValueIterator* pHTTPHeaderAttrs = nullptr ); - ::svl::IUndoManager& GetUndoManager(); - ::svl::IUndoManager* SetUndoManager(::svl::IUndoManager* pNew); + SfxUndoManager& GetUndoManager(); + SfxUndoManager* SetUndoManager(SfxUndoManager* pNew); void QuickSetAttribs( const SfxItemSet& rSet, const ESelection& rSel ); void QuickInsertField( const SvxFieldItem& rFld, const ESelection& rSel ); diff --git a/include/framework/undomanagerhelper.hxx b/include/framework/undomanagerhelper.hxx index 09ac28b01fd2..261936a862e9 100644 --- a/include/framework/undomanagerhelper.hxx +++ b/include/framework/undomanagerhelper.hxx @@ -28,10 +28,7 @@ #include <memory> -namespace svl -{ - class IUndoManager; -} +class SfxUndoManager; namespace framework @@ -63,15 +60,15 @@ namespace framework class SAL_NO_VTABLE IUndoManagerImplementation { public: - /** returns the IUndoManager interface to the actual Undo stack + /** returns the SfxUndoManager interface to the actual Undo stack @throws css::lang::DisposedException - when the instance is already disposed, and no IUndoManager can be provided + when the instance is already disposed, and no SfxUndoManager can be provided @throws css::lang::NotInitializedException - when the instance is not initialized, yet, and no IUndoManager can be provided + when the instance is not initialized, yet, and no SfxUndoManager can be provided */ - virtual ::svl::IUndoManager& getImplUndoManager() = 0; + virtual SfxUndoManager& getImplUndoManager() = 0; /** provides access to an UNO interface for the XUndoManager implementation. Used when throwing exceptions. */ @@ -95,15 +92,15 @@ namespace framework The following locking strategy is used for this mutex: <ul><li>Any notifications to the registered XUndoManagerListeners are after the guard has been cleared. i.e. without the mutex being locked.</p> - <li>Any calls into the <code>IUndoManager</code> implementation is made without the mutex being locked. - Note that this implies that the <code>IUndoManager</code> implementation must be thread-safe in itself + <li>Any calls into the <code>SfxUndoManager</code> implementation is made without the mutex being locked. + Note that this implies that the <code>SfxUndoManager</code> implementation must be thread-safe in itself (which is true for the default implementation, SfxUndoManager).</li> - <li>An exception to the previous item are the <member>IUndoManager::Undo</member> and - <member>IUndoManager::Redo</member> methods: They're called with the given external mutex being + <li>An exception to the previous item are the <member>SfxUndoManager::Undo</member> and + <member>SfxUndoManager::Redo</member> methods: They're called with the given external mutex being locked.</li> </ul> - The reason for the exception for IUndoManager::Undo and IUndoManager::Redo is that those are expected to + The reason for the exception for SfxUndoManager::Undo and SfxUndoManager::Redo is that those are expected to modify the actual document which the UndoManager works for. And as long as our documents are not thread-safe, and as long as we do not re-fit <strong>all</strong> existing SfxUndoImplementations to <em>not</em> expect the dreaded SolarMutex being locked when they're called, the above behavior is a compromise between "how it should diff --git a/include/sfx2/shell.hxx b/include/sfx2/shell.hxx index 7aeeed54bdd2..d2d72093338a 100644 --- a/include/sfx2/shell.hxx +++ b/include/sfx2/shell.hxx @@ -57,11 +57,7 @@ class SbxVariable; class SbxBase; class SfxBindings; class SfxModule; - -namespace svl -{ - class IUndoManager; -} +class SfxUndoManager; /** Id for <SfxInterface>s, gives a quasi-static access to the interface @@ -143,7 +139,7 @@ class SFX2_DLLPUBLIC SfxShell: public SfxBroadcaster std::unique_ptr< SfxShell_Impl > pImpl; SfxItemPool* pPool; - ::svl::IUndoManager* pUndoMgr; + SfxUndoManager* pUndoMgr; private: SfxShell( const SfxShell & ) = delete; @@ -298,7 +294,7 @@ public: The class SfxShell itself does not have a SfxUndoManager, a NULL-pointer is therefore returned. */ - virtual ::svl::IUndoManager* GetUndoManager(); + virtual SfxUndoManager* GetUndoManager(); /** Sets a <SfxUndoManager> for this <SfxShell> Instance. For the undo @@ -311,7 +307,7 @@ public: 'pNewUndoMgr' must exist until the Destructor of SfxShell instance is called or until the next 'SetUndoManager()'. */ - void SetUndoManager( ::svl::IUndoManager *pNewUndoMgr ); + void SetUndoManager( SfxUndoManager *pNewUndoMgr ); /** Returns a pointer to the <SfxRepeatTarget> instance that is used in 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 diff --git a/include/svx/svdedxv.hxx b/include/svx/svdedxv.hxx index 6a2a1f5de509..b7f5eb31caae 100644 --- a/include/svx/svdedxv.hxx +++ b/include/svx/svdedxv.hxx @@ -102,7 +102,7 @@ protected: rtl::Reference< sdr::SelectionController > mxLastSelectionController; private: - ::svl::IUndoManager* mpOldTextEditUndoManager; + SfxUndoManager* mpOldTextEditUndoManager; SVX_DLLPRIVATE void ImpClearVars(); diff --git a/include/vcl/texteng.hxx b/include/vcl/texteng.hxx index 82a60c7af122..97a370747ce8 100644 --- a/include/vcl/texteng.hxx +++ b/include/vcl/texteng.hxx @@ -54,12 +54,7 @@ class OutputDevice; class SfxUndoAction; class KeyEvent; class Timer; - -namespace svl -{ - class IUndoManager; -} - +class SfxUndoManager; class TextLine; class TETextPortion; struct TEIMEInfos; @@ -267,8 +262,7 @@ public: bool IsRightToLeft() const { return mbRightToLeft; } bool HasUndoManager() const { return mpUndoManager != nullptr; } - ::svl::IUndoManager& - GetUndoManager(); + SfxUndoManager& GetUndoManager(); void UndoActionStart( sal_uInt16 nId = 0 ); void UndoActionEnd(); void InsertUndo( TextUndo* pUndo, bool bTryMerge = false ); |