Kaydet (Commit) d7b7c9fd authored tarafından Armin Le Grand's avatar Armin Le Grand Kaydeden (comit) Caolán McNamara

Resolves: #i120515# Implemented and finetuned the enhanced Undo feature

(see #i120498#) for sw

(cherry picked from commit fb2580f1)

Conflicts:
	sw/source/core/draw/dview.cxx
	sw/source/core/inc/UndoManager.hxx
	sw/source/core/undo/docundo.cxx

Change-Id: I9970377d66f1104448a2ee7e4fb1cf82bf559cd8
üst c726a1b1
...@@ -22,6 +22,9 @@ ...@@ -22,6 +22,9 @@
#include <svx/svdpagv.hxx> #include <svx/svdpagv.hxx>
#include <svx/fmmodel.hxx> #include <svx/fmmodel.hxx>
#include <sot/exchange.hxx> #include <sot/exchange.hxx>
#include <svx/sdrundomanager.hxx>
#include <editeng/outliner.hxx>
#include <com/sun/star/embed/EmbedMisc.hpp>
#include "swtypes.hxx" #include "swtypes.hxx"
#include "pagefrm.hxx" #include "pagefrm.hxx"
...@@ -53,6 +56,7 @@ ...@@ -53,6 +56,7 @@
// #i28701# // #i28701#
#include <sortedobjs.hxx> #include <sortedobjs.hxx>
#include <flyfrms.hxx> #include <flyfrms.hxx>
#include <UndoManager.hxx>
using namespace com::sun::star; using namespace com::sun::star;
...@@ -952,4 +956,12 @@ void SwDrawView::DeleteMarked() ...@@ -952,4 +956,12 @@ void SwDrawView::DeleteMarked()
pTmpRoot->EndAllAction(); //swmod 080218 pTmpRoot->EndAllAction(); //swmod 080218
} }
// support enhanced text edit for draw objects
SdrUndoManager* SwDrawView::getSdrUndoManagerForEnhancedTextEdit() const
{
SwDoc* pDoc = Imp().GetShell()->GetDoc();
return pDoc ? dynamic_cast< SdrUndoManager* >(&(pDoc->GetUndoManager())) : 0;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include <IDocumentUndoRedo.hxx> #include <IDocumentUndoRedo.hxx>
#include <memory> #include <memory>
#include <svl/undo.hxx> #include <svx/sdrundomanager.hxx>
class IDocumentDrawModelAccess; class IDocumentDrawModelAccess;
class IDocumentRedlineAccess; class IDocumentRedlineAccess;
...@@ -32,7 +32,7 @@ namespace sw { ...@@ -32,7 +32,7 @@ namespace sw {
class UndoManager class UndoManager
: public IDocumentUndoRedo : public IDocumentUndoRedo
, public SfxUndoManager , public SdrUndoManager
{ {
public: public:
UndoManager(::std::auto_ptr<SwNodes> pUndoNodes, UndoManager(::std::auto_ptr<SwNodes> pUndoNodes,
...@@ -102,7 +102,7 @@ private: ...@@ -102,7 +102,7 @@ private:
bool impl_DoUndoRedo(UndoOrRedo_t const undoOrRedo); bool impl_DoUndoRedo(UndoOrRedo_t const undoOrRedo);
// UGLY: should not be called // UGLY: should not be called
using SfxUndoManager::Repeat; using SdrUndoManager::Repeat;
}; };
} // namespace sw } // namespace sw
......
...@@ -26,6 +26,7 @@ class SwViewImp; ...@@ -26,6 +26,7 @@ class SwViewImp;
class SwFrm; class SwFrm;
class SwFlyFrm; class SwFlyFrm;
class SwAnchoredObject; class SwAnchoredObject;
class SdrUndoManager;
class SwDrawView : public FmFormView class SwDrawView : public FmFormView
{ {
...@@ -74,6 +75,9 @@ protected: ...@@ -74,6 +75,9 @@ protected:
using FmFormView::CheckSingleSdrObjectHit; using FmFormView::CheckSingleSdrObjectHit;
virtual SdrObject* CheckSingleSdrObjectHit(const Point& rPnt, sal_uInt16 nTol, SdrObject* pObj, SdrPageView* pPV, sal_uLong nOptions, const SetOfByte* pMVisLay) const; virtual SdrObject* CheckSingleSdrObjectHit(const Point& rPnt, sal_uInt16 nTol, SdrObject* pObj, SdrPageView* pPV, sal_uLong nOptions, const SetOfByte* pMVisLay) const;
// support enhanced text edit for draw objects
virtual SdrUndoManager* getSdrUndoManagerForEnhancedTextEdit() const;
public: public:
SwDrawView( SwViewImp &rI, SdrModel *pMd, OutputDevice* pOutDev=NULL ); SwDrawView( SwViewImp &rI, SdrModel *pMd, OutputDevice* pOutDev=NULL );
......
...@@ -65,7 +65,7 @@ UndoManager::UndoManager(::std::auto_ptr<SwNodes> pUndoNodes, ...@@ -65,7 +65,7 @@ UndoManager::UndoManager(::std::auto_ptr<SwNodes> pUndoNodes,
OSL_ASSERT(m_pUndoNodes.get()); OSL_ASSERT(m_pUndoNodes.get());
// writer expects it to be disabled initially // writer expects it to be disabled initially
// Undo is enabled by SwEditShell constructor // Undo is enabled by SwEditShell constructor
SfxUndoManager::EnableUndo(false); SdrUndoManager::EnableUndo(false);
} }
SAL_WNODEPRECATED_DECLARATIONS_POP SAL_WNODEPRECATED_DECLARATIONS_POP
...@@ -86,6 +86,8 @@ bool UndoManager::IsUndoNodes(SwNodes const& rNodes) const ...@@ -86,6 +86,8 @@ bool UndoManager::IsUndoNodes(SwNodes const& rNodes) const
void UndoManager::DoUndo(bool const bDoUndo) void UndoManager::DoUndo(bool const bDoUndo)
{ {
if(!isTextEditActive())
{
EnableUndo(bDoUndo); EnableUndo(bDoUndo);
SdrModel *const pSdrModel = m_rDrawModelAccess.GetDrawModel(); SdrModel *const pSdrModel = m_rDrawModelAccess.GetDrawModel();
...@@ -93,11 +95,19 @@ void UndoManager::DoUndo(bool const bDoUndo) ...@@ -93,11 +95,19 @@ void UndoManager::DoUndo(bool const bDoUndo)
{ {
pSdrModel->EnableUndo(bDoUndo); pSdrModel->EnableUndo(bDoUndo);
} }
}
} }
bool UndoManager::DoesUndo() const bool UndoManager::DoesUndo() const
{ {
if(isTextEditActive())
{
return false;
}
else
{
return IsUndoEnabled(); return IsUndoEnabled();
}
} }
void UndoManager::DoGroupUndo(bool const bDoUndo) void UndoManager::DoGroupUndo(bool const bDoUndo)
...@@ -156,11 +166,11 @@ void UndoManager::UnLockUndoNoModifiedPosition() ...@@ -156,11 +166,11 @@ void UndoManager::UnLockUndoNoModifiedPosition()
SwUndo* UndoManager::GetLastUndo() SwUndo* UndoManager::GetLastUndo()
{ {
if (!SfxUndoManager::GetUndoActionCount(CurrentLevel)) if (!SdrUndoManager::GetUndoActionCount(CurrentLevel))
{ {
return 0; return 0;
} }
SfxUndoAction *const pAction( SfxUndoManager::GetUndoAction(0) ); SfxUndoAction *const pAction( SdrUndoManager::GetUndoAction(0) );
return dynamic_cast<SwUndo*>(pAction); return dynamic_cast<SwUndo*>(pAction);
} }
...@@ -171,14 +181,14 @@ void UndoManager::AppendUndo(SwUndo *const pUndo) ...@@ -171,14 +181,14 @@ void UndoManager::AppendUndo(SwUndo *const pUndo)
void UndoManager::ClearRedo() void UndoManager::ClearRedo()
{ {
return SfxUndoManager::ImplClearRedo_NoLock(TopLevel); return SdrUndoManager::ImplClearRedo_NoLock(TopLevel);
} }
void UndoManager::DelAllUndoObj() void UndoManager::DelAllUndoObj()
{ {
::sw::UndoGuard const undoGuard(*this); ::sw::UndoGuard const undoGuard(*this);
SfxUndoManager::ClearAllLevels(); SdrUndoManager::ClearAllLevels();
m_UndoSaveMark = MARK_INVALID; m_UndoSaveMark = MARK_INVALID;
} }
...@@ -207,7 +217,7 @@ UndoManager::StartUndo(SwUndoId const i_eUndoId, ...@@ -207,7 +217,7 @@ UndoManager::StartUndo(SwUndoId const i_eUndoId,
comment = pRewriter->Apply(comment); comment = pRewriter->Apply(comment);
} }
SfxUndoManager::EnterListAction(comment, comment, eUndoId); SdrUndoManager::EnterListAction(comment, comment, eUndoId);
return eUndoId; return eUndoId;
} }
...@@ -227,8 +237,8 @@ UndoManager::EndUndo(SwUndoId const i_eUndoId, SwRewriter const*const pRewriter) ...@@ -227,8 +237,8 @@ UndoManager::EndUndo(SwUndoId const i_eUndoId, SwRewriter const*const pRewriter)
"EndUndo(): no Undo ID, but rewriter given?"); "EndUndo(): no Undo ID, but rewriter given?");
SfxUndoAction *const pLastUndo( SfxUndoAction *const pLastUndo(
(0 == SfxUndoManager::GetUndoActionCount(CurrentLevel)) (0 == SdrUndoManager::GetUndoActionCount(CurrentLevel))
? 0 : SfxUndoManager::GetUndoAction(0) ); ? 0 : SdrUndoManager::GetUndoAction(0) );
int const nCount = LeaveListAction(); int const nCount = LeaveListAction();
...@@ -236,7 +246,7 @@ UndoManager::EndUndo(SwUndoId const i_eUndoId, SwRewriter const*const pRewriter) ...@@ -236,7 +246,7 @@ UndoManager::EndUndo(SwUndoId const i_eUndoId, SwRewriter const*const pRewriter)
{ {
OSL_ASSERT(pLastUndo); OSL_ASSERT(pLastUndo);
OSL_ASSERT(UNDO_START != eUndoId); OSL_ASSERT(UNDO_START != eUndoId);
SfxUndoAction *const pUndoAction(SfxUndoManager::GetUndoAction(0)); SfxUndoAction *const pUndoAction(SdrUndoManager::GetUndoAction(0));
SfxListUndoAction *const pListAction( SfxListUndoAction *const pListAction(
dynamic_cast<SfxListUndoAction*>(pUndoAction)); dynamic_cast<SfxListUndoAction*>(pUndoAction));
OSL_ASSERT(pListAction); OSL_ASSERT(pListAction);
...@@ -283,12 +293,13 @@ UndoManager::GetLastUndoInfo( ...@@ -283,12 +293,13 @@ UndoManager::GetLastUndoInfo(
{ {
// this is actually expected to work on the current level, // this is actually expected to work on the current level,
// but that was really not obvious from the previous implementation... // but that was really not obvious from the previous implementation...
if (!SfxUndoManager::GetUndoActionCount(CurrentLevel)) if (!SdrUndoManager::GetUndoActionCount(CurrentLevel))
{ {
return false; return false;
} }
SfxUndoAction *const pAction( SfxUndoManager::GetUndoAction(0) ); SfxUndoAction *const pAction( SdrUndoManager::GetUndoAction(0) );
if (o_pStr) if (o_pStr)
{ {
*o_pStr = pAction->GetComment(); *o_pStr = pAction->GetComment();
...@@ -304,15 +315,15 @@ UndoManager::GetLastUndoInfo( ...@@ -304,15 +315,15 @@ UndoManager::GetLastUndoInfo(
SwUndoComments_t UndoManager::GetUndoComments() const SwUndoComments_t UndoManager::GetUndoComments() const
{ {
OSL_ENSURE(!SfxUndoManager::IsInListAction(), OSL_ENSURE(!SdrUndoManager::IsInListAction(),
"GetUndoComments() called while in list action?"); "GetUndoComments() called while in list action?");
SwUndoComments_t ret; SwUndoComments_t ret;
sal_uInt16 const nUndoCount(SfxUndoManager::GetUndoActionCount(TopLevel)); sal_uInt16 const nUndoCount(SdrUndoManager::GetUndoActionCount(TopLevel));
for (sal_uInt16 n = 0; n < nUndoCount; ++n) for (sal_uInt16 n = 0; n < nUndoCount; ++n)
{ {
OUString const comment( OUString const comment(
SfxUndoManager::GetUndoActionComment(n, TopLevel)); SdrUndoManager::GetUndoActionComment(n, TopLevel));
ret.push_back(comment); ret.push_back(comment);
} }
...@@ -323,14 +334,14 @@ SwUndoComments_t UndoManager::GetUndoComments() const ...@@ -323,14 +334,14 @@ SwUndoComments_t UndoManager::GetUndoComments() const
/**************** REDO ******************/ /**************** REDO ******************/
bool UndoManager::GetFirstRedoInfo(OUString *const o_pStr) const bool UndoManager::GetFirstRedoInfo(OUString *const o_pStr) const
{ {
if (!SfxUndoManager::GetRedoActionCount(CurrentLevel)) if (!SdrUndoManager::GetRedoActionCount(CurrentLevel))
{ {
return false; return false;
} }
if (o_pStr) if (o_pStr)
{ {
*o_pStr = SfxUndoManager::GetRedoActionComment(0, CurrentLevel); *o_pStr = SdrUndoManager::GetRedoActionComment(0, CurrentLevel);
} }
return true; return true;
...@@ -339,15 +350,15 @@ bool UndoManager::GetFirstRedoInfo(OUString *const o_pStr) const ...@@ -339,15 +350,15 @@ bool UndoManager::GetFirstRedoInfo(OUString *const o_pStr) const
SwUndoComments_t UndoManager::GetRedoComments() const SwUndoComments_t UndoManager::GetRedoComments() const
{ {
OSL_ENSURE(!SfxUndoManager::IsInListAction(), OSL_ENSURE(!SdrUndoManager::IsInListAction(),
"GetRedoComments() called while in list action?"); "GetRedoComments() called while in list action?");
SwUndoComments_t ret; SwUndoComments_t ret;
sal_uInt16 const nRedoCount(SfxUndoManager::GetRedoActionCount(TopLevel)); sal_uInt16 const nRedoCount(SdrUndoManager::GetRedoActionCount(TopLevel));
for (sal_uInt16 n = 0; n < nRedoCount; ++n) for (sal_uInt16 n = 0; n < nRedoCount; ++n)
{ {
OUString const comment( OUString const comment(
SfxUndoManager::GetRedoActionComment(n, TopLevel)); SdrUndoManager::GetRedoActionComment(n, TopLevel));
ret.push_back(comment); ret.push_back(comment);
} }
...@@ -373,19 +384,19 @@ SwUndoId UndoManager::GetRepeatInfo(OUString *const o_pStr) const ...@@ -373,19 +384,19 @@ SwUndoId UndoManager::GetRepeatInfo(OUString *const o_pStr) const
SwUndo * UndoManager::RemoveLastUndo() SwUndo * UndoManager::RemoveLastUndo()
{ {
if (SfxUndoManager::GetRedoActionCount(CurrentLevel) || if (SdrUndoManager::GetRedoActionCount(CurrentLevel) ||
SfxUndoManager::GetRedoActionCount(TopLevel)) SdrUndoManager::GetRedoActionCount(TopLevel))
{ {
OSL_ENSURE(false, "RemoveLastUndoAction(): there are Redo actions?"); OSL_ENSURE(false, "RemoveLastUndoAction(): there are Redo actions?");
return 0; return 0;
} }
if (!SfxUndoManager::GetUndoActionCount(CurrentLevel)) if (!SdrUndoManager::GetUndoActionCount(CurrentLevel))
{ {
OSL_ENSURE(false, "RemoveLastUndoAction(): no Undo actions"); OSL_ENSURE(false, "RemoveLastUndoAction(): no Undo actions");
return 0; return 0;
} }
SfxUndoAction *const pLastUndo(GetUndoAction(0)); SfxUndoAction *const pLastUndo(GetUndoAction(0));
SfxUndoManager::RemoveLastUndoAction(); SdrUndoManager::RemoveLastUndoAction();
return dynamic_cast<SwUndo *>(pLastUndo); return dynamic_cast<SwUndo *>(pLastUndo);
} }
...@@ -393,9 +404,9 @@ SwUndo * UndoManager::RemoveLastUndo() ...@@ -393,9 +404,9 @@ SwUndo * UndoManager::RemoveLastUndo()
void UndoManager::EnableUndo(bool bEnable) void UndoManager::EnableUndo(bool bEnable)
{ {
// SfxUndoManager does not have a counter anymore, but reverted to the old behavior of // SdrUndoManager does not have a counter anymore, but reverted to the old behavior of
// having a simple boolean flag for locking. So, simply forward. // having a simple boolean flag for locking. So, simply forward.
SfxUndoManager::EnableUndo(bEnable); SdrUndoManager::EnableUndo(bEnable);
} }
void UndoManager::AddUndoAction(SfxUndoAction *pAction, sal_Bool bTryMerge) void UndoManager::AddUndoAction(SfxUndoAction *pAction, sal_Bool bTryMerge)
...@@ -408,7 +419,7 @@ void UndoManager::AddUndoAction(SfxUndoAction *pAction, sal_Bool bTryMerge) ...@@ -408,7 +419,7 @@ void UndoManager::AddUndoAction(SfxUndoAction *pAction, sal_Bool bTryMerge)
pUndo->SetRedlineMode( m_rRedlineAccess.GetRedlineMode() ); pUndo->SetRedlineMode( m_rRedlineAccess.GetRedlineMode() );
} }
} }
SfxUndoManager::AddUndoAction(pAction, bTryMerge); SdrUndoManager::AddUndoAction(pAction, bTryMerge);
// if the undo nodes array is too large, delete some actions // if the undo nodes array is too large, delete some actions
while (UNDO_ACTION_LIMIT < GetUndoNodes().Count()) while (UNDO_ACTION_LIMIT < GetUndoNodes().Count())
{ {
...@@ -473,17 +484,17 @@ bool UndoManager::impl_DoUndoRedo(UndoOrRedo_t const undoOrRedo) ...@@ -473,17 +484,17 @@ bool UndoManager::impl_DoUndoRedo(UndoOrRedo_t const undoOrRedo)
// N.B. these may throw! // N.B. these may throw!
if (UNDO == undoOrRedo) if (UNDO == undoOrRedo)
{ {
bRet = SfxUndoManager::UndoWithContext(context); bRet = SdrUndoManager::UndoWithContext(context);
} }
else else
{ {
bRet = SfxUndoManager::RedoWithContext(context); bRet = SdrUndoManager::RedoWithContext(context);
} }
if (bRet) if (bRet)
{ {
// if we are at the "last save" position, the document is not modified // if we are at the "last save" position, the document is not modified
if (SfxUndoManager::HasTopUndoActionMark(m_UndoSaveMark)) if (SdrUndoManager::HasTopUndoActionMark(m_UndoSaveMark))
{ {
m_rState.ResetModified(); m_rState.ResetModified();
} }
...@@ -500,31 +511,43 @@ bool UndoManager::impl_DoUndoRedo(UndoOrRedo_t const undoOrRedo) ...@@ -500,31 +511,43 @@ bool UndoManager::impl_DoUndoRedo(UndoOrRedo_t const undoOrRedo)
sal_Bool UndoManager::Undo() sal_Bool UndoManager::Undo()
{ {
bool const bRet = impl_DoUndoRedo(UNDO); if(isTextEditActive())
return bRet; {
return SdrUndoManager::Undo();
}
else
{
return impl_DoUndoRedo(UNDO);
}
} }
sal_Bool UndoManager::Redo() sal_Bool UndoManager::Redo()
{ {
bool const bRet = impl_DoUndoRedo(REDO); if(isTextEditActive())
return bRet; {
return SdrUndoManager::Redo();
}
else
{
return impl_DoUndoRedo(REDO);
}
} }
/** N.B.: this does _not_ call SfxUndoManager::Repeat because it is not /** N.B.: this does _not_ call SdrUndoManager::Repeat because it is not
possible to wrap a list action around it: possible to wrap a list action around it:
calling EnterListAction here will cause SfxUndoManager::Repeat calling EnterListAction here will cause SdrUndoManager::Repeat
to repeat the list action! to repeat the list action!
*/ */
bool bool
UndoManager::Repeat(::sw::RepeatContext & rContext, UndoManager::Repeat(::sw::RepeatContext & rContext,
sal_uInt16 const nRepeatCount) sal_uInt16 const nRepeatCount)
{ {
if (SfxUndoManager::IsInListAction()) if (SdrUndoManager::IsInListAction())
{ {
OSL_ENSURE(false, "repeat in open list action???"); OSL_ENSURE(false, "repeat in open list action???");
return false; return false;
} }
if (!SfxUndoManager::GetUndoActionCount(TopLevel)) if (!SdrUndoManager::GetUndoActionCount(TopLevel))
{ {
return false; return false;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment