You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by al...@apache.org on 2012/08/09 11:42:28 UTC

svn commit: r1371123 - in /incubator/ooo/trunk/main: editeng/inc/editeng/ editeng/source/editeng/ editeng/source/outliner/ sd/inc/undo/ sd/source/core/undo/ sd/source/ui/view/ svx/ svx/inc/svx/ svx/source/svdraw/

Author: alg
Date: Thu Aug  9 09:42:27 2012
New Revision: 1371123

URL: http://svn.apache.org/viewvc?rev=1371123&view=rev
Log:
#120498# Enhanced Undo/Redo and user experience when editing texts in graphic objects and/or tables

Added:
    incubator/ooo/trunk/main/svx/inc/svx/sdrundomanager.hxx   (with props)
    incubator/ooo/trunk/main/svx/source/svdraw/sdrundomanager.cxx   (with props)
Modified:
    incubator/ooo/trunk/main/editeng/inc/editeng/editeng.hxx
    incubator/ooo/trunk/main/editeng/inc/editeng/editund2.hxx
    incubator/ooo/trunk/main/editeng/inc/editeng/outliner.hxx
    incubator/ooo/trunk/main/editeng/source/editeng/editeng.cxx
    incubator/ooo/trunk/main/editeng/source/editeng/editundo.cxx
    incubator/ooo/trunk/main/editeng/source/editeng/impedit.hxx
    incubator/ooo/trunk/main/editeng/source/outliner/outliner.cxx
    incubator/ooo/trunk/main/sd/inc/undo/undomanager.hxx
    incubator/ooo/trunk/main/sd/source/core/undo/undomanager.cxx
    incubator/ooo/trunk/main/sd/source/ui/view/drviewse.cxx
    incubator/ooo/trunk/main/svx/Library_svxcore.mk
    incubator/ooo/trunk/main/svx/Package_inc.mk
    incubator/ooo/trunk/main/svx/inc/svx/svdedxv.hxx
    incubator/ooo/trunk/main/svx/source/svdraw/svdedxv.cxx

Modified: incubator/ooo/trunk/main/editeng/inc/editeng/editeng.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/editeng/inc/editeng/editeng.hxx?rev=1371123&r1=1371122&r2=1371123&view=diff
==============================================================================
--- incubator/ooo/trunk/main/editeng/inc/editeng/editeng.hxx (original)
+++ incubator/ooo/trunk/main/editeng/inc/editeng/editeng.hxx Thu Aug  9 09:42:27 2012
@@ -266,8 +266,8 @@ public:
 	void			ShowParagraph( sal_uInt16 nParagraph, sal_Bool bShow = sal_True );
 	sal_Bool			IsParagraphVisible( sal_uInt16 nParagraph );
 
-    ::svl::IUndoManager&
-                    GetUndoManager();
+    ::svl::IUndoManager& GetUndoManager();
+    ::svl::IUndoManager* SetUndoManager(::svl::IUndoManager* pNew);
 	void			UndoActionStart( sal_uInt16 nId );
 	void			UndoActionEnd( sal_uInt16 nId );
 	sal_Bool		IsInUndo();

Modified: incubator/ooo/trunk/main/editeng/inc/editeng/editund2.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/editeng/inc/editeng/editund2.hxx?rev=1371123&r1=1371122&r2=1371123&view=diff
==============================================================================
--- incubator/ooo/trunk/main/editeng/inc/editeng/editund2.hxx (original)
+++ incubator/ooo/trunk/main/editeng/inc/editeng/editund2.hxx Thu Aug  9 09:42:27 2012
@@ -29,15 +29,18 @@
 
 class ImpEditEngine;
 
