LibreOffice Module sw (master)  1
Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
sw::UndoManager Class Reference

#include <UndoManager.hxx>

Inheritance diagram for sw::UndoManager:
[legend]
Collaboration diagram for sw::UndoManager:
[legend]

Public Member Functions

 UndoManager (std::shared_ptr< SwNodes > const &pUndoNodes, IDocumentDrawModelAccess &rDrawModelAccess, IDocumentRedlineAccess &rRedlineAccess, IDocumentState &rState)
 
virtual void DoUndo (bool const bDoUndo) override
 IDocumentUndoRedo. More...
 
virtual bool DoesUndo () const override
 Is Undo enabled? More...
 
virtual void DoGroupUndo (bool const bDoUndo) override
 Enable/Disable Group Undo. More...
 
virtual bool DoesGroupUndo () const override
 Is Group Undo enabled? More...
 
virtual void DoDrawUndo (bool const bDoUndo) override
 Enable/Disable Undo for Drawing objects. More...
 
virtual bool DoesDrawUndo () const override
 Is Undo for Drawing objects enabled? for Draw-Undo: writer wants to handle actions on Flys on its own. More...
 
void DoRepair (bool bRepair) override
 Enable repair mode. More...
 
bool DoesRepair () const override
 Is repair mode active? More...
 
virtual void SetUndoNoModifiedPosition () override
 Set the position at which the document is in the "unmodified" state to the current position in the Undo stack. More...
 
virtual void LockUndoNoModifiedPosition () override
 Prevent updates to the "unmodified" state position via SetUndoNoResetModified(). More...
 
virtual void UnLockUndoNoModifiedPosition () override
 Allow updates to the "unmodified" state position via SetUndoNoResetModified(). More...
 
virtual void SetUndoNoResetModified () override
 Disable (re)setting the document modified flag on Undo/Redo. More...
 
virtual bool IsUndoNoResetModified () const override
 Is setting the document modified flag on Undo/Redo disabled? More...
 
virtual SwUndoId StartUndo (SwUndoId const eUndoId, SwRewriter const *const pRewriter) override
 Opens undo block. More...
 
virtual SwUndoId EndUndo (SwUndoId const eUndoId, SwRewriter const *const pRewriter) override
 Closes undo block. More...
 
virtual void DelAllUndoObj () override
 Delete all Undo actions. More...
 
virtual bool GetLastUndoInfo (OUString *const o_pStr, SwUndoId *const o_pId, const SwView *pView=nullptr) const override
 Get Id and comment of last Undo action. More...
 
virtual SwUndoComments_t GetUndoComments () const override
 Get comments of Undo actions. More...
 
virtual bool GetFirstRedoInfo (OUString *const o_pStr, SwUndoId *const o_pId, const SwView *pView=nullptr) const override
 Get Id and comment of first Redo action. More...
 
virtual SwUndoComments_t GetRedoComments () const override
 Get comments of Redo actions. More...
 
virtual bool Repeat (::sw::RepeatContext &rContext, sal_uInt16 const nRepeatCnt) override
 N.B. More...
 
virtual SwUndoId GetRepeatInfo (OUString *const o_pStr) const override
 Get Id and comment of last Undo action, if it is Repeat capable. More...
 
virtual void AppendUndo (std::unique_ptr< SwUndo > pUndo) override
 Add new Undo action. More...
 
virtual void ClearRedo () override
 Delete all Redo actions. More...
 
virtual bool IsUndoNodes (SwNodes const &rNodes) const override
 
virtual size_t GetUndoActionCount (const bool bCurrentLevel=true) const override
 Get the number of Undo actions. More...
 
size_t GetRedoActionCount (const bool bCurrentLevel=true) const override
 
void SetView (SwView *pView) override
 Return undo/redo info for this view. More...
 
virtual void AddUndoAction (std::unique_ptr< SfxUndoAction > pAction, bool bTryMerg=false) override
 
virtual bool Undo () override
 
virtual bool Redo () override
 
SwUndoRemoveLastUndo ()
 
SwUndoGetLastUndo ()
 
SwNodes const & GetUndoNodes () const
 
SwNodesGetUndoNodes ()
 
void SetDocShell (SwDocShell *pDocShell)
 
- Public Member Functions inherited from SdrUndoManager
 SdrUndoManager ()
 
