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/10 16:30:32 UTC

svn commit: r1371716 - in /incubator/ooo/trunk/main/sw/source/core: draw/dview.cxx inc/UndoManager.hxx inc/dview.hxx undo/docundo.cxx

Author: alg
Date: Fri Aug 10 14:30:31 2012
New Revision: 1371716

URL: http://svn.apache.org/viewvc?rev=1371716&view=rev
Log:
#120515# Implemented and finetuned the enhanced Undo feature (see #120498#) for sw

Modified:
    incubator/ooo/trunk/main/sw/source/core/draw/dview.cxx
    incubator/ooo/trunk/main/sw/source/core/inc/UndoManager.hxx
    incubator/ooo/trunk/main/sw/source/core/inc/dview.hxx
    incubator/ooo/trunk/main/sw/source/core/undo/docundo.cxx

Modified: incubator/ooo/trunk/main/sw/source/core/draw/dview.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/core/draw/dview.cxx?rev=1371716&r1=1371715&r2=1371716&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/core/draw/dview.cxx (original)
+++ incubator/ooo/trunk/main/sw/source/core/draw/dview.cxx Fri Aug 10 14:30:31 2012
@@ -19,8 +19,6 @@
  * 
  *************************************************************/
 
-
-
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_sw.hxx"
 
@@ -29,6 +27,9 @@
 #include <svx/svdpagv.hxx>
 #include <svx/fmmodel.hxx>
 #include <sot/exchange.hxx>
+#include <svx/sdrundomanager.hxx>
+#include <editeng/outliner.hxx>
+#include <com/sun/star/embed/EmbedMisc.hpp>
 
 #include "swtypes.hxx"
 #include "pagefrm.hxx"
@@ -49,26 +50,13 @@
 #include <fmtanchr.hxx>
 #include "shellres.hxx"
 #include <IDocumentUndoRedo.hxx>
-
-// #i7672#
-#include <editeng/outliner.hxx>
-
-#include <com/sun/star/embed/EmbedMisc.hpp>
-
-// OD 18.06.2003 #108784#
-//#ifndef _SVDVMARK_HXX //autogen
-//#include <svx/svdvmark.hxx>
-//#endif
 #include <vector>
-// --> OD 2004-06-24 #i28701#
 #include <sortedobjs.hxx>
 #include <flyfrms.hxx>
-// <--
-
+#include <UndoManager.hxx>
 
 using namespace com::sun::star;
 
-
 class SwSdrHdl : public SdrHdl
 {
 public:
@@ -1109,3 +1097,12 @@ void SwDrawView::DeleteMarked()
 		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;
+}
+
+// eof

Modified: incubator/ooo/trunk/main/sw/source/core/inc/UndoManager.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/core/inc/UndoManager.hxx?rev=1371716&r1=1371715&r2=1371716&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/core/inc/UndoManager.hxx (original)
+++ incubator/ooo/trunk/main/sw/source/core/inc/UndoManager.hxx Fri Aug 10 14:30:31 2012
@@ -25,22 +25,18 @@
 #define SW_UNDO_MANAGER_HXX
 
 #include <IDocumentUndoRedo.hxx>
-
 #include <memory>
-
-#include <svl/undo.hxx>
-
+#include <svx/sdrundomanager.hxx>
 
 class IDocumentDrawModelAccess;
 class IDocumentRedlineAccess;
 class IDocumentState;
 
-
 namespace sw {
 
 class UndoManager
     : public IDocumentUndoRedo
-    , public SfxUndoManager
+    , public SdrUndoManager
 {
 public:
 
@@ -111,7 +107,7 @@ private:
     bool impl_DoUndoRedo(UndoOrRedo_t const undoOrRedo);
 
     // UGLY: should not be called
-    using SfxUndoManager::Repeat;
+    using SdrUndoManager::Repeat;
 };
 
 } // namespace sw