-class EDITENG_DLLPRIVATE EditUndoManager : public SfxUndoManager
+class EDITENG_DLLPUBLIC EditUndoManager : public SfxUndoManager
 {
+private:
 	using SfxUndoManager::Undo;
 	using SfxUndoManager::Redo;
+    friend class ImpEditEngine;
+
+	ImpEditEngine*	mpImpEE;
+    void SetImpEditEngine(ImpEditEngine* pNew);
 
-private:
-	ImpEditEngine*	pImpEE;
 public:
-					EditUndoManager( ImpEditEngine* pImpEE );
+    EditUndoManager(sal_uInt16 nMaxUndoActionCount = 20);
 
 	virtual sal_Bool Undo();
 	virtual sal_Bool Redo();

Modified: incubator/ooo/trunk/main/editeng/inc/editeng/outliner.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/editeng/inc/editeng/outliner.hxx?rev=1371123&r1=1371122&r2=1371123&view=diff
==============================================================================
--- incubator/ooo/trunk/main/editeng/inc/editeng/outliner.hxx (original)
+++ incubator/ooo/trunk/main/editeng/inc/editeng/outliner.hxx Thu Aug  9 09:42:27 2012
@@ -939,8 +939,8 @@ public:
 	// nFormat muss ein Wert aus dem enum EETextFormat sein (wg.CLOOKS)
     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 );

Modified: incubator/ooo/trunk/main/editeng/source/editeng/editeng.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/editeng/source/editeng/editeng.cxx?rev=1371123&r1=1371122&r2=1371123&view=diff
==============================================================================
--- incubator/ooo/trunk/main/editeng/source/editeng/editeng.cxx (original)
+++ incubator/ooo/trunk/main/editeng/source/editeng/editeng.cxx Thu Aug  9 09:42:27 2012
@@ -147,6 +147,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 );