virtual ~SdrUndoManager () override
 
virtual void Clear () override
 
void SetEndTextEditHdl (const Link< SdrUndoManager *, void > &rLink)
 
bool isEndTextEditTriggeredFromUndo ()
 
void SetDocShell (SfxObjectShell *pDocShell)
 

Protected Member Functions

virtual void EmptyActionsChanged () override
 
- Protected Member Functions inherited from IDocumentUndoRedo
virtual ~IDocumentUndoRedo ()
 
- Protected Member Functions inherited from SdrUndoManager
bool isTextEditActive () const
 

Private Types

enum  UndoOrRedoType {
  UndoOrRedoType::Undo,
  UndoOrRedoType::Redo
}
 

Private Member Functions

bool impl_DoUndoRedo (UndoOrRedoType undoOrRedo)
 

Private Attributes

IDocumentDrawModelAccessm_rDrawModelAccess
 
IDocumentRedlineAccessm_rRedlineAccess
 
IDocumentStatem_rState
 
std::shared_ptr< SwNodesm_xUndoNodes
 Undo nodes array: content not currently in document. More...
 
bool m_bGroupUndo: 1
 
bool m_bDrawUndo: 1
 
bool m_bRepair
 If true, then repair mode is enabled. More...
 
bool m_bLockUndoNoModifiedPosition: 1
 
bool m_isAddWithIgnoreRepeat
 set the IgnoreRepeat flag on every added action More...
 
UndoStackMark m_UndoSaveMark
 position in Undo-Array at which Doc was saved (and is not modified) More...
 
SwDocShellm_pDocShell
 
SwViewm_pView
 

Detailed Description

Definition at line 36 of file UndoManager.hxx.

Member Enumeration Documentation

enum sw::UndoManager::UndoOrRedoType
strongprivate
Enumerator
Undo 
Redo 

Definition at line 120 of file UndoManager.hxx.

Constructor & Destructor Documentation

sw::UndoManager::UndoManager ( std::shared_ptr< SwNodes > const &  pUndoNodes,
IDocumentDrawModelAccess rDrawModelAccess,
IDocumentRedlineAccess rRedlineAccess,
IDocumentState rState 
)

Definition at line 51 of file docundo.cxx.

References m_xUndoNodes, and MARK_INVALID.

Member Function Documentation

void sw::UndoManager::AddUndoAction ( std::unique_ptr< SfxUndoAction pAction,
bool  bTryMerg = false 
)
overridevirtual
void sw::UndoManager::AppendUndo ( std::unique_ptr< SwUndo pUndo)
overridevirtual

Add new Undo action.

Takes over ownership of pUndo.

Remarks
calls ClearRedo(), except for SwUndoId::START/SwUndoId::END.
does nothing if !DoesUndo().

Implements IDocumentUndoRedo.

Definition at line 245 of file docundo.cxx.

References AddUndoAction().

void sw::UndoManager::ClearRedo ( )
overridevirtual

Delete all Redo actions.

Implements IDocumentUndoRedo.

Definition at line 250 of file docundo.cxx.

void sw::UndoManager::DelAllUndoObj ( )
overridevirtual

Delete all Undo actions.

Of course Undo will be disabled during deletion.

Implements IDocumentUndoRedo.

Definition at line 255 of file docundo.cxx.

References m_UndoSaveMark, and MARK_INVALID.

void sw::UndoManager::DoDrawUndo ( bool const  bDoUndo)
overridevirtual

Enable/Disable Undo for Drawing objects.

Implements IDocumentUndoRedo.

Definition at line 183 of file docundo.cxx.

References m_bDrawUndo.

bool sw::UndoManager::DoesDrawUndo ( ) const
overridevirtual

Is Undo for Drawing objects enabled? for Draw-Undo: writer wants to handle actions on Flys on its own.

Implements IDocumentUndoRedo.

Definition at line 188 of file docundo.cxx.

References m_bDrawUndo.

bool sw::UndoManager::DoesGroupUndo ( ) const
overridevirtual

Is Group Undo enabled?

Implements IDocumentUndoRedo.

Definition at line 178 of file docundo.cxx.

References m_bGroupUndo.

bool sw::UndoManager::DoesRepair ( ) const
overridevirtual

Is repair mode active?