Modified: incubator/ooo/trunk/main/sw/source/core/inc/dview.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/core/inc/dview.hxx?rev=1371716&r1=1371715&r2=1371716&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/core/inc/dview.hxx (original)
+++ incubator/ooo/trunk/main/sw/source/core/inc/dview.hxx Fri Aug 10 14:30:31 2012
@@ -31,6 +31,7 @@ class SwViewImp;
 class SwFrm;
 class SwFlyFrm;
 class SwAnchoredObject;
+class SdrUndoManager;
 
 class SwDrawView : public FmFormView
 {
@@ -87,6 +88,9 @@ protected:
     using FmFormView::CheckSingleSdrObjectHit;
     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:
 	SwDrawView( SwViewImp &rI, SdrModel *pMd, OutputDevice* pOutDev=NULL );
 

Modified: incubator/ooo/trunk/main/sw/source/core/undo/docundo.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/core/undo/docundo.cxx?rev=1371716&r1=1371715&r2=1371716&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/core/undo/docundo.cxx (original)
+++ incubator/ooo/trunk/main/sw/source/core/undo/docundo.cxx Fri Aug 10 14:30:31 2012
@@ -74,7 +74,7 @@ UndoManager::UndoManager(::std::auto_ptr
     OSL_ASSERT(m_pUndoNodes.get());
     // writer expects it to be disabled initially
     // Undo is enabled by SwEditShell constructor
-    SfxUndoManager::EnableUndo(false);
+    SdrUndoManager::EnableUndo(false);
 }
 
 SwNodes const& UndoManager::GetUndoNodes() const
@@ -94,18 +94,28 @@ bool UndoManager::IsUndoNodes(SwNodes co
 
 void UndoManager::DoUndo(bool const bDoUndo)
 {
-    EnableUndo(bDoUndo);
-
-    SdrModel *const pSdrModel = m_rDrawModelAccess.GetDrawModel();
-	if( pSdrModel )
+    if(!isTextEditActive())
     {
-        pSdrModel->EnableUndo(bDoUndo);
+        EnableUndo(bDoUndo);
+
+        SdrModel *const pSdrModel = m_rDrawModelAccess.GetDrawModel();
+	    if( pSdrModel )
+        {
+            pSdrModel->EnableUndo(bDoUndo);
+        }
     }
 }
 
 bool UndoManager::DoesUndo() const
 {
-    return IsUndoEnabled();
+    if(isTextEditActive())
+    {
+        return false;
+    }
+    else
+    {
+        return IsUndoEnabled();
+    }
 }
 
 void UndoManager::DoGroupUndo(bool const bDoUndo)
@@ -164,11 +174,11 @@ void UndoManager::UnLockUndoNoModifiedPo
 
 SwUndo* UndoManager::GetLastUndo()
 {
-    if (!SfxUndoManager::GetUndoActionCount(CurrentLevel))
+    if (!SdrUndoManager::GetUndoActionCount(CurrentLevel))
     {
         return 0;
     }
-    SfxUndoAction *const pAction( SfxUndoManager::GetUndoAction(0) );
+    SfxUndoAction *const pAction( SdrUndoManager::GetUndoAction(0) );
     return dynamic_cast<SwUndo*>(pAction);
 }
 
@@ -179,14 +189,14 @@ void UndoManager::AppendUndo(SwUndo *con
 
 void UndoManager::ClearRedo()
 {
-    return SfxUndoManager::ImplClearRedo_NoLock(TopLevel);
+    return SdrUndoManager::ImplClearRedo_NoLock(TopLevel);
 }
 
 void UndoManager::DelAllUndoObj()
 {
     ::sw::UndoGuard const undoGuard(*this);
 
-    SfxUndoManager::ClearAllLevels();
+    SdrUndoManager::ClearAllLevels();
 
     m_UndoSaveMark = MARK_INVALID;
 }
@@ -215,7 +225,7 @@ UndoManager::StartUndo(SwUndoId const i_
         comment = pRewriter->Apply(comment);
     }
 
-    SfxUndoManager::EnterListAction(comment, comment, eUndoId);
+    SdrUndoManager::EnterListAction(comment, comment, eUndoId);
 
     return eUndoId;
 }
@@ -235,8 +245,8 @@ UndoManager::EndUndo(SwUndoId const i_eU
                 "EndUndo(): no Undo ID, but rewriter given?");
 
     SfxUndoAction *const pLastUndo(
-        (0 == SfxUndoManager::GetUndoActionCount(CurrentLevel))
-            ? 0 : SfxUndoManager::GetUndoAction(0) );
+        (0 == SdrUndoManager::GetUndoActionCount(CurrentLevel))
+            ? 0 : SdrUndoManager::GetUndoAction(0) );
 
     int const nCount = LeaveListAction();
 
@@ -244,7 +254,7 @@ UndoManager::EndUndo(SwUndoId const i_eU
     {
         OSL_ASSERT(pLastUndo);
         OSL_ASSERT(UNDO_START != eUndoId);
-        SfxUndoAction *const pUndoAction(SfxUndoManager::GetUndoAction(0));
+        SfxUndoAction *const pUndoAction(SdrUndoManager::GetUndoAction(0));
         SfxListUndoAction *const pListAction(
             dynamic_cast<SfxListUndoAction*>(pUndoAction));
         OSL_ASSERT(pListAction);
@@ -291,12 +301,12 @@ UndoManager::GetLastUndoInfo(
 {
     // this is actually expected to work on the current level,
     // but that was really not obvious from the previous implementation...
-    if (!SfxUndoManager::GetUndoActionCount(CurrentLevel))
+    if (!SdrUndoManager::GetUndoActionCount(CurrentLevel))
     {
         return false;
     }
 
-    SfxUndoAction *const pAction( SfxUndoManager::GetUndoAction(0) );
+    SfxUndoAction *const pAction( SdrUndoManager::GetUndoAction(0) );
 
     if (o_pStr)
     {
@@ -313,15 +323,15 @@ UndoManager::GetLastUndoInfo(
 
 SwUndoComments_t UndoManager::GetUndoComments() const
 {
-    OSL_ENSURE(!SfxUndoManager::IsInListAction(),
+    OSL_ENSURE(!SdrUndoManager::IsInListAction(),
             "GetUndoComments() called while in list action?");
 
     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)
     {
         ::rtl::OUString const comment(
-                SfxUndoManager::GetUndoActionComment(n, TopLevel));
+                SdrUndoManager::GetUndoActionComment(n, TopLevel));
         ret.push_back(comment);
     }
 
@@ -333,14 +343,14 @@ SwUndoComments_t UndoManager::GetUndoCom
 
 bool UndoManager::GetFirstRedoInfo(::rtl::OUString *const o_pStr) const
 {
-    if (!SfxUndoManager::GetRedoActionCount(CurrentLevel))
+    if (!SdrUndoManager::GetRedoActionCount(CurrentLevel))
     {
         return false;
     }
 
     if (o_pStr)
     {
-        *o_pStr = SfxUndoManager::GetRedoActionComment(0, CurrentLevel);
+        *o_pStr = SdrUndoManager::GetRedoActionComment(0, CurrentLevel);
     }
 
     return true;
@@ -349,15 +359,15 @@ bool UndoManager::GetFirstRedoInfo(::rtl
 
 SwUndoComments_t UndoManager::GetRedoComments() const
 {
-    OSL_ENSURE(!SfxUndoManager::IsInListAction(),
+    OSL_ENSURE(!SdrUndoManager::IsInListAction(),
             "GetRedoComments() called while in list action?");
 
     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)
     {
         ::rtl::OUString const comment(
-                SfxUndoManager::GetRedoActionComment(n, TopLevel));
+                SdrUndoManager::GetRedoActionComment(n, TopLevel));
         ret.push_back(comment);
     }
 
@@ -383,19 +393,19 @@ SwUndoId UndoManager::GetRepeatInfo(::rt
 
 SwUndo * UndoManager::RemoveLastUndo()
 {
-    if (SfxUndoManager::GetRedoActionCount(CurrentLevel) ||
-        SfxUndoManager::GetRedoActionCount(TopLevel))
+    if (SdrUndoManager::GetRedoActionCount(CurrentLevel) ||
+        SdrUndoManager::GetRedoActionCount(TopLevel))
     {
         OSL_ENSURE(false, "RemoveLastUndoAction(): there are Redo actions?");
         return 0;
     }
-    if (!SfxUndoManager::GetUndoActionCount(CurrentLevel))
+    if (!SdrUndoManager::GetUndoActionCount(CurrentLevel))
     {
         OSL_ENSURE(false, "RemoveLastUndoAction(): no Undo actions");
         return 0;
     }
     SfxUndoAction *const pLastUndo(GetUndoAction(0));
-    SfxUndoManager::RemoveLastUndoAction();
+    SdrUndoManager::RemoveLastUndoAction();
     return dynamic_cast<SwUndo *>(pLastUndo);
 }
 
@@ -403,9 +413,9 @@ SwUndo * UndoManager::RemoveLastUndo()
 
 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.
-    SfxUndoManager::EnableUndo(bEnable);
+    SdrUndoManager::EnableUndo(bEnable);
 }
 
 void UndoManager::AddUndoAction(SfxUndoAction *pAction, sal_Bool bTryMerge)
@@ -418,7 +428,7 @@ void UndoManager::AddUndoAction(SfxUndoA
             pUndo->SetRedlineMode( m_rRedlineAccess.GetRedlineMode() );
         }
     }
-    SfxUndoManager::AddUndoAction(pAction, bTryMerge);
+    SdrUndoManager::AddUndoAction(pAction, bTryMerge);
     // if the undo nodes array is too large, delete some actions
     while (UNDO_ACTION_LIMIT < GetUndoNodes().Count())
     {
@@ -483,17 +493,17 @@ bool UndoManager::impl_DoUndoRedo(UndoOr
     // N.B. these may throw!
     if (UNDO == undoOrRedo)
     {
-        bRet = SfxUndoManager::UndoWithContext(context);
+        bRet = SdrUndoManager::UndoWithContext(context);
     }
     else
     {
-        bRet = SfxUndoManager::RedoWithContext(context);
+        bRet = SdrUndoManager::RedoWithContext(context);
     }
 
     if (bRet)
     {
         // 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();
         }
@@ -510,31 +520,43 @@ bool UndoManager::impl_DoUndoRedo(UndoOr
 
 sal_Bool UndoManager::Undo()
 {
-    bool const bRet = impl_DoUndoRedo(UNDO);
-    return bRet;
+    if(isTextEditActive())
+    {
+        return SdrUndoManager::Undo();
+    }
+    else
+    {
+        return impl_DoUndoRedo(UNDO);
+    }
 }
 
 sal_Bool UndoManager::Redo()
 {
-    bool const bRet = impl_DoUndoRedo(REDO);
-    return bRet;
+    if(isTextEditActive())
+    {
+        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:
-          calling EnterListAction here will cause SfxUndoManager::Repeat
+          calling EnterListAction here will cause SdrUndoManager::Repeat
           to repeat the list action!
  */
 bool
 UndoManager::Repeat(::sw::RepeatContext & rContext,
         sal_uInt16 const nRepeatCount)
 {
-    if (SfxUndoManager::IsInListAction())
+    if (SdrUndoManager::IsInListAction())
     {
         OSL_ENSURE(false, "repeat in open list action???");
         return false;
     }
-    if (!SfxUndoManager::GetUndoActionCount(TopLevel))
+    if (!SdrUndoManager::GetUndoActionCount(TopLevel))
     {
         return false;
     }