Modified: incubator/ooo/trunk/main/editeng/source/editeng/editundo.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/editeng/source/editeng/editundo.cxx?rev=1371123&r1=1371122&r2=1371123&view=diff
==============================================================================
--- incubator/ooo/trunk/main/editeng/source/editeng/editundo.cxx (original)
+++ incubator/ooo/trunk/main/editeng/source/editeng/editundo.cxx Thu Aug  9 09:42:27 2012
@@ -65,22 +65,28 @@ void lcl_DoSetSelection( EditView* pView
 // -----------------------------------------------------------------------
 // EditUndoManager
 // ------------------------------------------------------------------------
-EditUndoManager::EditUndoManager( ImpEditEngine* p )
+EditUndoManager::EditUndoManager(sal_uInt16 nMaxUndoActionCount )
+:   SfxUndoManager(nMaxUndoActionCount),
+    mpImpEE(0)
 {
-	pImpEE = p;
+}
+
+void EditUndoManager::SetImpEditEngine(ImpEditEngine* pNew) 
+{ 
+    mpImpEE = pNew; 
 }
 
 sal_Bool __EXPORT EditUndoManager::Undo()
 {
-	if ( GetUndoActionCount() == 0 )
+	if ( !mpImpEE || GetUndoActionCount() == 0 )
 		return sal_False;
 
-	DBG_ASSERT( pImpEE->GetActiveView(), "Active View?" );
+	DBG_ASSERT( mpImpEE->GetActiveView(), "Active View?" );
 
-	if ( !pImpEE->GetActiveView() )
+	if ( !mpImpEE->GetActiveView() )
 	{
-		if ( pImpEE->GetEditViews().Count() )
-			pImpEE->SetActiveView( pImpEE->GetEditViews().GetObject(0) );
+		if ( mpImpEE->GetEditViews().Count() )
+			mpImpEE->SetActiveView( mpImpEE->GetEditViews().GetObject(0) );
 		else
 		{
 			DBG_ERROR( "Undo in Engine ohne View nicht moeglich!" );
@@ -88,34 +94,34 @@ sal_Bool __EXPORT EditUndoManager::Undo(
 		}
 	}
 
-	pImpEE->GetActiveView()->GetImpEditView()->DrawSelection();	// alte Selektion entfernen
+	mpImpEE->GetActiveView()->GetImpEditView()->DrawSelection();	// alte Selektion entfernen
 
-	pImpEE->SetUndoMode( sal_True );
+	mpImpEE->SetUndoMode( sal_True );
 	sal_Bool bDone = SfxUndoManager::Undo();
-	pImpEE->SetUndoMode( sal_False );
+	mpImpEE->SetUndoMode( sal_False );
 
-	EditSelection aNewSel( pImpEE->GetActiveView()->GetImpEditView()->GetEditSelection() );
+	EditSelection aNewSel( mpImpEE->GetActiveView()->GetImpEditView()->GetEditSelection() );
 	DBG_ASSERT( !aNewSel.IsInvalid(), "Ungueltige Selektion nach Undo()" );
-	DBG_ASSERT( !aNewSel.DbgIsBuggy( pImpEE->GetEditDoc() ), "Kaputte Selektion nach Undo()" );
+	DBG_ASSERT( !aNewSel.DbgIsBuggy( mpImpEE->GetEditDoc() ), "Kaputte Selektion nach Undo()" );
 
 	aNewSel.Min() = aNewSel.Max();
-	pImpEE->GetActiveView()->GetImpEditView()->SetEditSelection( aNewSel );
-	pImpEE->FormatAndUpdate( pImpEE->GetActiveView() );
+	mpImpEE->GetActiveView()->GetImpEditView()->SetEditSelection( aNewSel );
+	mpImpEE->FormatAndUpdate( mpImpEE->GetActiveView() );
 
 	return bDone;
 }
 
 sal_Bool __EXPORT EditUndoManager::Redo()
 {
-	if ( GetRedoActionCount() == 0 )
+	if ( !mpImpEE || GetRedoActionCount() == 0 )
 		return sal_False;
 
-	DBG_ASSERT( pImpEE->GetActiveView(), "Active View?" );
+	DBG_ASSERT( mpImpEE->GetActiveView(), "Active View?" );
 
-	if ( !pImpEE->GetActiveView() )
+	if ( !mpImpEE->GetActiveView() )
 	{
-		if ( pImpEE->GetEditViews().Count() )
-			pImpEE->SetActiveView( pImpEE->GetEditViews().GetObject(0) );
+		if ( mpImpEE->GetEditViews().Count() )
+			mpImpEE->SetActiveView( mpImpEE->GetEditViews().GetObject(0) );
 		else
 		{
 			DBG_ERROR( "Redo in Engine ohne View nicht moeglich!" );
@@ -123,19 +129,19 @@ sal_Bool __EXPORT EditUndoManager::Redo(
 		}
 	}
 
-	pImpEE->GetActiveView()->GetImpEditView()->DrawSelection();	// alte Selektion entfernen
+	mpImpEE->GetActiveView()->GetImpEditView()->DrawSelection();	// alte Selektion entfernen
 
-	pImpEE->SetUndoMode( sal_True );
+	mpImpEE->SetUndoMode( sal_True );
 	sal_Bool bDone = SfxUndoManager::Redo();
-	pImpEE->SetUndoMode( sal_False );
+	mpImpEE->SetUndoMode( sal_False );
 
-	EditSelection aNewSel( pImpEE->GetActiveView()->GetImpEditView()->GetEditSelection() );
+	EditSelection aNewSel( mpImpEE->GetActiveView()->GetImpEditView()->GetEditSelection() );
 	DBG_ASSERT( !aNewSel.IsInvalid(), "Ungueltige Selektion nach Undo()" );
-	DBG_ASSERT( !aNewSel.DbgIsBuggy( pImpEE->GetEditDoc() ), "Kaputte Selektion nach Redo()" );
+	DBG_ASSERT( !aNewSel.DbgIsBuggy( mpImpEE->GetEditDoc() ), "Kaputte Selektion nach Redo()" );
 
 	aNewSel.Min() = aNewSel.Max();
-	pImpEE->GetActiveView()->GetImpEditView()->SetEditSelection( aNewSel );
-	pImpEE->FormatAndUpdate( pImpEE->GetActiveView() );
+	mpImpEE->GetActiveView()->GetImpEditView()->SetEditSelection( aNewSel );
+	mpImpEE->FormatAndUpdate( mpImpEE->GetActiveView() );
 
 	return bDone;
 }

Modified: incubator/ooo/trunk/main/editeng/source/editeng/impedit.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/editeng/source/editeng/impedit.hxx?rev=1371123&r1=1371122&r2=1371123&view=diff
==============================================================================
--- incubator/ooo/trunk/main/editeng/source/editeng/impedit.hxx (original)
+++ incubator/ooo/trunk/main/editeng/source/editeng/impedit.hxx Thu Aug  9 09:42:27 2012
@@ -709,6 +709,7 @@ public:
 	const EditDoc&			GetEditDoc() const		{ return aEditDoc; }
 
 	inline EditUndoManager&	GetUndoManager();
+    inline ::svl::IUndoManager* SetUndoManager(::svl::IUndoManager* pNew);
 
 	void					SetUpdateMode( sal_Bool bUp, EditView* pCurView = 0, sal_Bool bForceUpdate = sal_False );
 	sal_Bool				GetUpdateMode()	const	{ return bUpdate; }
@@ -1097,14 +1098,35 @@ inline void ImpEditEngine::IdleFormatAnd
 	aIdleFormatter.DoIdleFormat( pCurView );
 }
 
-#ifndef SVX_LIGHT
 inline EditUndoManager&	ImpEditEngine::GetUndoManager()
 {
 	if ( !pUndoManager )
-		pUndoManager = new EditUndoManager( this );
+    {
+		pUndoManager = new EditUndoManager();
+        pUndoManager->SetImpEditEngine(this);
+    }
 	return *pUndoManager;
 }
-#endif
+
+inline ::svl::IUndoManager* ImpEditEngine::SetUndoManager(::svl::IUndoManager* pNew)
+{
+    ::svl::IUndoManager* pRetval = pUndoManager;
+    EditUndoManager* pNewEditUndoManager = dynamic_cast< EditUndoManager* >(pNew);
+
+    if(pUndoManager)
+    {
+        pUndoManager->SetImpEditEngine(0);
+    }
+
+    pUndoManager = dynamic_cast< EditUndoManager* >(pNew);
+
+    if(pUndoManager)
+    {
+        pUndoManager->SetImpEditEngine(this);
+    }
+
+    return pRetval;
+}
 
 inline ParaPortion*	ImpEditEngine::FindParaPortion( ContentNode* pNode ) const
 {

Modified: incubator/ooo/trunk/main/editeng/source/outliner/outliner.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/editeng/source/outliner/outliner.cxx?rev=1371123&r1=1371122&r2=1371123&view=diff
==============================================================================
--- incubator/ooo/trunk/main/editeng/source/outliner/outliner.cxx (original)
+++ incubator/ooo/trunk/main/editeng/source/outliner/outliner.cxx Thu Aug  9 09:42:27 2012
@@ -1229,6 +1229,12 @@ void Outliner::ImpFilterIndents( sal_uLo
 	return pEditEngine->GetUndoManager();
 }
 
+::svl::IUndoManager* Outliner::SetUndoManager(::svl::IUndoManager* pNew)
+{
+	DBG_CHKTHIS(Outliner,0);
+	return pEditEngine->SetUndoManager(pNew);
+}
+
 void Outliner::ImpTextPasted( sal_uLong nStartPara, sal_uInt16 nCount )
 {
 	DBG_CHKTHIS(Outliner,0);

Modified: incubator/ooo/trunk/main/sd/inc/undo/undomanager.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sd/inc/undo/undomanager.hxx?rev=1371123&r1=1371122&r2=1371123&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sd/inc/undo/undomanager.hxx (original)
+++ incubator/ooo/trunk/main/sd/inc/undo/undomanager.hxx Thu Aug  9 09:42:27 2012
@@ -24,13 +24,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 );
@@ -44,8 +44,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.

Modified: incubator/ooo/trunk/main/sd/source/core/undo/undomanager.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sd/source/core/undo/undomanager.cxx?rev=1371123&r1=1371122&r2=1371123&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sd/source/core/undo/undomanager.cxx (original)
+++ incubator/ooo/trunk/main/sd/source/core/undo/undomanager.cxx Thu Aug  9 09:42:27 2012
@@ -23,13 +23,14 @@
 
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_sd.hxx"
+
 #include <tools/debug.hxx>
-#include "undo/undomanager.hxx"
+#include <undo/undomanager.hxx>
 
 using namespace sd;
 
 UndoManager::UndoManager( sal_uInt16 nMaxUndoActionCount /* = 20 */ )
-: SfxUndoManager( nMaxUndoActionCount )
+: SdrUndoManager( nMaxUndoActionCount )
 , mpLinkedUndoManager(NULL)
 {
 }
@@ -39,7 +40,7 @@ void UndoManager::EnterListAction(const 
 	if( !IsDoing() )
 	{
         ClearLinkedRedoActions();
-		SfxUndoManager::EnterListAction( rComment, rRepeatComment, nId );
+		SdrUndoManager::EnterListAction( rComment, rRepeatComment, nId );
 	}
 }
 
@@ -48,7 +49,7 @@ void UndoManager::AddUndoAction( SfxUndo
 	if( !IsDoing() )
 	{
         ClearLinkedRedoActions();
-		SfxUndoManager::AddUndoAction( pAction, bTryMerg );
+		SdrUndoManager::AddUndoAction( pAction, bTryMerg );
 	}
 	else
 	{

Modified: incubator/ooo/trunk/main/sd/source/ui/view/drviewse.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sd/source/ui/view/drviewse.cxx?rev=1371123&r1=1371122&r2=1371123&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sd/source/ui/view/drviewse.cxx (original)
+++ incubator/ooo/trunk/main/sd/source/ui/view/drviewse.cxx Thu Aug  9 09:42:27 2012
@@ -639,10 +639,6 @@ void DrawViewShell::FuPermanent(SfxReque
 	}
 }
 
-//////////////////////////////////////////////////////////////////////////////
-// service routine for Undo/Redo implementation
-extern SfxUndoManager* ImpGetUndoManagerFromViewShell(DrawViewShell& rDViewShell);
-
 /*************************************************************************
 |*
 |* SfxRequests fuer Support-Funktionen

Modified: incubator/ooo/trunk/main/svx/Library_svxcore.mk
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svx/Library_svxcore.mk?rev=1371123&r1=1371122&r2=1371123&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svx/Library_svxcore.mk (original)
+++ incubator/ooo/trunk/main/svx/Library_svxcore.mk Thu Aug  9 09:42:27 2012
@@ -299,6 +299,7 @@ $(eval $(call gb_Library_add_exception_o
     svx/source/svdraw/gradtrns \
     svx/source/svdraw/polypolygoneditor \
     svx/source/svdraw/sdrcomment \
+    svx/source/svdraw/sdrundomanager \
     svx/source/svdraw/sdrhittesthelper \
     svx/source/svdraw/sdrmasterpagedescriptor \
     svx/source/svdraw/sdrpagewindow \

Modified: incubator/ooo/trunk/main/svx/Package_inc.mk
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svx/Package_inc.mk?rev=1371123&r1=1371122&r2=1371123&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svx/Package_inc.mk (original)
+++ incubator/ooo/trunk/main/svx/Package_inc.mk Thu Aug  9 09:42:27 2012
@@ -376,6 +376,7 @@ $(eval $(call gb_Package_add_file,svx_in
 $(eval $(call gb_Package_add_file,svx_inc,inc/svx/AccessibleShapeInfo.hxx,svx/AccessibleShapeInfo.hxx))
 $(eval $(call gb_Package_add_file,svx_inc,inc/svx/numvset.hxx,svx/numvset.hxx))
 $(eval $(call gb_Package_add_file,svx_inc,inc/svx/sdrcomment.hxx,svx/sdrcomment.hxx))
+$(eval $(call gb_Package_add_file,svx_inc,inc/svx/sdrundomanager.hxx,svx/sdrundomanager.hxx))
 $(eval $(call gb_Package_add_file,svx_inc,inc/svx/txenctab.hxx,svx/txenctab.hxx))
 $(eval $(call gb_Package_add_file,svx_inc,inc/svx/svdorect.hxx,svx/svdorect.hxx))
 $(eval $(call gb_Package_add_file,svx_inc,inc/svx/xftshit.hxx,svx/xftshit.hxx))

Added: incubator/ooo/trunk/main/svx/inc/svx/sdrundomanager.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svx/inc/svx/sdrundomanager.hxx?rev=1371123&view=auto
==============================================================================
--- incubator/ooo/trunk/main/svx/inc/svx/sdrundomanager.hxx (added)
+++ incubator/ooo/trunk/main/svx/inc/svx/sdrundomanager.hxx Thu Aug  9 09:42:27 2012
@@ -0,0 +1,59 @@
+/**************************************************************
+ * 
+ * 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
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+#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

Propchange: incubator/ooo/trunk/main/svx/inc/svx/sdrundomanager.hxx
------------------------------------------------------------------------------
    svn:executable = *

Modified: incubator/ooo/trunk/main/svx/inc/svx/svdedxv.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svx/inc/svx/svdedxv.hxx?rev=1371123&r1=1371122&r2=1371123&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svx/inc/svx/svdedxv.hxx (original)
+++ incubator/ooo/trunk/main/svx/inc/svx/svdedxv.hxx Thu Aug  9 09:42:27 2012
@@ -42,6 +42,7 @@ class EditStatus;
 class EditFieldInfo;
 class ImpSdrEditPara;
 struct PasteOrDropInfos;
+class SdrUndoManager;
 
 namespace com { namespace sun { namespace star { namespace uno {
 	class Any;
@@ -101,7 +102,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)
@@ -114,6 +115,8 @@ protected:
 	rtl::Reference< sdr::SelectionController > mxLastSelectionController;
 
 private:
+    ::svl::IUndoManager* mpOldTextEditUndoManager;
+
 	SVX_DLLPRIVATE void ImpClearVars();
 
 protected:
@@ -134,7 +137,10 @@ protected:
 	DECL_LINK(ImpOutlinerStatusEventHdl,EditStatus*);
 	DECL_LINK(ImpOutlinerCalcFieldValueHdl,EditFieldInfo*);
 
-	void ImpMacroUp(const Point& rUpPos);
+    // link for EndTextEditHdl
+	DECL_LINK(EndTextEditHdl, SdrUndoManager*);
+
+    void ImpMacroUp(const Point& rUpPos);
 	void ImpMacroDown(const Point& rDownPos);
 
    	DECL_LINK( BeginPasteOrDropHdl, PasteOrDropInfos* );

Added: incubator/ooo/trunk/main/svx/source/svdraw/sdrundomanager.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svx/source/svdraw/sdrundomanager.cxx?rev=1371123&view=auto
==============================================================================
--- incubator/ooo/trunk/main/svx/source/svdraw/sdrundomanager.cxx (added)
+++ incubator/ooo/trunk/main/svx/source/svdraw/sdrundomanager.cxx Thu Aug  9 09:42:27 2012
@@ -0,0 +1,114 @@
+/**************************************************************
+ * 
+ * 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
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svx.hxx"
+#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

Propchange: incubator/ooo/trunk/main/svx/source/svdraw/sdrundomanager.cxx
------------------------------------------------------------------------------
    svn:executable = *

Modified: incubator/ooo/trunk/main/svx/source/svdraw/svdedxv.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svx/source/svdraw/svdedxv.cxx?rev=1371123&r1=1371122&r2=1371123&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svx/source/svdraw/svdedxv.cxx (original)
+++ incubator/ooo/trunk/main/svx/source/svdraw/svdedxv.cxx Thu Aug  9 09:42:27 2012
@@ -73,6 +73,7 @@
 #include <svtools/colorcfg.hxx>
 #include <vcl/svapp.hxx> //add CHINA001 
 #include <svx/sdrpaintwindow.hxx>
+#include <svx/sdrundomanager.hxx>
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -97,7 +98,8 @@ void SdrObjEditView::ImpClearVars()
 }
 
 SdrObjEditView::SdrObjEditView(SdrModel* pModel1, OutputDevice* pOut):
-    SdrGlueEditView(pModel1,pOut)
+    SdrGlueEditView(pModel1,pOut),
+    mpOldTextEditUndoManager(0)
 {
     ImpClearVars();
 }
@@ -109,6 +111,11 @@ SdrObjEditView::~SdrObjEditView()
     if (pTextEditOutliner!=NULL) {
         delete pTextEditOutliner;
     }
+
+    if(mpOldTextEditUndoManager)
+    {
+        delete mpOldTextEditUndoManager;
+    }
 }
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -537,6 +544,12 @@ IMPL_LINK(SdrObjEditView,ImpOutlinerCalc
     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, 
@@ -765,6 +778,31 @@ sal_Bool SdrObjEditView::SdrBeginTextEdi
 			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; // Gut gelaufen, TextEdit laeuft nun
         } 
 		else 
@@ -822,6 +860,42 @@ SdrEndTextEditKind SdrObjEditView::SdrEn
     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, "´Got UndoManager back in SdrEndTextEdit which is NOT the expected document UndoManager (!)");
+                delete pOriginal;
+            }
+        }
+    }
 
     // send HINT_ENDEDIT #99840#
     if( GetModel() && mxTextEditObj.is() )
@@ -1031,7 +1105,15 @@ SdrEndTextEditKind SdrObjEditView::SdrEn
 		((SfxBroadcaster*)pTEObj->GetBroadcaster())->Broadcast(aHint);
 	}
 
-	return eRet;
+    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;
 }
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////