diff options
author | Michael Stahl <mst@openoffice.org> | 2010-11-25 14:31:09 +0100 |
---|---|---|
committer | Michael Stahl <mst@openoffice.org> | 2010-11-25 14:31:09 +0100 |
commit | 0fcdedd36417d76441081b53814d40772e03e841 (patch) | |
tree | c43935a6d3e6c04c1cd6737328f5582300ca6a21 /sw/inc/IDocumentUndoRedo.hxx | |
parent | c8c50a05e2ec57fe46bb4e54013c0b3cbd0b3b3b (diff) |
unodapi: #i114888#: sw: introduce sw::UndoGuard, sw::GroupUndoGuard, clean up
Diffstat (limited to 'sw/inc/IDocumentUndoRedo.hxx')
-rw-r--r-- | sw/inc/IDocumentUndoRedo.hxx | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/sw/inc/IDocumentUndoRedo.hxx b/sw/inc/IDocumentUndoRedo.hxx index a224395429a9..ea3b4d7337f3 100644 --- a/sw/inc/IDocumentUndoRedo.hxx +++ b/sw/inc/IDocumentUndoRedo.hxx @@ -189,5 +189,55 @@ protected: virtual ~IDocumentUndoRedo() {}; }; + +namespace sw { + +class UndoGuard +{ +public: + + UndoGuard(IDocumentUndoRedo & rUndoRedo) + : m_rUndoRedo(rUndoRedo) + , m_bUndoWasEnabled(rUndoRedo.DoesUndo()) + { + m_rUndoRedo.DoUndo(false); + } + ~UndoGuard() + { + m_rUndoRedo.DoUndo(m_bUndoWasEnabled); + } + + bool UndoWasEnabled() const + { + return m_bUndoWasEnabled; + } + +private: + IDocumentUndoRedo & m_rUndoRedo; + bool const m_bUndoWasEnabled; +}; + +class GroupUndoGuard +{ +public: + + GroupUndoGuard(IDocumentUndoRedo & rUndoRedo) + : m_rUndoRedo(rUndoRedo) + , m_bGroupUndoWasEnabled(rUndoRedo.DoesGroupUndo()) + { + m_rUndoRedo.DoGroupUndo(false); + } + ~GroupUndoGuard() + { + m_rUndoRedo.DoGroupUndo(m_bGroupUndoWasEnabled); + } + +private: + IDocumentUndoRedo & m_rUndoRedo; + bool const m_bGroupUndoWasEnabled; +}; + +} // namespace sw + #endif |