Implements IDocumentUndoRedo.

Definition at line 198 of file docundo.cxx.

References m_bRepair.

bool sw::UndoManager::DoesUndo ( ) const
overridevirtual

Is Undo enabled?

Implements IDocumentUndoRedo.

Definition at line 161 of file docundo.cxx.

References SdrUndoManager::isTextEditActive().

Referenced by Repeat().

void sw::UndoManager::DoGroupUndo ( bool const  bDoUndo)
overridevirtual

Enable/Disable Group Undo.

This determines whether successive Insert/Delete/Overwrite actions are combined.

Implements IDocumentUndoRedo.

Definition at line 173 of file docundo.cxx.

References m_bGroupUndo.

void sw::UndoManager::DoRepair ( bool  bRepair)
overridevirtual

Enable repair mode.

Implements IDocumentUndoRedo.

Definition at line 193 of file docundo.cxx.

References m_bRepair.

void sw::UndoManager::DoUndo ( bool const  bDoUndo)
overridevirtual
void sw::UndoManager::EmptyActionsChanged ( )
overrideprotectedvirtual

Reimplemented from SdrUndoManager.

Definition at line 642 of file docundo.cxx.

References m_pDocShell.

SwUndoId sw::UndoManager::EndUndo ( SwUndoId const  eUndoId,
SwRewriter const *const  pRewriter 
)
overridevirtual

Closes undo block.

Remarks
StartUndo() and EndUndo() do nothing if !DoesUndo().
Parameters
nUndoIdundo ID for the list action
pRewriterrewriter for comments
See also
SwUndo::GetComment

If the given nUndoId is not SwUndoId::EMPTY or SwUndoId::END, the comment of the resulting list action will be set via the nUndoId, applying the given pRewriter (if not 0). Otherwise the comment of the resulting list action is unchanged if it has an UndoId that is not SwUndoId::START set by StartUndo, and in case the UndoId is SwUndoId::START the comment of the list action defaults to the comment of the last action contained in the list action.

Implements IDocumentUndoRedo.

Definition at line 297 of file docundo.cxx.

References SwRewriter::Apply(), EMPTY, END, SfxUndoAction::GetComment(), GetUndoComment(), and START.

bool sw::UndoManager::GetFirstRedoInfo ( OUString *const  o_pStr,
SwUndoId *const  o_pId,
const SwView pView = nullptr 
) const
overridevirtual

Get Id and comment of first Redo action.

Parameters
o_pStrif not 0, receives comment of first Redo action.
o_pIdif not 0, receives Id of first Redo action.
pViewif not nullptr, get the info for this view
Returns
true if there is a Redo action, false if none

Implements IDocumentUndoRedo.

Definition at line 416 of file docundo.cxx.

References CONFLICT, EMPTY, SfxUndoAction::GetComment(), SwDocShell::GetView(), SfxViewShell::GetViewShellId(), SfxUndoAction::GetViewShellId(), comphelper::LibreOfficeKit::isActive(), m_bRepair, and m_pDocShell.

SwUndo * sw::UndoManager::GetLastUndo ( )
bool sw::UndoManager::GetLastUndoInfo ( OUString *const  o_pStr,
SwUndoId *const  o_pId,
const SwView pView = nullptr 
) const
overridevirtual

Get Id and comment of last Undo action.

Parameters
o_pStrif not 0, receives comment of last Undo action.
o_pIdif not 0, receives Id of last Undo action.
pViewif not nullptr, get the info for this view
Returns
true if there is a Undo action, false if none

Implements IDocumentUndoRedo.

Definition at line 356 of file docundo.cxx.

References CONFLICT, EMPTY, SfxUndoAction::GetComment(), SwDocShell::GetView(), SfxViewShell::GetViewShellId(), SfxUndoAction::GetViewShellId(), comphelper::LibreOfficeKit::isActive(), m_bRepair, and m_pDocShell.

Referenced by GetRepeatInfo().

size_t sw::UndoManager::GetRedoActionCount ( const bool  bCurrentLevel = true) const
override
SwUndoComments_t sw::UndoManager::GetRedoComments ( ) const
overridevirtual

Get comments of Redo actions.

Returns
comments of all top-level Redo actions.

Implements IDocumentUndoRedo.

Definition at line 462 of file docundo.cxx.

SwUndoId sw::UndoManager::GetRepeatInfo ( OUString *const  o_pStr) const
overridevirtual

Get Id and comment of last Undo action, if it is Repeat capable.

Parameters
o_pStrif not 0, receives comment of last Undo action if it is Repeat capable.
Returns
Id of last Undo action if it is Repeat capable, or SwUndoId::EMPTY if there is none or it is not Repeat capable.

Implements IDocumentUndoRedo.

Definition at line 479 of file docundo.cxx.

References EMPTY, and GetLastUndoInfo().

size_t sw::UndoManager::GetUndoActionCount ( const bool  bCurrentLevel = true) const
overridevirtual

Get the number of Undo actions.

Implements IDocumentUndoRedo.

Definition at line 99 of file docundo.cxx.

References SfxViewShell::GetViewShellId(), SfxUndoAction::GetViewShellId(), comphelper::LibreOfficeKit::isActive(), m_bRepair, and m_pView.

SwUndoComments_t sw::UndoManager::GetUndoComments ( ) const
overridevirtual

Get comments of Undo actions.

Returns
comments of all top-level Undo actions.

Implements IDocumentUndoRedo.

Definition at line 399 of file docundo.cxx.

SwNodes const & sw::UndoManager::GetUndoNodes ( ) const
SwNodes & sw::UndoManager::GetUndoNodes ( )

Definition at line 79 of file docundo.cxx.

References m_xUndoNodes.

bool sw::UndoManager::impl_DoUndoRedo ( UndoOrRedoType  undoOrRedo)
private
bool sw::UndoManager::IsUndoNodes ( SwNodes const &  rNodes) const
overridevirtual

Implements IDocumentUndoRedo.

Definition at line 84 of file docundo.cxx.

References m_xUndoNodes.

bool sw::UndoManager::IsUndoNoResetModified ( ) const
overridevirtual

Is setting the document modified flag on Undo/Redo disabled?

Implements IDocumentUndoRedo.

Definition at line 203 of file docundo.cxx.

References m_UndoSaveMark, and MARK_INVALID.

void sw::UndoManager::LockUndoNoModifiedPosition ( )
overridevirtual

Prevent updates to the "unmodified" state position via SetUndoNoResetModified().

Implements IDocumentUndoRedo.

Definition at line 225 of file docundo.cxx.

References m_bLockUndoNoModifiedPosition.

bool sw::UndoManager::Redo ( )
overridevirtual

Reimplemented from SdrUndoManager.

Definition at line 630 of file docundo.cxx.

References impl_DoUndoRedo(), SdrUndoManager::isTextEditActive(), SdrUndoManager::Redo(), and Redo.

SwUndo * sw::UndoManager::RemoveLastUndo ( )

Definition at line 494 of file docundo.cxx.

Referenced by SwDoc::MergeTable().

bool sw::UndoManager::Repeat ( ::sw::RepeatContext rContext,
sal_uInt16 const  nRepeatCount 
)
overridevirtual

N.B.

: this does not call SdrUndoManager::Repeat because it is not possible to wrap a list action around it: calling EnterListAction here will cause SdrUndoManager::Repeat to repeat the list action!

Implements IDocumentUndoRedo.

Definition at line 655 of file docundo.cxx.

References SfxUndoAction::CanRepeat(), DoesUndo(), SfxUndoAction::GetComment(), SfxUndoAction::GetRepeatComment(), sw::RepeatContext::GetRepeatPaM(), sw::Ring< value_type >::GetRingContainer(), SwDocShell::GetView(), sw::RepeatContext::m_bDeleteRepeated, m_isAddWithIgnoreRepeat, sw::RepeatContext::m_pCurrentPaM, m_pDocShell, nId, and SfxUndoAction::Repeat().

void sw::UndoManager::SetDocShell ( SwDocShell pDocShell)

Definition at line 89 of file docundo.cxx.

References m_pDocShell.

Referenced by SwDoc::SetDocShell().

void sw::UndoManager::SetUndoNoModifiedPosition ( )
overridevirtual

Set the position at which the document is in the "unmodified" state to the current position in the Undo stack.

Implements IDocumentUndoRedo.

Definition at line 217 of file docundo.cxx.

References m_bLockUndoNoModifiedPosition, and m_UndoSaveMark.

