diff options
-rw-r--r-- | sw/inc/IDocumentUndoRedo.hxx | 4 | ||||
-rw-r--r-- | sw/source/core/inc/UndoManager.hxx | 1 | ||||
-rw-r--r-- | sw/source/core/undo/docundo.cxx | 5 | ||||
-rw-r--r-- | sw/source/uibase/docvw/edtwin.cxx | 37 | ||||
-rw-r--r-- | sw/source/uibase/inc/view.hxx | 4 |
5 files changed, 37 insertions, 14 deletions
diff --git a/sw/inc/IDocumentUndoRedo.hxx b/sw/inc/IDocumentUndoRedo.hxx index ee67ba04ec8a..206617f0a034 100644 --- a/sw/inc/IDocumentUndoRedo.hxx +++ b/sw/inc/IDocumentUndoRedo.hxx @@ -193,6 +193,10 @@ public: */ virtual bool IsUndoNodes(SwNodes const& rNodes) const = 0; + /** Get the number of Undo actions. + */ + virtual size_t GetUndoActionCount(const bool bCurrentLevel = true) const = 0; + protected: virtual ~IDocumentUndoRedo() {}; }; diff --git a/sw/source/core/inc/UndoManager.hxx b/sw/source/core/inc/UndoManager.hxx index 934edc55fd58..087d81eb4219 100644 --- a/sw/source/core/inc/UndoManager.hxx +++ b/sw/source/core/inc/UndoManager.hxx @@ -71,6 +71,7 @@ public: virtual void AppendUndo(SwUndo *const pUndo) SAL_OVERRIDE; virtual void ClearRedo() SAL_OVERRIDE; virtual bool IsUndoNodes(SwNodes const& rNodes) const SAL_OVERRIDE; + virtual size_t GetUndoActionCount(const bool bCurrentLevel = true) const SAL_OVERRIDE; // ::svl::IUndoManager virtual void AddUndoAction(SfxUndoAction *pAction, diff --git a/sw/source/core/undo/docundo.cxx b/sw/source/core/undo/docundo.cxx index ea020b766ae6..37f92d5451d8 100644 --- a/sw/source/core/undo/docundo.cxx +++ b/sw/source/core/undo/docundo.cxx @@ -79,6 +79,11 @@ bool UndoManager::IsUndoNodes(SwNodes const& rNodes) const return & rNodes == m_xUndoNodes.get(); } +size_t UndoManager::GetUndoActionCount(const bool bCurrentLevel) const +{ + return SdrUndoManager::GetUndoActionCount(bCurrentLevel); +} + void UndoManager::DoUndo(bool const bDoUndo) { if(!isTextEditActive()) diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index d89de19b86ab..388ca5082270 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -77,6 +77,7 @@ #include <wrtsh.hxx> #include <IDocumentSettingAccess.hxx> #include <IDocumentDrawModelAccess.hxx> +#include <IDocumentUndoRedo.hxx> #include <textboxhelper.hxx> #include <dcontact.hxx> #include <fldbas.hxx> @@ -4706,15 +4707,15 @@ void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt) { if( rSh.IsSelection() && !rSh.HasReadonlySel() ) { - if(nId == RES_CHRATR_BACKGROUND) + m_pApplyTempl->nUndo = + std::min(m_pApplyTempl->nUndo, rSh.GetDoc()->GetIDocumentUndoRedo().GetUndoActionCount()); + if (nId == RES_CHRATR_BACKGROUND) rSh.SetAttrItem( SvxBrushItem( SwEditWin::m_aWaterCanTextBackColor, nId ) ); else rSh.SetAttrItem( SvxColorItem( SwEditWin::m_aWaterCanTextColor, nId ) ); rSh.UnSetVisCrsr(); rSh.EnterStdMode(); rSh.SetVisCrsr(aDocPt); - - m_pApplyTempl->bUndo = true; bCallBase = false; m_aTemplateIdle.Stop(); } @@ -4735,7 +4736,8 @@ void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt) & eSelection ) && !rSh.HasReadonlySel() ) { rSh.SetTextFormatColl( m_pApplyTempl->aColl.pTextColl ); - m_pApplyTempl->bUndo = true; + m_pApplyTempl->nUndo = + std::min(m_pApplyTempl->nUndo, rSh.GetDoc()->GetIDocumentUndoRedo().GetUndoActionCount()); bCallBase = false; if ( m_pApplyTempl->aColl.pTextColl ) aStyleName = m_pApplyTempl->aColl.pTextColl->GetName(); @@ -4749,7 +4751,8 @@ void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt) rSh.UnSetVisCrsr(); rSh.EnterStdMode(); rSh.SetVisCrsr(aDocPt); - m_pApplyTempl->bUndo = true; + m_pApplyTempl->nUndo = + std::min(m_pApplyTempl->nUndo, rSh.GetDoc()->GetIDocumentUndoRedo().GetUndoActionCount()); bCallBase = false; if ( m_pApplyTempl->aColl.pCharFormat ) aStyleName = m_pApplyTempl->aColl.pCharFormat->GetName(); @@ -4761,7 +4764,8 @@ void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt) if(PTR_CAST(SwFlyFrameFormat, pFormat)) { rSh.SetFrameFormat( m_pApplyTempl->aColl.pFrameFormat, false, &aDocPt ); - m_pApplyTempl->bUndo = true; + m_pApplyTempl->nUndo = + std::min(m_pApplyTempl->nUndo, rSh.GetDoc()->GetIDocumentUndoRedo().GetUndoActionCount()); bCallBase = false; if( m_pApplyTempl->aColl.pFrameFormat ) aStyleName = m_pApplyTempl->aColl.pFrameFormat->GetName(); @@ -4773,6 +4777,8 @@ void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt) rSh.ChgCurPageDesc( *m_pApplyTempl->aColl.pPageDesc ); if ( m_pApplyTempl->aColl.pPageDesc ) aStyleName = m_pApplyTempl->aColl.pPageDesc->GetName(); + m_pApplyTempl->nUndo = + std::min(m_pApplyTempl->nUndo, rSh.GetDoc()->GetIDocumentUndoRedo().GetUndoActionCount()); bCallBase = false; break; case SFX_STYLE_FAMILY_PSEUDO: @@ -4782,7 +4788,8 @@ void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt) false, m_pApplyTempl->aColl.pNumRule->GetDefaultListId() ); bCallBase = false; - m_pApplyTempl->bUndo = true; + m_pApplyTempl->nUndo = + std::min(m_pApplyTempl->nUndo, rSh.GetDoc()->GetIDocumentUndoRedo().GetUndoActionCount()); if( m_pApplyTempl->aColl.pNumRule ) aStyleName = m_pApplyTempl->aColl.pNumRule->GetName(); } @@ -4848,14 +4855,16 @@ void SwEditWin::SetApplyTemplate(const SwApplyTemplate &rTempl) if(rTempl.m_pFormatClipboard) { m_pApplyTempl = new SwApplyTemplate( rTempl ); - SetPointer( PointerStyle::Fill );//@todo #i20119# maybe better a new brush pointer here in future - rSh.NoEdit( false ); - bIdle = rSh.GetViewOptions()->IsIdle(); - rSh.GetViewOptions()->SetIdle( false ); + m_pApplyTempl->nUndo = rSh.GetDoc()->GetIDocumentUndoRedo().GetUndoActionCount(); + SetPointer( PointerStyle::Fill );//@todo #i20119# maybe better a new brush pointer here in future + rSh.NoEdit( false ); + bIdle = rSh.GetViewOptions()->IsIdle(); + rSh.GetViewOptions()->SetIdle( false ); } else if(rTempl.nColor) { m_pApplyTempl = new SwApplyTemplate( rTempl ); + m_pApplyTempl->nUndo = rSh.GetDoc()->GetIDocumentUndoRedo().GetUndoActionCount(); SetPointer( PointerStyle::Fill ); rSh.NoEdit( false ); bIdle = rSh.GetViewOptions()->IsIdle(); @@ -4864,6 +4873,7 @@ void SwEditWin::SetApplyTemplate(const SwApplyTemplate &rTempl) else if( rTempl.eType ) { m_pApplyTempl = new SwApplyTemplate( rTempl ); + m_pApplyTempl->nUndo = rSh.GetDoc()->GetIDocumentUndoRedo().GetUndoActionCount(); SetPointer( PointerStyle::Fill ); rSh.NoEdit( false ); bIdle = rSh.GetViewOptions()->IsIdle(); @@ -5189,8 +5199,11 @@ void SwEditWin::Command( const CommandEvent& rCEvt ) else if ( !m_rView.ExecSpellPopup( aDocPos ) ) SfxDispatcher::ExecutePopup( 0, this, &aPixPos); } - else if (m_pApplyTempl->bUndo) + else if (m_pApplyTempl->nUndo < rSh.GetDoc()->GetIDocumentUndoRedo().GetUndoActionCount()) + { + // Undo until we reach the point when we entered this context. rSh.Do(SwWrtShell::UNDO); + } bCallBase = false; } } diff --git a/sw/source/uibase/inc/view.hxx b/sw/source/uibase/inc/view.hxx index a46879986888..1524d605528b 100644 --- a/sw/source/uibase/inc/view.hxx +++ b/sw/source/uibase/inc/view.hxx @@ -132,13 +132,13 @@ struct SwApplyTemplate int eType; sal_uInt16 nColor; SwFormatClipboard* m_pFormatClipboard; - bool bUndo; + size_t nUndo; //< The initial undo stack depth. SwApplyTemplate() : eType(0), nColor(0), m_pFormatClipboard(0), - bUndo(false) + nUndo(0) { aColl.pTextColl = 0; } |