Related: #i120498# Enhanced Undo/Redo and user experience...
when editing texts in graphic objects and/or tables (cherry picked from commit a096725779b210c7a2706e72596fd7c80e049fdd) Conflicts: editeng/inc/editeng/editeng.hxx editeng/inc/editeng/editund2.hxx editeng/inc/editeng/outliner.hxx editeng/source/editeng/editundo.cxx editeng/source/editeng/impedit.hxx editeng/source/outliner/outliner.cxx sd/source/core/undo/undomanager.cxx sd/source/ui/view/drviewse.cxx svx/Library_svxcore.mk svx/Package_inc.mk svx/inc/svx/svdedxv.hxx svx/source/svdraw/svdedxv.cxx Change-Id: I40e3ef2dff681f9b6f2f6b5d35507071f8110533 Comment unused variable pNewEditUndoManager to silence the compiler (cherry picked from commit 568655083af7830e7b9edf56ef862ddf9a99003b) Change-Id: Ib7179ee6c34ce03a75942978831c3a55968f161f Removed unused variable (cherry picked from commit 0bbde4414badfd40234de4a4c9f750194f5d1d5e) Change-Id: I39e7f25426e8e7d1367102d603b0f6c84d96622f
This commit is contained in:
committed by
Caolán McNamara
parent
64b07d99aa
commit
12a4200e8f
@@ -134,6 +134,12 @@ sal_Bool EditEngine::IsInUndo()
|
||||
return pImpEditEngine->GetUndoManager();
|
||||
}
|
||||
|
||||
::svl::IUndoManager* EditEngine::SetUndoManager(::svl::IUndoManager* pNew)
|
||||
{
|
||||
DBG_CHKTHIS( EditEngine, 0 );
|
||||
return pImpEditEngine->SetUndoManager(pNew);
|
||||
}
|
||||
|
||||
void EditEngine::UndoActionStart( sal_uInt16 nId )
|
||||
{
|
||||
DBG_CHKTHIS( EditEngine, 0 );
|
||||
|
@@ -37,11 +37,20 @@ static void lcl_DoSetSelection( EditView* pView, sal_uInt16 nPara )
|
||||
pView->GetImpEditView()->SetEditSelection( aSel );
|
||||
}
|
||||
|
||||
EditUndoManager::EditUndoManager(EditEngine* pEE) : mpEditEngine(pEE) {}
|
||||
EditUndoManager::EditUndoManager(sal_uInt16 nMaxUndoActionCount )
|
||||
: SfxUndoManager(nMaxUndoActionCount),
|
||||
mpEditEngine(0)
|
||||
{
|
||||
}
|
||||
|
||||
void EditUndoManager::SetEditEngine(EditEngine* pNew)
|
||||
{
|
||||
mpEditEngine = pNew;
|
||||
}
|
||||
|
||||
sal_Bool EditUndoManager::Undo()
|
||||
{
|
||||
if ( GetUndoActionCount() == 0 )
|
||||
if ( !mpEditEngine || GetUndoActionCount() == 0 )
|
||||
return sal_False;
|
||||
|
||||
DBG_ASSERT( mpEditEngine->GetActiveView(), "Active View?" );
|
||||
@@ -76,7 +85,7 @@ sal_Bool EditUndoManager::Undo()
|
||||
|
||||
sal_Bool EditUndoManager::Redo()
|
||||
{
|
||||
if ( GetRedoActionCount() == 0 )
|
||||
if ( !mpEditEngine || GetRedoActionCount() == 0 )
|
||||
return sal_False;
|
||||
|
||||
DBG_ASSERT( mpEditEngine->GetActiveView(), "Active View?" );
|
||||
|
@@ -681,6 +681,7 @@ public:
|
||||
~ImpEditEngine();
|
||||
|
||||
inline EditUndoManager& GetUndoManager();
|
||||
inline ::svl::IUndoManager* SetUndoManager(::svl::IUndoManager* pNew);
|
||||
|
||||
void SetUpdateMode( bool bUp, EditView* pCurView = 0, sal_Bool bForceUpdate = sal_False );
|
||||
bool GetUpdateMode() const { return bUpdate; }
|
||||
@@ -1072,10 +1073,32 @@ inline void ImpEditEngine::IdleFormatAndUpdate( EditView* pCurView )
|
||||
inline EditUndoManager& ImpEditEngine::GetUndoManager()
|
||||
{
|
||||
if ( !pUndoManager )
|
||||
pUndoManager = new EditUndoManager(pEditEngine);
|
||||
{
|
||||
pUndoManager = new EditUndoManager();
|
||||
pUndoManager->SetEditEngine(pEditEngine);
|
||||
}
|
||||
return *pUndoManager;
|
||||
}
|
||||
|
||||
inline ::svl::IUndoManager* ImpEditEngine::SetUndoManager(::svl::IUndoManager* pNew)
|
||||
{
|
||||
::svl::IUndoManager* pRetval = pUndoManager;
|
||||
|
||||
if(pUndoManager)
|
||||
{
|
||||
pUndoManager->SetEditEngine(0);
|
||||
}
|
||||
|
||||
pUndoManager = dynamic_cast< EditUndoManager* >(pNew);
|
||||
|
||||
if(pUndoManager)
|
||||
{
|
||||
pUndoManager->SetEditEngine(pEditEngine);
|
||||
}
|
||||
|
||||
return pRetval;
|
||||
}
|
||||
|
||||
inline const ParaPortion* ImpEditEngine::FindParaPortion( const ContentNode* pNode ) const
|
||||
{
|
||||
sal_Int32 nPos = aEditDoc.GetPos( pNode );
|
||||
|
@@ -1218,6 +1218,12 @@ void Outliner::ImpFilterIndents( sal_Int32 nFirstPara, sal_Int32 nLastPara )
|
||||
return pEditEngine->GetUndoManager();
|
||||
}
|
||||
|
||||
::svl::IUndoManager* Outliner::SetUndoManager(::svl::IUndoManager* pNew)
|
||||
{
|
||||
DBG_CHKTHIS(Outliner,0);
|
||||
return pEditEngine->SetUndoManager(pNew);
|
||||
}
|
||||
|
||||
void Outliner::ImpTextPasted( sal_Int32 nStartPara, sal_Int32 nCount )
|
||||
{
|
||||
DBG_CHKTHIS(Outliner,0);
|
||||
|
@@ -303,8 +303,8 @@ public:
|
||||
|
||||
void ShowParagraph( sal_Int32 nParagraph, sal_Bool bShow = sal_True );
|
||||
|
||||
::svl::IUndoManager&
|
||||
GetUndoManager();
|
||||
::svl::IUndoManager& GetUndoManager();
|
||||
::svl::IUndoManager* SetUndoManager(::svl::IUndoManager* pNew);
|
||||
void UndoActionStart( sal_uInt16 nId );
|
||||
void UndoActionStart(sal_uInt16 nId, const ESelection& rSel);
|
||||
void UndoActionEnd( sal_uInt16 nId );
|
||||
|
@@ -25,14 +25,16 @@
|
||||
|
||||
class EditEngine;
|
||||
|
||||
class EDITENG_DLLPRIVATE EditUndoManager : public SfxUndoManager
|
||||
class EDITENG_DLLPUBLIC EditUndoManager : public SfxUndoManager
|
||||
{
|
||||
using SfxUndoManager::Undo;
|
||||
using SfxUndoManager::Redo;
|
||||
friend class ImpEditEngine;
|
||||
|
||||
EditEngine* mpEditEngine;
|
||||
void SetEditEngine(EditEngine* pNew);
|
||||
public:
|
||||
EditUndoManager(EditEngine* pEE);
|
||||
EditUndoManager(sal_uInt16 nMaxUndoActionCount = 20);
|
||||
|
||||
virtual sal_Bool Undo();
|
||||
virtual sal_Bool Redo();
|
||||
|
@@ -891,8 +891,8 @@ public:
|
||||
|
||||
sal_uLong Read( SvStream& rInput, const String& rBaseURL, sal_uInt16, SvKeyValueIterator* pHTTPHeaderAttrs = NULL );
|
||||
|
||||
::svl::IUndoManager&
|
||||
GetUndoManager();
|
||||
::svl::IUndoManager& GetUndoManager();
|
||||
::svl::IUndoManager* SetUndoManager(::svl::IUndoManager* pNew);
|
||||
|
||||
void QuickSetAttribs( const SfxItemSet& rSet, const ESelection& rSel );
|
||||
void QuickInsertField( const SvxFieldItem& rFld, const ESelection& rSel );
|
||||
|
55
include/svx/sdrundomanager.hxx
Normal file
55
include/svx/sdrundomanager.hxx
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* This file incorporates work covered by the following license notice:
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
*/
|
||||
#ifndef _SDR_UNDOMANAGER_HXX
|
||||
#define _SDR_UNDOMANAGER_HXX
|
||||
|
||||
#include "svx/svxdllapi.h"
|
||||
#include <sal/types.h>
|
||||
#include <editeng/editund2.hxx>
|
||||
#include <tools/link.hxx>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class SVX_DLLPUBLIC SdrUndoManager : public EditUndoManager
|
||||
{
|
||||
private:
|
||||
using EditUndoManager::Undo;
|
||||
using EditUndoManager::Redo;
|
||||
|
||||
Link maEndTextEditHdl;
|
||||
SfxUndoAction* mpLastUndoActionBeforeTextEdit;
|
||||
|
||||
public:
|
||||
SdrUndoManager(sal_uInt16 nMaxUndoActionCount = 20);
|
||||
virtual ~SdrUndoManager();
|
||||
|
||||
/// react depending on edit mode and if no more undo is possible
|
||||
virtual sal_Bool Undo();
|
||||
virtual sal_Bool Redo();
|
||||
|
||||
// Call for the view which starts the interactive text edit. Use link to
|
||||
// activate (start text edit) and empty link to reset (end text edit). On
|
||||
// reset all text edit actions will be removed from this undo manager to
|
||||
// restore the state before activation
|
||||
void SetEndTextEditHdl(const Link& rLink);
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif //_SDR_UNDOMANAGER_HXX
|
||||
// eof
|
@@ -38,6 +38,7 @@ class EditStatus;
|
||||
class EditFieldInfo;
|
||||
class ImpSdrEditPara;
|
||||
struct PasteOrDropInfos;
|
||||
class SdrUndoManager;
|
||||
|
||||
namespace com { namespace sun { namespace star { namespace uno {
|
||||
class Any;
|
||||
@@ -97,7 +98,7 @@ protected:
|
||||
Link aOldCalcFieldValueLink; // Zum rufen des alten Handlers
|
||||
Point aMacroDownPos;
|
||||
|
||||
sal_uInt16 nMacroTol;
|
||||
sal_uInt16 nMacroTol;
|
||||
|
||||
unsigned bTextEditDontDelete : 1; // Outliner und View bei SdrEndTextEdit nicht deleten (f. Rechtschreibpruefung)
|
||||
unsigned bTextEditOnlyOneView : 1; // Nur eine OutlinerView (f. Rechtschreibpruefung)
|
||||
@@ -110,6 +111,8 @@ protected:
|
||||
rtl::Reference< sdr::SelectionController > mxLastSelectionController;
|
||||
|
||||
private:
|
||||
::svl::IUndoManager* mpOldTextEditUndoManager;
|
||||
|
||||
SVX_DLLPRIVATE void ImpClearVars();
|
||||
|
||||
protected:
|
||||
@@ -130,6 +133,9 @@ protected:
|
||||
DECL_LINK(ImpOutlinerStatusEventHdl,EditStatus*);
|
||||
DECL_LINK(ImpOutlinerCalcFieldValueHdl,EditFieldInfo*);
|
||||
|
||||
// link for EndTextEditHdl
|
||||
DECL_LINK(EndTextEditHdl, SdrUndoManager*);
|
||||
|
||||
void ImpMacroUp(const Point& rUpPos);
|
||||
void ImpMacroDown(const Point& rDownPos);
|
||||
|
||||
|
@@ -20,13 +20,13 @@
|
||||
#ifndef _SD_UNDOMANAGER_HXX
|
||||
#define _SD_UNDOMANAGER_HXX
|
||||
|
||||
#include "misc/scopelock.hxx"
|
||||
#include <svl/undo.hxx>
|
||||
#include <misc/scopelock.hxx>
|
||||
#include <svx/sdrundomanager.hxx>
|
||||
|
||||
namespace sd
|
||||
{
|
||||
|
||||
class UndoManager : public SfxUndoManager
|
||||
class UndoManager : public SdrUndoManager
|
||||
{
|
||||
public:
|
||||
UndoManager( sal_uInt16 nMaxUndoActionCount = 20 );
|
||||
@@ -40,8 +40,8 @@ public:
|
||||
void SetLinkedUndoManager (::svl::IUndoManager* pLinkedUndoManager);
|
||||
|
||||
private:
|
||||
using SfxUndoManager::Undo;
|
||||
using SfxUndoManager::Redo;
|
||||
using SdrUndoManager::Undo;
|
||||
using SdrUndoManager::Redo;
|
||||
|
||||
/** Used when the outline view is visible as a last resort to
|
||||
synchronize the undo managers.
|
||||
|
@@ -17,12 +17,12 @@
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
*/
|
||||
|
||||
#include "undo/undomanager.hxx"
|
||||
#include <undo/undomanager.hxx>
|
||||
|
||||
using namespace sd;
|
||||
|
||||
UndoManager::UndoManager( sal_uInt16 nMaxUndoActionCount /* = 20 */ )
|
||||
: SfxUndoManager( nMaxUndoActionCount )
|
||||
: SdrUndoManager( nMaxUndoActionCount )
|
||||
, mpLinkedUndoManager(NULL)
|
||||
{
|
||||
}
|
||||
@@ -32,7 +32,7 @@ void UndoManager::EnterListAction(const OUString &rComment, const OUString& rRep
|
||||
if( !IsDoing() )
|
||||
{
|
||||
ClearLinkedRedoActions();
|
||||
SfxUndoManager::EnterListAction( rComment, rRepeatComment, nId );
|
||||
SdrUndoManager::EnterListAction( rComment, rRepeatComment, nId );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ void UndoManager::AddUndoAction( SfxUndoAction *pAction, sal_Bool bTryMerg /* =
|
||||
if( !IsDoing() )
|
||||
{
|
||||
ClearLinkedRedoActions();
|
||||
SfxUndoManager::AddUndoAction( pAction, bTryMerg );
|
||||
SdrUndoManager::AddUndoAction( pAction, bTryMerg );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -625,11 +625,6 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq)
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// service routine for Undo/Redo implementation
|
||||
extern SfxUndoManager* ImpGetUndoManagerFromViewShell(DrawViewShell& rDViewShell);
|
||||
|
||||
|
||||
void DrawViewShell::FuSupport(SfxRequest& rReq)
|
||||
{
|
||||
if( rReq.GetSlot() == SID_STYLE_FAMILY && rReq.GetArgs())
|
||||
|
@@ -254,6 +254,7 @@ $(eval $(call gb_Library_add_exception_objects,svxcore,\
|
||||
svx/source/svdraw/sdrmasterpagedescriptor \
|
||||
svx/source/svdraw/sdrpagewindow \
|
||||
svx/source/svdraw/sdrpaintwindow \
|
||||
svx/source/svdraw/sdrundomanager \
|
||||
svx/source/svdraw/selectioncontroller \
|
||||
svx/source/svdraw/svdattr \
|
||||
svx/source/svdraw/svdcrtv \
|
||||
|
109
svx/source/svdraw/sdrundomanager.cxx
Normal file
109
svx/source/svdraw/sdrundomanager.cxx
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* This file incorporates work covered by the following license notice:
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
*/
|
||||
|
||||
#include <svx/sdrundomanager.hxx>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SdrUndoManager::SdrUndoManager(sal_uInt16 nMaxUndoActionCount)
|
||||
: EditUndoManager(nMaxUndoActionCount),
|
||||
maEndTextEditHdl(),
|
||||
mpLastUndoActionBeforeTextEdit(0)
|
||||
{
|
||||
}
|
||||
|
||||
SdrUndoManager::~SdrUndoManager()
|
||||
{
|
||||
}
|
||||
|
||||
sal_Bool SdrUndoManager::Undo()
|
||||
{
|
||||
sal_Bool bRetval(sal_False);
|
||||
|
||||
if(maEndTextEditHdl.IsSet())
|
||||
{
|
||||
// we are in text edit mode
|
||||
if(GetUndoActionCount() && mpLastUndoActionBeforeTextEdit != GetUndoAction(0))
|
||||
{
|
||||
// there is an undo action for text edit, trigger it
|
||||
bRetval = EditUndoManager::Undo();
|
||||
}
|
||||
else
|
||||
{
|
||||
// no more text edit undo, end text edit
|
||||
maEndTextEditHdl.Call(this);
|
||||
}
|
||||
}
|
||||
|
||||
if(!bRetval && GetUndoActionCount())
|
||||
{
|
||||
// no undo triggered up to now, trigger local one
|
||||
bRetval = SfxUndoManager::Undo();
|
||||
}
|
||||
|
||||
return bRetval;
|
||||
}
|
||||
|
||||
sal_Bool SdrUndoManager::Redo()
|
||||
{
|
||||
sal_Bool bRetval(sal_False);
|
||||
|
||||
if(maEndTextEditHdl.IsSet())
|
||||
{
|
||||
// we are in text edit mode
|
||||
bRetval = EditUndoManager::Redo();
|
||||
}
|
||||
|
||||
if(!bRetval)
|
||||
{
|
||||
// no redo triggered up to now, trigger local one
|
||||
bRetval = SfxUndoManager::Redo();
|
||||
}
|
||||
|
||||
return bRetval;
|
||||
}
|
||||
|
||||
void SdrUndoManager::SetEndTextEditHdl(const Link& rLink)
|
||||
{
|
||||
maEndTextEditHdl = rLink;
|
||||
|
||||
if(maEndTextEditHdl.IsSet())
|
||||
{
|
||||
// text edit start, remember last non-textedit action for later cleanup
|
||||
mpLastUndoActionBeforeTextEdit = GetUndoActionCount() ? GetUndoAction(0) : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// text edit ends, pop all textedit actions up to the remembered non-textedit action from the start
|
||||
// to set back the UndoManager to the state before text edit started. If that action is already gone
|
||||
// (due to being removed from the undo stack in the meantime), all need to be removed anyways
|
||||
while(GetUndoActionCount() && mpLastUndoActionBeforeTextEdit != GetUndoAction(0))
|
||||
{
|
||||
RemoveLastUndoAction();
|
||||
}
|
||||
|
||||
// urgently needed: RemoveLastUndoAction does NOT correct the Redo stack by itself (!)
|
||||
ClearRedo();
|
||||
|
||||
// forget marker again
|
||||
mpLastUndoActionBeforeTextEdit = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// eof
|
@@ -63,6 +63,7 @@
|
||||
#include <svtools/colorcfg.hxx>
|
||||
#include <vcl/svapp.hxx>
|
||||
#include <svx/sdrpaintwindow.hxx>
|
||||
#include <svx/sdrundomanager.hxx>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -87,7 +88,8 @@ void SdrObjEditView::ImpClearVars()
|
||||
}
|
||||
|
||||
SdrObjEditView::SdrObjEditView(SdrModel* pModel1, OutputDevice* pOut):
|
||||
SdrGlueEditView(pModel1,pOut)
|
||||
SdrGlueEditView(pModel1,pOut),
|
||||
mpOldTextEditUndoManager(0)
|
||||
{
|
||||
ImpClearVars();
|
||||
}
|
||||
@@ -95,8 +97,10 @@ SdrObjEditView::SdrObjEditView(SdrModel* pModel1, OutputDevice* pOut):
|
||||
SdrObjEditView::~SdrObjEditView()
|
||||
{
|
||||
pTextEditWin = NULL; // so there's no ShowCursor in SdrEndTextEdit
|
||||
if (IsTextEdit()) SdrEndTextEdit();
|
||||
if (IsTextEdit())
|
||||
SdrEndTextEdit();
|
||||
delete pTextEditOutliner;
|
||||
delete mpOldTextEditUndoManager;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -516,6 +520,12 @@ IMPL_LINK(SdrObjEditView,ImpOutlinerCalcFieldValueHdl,EditFieldInfo*,pFI)
|
||||
return 0;
|
||||
}
|
||||
|
||||
IMPL_LINK(SdrObjEditView, EndTextEditHdl, SdrUndoManager*, /*pUndoManager*/)
|
||||
{
|
||||
SdrEndTextEdit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
sal_Bool SdrObjEditView::SdrBeginTextEdit(
|
||||
SdrObject* pObj, SdrPageView* pPV, Window* pWin,
|
||||
sal_Bool bIsNewObj, SdrOutliner* pGivenOutliner,
|
||||
@@ -742,6 +752,31 @@ sal_Bool SdrObjEditView::SdrBeginTextEdit(
|
||||
if( mxSelectionController.is() )
|
||||
mxSelectionController->onSelectionHasChanged();
|
||||
|
||||
if(IsUndoEnabled())
|
||||
{
|
||||
SdrUndoManager* pSdrUndoManager = dynamic_cast< SdrUndoManager* >(GetModel()->GetSdrUndoManager());
|
||||
|
||||
if(pSdrUndoManager)
|
||||
{
|
||||
// we have an outliner, undo manager and it's an EditUndoManager, exchange
|
||||
// the document undo manager and the default one from the outliner and tell
|
||||
// it that text edit starts by setting a callback if it needs to end text edit mode.
|
||||
if(mpOldTextEditUndoManager)
|
||||
{
|
||||
// should not happen, delete it
|
||||
delete mpOldTextEditUndoManager;
|
||||
mpOldTextEditUndoManager = 0;
|
||||
}
|
||||
|
||||
mpOldTextEditUndoManager = pTextEditOutliner->SetUndoManager(pSdrUndoManager);
|
||||
pSdrUndoManager->SetEndTextEditHdl(LINK(this, SdrObjEditView, EndTextEditHdl));
|
||||
}
|
||||
else
|
||||
{
|
||||
OSL_ENSURE(false, "The document undo manager is not derived from SdrUndoManager (!)");
|
||||
}
|
||||
}
|
||||
|
||||
return sal_True; // ran fine, let TextEdit run now
|
||||
}
|
||||
else
|
||||
@@ -795,6 +830,42 @@ SdrEndTextEditKind SdrObjEditView::SdrEndTextEdit(sal_Bool bDontDeleteReally)
|
||||
SdrOutliner* pTEOutliner =pTextEditOutliner;
|
||||
OutlinerView* pTEOutlinerView=pTextEditOutlinerView;
|
||||
Cursor* pTECursorMerker=pTextEditCursorMerker;
|
||||
SdrUndoManager* pExtraUndoEditUndoManager = 0;
|
||||
|
||||
if(IsUndoEnabled() && GetModel() && pTEObj && pTEOutliner)
|
||||
{
|
||||
// change back the UndoManager to the remembered original one
|
||||
::svl::IUndoManager* pOriginal = pTEOutliner->SetUndoManager(mpOldTextEditUndoManager);
|
||||
mpOldTextEditUndoManager = 0;
|
||||
|
||||
if(pOriginal)
|
||||
{
|
||||
// check if we got back our document undo manager
|
||||
SdrUndoManager* pSdrUndoManager = dynamic_cast< SdrUndoManager* >(GetModel()->GetSdrUndoManager());
|
||||
|
||||
if(pSdrUndoManager && dynamic_cast< SdrUndoManager* >(pOriginal) == pSdrUndoManager)
|
||||
{
|
||||
// We are ending text edit; execute all redos to create a complete text change
|
||||
// undo action for the redo buffer. Also mark this state when at least one redo was
|
||||
// executed; the created TextChange needs to be undone plus the first real undo
|
||||
// outside the text edit changes
|
||||
while(pSdrUndoManager->GetRedoActionCount())
|
||||
{
|
||||
pExtraUndoEditUndoManager = pSdrUndoManager;
|
||||
pSdrUndoManager->Redo();
|
||||
}
|
||||
|
||||
// reset the callback link and let the undo manager cleanup all text edit
|
||||
// undo actions to get the stack back to the form before the text edit
|
||||
pSdrUndoManager->SetEndTextEditHdl(Link());
|
||||
}
|
||||
else
|
||||
{
|
||||
OSL_ENSURE(false, "<EFBFBD>Got UndoManager back in SdrEndTextEdit which is NOT the expected document UndoManager (!)");
|
||||
delete pOriginal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( GetModel() && mxTextEditObj.is() )
|
||||
{
|
||||
@@ -988,6 +1059,14 @@ SdrEndTextEditKind SdrObjEditView::SdrEndTextEdit(sal_Bool bDontDeleteReally)
|
||||
((SfxBroadcaster*)pTEObj->GetBroadcaster())->Broadcast(aHint);
|
||||
}
|
||||
|
||||
if(pExtraUndoEditUndoManager)
|
||||
{
|
||||
// undo the text edit action since it was created as part of a EndTextEdit
|
||||
// callback from undo itself. This needs to be done after the call to
|
||||
// FmFormView::SdrEndTextEdit since it gets created there
|
||||
pExtraUndoEditUndoManager->Undo();
|
||||
}
|
||||
|
||||
return eRet;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user