void sw::UndoManager::SetUndoNoResetModified ( )
overridevirtual

Disable (re)setting the document modified flag on Undo/Redo.

Implements IDocumentUndoRedo.

Definition at line 208 of file docundo.cxx.

References m_UndoSaveMark, and MARK_INVALID.

void sw::UndoManager::SetView ( SwView pView)
overridevirtual

Return undo/redo info for this view.

Implements IDocumentUndoRedo.

Definition at line 94 of file docundo.cxx.

References m_pView.

SwUndoId sw::UndoManager::StartUndo ( SwUndoId const  eUndoId,
SwRewriter const *const  pRewriter 
)
overridevirtual

Opens undo block.

Remarks
StartUndo() and EndUndo() do nothing if !DoesUndo().
Parameters
nUndoIdundo ID for the list action
pRewriterrewriter for comments
See also
SwUndo::GetComment

If the given nUndoId is equal to zero an undo object with ID SwUndoId::START will be generated.

Returns
the undo ID of the created object

Implements IDocumentUndoRedo.

Definition at line 265 of file docundo.cxx.

References SwRewriter::Apply(), EMPTY, END, GetUndoComment(), SwDocShell::GetView(), m_pDocShell, and START.

bool sw::UndoManager::Undo ( )
overridevirtual

Reimplemented from SdrUndoManager.

Definition at line 618 of file docundo.cxx.

References impl_DoUndoRedo(), SdrUndoManager::isTextEditActive(), SdrUndoManager::Undo(), and Undo.

void sw::UndoManager::UnLockUndoNoModifiedPosition ( )
overridevirtual

Allow updates to the "unmodified" state position via SetUndoNoResetModified().

Implements IDocumentUndoRedo.

Definition at line 230 of file docundo.cxx.

References m_bLockUndoNoModifiedPosition.

Member Data Documentation

bool sw::UndoManager::m_bDrawUndo
private

Definition at line 109 of file UndoManager.hxx.

Referenced by DoDrawUndo(), and DoesDrawUndo().

bool sw::UndoManager::m_bGroupUndo
private

Definition at line 108 of file UndoManager.hxx.

Referenced by DoesGroupUndo(), and DoGroupUndo().

bool sw::UndoManager::m_bLockUndoNoModifiedPosition
private
bool sw::UndoManager::m_bRepair
private

If true, then repair mode is enabled.

Definition at line 111 of file UndoManager.hxx.

Referenced by DoesRepair(), DoRepair(), GetFirstRedoInfo(), GetLastUndoInfo(), GetRedoActionCount(), and GetUndoActionCount().

bool sw::UndoManager::m_isAddWithIgnoreRepeat
private

set the IgnoreRepeat flag on every added action

Definition at line 114 of file UndoManager.hxx.

Referenced by AddUndoAction(), and Repeat().

SwDocShell* sw::UndoManager::m_pDocShell
private
SwView* sw::UndoManager::m_pView
private

Definition at line 118 of file UndoManager.hxx.

Referenced by GetRedoActionCount(), GetUndoActionCount(), and SetView().

IDocumentDrawModelAccess& sw::UndoManager::m_rDrawModelAccess
private

Definition at line 101 of file UndoManager.hxx.

Referenced by DoUndo().

IDocumentRedlineAccess& sw::UndoManager::m_rRedlineAccess
private

Definition at line 102 of file UndoManager.hxx.

Referenced by AddUndoAction().

IDocumentState& sw::UndoManager::m_rState
private

Definition at line 103 of file UndoManager.hxx.

Referenced by impl_DoUndoRedo().

UndoStackMark sw::UndoManager::m_UndoSaveMark
private

position in Undo-Array at which Doc was saved (and is not modified)

Definition at line 116 of file UndoManager.hxx.

Referenced by DelAllUndoObj(), impl_DoUndoRedo(), IsUndoNoResetModified(), SetUndoNoModifiedPosition(), and SetUndoNoResetModified().

std::shared_ptr<SwNodes> sw::UndoManager::m_xUndoNodes
private

Undo nodes array: content not currently in document.

Definition at line 106 of file UndoManager.hxx.

Referenced by GetUndoNodes(), IsUndoNodes(), and UndoManager().


The documentation for this class was generated from the following files: