summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mst@openoffice.org>2010-12-15 09:14:11 +0100
committerMichael Stahl <mst@openoffice.org>2010-12-15 09:14:11 +0100
commit1ba0c1878116ada5dc4ebdecdb1e0a3da9758547 (patch)
treef05a3cd3b9edf548208503349b23aab3063c8973
parentadd33f72ec6c6dbdc8cb11b24c018c8033f9a570 (diff)
undoapi: #i115383#: derive sw::UndoManager from SfxUndoManager:
derive SwUndo from SfxUndoAction. throw away most of docundo.cxx. throw away SwUndoStart and SwUndoEnd. replace SwUndoIter with sw::UndoRedoContext and sw::RepeatContext. SwUndo::GetId() no longer public to prevent abuse. add SwEditShell::HandleUndoRedoContext().
-rw-r--r--sw/inc/IDocumentUndoRedo.hxx15
-rw-r--r--sw/inc/SwUndoField.hxx23
-rw-r--r--sw/inc/editsh.hxx21
-rw-r--r--sw/inc/undobj.hxx600
-rw-r--r--sw/source/core/doc/dbgoutsw.cxx39
-rw-r--r--sw/source/core/doc/doc.cxx8
-rw-r--r--sw/source/core/docnode/ndtbl.cxx7
-rw-r--r--sw/source/core/edit/edundo.cxx167
-rw-r--r--sw/source/core/edit/makefile.mk2
-rw-r--r--sw/source/core/inc/SwUndoFmt.hxx31
-rw-r--r--sw/source/core/inc/SwUndoPageDesc.hxx25
-rw-r--r--sw/source/core/inc/SwUndoTOXChange.hxx14
-rw-r--r--sw/source/core/inc/UndoManager.hxx41
-rw-r--r--sw/source/core/inc/undoflystrattr.hxx11
-rw-r--r--sw/source/core/undo/SwUndoField.cxx26
-rw-r--r--sw/source/core/undo/SwUndoFmt.cxx24
-rw-r--r--sw/source/core/undo/SwUndoPageDesc.cxx35
-rw-r--r--sw/source/core/undo/SwUndoTOXChange.cxx16
-rw-r--r--sw/source/core/undo/docundo.cxx1025
-rw-r--r--sw/source/core/undo/makefile.mk1
-rw-r--r--sw/source/core/undo/rolbck.cxx9
-rw-r--r--sw/source/core/undo/unattr.cxx208
-rw-r--r--sw/source/core/undo/unbkmk.cxx14
-rw-r--r--sw/source/core/undo/undel.cxx22
-rw-r--r--sw/source/core/undo/undobj.cxx196
-rw-r--r--sw/source/core/undo/undobj1.cxx89
-rw-r--r--sw/source/core/undo/undoflystrattr.cxx9
-rw-r--r--sw/source/core/undo/undraw.cxx38
-rw-r--r--sw/source/core/undo/unfmco.cxx31
-rw-r--r--sw/source/core/undo/unins.cxx124
-rw-r--r--sw/source/core/undo/unmove.cxx16
-rw-r--r--sw/source/core/undo/unnum.cxx160
-rw-r--r--sw/source/core/undo/unoutl.cxx25
-rw-r--r--sw/source/core/undo/unovwr.cxx53
-rw-r--r--sw/source/core/undo/unredln.cxx125
-rw-r--r--sw/source/core/undo/unsect.cxx59
-rw-r--r--sw/source/core/undo/unsort.cxx36
-rw-r--r--sw/source/core/undo/unspnd.cxx39
-rw-r--r--sw/source/core/undo/untbl.cxx293
-rw-r--r--sw/source/core/undo/untblk.cxx34
-rw-r--r--sw/source/core/unocore/unotext.cxx13
-rw-r--r--sw/source/ui/app/docst.cxx2
-rw-r--r--sw/source/ui/wrtsh/select.cxx6
-rw-r--r--sw/source/ui/wrtsh/wrtundo.cxx2
44 files changed, 1634 insertions, 2100 deletions
diff --git a/sw/inc/IDocumentUndoRedo.hxx b/sw/inc/IDocumentUndoRedo.hxx
index 389b12239ee3..d8e4f8827fbb 100644
--- a/sw/inc/IDocumentUndoRedo.hxx
+++ b/sw/inc/IDocumentUndoRedo.hxx
@@ -33,11 +33,14 @@
#include <swundo.hxx>
-class SwUndoIter;
class SwRewriter;
class SwNodes;
class SwUndo;
+namespace sw {
+ class RepeatContext;
+}
+
/** IDocumentUndoRedo
@@ -98,10 +101,9 @@ public:
/** Execute Undo.
- @postcondition rUndoIter.pAktPam will contain the affected range.
@return true if executing the last Undo action was successful.
*/
- virtual bool Undo(SwUndoIter & rUndoIter) = 0; // -> #111827#
+ virtual sal_Bool Undo() = 0;
/** Opens undo block.
@@ -159,10 +161,9 @@ public:
/** Execute Redo.
- @postcondition rUndoIter.pAktPam will contain the affected range.
@return true if executing the first Redo action was successful.
*/
- virtual bool Redo(SwUndoIter & rUndoIter) = 0;
+ virtual sal_Bool Redo() = 0;
/** Get comment of first Redo action.
@param o_pStr if not 0, receives comment of first Redo action.
@@ -178,8 +179,8 @@ public:
/** Repeat the last Undo action.
@return true if repeating the last Undo Redo action was attempted.
*/
- virtual bool Repeat(SwUndoIter & rUndoIter, sal_uInt16 const nRepeatCnt)
- = 0;
+ virtual bool Repeat(::sw::RepeatContext & rContext,
+ sal_uInt16 const nRepeatCnt) = 0;
/** Get Id and comment of last Undo action, if it is Repeat capable.
@param o_pStr if not 0, receives comment of last Undo action
diff --git a/sw/inc/SwUndoField.hxx b/sw/inc/SwUndoField.hxx
index 33f5cfd85e49..b42ae2b5a0b0 100644
--- a/sw/inc/SwUndoField.hxx
+++ b/sw/inc/SwUndoField.hxx
@@ -24,8 +24,8 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-#ifndef _SW_UNDO_FIELD_HXX
-#define _SW_UNDO_FIELD_HXX
+#ifndef SW_UNDO_FIELD_HXX
+#define SW_UNDO_FIELD_HXX
#include <undobj.hxx>
@@ -53,16 +53,19 @@ class SwUndoFieldFromDoc : public SwUndoField
SwMsgPoolItem * pHnt;
BOOL bUpdate;
+ void DoImpl();
+
public:
SwUndoFieldFromDoc(const SwPosition & rPos, const SwField & aOldField,
const SwField & aNewField,
SwMsgPoolItem * pHnt, BOOL bUpdate,
SwUndoId nId = UNDO_FIELD );
+
virtual ~SwUndoFieldFromDoc();
- virtual void Undo(SwUndoIter & rIt);
- virtual void Redo(SwUndoIter & rIt);
- virtual void Repeat(SwUndoIter & rIt);
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+ virtual void RepeatImpl( ::sw::RepeatContext & );
};
class SwUndoFieldFromAPI : public SwUndoField
@@ -70,6 +73,8 @@ class SwUndoFieldFromAPI : public SwUndoField
com::sun::star::uno::Any aOldVal, aNewVal;
USHORT nWhich;
+ void DoImpl();
+
public:
SwUndoFieldFromAPI(const SwPosition & rPos,
const com::sun::star::uno::Any & rOldVal,
@@ -77,9 +82,9 @@ public:
USHORT nWhich);
virtual ~SwUndoFieldFromAPI();
- virtual void Undo(SwUndoIter & rIt);
- virtual void Redo(SwUndoIter & rIt);
- virtual void Repeat(SwUndoIter & rIt);
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+ virtual void RepeatImpl( ::sw::RepeatContext & );
};
-#endif // _SW_UNDO_FIELD_HXX
+#endif // SW_UNDO_FIELD_HXX
diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index c5f82d2ceebf..de590e4b5d78 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -122,6 +122,10 @@ namespace sfx2{
class LinkManager;
}
+namespace sw {
+ class UndoRedoContext;
+}
+
#define GETSELTXT_PARABRK_TO_BLANK 0
#define GETSELTXT_PARABRK_KEEP 1
#define GETSELTXT_PARABRK_TO_ONLYCR 2
@@ -538,13 +542,16 @@ public:
bool GetFirstRedoInfo(::rtl::OUString *const o_pStr) const;
SwUndoId GetRepeatInfo(::rtl::OUString *const o_pStr) const;
- // 0 letzte Aktion, sonst Aktionen bis zum Start der Klammerung nUndoId
- // mit KillPaMs, ClearMark
- BOOL Undo(SwUndoId nUndoId = UNDO_EMPTY, USHORT nCnt = 1 );
- // wiederholt
- USHORT Repeat( USHORT nCount );
- // wiederholt
- USHORT Redo( USHORT nCnt = 1 );
+ /// is it forbidden to modify cursors via API calls?
+ bool CursorsLocked() const;
+ /// set selections to those contained in the UndoRedoContext
+ /// should only be called by sw::UndoManager!
+ void HandleUndoRedoContext(::sw::UndoRedoContext & rContext);
+
+ bool Undo(USHORT const nCount = 1);
+ bool Redo(USHORT const nCount = 1);
+ bool Repeat(USHORT const nCount);
+
// fuer alle Sichten auf dieses Dokument
void StartAllAction();
void EndAllAction();
diff --git a/sw/inc/undobj.hxx b/sw/inc/undobj.hxx
index c02e30513077..6cf431f0df31 100644
--- a/sw/inc/undobj.hxx
+++ b/sw/inc/undobj.hxx
@@ -44,6 +44,7 @@
#include <svl/svstdarr.hxx>
#endif
#include <svl/itemset.hxx>
+#include <svl/undo.hxx>
#include <svx/svdundo.hxx> // #111827#
@@ -56,7 +57,6 @@
#include <IDocumentContentOperations.hxx>
-class SwUndoIter;
class SwHistory;
class SwIndex;
class SwPaM;
@@ -98,6 +98,7 @@ class SwSelBoxes;
class SwTableSortBoxes;
class SwUndoSaveSections;
class SwUndoMoves;
+class SwUndoDelete;
class SwStartNode;
class _SaveFlyArr;
class SwTblToTxtSaves;
@@ -116,13 +117,80 @@ namespace utl {
namespace sw {
class UndoManager;
+ class IShellCursorSupplier;
}
typedef SwRedlineSaveData* SwRedlineSaveDataPtr;
SV_DECL_PTRARR_DEL( SwRedlineSaveDatas, SwRedlineSaveDataPtr, 8, 8 )
+
+namespace sw {
+
+class SW_DLLPRIVATE UndoRedoContext
+ : public SfxUndoContext
+{
+public:
+ UndoRedoContext(SwDoc & rDoc, IShellCursorSupplier & rCursorSupplier)
+ : m_rDoc(rDoc)
+ , m_rCursorSupplier(rCursorSupplier)
+ , m_pSelFmt(0)
+ , m_pMarkList(0)
+ { }
+
+ SwDoc & GetDoc() const { return m_rDoc; }
+
+ IShellCursorSupplier & GetCursorSupplier() { return m_rCursorSupplier; }
+
+ void SetSelections(SwFrmFmt *const pSelFmt, SdrMarkList *const pMarkList)
+ {
+ m_pSelFmt = pSelFmt;
+ m_pMarkList = pMarkList;
+ }
+ void GetSelections(SwFrmFmt *& o_rpSelFmt, SdrMarkList *& o_rpMarkList)
+ {
+ o_rpSelFmt = m_pSelFmt;
+ o_rpMarkList = m_pMarkList;
+ }
+
+private:
+ SwDoc & m_rDoc;
+ IShellCursorSupplier & m_rCursorSupplier;
+ SwFrmFmt * m_pSelFmt;
+ SdrMarkList * m_pMarkList;
+};
+
+class SW_DLLPRIVATE RepeatContext
+ : public SfxRepeatTarget
+{
+public:
+ RepeatContext(SwDoc & rDoc, SwPaM & rPaM)
+ : m_rDoc(rDoc)
+ , m_pCurrentPaM(& rPaM)
+ , m_bDeleteRepeated(false)
+ { }
+
+ SwDoc & GetDoc() const { return m_rDoc; }
+
+ SwPaM & GetRepeatPaM()
+ {
+ return *m_pCurrentPaM;
+ }
+
+private:
+ friend class ::sw::UndoManager;
+ friend class ::SwUndoDelete;
+
+ SwDoc & m_rDoc;
+ SwPaM * m_pCurrentPaM;
+ bool m_bDeleteRepeated; /// has a delete action been repeated?
+};
+
+} // namespace sw
+
+
class SwUndo
+ : public SfxUndoAction
{
SwUndoId const m_nId;
USHORT nOrigRedlineMode;
@@ -146,16 +214,31 @@ protected:
@return the rewriter for this object
*/
virtual SwRewriter GetRewriter() const;
+
+ // return type is USHORT because this overrides SfxUndoAction::GetId()
+ virtual USHORT GetId() const { return static_cast<USHORT>(m_nId); }
+
+ // the 4 methods that derived classes have to override
+ // base implementation does nothing
+ virtual void RepeatImpl( ::sw::RepeatContext & );
+ virtual bool CanRepeatImpl( ::sw::RepeatContext & ) const;
+public: // should not be public, but ran into trouble in untbl.cxx
+ virtual void UndoImpl( ::sw::UndoRedoContext & ) = 0;
+ virtual void RedoImpl( ::sw::UndoRedoContext & ) = 0;
+
+private:
+ // SfxUndoAction
+ virtual void Undo();
+ virtual void Redo();
+ virtual void UndoWithContext(SfxUndoContext &);
+ virtual void RedoWithContext(SfxUndoContext &);
+ virtual void Repeat(SfxRepeatTarget &);
+ virtual BOOL CanRepeat(SfxRepeatTarget &) const;
+
public:
SwUndo(SwUndoId const nId);
virtual ~SwUndo();
- SwUndoId GetId() const { return m_nId; }
- virtual SwUndoId GetEffectiveId() const;
- virtual void Undo( SwUndoIter& ) = 0;
- virtual void Redo( SwUndoIter& ) = 0;
- virtual void Repeat( SwUndoIter& );
-
// #111827#
/**
Returns textual comment for this undo object.
@@ -277,65 +360,11 @@ public:
void SetValues( const SwPaM& rPam );
void SetPaM( SwPaM&, BOOL bCorrToCntnt = FALSE ) const;
- void SetPaM( SwUndoIter&, BOOL bCorrToCntnt = FALSE ) const;
+ SwPaM & AddUndoRedoPaM(
+ ::sw::UndoRedoContext &, bool const bCorrToCntnt = false) const;
};
-class SwUndoStart: public SwUndo
-{
- // Um innerhalb von Undo zuerkennen, wann ein Start vorliegt, gibt
- // GetId() immer die UNDO_START zurueck. Die UserId kann ueber
- // GetUserId() erfragt werden.
- SwUndoId nUserId;
- // fuer die "Verpointerung" von Start- und End-Undos
- USHORT nEndOffset;
-
-public:
- SwUndoStart( SwUndoId nId );
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
- virtual void Repeat( SwUndoIter& );
-
- // -> #111827#
- virtual String GetComment() const;
- void SetComment(String const& rString);
- // <- #111827#
-
- virtual SwUndoId GetEffectiveId() const;
- SwUndoId GetUserId() const { return nUserId; }
- // Setzen vom End-Undo-Offset geschieht im Doc::EndUndo
- USHORT GetEndOffset() const { return nEndOffset; }
- void SetEndOffset( USHORT n ) { nEndOffset = n; }
-};
-
-class SwUndoEnd: public SwUndo
-{
- // Um innerhalb von Undo zuerkennen, wann ein Ende vorliegt, gibt
- // GetId() immer die UNDO_END zurueck. Die UserId kann ueber
- // GetUserId() erfragt werden.
- SwUndoId nUserId;
- // fuer die "Verpointerung" von Start- und End-Undos
- USHORT nSttOffset;
-
-public:
- SwUndoEnd( SwUndoId nId );
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
- virtual void Repeat( SwUndoIter& );
-
- // -> #111827#
- virtual String GetComment() const;
- void SetComment(String const& rString);
- // <- #111827#
-
- virtual SwUndoId GetEffectiveId() const;
- SwUndoId GetUserId() const { return nUserId; }
-
- // Setzen vom Start-Undo-Offset geschieht im Doc::EndUndo
- void SetSttOffset(USHORT _nSttOffSet) { nSttOffset = _nSttOffSet; }
- USHORT GetSttOffset() const { return nSttOffset; }
-};
-
class SwUndoInsert: public SwUndo, private SwUndoSaveCntnt
{
SwPosition *pPos; // Inhalt fuers Redo
@@ -364,9 +393,9 @@ public:
SwUndoInsert( const SwNodeIndex& rNode );
virtual ~SwUndoInsert();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
- virtual void Repeat( SwUndoIter& );
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+ virtual void RepeatImpl( ::sw::RepeatContext & );
// #111827#
/**
@@ -418,9 +447,10 @@ class SwUndoDelete: public SwUndo, private SwUndRng, private SwUndoSaveCntnt
public:
SwUndoDelete( SwPaM&, BOOL bFullPara = FALSE, BOOL bCalledByTblCpy = FALSE );
virtual ~SwUndoDelete();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
- virtual void Repeat( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+ virtual void RepeatImpl( ::sw::RepeatContext & );
// #111827#
/**
@@ -464,10 +494,12 @@ class SwUndoOverwrite: public SwUndo, private SwUndoSaveCntnt
// CanGrouping() ausgwertet !!
public:
SwUndoOverwrite( SwDoc*, SwPosition&, sal_Unicode cIns );
+
virtual ~SwUndoOverwrite();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
- virtual void Repeat( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+ virtual void RepeatImpl( ::sw::RepeatContext & );
// #111827#
/**
@@ -497,10 +529,13 @@ class SwUndoSplitNode: public SwUndo
BOOL bChkTblStt : 1;
public:
SwUndoSplitNode( SwDoc* pDoc, const SwPosition& rPos, BOOL bChkTbl );
+
virtual ~SwUndoSplitNode();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
- virtual void Repeat( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+ virtual void RepeatImpl( ::sw::RepeatContext & );
+
void SetTblFlag() { bTblFlag = TRUE; }
};
@@ -525,8 +560,10 @@ class SwUndoMove : public SwUndo, private SwUndRng, private SwUndoSaveCntnt
public:
SwUndoMove( const SwPaM&, const SwPosition& );
SwUndoMove( SwDoc* pDoc, const SwNodeRange&, const SwNodeIndex& );
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+
// setze den Destination-Bereich nach dem Verschieben.
void SetDestRange( const SwPaM&, const SwPosition&, BOOL, BOOL );
void SetDestRange( const SwNodeIndex& rStt, const SwNodeIndex& rEnd,
@@ -556,10 +593,13 @@ class SwUndoAttr : public SwUndo, private SwUndRng
public:
SwUndoAttr( const SwPaM&, const SfxItemSet &, const SetAttrMode nFlags );
SwUndoAttr( const SwPaM&, const SfxPoolItem&, const SetAttrMode nFlags );
+
virtual ~SwUndoAttr();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
- virtual void Repeat( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+ virtual void RepeatImpl( ::sw::RepeatContext & );
+
void SaveRedlineData( const SwPaM& rPam, BOOL bInsCntnt );
SwHistory& GetHistory() { return *m_pHistory; }
@@ -575,10 +615,13 @@ class SwUndoResetAttr : public SwUndo, private SwUndRng
public:
SwUndoResetAttr( const SwPaM&, USHORT nFmtId );
SwUndoResetAttr( const SwPosition&, USHORT nFmtId );
+
virtual ~SwUndoResetAttr();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
- virtual void Repeat( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+ virtual void RepeatImpl( ::sw::RepeatContext & );
+
void SetAttrs( const SvUShortsSort& rArr );
SwHistory& GetHistory() { return *m_pHistory; }
@@ -604,7 +647,7 @@ class SwUndoFmtAttr : public SwUndo
// an invalid anchor position and all other existing attributes
// aren't restored.
// This situation occurs for undo of styles.
- bool RestoreFlyAnchor( SwUndoIter& rIter );
+ bool RestoreFlyAnchor(::sw::UndoRedoContext & rContext);
// <--
// --> OD 2008-02-27 #refactorlists# - removed <rAffectedItemSet>
void Init();
@@ -620,12 +663,13 @@ public:
SwUndoFmtAttr( const SfxPoolItem& rItem,
SwFmt& rFmt,
bool bSaveDrawPt = true );
+
virtual ~SwUndoFmtAttr();
- virtual void Undo( SwUndoIter& );
- // --> OD 2004-10-26 #i35443# - <Redo(..)> calls <Undo(..)> - nothing else
- virtual void Redo( SwUndoIter& );
- // <--
- virtual void Repeat( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+ virtual void RepeatImpl( ::sw::RepeatContext & );
+
virtual SwRewriter GetRewriter() const;
void PutAttr( const SfxPoolItem& rItem );
@@ -640,8 +684,8 @@ class SwUndoFmtResetAttr : public SwUndo
const USHORT nWhichId );
~SwUndoFmtResetAttr();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
private:
// format at which a certain attribute is reset.
@@ -660,9 +704,10 @@ class SwUndoDontExpandFmt : public SwUndo
public:
SwUndoDontExpandFmt( const SwPosition& rPos );
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
- virtual void Repeat( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+ virtual void RepeatImpl( ::sw::RepeatContext & );
};
// helper class to receive changed attribute sets
@@ -695,6 +740,9 @@ class SwUndoFmtColl : public SwUndo, private SwUndRng
// the nodes before the format has been applied.
const bool mbResetListAttrs;
// <--
+
+ void DoSetFmtColl(SwDoc & rDoc, SwPaM & rPaM);
+
public:
// --> OD 2008-04-15 #refactorlists#
// SwUndoFmtColl( const SwPaM&, SwFmtColl* );
@@ -703,9 +751,10 @@ public:
const bool bResetListAttrs );
// <--
virtual ~SwUndoFmtColl();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
- virtual void Repeat( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+ virtual void RepeatImpl( ::sw::RepeatContext & );
// #111827#
/**
@@ -735,10 +784,12 @@ class SwUndoMoveLeftMargin : public SwUndo, private SwUndRng
public:
SwUndoMoveLeftMargin( const SwPaM&, BOOL bRight, BOOL bModulus );
+
virtual ~SwUndoMoveLeftMargin();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
- virtual void Repeat( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+ virtual void RepeatImpl( ::sw::RepeatContext & );
SwHistory& GetHistory() { return *m_pHistory; }
@@ -761,9 +812,10 @@ protected:
public:
virtual ~SwUndoInserts();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
- virtual void Repeat( SwUndoIter& );
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+ virtual void RepeatImpl( ::sw::RepeatContext & );
+
// setze den Destination-Bereich nach dem Einlesen.
void SetInsertRange( const SwPaM&, BOOL bScanFlys = TRUE,
BOOL bSttWasTxtNd = TRUE );
@@ -798,10 +850,12 @@ public:
USHORT eAdjust, const SwInsertTableOptions& rInsTblOpts,
const SwTableAutoFmt* pTAFmt, const SvUShorts* pColArr,
const String & rName);
+
virtual ~SwUndoInsTbl();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
- virtual void Repeat( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+ virtual void RepeatImpl( ::sw::RepeatContext & );
virtual SwRewriter GetRewriter() const;
@@ -821,11 +875,13 @@ class SwUndoTxtToTbl : public SwUndo, public SwUndRng
public:
SwUndoTxtToTbl( const SwPaM&, const SwInsertTableOptions&, sal_Unicode , USHORT,
const SwTableAutoFmt* pAFmt );
+
virtual ~SwUndoTxtToTbl();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
- virtual void Repeat( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+ virtual void RepeatImpl( ::sw::RepeatContext & );
SwHistory& GetHistory(); // wird ggfs. angelegt
void AddFillBox( const SwTableBox& rBox );
@@ -846,10 +902,12 @@ class SwUndoTblToTxt : public SwUndo
public:
SwUndoTblToTxt( const SwTable& rTbl, sal_Unicode cCh );
+
virtual ~SwUndoTblToTxt();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
- virtual void Repeat( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+ virtual void RepeatImpl( ::sw::RepeatContext & );
void SetRange( const SwNodeRange& );
void AddBoxPos( SwDoc& rDoc, ULONG nNdIdx, ULONG nEndIdx,
@@ -863,9 +921,11 @@ class SwUndoAttrTbl : public SwUndo
BOOL bClearTabCol : 1;
public:
SwUndoAttrTbl( const SwTableNode& rTblNd, BOOL bClearTabCols = FALSE );
+
virtual ~SwUndoAttrTbl();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
};
class SwUndoTblAutoFmt : public SwUndo
@@ -875,13 +935,16 @@ class SwUndoTblAutoFmt : public SwUndo
SwUndos* pUndos;
BOOL bSaveCntntAttr;
- void UndoRedo( BOOL bUndo, SwUndoIter& rUndoIter );
+ void UndoRedo(bool const bUndo, ::sw::UndoRedoContext & rContext);
public:
SwUndoTblAutoFmt( const SwTableNode& rTblNd, const SwTableAutoFmt& );
+
virtual ~SwUndoTblAutoFmt();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+
void SaveBoxCntnt( const SwTableBox& rBox );
};
@@ -912,8 +975,9 @@ public:
const SwTableNode& rTblNd );
virtual ~SwUndoTblNdsChg();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
void SaveNewBoxes( const SwTableNode& rTblNd, const SwTableSortBoxes& rOld );
void SaveNewBoxes( const SwTableNode& rTblNd, const SwTableSortBoxes& rOld,
@@ -944,9 +1008,11 @@ class SwUndoTblMerge : public SwUndo, private SwUndRng
public:
SwUndoTblMerge( const SwPaM& rTblSel );
+
virtual ~SwUndoTblMerge();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
void MoveBoxCntnt( SwDoc* pDoc, SwNodeRange& rRg, SwNodeIndex& rPos );
@@ -977,9 +1043,11 @@ class SwUndoTblNumFmt : public SwUndo
public:
SwUndoTblNumFmt( const SwTableBox& rBox, const SfxItemSet* pNewSet = 0 );
+
virtual ~SwUndoTblNumFmt();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
void SetNumFmt( ULONG nNewNumFmtIdx, const double& rNewNumber )
{ nFmtIdx = nNewNumFmtIdx; fNum = rNewNumber; }
@@ -999,9 +1067,11 @@ class SwUndoTblCpyTbl : public SwUndo
bool& rJoin, bool bRedo );
public:
SwUndoTblCpyTbl();
+
virtual ~SwUndoTblCpyTbl();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
void AddBoxBefore( const SwTableBox& rBox, BOOL bDelCntnt );
void AddBoxAfter( const SwTableBox& rBox, const SwNodeIndex& rIdx, BOOL bDelCntnt );
@@ -1016,9 +1086,11 @@ class SwUndoCpyTbl : public SwUndo
ULONG nTblNode;
public:
SwUndoCpyTbl();
+
virtual ~SwUndoCpyTbl();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
void SetTableSttIdx( ULONG nIdx ) { nTblNode = nIdx; }
};
@@ -1033,10 +1105,12 @@ class SwUndoSplitTbl : public SwUndo
BOOL bCalcNewSize;
public:
SwUndoSplitTbl( const SwTableNode& rTblNd, SwSaveRowSpan* pRowSp, USHORT nMode, BOOL bCalcNewSize );
+
virtual ~SwUndoSplitTbl();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
- virtual void Repeat( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+ virtual void RepeatImpl( ::sw::RepeatContext & );
void SetTblNodeOffset( ULONG nIdx ) { nOffset = nIdx - nTblNode; }
SwHistory* GetHistory() { return pHistory; }
@@ -1054,10 +1128,12 @@ class SwUndoMergeTbl : public SwUndo
public:
SwUndoMergeTbl( const SwTableNode& rTblNd, const SwTableNode& rDelTblNd,
BOOL bWithPrev, USHORT nMode );
+
virtual ~SwUndoMergeTbl();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
- virtual void Repeat( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+ virtual void RepeatImpl( ::sw::RepeatContext & );
void SaveFormula( SwHistory& rHistory );
};
@@ -1097,8 +1173,9 @@ class SwUndoInsBookmark : public SwUndoBookmark
{
public:
SwUndoInsBookmark( const ::sw::mark::IMark& );
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
};
@@ -1147,11 +1224,12 @@ public:
SwUndoSort( const SwPaM&, const SwSortOptions& );
SwUndoSort( ULONG nStt, ULONG nEnd, const SwTableNode&,
const SwSortOptions&, BOOL bSaveTable );
+
virtual ~SwUndoSort();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
- virtual void Repeat( SwUndoIter& );
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+ virtual void RepeatImpl( ::sw::RepeatContext & );
void Insert( const String& rOrgPos, const String& rNewPos );
void Insert( ULONG nOrgPos, ULONG nNewPos );
@@ -1171,7 +1249,7 @@ protected:
USHORT nRndId;
BOOL bDelFmt; // loesche das gespeicherte Format
- void InsFly( SwUndoIter&, BOOL bShowSel = TRUE );
+ void InsFly(::sw::UndoRedoContext & rContext, bool bShowSel = true);
void DelFly( SwDoc* );
SwUndoFlyBase( SwFrmFmt* pFormat, SwUndoId nUndoId );
@@ -1182,9 +1260,6 @@ protected:
public:
virtual ~SwUndoFlyBase();
- virtual void Undo( SwUndoIter& ) = 0;
- virtual void Redo( SwUndoIter& ) = 0;
-
};
class SwUndoInsLayFmt : public SwUndoFlyBase
@@ -1193,11 +1268,12 @@ class SwUndoInsLayFmt : public SwUndoFlyBase
xub_StrLen mnCrsrSaveIndexPos; // for undo
public:
SwUndoInsLayFmt( SwFrmFmt* pFormat, ULONG nNodeIdx, xub_StrLen nCntIdx );
- ~SwUndoInsLayFmt();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
- virtual void Repeat( SwUndoIter& );
+ virtual ~SwUndoInsLayFmt();
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+ virtual void RepeatImpl( ::sw::RepeatContext & );
String GetComment() const;
@@ -1209,9 +1285,10 @@ class SwUndoDelLayFmt : public SwUndoFlyBase
public:
SwUndoDelLayFmt( SwFrmFmt* pFormat );
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
- void Redo(); // Schnittstelle fuers Rollback
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+
+ void RedoForRollback();
void ChgShowSel( BOOL bNew ) { bShowSelFrm = bNew; }
@@ -1239,8 +1316,8 @@ public:
SwUndoSetFlyFmt( SwFrmFmt& rFlyFmt, SwFrmFmt& rNewFrmFmt );
virtual ~SwUndoSetFlyFmt();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
virtual SwRewriter GetRewriter() const;
};
@@ -1259,8 +1336,9 @@ public:
::rtl::OUString const& rInsert, bool const bRegExp);
virtual ~SwUndoReplace();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
// #111827#
/**
@@ -1302,9 +1380,10 @@ class SwUndoTblHeadline : public SwUndo
USHORT nNewHeadline;
public:
SwUndoTblHeadline( const SwTable&, USHORT nOldHdl, USHORT nNewHdl );
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
- virtual void Repeat( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+ virtual void RepeatImpl( ::sw::RepeatContext & );
};
@@ -1328,10 +1407,12 @@ private:
public:
SwUndoInsSection(SwPaM const&, SwSectionData const&,
SfxItemSet const*const pSet, SwTOXBase const*const pTOXBase);
+
virtual ~SwUndoInsSection();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
- virtual void Repeat( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+ virtual void RepeatImpl( ::sw::RepeatContext & );
void SetSectNdPos(ULONG const nPos) { m_nSectionNodePos = nPos; }
void SaveSplitNode(SwTxtNode *const pTxtNd, bool const bAtStart);
@@ -1350,9 +1431,10 @@ class SwUndoOutlineLeftRight : public SwUndo, private SwUndRng
short nOffset;
public:
SwUndoOutlineLeftRight( const SwPaM& rPam, short nOffset );
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
- virtual void Repeat( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+ virtual void RepeatImpl( ::sw::RepeatContext & );
};
//--------------------------------------------------------------------
@@ -1365,9 +1447,11 @@ class SwUndoDefaultAttr : public SwUndo
public:
// registers at the format and saves old attributes
SwUndoDefaultAttr( const SfxItemSet& rOldSet );
+
virtual ~SwUndoDefaultAttr();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
};
//--------------------------------------------------------------------
@@ -1387,10 +1471,13 @@ public:
SwUndoId nUndoId = UNDO_INSFMTATTR );
SwUndoInsNum( const SwPosition& rPos, const SwNumRule& rRule,
const String& rReplaceRule );
+
virtual ~SwUndoInsNum();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
- virtual void Repeat( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+ virtual void RepeatImpl( ::sw::RepeatContext & );
+
virtual SwRewriter GetRewriter() const;
SwHistory* GetHistory(); // wird ggfs. neu angelegt!
@@ -1409,10 +1496,12 @@ class SwUndoDelNum : public SwUndo, private SwUndRng
SwHistory* pHistory;
public:
SwUndoDelNum( const SwPaM& rPam );
+
virtual ~SwUndoDelNum();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
- virtual void Repeat( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+ virtual void RepeatImpl( ::sw::RepeatContext & );
void AddNode( const SwTxtNode& rNd, BOOL bResetLRSpace );
SwHistory* GetHistory() { return pHistory; }
@@ -1425,9 +1514,11 @@ class SwUndoMoveNum : public SwUndo, private SwUndRng
long nOffset;
public:
SwUndoMoveNum( const SwPaM& rPam, long nOffset, BOOL bIsOutlMv = FALSE );
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
- virtual void Repeat( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+ virtual void RepeatImpl( ::sw::RepeatContext & );
+
void SetStartNode( ULONG nValue ) { nNewStt = nValue; }
};
@@ -1436,9 +1527,10 @@ class SwUndoNumUpDown : public SwUndo, private SwUndRng
short nOffset;
public:
SwUndoNumUpDown( const SwPaM& rPam, short nOffset );
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
- virtual void Repeat( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+ virtual void RepeatImpl( ::sw::RepeatContext & );
};
class SwUndoNumOrNoNum : public SwUndo
@@ -1449,9 +1541,10 @@ class SwUndoNumOrNoNum : public SwUndo
public:
SwUndoNumOrNoNum( const SwNodeIndex& rIdx, BOOL mbOldNum,
BOOL mbNewNum );
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
- virtual void Repeat( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+ virtual void RepeatImpl( ::sw::RepeatContext & );
};
class SwUndoNumRuleStart : public SwUndo
@@ -1463,9 +1556,10 @@ class SwUndoNumRuleStart : public SwUndo
public:
SwUndoNumRuleStart( const SwPosition& rPos, BOOL bDelete );
SwUndoNumRuleStart( const SwPosition& rPos, USHORT nStt );
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
- virtual void Repeat( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+ virtual void RepeatImpl( ::sw::RepeatContext & );
};
//--------------------------------------------------------------------
@@ -1477,9 +1571,11 @@ class SwSdrUndo : public SwUndo
SdrMarkList* pMarkList; // MarkList for all selected SdrObjects
public:
SwSdrUndo( SdrUndoAction* , const SdrMarkList* pMarkList );
+
virtual ~SwSdrUndo();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
String GetComment() const;
};
@@ -1492,9 +1588,11 @@ class SwUndoDrawGroup : public SwUndo
public:
SwUndoDrawGroup( USHORT nCnt );
+
virtual ~SwUndoDrawGroup();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
void AddObj( USHORT nPos, SwDrawFrmFmt*, SdrObject* );
void SetGroupFmt( SwDrawFrmFmt* );
@@ -1520,9 +1618,11 @@ class SwUndoDrawUnGroup : public SwUndo
public:
SwUndoDrawUnGroup( SdrObjGroup* );
+
virtual ~SwUndoDrawUnGroup();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
void AddObj( USHORT nPos, SwDrawFrmFmt* );
};
@@ -1535,9 +1635,11 @@ class SwUndoDrawUnGroupConnectToLayout : public SwUndo
public:
SwUndoDrawUnGroupConnectToLayout();
+
virtual ~SwUndoDrawUnGroupConnectToLayout();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
void AddFmtAndObj( SwDrawFrmFmt* pDrawFrmFmt,
SdrObject* pDrawObject );
@@ -1554,9 +1656,11 @@ class SwUndoDrawDelete : public SwUndo
public:
SwUndoDrawDelete( USHORT nCnt );
+
virtual ~SwUndoDrawDelete();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
void AddObj( USHORT nPos, SwDrawFrmFmt*, const SdrMark& );
};
@@ -1571,14 +1675,15 @@ class SwUndoReRead : public SwUndo
USHORT nMirr;
void SaveGraphicData( const SwGrfNode& );
- void SetAndSave( SwUndoIter& );
+ void SetAndSave( ::sw::UndoRedoContext & );
public:
SwUndoReRead( const SwPaM& rPam, const SwGrfNode& pGrfNd );
+
virtual ~SwUndoReRead();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
};
//--------------------------------------------------------------------
@@ -1623,9 +1728,9 @@ public:
const BOOL bCpyBrd );
virtual ~SwUndoInsertLabel();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
- virtual void Repeat( SwUndoIter& );
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+ virtual void RepeatImpl( ::sw::RepeatContext & );
// #111827#
/**
@@ -1664,9 +1769,9 @@ public:
USHORT nNum, bool bIsEndNote );
virtual ~SwUndoChangeFootNote();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
- virtual void Repeat( SwUndoIter& );
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+ virtual void RepeatImpl( ::sw::RepeatContext & );
SwHistory& GetHistory() { return *m_pHistory; }
};
@@ -1677,10 +1782,11 @@ class SwUndoFootNoteInfo : public SwUndo
public:
SwUndoFootNoteInfo( const SwFtnInfo &rInfo );
+
virtual ~SwUndoFootNoteInfo();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
};
class SwUndoEndNoteInfo : public SwUndo
@@ -1689,10 +1795,11 @@ class SwUndoEndNoteInfo : public SwUndo
public:
SwUndoEndNoteInfo( const SwEndNoteInfo &rInfo );
+
virtual ~SwUndoEndNoteInfo();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
};
@@ -1704,14 +1811,17 @@ class SwUndoTransliterate : public SwUndo, public SwUndRng
std::vector< _UndoTransliterate_Data * > aChanges;
sal_uInt32 nType;
+ void DoTransliterate(SwDoc & rDoc, SwPaM & rPam);
+
public:
SwUndoTransliterate( const SwPaM& rPam,
const utl::TransliterationWrapper& rTrans );
+
virtual ~SwUndoTransliterate();
- virtual void Undo( SwUndoIter& rUndoIter );
- virtual void Redo( SwUndoIter& rUndoIter );
- virtual void Repeat( SwUndoIter& rUndoIter );
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+ virtual void RepeatImpl( ::sw::RepeatContext & );
void AddChanges( SwTxtNode& rTNd, xub_StrLen nStart, xub_StrLen nLen,
::com::sun::star::uno::Sequence <sal_Int32>& rOffsets );
@@ -1728,14 +1838,16 @@ protected:
SwUndoId nUserId;
BOOL bHiddenRedlines;
- virtual void _Undo( SwUndoIter& );
- virtual void _Redo( SwUndoIter& );
+ virtual void UndoRedlineImpl(SwDoc & rDoc, SwPaM & rPam);
+ virtual void RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam);
public:
SwUndoRedline( SwUndoId nUserId, const SwPaM& rRange );
+
virtual ~SwUndoRedline();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
SwUndoId GetUserId() const { return nUserId; }
USHORT GetRedlSaveCount() const
@@ -1748,8 +1860,8 @@ class SwUndoRedlineDelete : public SwUndoRedline
BOOL bIsDelim : 1;
BOOL bIsBackspace : 1;
- virtual void _Undo( SwUndoIter& );
- virtual void _Redo( SwUndoIter& );
+ virtual void UndoRedlineImpl(SwDoc & rDoc, SwPaM & rPam);
+ virtual void RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam);
public:
SwUndoRedlineDelete( const SwPaM& rRange, SwUndoId nUserId = UNDO_EMPTY );
@@ -1767,13 +1879,15 @@ class SwUndoRedlineSort : public SwUndoRedline
ULONG nSaveEndNode, nOffset;
xub_StrLen nSaveEndCntnt;
- virtual void _Undo( SwUndoIter& );
- virtual void _Redo( SwUndoIter& );
+ virtual void UndoRedlineImpl(SwDoc & rDoc, SwPaM & rPam);
+ virtual void RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam);
public:
SwUndoRedlineSort( const SwPaM& rRange, const SwSortOptions& rOpt );
+
virtual ~SwUndoRedlineSort();
- virtual void Repeat( SwUndoIter& );
+
+ virtual void RepeatImpl( ::sw::RepeatContext & );
void SetSaveRange( const SwPaM& rRange );
void SetOffset( const SwNodeIndex& rIdx );
@@ -1781,18 +1895,24 @@ public:
class SwUndoAcceptRedline : public SwUndoRedline
{
- virtual void _Redo( SwUndoIter& );
+private:
+ virtual void RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam);
+
public:
SwUndoAcceptRedline( const SwPaM& rRange );
- virtual void Repeat( SwUndoIter& );
+
+ virtual void RepeatImpl( ::sw::RepeatContext & );
};
class SwUndoRejectRedline : public SwUndoRedline
{
- virtual void _Redo( SwUndoIter& );
+private:
+ virtual void RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam);
+
public:
SwUndoRejectRedline( const SwPaM& rRange );
- virtual void Repeat( SwUndoIter& );
+
+ virtual void RepeatImpl( ::sw::RepeatContext & );
};
//--------------------------------------------------------------------
@@ -1808,46 +1928,14 @@ public:
SwUndoCompDoc( const SwRedline& rRedl );
virtual ~SwUndoCompDoc();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
};
//--------------------------------------------------------------------
-// Object der als Iterator durch die Undo-Liste laeuft, bis die
-// letze oder die angegebene Klammerung/Id erreicht ist.
-
-class SwUndoIter
-{
- friend class ::sw::UndoManager; // to set bWeiter in SwDoc::Undo
- friend void SwUndoEnd::Undo( SwUndoIter& );
- friend void SwUndoStart::Undo( SwUndoIter& );
- friend void SwUndoEnd::Redo( SwUndoIter& );
- friend void SwUndoStart::Redo( SwUndoIter& );
- friend void SwUndoEnd::Repeat( SwUndoIter& );
- friend void SwUndoStart::Repeat( SwUndoIter& );
-
- SwUndoId nUndoId;
- USHORT nEndCnt;
- BOOL bWeiter : 1;
-
-public:
- bool m_bDeleteRepeated; // has a delete action been repeated?
- SwPaM * pAktPam; // Member fuer das Undo
- SwFrmFmt* pSelFmt; // ggfs. das Format Rahmen/Object-Selektionen
- SdrMarkList* pMarkList; // MarkList for all selected SdrObjects
-
- SwUndoIter( SwPaM * pPam, SwUndoId nId = UNDO_EMPTY );
-
- BOOL IsNextUndo() const { return bWeiter; }
-
- inline SwDoc& GetDoc() const;
- SwUndoId GetId() const { return nUndoId; }
- void ClearSelections() { pSelFmt = 0; pMarkList = 0; }
-};
-
-
// -> #111827#
const int nUndoStringLength = 20;
diff --git a/sw/source/core/doc/dbgoutsw.cxx b/sw/source/core/doc/dbgoutsw.cxx
index 3c85091c7d20..91d021402965 100644
--- a/sw/source/core/doc/dbgoutsw.cxx
+++ b/sw/source/core/doc/dbgoutsw.cxx
@@ -808,43 +808,10 @@ String lcl_dbg_out(const SwUndo & rUndo)
{
String aStr("[ ", RTL_TEXTENCODING_ASCII_US);
- aStr += String::CreateFromInt32(rUndo.GetId());
+ aStr += String::CreateFromInt32(
+ static_cast<SfxUndoAction const&>(rUndo).GetId());
aStr += String(": ", RTL_TEXTENCODING_ASCII_US);
- switch(rUndo.GetId())
- {
- case UNDO_START:
- aStr += String(", ", RTL_TEXTENCODING_ASCII_US);
- aStr +=
- String::CreateFromInt32(dynamic_cast
- <const SwUndoStart &>(rUndo).
- GetUserId());
- aStr += String(", ", RTL_TEXTENCODING_ASCII_US);
- aStr += String::CreateFromInt32(dynamic_cast
- <const SwUndoStart &>(rUndo).
- GetEndOffset());
- aStr += String(" ", RTL_TEXTENCODING_ASCII_US);
-
- break;
-
- case UNDO_END:
- aStr += String(", ", RTL_TEXTENCODING_ASCII_US);
- aStr +=
- String::CreateFromInt32(dynamic_cast
- <const SwUndoEnd &>(rUndo).
- GetId());
- aStr += String(", ", RTL_TEXTENCODING_ASCII_US);
- aStr += String::CreateFromInt32(dynamic_cast
- <const SwUndoEnd &>(rUndo).
- GetSttOffset());
- aStr += String(" ", RTL_TEXTENCODING_ASCII_US);
-
- break;
-
- default:
- break;
- }
-
aStr += rUndo.GetComment();
aStr += String(" ]", RTL_TEXTENCODING_ASCII_US);
@@ -876,6 +843,7 @@ SW_DLLPUBLIC const char * dbg_out(SwOutlineNodes & rNodes)
return dbg_out(lcl_dbg_out(rNodes));
}
+#if 0
String lcl_dbg_out(const SwUndos & rUndos)
{
USHORT nIndent = 0;
@@ -908,6 +876,7 @@ SW_DLLPUBLIC const char * dbg_out(const SwUndos & rUndos)
{
return dbg_out(lcl_dbg_out(rUndos));
}
+#endif
String lcl_dbg_out(const SwRewriter & rRewriter)
{
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index fe1f8be5c44d..bfeb9064bd2e 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -2443,13 +2443,7 @@ bool SwDoc::RestoreInvisibleContent()
if (GetIDocumentUndoRedo().GetLastUndoInfo(0, & nLastUndoId)
&& (UNDO_UI_DELETE_INVISIBLECNTNT == nLastUndoId))
{
- SwPaM aPam( GetNodes().GetEndOfPostIts() );
- SwUndoIter aUndoIter( &aPam );
- do
- {
- GetIDocumentUndoRedo().Undo( aUndoIter );
- }
- while (aUndoIter.IsNextUndo());
+ GetIDocumentUndoRedo().Undo();
GetIDocumentUndoRedo().ClearRedo();
bRet = true;
}
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 1c6b199f1268..aa519905198c 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -2385,12 +2385,15 @@ USHORT SwDoc::MergeTbl( SwPaM& rPam )
if (GetIDocumentUndoRedo().GetLastUndoInfo(0, & nLastUndoId)
&& (UNDO_REDLINE == nLastUndoId))
{
+ // FIXME: why is this horrible cleanup necessary?
SwUndoRedline *const pU = dynamic_cast<SwUndoRedline*>(
GetUndoManager().RemoveLastUndo());
if( pU->GetRedlSaveCount() )
{
- SwUndoIter aUndoIter( &rPam, UNDO_REDLINE );
- pU->Undo( aUndoIter );
+ SwEditShell *const pEditShell(GetEditShell(0));
+ OSL_ASSERT(pEditShell);
+ ::sw::UndoRedoContext context(*this, *pEditShell);
+ static_cast<SfxUndoAction *>(pU)->UndoWithContext(context);
}
delete pU;
}
diff --git a/sw/source/core/edit/edundo.cxx b/sw/source/core/edit/edundo.cxx
index 1ba494a88b79..4472c08daab0 100644
--- a/sw/source/core/edit/edundo.cxx
+++ b/sw/source/core/edit/edundo.cxx
@@ -41,6 +41,7 @@
#include <flyfrm.hxx>
#include <frmfmt.hxx>
#include <viewimp.hxx>
+#include <docsh.hxx>
/** helper function to select all objects in an SdrMarkList;
@@ -48,8 +49,57 @@
void lcl_SelectSdrMarkList( SwEditShell* pShell,
const SdrMarkList* pSdrMarkList );
+bool SwEditShell::CursorsLocked() const
+{
+
+ return GetDoc()->GetDocShell()->GetModel()->hasControllersLocked();
+}
-BOOL SwEditShell::Undo( SwUndoId nUndoId, USHORT nCnt )
+void
+SwEditShell::HandleUndoRedoContext(::sw::UndoRedoContext & rContext)
+{
+ // do nothing if somebody has locked controllers!
+ if (CursorsLocked())
+ {
+ return;
+ }
+
+ SwFrmFmt * pSelFmt(0);
+ SdrMarkList * pMarkList(0);
+ rContext.GetSelections(pSelFmt, pMarkList);
+
+ if (pSelFmt) // select frame
+ {
+ if (RES_DRAWFRMFMT == pSelFmt->Which())
+ {
+ SdrObject* pSObj = pSelFmt->FindSdrObject();
+ static_cast<SwFEShell*>(this)->SelectObj(
+ pSObj->GetCurrentBoundRect().Center() );
+ }
+ else
+ {
+ Point aPt;
+ SwFlyFrm *const pFly =
+ static_cast<SwFlyFrmFmt*>(pSelFmt)->GetFrm(& aPt, false);
+ if (pFly)
+ {
+ static_cast<SwFEShell*>(this)->SelectFlyFrm(*pFly, true);
+ }
+ }
+ }
+ else if (pMarkList)
+ {
+ lcl_SelectSdrMarkList( this, pMarkList );
+ }
+ else if (GetCrsr()->GetNext() != GetCrsr())
+ {
+ // current cursor is the last one:
+ // go around the ring, to the first cursor
+ GoNextCrsr();
+ }
+}
+
+bool SwEditShell::Undo(USHORT const nCount)
{
SET_CURR_SHELL( this );
@@ -71,7 +121,7 @@ BOOL SwEditShell::Undo( SwUndoId nUndoId, USHORT nCnt )
// soll dieser wieder an die Position
SwUndoId nLastUndoId(UNDO_EMPTY);
GetDoc()->GetIDocumentUndoRedo().GetLastUndoInfo(0, & nLastUndoId);
- BOOL bRestoreCrsr = 1 == nCnt && ( UNDO_AUTOFORMAT == nLastUndoId ||
+ bool bRestoreCrsr = 1 == nCount && (UNDO_AUTOFORMAT == nLastUndoId ||
UNDO_AUTOCORRECT == nLastUndoId );
Push();
@@ -81,53 +131,20 @@ BOOL SwEditShell::Undo( SwUndoId nUndoId, USHORT nCnt )
RedlineMode_t eOld = GetDoc()->GetRedlineMode();
- SwUndoIter aUndoIter( GetCrsr(), nUndoId );
- while( nCnt-- )
- {
- do {
-
- bRet = GetDoc()->GetIDocumentUndoRedo().Undo( aUndoIter )
+ try {
+ for (USHORT i = 0; i < nCount; ++i)
+ {
+ bRet = GetDoc()->GetIDocumentUndoRedo().Undo()
|| bRet;
-
- if( !aUndoIter.IsNextUndo() )
- break;
-
- // es geht weiter, also erzeuge einen neuen Cursor wenn
- // der alte schon eine Selection hat
- // JP 02.04.98: aber nicht wenns ein Autoformat ist
- if( !bRestoreCrsr && HasSelection() )
- {
- CreateCrsr();
- aUndoIter.pAktPam = GetCrsr();
- }
- } while( TRUE );
+ }
+ } catch (::com::sun::star::uno::Exception & e) {
+ OSL_TRACE("SwEditShell::Undo(): exception caught:\n %s",
+ ::rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8)
+ .getStr());
}
Pop( !bRestoreCrsr );
- if( aUndoIter.pSelFmt ) // dann erzeuge eine Rahmen-Selection
- {
- if( RES_DRAWFRMFMT == aUndoIter.pSelFmt->Which() )
- {
- SdrObject* pSObj = aUndoIter.pSelFmt->FindSdrObject();
- ((SwFEShell*)this)->SelectObj( pSObj->GetCurrentBoundRect().Center() );
- }
- else
- {
- Point aPt;
- SwFlyFrm* pFly = ((SwFlyFrmFmt*)aUndoIter.pSelFmt)->GetFrm(
- &aPt, FALSE );
- if( pFly )
- ((SwFEShell*)this)->SelectFlyFrm( *pFly, TRUE );
- }
- }
- else if( aUndoIter.pMarkList )
- {
- lcl_SelectSdrMarkList( this, aUndoIter.pMarkList );
- }
- else if( GetCrsr()->GetNext() != GetCrsr() ) // gehe nach einem
- GoNextCrsr(); // Undo zur alten Undo-Position !!
-
GetDoc()->SetRedlineMode( eOld );
GetDoc()->CompressRedlines();
@@ -139,7 +156,7 @@ BOOL SwEditShell::Undo( SwUndoId nUndoId, USHORT nCnt )
return bRet;
}
-USHORT SwEditShell::Redo( USHORT nCnt )
+bool SwEditShell::Redo(USHORT const nCount)
{
SET_CURR_SHELL( this );
@@ -165,49 +182,17 @@ USHORT SwEditShell::Redo( USHORT nCnt )
RedlineMode_t eOld = GetDoc()->GetRedlineMode();
- SwUndoIter aUndoIter( GetCrsr(), UNDO_EMPTY );
- while( nCnt-- )
- {
- do {
-
- bRet = GetDoc()->GetIDocumentUndoRedo().Redo( aUndoIter )
- || bRet;
-
- if( !aUndoIter.IsNextUndo() )
- break;
-
- // es geht weiter, also erzeugen einen neuen Cursor wenn
- // der alte schon eine SSelection hat
- if( HasSelection() )
- {
- CreateCrsr();
- aUndoIter.pAktPam = GetCrsr();
- }
- } while( TRUE );
- }
-
- if( aUndoIter.pSelFmt ) // dann erzeuge eine Rahmen-Selection
- {
- if( RES_DRAWFRMFMT == aUndoIter.pSelFmt->Which() )
+ try {
+ for (USHORT i = 0; i < nCount; ++i)
{
- SdrObject* pSObj = aUndoIter.pSelFmt->FindSdrObject();
- ((SwFEShell*)this)->SelectObj( pSObj->GetCurrentBoundRect().Center() );
- }
- else
- {
- Point aPt;
- SwFlyFrm* pFly = ((SwFlyFrmFmt*)aUndoIter.pSelFmt)->GetFrm(
- &aPt, FALSE );
- if( pFly )
- ((SwFEShell*)this)->SelectFlyFrm( *pFly, TRUE );
+ bRet = GetDoc()->GetIDocumentUndoRedo().Redo()
+ || bRet;
}
+ } catch (::com::sun::star::uno::Exception & e) {
+ OSL_TRACE("SwEditShell::Redo(): exception caught:\n %s",
+ ::rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8)
+ .getStr());
}
- else if( aUndoIter.pMarkList )
- {
- lcl_SelectSdrMarkList( this, aUndoIter.pMarkList );
- }
- else if( GetCrsr()->GetNext() != GetCrsr() ) // gehe nach einem
- GoNextCrsr(); // Redo zur alten Undo-Position !!
GetDoc()->SetRedlineMode( eOld );
GetDoc()->CompressRedlines();
@@ -222,16 +207,22 @@ USHORT SwEditShell::Redo( USHORT nCnt )
}
-USHORT SwEditShell::Repeat( USHORT nCount )
+bool SwEditShell::Repeat(USHORT const nCount)
{
SET_CURR_SHELL( this );
BOOL bRet = FALSE;
StartAllAction();
- SwUndoIter aUndoIter( GetCrsr(), UNDO_EMPTY );
- bRet = GetDoc()->GetIDocumentUndoRedo().Repeat( aUndoIter, nCount )
+ try {
+ ::sw::RepeatContext context(*GetDoc(), *GetCrsr());
+ bRet = GetDoc()->GetIDocumentUndoRedo().Repeat( context, nCount )
|| bRet;
+ } catch (::com::sun::star::uno::Exception & e) {
+ OSL_TRACE("SwEditShell::Repeat(): exception caught:\n %s",
+ ::rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8)
+ .getStr());
+ }
EndAllAction();
return bRet;
diff --git a/sw/source/core/edit/makefile.mk b/sw/source/core/edit/makefile.mk
index a7820b405842..671ee65973b4 100644
--- a/sw/source/core/edit/makefile.mk
+++ b/sw/source/core/edit/makefile.mk
@@ -41,6 +41,7 @@ AUTOSEG=true
# --- Files --------------------------------------------------------
EXCEPTIONSFILES=\
+ $(SLO)$/edundo.obj \
$(SLO)$/eddel.obj \
$(SLO)$/edlingu.obj \
$(SLO)$/edfldexp.obj \
@@ -61,7 +62,6 @@ SLOFILES = \
$(SLO)$/ednumber.obj \
$(SLO)$/edredln.obj \
$(SLO)$/edtox.obj \
- $(SLO)$/edundo.obj \
$(SLO)$/edws.obj \
$(SLO)$/edsect.obj
diff --git a/sw/source/core/inc/SwUndoFmt.hxx b/sw/source/core/inc/SwUndoFmt.hxx
index ea23724fa817..f5010ff545ae 100644
--- a/sw/source/core/inc/SwUndoFmt.hxx
+++ b/sw/source/core/inc/SwUndoFmt.hxx
@@ -24,8 +24,8 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-#ifndef _SW_UNDO_TXT_FMT_COLL_HXX
-#define _SW_UNDO_TXT_FMT_COLL_HXX
+#ifndef SW_UNDO_TXT_FMT_COLL_HXX
+#define SW_UNDO_TXT_FMT_COLL_HXX
#include <undobj.hxx>
#include <swundo.hxx>
@@ -53,8 +53,8 @@ public:
SwDoc * pDoc);
virtual ~SwUndoFmtCreate();
- virtual void Undo(SwUndoIter & rIter);
- virtual void Redo(SwUndoIter & rIter);
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
virtual SwRewriter GetRewriter() const;
@@ -77,8 +77,8 @@ public:
SwUndoFmtDelete(SwUndoId nUndoId, SwFmt * pOld, SwDoc * pDoc);
~SwUndoFmtDelete();
- virtual void Undo(SwUndoIter & rIter);
- virtual void Redo(SwUndoIter & rIter);
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
virtual SwRewriter GetRewriter() const;
@@ -100,8 +100,8 @@ public:
SwDoc * pDoc);
~SwUndoRenameFmt();
- void Undo(SwUndoIter & rIter);
- void Redo(SwUndoIter & rIter);
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
SwRewriter GetRewriter() const;
@@ -213,8 +213,8 @@ class SwUndoNumruleCreate : public SwUndo
public:
SwUndoNumruleCreate(const SwNumRule * pNew, SwDoc * pDoc);
- virtual void Undo(SwUndoIter & rIter);
- virtual void Redo(SwUndoIter & rIter);
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
SwRewriter GetRewriter() const;
};
@@ -227,8 +227,8 @@ class SwUndoNumruleDelete : public SwUndo
public:
SwUndoNumruleDelete(const SwNumRule & aRule, SwDoc * pDoc);
- virtual void Undo(SwUndoIter & rIter);
- virtual void Redo(SwUndoIter & rIter);
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
SwRewriter GetRewriter() const;
};
@@ -242,9 +242,10 @@ class SwUndoNumruleRename : public SwUndo
SwUndoNumruleRename(const String & aOldName, const String & aNewName,
SwDoc * pDoc);
- virtual void Undo(SwUndoIter & rIter);
- virtual void Redo(SwUndoIter & rIter);
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
SwRewriter GetRewriter() const;
};
-#endif // _SW_UNDO_TXT_FMT_COLL_HXX
+
+#endif // SW_UNDO_TXT_FMT_COLL_HXX
diff --git a/sw/source/core/inc/SwUndoPageDesc.hxx b/sw/source/core/inc/SwUndoPageDesc.hxx
index 84a734b57937..1de717a453d6 100644
--- a/sw/source/core/inc/SwUndoPageDesc.hxx
+++ b/sw/source/core/inc/SwUndoPageDesc.hxx
@@ -24,8 +24,8 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-#ifndef _SW_UNDO_PAGE_DESC_HXX
-#define _SW_UNDO_PAGE_DESC_HXX
+#ifndef SW_UNDO_PAGE_DESC_HXX
+#define SW_UNDO_PAGE_DESC_HXX
#include <undobj.hxx>
#include <pagedesc.hxx>
@@ -48,9 +48,8 @@ public:
SwDoc * pDoc);
virtual ~SwUndoPageDesc();
- virtual void Undo(SwUndoIter & rIt);
- virtual void Redo(SwUndoIter & rIt);
- virtual void Repeat(SwUndoIter & rIt);
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
virtual SwRewriter GetRewriter() const;
};
@@ -61,13 +60,15 @@ class SwUndoPageDescCreate : public SwUndo
SwPageDescExt aNew;
SwDoc * pDoc;
+ void DoImpl();
+
public:
SwUndoPageDescCreate(const SwPageDesc * pNew, SwDoc * pDoc); // #116530#
virtual ~SwUndoPageDescCreate();
- virtual void Undo(SwUndoIter & rIt);
- virtual void Redo(SwUndoIter & rIt);
- virtual void Repeat(SwUndoIter & rIt);
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+ virtual void RepeatImpl( ::sw::RepeatContext & );
virtual SwRewriter GetRewriter() const;
};
@@ -77,13 +78,15 @@ class SwUndoPageDescDelete : public SwUndo
SwPageDescExt aOld;
SwDoc * pDoc;
+ void DoImpl();
+
public:
SwUndoPageDescDelete(const SwPageDesc & aOld, SwDoc * pDoc);
virtual ~SwUndoPageDescDelete();
- virtual void Undo(SwUndoIter & rIt);
- virtual void Redo(SwUndoIter & rIt);
- virtual void Repeat(SwUndoIter & rIt);
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+ virtual void RepeatImpl( ::sw::RepeatContext & );
virtual SwRewriter GetRewriter() const;
};
diff --git a/sw/source/core/inc/SwUndoTOXChange.hxx b/sw/source/core/inc/SwUndoTOXChange.hxx
index 36498fec9643..5fa221b23979 100644
--- a/sw/source/core/inc/SwUndoTOXChange.hxx
+++ b/sw/source/core/inc/SwUndoTOXChange.hxx
@@ -24,8 +24,9 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-#ifndef _SW_UNDO_TOX_CHANGE_HXX
-#define _SW_UNDO_TOX_CHANGE_HXX
+#ifndef SW_UNDO_TOX_CHANGE_HXX
+#define SW_UNDO_TOX_CHANGE_HXX
+
#include <undobj.hxx>
#include <tox.hxx>
@@ -34,14 +35,15 @@ class SwUndoTOXChange : public SwUndo
SwTOXBase * pTOX, aOld, aNew;
void UpdateTOXBaseSection();
+ void DoImpl();
public:
SwUndoTOXChange(SwTOXBase * pTOX, const SwTOXBase & rNew);
virtual ~SwUndoTOXChange();
- virtual void Undo(SwUndoIter & rIter);
- virtual void Redo(SwUndoIter & rIter);
- virtual void Repeat(SwUndoIter & rIter);
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+ virtual void RepeatImpl( ::sw::RepeatContext & );
};
-#endif //_SW_UNDO_TOX_CHANGE_HXX
+#endif // SW_UNDO_TOX_CHANGE_HXX
diff --git a/sw/source/core/inc/UndoManager.hxx b/sw/source/core/inc/UndoManager.hxx
index ff464f73137f..fb679db75061 100644
--- a/sw/source/core/inc/UndoManager.hxx
+++ b/sw/source/core/inc/UndoManager.hxx
@@ -32,8 +32,9 @@
#include <memory>
+#include <svl/undo.hxx>
+
-class SwUndos;
class IDocumentDrawModelAccess;
class IDocumentRedlineAccess;
class IDocumentState;
@@ -43,6 +44,7 @@ namespace sw {
class UndoManager
: public IDocumentUndoRedo
+ , private SfxUndoManager
{
public:
@@ -63,7 +65,7 @@ public:
virtual void UnLockUndoNoModifiedPosition();
virtual void SetUndoNoResetModified();
virtual bool IsUndoNoResetModified() const;
- virtual bool Undo(SwUndoIter & rUndoIter);
+// virtual bool Undo();
virtual SwUndoId StartUndo(SwUndoId const eUndoId,
SwRewriter const*const pRewriter);
virtual SwUndoId EndUndo(SwUndoId const eUndoId,
@@ -72,15 +74,24 @@ public:
virtual bool GetLastUndoInfo(::rtl::OUString *const o_pStr,
SwUndoId *const o_pId) const;
virtual SwUndoComments_t GetUndoComments() const;
- virtual bool Redo(SwUndoIter & rUndoIter);
+// virtual bool Redo();
virtual bool GetFirstRedoInfo(::rtl::OUString *const o_pStr) const;
virtual SwUndoComments_t GetRedoComments() const;
- virtual bool Repeat(SwUndoIter & rUndoIter, sal_uInt16 const nRepeatCnt);
+ virtual bool Repeat(::sw::RepeatContext & rContext,
+ sal_uInt16 const nRepeatCnt);
virtual SwUndoId GetRepeatInfo(::rtl::OUString *const o_pStr) const;
virtual void AppendUndo(SwUndo *const pUndo);
virtual void ClearRedo();
virtual bool IsUndoNodes(SwNodes const& rNodes) const;
+ // ::svl::IUndoManager
+ virtual void AddUndoAction(SfxUndoAction *pAction,
+ sal_Bool bTryMerg = sal_False);
+ virtual sal_Bool Undo();
+ virtual sal_Bool Redo();
+ virtual void EnableUndo(bool bEnable);
+ virtual USHORT LeaveListAction();
+
SwUndo * RemoveLastUndo();
SwUndo * GetLastUndo();
@@ -95,24 +106,18 @@ private:
/// Undo nodes array: content not currently in document
::std::auto_ptr<SwNodes> m_pUndoNodes;
- ::std::auto_ptr<SwUndos> m_pUndos; // Undo/Redo History
-
- sal_uInt16 m_nUndoPos; // current Undo-InsertPosition (beyond: Redo)
- sal_uInt16 m_nUndoSavePos; // position in Undo-Array at which Doc was saved
- sal_uInt16 m_nUndoActions; // number of Undo/Redo actions
- sal_uInt16 m_nNestingDepth;// nesting depth: != 0 -> inside StartUndo()
-
- bool m_bUndo : 1; // TRUE: Undo enabled
bool m_bGroupUndo : 1; // TRUE: Undo grouping enabled
bool m_bDrawUndo : 1; // TRUE: Draw Undo enabled
bool m_bLockUndoNoModifiedPosition : 1;
+ bool m_bClearOnLeave : 1;
+ /// position in Undo-Array at which Doc was saved (and is not modified)
+ UndoStackMark m_UndoSaveMark;
+
+ typedef enum { UNDO = true, REDO = false } UndoOrRedo_t;
+ bool impl_DoUndoRedo(UndoOrRedo_t const undoOrRedo);
- /// delete all undo objects from 0 until nEnd
- bool DelUndoObj(sal_uInt16 nEnd);
- /** Is there an Undo action with the given Id, or a Start/End action
- with the given Id as UserId?
- */
- bool HasUndoId(SwUndoId const eId) const;
+ // UGLY: should not be called
+ using SfxUndoManager::Repeat;
};
} // namespace sw
diff --git a/sw/source/core/inc/undoflystrattr.hxx b/sw/source/core/inc/undoflystrattr.hxx
index 329502ea1d1c..5115f1a37c07 100644
--- a/sw/source/core/inc/undoflystrattr.hxx
+++ b/sw/source/core/inc/undoflystrattr.hxx
@@ -24,8 +24,8 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-#ifndef _UNDO_FLY_STR_ATTR_HXX
-#define _UNDO_FLY_STR_ATTR_HXX
+#ifndef SW_UNDO_FLY_STR_ATTR_HXX
+#define SW_UNDO_FLY_STR_ATTR_HXX
#include <undobj.hxx>
#include <swundo.hxx>
@@ -42,9 +42,8 @@ class SwUndoFlyStrAttr : public SwUndo
const String& sNewStr );
virtual ~SwUndoFlyStrAttr();
- virtual void Undo( SwUndoIter & rIt );
- virtual void Redo( SwUndoIter & rIt );
- virtual void Repeat( SwUndoIter & rIt );
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
virtual SwRewriter GetRewriter() const;
@@ -54,4 +53,4 @@ class SwUndoFlyStrAttr : public SwUndo
const String msNewStr;
};
-#endif // _UNDO_FLY_STR_ATTR_HXX
+#endif // SW_UNDO_FLY_STR_ATTR_HXX
diff --git a/sw/source/core/undo/SwUndoField.cxx b/sw/source/core/undo/SwUndoField.cxx
index 578e6edf144e..3f714561b05b 100644
--- a/sw/source/core/undo/SwUndoField.cxx
+++ b/sw/source/core/undo/SwUndoField.cxx
@@ -86,7 +86,7 @@ SwUndoFieldFromDoc::~SwUndoFieldFromDoc()
delete pNewField;
}
-void SwUndoFieldFromDoc::Undo( SwUndoIter& )
+void SwUndoFieldFromDoc::UndoImpl(::sw::UndoRedoContext &)
{
SwTxtFld * pTxtFld = SwDoc::GetTxtFld(GetPosition());
const SwField * pField = pTxtFld->GetFld().GetFld();
@@ -97,7 +97,7 @@ void SwUndoFieldFromDoc::Undo( SwUndoIter& )
}
}
-void SwUndoFieldFromDoc::Redo( SwUndoIter& )
+void SwUndoFieldFromDoc::DoImpl()
{
SwTxtFld * pTxtFld = SwDoc::GetTxtFld(GetPosition());
const SwField * pField = pTxtFld->GetFld().GetFld();
@@ -112,10 +112,15 @@ void SwUndoFieldFromDoc::Redo( SwUndoIter& )
}
}
-void SwUndoFieldFromDoc::Repeat(SwUndoIter & rIt)
+void SwUndoFieldFromDoc::RedoImpl(::sw::UndoRedoContext &)
+{
+ DoImpl();
+}
+
+void SwUndoFieldFromDoc::RepeatImpl(::sw::RepeatContext &)
{
::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
- Redo(rIt);
+ DoImpl();
}
SwUndoFieldFromAPI::SwUndoFieldFromAPI(const SwPosition & rPos,
@@ -129,7 +134,7 @@ SwUndoFieldFromAPI::~SwUndoFieldFromAPI()
{
}
-void SwUndoFieldFromAPI::Undo( SwUndoIter& )
+void SwUndoFieldFromAPI::UndoImpl(::sw::UndoRedoContext &)
{
SwField * pField = SwDoc::GetField(GetPosition());
@@ -137,7 +142,7 @@ void SwUndoFieldFromAPI::Undo( SwUndoIter& )
pField->PutValue(aOldVal, nWhich);
}
-void SwUndoFieldFromAPI::Redo( SwUndoIter& )
+void SwUndoFieldFromAPI::DoImpl()
{
SwField * pField = SwDoc::GetField(GetPosition());
@@ -145,8 +150,13 @@ void SwUndoFieldFromAPI::Redo( SwUndoIter& )
pField->PutValue(aNewVal, nWhich);
}
+void SwUndoFieldFromAPI::RedoImpl(::sw::UndoRedoContext &)
+{
+ DoImpl();
+}
-void SwUndoFieldFromAPI::Repeat(SwUndoIter & rIter)
+void SwUndoFieldFromAPI::RepeatImpl(::sw::RepeatContext &)
{
- Redo(rIter);
+ DoImpl();
}
+
diff --git a/sw/source/core/undo/SwUndoFmt.cxx b/sw/source/core/undo/SwUndoFmt.cxx
index 00518539a8ae..4c95a6f1049d 100644
--- a/sw/source/core/undo/SwUndoFmt.cxx
+++ b/sw/source/core/undo/SwUndoFmt.cxx
@@ -56,7 +56,7 @@ SwUndoFmtCreate::~SwUndoFmtCreate()
{
}
-void SwUndoFmtCreate::Undo(SwUndoIter &)
+void SwUndoFmtCreate::UndoImpl(::sw::UndoRedoContext &)
{
if (pNew)
{
@@ -77,7 +77,7 @@ void SwUndoFmtCreate::Undo(SwUndoIter &)
}
}
-void SwUndoFmtCreate::Redo(SwUndoIter &)
+void SwUndoFmtCreate::RedoImpl(::sw::UndoRedoContext &)
{
SwFmt * pDerivedFrom = Find(sDerivedFrom);
SwFmt * pFmt = Create(pDerivedFrom);
@@ -123,7 +123,7 @@ SwUndoFmtDelete::~SwUndoFmtDelete()
{
}
-void SwUndoFmtDelete::Undo(SwUndoIter &)
+void SwUndoFmtDelete::UndoImpl(::sw::UndoRedoContext &)
{
SwFmt * pDerivedFrom = Find(sDerivedFrom);
@@ -139,7 +139,7 @@ void SwUndoFmtDelete::Undo(SwUndoIter &)
}
}
-void SwUndoFmtDelete::Redo(SwUndoIter &)
+void SwUndoFmtDelete::RedoImpl(::sw::UndoRedoContext &)
{
SwFmt * pOld = Find(sOldName);
@@ -172,7 +172,7 @@ SwUndoRenameFmt::~SwUndoRenameFmt()
{
}
-void SwUndoRenameFmt::Undo(SwUndoIter &)
+void SwUndoRenameFmt::UndoImpl(::sw::UndoRedoContext &)
{
SwFmt * pFmt = Find(sNewName);
@@ -182,7 +182,7 @@ void SwUndoRenameFmt::Undo(SwUndoIter &)
}
}
-void SwUndoRenameFmt::Redo(SwUndoIter &)
+void SwUndoRenameFmt::RedoImpl(::sw::UndoRedoContext &)
{
SwFmt * pFmt = Find(sOldName);
@@ -373,7 +373,7 @@ SwUndoNumruleCreate::SwUndoNumruleCreate(const SwNumRule * _pNew,
{
}
-void SwUndoNumruleCreate::Undo(SwUndoIter &)
+void SwUndoNumruleCreate::UndoImpl(::sw::UndoRedoContext &)
{
if (! bInitialized)
{
@@ -384,7 +384,7 @@ void SwUndoNumruleCreate::Undo(SwUndoIter &)
pDoc->DelNumRule(aNew.GetName(), TRUE);
}
-void SwUndoNumruleCreate::Redo(SwUndoIter &)
+void SwUndoNumruleCreate::RedoImpl(::sw::UndoRedoContext &)
{
pDoc->MakeNumRule(aNew.GetName(), &aNew, TRUE);
}
@@ -410,12 +410,12 @@ SwUndoNumruleDelete::SwUndoNumruleDelete(const SwNumRule & rRule,
{
}
-void SwUndoNumruleDelete::Undo(SwUndoIter &)
+void SwUndoNumruleDelete::UndoImpl(::sw::UndoRedoContext &)
{
pDoc->MakeNumRule(aOld.GetName(), &aOld, TRUE);
}
-void SwUndoNumruleDelete::Redo(SwUndoIter &)
+void SwUndoNumruleDelete::RedoImpl(::sw::UndoRedoContext &)
{
pDoc->DelNumRule(aOld.GetName(), TRUE);
}
@@ -437,12 +437,12 @@ SwUndoNumruleRename::SwUndoNumruleRename(const String & _aOldName,
{
}
-void SwUndoNumruleRename::Undo(SwUndoIter &)
+void SwUndoNumruleRename::UndoImpl(::sw::UndoRedoContext &)
{
pDoc->RenameNumRule(aNewName, aOldName, TRUE);
}
-void SwUndoNumruleRename::Redo(SwUndoIter &)
+void SwUndoNumruleRename::RedoImpl(::sw::UndoRedoContext &)
{
pDoc->RenameNumRule(aOldName, aNewName, TRUE);
}
diff --git a/sw/source/core/undo/SwUndoPageDesc.cxx b/sw/source/core/undo/SwUndoPageDesc.cxx
index adada319d516..c23811d08f4c 100644
--- a/sw/source/core/undo/SwUndoPageDesc.cxx
+++ b/sw/source/core/undo/SwUndoPageDesc.cxx
@@ -326,7 +326,7 @@ void SwUndoPageDesc::ExchangeContentNodes( SwPageDesc& rSource, SwPageDesc &rDes
}
}
-void SwUndoPageDesc::Undo(SwUndoIter &)
+void SwUndoPageDesc::UndoImpl(::sw::UndoRedoContext &)
{
// Move (header/footer)content node responsibility from new page descriptor to old one again.
if( bExchange )
@@ -334,7 +334,7 @@ void SwUndoPageDesc::Undo(SwUndoIter &)
pDoc->ChgPageDesc(aOld.GetName(), aOld);
}
-void SwUndoPageDesc::Redo(SwUndoIter &)
+void SwUndoPageDesc::RedoImpl(::sw::UndoRedoContext &)
{
// Move (header/footer)content node responsibility from old page descriptor to new one again.
if( bExchange )
@@ -342,10 +342,6 @@ void SwUndoPageDesc::Redo(SwUndoIter &)
pDoc->ChgPageDesc(aNew.GetName(), aNew);
}
-void SwUndoPageDesc::Repeat(SwUndoIter &)
-{
-}
-
SwRewriter SwUndoPageDesc::GetRewriter() const
{
SwRewriter aResult;
@@ -370,7 +366,7 @@ SwUndoPageDescCreate::~SwUndoPageDescCreate()
{
}
-void SwUndoPageDescCreate::Undo(SwUndoIter &)
+void SwUndoPageDescCreate::UndoImpl(::sw::UndoRedoContext &)
{
// -> #116530#
if (pDesc)
@@ -383,17 +379,21 @@ void SwUndoPageDescCreate::Undo(SwUndoIter &)
pDoc->DelPageDesc(aNew.GetName(), TRUE);
}
-
-void SwUndoPageDescCreate::Redo(SwUndoIter &)
+void SwUndoPageDescCreate::DoImpl()
{
SwPageDesc aPageDesc = aNew;
pDoc->MakePageDesc(aNew.GetName(), &aPageDesc, FALSE, TRUE); // #116530#
}
-void SwUndoPageDescCreate::Repeat(SwUndoIter & rIt)
+void SwUndoPageDescCreate::RedoImpl(::sw::UndoRedoContext &)
+{
+ DoImpl();
+}
+
+void SwUndoPageDescCreate::RepeatImpl(::sw::RepeatContext &)
{
::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
- Redo(rIt);
+ DoImpl();
}
SwRewriter SwUndoPageDescCreate::GetRewriter() const
@@ -420,21 +420,26 @@ SwUndoPageDescDelete::~SwUndoPageDescDelete()
{
}
-void SwUndoPageDescDelete::Undo(SwUndoIter &)
+void SwUndoPageDescDelete::UndoImpl(::sw::UndoRedoContext &)
{
SwPageDesc aPageDesc = aOld;
pDoc->MakePageDesc(aOld.GetName(), &aPageDesc, FALSE, TRUE); // #116530#
}
-void SwUndoPageDescDelete::Redo(SwUndoIter &)
+void SwUndoPageDescDelete::DoImpl()
{
pDoc->DelPageDesc(aOld.GetName(), TRUE); // #116530#
}
-void SwUndoPageDescDelete::Repeat(SwUndoIter & rIt)
+void SwUndoPageDescDelete::RedoImpl(::sw::UndoRedoContext &)
+{
+ DoImpl();
+}
+
+void SwUndoPageDescDelete::RepeatImpl(::sw::RepeatContext &)
{
::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
- Redo(rIt);
+ DoImpl();
}
SwRewriter SwUndoPageDescDelete::GetRewriter() const
diff --git a/sw/source/core/undo/SwUndoTOXChange.cxx b/sw/source/core/undo/SwUndoTOXChange.cxx
index 8628ff70acc7..457ddc366e7c 100644
--- a/sw/source/core/undo/SwUndoTOXChange.cxx
+++ b/sw/source/core/undo/SwUndoTOXChange.cxx
@@ -27,6 +27,7 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sw.hxx"
+
#include <SwUndoTOXChange.hxx>
#include <swundo.hxx>
#include <doctxm.hxx>
@@ -45,27 +46,32 @@ void SwUndoTOXChange::UpdateTOXBaseSection()
if (pTOX->ISA(SwTOXBaseSection))
{
SwTOXBaseSection * pTOXBase = static_cast<SwTOXBaseSection *>(pTOX);
-
pTOXBase->Update();
pTOXBase->UpdatePageNum();
}
}
-void SwUndoTOXChange::Undo(SwUndoIter &)
+void SwUndoTOXChange::UndoImpl(::sw::UndoRedoContext &)
{
*pTOX = aOld;
UpdateTOXBaseSection();
}
-void SwUndoTOXChange::Redo(SwUndoIter &)
+void SwUndoTOXChange::DoImpl()
{
*pTOX = aNew;
UpdateTOXBaseSection();
}
-void SwUndoTOXChange::Repeat(SwUndoIter & rIter)
+void SwUndoTOXChange::RedoImpl(::sw::UndoRedoContext &)
+{
+ DoImpl();
+}
+
+void SwUndoTOXChange::RepeatImpl(::sw::RepeatContext &)
{
- Redo(rIter);
+ DoImpl();
}
+
diff --git a/sw/source/core/undo/docundo.cxx b/sw/source/core/undo/docundo.cxx
index 4b42a2b9540e..18a37e02c307 100644
--- a/sw/source/core/undo/docundo.cxx
+++ b/sw/source/core/undo/docundo.cxx
@@ -41,11 +41,12 @@
#include <ndarr.hxx>
#include <pam.hxx>
#include <ndtxt.hxx>
-#include <swundo.hxx> // fuer die UndoIds
+#include <swundo.hxx>
#include <undobj.hxx>
#include <rolbck.hxx>
-#include <docary.hxx>
#include <undo.hrc>
+#include <editsh.hxx>
+#include <unobaseclass.hxx>
using namespace ::com::sun::star;
@@ -55,50 +56,6 @@ using namespace ::com::sun::star;
#define UNDO_ACTION_LIMIT (USHRT_MAX - 1000)
-//#define _SHOW_UNDORANGE
-#ifdef _SHOW_UNDORANGE
-
-
-class UndoArrStatus : public WorkWindow
-{
- USHORT nUndo, nUndoNds;
- virtual void Paint( const Rectangle& );
-public:
- UndoArrStatus();
- void Set( USHORT, USHORT );
-};
-static UndoArrStatus* pUndoMsgWin = 0;
-
-
-UndoArrStatus::UndoArrStatus()
- : WorkWindow( APP_GETAPPWINDOW() ), nUndo(0), nUndoNds(0)
-{
- SetSizePixel( Size( 200, 100 ));
- SetFont( Font( "Courier", Size( 0, 10 )) );
- Show();
-}
-
-
-void UndoArrStatus::Set( USHORT n1, USHORT n2 )
-{
- nUndo = n1; nUndoNds = n2;
- Invalidate();
-}
-
-
-void UndoArrStatus::Paint( const Rectangle& )
-{
- String s;
- DrawRect( Rectangle( Point(0,0), GetOutputSize() ));
- ( s = "Undos: " ) += nUndo;
- DrawText( Point( 0, 0 ), s );
- ( s = "UndoNodes: " ) += nUndoNds;
- DrawText( Point( 0, 15 ), s );
-}
-
-#endif
-
-
// UndoManager ///////////////////////////////////////////////////////////
namespace sw {
@@ -111,17 +68,16 @@ UndoManager::UndoManager(::std::auto_ptr<SwNodes> pUndoNodes,
, m_rRedlineAccess(rRedlineAccess)
, m_rState(rState)
, m_pUndoNodes(pUndoNodes)
- , m_pUndos( new SwUndos( 0, 20 ) )
- , m_nUndoPos(0)
- , m_nUndoSavePos(0)
- , m_nUndoActions(0)
- , m_nNestingDepth(0)
- , m_bUndo(false)
, m_bGroupUndo(true)
, m_bDrawUndo(true)
, m_bLockUndoNoModifiedPosition(false)
+ , m_bClearOnLeave(false)
+ , m_UndoSaveMark(MARK_INVALID)
{
OSL_ASSERT(m_pUndoNodes.get());
+ // writer expects it to be disabled initially
+ // Undo is enabled by SwEditShell constructor
+ SfxUndoManager::EnableUndo(false);
}
SwNodes const& UndoManager::GetUndoNodes() const
@@ -141,7 +97,7 @@ bool UndoManager::IsUndoNodes(SwNodes const& rNodes) const
void UndoManager::DoUndo(bool const bDoUndo)
{
- m_bUndo = bDoUndo;
+ EnableUndo(bDoUndo);
SdrModel *const pSdrModel = m_rDrawModelAccess.GetDrawModel();
if( pSdrModel )
@@ -152,7 +108,7 @@ void UndoManager::DoUndo(bool const bDoUndo)
bool UndoManager::DoesUndo() const
{
- return m_bUndo;
+ return IsUndoEnabled();
}
void UndoManager::DoGroupUndo(bool const bDoUndo)
@@ -178,21 +134,23 @@ bool UndoManager::DoesDrawUndo() const
bool UndoManager::IsUndoNoResetModified() const
{
- return USHRT_MAX == m_nUndoSavePos;
+ return MARK_INVALID == m_UndoSaveMark;
}
void UndoManager::SetUndoNoResetModified()
{
- m_nUndoSavePos = USHRT_MAX;
+ if (MARK_INVALID != m_UndoSaveMark)
+ {
+ RemoveMark(m_UndoSaveMark);
+ m_UndoSaveMark = MARK_INVALID;
+ }
}
void UndoManager::SetUndoNoModifiedPosition()
{
if (!m_bLockUndoNoModifiedPosition)
{
- m_nUndoSavePos = (m_pUndos->Count())
- ? m_nUndoPos
- : USHRT_MAX;
+ m_UndoSaveMark = MarkTopUndoAction();
}
}
@@ -209,334 +167,51 @@ void UndoManager::UnLockUndoNoModifiedPosition()
SwUndo* UndoManager::GetLastUndo()
{
- return (0 == m_nUndoPos)
- ? 0
- : (*m_pUndos)[m_nUndoPos-1];
-}
-
-void UndoManager::AppendUndo(SwUndo *const pUndo)
-{
- OSL_ENSURE(DoesUndo(), "AppendUndo called with Undo disabled?");
- if (!DoesUndo())
- {
- return;
- }
-
- if( nsRedlineMode_t::REDLINE_NONE == pUndo->GetRedlineMode() )
- {
- pUndo->SetRedlineMode( m_rRedlineAccess.GetRedlineMode() );
- }
-
- // Unfortunately, the silly SvPtrArr can only store a little less than
- // USHRT_MAX elements. Of course it doesn't see any necessity for asserting
- // or even doing error handling. pUndos should definitely be replaced by an
- // STL container that doesn't have this problem. cf #95884#
- OSL_ENSURE( m_pUndos->Count() < USHRT_MAX - 16,
- "Writer will crash soon. I apologize for the inconvenience." );
-
- m_pUndos->Insert(pUndo, m_nUndoPos);
- ++m_nUndoPos;
- switch( pUndo->GetId() )
- {
- case UNDO_START:
- ++m_nNestingDepth;
- break;
-
- case UNDO_END:
- OSL_ENSURE(m_nNestingDepth, "AppendUndo(): Undo-End without Start");
- --m_nNestingDepth;
- // no break !
-
- default:
- if ((m_pUndos->Count() != m_nUndoPos) &&
- (UNDO_END != pUndo->GetId()))
- {
- ClearRedo();
- }
- OSL_ENSURE( m_pUndos->Count() == m_nUndoPos
- || UNDO_END == pUndo->GetId(),
- "AppendUndo(): Redo history not deleted!" );
- if (!m_nNestingDepth)
- {
- ++m_nUndoActions;
- }
- break;
- }
-
-#ifdef _SHOW_UNDORANGE
- // zur Anzeige der aktuellen Undo-Groessen
- if( !pUndoMsgWin )
- pUndoMsgWin = new UndoArrStatus;
- pUndoMsgWin->Set( m_pUndos->Count(), GetUndoNodes()->Count() );
-#endif
-
- // if the bracketing is still open, nothing more to do here
- if (m_nNestingDepth)
- {
- return;
- }
-
- // folgende Array-Grenzen muessen ueberwacht werden:
- // - Undo, Grenze: fester Wert oder USHRT_MAX - 1000
- // - UndoNodes, Grenze: USHRT_MAX - 1000
- // - AttrHistory Grenze: USHRT_MAX - 1000
- // (defined in UNDO_ACTION_LIMIT at the top of this file)
-
- USHORT nEnde = UNDO_ACTION_LIMIT;
-
-#ifdef DBG_UTIL
-{
- USHORT nUndosCnt = 0, nSttEndCnt = 0;
- for (USHORT nCnt = 0; nCnt < m_nUndoPos; ++nCnt)
+ if (!SfxUndoManager::GetUndoActionCount(CurrentLevel))
{
- SwUndoId const nId = (*m_pUndos)[ nCnt ]->GetId();
- if (UNDO_START == nId)
- {
- ++nSttEndCnt;
- }
- else if( UNDO_END == nId )
- --nSttEndCnt;
- if( !nSttEndCnt )
- ++nUndosCnt;
+ return 0;
}
- OSL_ENSURE(nSttEndCnt == m_nNestingDepth,
- "AppendUndo(): nesting depth is wrong");
- OSL_ENSURE(nUndosCnt == m_nUndoActions,
- "AppendUndo(): Undo action count is wrong");
+ SfxUndoAction *const pAction( SfxUndoManager::GetUndoAction(0) );
+ return dynamic_cast<SwUndo*>(pAction);
}
-#endif
- sal_Int32 const nActions(SW_MOD()->GetUndoOptions().GetUndoCount());
- if (nActions < m_nUndoActions)
- {
- // immer 1/10 loeschen
- //JP 23.09.95: oder wenn neu eingestellt wurde um die Differenz
- //JP 29.5.2001: Task #83891#: remove only the overlapping actions
- DelUndoObj( sal_uInt16( m_nUndoActions - nActions ) );
- }
- else
- {
- USHORT const nUndosCnt = m_nUndoActions;
- // immer 1/10 loeschen bis der "Ausloeser" behoben ist
- while (nEnde < GetUndoNodes().Count())
- {
- DelUndoObj( nUndosCnt / 10 );
- }
- }
+void UndoManager::AppendUndo(SwUndo *const pUndo)
+{
+ AddUndoAction(pUndo);
}
-
void UndoManager::ClearRedo()
{
- if (m_nUndoPos != m_pUndos->Count())
- {
- // update m_nUndoActions
- for (USHORT nCnt = m_pUndos->Count(); m_nUndoPos < nCnt;
- --m_nUndoActions)
- {
- // skip Start/End bracketing
- SwUndo *const pUndo = (*m_pUndos)[ --nCnt ];
- if (UNDO_END == pUndo->GetId())
- {
- nCnt = nCnt - static_cast<SwUndoEnd*>(pUndo)->GetSttOffset();
- }
- }
-
- // delete Undo actions in reverse order!
- m_pUndos->DeleteAndDestroy(m_nUndoPos, m_pUndos->Count() - m_nUndoPos);
- }
+ return SfxUndoManager::ImplClearRedo_NoLock(TopLevel);
}
-
void UndoManager::DelAllUndoObj()
{
::sw::UndoGuard const undoGuard(*this);
- ClearRedo();
+ SfxUndoManager::Clear();
- // retain open Start bracketing!
- USHORT nSize = m_pUndos->Count();
- while( nSize )
+ m_UndoSaveMark = MARK_INVALID;
+ if (SfxUndoManager::IsInListAction())
{
- SwUndo *const pUndo = (*m_pUndos)[ --nSize ];
- if ((UNDO_START != pUndo->GetId()) ||
- // bracketing closed with End?
- static_cast<SwUndoStart*>(pUndo)->GetEndOffset())
- {
- m_pUndos->DeleteAndDestroy( nSize, 1 );
- }
+ m_bClearOnLeave = true;
}
-
- m_nUndoActions = 0;
- m_nUndoPos = m_pUndos->Count();
-
- m_nUndoSavePos = USHRT_MAX;
}
-bool UndoManager::DelUndoObj( sal_uInt16 nEnd )
-{
- if (0 == nEnd) // in case 0 is passed in
- {
- if (!m_pUndos->Count())
- {
- return false;
- }
- ++nEnd; // correct it to 1 // FIXME why ???
- }
-
- ::sw::UndoGuard const undoGuard(*this);
-
- // check where the end is
- USHORT nSttEndCnt = 0;
- USHORT nCnt;
-
- for (nCnt = 0; nEnd && nCnt < m_nUndoPos; ++nCnt)
- {
- SwUndoId const nId = (*m_pUndos)[ nCnt ]->GetId();
- if (UNDO_START == nId)
- {
- ++nSttEndCnt;
- }
- else if( UNDO_END == nId )
- {
- --nSttEndCnt;
- }
- if( !nSttEndCnt )
- {
- --nEnd, --m_nUndoActions;
- }
- }
-
- OSL_ENSURE( nCnt < m_nUndoPos || m_nUndoPos == m_pUndos->Count(),
- "DelUndoObj(): end inside of Redo actions!" );
-
- // update positions
- nSttEndCnt = nCnt;
- if (m_nUndoSavePos < nSttEndCnt) // abandon SavePos
- {
- m_nUndoSavePos = USHRT_MAX;
- }
- else if (m_nUndoSavePos != USHRT_MAX)
- {
- m_nUndoSavePos = m_nUndoSavePos - nSttEndCnt;
- }
-
- while( nSttEndCnt )
- {
- m_pUndos->DeleteAndDestroy( --nSttEndCnt, 1 );
- }
- m_nUndoPos = m_pUndos->Count();
-
- return true;
-}
-
/**************** UNDO ******************/
-bool UndoManager::HasUndoId(SwUndoId const eId) const
-{
- USHORT nSize = m_nUndoPos;
- while( nSize-- )
- {
- SwUndo *const pUndo = (*m_pUndos)[nSize];
- if ((pUndo->GetId() == eId) ||
- ( UNDO_START == pUndo->GetId() &&
- (static_cast<SwUndoStart*>(pUndo)->GetUserId() == eId))
- || ( UNDO_END == pUndo->GetId() &&
- (static_cast<SwUndoEnd*>(pUndo)->GetUserId() == eId)))
- {
- return true;
- }
- }
-
- return false;
-}
-
-
-bool UndoManager::Undo( SwUndoIter& rUndoIter )
-{
- if ( (rUndoIter.GetId()!=0) && (!HasUndoId(rUndoIter.GetId())) )
- {
- rUndoIter.bWeiter = FALSE;
- return false;
- }
- if (!m_nUndoPos)
- {
- rUndoIter.bWeiter = FALSE;
- return false;
- }
-
- ::sw::UndoGuard const undoGuard(*this);
-
- SwUndo * pUndo = (*m_pUndos)[ --m_nUndoPos ];
-
- RedlineMode_t const eOld = m_rRedlineAccess.GetRedlineMode();
- RedlineMode_t eTmpMode = (RedlineMode_t)pUndo->GetRedlineMode();
- if( (nsRedlineMode_t::REDLINE_SHOW_MASK & eTmpMode) != (nsRedlineMode_t::REDLINE_SHOW_MASK & eOld) &&
- UNDO_START != pUndo->GetId() && UNDO_END != pUndo->GetId() )
- {
- m_rRedlineAccess.SetRedlineMode( eTmpMode );
- }
- m_rRedlineAccess.SetRedlineMode_intern(
- static_cast<RedlineMode_t>(eTmpMode | nsRedlineMode_t::REDLINE_IGNORE));
-
- SwUndoId const nAktId = pUndo->GetId();
- //JP 11.05.98: FlyFormate ueber die EditShell selektieren, nicht aus dem
- // Undo heraus
- switch( nAktId )
- {
- case UNDO_START:
- case UNDO_END:
- case UNDO_INSDRAWFMT:
- break;
-
- default:
- rUndoIter.ClearSelections();
- }
-
- pUndo->Undo( rUndoIter );
-
- m_rRedlineAccess.SetRedlineMode( eOld );
-
- if (m_nUndoPos && !rUndoIter.bWeiter)
- {
- pUndo = (*m_pUndos)[ m_nUndoPos-1 ];
- if (UNDO_START == pUndo->GetId())
- {
- --m_nUndoPos;
- }
- }
-
- // if we are at the "last save" position, the document is not modified
- if (m_nUndoSavePos == m_nUndoPos)
- {
- m_rState.ResetModified();
- }
- // JP 29.10.96: Start und End setzen kein Modify-Flag.
- // Sonst gibt es Probleme mit der autom. Aufnahme von Ausnahmen
- // bei der Autokorrektur
- else if ((UNDO_START != nAktId) && (UNDO_END != nAktId))
- {
- m_rState.SetModified();
- }
-
- return true;
-}
-
-
SwUndoId
UndoManager::StartUndo(SwUndoId const i_eUndoId,
SwRewriter const*const pRewriter)
{
- if (!m_bUndo)
+ if (!IsUndoEnabled())
{
return UNDO_EMPTY;
}
SwUndoId const eUndoId( (0 == i_eUndoId) ? UNDO_START : i_eUndoId );
- SwUndoStart * pUndo = new SwUndoStart( eUndoId );
-
OSL_ASSERT(UNDO_END != eUndoId);
String comment( (UNDO_START == eUndoId)
? String("??", RTL_TEXTENCODING_ASCII_US)
@@ -546,9 +221,8 @@ UndoManager::StartUndo(SwUndoId const i_eUndoId,
OSL_ASSERT(UNDO_START != eUndoId);
comment = pRewriter->Apply(comment);
}
- pUndo->SetComment(comment);
- AppendUndo(pUndo);
+ SfxUndoManager::EnterListAction(comment, comment, eUndoId);
return eUndoId;
}
@@ -557,8 +231,7 @@ UndoManager::StartUndo(SwUndoId const i_eUndoId,
SwUndoId
UndoManager::EndUndo(SwUndoId const i_eUndoId, SwRewriter const*const pRewriter)
{
- USHORT nSize = m_nUndoPos;
- if (!m_bUndo || !nSize--)
+ if (!IsUndoEnabled())
{
return UNDO_EMPTY;
}
@@ -566,334 +239,93 @@ UndoManager::EndUndo(SwUndoId const i_eUndoId, SwRewriter const*const pRewriter)
SwUndoId const eUndoId( ((0 == i_eUndoId) || (UNDO_START == i_eUndoId))
? UNDO_END : i_eUndoId );
- SwUndo * pUndo = (*m_pUndos)[ nSize ];
- if( UNDO_START == pUndo->GetId() )
- {
- // empty Start/End bracketing?
- m_pUndos->DeleteAndDestroy( nSize );
- --m_nUndoPos;
- --m_nNestingDepth;
- return UNDO_EMPTY;
- }
+ SfxUndoAction *const pLastUndo(
+ (0 == SfxUndoManager::GetUndoActionCount(CurrentLevel))
+ ? 0 : SfxUndoManager::GetUndoAction(0) );
- // exist above any redo objects? If yes, delete them
- if (m_nUndoPos != m_pUndos->Count())
- {
- // update UndoCnt
- for (USHORT nCnt = m_pUndos->Count(); m_nUndoPos < nCnt;
- --m_nUndoActions)
- {
- // skip bracketing
- pUndo = (*m_pUndos)[ --nCnt ];
- if (UNDO_END == pUndo->GetId())
- {
- nCnt -= static_cast<SwUndoEnd*>(pUndo)->GetSttOffset();
- }
- }
+ int const nCount = LeaveListAction();
- m_pUndos->DeleteAndDestroy(m_nUndoPos, m_pUndos->Count() - m_nUndoPos);
- }
-
- // search for Start of this bracketing
- SwUndoStart * pUndoStart(0);
- while( nSize )
+ if (nCount) // otherwise: empty list action not inserted!
{
- SwUndo *const pTmpUndo = (*m_pUndos)[ --nSize ];
- if ((UNDO_START == pTmpUndo->GetId()) &&
- !static_cast<SwUndoStart*>(pTmpUndo)->GetEndOffset())
- {
- pUndoStart = static_cast<SwUndoStart *>(pTmpUndo);
- break; // found start
- }
- }
-
- if (!pUndoStart)
- {
- // kann eigentlich nur beim Abspielen von Macros passieren, die
- // Undo/Redo/Repeat benutzen und die eine exitierende Selection
- // durch Einfuegen loeschen
- OSL_ENSURE(false , "EndUndo(): corresponding UNDO_START not found");
- // not found => do not insert end and reset members
-
- m_nNestingDepth = 0;
- m_nUndoActions = 0;
- // update m_nUndoActions
- for (USHORT nCnt = 0; nCnt < m_pUndos->Count();
- ++nCnt, ++m_nUndoActions)
- {
- // skip bracketing
- SwUndo *const pTmpUndo = (*m_pUndos)[ nCnt ];
- if (UNDO_START == pTmpUndo->GetId())
- {
- nCnt += static_cast<SwUndoStart*>(pTmpUndo)->GetEndOffset();
- }
- }
- return UNDO_EMPTY;
- }
-
- // bracketing around single Undo action is unnecessary!
- // except if there is a custom user ID.
- if ((2 == m_pUndos->Count() - nSize) &&
- ((UNDO_END == eUndoId) || (eUndoId == (*m_pUndos)[ nSize+1 ]->GetId())))
- {
- m_pUndos->DeleteAndDestroy( nSize );
- m_nUndoPos = m_pUndos->Count();
- if (!--m_nNestingDepth)
+ OSL_ASSERT(pLastUndo);
+ OSL_ASSERT(UNDO_START != eUndoId);
+ SfxUndoAction *const pUndoAction(SfxUndoManager::GetUndoAction(0));
+ SfxListUndoAction *const pListAction(
+ dynamic_cast<SfxListUndoAction*>(pUndoAction));
+ OSL_ASSERT(pListAction);
+ if (pListAction)
{
- ++m_nUndoActions;
- sal_Int32 const nActions(SW_MOD()->GetUndoOptions().GetUndoCount());
- if (nActions < m_nUndoActions)
+ if (UNDO_END != eUndoId)
{
- // immer 1/10 loeschen
- //JP 23.09.95: oder wenn neu eingestellt wurde um die Differenz
- //JP 29.5.2001: Task #83891#: remove only the overlapping actions
- DelUndoObj( sal_uInt16( m_nUndoActions - nActions ) );
- }
- else
- {
- USHORT nEnde = USHRT_MAX - 1000;
- USHORT const nUndosCnt = m_nUndoActions;
- // immer 1/10 loeschen bis der "Ausloeser" behoben ist
- while (nEnde < GetUndoNodes().Count())
+ // comment set by caller of EndUndo
+ String comment = String(SW_RES(UNDO_BASE + eUndoId));
+ if (pRewriter)
{
- DelUndoObj( nUndosCnt / 10 );
+ comment = pRewriter->Apply(comment);
}
+ pListAction->SetComment(comment);
}
- }
- return eUndoId;
- }
-
- // set offset for Start/End bracketing
- nSize = m_pUndos->Count() - nSize;
- pUndoStart->SetEndOffset( nSize );
-
- SwUndoEnd *const pUndoEnd = new SwUndoEnd( eUndoId );
- pUndoEnd->SetSttOffset( nSize );
-
-// nur zum Testen der Start/End-Verpointerung vom Start/End Undo
-#ifdef DBG_UTIL
- {
- USHORT nEndCnt = 1;
- USHORT nCnt = m_pUndos->Count();
- SwUndoId nTmpId = UNDO_EMPTY;
- while( nCnt )
- {
- nTmpId = (*m_pUndos)[ --nCnt ]->GetId();
- if (UNDO_START == nTmpId)
+ else if ((UNDO_START != pListAction->GetId()))
{
- if( !nEndCnt ) // falls mal ein Start ohne Ende vorhanden ist
- continue;
- --nEndCnt;
- if( !nEndCnt ) // hier ist der Anfang
- break;
+ // comment set by caller of StartUndo: nothing to do here
}
- else if( UNDO_END == nTmpId )
- ++nEndCnt;
- else if( !nEndCnt )
- break;
- }
- OSL_ENSURE( nCnt == m_pUndos->Count() - nSize,
- "EndUndo(): Start-End bracketing wrong" );
- }
-#endif
-
- if (pRewriter)
- {
- OSL_ASSERT(UNDO_START != eUndoId);
- String const comment( (UNDO_END == eUndoId)
- ? String("??", RTL_TEXTENCODING_ASCII_US)
- : pRewriter->Apply(String(SW_RES(UNDO_BASE + eUndoId))) );
- pUndoStart->SetComment(comment);
- pUndoEnd->SetComment(comment);
- }
- else
- {
- pUndoEnd->SetComment(pUndoStart->GetComment());
- }
-
- AppendUndo( pUndoEnd );
- return eUndoId;
-}
-
-/*-- 24.11.2004 16:11:21---------------------------------------------------
-
- -----------------------------------------------------------------------*/
-
-typedef ::std::pair<SwUndoId, ::rtl::OUString> IdAndName_t;
-
-/**
- Returns id and comment for a certain undo object in an undo stack.
-
- Remark: In the following the object type referred to is always the
- effective object type. If an UNDO_START or UNDO_END has a user type
- it is referred to as this type.
-
- If the queried object is an UNDO_END and has no user id the result
- is taken from the first object that is not an UNDO_END nor an
- UNDO_START preceeding the queried object.
-
- If the queried object is an UNDO_START and has no user id the
- result is taken from the first object that is not an UNDO_END nor
- an UNDO_START preceeding the UNDO_END object belonging to the
- queried object.
-
- In all other cases the result is taken from the queried object.
-
- @param rUndos the undo stack
- @param nPos position of the undo object to query
-
- @return IdAndName_t object containing the query result
- */
-IdAndName_t lcl_GetUndoIdAndName(const SwUndos & rUndos, sal_uInt16 nPos)
-{
- SwUndo * pUndo = rUndos[ nPos ];
- SwUndoId nId = UNDO_EMPTY;
- String sStr("??", RTL_TEXTENCODING_ASCII_US);
-
- OSL_ENSURE( nPos < rUndos.Count(), "nPos out of range");
-
- switch (pUndo->GetId())
- {
- case UNDO_START:
- {
- SwUndoStart * pUndoStart = (SwUndoStart *) pUndo;
- nId = pUndoStart->GetUserId();
-
- if (nId <= UNDO_END)
+ else if (pLastUndo)
{
- /**
- Start at the according UNDO_END. Search backwards
- for first objects that is not a UNDO_END.
- */
- int nTmpPos = nPos + pUndoStart->GetEndOffset();
- int nSubstitute = -1;
-
- // --> OD 2009-09-30 #i105457#
- if ( nTmpPos > 0 )
- // <--
- {
- SwUndo * pTmpUndo;
- do
- {
- nTmpPos--;
- pTmpUndo = rUndos[ static_cast<USHORT>(nTmpPos) ];
-
- if (pTmpUndo->GetEffectiveId() > UNDO_END)
- nSubstitute = nTmpPos;
- }
- while (nSubstitute < 0 && nTmpPos > nPos);
-
- if (nSubstitute >= 0)
- {
- SwUndo * pSubUndo = rUndos[ static_cast<USHORT>(nSubstitute) ];
- nId = pSubUndo->GetEffectiveId();
- sStr = pSubUndo->GetComment();
- }
- }
+ // comment was not set at StartUndo or EndUndo:
+ // take comment of last contained action
+ // (note that this works recursively, i.e. the last contained
+ // action may be a list action created by StartUndo/EndUndo)
+ String const comment(pLastUndo->GetComment());
+ pListAction->SetComment(comment);
}
else
- sStr = pUndo->GetComment();
- }
-
- break;
-
- case UNDO_END:
- {
- SwUndoEnd * pUndoEnd = (SwUndoEnd *) pUndo;
- nId = pUndoEnd->GetUserId();
-
- if (nId <= UNDO_END)
{
- /**
- Start at this UNDO_END. Search backwards
- for first objects that is not a UNDO_END.
- */
-
- int nTmpPos = nPos;
- int nUndoStart = nTmpPos - pUndoEnd->GetSttOffset();
- int nSubstitute = -1;
-
- if (nTmpPos > 0)
- {
- SwUndo * pTmpUndo;
-
- do
- {
- nTmpPos--;
- pTmpUndo = rUndos[ static_cast<USHORT>(nTmpPos) ];
-
- if (pTmpUndo->GetEffectiveId() > UNDO_END)
- nSubstitute = nTmpPos;
- }
- while (nSubstitute < 0 && nTmpPos > nUndoStart);
-
- if (nSubstitute >= 0)
- {
- SwUndo * pSubUndo = rUndos[ static_cast<USHORT>(nSubstitute) ];
- nId = pSubUndo->GetEffectiveId();
- sStr = pSubUndo->GetComment();
- }
- }
+ OSL_ENSURE(false, "EndUndo(): no comment?");
}
- else
- sStr = pUndo->GetComment();
}
-
- break;
-
- default:
- nId = pUndo->GetId();
- sStr = pUndo->GetComment();
}
- return IdAndName_t(nId, sStr);
+ return eUndoId;
}
-
bool
UndoManager::GetLastUndoInfo(
::rtl::OUString *const o_pStr, SwUndoId *const o_pId) const
{
- if (!m_nUndoPos)
+ // this is actually expected to work on the current level,
+ // but that was really not obvious from the previous implementation...
+ if (!SfxUndoManager::GetUndoActionCount(CurrentLevel))
{
return false;
}
- IdAndName_t const idAndName(lcl_GetUndoIdAndName(*m_pUndos, m_nUndoPos-1));
+ SfxUndoAction *const pAction( SfxUndoManager::GetUndoAction(0) );
if (o_pStr)
{
- *o_pStr = idAndName.second;
+ *o_pStr = pAction->GetComment();
}
if (o_pId)
{
- *o_pId = idAndName.first;
+ USHORT const nId(pAction->GetId());
+ *o_pId = static_cast<SwUndoId>(nId);
}
return true;
}
-
SwUndoComments_t UndoManager::GetUndoComments() const
{
- SwUndoComments_t ret;
- int nTmpPos = m_nUndoPos - 1;
+ OSL_ENSURE(!SfxUndoManager::IsInListAction(),
+ "GetUndoComments() called while in list action?");
- while (nTmpPos >= 0)
+ SwUndoComments_t ret;
+ USHORT const nUndoCount(SfxUndoManager::GetUndoActionCount(TopLevel));
+ for (USHORT n = 0; n < nUndoCount; ++n)
{
- SwUndo *const pUndo = (*m_pUndos)[ static_cast<USHORT>(nTmpPos) ];
-
- IdAndName_t const idAndName(
- lcl_GetUndoIdAndName(*m_pUndos, static_cast<sal_uInt16>(nTmpPos)));
-
- ret.push_back(idAndName.second);
-
- if (pUndo->GetId() == UNDO_END)
- {
- nTmpPos -= static_cast<SwUndoEnd *>(pUndo)->GetSttOffset();
- }
-
- nTmpPos--;
+ ::rtl::OUString const comment(
+ SfxUndoManager::GetUndoActionComment(n, TopLevel));
+ ret.push_back(comment);
}
return ret;
@@ -902,197 +334,264 @@ SwUndoComments_t UndoManager::GetUndoComments() const
/**************** REDO ******************/
-
-bool UndoManager::Redo(SwUndoIter & rUndoIter)
+bool UndoManager::GetFirstRedoInfo(::rtl::OUString *const o_pStr) const
{
- if( rUndoIter.GetId() && !HasUndoId( rUndoIter.GetId() ) )
+ if (!SfxUndoManager::GetRedoActionCount(CurrentLevel))
{
- rUndoIter.bWeiter = FALSE;
return false;
}
- if (m_nUndoPos == m_pUndos->Count())
+
+ if (o_pStr)
{
- rUndoIter.bWeiter = FALSE;
- return false;
+ *o_pStr = SfxUndoManager::GetRedoActionComment(0, CurrentLevel);
}
- ::sw::UndoGuard const undoGuard(*this);
+ return true;
+}
+
- SwUndo *const pUndo = (*m_pUndos)[ m_nUndoPos++ ];
+SwUndoComments_t UndoManager::GetRedoComments() const
+{
+ OSL_ENSURE(!SfxUndoManager::IsInListAction(),
+ "GetRedoComments() called while in list action?");
- RedlineMode_t const eOld = m_rRedlineAccess.GetRedlineMode();
- RedlineMode_t eTmpMode = (RedlineMode_t)pUndo->GetRedlineMode();
- if( (nsRedlineMode_t::REDLINE_SHOW_MASK & eTmpMode) != (nsRedlineMode_t::REDLINE_SHOW_MASK & eOld) &&
- UNDO_START != pUndo->GetId() && UNDO_END != pUndo->GetId() )
+ SwUndoComments_t ret;
+ USHORT const nRedoCount(SfxUndoManager::GetRedoActionCount(TopLevel));
+ for (USHORT n = 0; n < nRedoCount; ++n)
{
- m_rRedlineAccess.SetRedlineMode(eTmpMode);
+ ::rtl::OUString const comment(
+ SfxUndoManager::GetRedoActionComment(n, TopLevel));
+ ret.push_back(comment);
}
- m_rRedlineAccess.SetRedlineMode_intern(
- static_cast<RedlineMode_t>(eTmpMode | nsRedlineMode_t::REDLINE_IGNORE));
- //JP 11.05.98: FlyFormate ueber die EditShell selektieren, nicht aus dem
- // Undo heraus
- if( UNDO_START != pUndo->GetId() && UNDO_END != pUndo->GetId() )
- rUndoIter.ClearSelections();
-
- pUndo->Redo( rUndoIter );
+ return ret;
+}
- m_rRedlineAccess.SetRedlineMode(eOld);
+/**************** REPEAT ******************/
- if (rUndoIter.bWeiter && (m_nUndoPos >= m_pUndos->Count()))
+SwUndoId UndoManager::GetRepeatInfo(::rtl::OUString *const o_pStr) const
+{
+ SwUndoId nRepeatId(UNDO_EMPTY);
+ GetLastUndoInfo(o_pStr, & nRepeatId);
+ if( REPEAT_START <= nRepeatId && REPEAT_END > nRepeatId )
{
- rUndoIter.bWeiter = FALSE;
+ return nRepeatId;
}
+ if (o_pStr) // not repeatable -> clear comment
+ {
+ *o_pStr = String();
+ }
+ return UNDO_EMPTY;
+}
- // if we are at the "last save" position, the document is not modified
- if (m_nUndoSavePos == m_nUndoPos)
+SwUndo * UndoManager::RemoveLastUndo()
+{
+ if (SfxUndoManager::GetRedoActionCount(CurrentLevel) ||
+ SfxUndoManager::GetRedoActionCount(TopLevel))
{
- m_rState.ResetModified();
+ OSL_ENSURE(false, "RemoveLastUndoAction(): there are Redo actions?");
+ return 0;
}
- else
+ if (!SfxUndoManager::GetUndoActionCount(CurrentLevel))
{
- m_rState.SetModified();
+ OSL_ENSURE(false, "RemoveLastUndoAction(): no Undo actions");
+ return 0;
}
- return true;
+ SfxUndoAction *const pLastUndo(GetUndoAction(0));
+ SfxUndoManager::RemoveLastUndoAction();
+ return dynamic_cast<SwUndo *>(pLastUndo);
}
+// svl::IUndoManager /////////////////////////////////////////////////////
-bool UndoManager::GetFirstRedoInfo(::rtl::OUString *const o_pStr) const
+void UndoManager::EnableUndo(bool bEnable)
{
- if (m_pUndos->Count() == m_nUndoPos)
+ // UGLY: SfxUndoManager has a counter to match enable/disable calls
+ // but the writer code expects that a single call switches
+ while (IsUndoEnabled() != bEnable)
{
- return false;
+ SfxUndoManager::EnableUndo(bEnable);
}
+}
- IdAndName_t const idAndName(lcl_GetUndoIdAndName(*m_pUndos, m_nUndoPos));
+USHORT UndoManager::LeaveListAction()
+{
+ USHORT const nCount = SfxUndoManager::LeaveListAction();
- if (o_pStr)
+ if (m_bClearOnLeave)
{
- *o_pStr = idAndName.second;
+ SfxUndoManager::Clear();
+ if (!SfxUndoManager::IsInListAction())
+ {
+ m_bClearOnLeave = false;
+ }
+ return 0; // EndUndo() must not access deleted last undo action!
}
- return true;
+ return nCount;
}
-
-SwUndoComments_t UndoManager::GetRedoComments() const
+void UndoManager::AddUndoAction(SfxUndoAction *pAction, sal_Bool bTryMerge)
{
- SwUndoComments_t ret;
- sal_uInt16 nTmpPos = m_nUndoPos;
-
- while (nTmpPos < m_pUndos->Count())
+ SwUndo *const pUndo( dynamic_cast<SwUndo *>(pAction) );
+ if (pUndo)
{
- SwUndo *const pUndo = (*m_pUndos)[nTmpPos];
-
- IdAndName_t const idAndName(lcl_GetUndoIdAndName(*m_pUndos, nTmpPos));
-
- ret.push_back(idAndName.second);
-
- if (pUndo->GetId() == UNDO_START)
+ if (nsRedlineMode_t::REDLINE_NONE == pUndo->GetRedlineMode())
{
- nTmpPos =
- nTmpPos + static_cast<SwUndoStart *>(pUndo)->GetEndOffset();
+ pUndo->SetRedlineMode( m_rRedlineAccess.GetRedlineMode() );
}
-
- nTmpPos++;
}
-
- return ret;
+ SfxUndoManager::AddUndoAction(pAction, bTryMerge);
+ // if the undo nodes array is too large, delete some actions
+ while (UNDO_ACTION_LIMIT < GetUndoNodes().Count())
+ {
+ RemoveOldestUndoActions(1);
+ }
}
-/**************** REPEAT ******************/
-
-
-bool UndoManager::Repeat(SwUndoIter & rUndoIter, sal_uInt16 const nRepeatCnt)
+class CursorGuard
{
- if( rUndoIter.GetId() && !HasUndoId( rUndoIter.GetId() ) )
+public:
+ CursorGuard(SwEditShell & rShell, bool const bSave)
+ : m_rShell(rShell)
+ , m_bSaveCursor(bSave)
{
- rUndoIter.bWeiter = FALSE;
- return false;
+ if (m_bSaveCursor)
+ {
+ m_rShell.Push(); // prevent modification of current cursor
+ }
}
- USHORT nCurrentRepeat = m_nUndoPos;
- if( !nCurrentRepeat )
+ ~CursorGuard()
{
- rUndoIter.bWeiter = FALSE;
- return false;
+ if (m_bSaveCursor)
+ {
+ m_rShell.Pop();
+ }
}
+private:
+ SwEditShell & m_rShell;
+ bool const m_bSaveCursor;
+};
+
+bool UndoManager::impl_DoUndoRedo(UndoOrRedo_t const undoOrRedo)
+{
+ SwDoc & rDoc(*GetUndoNodes().GetDoc());
+
+ UnoActionContext c(& rDoc); // exception-safe StartAllAction/EndAllAction
- // look for current Repeat action, considering Start/End bracketing
- SwUndo *const pUndo = (*m_pUndos)[ --nCurrentRepeat ];
- if( UNDO_END == pUndo->GetId() )
+ SwEditShell *const pEditShell( rDoc.GetEditShell() );
+
+ OSL_ENSURE(pEditShell, "sw::UndoManager needs a SwEditShell!");
+ if (!pEditShell)
{
- nCurrentRepeat -= static_cast<SwUndoEnd*>(pUndo)->GetSttOffset();
+ throw uno::RuntimeException();
}
- USHORT const nEndCnt = m_nUndoPos;
- bool const bOneUndo = (nCurrentRepeat + 1 == m_nUndoPos);
+ // in case the model has controllers locked, the Undo should not
+ // change the view cursors!
+ bool const bSaveCursors(pEditShell->CursorsLocked());
+ CursorGuard(*pEditShell, bSaveCursors);
+ if (!bSaveCursors)
+ {
+ // (in case Undo was called via API) clear the cursors:
+ pEditShell->KillPams();
+ pEditShell->SetMark();
+ pEditShell->ClearMark();
+ }
- SwPaM* pTmpCrsr = rUndoIter.pAktPam;
- SwUndoId nId = UNDO_EMPTY;
+ bool bRet(false);
- // need Start/End bracketing?
- if (pTmpCrsr != pTmpCrsr->GetNext() || !bOneUndo)
+ ::sw::UndoRedoContext context(rDoc, *pEditShell);
+
+ // N.B. these may throw!
+ if (UNDO == undoOrRedo)
{
- if (pUndo->GetId() == UNDO_END)
+ bRet = SfxUndoManager::UndoWithContext(context);
+ }
+ else
+ {
+ bRet = SfxUndoManager::RedoWithContext(context);
+ }
+
+ if (bRet)
+ {
+ // if we are at the "last save" position, the document is not modified
+ if (SfxUndoManager::HasTopUndoActionMark(m_UndoSaveMark))
{
- SwUndoStart *const pStartUndo =
- static_cast<SwUndoStart *>((*m_pUndos)[nCurrentRepeat]);
- nId = pStartUndo->GetUserId();
+ m_rState.ResetModified();
}
-
- StartUndo( nId, NULL );
- }
- do { // iterate over ring
- for( USHORT nRptCnt = nRepeatCnt; nRptCnt > 0; --nRptCnt )
+ else
{
- for (USHORT nCnt = nCurrentRepeat; nCnt < nEndCnt; ++nCnt)
- {
- (*m_pUndos)[ nCnt ]->Repeat( rUndoIter );
- }
+ m_rState.SetModified();
}
- rUndoIter.m_bDeleteRepeated = false; // reset for next PaM
- rUndoIter.pAktPam = static_cast<SwPaM*>(rUndoIter.pAktPam->GetNext());
- } while (pTmpCrsr != rUndoIter.pAktPam);
- if( pTmpCrsr != pTmpCrsr->GetNext() || !bOneUndo )
- {
- EndUndo( nId, NULL );
}
- return true;
+ pEditShell->HandleUndoRedoContext(context);
+
+ return bRet;
}
+sal_Bool UndoManager::Undo()
+{
+ bool const bRet = impl_DoUndoRedo(UNDO);
+ return bRet;
+}
-SwUndoId UndoManager::GetRepeatInfo(::rtl::OUString *const o_pStr) const
+sal_Bool UndoManager::Redo()
{
- SwUndoId nRepeatId(UNDO_EMPTY);
- GetLastUndoInfo(o_pStr, & nRepeatId);
- if( REPEAT_START <= nRepeatId && REPEAT_END > nRepeatId )
+ bool const bRet = impl_DoUndoRedo(REDO);
+ return bRet;
+}
+
+/** N.B.: this does _not_ call SfxUndoManager::Repeat because it is not
+ possible to wrap a list action around it:
+ calling EnterListAction here will cause SfxUndoManager::Repeat
+ to repeat the list action!
+ */
+bool
+UndoManager::Repeat(::sw::RepeatContext & rContext,
+ sal_uInt16 const nRepeatCount)
+{
+ if (SfxUndoManager::IsInListAction())
{
- return nRepeatId;
+ OSL_ENSURE(false, "repeat in open list action???");
+ return false;
}
- if (o_pStr) // not repeatable -> clear comment
+ if (!SfxUndoManager::GetUndoActionCount(TopLevel))
{
- *o_pStr = String();
+ return false;
+ }
+ SfxUndoAction *const pRepeatAction(GetUndoAction(0));
+ OSL_ASSERT(pRepeatAction);
+ if (!pRepeatAction || !pRepeatAction->CanRepeat(rContext))
+ {
+ return false;
}
- return UNDO_EMPTY;
-}
-
-SwUndo* UndoManager::RemoveLastUndo()
-{
- SwUndo *const pUndo = (*m_pUndos)[ m_nUndoPos - 1 ];
- if (m_nUndoPos != m_pUndos->Count())
+ ::rtl::OUString const comment(pRepeatAction->GetComment());
+ ::rtl::OUString const rcomment(pRepeatAction->GetRepeatComment(rContext));
+ USHORT const nId(pRepeatAction->GetId());
+ if (DoesUndo())
{
- OSL_ENSURE(false, "RemoveLastUndo(): there are Redo actions?");
- return 0;
+ EnterListAction(comment, rcomment, nId);
}
- if (!m_nNestingDepth)
+
+ SwPaM *const pFirstCursor(& rContext.GetRepeatPaM());
+ do { // iterate over ring
+ for (USHORT nRptCnt = nRepeatCount; nRptCnt > 0; --nRptCnt)
+ {
+ pRepeatAction->Repeat(rContext);
+ }
+ rContext.m_bDeleteRepeated = false; // reset for next PaM
+ rContext.m_pCurrentPaM =
+ static_cast<SwPaM*>(rContext.m_pCurrentPaM->GetNext());
+ } while (pFirstCursor != & rContext.GetRepeatPaM());
+
+ if (DoesUndo())
{
- --m_nUndoActions;
+ LeaveListAction();
}
- --m_nUndoPos;
- m_pUndos->Remove( m_nUndoPos, 1 );
- return pUndo;
+ return true;
}
} // namespace sw
diff --git a/sw/source/core/undo/makefile.mk b/sw/source/core/undo/makefile.mk
index 35771fa444bf..38285c909187 100644
--- a/sw/source/core/undo/makefile.mk
+++ b/sw/source/core/undo/makefile.mk
@@ -46,6 +46,7 @@ SRC1FILES = \
EXCEPTIONSFILES = \
$(SLO)$/SwRewriter.obj \
+ $(SLO)$/docundo.obj \
$(SLO)$/unattr.obj \
$(SLO)$/undobj.obj \
$(SLO)$/undraw.obj \
diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx
index e2a8ffa8f67c..7ee75378ff5a 100644
--- a/sw/source/core/undo/rolbck.cxx
+++ b/sw/source/core/undo/rolbck.cxx
@@ -579,9 +579,10 @@ SwHistoryTxtFlyCnt::~SwHistoryTxtFlyCnt()
void SwHistoryTxtFlyCnt::SetInDoc( SwDoc* pDoc, bool )
{
- SwPaM aPam( pDoc->GetNodes().GetEndOfPostIts() );
- SwUndoIter aUndoIter( &aPam );
- m_pUndo->Undo( aUndoIter );
+ ::sw::IShellCursorSupplier *const pISCS(pDoc->GetIShellCursorSupplier());
+ OSL_ASSERT(pISCS);
+ ::sw::UndoRedoContext context(*pDoc, *pISCS);
+ m_pUndo->UndoImpl(context);
}
@@ -1265,7 +1266,7 @@ USHORT SwHistory::SetTmpEnd( USHORT nNewTmpEnd )
if ( HSTRY_FLYCNT == (*this)[ n ]->Which() )
{
static_cast<SwHistoryTxtFlyCnt*>((*this)[ n ])
- ->GetUDelLFmt()->Redo();
+ ->GetUDelLFmt()->RedoForRollback();
}
}
diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx
index 1886e40ec4b9..5e0cdda4e5bd 100644
--- a/sw/source/core/undo/unattr.cxx
+++ b/sw/source/core/undo/unattr.cxx
@@ -48,6 +48,7 @@
#include <ftnidx.hxx>
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
+#include <IShellCursorSupplier.hxx>
#include <docary.hxx>
#include <swundo.hxx> // fuer die UndoIds
#include <pam.hxx>
@@ -65,9 +66,6 @@
-inline SwDoc& SwUndoIter::GetDoc() const
-{ return *pAktPam->GetDoc(); }
-
// -----------------------------------------------------
SwUndoFmtAttrHelper::SwUndoFmtAttrHelper( SwFmt& rFmt, bool bSvDrwPt )
@@ -195,12 +193,12 @@ SwUndoFmtAttr::~SwUndoFmtAttr()
{
}
-void SwUndoFmtAttr::Undo( SwUndoIter& rUndoIter)
+void SwUndoFmtAttr::UndoImpl(::sw::UndoRedoContext & rContext)
{
// OD 2004-10-26 #i35443#
// Important note: <Undo(..)> also called by <ReDo(..)>
- if ( !m_pOldSet.get() || !m_pFmt || !IsFmtInDoc( &rUndoIter.GetDoc() ))
+ if ( !m_pOldSet.get() || !m_pFmt || !IsFmtInDoc( &rContext.GetDoc() ))
return;
// --> OD 2004-10-26 #i35443# - If anchor attribute has been successfull
@@ -209,7 +207,7 @@ void SwUndoFmtAttr::Undo( SwUndoIter& rUndoIter)
bool bAnchorAttrRestored( false );
if ( SFX_ITEM_SET == m_pOldSet->GetItemState( RES_ANCHOR, FALSE ))
{
- bAnchorAttrRestored = RestoreFlyAnchor( rUndoIter );
+ bAnchorAttrRestored = RestoreFlyAnchor(rContext);
if ( bAnchorAttrRestored )
{
// Anchor attribute successfull restored.
@@ -241,7 +239,7 @@ void SwUndoFmtAttr::Undo( SwUndoIter& rUndoIter)
if ( RES_FLYFRMFMT == m_nFmtWhich || RES_DRAWFRMFMT == m_nFmtWhich )
{
- rUndoIter.pSelFmt = static_cast<SwFrmFmt*>(m_pFmt);
+ rContext.SetSelections(static_cast<SwFrmFmt*>(m_pFmt), 0);
}
}
}
@@ -331,39 +329,41 @@ SwFmt* SwUndoFmtAttr::GetFmt( SwDoc& rDoc )
return m_pFmt && IsFmtInDoc( &rDoc ) ? m_pFmt : 0;
}
-void SwUndoFmtAttr::Redo( SwUndoIter& rUndoIter)
+void SwUndoFmtAttr::RedoImpl(::sw::UndoRedoContext & rContext)
{
// --> OD 2004-10-26 #i35443# - Because the undo stores the attributes for
// redo, the same code as for <Undo(..)> can be applied for <Redo(..)>
- Undo( rUndoIter );
+ UndoImpl(rContext);
// <--
}
-void SwUndoFmtAttr::Repeat( SwUndoIter& rUndoIter)
+void SwUndoFmtAttr::RepeatImpl(::sw::RepeatContext & rContext)
{
if ( !m_pOldSet.get() )
return;
+ SwDoc & rDoc(rContext.GetDoc());
+
switch ( m_nFmtWhich )
{
case RES_GRFFMTCOLL:
{
- SwNoTxtNode * pNd = rUndoIter.pAktPam->GetNode()->GetNoTxtNode();
+ SwNoTxtNode *const pNd =
+ rContext.GetRepeatPaM().GetNode()->GetNoTxtNode();
if( pNd )
{
- rUndoIter.GetDoc().SetAttr( m_pFmt->GetAttrSet(),
- *pNd->GetFmtColl() );
+ rDoc.SetAttr( m_pFmt->GetAttrSet(), *pNd->GetFmtColl() );
}
}
break;
case RES_TXTFMTCOLL:
{
- SwTxtNode * pNd = rUndoIter.pAktPam->GetNode()->GetTxtNode();
+ SwTxtNode *const pNd =
+ rContext.GetRepeatPaM().GetNode()->GetTxtNode();
if( pNd )
{
- rUndoIter.GetDoc().SetAttr( m_pFmt->GetAttrSet(),
- *pNd->GetFmtColl() );
+ rDoc.SetAttr( m_pFmt->GetAttrSet(), *pNd->GetFmtColl() );
}
}
break;
@@ -377,7 +377,8 @@ void SwUndoFmtAttr::Repeat( SwUndoIter& rUndoIter)
// Rahmen steht. Der Weg ist: suche in allen FlyFrmFormaten
// nach dem FlyCntnt-Attribut und teste ob der Cursor in der
// entsprechenden Section liegt.
- SwFrmFmt* pFly = rUndoIter.pAktPam->GetNode()->GetFlyFmt();
+ SwFrmFmt *const pFly =
+ rContext.GetRepeatPaM().GetNode()->GetFlyFmt();
if( pFly )
{
// Bug 43672: es duerfen nicht alle Attribute gesetzt werden!
@@ -387,11 +388,13 @@ void SwUndoFmtAttr::Repeat( SwUndoIter& rUndoIter)
SfxItemSet aTmpSet( m_pFmt->GetAttrSet() );
aTmpSet.ClearItem( RES_CNTNT );
if( aTmpSet.Count() )
- rUndoIter.GetDoc().SetAttr( aTmpSet, *pFly );
+ {
+ rDoc.SetAttr( aTmpSet, *pFly );
+ }
}
else
{
- rUndoIter.GetDoc().SetAttr( m_pFmt->GetAttrSet(), *pFly );
+ rDoc.SetAttr( m_pFmt->GetAttrSet(), *pFly );
}
}
break;
@@ -466,9 +469,9 @@ void SwUndoFmtAttr::SaveFlyAnchor( bool bSvDrwPt )
// Return value indicates, if anchor attribute is restored.
// Note: If anchor attribute is restored, all other existing attributes
// are also restored.
-bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter )
+bool SwUndoFmtAttr::RestoreFlyAnchor(::sw::UndoRedoContext & rContext)
{
- SwDoc* pDoc = &rIter.GetDoc();
+ SwDoc *const pDoc = & rContext.GetDoc();
SwFlyFrmFmt* pFrmFmt = static_cast<SwFlyFrmFmt*>(m_pFmt);
const SwFmtAnchor& rAnchor =
static_cast<const SwFmtAnchor&>( m_pOldSet->Get( RES_ANCHOR, FALSE ) );
@@ -611,7 +614,7 @@ bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter )
if( RES_DRAWFRMFMT != pFrmFmt->Which() )
pFrmFmt->MakeFrms();
- rIter.pSelFmt = pFrmFmt;
+ rContext.SetSelections(pFrmFmt, 0);
// --> OD 2004-10-26 #i35443# - anchor attribute restored.
return true;
@@ -639,7 +642,7 @@ SwUndoFmtResetAttr::~SwUndoFmtResetAttr()
{
}
-void SwUndoFmtResetAttr::Undo( SwUndoIter& )
+void SwUndoFmtResetAttr::UndoImpl(::sw::UndoRedoContext &)
{
if ( m_pOldItem.get() )
{
@@ -647,7 +650,7 @@ void SwUndoFmtResetAttr::Undo( SwUndoIter& )
}
}
-void SwUndoFmtResetAttr::Redo( SwUndoIter& )
+void SwUndoFmtResetAttr::RedoImpl(::sw::UndoRedoContext &)
{
if ( m_pOldItem.get() )
{
@@ -678,10 +681,10 @@ SwUndoResetAttr::~SwUndoResetAttr()
{
}
-void SwUndoResetAttr::Undo( SwUndoIter& rUndoIter )
+void SwUndoResetAttr::UndoImpl(::sw::UndoRedoContext & rContext)
{
// reset old values
- SwDoc& rDoc = rUndoIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
m_pHistory->TmpRollback( &rDoc, 0 );
m_pHistory->SetTmpEnd( m_pHistory->Count() );
@@ -696,27 +699,25 @@ void SwUndoResetAttr::Undo( SwUndoIter& rUndoIter )
}
}
- // setze noch den Cursor auf den Undo-Bereich
- SetPaM( rUndoIter );
+ AddUndoRedoPaM(rContext);
}
-void SwUndoResetAttr::Redo( SwUndoIter& rUndoIter )
+void SwUndoResetAttr::RedoImpl(::sw::UndoRedoContext & rContext)
{
- // setze Attribut in dem Bereich:
- SetPaM( rUndoIter );
- SwDoc& rDoc = rUndoIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
+ SwPaM & rPam = AddUndoRedoPaM(rContext);
SvUShortsSort* pIdArr = m_Ids.Count() ? &m_Ids : 0;
switch ( m_nFormatId )
{
case RES_CHRFMT:
- rUndoIter.GetDoc().RstTxtAttrs( *rUndoIter.pAktPam );
+ rDoc.RstTxtAttrs(rPam);
break;
case RES_TXTFMTCOLL:
- rUndoIter.GetDoc().ResetAttrs( *rUndoIter.pAktPam, FALSE, pIdArr );
+ rDoc.ResetAttrs(rPam, FALSE, pIdArr );
break;
case RES_CONDTXTFMTCOLL:
- rUndoIter.GetDoc().ResetAttrs( *rUndoIter.pAktPam, TRUE, pIdArr );
+ rDoc.ResetAttrs(rPam, TRUE, pIdArr );
break;
case RES_TXTATR_TOXMARK:
@@ -760,7 +761,7 @@ void SwUndoResetAttr::Redo( SwUndoIter& rUndoIter )
}
}
-void SwUndoResetAttr::Repeat( SwUndoIter& rUndoIter )
+void SwUndoResetAttr::RepeatImpl(::sw::RepeatContext & rContext)
{
if (m_nFormatId < RES_FMT_BEGIN)
{
@@ -771,13 +772,13 @@ void SwUndoResetAttr::Repeat( SwUndoIter& rUndoIter )
switch ( m_nFormatId )
{
case RES_CHRFMT:
- rUndoIter.GetDoc().RstTxtAttrs( *rUndoIter.pAktPam );
+ rContext.GetDoc().RstTxtAttrs(rContext.GetRepeatPaM());
break;
case RES_TXTFMTCOLL:
- rUndoIter.GetDoc().ResetAttrs( *rUndoIter.pAktPam, FALSE, pIdArr );
+ rContext.GetDoc().ResetAttrs(rContext.GetRepeatPaM(), false, pIdArr);
break;
case RES_CONDTXTFMTCOLL:
- rUndoIter.GetDoc().ResetAttrs( *rUndoIter.pAktPam, TRUE, pIdArr );
+ rContext.GetDoc().ResetAttrs(rContext.GetRepeatPaM(), true, pIdArr);
break;
}
}
@@ -848,29 +849,29 @@ void SwUndoAttr::SaveRedlineData( const SwPaM& rPam, BOOL bIsCntnt )
}
}
-void SwUndoAttr::Undo( SwUndoIter& rUndoIter )
+void SwUndoAttr::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc* pDoc = &rUndoIter.GetDoc();
+ SwDoc *const pDoc = & rContext.GetDoc();
RemoveIdx( *pDoc );
if( IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() ) )
{
- SwPaM& rPam = *rUndoIter.pAktPam;
+ SwPaM aPam(pDoc->GetNodes().GetEndOfContent());
if ( ULONG_MAX != m_nNodeIndex )
{
- rPam.DeleteMark();
- rPam.GetPoint()->nNode = m_nNodeIndex;
- rPam.GetPoint()->nContent.Assign( rPam.GetCntntNode(), nSttCntnt );
- rPam.SetMark();
- rPam.GetPoint()->nContent++;
- pDoc->DeleteRedline( rPam, false, USHRT_MAX );
+ aPam.DeleteMark();
+ aPam.GetPoint()->nNode = m_nNodeIndex;
+ aPam.GetPoint()->nContent.Assign( aPam.GetCntntNode(), nSttCntnt );
+ aPam.SetMark();
+ aPam.GetPoint()->nContent++;
+ pDoc->DeleteRedline(aPam, false, USHRT_MAX);
}
else
{
// alle Format-Redlines entfernen, werden ggfs. neu gesetzt
- SetPaM( rUndoIter );
- pDoc->DeleteRedline( rPam, false, nsRedlineType_t::REDLINE_FORMAT );
+ SetPaM(aPam);
+ pDoc->DeleteRedline(aPam, false, nsRedlineType_t::REDLINE_FORMAT);
if ( m_pRedlineSaveData.get() )
{
SetSaveData( *pDoc, *m_pRedlineSaveData );
@@ -887,32 +888,30 @@ void SwUndoAttr::Undo( SwUndoIter& rUndoIter )
m_pHistory->SetTmpEnd( m_pHistory->Count() );
// set cursor onto Undo area
- SetPaM( rUndoIter );
+ AddUndoRedoPaM(rContext);
}
-void SwUndoAttr::Repeat( SwUndoIter& rUndoIter )
+void SwUndoAttr::RepeatImpl(::sw::RepeatContext & rContext)
{
// RefMarks are not repeat capable
if ( SFX_ITEM_SET != m_AttrSet.GetItemState( RES_TXTATR_REFMARK, FALSE ) )
{
- rUndoIter.GetDoc().InsertItemSet( *rUndoIter.pAktPam,
+ rContext.GetDoc().InsertItemSet( rContext.GetRepeatPaM(),
m_AttrSet, m_nInsertFlags );
}
else if ( 1 < m_AttrSet.Count() )
{
SfxItemSet aTmpSet( m_AttrSet );
aTmpSet.ClearItem( RES_TXTATR_REFMARK );
- rUndoIter.GetDoc().InsertItemSet( *rUndoIter.pAktPam,
+ rContext.GetDoc().InsertItemSet( rContext.GetRepeatPaM(),
aTmpSet, m_nInsertFlags );
}
}
-void SwUndoAttr::Redo( SwUndoIter& rUndoIter )
+void SwUndoAttr::RedoImpl(::sw::UndoRedoContext & rContext)
{
- // setze Attribut in dem Bereich:
- SetPaM( rUndoIter );
- SwPaM& rPam = *rUndoIter.pAktPam;
- SwDoc& rDoc = rUndoIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
+ SwPaM & rPam = AddUndoRedoPaM(rContext);
if ( m_pRedlineData.get() &&
IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() ) )
@@ -1042,9 +1041,9 @@ SwUndoDefaultAttr::~SwUndoDefaultAttr()
{
}
-void SwUndoDefaultAttr::Undo( SwUndoIter& rUndoIter)
+void SwUndoDefaultAttr::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc& rDoc = rUndoIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
if ( m_pOldSet.get() )
{
SwUndoFmtAttrHelper aTmp(
@@ -1066,9 +1065,9 @@ void SwUndoDefaultAttr::Undo( SwUndoIter& rUndoIter)
}
}
-void SwUndoDefaultAttr::Redo( SwUndoIter& rUndoIter)
+void SwUndoDefaultAttr::RedoImpl(::sw::UndoRedoContext & rContext)
{
- Undo( rUndoIter );
+ UndoImpl(rContext);
}
// -----------------------------------------------------
@@ -1086,29 +1085,30 @@ SwUndoMoveLeftMargin::~SwUndoMoveLeftMargin()
{
}
-void SwUndoMoveLeftMargin::Undo( SwUndoIter& rIter )
+void SwUndoMoveLeftMargin::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc* pDoc = &rIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
// restore old values
- m_pHistory->TmpRollback( pDoc, 0 );
+ m_pHistory->TmpRollback( & rDoc, 0 );
m_pHistory->SetTmpEnd( m_pHistory->Count() );
- SetPaM( rIter );
+ AddUndoRedoPaM(rContext);
}
-void SwUndoMoveLeftMargin::Redo( SwUndoIter& rIter )
+void SwUndoMoveLeftMargin::RedoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc* pDoc = &rIter.GetDoc();
- SetPaM( rIter );
- pDoc->MoveLeftMargin( *rIter.pAktPam, GetId() == UNDO_INC_LEFTMARGIN,
- m_bModulus );
+ SwDoc & rDoc = rContext.GetDoc();
+ SwPaM & rPam = AddUndoRedoPaM(rContext);
+
+ rDoc.MoveLeftMargin( rPam,
+ GetId() == UNDO_INC_LEFTMARGIN, m_bModulus );
}
-void SwUndoMoveLeftMargin::Repeat( SwUndoIter& rIter )
+void SwUndoMoveLeftMargin::RepeatImpl(::sw::RepeatContext & rContext)
{
- SwDoc* pDoc = &rIter.GetDoc();
- pDoc->MoveLeftMargin( *rIter.pAktPam, GetId() == UNDO_INC_LEFTMARGIN,
+ SwDoc & rDoc = rContext.GetDoc();
+ rDoc.MoveLeftMargin(rContext.GetRepeatPaM(), GetId() == UNDO_INC_LEFTMARGIN,
m_bModulus );
}
@@ -1129,30 +1129,30 @@ SwUndoChangeFootNote::~SwUndoChangeFootNote()
{
}
-void SwUndoChangeFootNote::Undo( SwUndoIter& rIter )
+void SwUndoChangeFootNote::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc& rDoc = rIter.GetDoc();
- SetPaM( rIter );
+ SwDoc & rDoc = rContext.GetDoc();
m_pHistory->TmpRollback( &rDoc, 0 );
m_pHistory->SetTmpEnd( m_pHistory->Count() );
rDoc.GetFtnIdxs().UpdateAllFtn();
- SetPaM( rIter );
+ AddUndoRedoPaM(rContext);
}
-void SwUndoChangeFootNote::Redo( SwUndoIter& rIter )
+void SwUndoChangeFootNote::RedoImpl(::sw::UndoRedoContext & rContext)
{
- SetPaM( rIter );
- rIter.GetDoc().SetCurFtn( *rIter.pAktPam, m_Text, m_nNumber, m_bEndNote );
- SetPaM( rIter );
+ SwDoc & rDoc( rContext.GetDoc() );
+ SwPaM & rPaM = AddUndoRedoPaM(rContext);
+ rDoc.SetCurFtn(rPaM, m_Text, m_nNumber, m_bEndNote);
+ SetPaM(rPaM);
}
-void SwUndoChangeFootNote::Repeat( SwUndoIter& rIter )
+void SwUndoChangeFootNote::RepeatImpl(::sw::RepeatContext & rContext)
{
- SwDoc& rDoc = rIter.GetDoc();
- rDoc.SetCurFtn( *rIter.pAktPam, m_Text, m_nNumber, m_bEndNote );
+ SwDoc & rDoc = rContext.GetDoc();
+ rDoc.SetCurFtn( rContext.GetRepeatPaM(), m_Text, m_nNumber, m_bEndNote );
}
@@ -1169,17 +1169,17 @@ SwUndoFootNoteInfo::~SwUndoFootNoteInfo()
{
}
-void SwUndoFootNoteInfo::Undo( SwUndoIter &rIter )
+void SwUndoFootNoteInfo::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc &rDoc = rIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
SwFtnInfo *pInf = new SwFtnInfo( rDoc.GetFtnInfo() );
rDoc.SetFtnInfo( *m_pFootNoteInfo );
m_pFootNoteInfo.reset( pInf );
}
-void SwUndoFootNoteInfo::Redo( SwUndoIter &rIter )
+void SwUndoFootNoteInfo::RedoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc &rDoc = rIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
SwFtnInfo *pInf = new SwFtnInfo( rDoc.GetFtnInfo() );
rDoc.SetFtnInfo( *m_pFootNoteInfo );
m_pFootNoteInfo.reset( pInf );
@@ -1198,17 +1198,17 @@ SwUndoEndNoteInfo::~SwUndoEndNoteInfo()
{
}
-void SwUndoEndNoteInfo::Undo( SwUndoIter &rIter )
+void SwUndoEndNoteInfo::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc &rDoc = rIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
SwEndNoteInfo *pInf = new SwEndNoteInfo( rDoc.GetEndNoteInfo() );
rDoc.SetEndNoteInfo( *m_pEndNoteInfo );
m_pEndNoteInfo.reset( pInf );
}
-void SwUndoEndNoteInfo::Redo( SwUndoIter &rIter )
+void SwUndoEndNoteInfo::RedoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc &rDoc = rIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
SwEndNoteInfo *pInf = new SwEndNoteInfo( rDoc.GetEndNoteInfo() );
rDoc.SetEndNoteInfo( *m_pEndNoteInfo );
m_pEndNoteInfo.reset( pInf );
@@ -1223,10 +1223,10 @@ SwUndoDontExpandFmt::SwUndoDontExpandFmt( const SwPosition& rPos )
{
}
-void SwUndoDontExpandFmt::Undo( SwUndoIter& rIter )
+void SwUndoDontExpandFmt::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwPaM* pPam = rIter.pAktPam;
- SwDoc* pDoc = pPam->GetDoc();
+ SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
+ SwDoc *const pDoc = & rContext.GetDoc();
SwPosition& rPos = *pPam->GetPoint();
rPos.nNode = m_nNodeIndex;
@@ -1235,10 +1235,10 @@ void SwUndoDontExpandFmt::Undo( SwUndoIter& rIter )
}
-void SwUndoDontExpandFmt::Redo( SwUndoIter& rIter )
+void SwUndoDontExpandFmt::RedoImpl(::sw::UndoRedoContext & rContext)
{
- SwPaM* pPam = rIter.pAktPam;
- SwDoc* pDoc = pPam->GetDoc();
+ SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
+ SwDoc *const pDoc = & rContext.GetDoc();
SwPosition& rPos = *pPam->GetPoint();
rPos.nNode = m_nNodeIndex;
@@ -1246,10 +1246,10 @@ void SwUndoDontExpandFmt::Redo( SwUndoIter& rIter )
pDoc->DontExpandFmt( rPos );
}
-void SwUndoDontExpandFmt::Repeat( SwUndoIter& rIter )
+void SwUndoDontExpandFmt::RepeatImpl(::sw::RepeatContext & rContext)
{
- SwPaM* pPam = rIter.pAktPam;
- SwDoc* pDoc = pPam->GetDoc();
- pDoc->DontExpandFmt( *pPam->GetPoint() );
+ SwPaM & rPam = rContext.GetRepeatPaM();
+ SwDoc & rDoc = rContext.GetDoc();
+ rDoc.DontExpandFmt( *rPam.GetPoint() );
}
diff --git a/sw/source/core/undo/unbkmk.cxx b/sw/source/core/undo/unbkmk.cxx
index b86bdad692ac..e433ed72a315 100644
--- a/sw/source/core/undo/unbkmk.cxx
+++ b/sw/source/core/undo/unbkmk.cxx
@@ -41,9 +41,6 @@
#include "SwRewriter.hxx"
-inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); }
-
-
SwUndoBookmark::SwUndoBookmark( SwUndoId nUndoId,
const ::sw::mark::IMark& rBkmk )
: SwUndo( nUndoId )
@@ -60,7 +57,6 @@ void SwUndoBookmark::SetInDoc( SwDoc* pDoc )
m_pHistoryBookmark->SetInDoc( pDoc, false );
}
-
void SwUndoBookmark::ResetInDoc( SwDoc* pDoc )
{
IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess();
@@ -95,15 +91,13 @@ SwUndoInsBookmark::SwUndoInsBookmark( const ::sw::mark::IMark& rBkmk )
}
-void SwUndoInsBookmark::Undo( SwUndoIter& rUndoIter )
+void SwUndoInsBookmark::UndoImpl(::sw::UndoRedoContext & rContext)
{
- ResetInDoc( &rUndoIter.GetDoc() );
+ ResetInDoc( &rContext.GetDoc() );
}
-
-void SwUndoInsBookmark::Redo( SwUndoIter& rUndoIter )
+void SwUndoInsBookmark::RedoImpl(::sw::UndoRedoContext & rContext)
{
- SetInDoc( &rUndoIter.GetDoc() );
+ SetInDoc( &rContext.GetDoc() );
}
-
diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx
index db51feb5d138..680660de4353 100644
--- a/sw/source/core/undo/undel.cxx
+++ b/sw/source/core/undo/undel.cxx
@@ -61,8 +61,6 @@
// using namespace comphelper;
-inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); }
-
// DELETE
/* lcl_MakeAutoFrms has to call MakeFrms for objects bounded "AtChar" ( == AUTO ),
@@ -643,9 +641,9 @@ void lcl_ReAnchorAtCntntFlyFrames( const SwSpzFrmFmts& rSpzArr, SwPosition &rPos
}
}
-void SwUndoDelete::Undo( SwUndoIter& rUndoIter )
+void SwUndoDelete::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc* pDoc = &rUndoIter.GetDoc();
+ SwDoc *const pDoc = & rContext.GetDoc();
ULONG nCalcStt = nSttNode - nNdDiff;
@@ -846,16 +844,14 @@ void SwUndoDelete::Undo( SwUndoIter& rUndoIter )
if( pRedlSaveData )
SetSaveData( *pDoc, *pRedlSaveData );
- SetPaM( rUndoIter, TRUE );
+ AddUndoRedoPaM(rContext, true);
}
-void SwUndoDelete::Redo( SwUndoIter& rUndoIter )
+void SwUndoDelete::RedoImpl(::sw::UndoRedoContext & rContext)
{
- SwPaM& rPam = *rUndoIter.pAktPam;
+ SwPaM & rPam = AddUndoRedoPaM(rContext);
SwDoc& rDoc = *rPam.GetDoc();
- SetPaM( rPam );
-
if( pRedlSaveData )
{
bool bSuccess = FillSaveData(rPam, *pRedlSaveData, TRUE);
@@ -970,14 +966,14 @@ void SwUndoDelete::Redo( SwUndoIter& rUndoIter )
rDoc.DeleteAndJoin( rPam );
}
-void SwUndoDelete::Repeat( SwUndoIter& rUndoIter )
+void SwUndoDelete::RepeatImpl(::sw::RepeatContext & rContext)
{
// this action does not seem idempotent,
// so make sure it is only executed once on repeat
- if (rUndoIter.m_bDeleteRepeated)
+ if (rContext.m_bDeleteRepeated)
return;
- SwPaM& rPam = *rUndoIter.pAktPam;
+ SwPaM & rPam = rContext.GetRepeatPaM();
SwDoc& rDoc = *rPam.GetDoc();
::sw::GroupUndoGuard const undoGuard(rDoc.GetIDocumentUndoRedo());
if( !rPam.HasMark() )
@@ -989,7 +985,7 @@ void SwUndoDelete::Repeat( SwUndoIter& rUndoIter )
rDoc.DelFullPara( rPam );
else
rDoc.DeleteAndJoin( rPam );
- rUndoIter.m_bDeleteRepeated = true;
+ rContext.m_bDeleteRepeated = true;
}
diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx
index dfb2fe8b7be6..144b15c6b725 100644
--- a/sw/source/core/undo/undobj.cxx
+++ b/sw/source/core/undo/undobj.cxx
@@ -29,6 +29,7 @@
#include "precompiled_sw.hxx"
+#include <IShellCursorSupplier.hxx>
#include <txtftn.hxx>
#include <fmtanchr.hxx>
#include <ftnidx.hxx>
@@ -70,17 +71,6 @@ public:
SV_IMPL_PTRARR( SwUndos, SwUndo*)
SV_IMPL_PTRARR( SwRedlineSaveDatas, SwRedlineSaveDataPtr )
-SwUndoIter::SwUndoIter( SwPaM* pPam, SwUndoId nId )
- : m_bDeleteRepeated(false)
-{
- nUndoId = nId;
- bWeiter = nId ? TRUE : FALSE;
- pAktPam = pPam;
- nEndCnt = 0;
- pSelFmt = 0;
- pMarkList = 0;
-}
-inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); }
//------------------------------------------------------------
@@ -144,12 +134,15 @@ void SwUndRng::SetPaM( SwPaM & rPam, BOOL bCorrToCntnt ) const
rPam.GetPoint()->nContent.Assign( 0, 0 );
}
-void SwUndRng::SetPaM( SwUndoIter& rIter, BOOL bCorrToCntnt ) const
+SwPaM & SwUndRng::AddUndoRedoPaM(
+ ::sw::UndoRedoContext & rContext, bool bCorrToCntnt) const
{
- if( rIter.pAktPam )
- SetPaM( *rIter.pAktPam, bCorrToCntnt );
+ SwPaM & rPaM( rContext.GetCursorSupplier().CreateNewShellCursor() );
+ SetPaM( rPaM, bCorrToCntnt );
+ return rPaM;
}
+
//------------------------------------------------------------
@@ -215,8 +208,89 @@ SwUndo::~SwUndo()
delete pComment;
}
-void SwUndo::Repeat( SwUndoIter & )
+
+class UndoRedoRedlineGuard
{
+public:
+ UndoRedoRedlineGuard(::sw::UndoRedoContext & rContext, SwUndo & rUndo)
+ : m_rRedlineAccess(rContext.GetDoc())
+ , m_eMode(m_rRedlineAccess.GetRedlineMode())
+ {
+ RedlineMode_t const eTmpMode =
+ static_cast<RedlineMode_t>(rUndo.GetRedlineMode());
+ if ((nsRedlineMode_t::REDLINE_SHOW_MASK & eTmpMode) !=
+ (nsRedlineMode_t::REDLINE_SHOW_MASK & m_eMode))
+ {
+ m_rRedlineAccess.SetRedlineMode( eTmpMode );
+ }
+ m_rRedlineAccess.SetRedlineMode_intern( static_cast<RedlineMode_t>(
+ eTmpMode | nsRedlineMode_t::REDLINE_IGNORE) );
+ }
+ ~UndoRedoRedlineGuard()
+ {
+ m_rRedlineAccess.SetRedlineMode(m_eMode);
+ }
+private:
+ IDocumentRedlineAccess & m_rRedlineAccess;
+ RedlineMode_t const m_eMode;
+};
+
+void SwUndo::Undo()
+{
+ OSL_ENSURE(false, "SwUndo::Undo(): ERROR: must call Undo(context) instead");
+}
+
+void SwUndo::Redo()
+{
+ OSL_ENSURE(false, "SwUndo::Redo(): ERROR: must call Redo(context) instead");
+}
+
+void SwUndo::UndoWithContext(SfxUndoContext & rContext)
+{
+ ::sw::UndoRedoContext *const pContext(
+ dynamic_cast< ::sw::UndoRedoContext * >(& rContext));
+ OSL_ASSERT(pContext);
+ if (!pContext) { return; }
+ UndoRedoRedlineGuard(*pContext, *this);
+ UndoImpl(*pContext);
+}
+
+void SwUndo::RedoWithContext(SfxUndoContext & rContext)
+{
+ ::sw::UndoRedoContext *const pContext(
+ dynamic_cast< ::sw::UndoRedoContext * >(& rContext));
+ OSL_ASSERT(pContext);
+ if (!pContext) { return; }
+ UndoRedoRedlineGuard(*pContext, *this);
+ RedoImpl(*pContext);
+}
+
+void SwUndo::Repeat(SfxRepeatTarget & rContext)
+{
+ ::sw::RepeatContext *const pRepeatContext(
+ dynamic_cast< ::sw::RepeatContext * >(& rContext));
+ OSL_ASSERT(pRepeatContext);
+ if (!pRepeatContext) { return; }
+ RepeatImpl(*pRepeatContext);
+}
+
+BOOL SwUndo::CanRepeat(SfxRepeatTarget & rContext) const
+{
+ ::sw::RepeatContext *const pRepeatContext(
+ dynamic_cast< ::sw::RepeatContext * >(& rContext));
+ OSL_ASSERT(pRepeatContext);
+ if (!pRepeatContext) { return false; }
+ return CanRepeatImpl(*pRepeatContext);
+}
+
+void SwUndo::RepeatImpl( ::sw::RepeatContext & )
+{
+}
+
+bool SwUndo::CanRepeatImpl( ::sw::RepeatContext & ) const
+{
+// return false;
+ return ((REPEAT_START <= GetId()) && (GetId() < REPEAT_END));
}
String SwUndo::GetComment() const
@@ -248,11 +322,6 @@ String SwUndo::GetComment() const
return aResult;
}
-SwUndoId SwUndo::GetEffectiveId() const
-{
- return GetId();
-}
-
SwRewriter SwUndo::GetRewriter() const
{
SwRewriter aResult;
@@ -260,6 +329,7 @@ SwRewriter SwUndo::GetRewriter() const
return aResult;
}
+
//------------------------------------------------------------
SwUndoSaveCntnt::SwUndoSaveCntnt()
@@ -905,92 +975,6 @@ void SwUndoSaveSection::RestoreSection( SwDoc* pDoc, const SwNodeIndex& rInsPos
}
}
-// START
-SwUndoStart::SwUndoStart( SwUndoId nInitId )
- : SwUndo( UNDO_START ), nUserId( nInitId ), nEndOffset( 0 )
-{
-}
-
-void SwUndoStart::Undo( SwUndoIter& rUndoIter )
-{
- if( !( --rUndoIter.nEndCnt ) && rUndoIter.bWeiter &&
- ( rUndoIter.GetId() ? ( rUndoIter.GetId() == nUserId ||
- ( UNDO_END == rUndoIter.GetId() && UNDO_START == GetId() )) : TRUE ))
- rUndoIter.bWeiter = FALSE;
-}
-
-void SwUndoStart::Redo( SwUndoIter& rUndoIter )
-{
- rUndoIter.bWeiter = TRUE;
- ++rUndoIter.nEndCnt;
-}
-
-void SwUndoStart::Repeat( SwUndoIter& rUndoIter )
-{
- rUndoIter.bWeiter = FALSE;
-}
-
-String SwUndoStart::GetComment() const
-{
- OSL_ASSERT(pComment);
- return (pComment) ? *pComment : String("??", RTL_TEXTENCODING_ASCII_US);
-}
-
-void SwUndoStart::SetComment(String const& rComment)
-{
- pComment = new String(rComment);
-}
-
-SwUndoId SwUndoStart::GetEffectiveId() const
-{
- return GetUserId();
-}
-
-
-// END
-SwUndoEnd::SwUndoEnd( SwUndoId nInitId )
- : SwUndo( UNDO_END ), nUserId( nInitId ), nSttOffset( 0 )
-{
-}
-
-void SwUndoEnd::Undo( SwUndoIter& rUndoIter )
-{
- if( rUndoIter.GetId() == GetId() || !rUndoIter.GetId() )
- rUndoIter.bWeiter = TRUE;
- if( rUndoIter.bWeiter )
- ++rUndoIter.nEndCnt;
-}
-
-void SwUndoEnd::Redo( SwUndoIter& rUndoIter )
-{
- if( !( --rUndoIter.nEndCnt ) && rUndoIter.bWeiter &&
- ( rUndoIter.GetId() ? ( rUndoIter.GetId() == nUserId ||
- ( UNDO_END == rUndoIter.GetId() && UNDO_START == GetId() )) : TRUE ))
- rUndoIter.bWeiter = FALSE;
-}
-
-void SwUndoEnd::Repeat( SwUndoIter& rUndoIter )
-{
- rUndoIter.bWeiter = FALSE;
-}
-
-String SwUndoEnd::GetComment() const
-{
- OSL_ASSERT(pComment);
- return (pComment) ? *pComment : String("??", RTL_TEXTENCODING_ASCII_US);
-}
-
-void SwUndoEnd::SetComment(String const& rComment)
-{
- pComment = new String(rComment);
-}
-
-SwUndoId SwUndoEnd::GetEffectiveId() const
-{
- return GetUserId();
-}
-
-/* */
// sicher und setze die RedlineDaten
SwRedlineSaveData::SwRedlineSaveData( SwComparePosition eCmpPos,
diff --git a/sw/source/core/undo/undobj1.cxx b/sw/source/core/undo/undobj1.cxx
index 42b1944d1139..a6050354545e 100644
--- a/sw/source/core/undo/undobj1.cxx
+++ b/sw/source/core/undo/undobj1.cxx
@@ -49,10 +49,9 @@
#include <dcontact.hxx>
#include <ndole.hxx>
-// Inline Methode vom UndoIter
-inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); }
//---------------------------------------------------------------------
+// SwUndoLayBase /////////////////////////////////////////////////////////
SwUndoFlyBase::SwUndoFlyBase( SwFrmFmt* pFormat, SwUndoId nUndoId )
: SwUndo( nUndoId ), pFrmFmt( pFormat )
@@ -65,9 +64,9 @@ SwUndoFlyBase::~SwUndoFlyBase()
delete pFrmFmt;
}
-void SwUndoFlyBase::InsFly( SwUndoIter& rUndoIter, BOOL bShowSelFrm )
+void SwUndoFlyBase::InsFly(::sw::UndoRedoContext & rContext, bool bShowSelFrm)
{
- SwDoc* pDoc = &rUndoIter.GetDoc();
+ SwDoc *const pDoc = & rContext.GetDoc();
// ins Array wieder eintragen
SwSpzFrmFmts& rFlyFmts = *(SwSpzFrmFmts*)pDoc->GetSpzFrmFmts();
@@ -96,7 +95,7 @@ void SwUndoFlyBase::InsFly( SwUndoIter& rUndoIter, BOOL bShowSelFrm )
}
else
{
- SwPosition aNewPos( *rUndoIter.pAktPam->GetPoint() );
+ SwPosition aNewPos(pDoc->GetNodes().GetEndOfContent());
aNewPos.nNode = nNdPgPos;
if ((FLY_AS_CHAR == nRndId) || (FLY_AT_CHAR == nRndId))
{
@@ -132,7 +131,9 @@ void SwUndoFlyBase::InsFly( SwUndoIter& rUndoIter, BOOL bShowSelFrm )
pFrmFmt->MakeFrms();
if( bShowSelFrm )
- rUndoIter.pSelFmt = pFrmFmt;
+ {
+ rContext.SetSelections(pFrmFmt, 0);
+ }
if( GetHistory() )
GetHistory()->Rollback( pDoc );
@@ -234,7 +235,7 @@ void SwUndoFlyBase::DelFly( SwDoc* pDoc )
rFlyFmts.Remove( rFlyFmts.GetPos( pFrmFmt ));
}
-// ----- Undo-InsertFly ------
+// SwUndoInsLayFmt ///////////////////////////////////////////////////////
SwUndoInsLayFmt::SwUndoInsLayFmt( SwFrmFmt* pFormat, ULONG nNodeIdx, xub_StrLen nCntIdx )
: SwUndoFlyBase( pFormat, RES_DRAWFRMFMT == pFormat->Which() ?
@@ -270,47 +271,52 @@ SwUndoInsLayFmt::~SwUndoInsLayFmt()
{
}
-void SwUndoInsLayFmt::Undo( SwUndoIter& rUndoIter )
+void SwUndoInsLayFmt::UndoImpl(::sw::UndoRedoContext & rContext)
{
+ SwDoc & rDoc(rContext.GetDoc());
const SwFmtCntnt& rCntnt = pFrmFmt->GetCntnt();
if( rCntnt.GetCntntIdx() ) // kein Inhalt
{
bool bRemoveIdx = true;
if( mnCrsrSaveIndexPara > 0 )
{
- SwTxtNode *pNode = rUndoIter.GetDoc().GetNodes()[mnCrsrSaveIndexPara]->GetTxtNode();
+ SwTxtNode *const pNode =
+ rDoc.GetNodes()[mnCrsrSaveIndexPara]->GetTxtNode();
if( pNode )
{
- SwNodeIndex aIdx( rUndoIter.GetDoc().GetNodes(), rCntnt.GetCntntIdx()->GetIndex() );
- SwNodeIndex aEndIdx( rUndoIter.GetDoc().GetNodes(), aIdx.GetNode().EndOfSectionIndex() );
+ SwNodeIndex aIdx( rDoc.GetNodes(),
+ rCntnt.GetCntntIdx()->GetIndex() );
+ SwNodeIndex aEndIdx( rDoc.GetNodes(),
+ aIdx.GetNode().EndOfSectionIndex() );
SwIndex aIndex( pNode, mnCrsrSaveIndexPos );
SwPosition aPos( *pNode, aIndex );
- rUndoIter.GetDoc().CorrAbs( aIdx, aEndIdx, aPos, TRUE );
+ rDoc.CorrAbs( aIdx, aEndIdx, aPos, TRUE );
bRemoveIdx = false;
}
}
if( bRemoveIdx )
- RemoveIdxFromSection( rUndoIter.GetDoc(),
- rCntnt.GetCntntIdx()->GetIndex() );
+ {
+ RemoveIdxFromSection( rDoc, rCntnt.GetCntntIdx()->GetIndex() );
+ }
}
- DelFly( &rUndoIter.GetDoc() );
+ DelFly(& rDoc);
}
-void SwUndoInsLayFmt::Redo( SwUndoIter& rUndoIter )
+void SwUndoInsLayFmt::RedoImpl(::sw::UndoRedoContext & rContext)
{
- InsFly( rUndoIter );
+ InsFly(rContext);
}
-void SwUndoInsLayFmt::Repeat( SwUndoIter& rUndoIter )
+void SwUndoInsLayFmt::RepeatImpl(::sw::RepeatContext & rContext)
{
- SwDoc* pDoc = &rUndoIter.GetDoc();
+ SwDoc *const pDoc = & rContext.GetDoc();
// erfrage und setze den Anker neu
SwFmtAnchor aAnchor( pFrmFmt->GetAnchor() );
if ((FLY_AT_PARA == aAnchor.GetAnchorId()) ||
(FLY_AT_CHAR == aAnchor.GetAnchorId()) ||
(FLY_AS_CHAR == aAnchor.GetAnchorId()))
{
- SwPosition aPos( *rUndoIter.pAktPam->GetPoint() );
+ SwPosition aPos( *rContext.GetRepeatPaM().GetPoint() );
if (FLY_AT_PARA == aAnchor.GetAnchorId())
{
aPos.nContent.Assign( 0, 0 );
@@ -319,7 +325,8 @@ void SwUndoInsLayFmt::Repeat( SwUndoIter& rUndoIter )
}
else if( FLY_AT_FLY == aAnchor.GetAnchorId() )
{
- const SwStartNode* pSttNd = rUndoIter.pAktPam->GetNode()->FindFlyStartNode();
+ SwStartNode const*const pSttNd =
+ rContext.GetRepeatPaM().GetNode()->FindFlyStartNode();
if( pSttNd )
{
SwPosition aPos( *pSttNd );
@@ -332,15 +339,17 @@ void SwUndoInsLayFmt::Repeat( SwUndoIter& rUndoIter )
}
else if (FLY_AT_PAGE == aAnchor.GetAnchorId())
{
- aAnchor.SetPageNum( pDoc->GetRootFrm()->GetCurrPage(
- rUndoIter.pAktPam ));
+ aAnchor.SetPageNum(
+ pDoc->GetRootFrm()->GetCurrPage(& rContext.GetRepeatPaM()) );
}
else {
ASSERT( FALSE, "was fuer ein Anker ist es denn nun?" );
}
SwFrmFmt* pFlyFmt = pDoc->CopyLayoutFmt( *pFrmFmt, aAnchor, true, true );
- rUndoIter.pSelFmt = pFlyFmt;
+ (void) pFlyFmt;
+//FIXME nobody ever did anything with this selection:
+// rContext.SetSelections(pFlyFmt, 0);
}
// #111827#
@@ -375,7 +384,7 @@ String SwUndoInsLayFmt::GetComment() const
return aResult;
}
-// ----- Undo-DeleteFly ------
+// SwUndoDelLayFmt ///////////////////////////////////////////////////////
static SwUndoId
lcl_GetSwUndoId(SwFrmFmt *const pFrmFmt)
@@ -433,22 +442,24 @@ SwRewriter SwUndoDelLayFmt::GetRewriter() const
return aRewriter;
}
-void SwUndoDelLayFmt::Undo( SwUndoIter& rUndoIter )
+void SwUndoDelLayFmt::UndoImpl(::sw::UndoRedoContext & rContext)
{
- InsFly( rUndoIter, bShowSelFrm );
+ InsFly( rContext, bShowSelFrm );
}
-void SwUndoDelLayFmt::Redo( SwUndoIter& rUndoIter )
+void SwUndoDelLayFmt::RedoImpl(::sw::UndoRedoContext & rContext)
{
+ SwDoc & rDoc(rContext.GetDoc());
const SwFmtCntnt& rCntnt = pFrmFmt->GetCntnt();
if( rCntnt.GetCntntIdx() ) // kein Inhalt
- RemoveIdxFromSection( rUndoIter.GetDoc(),
- rCntnt.GetCntntIdx()->GetIndex() );
+ {
+ RemoveIdxFromSection(rDoc, rCntnt.GetCntntIdx()->GetIndex());
+ }
- DelFly( &rUndoIter.GetDoc() );
+ DelFly(& rDoc);
}
-void SwUndoDelLayFmt::Redo()
+void SwUndoDelLayFmt::RedoForRollback()
{
const SwFmtCntnt& rCntnt = pFrmFmt->GetCntnt();
if( rCntnt.GetCntntIdx() ) // kein Inhalt
@@ -458,7 +469,7 @@ void SwUndoDelLayFmt::Redo()
DelFly( pFrmFmt->GetDoc() );
}
-/* */
+// SwUndoSetFlyFmt ///////////////////////////////////////////////////////
SwUndoSetFlyFmt::SwUndoSetFlyFmt( SwFrmFmt& rFlyFmt, SwFrmFmt& rNewFrmFmt )
: SwUndo( UNDO_SETFLYFRMFMT ), SwClient( &rFlyFmt ), pFrmFmt( &rFlyFmt ),
@@ -534,9 +545,9 @@ void SwUndoSetFlyFmt::GetAnchor( SwFmtAnchor& rAnchor,
rAnchor.SetPageNum( nCntnt );
}
-void SwUndoSetFlyFmt::Undo( SwUndoIter& rIter )
+void SwUndoSetFlyFmt::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc& rDoc = rIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
// ist das neue Format noch vorhanden ??
if( USHRT_MAX != rDoc.GetFrmFmts()->GetPos( (const SwFrmFmtPtr)pOldFmt ) )
@@ -604,13 +615,13 @@ void SwUndoSetFlyFmt::Undo( SwUndoIter& rIter )
pFrmFmt->MakeFrms();
}
- rIter.pSelFmt = pFrmFmt;
+ rContext.SetSelections(pFrmFmt, 0);
}
}
-void SwUndoSetFlyFmt::Redo( SwUndoIter& rIter )
+void SwUndoSetFlyFmt::RedoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc& rDoc = rIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
// ist das neue Format noch vorhanden ??
if( USHRT_MAX != rDoc.GetFrmFmts()->GetPos( (const SwFrmFmtPtr)pNewFmt ) )
@@ -627,7 +638,7 @@ void SwUndoSetFlyFmt::Redo( SwUndoIter& rIter )
else
rDoc.SetFrmFmtToFly( *pFrmFmt, *pNewFmt, 0 );
- rIter.pSelFmt = pFrmFmt;
+ rContext.SetSelections(pFrmFmt, 0);
}
}
diff --git a/sw/source/core/undo/undoflystrattr.cxx b/sw/source/core/undo/undoflystrattr.cxx
index 23113d6b0d1b..fad07654f6f8 100644
--- a/sw/source/core/undo/undoflystrattr.cxx
+++ b/sw/source/core/undo/undoflystrattr.cxx
@@ -49,7 +49,7 @@ SwUndoFlyStrAttr::~SwUndoFlyStrAttr()
{
}
-void SwUndoFlyStrAttr::Undo( SwUndoIter& )
+void SwUndoFlyStrAttr::UndoImpl(::sw::UndoRedoContext &)
{
switch ( GetId() )
{
@@ -69,7 +69,7 @@ void SwUndoFlyStrAttr::Undo( SwUndoIter& )
}
}
-void SwUndoFlyStrAttr::Redo( SwUndoIter& )
+void SwUndoFlyStrAttr::RedoImpl(::sw::UndoRedoContext &)
{
switch ( GetId() )
{
@@ -89,11 +89,6 @@ void SwUndoFlyStrAttr::Redo( SwUndoIter& )
}
}
-void SwUndoFlyStrAttr::Repeat( SwUndoIter& )
-{
- // no repeat
-}
-
SwRewriter SwUndoFlyStrAttr::GetRewriter() const
{
SwRewriter aResult;
diff --git a/sw/source/core/undo/undraw.cxx b/sw/source/core/undo/undraw.cxx
index e4e9e9055c91..7e736b59dd50 100644
--- a/sw/source/core/undo/undraw.cxx
+++ b/sw/source/core/undo/undraw.cxx
@@ -65,8 +65,6 @@ struct SwUndoGroupObjImpl
};
-inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); }
-
// Draw-Objecte
IMPL_LINK( SwDoc, AddDrawUndo, SdrUndoAction *, pUndo )
@@ -107,16 +105,16 @@ SwSdrUndo::~SwSdrUndo()
delete pMarkList;
}
-void SwSdrUndo::Undo( SwUndoIter& rUndoIter )
+void SwSdrUndo::UndoImpl(::sw::UndoRedoContext & rContext)
{
pSdrUndo->Undo();
- rUndoIter.pMarkList = pMarkList;
+ rContext.SetSelections(0, pMarkList);
}
-void SwSdrUndo::Redo( SwUndoIter& rUndoIter )
+void SwSdrUndo::RedoImpl(::sw::UndoRedoContext & rContext)
{
pSdrUndo->Redo();
- rUndoIter.pMarkList = pMarkList;
+ rContext.SetSelections(0, pMarkList);
}
String SwSdrUndo::GetComment() const
@@ -223,7 +221,7 @@ SwUndoDrawGroup::~SwUndoDrawGroup()
delete [] pObjArr;
}
-void SwUndoDrawGroup::Undo( SwUndoIter& )
+void SwUndoDrawGroup::UndoImpl(::sw::UndoRedoContext &)
{
bDelFmt = FALSE;
@@ -274,7 +272,7 @@ void SwUndoDrawGroup::Undo( SwUndoIter& )
}
}
-void SwUndoDrawGroup::Redo( SwUndoIter& )
+void SwUndoDrawGroup::RedoImpl(::sw::UndoRedoContext &)
{
bDelFmt = TRUE;
@@ -388,14 +386,14 @@ SwUndoDrawUnGroup::~SwUndoDrawUnGroup()
delete [] pObjArr;
}
-void SwUndoDrawUnGroup::Undo( SwUndoIter& rIter )
+void SwUndoDrawUnGroup::UndoImpl(::sw::UndoRedoContext & rContext)
{
bDelFmt = TRUE;
- // aus dem Array austragen
- SwDoc* pDoc = &rIter.GetDoc();
+ SwDoc *const pDoc = & rContext.GetDoc();
SwSpzFrmFmts& rFlyFmts = *(SwSpzFrmFmts*)pDoc->GetSpzFrmFmts();
+ // remove from array
for( USHORT n = 1; n < nSize; ++n )
{
SwUndoGroupObjImpl& rSave = *( pObjArr + n );
@@ -440,7 +438,7 @@ void SwUndoDrawUnGroup::Undo( SwUndoIter& rIter )
// <--
}
-void SwUndoDrawUnGroup::Redo( SwUndoIter& )
+void SwUndoDrawUnGroup::RedoImpl(::sw::UndoRedoContext &)
{
bDelFmt = FALSE;
@@ -510,7 +508,8 @@ SwUndoDrawUnGroupConnectToLayout::~SwUndoDrawUnGroupConnectToLayout()
{
}
-void SwUndoDrawUnGroupConnectToLayout::Undo( SwUndoIter& )
+void
+SwUndoDrawUnGroupConnectToLayout::UndoImpl(::sw::UndoRedoContext &)
{
for ( std::vector< SdrObject >::size_type i = 0;
i < aDrawFmtsAndObjs.size(); ++i )
@@ -529,7 +528,8 @@ void SwUndoDrawUnGroupConnectToLayout::Undo( SwUndoIter& )
}
}
-void SwUndoDrawUnGroupConnectToLayout::Redo( SwUndoIter& )
+void
+SwUndoDrawUnGroupConnectToLayout::RedoImpl(::sw::UndoRedoContext &)
{
for ( std::vector< std::pair< SwDrawFrmFmt*, SdrObject* > >::size_type i = 0;
i < aDrawFmtsAndObjs.size(); ++i )
@@ -571,10 +571,10 @@ SwUndoDrawDelete::~SwUndoDrawDelete()
delete pMarkLst;
}
-void SwUndoDrawDelete::Undo( SwUndoIter &rIter )
+void SwUndoDrawDelete::UndoImpl(::sw::UndoRedoContext & rContext)
{
bDelFmt = FALSE;
- SwSpzFrmFmts& rFlyFmts = *rIter.GetDoc().GetSpzFrmFmts();
+ SwSpzFrmFmts & rFlyFmts = *rContext.GetDoc().GetSpzFrmFmts();
for( USHORT n = 0; n < pMarkLst->GetMarkCount(); ++n )
{
SwUndoGroupObjImpl& rSave = *( pObjArr + n );
@@ -597,13 +597,13 @@ void SwUndoDrawDelete::Undo( SwUndoIter &rIter )
}
// <--
}
- rIter.pMarkList = pMarkLst;
+ rContext.SetSelections(0, pMarkLst);
}
-void SwUndoDrawDelete::Redo( SwUndoIter &rIter )
+void SwUndoDrawDelete::RedoImpl(::sw::UndoRedoContext & rContext)
{
bDelFmt = TRUE;
- SwSpzFrmFmts& rFlyFmts = *rIter.GetDoc().GetSpzFrmFmts();
+ SwSpzFrmFmts & rFlyFmts = *rContext.GetDoc().GetSpzFrmFmts();
for( USHORT n = 0; n < pMarkLst->GetMarkCount(); ++n )
{
SwUndoGroupObjImpl& rSave = *( pObjArr + n );
diff --git a/sw/source/core/undo/unfmco.cxx b/sw/source/core/undo/unfmco.cxx
index 6c51b8556ee2..29b694a095db 100644
--- a/sw/source/core/undo/unfmco.cxx
+++ b/sw/source/core/undo/unfmco.cxx
@@ -39,8 +39,6 @@
#include "rolbck.hxx"
-inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); }
-
//--------------------------------------------------
@@ -70,37 +68,40 @@ SwUndoFmtColl::~SwUndoFmtColl()
}
-void SwUndoFmtColl::Undo( SwUndoIter& rUndoIter )
+void SwUndoFmtColl::UndoImpl(::sw::UndoRedoContext & rContext)
{
- // die alten Werte wieder zurueck
- pHistory->TmpRollback( &rUndoIter.GetDoc(), 0 );
+ // restore old values
+ pHistory->TmpRollback(& rContext.GetDoc(), 0);
pHistory->SetTmpEnd( pHistory->Count() );
- // setze noch den Cursor auf den Undo-Bereich
- SetPaM( rUndoIter );
+ // create cursor for undo range
+ AddUndoRedoPaM(rContext);
}
-void SwUndoFmtColl::Redo( SwUndoIter& rUndoIter )
+void SwUndoFmtColl::RedoImpl(::sw::UndoRedoContext & rContext)
{
- // setze Attribut in dem Bereich:
- SetPaM( rUndoIter );
+ SwPaM & rPam = AddUndoRedoPaM(rContext);
- Repeat( rUndoIter ); // Collection setzen
+ DoSetFmtColl(rContext.GetDoc(), rPam);
}
+void SwUndoFmtColl::RepeatImpl(::sw::RepeatContext & rContext)
+{
+ DoSetFmtColl(rContext.GetDoc(), rContext.GetRepeatPaM());
+}
-void SwUndoFmtColl::Repeat( SwUndoIter& rUndoIter )
+void SwUndoFmtColl::DoSetFmtColl(SwDoc & rDoc, SwPaM & rPaM)
{
// es kann nur eine TextFmtColl auf einen Bereich angewendet werden,
// also erfrage auch nur in dem Array
- USHORT nPos = rUndoIter.GetDoc().GetTxtFmtColls()->GetPos(
+ USHORT const nPos = rDoc.GetTxtFmtColls()->GetPos(
(SwTxtFmtColl*)pFmtColl );
- // ist das Format ueberhaupt noch vorhanden?
+ // does the format still exist?
if( USHRT_MAX != nPos )
{
// --> OD 2008-04-15 #refactorlists#
- rUndoIter.GetDoc().SetTxtFmtColl( *rUndoIter.pAktPam,
+ rDoc.SetTxtFmtColl(rPaM,
(SwTxtFmtColl*)pFmtColl,
mbReset,
mbResetListAttrs );
diff --git a/sw/source/core/undo/unins.cxx b/sw/source/core/undo/unins.cxx
index 215cc8693f7e..d9f39925045f 100644
--- a/sw/source/core/undo/unins.cxx
+++ b/sw/source/core/undo/unins.cxx
@@ -63,16 +63,6 @@
using namespace ::com::sun::star;
-//------------------------------------------------------------------
-
-inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); }
-
-// zwei Zugriffs-Funktionen
-inline SwPosition* IterPt( SwUndoIter& rUIter )
-{ return rUIter.pAktPam->GetPoint(); }
-inline SwPosition* IterMk( SwUndoIter& rUIter )
-{ return rUIter.pAktPam->GetMark(); }
-
//------------------------------------------------------------
// INSERT
@@ -224,13 +214,13 @@ SwUndoInsert::~SwUndoInsert()
-void SwUndoInsert::Undo( SwUndoIter& rUndoIter )
+void SwUndoInsert::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc* pTmpDoc = &rUndoIter.GetDoc();
+ SwDoc *const pTmpDoc = & rContext.GetDoc();
+ SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
if( bIsAppend )
{
- SwPaM* pPam = rUndoIter.pAktPam;
pPam->GetPoint()->nNode = nNode;
if( IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() ))
@@ -287,24 +277,22 @@ void SwUndoInsert::Undo( SwUndoIter& rUndoIter )
nCntnt = aPaM.GetPoint()->nContent.GetIndex();
}
- // setze noch den Cursor auf den Undo-Bereich
- rUndoIter.pAktPam->DeleteMark();
+ // set cursor to Undo range
+ pPam->DeleteMark();
- IterPt(rUndoIter)->nNode = nNd;
- IterPt(rUndoIter)->nContent.Assign(
- IterPt(rUndoIter)->nNode.GetNode().GetCntntNode(), nCnt );
- // SPoint und GetMark auf der gleichen Position
+ pPam->GetPoint()->nNode = nNd;
+ pPam->GetPoint()->nContent.Assign(
+ pPam->GetPoint()->nNode.GetNode().GetCntntNode(), nCnt );
}
DELETEZ(pUndoTxt);
}
-void SwUndoInsert::Redo( SwUndoIter& rUndoIter )
+void SwUndoInsert::RedoImpl(::sw::UndoRedoContext & rContext)
{
- // setze noch den Cursor auf den Redo-Bereich
- SwPaM* pPam = rUndoIter.pAktPam;
- SwDoc* pTmpDoc = pPam->GetDoc();
+ SwDoc *const pTmpDoc = & rContext.GetDoc();
+ SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
pPam->DeleteMark();
if( bIsAppend )
@@ -360,18 +348,18 @@ void SwUndoInsert::Redo( SwUndoIter& rUndoIter )
nCntnt = pPam->GetMark()->nContent.GetIndex();
MovePtForward( *pPam, bMvBkwrd );
- rUndoIter.pAktPam->Exchange();
+ pPam->Exchange();
if( pRedlData && IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() ))
{
RedlineMode_t eOld = pTmpDoc->GetRedlineMode();
pTmpDoc->SetRedlineMode_intern((RedlineMode_t)(eOld & ~nsRedlineMode_t::REDLINE_IGNORE));
pTmpDoc->AppendRedline( new SwRedline( *pRedlData,
- *rUndoIter.pAktPam ), true);
+ *pPam ), true);
pTmpDoc->SetRedlineMode_intern( eOld );
}
else if( !( nsRedlineMode_t::REDLINE_IGNORE & GetRedlineMode() ) &&
pTmpDoc->GetRedlineTbl().Count() )
- pTmpDoc->SplitRedline( *rUndoIter.pAktPam );
+ pTmpDoc->SplitRedline(*pPam);
}
}
@@ -379,12 +367,12 @@ void SwUndoInsert::Redo( SwUndoIter& rUndoIter )
}
-void SwUndoInsert::Repeat( SwUndoIter& rUndoIter )
+void SwUndoInsert::RepeatImpl(::sw::RepeatContext & rContext)
{
if( !nLen )
return;
- SwDoc& rDoc = rUndoIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
SwNodeIndex aNd( rDoc.GetNodes(), nNode );
SwCntntNode* pCNd = aNd.GetNode().GetCntntNode();;
@@ -402,12 +390,14 @@ void SwUndoInsert::Repeat( SwUndoIter& rUndoIter )
{
case ND_TEXTNODE:
if( bIsAppend )
- rDoc.AppendTxtNode( *rUndoIter.pAktPam->GetPoint() );
+ {
+ rDoc.AppendTxtNode( *rContext.GetRepeatPaM().GetPoint() );
+ }
else
{
String aTxt( ((SwTxtNode*)pCNd)->GetTxt() );
::sw::GroupUndoGuard const undoGuard(rDoc.GetIDocumentUndoRedo());
- rDoc.InsertString( *rUndoIter.pAktPam,
+ rDoc.InsertString( rContext.GetRepeatPaM(),
aTxt.Copy( nCntnt - nLen, nLen ) );
}
break;
@@ -418,7 +408,7 @@ void SwUndoInsert::Repeat( SwUndoIter& rUndoIter )
if( pGrfNd->IsGrfLink() )
pGrfNd->GetFileFilterNms( &sFile, &sFilter );
- rDoc.Insert( *rUndoIter.pAktPam, sFile, sFilter,
+ rDoc.Insert( rContext.GetRepeatPaM(), sFile, sFilter,
&pGrfNd->GetGrf(),
0/* Grafik-Collection*/, NULL, NULL );
}
@@ -438,7 +428,10 @@ void SwUndoInsert::Repeat( SwUndoIter& rUndoIter )
if ( aCnt.StoreEmbeddedObject( rSwOLE.GetOleRef(), aName, sal_True ) )
{
uno::Reference < embed::XEmbeddedObject > aNew = aCnt.GetEmbeddedObject( aName );
- rDoc.Insert( *rUndoIter.pAktPam, svt::EmbeddedObjectRef( aNew, ((SwOLENode*)pCNd)->GetAspect() ), NULL, NULL, NULL );
+ rDoc.Insert( rContext.GetRepeatPaM(),
+ svt::EmbeddedObjectRef( aNew,
+ static_cast<SwOLENode*>(pCNd)->GetAspect() ),
+ NULL, NULL, NULL );
}
break;
@@ -497,8 +490,9 @@ class SwUndoReplace::Impl
public:
Impl(SwPaM const& rPam, ::rtl::OUString const& rIns, bool const bRegExp);
- void Undo( SwUndoIter& );
- void Redo( SwUndoIter& );
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
+
void SetEnd(SwPaM const& rPam);
::rtl::OUString const& GetOld() const { return m_sOld; }
@@ -517,15 +511,14 @@ SwUndoReplace::~SwUndoReplace()
{
}
-void SwUndoReplace::Undo( SwUndoIter& rUndoIter )
+void SwUndoReplace::UndoImpl(::sw::UndoRedoContext & rContext)
{
- m_pImpl->Undo( rUndoIter );
+ m_pImpl->UndoImpl(rContext);
}
-
-void SwUndoReplace::Redo( SwUndoIter& rUndoIter )
+void SwUndoReplace::RedoImpl(::sw::UndoRedoContext & rContext)
{
- m_pImpl->Redo( rUndoIter );
+ m_pImpl->RedoImpl(rContext);
}
SwRewriter
@@ -646,10 +639,10 @@ SwUndoReplace::Impl::Impl(
m_sOld = pNd->GetTxt().Copy( m_nSttCnt, nECnt - m_nSttCnt );
}
-void SwUndoReplace::Impl::Undo( SwUndoIter& rIter )
+void SwUndoReplace::Impl::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc* pDoc = &rIter.GetDoc();
- SwPaM& rPam = *rIter.pAktPam;
+ SwDoc *const pDoc = & rContext.GetDoc();
+ SwPaM & rPam(rContext.GetCursorSupplier().CreateNewShellCursor());
rPam.DeleteMark();
SwTxtNode* pNd = pDoc->GetNodes()[ m_nSttNd - m_nOffset ]->GetTxtNode();
@@ -731,11 +724,10 @@ void SwUndoReplace::Impl::Undo( SwUndoIter& rIter )
rPam.GetPoint()->nContent = aIdx;
}
-void SwUndoReplace::Impl::Redo( SwUndoIter& rIter )
+void SwUndoReplace::Impl::RedoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc& rDoc = rIter.GetDoc();
-
- SwPaM& rPam = *rIter.pAktPam;
+ SwDoc & rDoc = rContext.GetDoc();
+ SwPaM & rPam(rContext.GetCursorSupplier().CreateNewShellCursor());
rPam.DeleteMark();
rPam.GetPoint()->nNode = m_nSttNd;
@@ -804,9 +796,9 @@ SwUndoReRead::~SwUndoReRead()
}
-void SwUndoReRead::SetAndSave( SwUndoIter& rIter )
+void SwUndoReRead::SetAndSave(::sw::UndoRedoContext & rContext)
{
- SwDoc& rDoc = rIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
SwGrfNode* pGrfNd = rDoc.GetNodes()[ nPos ]->GetGrfNode();
if( !pGrfNd )
@@ -834,19 +826,19 @@ void SwUndoReRead::SetAndSave( SwUndoIter& rIter )
if( RES_MIRROR_GRAPH_DONT != nOldMirr )
pGrfNd->SetAttr( SwMirrorGrf() );
- rIter.pSelFmt = pGrfNd->GetFlyFmt();
+ rContext.SetSelections(pGrfNd->GetFlyFmt(), 0);
}
-void SwUndoReRead::Undo( SwUndoIter& rIter )
+void SwUndoReRead::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SetAndSave( rIter );
+ SetAndSave(rContext);
}
-void SwUndoReRead::Redo( SwUndoIter& rIter )
+void SwUndoReRead::RedoImpl(::sw::UndoRedoContext & rContext)
{
- SetAndSave( rIter );
+ SetAndSave(rContext);
}
@@ -905,9 +897,9 @@ SwUndoInsertLabel::~SwUndoInsertLabel()
delete NODE.pUndoInsNd;
}
-void SwUndoInsertLabel::Undo( SwUndoIter& rIter )
+void SwUndoInsertLabel::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc& rDoc = rIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
if( LTYPE_OBJECT == eType || LTYPE_DRAW == eType )
{
@@ -919,8 +911,8 @@ void SwUndoInsertLabel::Undo( SwUndoIter& rIter )
( LTYPE_DRAW != eType ||
0 != (pSdrObj = pFmt->FindSdrObject()) ) )
{
- OBJECT.pUndoAttr->Undo( rIter );
- OBJECT.pUndoFly->Undo( rIter );
+ OBJECT.pUndoAttr->UndoImpl(rContext);
+ OBJECT.pUndoFly->UndoImpl(rContext);
if( LTYPE_DRAW == eType )
{
pSdrObj->SetLayer( nLayerId );
@@ -936,7 +928,7 @@ void SwUndoInsertLabel::Undo( SwUndoIter& rIter )
if ( pNd )
pNd->GetTable().GetFrmFmt()->ResetFmtAttr( RES_KEEP );
}
- SwPaM aPam( *rIter.pAktPam->GetPoint() );
+ SwPaM aPam( rDoc.GetNodes().GetEndOfContent() );
aPam.GetPoint()->nNode = NODE.nNode;
aPam.SetMark();
aPam.GetPoint()->nNode = NODE.nNode + 1;
@@ -945,9 +937,9 @@ void SwUndoInsertLabel::Undo( SwUndoIter& rIter )
}
-void SwUndoInsertLabel::Redo( SwUndoIter& rIter )
+void SwUndoInsertLabel::RedoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc& rDoc = rIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
if( LTYPE_OBJECT == eType || LTYPE_DRAW == eType )
{
@@ -959,8 +951,8 @@ void SwUndoInsertLabel::Redo( SwUndoIter& rIter )
( LTYPE_DRAW != eType ||
0 != (pSdrObj = pFmt->FindSdrObject()) ) )
{
- OBJECT.pUndoFly->Redo( rIter );
- OBJECT.pUndoAttr->Redo( rIter );
+ OBJECT.pUndoFly->RedoImpl(rContext);
+ OBJECT.pUndoAttr->RedoImpl(rContext);
if( LTYPE_DRAW == eType )
{
pSdrObj->SetLayer( nLayerId );
@@ -981,15 +973,15 @@ void SwUndoInsertLabel::Redo( SwUndoIter& rIter )
if ( pNd )
pNd->GetTable().GetFrmFmt()->SetFmtAttr( SvxFmtKeepItem(TRUE, RES_KEEP) );
}
- NODE.pUndoInsNd->Undo( rIter );
+ NODE.pUndoInsNd->UndoImpl(rContext);
delete NODE.pUndoInsNd, NODE.pUndoInsNd = 0;
}
}
-void SwUndoInsertLabel::Repeat( SwUndoIter& rIter )
+void SwUndoInsertLabel::RepeatImpl(::sw::RepeatContext & rContext)
{
- SwDoc& rDoc = rIter.GetDoc();
- const SwPosition& rPos = *rIter.pAktPam->GetPoint();
+ SwDoc & rDoc = rContext.GetDoc();
+ const SwPosition& rPos = *rContext.GetRepeatPaM().GetPoint();
ULONG nIdx = 0;
diff --git a/sw/source/core/undo/unmove.cxx b/sw/source/core/undo/unmove.cxx
index 1b155a8e3c7d..b93d33f6c972 100644
--- a/sw/source/core/undo/unmove.cxx
+++ b/sw/source/core/undo/unmove.cxx
@@ -37,8 +37,6 @@
#include <rolbck.hxx>
-inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); }
-
// MOVE
SwUndoMove::SwUndoMove( const SwPaM& rRange, const SwPosition& rMvPos )
@@ -188,9 +186,9 @@ void SwUndoMove::SetDestRange( const SwNodeIndex& rStt,
}
-void SwUndoMove::Undo( SwUndoIter& rUndoIter )
+void SwUndoMove::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc* pDoc = &rUndoIter.GetDoc();
+ SwDoc *const pDoc = & rContext.GetDoc();
// Block, damit aus diesem gesprungen werden kann
do {
@@ -277,14 +275,16 @@ void SwUndoMove::Undo( SwUndoIter& rUndoIter )
// setze noch den Cursor auf den Undo-Bereich
if( !bMoveRange )
- SetPaM( rUndoIter );
+ {
+ AddUndoRedoPaM(rContext);
+ }
}
-void SwUndoMove::Redo( SwUndoIter& rUndoIter )
+void SwUndoMove::RedoImpl(::sw::UndoRedoContext & rContext)
{
- SwPaM* pPam = rUndoIter.pAktPam;
- SwDoc& rDoc = *pPam->GetDoc();
+ SwPaM *const pPam = & AddUndoRedoPaM(rContext);
+ SwDoc & rDoc = rContext.GetDoc();
SwNodes& rNds = rDoc.GetNodes();
SwNodeIndex aIdx( rNds, nMvDestNode );
diff --git a/sw/source/core/undo/unnum.cxx b/sw/source/core/undo/unnum.cxx
index f5947bc702b4..da7d5b8d1c0a 100644
--- a/sw/source/core/undo/unnum.cxx
+++ b/sw/source/core/undo/unnum.cxx
@@ -43,7 +43,6 @@
SV_DECL_PTRARR_DEL( _SfxPoolItems, SfxPoolItem*, 16, 16 )
SV_IMPL_PTRARR( _SfxPoolItems, SfxPoolItem* );
-inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); }
SwUndoInsNum::SwUndoInsNum( const SwNumRule& rOldRule,
const SwNumRule& rNewRule,
@@ -88,11 +87,9 @@ SwRewriter SwUndoInsNum::GetRewriter() const
return aResult;
}
-void SwUndoInsNum::Undo( SwUndoIter& rUndoIter )
+void SwUndoInsNum::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc& rDoc = rUndoIter.GetDoc();
- if( nSttNode )
- SetPaM( rUndoIter );
+ SwDoc & rDoc = rContext.GetDoc();
if( pOldNumRule )
rDoc.ChgNumRuleFmts( *pOldNumRule );
@@ -132,28 +129,31 @@ void SwUndoInsNum::Undo( SwUndoIter& rUndoIter )
pHistory->SetTmpEnd( pHistory->Count() );
}
- if( nSttNode )
- SetPaM( rUndoIter );
+ if (nSttNode)
+ {
+ AddUndoRedoPaM(rContext);
+ }
}
-
-void SwUndoInsNum::Redo( SwUndoIter& rUndoIter )
+void SwUndoInsNum::RedoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc& rDoc = rUndoIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
if( pOldNumRule )
rDoc.ChgNumRuleFmts( aNumRule );
else if( pHistory )
{
- SetPaM( rUndoIter );
+ SwPaM & rPam( AddUndoRedoPaM(rContext) );
if( sReplaceRule.Len() )
- rDoc.ReplaceNumRule( *rUndoIter.pAktPam->GetPoint(),
+ {
+ rDoc.ReplaceNumRule(*rPam.GetPoint(),
sReplaceRule, aNumRule.GetName() );
+ }
else
{
// --> OD 2005-02-25 #i42921# - adapt to changed signature
// --> OD 2008-03-18 #refactorlists#
- rDoc.SetNumRule( *rUndoIter.pAktPam, aNumRule, false );
+ rDoc.SetNumRule(rPam, aNumRule, false);
// <--
}
}
@@ -165,20 +165,23 @@ void SwUndoInsNum::SetLRSpaceEndPos()
nLRSavePos = pHistory->Count();
}
-void SwUndoInsNum::Repeat( SwUndoIter& rUndoIter )
+void SwUndoInsNum::RepeatImpl(::sw::RepeatContext & rContext)
{
+ SwDoc & rDoc(rContext.GetDoc());
if( nSttNode )
{
if( !sReplaceRule.Len() )
{
// --> OD 2005-02-25 #i42921# - adapt to changed signature
// --> OD 2008-03-18 #refactorlists#
- rUndoIter.GetDoc().SetNumRule( *rUndoIter.pAktPam, aNumRule, false );
+ rDoc.SetNumRule(rContext.GetRepeatPaM(), aNumRule, false);
// <--
}
}
else
- rUndoIter.GetDoc().ChgNumRuleFmts( aNumRule );
+ {
+ rDoc.ChgNumRuleFmts( aNumRule );
+ }
}
SwHistory* SwUndoInsNum::GetHistory()
@@ -204,17 +207,14 @@ SwUndoDelNum::SwUndoDelNum( const SwPaM& rPam )
pHistory = new SwHistory;
}
-
SwUndoDelNum::~SwUndoDelNum()
{
delete pHistory;
}
-
-void SwUndoDelNum::Undo( SwUndoIter& rUndoIter )
+void SwUndoDelNum::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc& rDoc = rUndoIter.GetDoc();
- SetPaM( rUndoIter );
+ SwDoc & rDoc = rContext.GetDoc();
pHistory->TmpRollback( &rDoc, 0 );
pHistory->SetTmpEnd( pHistory->Count() );
@@ -229,21 +229,18 @@ void SwUndoDelNum::Undo( SwUndoIter& rUndoIter )
pNd->ChkCondColl();
}
- SetPaM( rUndoIter );
+ AddUndoRedoPaM(rContext);
}
-
-void SwUndoDelNum::Redo( SwUndoIter& rUndoIter )
+void SwUndoDelNum::RedoImpl(::sw::UndoRedoContext & rContext)
{
- SetPaM( rUndoIter );
- rUndoIter.GetDoc().DelNumRules( *rUndoIter.pAktPam );
+ SwPaM & rPam( AddUndoRedoPaM(rContext) );
+ rContext.GetDoc().DelNumRules(rPam);
}
-
-void SwUndoDelNum::Repeat( SwUndoIter& rUndoIter )
+void SwUndoDelNum::RepeatImpl(::sw::RepeatContext & rContext)
{
- SetPaM( rUndoIter );
- rUndoIter.GetDoc().DelNumRules( *rUndoIter.pAktPam );
+ rContext.GetDoc().DelNumRules(rContext.GetRepeatPaM());
}
void SwUndoDelNum::AddNode( const SwTxtNode& rNd, BOOL )
@@ -270,8 +267,7 @@ SwUndoMoveNum::SwUndoMoveNum( const SwPaM& rPam, long nOff, BOOL bIsOutlMv )
// nach oben => -1
}
-
-void SwUndoMoveNum::Undo( SwUndoIter& rUndoIter )
+void SwUndoMoveNum::UndoImpl(::sw::UndoRedoContext & rContext)
{
ULONG nTmpStt = nSttNode, nTmpEnd = nEndNode;
@@ -288,33 +284,35 @@ void SwUndoMoveNum::Undo( SwUndoIter& rUndoIter )
// SetPaM( rUndoIter );
// RemoveIdxFromRange( *rUndoIter.pAktPam, TRUE );
- SetPaM( rUndoIter );
- rUndoIter.GetDoc().MoveParagraph( *rUndoIter.pAktPam, -nOffset,
+ SwPaM & rPam( AddUndoRedoPaM(rContext) );
+ rContext.GetDoc().MoveParagraph( rPam, -nOffset,
UNDO_OUTLINE_UD == GetId() );
nSttNode = nTmpStt;
nEndNode = nTmpEnd;
}
-
-void SwUndoMoveNum::Redo( SwUndoIter& rUndoIter )
+void SwUndoMoveNum::RedoImpl(::sw::UndoRedoContext & rContext)
{
//JP 22.06.95: wird wollen die Bookmarks/Verzeichnisse behalten, oder?
// SetPaM( rUndoIter );
// RemoveIdxFromRange( *rUndoIter.pAktPam, TRUE );
- SetPaM( rUndoIter );
- rUndoIter.GetDoc().MoveParagraph( *rUndoIter.pAktPam, nOffset,
- UNDO_OUTLINE_UD == GetId() );
+ SwPaM & rPam( AddUndoRedoPaM(rContext) );
+ rContext.GetDoc().MoveParagraph(rPam, nOffset, UNDO_OUTLINE_UD == GetId());
}
-
-void SwUndoMoveNum::Repeat( SwUndoIter& rUndoIter )
+void SwUndoMoveNum::RepeatImpl(::sw::RepeatContext & rContext)
{
+ SwDoc & rDoc = rContext.GetDoc();
if( UNDO_OUTLINE_UD == GetId() )
- rUndoIter.GetDoc().MoveOutlinePara( *rUndoIter.pAktPam,
+ {
+ rDoc.MoveOutlinePara(rContext.GetRepeatPaM(),
0 < nOffset ? 1 : -1 );
+ }
else
- rUndoIter.GetDoc().MoveParagraph( *rUndoIter.pAktPam, nOffset, FALSE );
+ {
+ rDoc.MoveParagraph(rContext.GetRepeatPaM(), nOffset, FALSE);
+ }
}
/* */
@@ -328,24 +326,21 @@ SwUndoNumUpDown::SwUndoNumUpDown( const SwPaM& rPam, short nOff )
// Up => -1
}
-
-void SwUndoNumUpDown::Undo( SwUndoIter& rUndoIter )
+void SwUndoNumUpDown::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SetPaM( rUndoIter );
- rUndoIter.GetDoc().NumUpDown( *rUndoIter.pAktPam, 1 != nOffset );
+ SwPaM & rPam( AddUndoRedoPaM(rContext) );
+ rContext.GetDoc().NumUpDown(rPam, 1 != nOffset );
}
-
-void SwUndoNumUpDown::Redo( SwUndoIter& rUndoIter )
+void SwUndoNumUpDown::RedoImpl(::sw::UndoRedoContext & rContext)
{
- SetPaM( rUndoIter );
- rUndoIter.GetDoc().NumUpDown( *rUndoIter.pAktPam, 1 == nOffset );
+ SwPaM & rPam( AddUndoRedoPaM(rContext) );
+ rContext.GetDoc().NumUpDown(rPam, 1 == nOffset);
}
-
-void SwUndoNumUpDown::Repeat( SwUndoIter& rUndoIter )
+void SwUndoNumUpDown::RepeatImpl(::sw::RepeatContext & rContext)
{
- rUndoIter.GetDoc().NumUpDown( *rUndoIter.pAktPam, 1 == nOffset );
+ rContext.GetDoc().NumUpDown(rContext.GetRepeatPaM(), 1 == nOffset);
}
/* */
@@ -359,9 +354,9 @@ SwUndoNumOrNoNum::SwUndoNumOrNoNum( const SwNodeIndex& rIdx, BOOL bOldNum,
}
// #115901#, #i40034#
-void SwUndoNumOrNoNum::Undo( SwUndoIter& rUndoIter )
+void SwUndoNumOrNoNum::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwNodeIndex aIdx( rUndoIter.GetDoc().GetNodes(), nIdx );
+ SwNodeIndex aIdx( rContext.GetDoc().GetNodes(), nIdx );
SwTxtNode * pTxtNd = aIdx.GetNode().GetTxtNode();
if (NULL != pTxtNd)
@@ -371,9 +366,9 @@ void SwUndoNumOrNoNum::Undo( SwUndoIter& rUndoIter )
}
// #115901#, #i40034#
-void SwUndoNumOrNoNum::Redo( SwUndoIter& rUndoIter )
+void SwUndoNumOrNoNum::RedoImpl(::sw::UndoRedoContext & rContext)
{
- SwNodeIndex aIdx( rUndoIter.GetDoc().GetNodes(), nIdx );
+ SwNodeIndex aIdx( rContext.GetDoc().GetNodes(), nIdx );
SwTxtNode * pTxtNd = aIdx.GetNode().GetTxtNode();
if (NULL != pTxtNd)
@@ -383,15 +378,17 @@ void SwUndoNumOrNoNum::Redo( SwUndoIter& rUndoIter )
}
// #115901#
-void SwUndoNumOrNoNum::Repeat( SwUndoIter& rUndoIter )
+void SwUndoNumOrNoNum::RepeatImpl(::sw::RepeatContext & rContext)
{
-
+ SwDoc & rDoc = rContext.GetDoc();
if (mbOldNum && ! mbNewNum)
- rUndoIter.GetDoc().NumOrNoNum( rUndoIter.pAktPam->GetPoint()->nNode,
- FALSE);
+ {
+ rDoc.NumOrNoNum(rContext.GetRepeatPaM().GetPoint()->nNode, FALSE);
+ }
else if ( ! mbOldNum && mbNewNum )
- rUndoIter.GetDoc().NumOrNoNum( rUndoIter.pAktPam->GetPoint()->nNode,
- TRUE);
+ {
+ rDoc.NumOrNoNum(rContext.GetRepeatPaM().GetPoint()->nNode, TRUE);
+ }
}
/* */
@@ -425,34 +422,47 @@ SwUndoNumRuleStart::SwUndoNumRuleStart( const SwPosition& rPos, USHORT nStt )
}
-void SwUndoNumRuleStart::Undo( SwUndoIter& rUndoIter )
+void SwUndoNumRuleStart::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwPosition aPos( *rUndoIter.GetDoc().GetNodes()[ nIdx ] );
+ SwDoc & rDoc = rContext.GetDoc();
+ SwPosition const aPos( *rDoc.GetNodes()[ nIdx ] );
if( bSetSttValue )
- rUndoIter.GetDoc().SetNodeNumStart( aPos, nOldStt );
+ {
+ rDoc.SetNodeNumStart( aPos, nOldStt );
+ }
else
- rUndoIter.GetDoc().SetNumRuleStart( aPos, !bFlag );
+ {
+ rDoc.SetNumRuleStart( aPos, !bFlag );
+ }
}
-void SwUndoNumRuleStart::Redo( SwUndoIter& rUndoIter )
+void SwUndoNumRuleStart::RedoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc& rDoc = rUndoIter.GetDoc();
-
- SwPosition aPos( *rDoc.GetNodes()[ nIdx ] );
+ SwDoc & rDoc = rContext.GetDoc();
+ SwPosition const aPos( *rDoc.GetNodes()[ nIdx ] );
if( bSetSttValue )
+ {
rDoc.SetNodeNumStart( aPos, nNewStt );
+ }
else
+ {
rDoc.SetNumRuleStart( aPos, bFlag );
+ }
}
-void SwUndoNumRuleStart::Repeat( SwUndoIter& rUndoIter )
+void SwUndoNumRuleStart::RepeatImpl(::sw::RepeatContext & rContext)
{
+ SwDoc & rDoc = rContext.GetDoc();
if( bSetSttValue )
- rUndoIter.GetDoc().SetNodeNumStart( *rUndoIter.pAktPam->GetPoint(), nNewStt );
+ {
+ rDoc.SetNodeNumStart(*rContext.GetRepeatPaM().GetPoint(), nNewStt);
+ }
else
- rUndoIter.GetDoc().SetNumRuleStart( *rUndoIter.pAktPam->GetPoint(), bFlag );
+ {
+ rDoc.SetNumRuleStart(*rContext.GetRepeatPaM().GetPoint(), bFlag);
+ }
}
diff --git a/sw/source/core/undo/unoutl.cxx b/sw/source/core/undo/unoutl.cxx
index 2a92097221b6..1e8474d79f8e 100644
--- a/sw/source/core/undo/unoutl.cxx
+++ b/sw/source/core/undo/unoutl.cxx
@@ -28,8 +28,6 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sw.hxx"
-
-
#include "doc.hxx"
#include "swundo.hxx" // fuer die UndoIds
#include "pam.hxx"
@@ -38,33 +36,26 @@
#include "undobj.hxx"
-inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); }
-
SwUndoOutlineLeftRight::SwUndoOutlineLeftRight( const SwPaM& rPam,
short nOff )
: SwUndo( UNDO_OUTLINE_LR ), SwUndRng( rPam ), nOffset( nOff )
{
}
-
-void SwUndoOutlineLeftRight::Undo( SwUndoIter& rUndoIter )
+void SwUndoOutlineLeftRight::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SetPaM( rUndoIter );
- rUndoIter.GetDoc().OutlineUpDown( *rUndoIter.pAktPam, -nOffset );
+ SwPaM & rPaM( AddUndoRedoPaM(rContext) );
+ rContext.GetDoc().OutlineUpDown(rPaM, -nOffset);
}
-
-void SwUndoOutlineLeftRight::Redo( SwUndoIter& rUndoIter )
+void SwUndoOutlineLeftRight::RedoImpl(::sw::UndoRedoContext & rContext)
{
- SetPaM( rUndoIter );
- rUndoIter.GetDoc().OutlineUpDown( *rUndoIter.pAktPam, nOffset );
+ SwPaM & rPaM( AddUndoRedoPaM(rContext) );
+ rContext.GetDoc().OutlineUpDown(rPaM, nOffset);
}
-
-void SwUndoOutlineLeftRight::Repeat( SwUndoIter& rUndoIter )
+void SwUndoOutlineLeftRight::RepeatImpl(::sw::RepeatContext & rContext)
{
- rUndoIter.GetDoc().OutlineUpDown( *rUndoIter.pAktPam, nOffset );
+ rContext.GetDoc().OutlineUpDown(rContext.GetRepeatPaM(), nOffset);
}
-
-
diff --git a/sw/source/core/undo/unovwr.cxx b/sw/source/core/undo/unovwr.cxx
index b9a3d8a709b6..0c83b2aeba48 100644
--- a/sw/source/core/undo/unovwr.cxx
+++ b/sw/source/core/undo/unovwr.cxx
@@ -37,6 +37,7 @@
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
+#include <IShellCursorSupplier.hxx>
#include <swundo.hxx> // fuer die UndoIds
#include <pam.hxx>
#include <ndtxt.hxx>
@@ -52,19 +53,9 @@ using namespace ::com::sun::star;
using namespace ::com::sun::star::i18n;
using namespace ::com::sun::star::uno;
-//------------------------------------------------------------------
-
-// zwei Zugriffs-Funktionen
-inline SwPosition* IterPt( SwUndoIter& rUIter )
-{ return rUIter.pAktPam->GetPoint(); }
-inline SwPosition* IterMk( SwUndoIter& rUIter )
-{ return rUIter.pAktPam->GetMark(); }
-
-inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); }
//------------------------------------------------------------
-
// OVERWRITE
@@ -203,10 +194,11 @@ BOOL SwUndoOverwrite::CanGrouping( SwDoc* pDoc, SwPosition& rPos,
-void SwUndoOverwrite::Undo( SwUndoIter& rUndoIter )
+void SwUndoOverwrite::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwPaM* pAktPam = rUndoIter.pAktPam;
- SwDoc* pDoc = pAktPam->GetDoc();
+ SwDoc *const pDoc = & rContext.GetDoc();
+ SwPaM *const pAktPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
+
pAktPam->DeleteMark();
pAktPam->GetPoint()->nNode = nSttNode;
SwTxtNode* pTxtNd = pAktPam->GetNode()->GetTxtNode();
@@ -269,13 +261,13 @@ void SwUndoOverwrite::Undo( SwUndoIter& rUndoIter )
SetSaveData( *pDoc, *pRedlSaveData );
}
-void SwUndoOverwrite::Repeat( SwUndoIter& rUndoIter )
+void SwUndoOverwrite::RepeatImpl(::sw::RepeatContext & rContext)
{
- SwPaM* pAktPam = rUndoIter.pAktPam;
+ SwPaM *const pAktPam = & rContext.GetRepeatPaM();
if( !aInsStr.Len() || pAktPam->HasMark() )
return;
- SwDoc& rDoc = *pAktPam->GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
{
::sw::GroupUndoGuard const undoGuard(rDoc.GetIDocumentUndoRedo());
@@ -285,12 +277,11 @@ void SwUndoOverwrite::Repeat( SwUndoIter& rUndoIter )
rDoc.Overwrite( *pAktPam, aInsStr.GetChar( n ) );
}
-
-
-void SwUndoOverwrite::Redo( SwUndoIter& rUndoIter )
+void SwUndoOverwrite::RedoImpl(::sw::UndoRedoContext & rContext)
{
- SwPaM* pAktPam = rUndoIter.pAktPam;
- SwDoc* pDoc = pAktPam->GetDoc();
+ SwDoc *const pDoc = & rContext.GetDoc();
+ SwPaM *const pAktPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
+
pAktPam->DeleteMark();
pAktPam->GetPoint()->nNode = nSttNode;
SwTxtNode* pTxtNd = pAktPam->GetNode()->GetTxtNode();
@@ -382,9 +373,9 @@ SwUndoTransliterate::~SwUndoTransliterate()
delete aChanges[i];
}
-void SwUndoTransliterate::Undo( SwUndoIter& rUndoIter )
+void SwUndoTransliterate::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc& rDoc = rUndoIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
// since the changes were added to the vector from the end of the string/node towards
// the start, we need to revert them from the start towards the end now to keep the
@@ -393,20 +384,22 @@ void SwUndoTransliterate::Undo( SwUndoIter& rUndoIter )
for (sal_Int32 i = aChanges.size() - 1; i >= 0; --i)
aChanges[i]->SetChangeAtNode( rDoc );
- SetPaM( rUndoIter, TRUE );
+ AddUndoRedoPaM(rContext, true);
}
-void SwUndoTransliterate::Redo( SwUndoIter& rUndoIter )
+void SwUndoTransliterate::RedoImpl(::sw::UndoRedoContext & rContext)
{
- SetPaM( *rUndoIter.pAktPam );
- Repeat( rUndoIter );
+ SwPaM & rPam( AddUndoRedoPaM(rContext) );
+ DoTransliterate(rContext.GetDoc(), rPam);
}
-void SwUndoTransliterate::Repeat( SwUndoIter& rUndoIter )
+void SwUndoTransliterate::RepeatImpl(::sw::RepeatContext & rContext)
{
- SwPaM& rPam = *rUndoIter.pAktPam;
- SwDoc& rDoc = rUndoIter.GetDoc();
+ DoTransliterate(rContext.GetDoc(), rContext.GetRepeatPaM());
+}
+void SwUndoTransliterate::DoTransliterate(SwDoc & rDoc, SwPaM & rPam)
+{
utl::TransliterationWrapper aTrans( ::comphelper::getProcessServiceFactory(), nType );
rDoc.TransliterateText( rPam, aTrans );
}
diff --git a/sw/source/core/undo/unredln.cxx b/sw/source/core/undo/unredln.cxx
index 392ffbd854b8..ee51af629163 100644
--- a/sw/source/core/undo/unredln.cxx
+++ b/sw/source/core/undo/unredln.cxx
@@ -46,9 +46,6 @@ extern void lcl_GetJoinFlags( SwPaM& rPam, BOOL& rJoinTxt, BOOL& rJoinPrev );
//------------------------------------------------------------------
-inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); }
-
-
SwUndoRedline::SwUndoRedline( SwUndoId nUsrId, const SwPaM& rRange )
: SwUndo( UNDO_REDLINE ), SwUndRng( rRange ),
pRedlData( 0 ), pRedlSaveData( 0 ), nUserId( nUsrId ),
@@ -94,13 +91,12 @@ SwUndoRedline::~SwUndoRedline()
delete pRedlSaveData;
}
-void SwUndoRedline::Undo( SwUndoIter& rIter )
+void SwUndoRedline::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc* pDoc = &rIter.GetDoc();
- SetPaM( *rIter.pAktPam );
+ SwDoc *const pDoc = & rContext.GetDoc();
+ SwPaM & rPam( AddUndoRedoPaM(rContext) );
-// RedlineMode setzen?
- _Undo( rIter );
+ UndoRedlineImpl(*pDoc, rPam);
if( pRedlSaveData )
{
@@ -114,47 +110,47 @@ void SwUndoRedline::Undo( SwUndoIter& rIter )
nSttNode += nEndExtra;
nEndNode += nEndExtra;
}
- SetPaM( *rIter.pAktPam, TRUE );
+ SetPaM(rPam, true);
}
}
-void SwUndoRedline::Redo( SwUndoIter& rIter )
+void SwUndoRedline::RedoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc* pDoc = &rIter.GetDoc();
+ SwDoc *const pDoc = & rContext.GetDoc();
RedlineMode_t eOld = pDoc->GetRedlineMode();
pDoc->SetRedlineMode_intern((RedlineMode_t)(( eOld & ~nsRedlineMode_t::REDLINE_IGNORE) | nsRedlineMode_t::REDLINE_ON ));
- SetPaM( *rIter.pAktPam );
+ SwPaM & rPam( AddUndoRedoPaM(rContext) );
if( pRedlSaveData && bHiddenRedlines )
{
ULONG nEndExtra = pDoc->GetNodes().GetEndOfExtras().GetIndex();
- FillSaveData( *rIter.pAktPam, *pRedlSaveData, FALSE,
+ FillSaveData(rPam, *pRedlSaveData, FALSE,
UNDO_REJECT_REDLINE != nUserId );
nEndExtra -= pDoc->GetNodes().GetEndOfExtras().GetIndex();
nSttNode -= nEndExtra;
nEndNode -= nEndExtra;
}
- _Redo( rIter );
- SetPaM( *rIter.pAktPam, TRUE );
+ RedoRedlineImpl(*pDoc, rPam);
+
+ SetPaM(rPam, true);
pDoc->SetRedlineMode_intern( eOld );
}
-// default ist leer
-void SwUndoRedline::_Undo( SwUndoIter& )
+void SwUndoRedline::UndoRedlineImpl(SwDoc &, SwPaM &)
{
}
-// default ist Redlines entfernen
-void SwUndoRedline::_Redo( SwUndoIter& rIter )
+// default: remove redlines
+void SwUndoRedline::RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam)
{
- rIter.GetDoc().DeleteRedline( *rIter.pAktPam, true, USHRT_MAX );
+ rDoc.DeleteRedline(rPam, true, USHRT_MAX);
}
-/* */
+// SwUndoRedlineDelete ///////////////////////////////////////////////////
SwUndoRedlineDelete::SwUndoRedlineDelete( const SwPaM& rRange, SwUndoId nUsrId )
: SwUndoRedline( nUsrId = (nUsrId ? nUsrId : UNDO_DELETE), rRange ),
@@ -178,15 +174,17 @@ SwUndoRedlineDelete::SwUndoRedlineDelete( const SwPaM& rRange, SwUndoId nUsrId )
bCacheComment = false;
}
-void SwUndoRedlineDelete::_Undo( SwUndoIter& rIter )
+void SwUndoRedlineDelete::UndoRedlineImpl(SwDoc & rDoc, SwPaM & rPam)
{
- rIter.GetDoc().DeleteRedline( *rIter.pAktPam, true, USHRT_MAX );
+ rDoc.DeleteRedline(rPam, true, USHRT_MAX);
}
-void SwUndoRedlineDelete::_Redo( SwUndoIter& rIter )
+void SwUndoRedlineDelete::RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam)
{
- if( *rIter.pAktPam->GetPoint() != *rIter.pAktPam->GetMark() )
- rIter.GetDoc().AppendRedline( new SwRedline( *pRedlData, *rIter.pAktPam ), FALSE );
+ if (rPam.GetPoint() != rPam.GetMark())
+ {
+ rDoc.AppendRedline( new SwRedline(*pRedlData, rPam), FALSE );
+ }
}
BOOL SwUndoRedlineDelete::CanGrouping( const SwUndoRedlineDelete& rNext )
@@ -238,14 +236,13 @@ SwUndoRedlineSort::~SwUndoRedlineSort()
delete pOpt;
}
-void SwUndoRedlineSort::_Undo( SwUndoIter& rIter )
+void SwUndoRedlineSort::UndoRedlineImpl(SwDoc & rDoc, SwPaM & rPam)
{
- // im rIter.pAktPam ist der sortiete Bereich,
- // im aSaveRange steht der kopierte, sprich der originale.
- SwDoc& rDoc = rIter.GetDoc();
+ // rPam contains the sorted range
+ // aSaveRange contains copied (i.e. original) range
- SwPosition* pStart = rIter.pAktPam->Start();
- SwPosition* pEnd = rIter.pAktPam->End();
+ SwPosition *const pStart = rPam.Start();
+ SwPosition *const pEnd = rPam.End();
SwNodeIndex aPrevIdx( pStart->nNode, -1 );
ULONG nOffsetTemp = pEnd->nNode.GetIndex() - pStart->nNode.GetIndex();
@@ -266,7 +263,7 @@ void SwUndoRedlineSort::_Undo( SwUndoIter& rIter )
}
{
- SwPaM aTmp( *rIter.pAktPam->GetMark() );
+ SwPaM aTmp( *rPam.GetMark() );
aTmp.GetMark()->nContent = 0;
aTmp.SetMark();
aTmp.GetPoint()->nNode = nSaveEndNode;
@@ -274,9 +271,9 @@ void SwUndoRedlineSort::_Undo( SwUndoIter& rIter )
rDoc.DeleteRedline( aTmp, true, USHRT_MAX );
}
- rDoc.DelFullPara( *rIter.pAktPam );
+ rDoc.DelFullPara(rPam);
- SwPaM* pPam = rIter.pAktPam;
+ SwPaM *const pPam = & rPam;
pPam->DeleteMark();
pPam->GetPoint()->nNode.Assign( aPrevIdx.GetNode(), +1 );
SwCntntNode* pCNd = pPam->GetCntntNode();
@@ -289,13 +286,11 @@ void SwUndoRedlineSort::_Undo( SwUndoIter& rIter )
SetValues( *pPam );
- SetPaM( *rIter.pAktPam );
+ SetPaM(rPam);
}
-void SwUndoRedlineSort::_Redo( SwUndoIter& rIter )
+void SwUndoRedlineSort::RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam)
{
- SwPaM& rPam = *rIter.pAktPam;
-
SwPaM* pPam = &rPam;
SwPosition* pStart = pPam->Start();
SwPosition* pEnd = pPam->End();
@@ -304,7 +299,7 @@ void SwUndoRedlineSort::_Redo( SwUndoIter& rIter )
ULONG nOffsetTemp = pEnd->nNode.GetIndex() - pStart->nNode.GetIndex();
xub_StrLen nCntStt = pStart->nContent.GetIndex();
- rIter.GetDoc().SortText( rPam, *pOpt );
+ rDoc.SortText(rPam, *pOpt);
pPam->DeleteMark();
pPam->GetPoint()->nNode.Assign( aPrevIdx.GetNode(), +1 );
@@ -326,9 +321,9 @@ void SwUndoRedlineSort::_Redo( SwUndoIter& rIter )
rPam.GetPoint()->nContent.Assign( rPam.GetCntntNode(), nSaveEndCntnt );
}
-void SwUndoRedlineSort::Repeat( SwUndoIter& rIter )
+void SwUndoRedlineSort::RepeatImpl(::sw::RepeatContext & rContext)
{
- rIter.GetDoc().SortText( *rIter.pAktPam, *pOpt );
+ rContext.GetDoc().SortText( rContext.GetRepeatPaM(), *pOpt );
}
void SwUndoRedlineSort::SetSaveRange( const SwPaM& rRange )
@@ -343,21 +338,21 @@ void SwUndoRedlineSort::SetOffset( const SwNodeIndex& rIdx )
nOffset = rIdx.GetIndex() - nSttNode;
}
-/* */
+// SwUndoAcceptRedline ///////////////////////////////////////////////////
SwUndoAcceptRedline::SwUndoAcceptRedline( const SwPaM& rRange )
: SwUndoRedline( UNDO_ACCEPT_REDLINE, rRange )
{
}
-void SwUndoAcceptRedline::_Redo( SwUndoIter& rIter )
+void SwUndoAcceptRedline::RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam)
{
- rIter.GetDoc().AcceptRedline( *rIter.pAktPam, false );
+ rDoc.AcceptRedline(rPam, false);
}
-void SwUndoAcceptRedline::Repeat( SwUndoIter& rIter )
+void SwUndoAcceptRedline::RepeatImpl(::sw::RepeatContext & rContext)
{
- rIter.GetDoc().AcceptRedline( *rIter.pAktPam, true );
+ rContext.GetDoc().AcceptRedline(rContext.GetRepeatPaM(), true);
}
SwUndoRejectRedline::SwUndoRejectRedline( const SwPaM& rRange )
@@ -365,17 +360,17 @@ SwUndoRejectRedline::SwUndoRejectRedline( const SwPaM& rRange )
{
}
-void SwUndoRejectRedline::_Redo( SwUndoIter& rIter )
+void SwUndoRejectRedline::RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam)
{
- rIter.GetDoc().RejectRedline( *rIter.pAktPam, false );
+ rDoc.RejectRedline(rPam, false);
}
-void SwUndoRejectRedline::Repeat( SwUndoIter& rIter )
+void SwUndoRejectRedline::RepeatImpl(::sw::RepeatContext & rContext)
{
- rIter.GetDoc().RejectRedline( *rIter.pAktPam, true );
+ rContext.GetDoc().RejectRedline(rContext.GetRepeatPaM(), true);
}
-/* */
+// SwUndoCompDoc /////////////////////////////////////////////////////////
SwUndoCompDoc::SwUndoCompDoc( const SwPaM& rRg, BOOL bIns )
: SwUndo( UNDO_COMPAREDOC ), SwUndRng( rRg ), pRedlData( 0 ),
@@ -416,12 +411,10 @@ SwUndoCompDoc::~SwUndoCompDoc()
delete pRedlSaveData;
}
-void SwUndoCompDoc::Undo( SwUndoIter& rIter )
+void SwUndoCompDoc::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwPaM* pPam = rIter.pAktPam;
- SwDoc* pDoc = pPam->GetDoc();
-
- SetPaM( *pPam );
+ SwDoc *const pDoc = & rContext.GetDoc();
+ SwPaM *const pPam( & AddUndoRedoPaM(rContext) );
if( !bInsert )
{
@@ -481,20 +474,17 @@ void SwUndoCompDoc::Undo( SwUndoIter& rIter )
if( pRedlSaveData )
SetSaveData( *pDoc, *pRedlSaveData );
}
- SetPaM( rIter, TRUE );
+ SetPaM(*pPam, true);
}
}
-void SwUndoCompDoc::Redo( SwUndoIter& rIter )
+void SwUndoCompDoc::RedoImpl(::sw::UndoRedoContext & rContext)
{
- // setze noch den Cursor auf den Redo-Bereich
- SwPaM* pPam = rIter.pAktPam;
- SwDoc* pDoc = pPam->GetDoc();
+ SwDoc *const pDoc = & rContext.GetDoc();
+ SwPaM *const pPam( & AddUndoRedoPaM(rContext) );
if( bInsert )
{
- SetPaM( *pPam );
-
if( pRedlData && IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() ))
{
SwRedline* pTmp = new SwRedline( *pRedlData, *pPam );
@@ -519,10 +509,10 @@ void SwUndoCompDoc::Redo( SwUndoIter& rIter )
if( pUnDel2 )
{
- pUnDel2->Undo( rIter );
+ pUnDel2->UndoImpl(rContext);
delete pUnDel2, pUnDel2 = 0;
}
- pUnDel->Undo( rIter );
+ pUnDel->UndoImpl(rContext);
delete pUnDel, pUnDel = 0;
SetPaM( *pPam );
@@ -535,7 +525,6 @@ void SwUndoCompDoc::Redo( SwUndoIter& rIter )
// pDoc->SetRedlineMode_intern( eOld );
}
- SetPaM( rIter, TRUE );
+ SetPaM(*pPam, true);
}
-
diff --git a/sw/source/core/undo/unsect.cxx b/sw/source/core/undo/unsect.cxx
index 98d0e41d4616..bcda05a60344 100644
--- a/sw/source/core/undo/unsect.cxx
+++ b/sw/source/core/undo/unsect.cxx
@@ -48,8 +48,6 @@
#include <calc.hxx>
-inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); }
-
SfxItemSet* lcl_GetAttrSet( const SwSection& rSect )
{
// Attribute des Formate sichern (Spalten, Farbe, ... )
@@ -122,9 +120,9 @@ SwUndoInsSection::~SwUndoInsSection()
{
}
-void SwUndoInsSection::Undo( SwUndoIter& rUndoIter )
+void SwUndoInsSection::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc& rDoc = rUndoIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
RemoveIdxFromSection( rDoc, m_nSectionNodePos );
@@ -167,25 +165,23 @@ void SwUndoInsSection::Undo( SwUndoIter& rUndoIter )
rDoc.GetFtnIdxs().UpdateFtn( aIdx );
}
- SetPaM( rUndoIter );
+ AddUndoRedoPaM(rContext);
}
-
-void SwUndoInsSection::Redo( SwUndoIter& rUndoIter )
+void SwUndoInsSection::RedoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc& rDoc = rUndoIter.GetDoc();
- SetPaM( rUndoIter );
+ SwDoc & rDoc = rContext.GetDoc();
+ SwPaM & rPam( AddUndoRedoPaM(rContext) );
const SwTOXBaseSection* pUpdateTOX = 0;
if (m_pTOXBase.get())
{
- pUpdateTOX = rDoc.InsertTableOf( *rUndoIter.pAktPam->GetPoint(),
+ pUpdateTOX = rDoc.InsertTableOf( *rPam.GetPoint(),
*m_pTOXBase, m_pAttrSet.get(), true);
}
else
{
- rDoc.InsertSwSection(*rUndoIter.pAktPam,
- *m_pSectionData, 0, m_pAttrSet.get(), true);
+ rDoc.InsertSwSection(rPam, *m_pSectionData, 0, m_pAttrSet.get(), true);
}
if (m_pHistory.get())
@@ -224,22 +220,21 @@ void SwUndoInsSection::Redo( SwUndoIter& rUndoIter )
}
}
-
-void SwUndoInsSection::Repeat( SwUndoIter& rUndoIter )
+void SwUndoInsSection::RepeatImpl(::sw::RepeatContext & rContext)
{
+ SwDoc & rDoc = rContext.GetDoc();
if (m_pTOXBase.get())
{
- rUndoIter.GetDoc().InsertTableOf( *rUndoIter.pAktPam->GetPoint(),
+ rDoc.InsertTableOf(*rContext.GetRepeatPaM().GetPoint(),
*m_pTOXBase, m_pAttrSet.get(), true);
}
else
{
- rUndoIter.GetDoc().InsertSwSection( *rUndoIter.pAktPam,
+ rDoc.InsertSwSection(rContext.GetRepeatPaM(),
*m_pSectionData, 0, m_pAttrSet.get());
}
}
-
void SwUndoInsSection::Join( SwDoc& rDoc, ULONG nNode )
{
SwNodeIndex aIdx( rDoc.GetNodes(), nNode );
@@ -300,9 +295,11 @@ private:
public:
SwUndoDelSection(
SwSectionFmt const&, SwSection const&, SwNodeIndex const*const);
+
virtual ~SwUndoDelSection();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
};
SW_DLLPRIVATE SwUndo * MakeUndoDelSection(SwSectionFmt const& rFormat)
@@ -330,9 +327,9 @@ SwUndoDelSection::~SwUndoDelSection()
{
}
-void SwUndoDelSection::Undo( SwUndoIter& rUndoIter )
+void SwUndoDelSection::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc& rDoc = rUndoIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
if (m_pTOXBase.get())
{
@@ -383,13 +380,13 @@ void SwUndoDelSection::Undo( SwUndoIter& rUndoIter )
}
}
-void SwUndoDelSection::Redo( SwUndoIter& rUndoIter )
+void SwUndoDelSection::RedoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc& rDoc = rUndoIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
SwSectionNode *const pNd =
rDoc.GetNodes()[ m_nStartNode ]->GetSectionNode();
- ASSERT( pNd, "wo ist mein SectionNode?" );
+ OSL_ENSURE(pNd, "SwUndoDelSection::RedoImpl(): no SectionNode?");
// einfach das Format loeschen, der Rest erfolgt automatisch
rDoc.DelSectionFmt( pNd->GetSection().GetFmt() );
}
@@ -409,9 +406,11 @@ private:
public:
SwUndoUpdateSection(
SwSection const&, SwNodeIndex const*const, bool const bOnlyAttr);
+
virtual ~SwUndoUpdateSection();
- virtual void Undo( SwUndoIter& );
- virtual void Redo( SwUndoIter& );
+
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
};
SW_DLLPRIVATE SwUndo *
@@ -436,9 +435,9 @@ SwUndoUpdateSection::~SwUndoUpdateSection()
{
}
-void SwUndoUpdateSection::Undo( SwUndoIter& rUndoIter )
+void SwUndoUpdateSection::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc& rDoc = rUndoIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
SwSectionNode *const pSectNd =
rDoc.GetNodes()[ m_nStartNode ]->GetSectionNode();
ASSERT( pSectNd, "wo ist mein SectionNode?" );
@@ -492,8 +491,8 @@ void SwUndoUpdateSection::Undo( SwUndoIter& rUndoIter )
}
}
-void SwUndoUpdateSection::Redo( SwUndoIter& rUndoIter )
+void SwUndoUpdateSection::RedoImpl(::sw::UndoRedoContext & rContext)
{
- Undo( rUndoIter );
+ UndoImpl(rContext);
}
diff --git a/sw/source/core/undo/unsort.cxx b/sw/source/core/undo/unsort.cxx
index 0a32f8e3e084..4175476877f4 100644
--- a/sw/source/core/undo/unsort.cxx
+++ b/sw/source/core/undo/unsort.cxx
@@ -39,7 +39,6 @@
#include <redline.hxx>
#include <node2lay.hxx>
-inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); }
/*--------------------------------------------------------------------
Beschreibung: Undo fuers Sorting
@@ -88,16 +87,18 @@ SwUndoSort::~SwUndoSort()
delete pRedlData;
}
-void SwUndoSort::Undo( SwUndoIter& rIter)
+void SwUndoSort::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc& rDoc = rIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
if(pSortOpt->bTable)
{
// Undo Tabelle
RemoveIdxFromSection( rDoc, nSttNode, &nEndNode );
if( pUndoTblAttr )
- pUndoTblAttr->Undo( rIter );
+ {
+ pUndoTblAttr->UndoImpl(rContext);
+ }
SwTableNode* pTblNd = rDoc.GetNodes()[ nTblNd ]->GetTableNode();
@@ -135,8 +136,7 @@ void SwUndoSort::Undo( SwUndoIter& rIter)
else
{
// Undo Text
- SwPaM & rPam( *rIter.pAktPam );
- SetPaM(rPam);
+ SwPaM & rPam( AddUndoRedoPaM(rContext) );
RemoveIdxFromRange(rPam, true);
// fuer die sorted Positions einen Index anlegen.
@@ -164,13 +164,13 @@ void SwUndoSort::Undo( SwUndoIter& rIter)
}
// Indixes loeschen
aIdxList.DeleteAndDestroy(0, aIdxList.Count());
- SetPaM( rIter, TRUE );
+ SetPaM(rPam, true);
}
}
-void SwUndoSort::Redo( SwUndoIter& rIter)
+void SwUndoSort::RedoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc& rDoc = rIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
if(pSortOpt->bTable)
{
@@ -203,7 +203,9 @@ void SwUndoSort::Redo( SwUndoIter& rIter)
}
if( pUndoTblAttr )
- pUndoTblAttr->Redo( rIter );
+ {
+ pUndoTblAttr->RedoImpl(rContext);
+ }
// Restore table frames:
// --> FME 2004-11-26 #i37739# A simple 'MakeFrms' after the node sorting
@@ -215,7 +217,7 @@ void SwUndoSort::Redo( SwUndoIter& rIter)
else
{
// Redo for Text
- SwPaM & rPam( *rIter.pAktPam );
+ SwPaM & rPam( AddUndoRedoPaM(rContext) );
SetPaM(rPam);
RemoveIdxFromRange(rPam, true);
@@ -238,19 +240,21 @@ void SwUndoSort::Redo( SwUndoIter& rIter)
}
// Indixes loeschen
aIdxList.DeleteAndDestroy(0, aIdxList.Count());
- SetPaM( rIter, TRUE );
- const SwTxtNode* pTNd = rIter.pAktPam->GetNode()->GetTxtNode();
+ SetPaM(rPam, true);
+ SwTxtNode const*const pTNd = rPam.GetNode()->GetTxtNode();
if( pTNd )
- rIter.pAktPam->GetPoint()->nContent = pTNd->GetTxt().Len();
+ {
+ rPam.GetPoint()->nContent = pTNd->GetTxt().Len();
+ }
}
}
-void SwUndoSort::Repeat(SwUndoIter& rIter)
+void SwUndoSort::RepeatImpl(::sw::RepeatContext & rContext)
{
// table not repeat capable
if(!pSortOpt->bTable)
{
- SwPaM* pPam = rIter.pAktPam;
+ SwPaM *const pPam = & rContext.GetRepeatPaM();
SwDoc& rDoc = *pPam->GetDoc();
if( !rDoc.IsIdxInTbl( pPam->Start()->nNode ) )
diff --git a/sw/source/core/undo/unspnd.cxx b/sw/source/core/undo/unspnd.cxx
index dd76f81bc219..0409575d0f3d 100644
--- a/sw/source/core/undo/unspnd.cxx
+++ b/sw/source/core/undo/unspnd.cxx
@@ -28,7 +28,6 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sw.hxx"
-
#include "doc.hxx"
#include "pam.hxx"
#include "swtable.hxx"
@@ -41,9 +40,7 @@
#include "rolbck.hxx"
#include "redline.hxx"
#include "docary.hxx"
-
-
-inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); }
+#include <IShellCursorSupplier.hxx>
//------------------------------------------------------------------
@@ -75,21 +72,16 @@ SwUndoSplitNode::SwUndoSplitNode( SwDoc* pDoc, const SwPosition& rPos,
}
}
-
-
-
SwUndoSplitNode::~SwUndoSplitNode()
{
delete pHistory;
delete pRedlData;
}
-
-
-void SwUndoSplitNode::Undo( SwUndoIter& rUndoIter )
+void SwUndoSplitNode::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc* pDoc = &rUndoIter.GetDoc();
- SwPaM& rPam = *rUndoIter.pAktPam;
+ SwDoc *const pDoc = & rContext.GetDoc();
+ SwPaM & rPam( rContext.GetCursorSupplier().CreateNewShellCursor() );
rPam.DeleteMark();
if( bTblFlag )
{
@@ -163,20 +155,13 @@ void SwUndoSplitNode::Undo( SwUndoIter& rUndoIter )
rPam.GetPoint()->nContent.Assign( rPam.GetCntntNode(), nCntnt );
}
-
-void SwUndoSplitNode::Repeat( SwUndoIter& rUndoIter )
+void SwUndoSplitNode::RedoImpl(::sw::UndoRedoContext & rContext)
{
- rUndoIter.GetDoc().SplitNode( *rUndoIter.pAktPam->GetPoint(), bChkTblStt );
-}
-
-
-void SwUndoSplitNode::Redo( SwUndoIter& rUndoIter )
-{
- SwPaM& rPam = *rUndoIter.pAktPam;
- ULONG nOldNode = rPam.GetPoint()->nNode.GetIndex();
+ SwPaM & rPam( rContext.GetCursorSupplier().CreateNewShellCursor() );
rPam.GetPoint()->nNode = nNode;
SwTxtNode * pTNd = rPam.GetNode()->GetTxtNode();
- if( pTNd ) // sollte eigentlich immer ein TextNode sein !!
+ OSL_ENSURE(pTNd, "SwUndoSplitNode::RedoImpl(): SwTxtNode expected");
+ if (pTNd)
{
rPam.GetPoint()->nContent.Assign( pTNd, nCntnt );
@@ -207,7 +192,11 @@ void SwUndoSplitNode::Redo( SwUndoIter& rUndoIter )
rPam.DeleteMark();
}
}
- else
- rPam.GetPoint()->nNode = nOldNode;
+}
+
+void SwUndoSplitNode::RepeatImpl(::sw::RepeatContext & rContext)
+{
+ rContext.GetDoc().SplitNode(
+ *rContext.GetRepeatPaM().GetPoint(), bChkTblStt );
}
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index b96fe8d05440..1f274a7e6c9e 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -81,7 +81,6 @@
#define _DEBUG_REDLINE( pDoc ) lcl_DebugRedline( pDoc );
#endif
-inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); }
extern void ClearFEShellTabCols();
typedef SfxItemSet* SfxItemSetPtr;
@@ -276,9 +275,9 @@ SwUndoInsTbl::~SwUndoInsTbl()
delete pAutoFmt;
}
-void SwUndoInsTbl::Undo( SwUndoIter& rUndoIter )
+void SwUndoInsTbl::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc& rDoc = rUndoIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
SwNodeIndex aIdx( rDoc.GetNodes(), nSttNode );
SwTableNode* pTblNd = aIdx.GetNode().GetTableNode();
@@ -314,19 +313,18 @@ void SwUndoInsTbl::Undo( SwUndoIter& rUndoIter )
rDoc.GetNodes().Delete( aIdx, pTblNd->EndOfSectionIndex() -
aIdx.GetIndex() + 1 );
- rUndoIter.pAktPam->DeleteMark();
- rUndoIter.pAktPam->GetPoint()->nNode = aIdx;
- rUndoIter.pAktPam->GetPoint()->nContent.Assign(
- rUndoIter.pAktPam->GetCntntNode(), 0 );
+ SwPaM & rPam( rContext.GetCursorSupplier().CreateNewShellCursor() );
+ rPam.DeleteMark();
+ rPam.GetPoint()->nNode = aIdx;
+ rPam.GetPoint()->nContent.Assign( rPam.GetCntntNode(), 0 );
}
-void SwUndoInsTbl::Redo( SwUndoIter& rUndoIter )
+void SwUndoInsTbl::RedoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc& rDoc = rUndoIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
- SwPosition aPos( *rUndoIter.pAktPam->GetPoint() );
- aPos.nNode = nSttNode;
+ SwPosition const aPos(SwNodeIndex(rDoc.GetNodes(), nSttNode));
const SwTable* pTbl = rDoc.InsertTable( aInsTblOpts, aPos, nRows, nCols,
nAdjust,
pAutoFmt, pColWidth );
@@ -365,11 +363,11 @@ void SwUndoInsTbl::Redo( SwUndoIter& rUndoIter )
}
-void SwUndoInsTbl::Repeat( SwUndoIter& rUndoIter )
+void SwUndoInsTbl::RepeatImpl(::sw::RepeatContext & rContext)
{
- rUndoIter.GetDoc().InsertTable( aInsTblOpts, *rUndoIter.pAktPam->GetPoint(),
- nRows, nCols, nAdjust,
- pAutoFmt, pColWidth );
+ rContext.GetDoc().InsertTable(
+ aInsTblOpts, *rContext.GetRepeatPaM().GetPoint(),
+ nRows, nCols, nAdjust, pAutoFmt, pColWidth );
}
SwRewriter SwUndoInsTbl::GetRewriter() const
@@ -474,10 +472,10 @@ SwUndoTblToTxt::~SwUndoTblToTxt()
-void SwUndoTblToTxt::Undo( SwUndoIter& rUndoIter )
+void SwUndoTblToTxt::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc& rDoc = rUndoIter.GetDoc();
- SwPaM* pPam = rUndoIter.pAktPam;
+ SwDoc & rDoc = rContext.GetDoc();
+ SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
SwNodeIndex aFrmIdx( rDoc.GetNodes(), nSttNd );
SwNodeIndex aEndIdx( rDoc.GetNodes(), nEndNd );
@@ -654,11 +652,10 @@ SwTableNode* SwNodes::UndoTableToText( ULONG nSttNd, ULONG nEndNd,
}
-void SwUndoTblToTxt::Redo( SwUndoIter& rUndoIter )
+void SwUndoTblToTxt::RedoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc& rDoc = rUndoIter.GetDoc();
- SwPaM* pPam = rUndoIter.pAktPam;
-
+ SwDoc & rDoc = rContext.GetDoc();
+ SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
pPam->GetPoint()->nNode = nSttNd;
pPam->GetPoint()->nContent.Assign( 0, 0 );
@@ -692,19 +689,19 @@ void SwUndoTblToTxt::Redo( SwUndoIter& rUndoIter )
}
-void SwUndoTblToTxt::Repeat( SwUndoIter& rUndoIter )
+void SwUndoTblToTxt::RepeatImpl(::sw::RepeatContext & rContext)
{
- SwTableNode* pTblNd = rUndoIter.pAktPam->GetNode()->FindTableNode();
+ SwPaM *const pPam = & rContext.GetRepeatPaM();
+ SwTableNode *const pTblNd = pPam->GetNode()->FindTableNode();
if( pTblNd )
{
- // bewege den Cursor aus der Tabelle
- SwPaM* pPam = rUndoIter.pAktPam;
+ // move cursor out of table
pPam->GetPoint()->nNode = *pTblNd->EndOfSectionNode();
pPam->Move( fnMoveForward, fnGoCntnt );
pPam->SetMark();
pPam->DeleteMark();
- rUndoIter.GetDoc().TableToText( pTblNd, cTrenner );
+ rContext.GetDoc().TableToText( pTblNd, cTrenner );
}
}
@@ -746,9 +743,9 @@ SwUndoTxtToTbl::~SwUndoTxtToTbl()
delete pAutoFmt;
}
-void SwUndoTxtToTbl::Undo( SwUndoIter& rUndoIter )
+void SwUndoTxtToTbl::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc& rDoc = rUndoIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
ULONG nTblNd = nSttNode;
if( nSttCntnt )
@@ -784,15 +781,16 @@ void SwUndoTxtToTbl::Undo( SwUndoIter& rUndoIter )
SwNodeIndex aEndIdx( *pTNd->EndOfSectionNode() );
rDoc.TableToText( pTNd, 0x0b == cTrenner ? 0x09 : cTrenner );
- // am Start wieder zusammenfuegen ?
- SwPosition* pPos = rUndoIter.pAktPam->GetPoint();
+ // join again at start?
+ SwPaM aPam(rDoc.GetNodes().GetEndOfContent());
+ SwPosition *const pPos = aPam.GetPoint();
if( nSttCntnt )
{
pPos->nNode = nTblNd;
pPos->nContent.Assign(pPos->nNode.GetNode().GetCntntNode(), 0);
- if( rUndoIter.pAktPam->Move( fnMoveBackward, fnGoCntnt))
+ if (aPam.Move(fnMoveBackward, fnGoCntnt))
{
- SwNodeIndex& rIdx = rUndoIter.pAktPam->GetPoint()->nNode;
+ SwNodeIndex & rIdx = aPam.GetPoint()->nNode;
// dann die Crsr/etc. nochmal relativ verschieben
RemoveIdxRel( rIdx.GetIndex()+1, *pPos );
@@ -801,7 +799,7 @@ void SwUndoTxtToTbl::Undo( SwUndoIter& rUndoIter )
}
}
- // am Ende wieder zusammenfuegen ?
+ // join again at end?
if( bSplitEnd )
{
SwNodeIndex& rIdx = pPos->nNode;
@@ -809,8 +807,8 @@ void SwUndoTxtToTbl::Undo( SwUndoIter& rUndoIter )
SwTxtNode* pTxtNd = rIdx.GetNode().GetTxtNode();
if( pTxtNd && pTxtNd->CanJoinNext() )
{
- rUndoIter.pAktPam->GetMark()->nContent.Assign( 0, 0 );
- rUndoIter.pAktPam->GetPoint()->nContent.Assign( 0, 0 );
+ aPam.GetMark()->nContent.Assign( 0, 0 );
+ aPam.GetPoint()->nContent.Assign( 0, 0 );
// dann die Crsr/etc. nochmal relativ verschieben
pPos->nContent.Assign( pTxtNd, pTxtNd->GetTxt().Len() );
@@ -820,30 +818,31 @@ void SwUndoTxtToTbl::Undo( SwUndoIter& rUndoIter )
}
}
- SetPaM( rUndoIter ); // manipulierten Bereich selectieren
+ AddUndoRedoPaM(rContext);
}
-void SwUndoTxtToTbl::Redo( SwUndoIter& rUndoIter )
+void SwUndoTxtToTbl::RedoImpl(::sw::UndoRedoContext & rContext)
{
- SetPaM( rUndoIter );
- RemoveIdxFromRange( *rUndoIter.pAktPam, FALSE );
- SetPaM( rUndoIter );
+ SwPaM & rPam( AddUndoRedoPaM(rContext) );
+ RemoveIdxFromRange(rPam, false);
+ SetPaM(rPam);
- const SwTable* pTable = rUndoIter.GetDoc().TextToTable(
- aInsTblOpts, *rUndoIter.pAktPam, cTrenner,
- nAdjust, pAutoFmt );
+ SwTable const*const pTable = rContext.GetDoc().TextToTable(
+ aInsTblOpts, rPam, cTrenner, nAdjust, pAutoFmt );
((SwFrmFmt*)pTable->GetFrmFmt())->SetName( sTblNm );
}
-void SwUndoTxtToTbl::Repeat( SwUndoIter& rUndoIter )
+void SwUndoTxtToTbl::RepeatImpl(::sw::RepeatContext & rContext)
{
- // keine TABLE IN TABLE
- if( !rUndoIter.pAktPam->GetNode()->FindTableNode() )
- rUndoIter.GetDoc().TextToTable( aInsTblOpts, *rUndoIter.pAktPam,
+ // no Table In Table
+ if (!rContext.GetRepeatPaM().GetNode()->FindTableNode())
+ {
+ rContext.GetDoc().TextToTable( aInsTblOpts, rContext.GetRepeatPaM(),
cTrenner, nAdjust,
pAutoFmt );
+ }
}
void SwUndoTxtToTbl::AddFillBox( const SwTableBox& rBox )
@@ -875,20 +874,18 @@ SwUndoTblHeadline::SwUndoTblHeadline( const SwTable& rTbl, USHORT nOldHdl,
nTblNd = pSttNd->StartOfSectionIndex();
}
-
-void SwUndoTblHeadline::Undo( SwUndoIter& rUndoIter )
+void SwUndoTblHeadline::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc& rDoc = rUndoIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
SwTableNode* pTNd = rDoc.GetNodes()[ nTblNd ]->GetTableNode();
ASSERT( pTNd, "keinen Tabellen-Node gefunden" );
rDoc.SetRowsToRepeat( pTNd->GetTable(), nOldHeadline );
}
-
-void SwUndoTblHeadline::Redo( SwUndoIter& rUndoIter )
+void SwUndoTblHeadline::RedoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc& rDoc = rUndoIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
SwTableNode* pTNd = rDoc.GetNodes()[ nTblNd ]->GetTableNode();
ASSERT( pTNd, "keinen Tabellen-Node gefunden" );
@@ -896,17 +893,18 @@ void SwUndoTblHeadline::Redo( SwUndoIter& rUndoIter )
rDoc.SetRowsToRepeat( pTNd->GetTable(), nNewHeadline );
}
-
-void SwUndoTblHeadline::Repeat( SwUndoIter& rUndoIter )
+void SwUndoTblHeadline::RepeatImpl(::sw::RepeatContext & rContext)
{
- SwTableNode* pTblNd = rUndoIter.pAktPam->GetNode()->FindTableNode();
+ SwTableNode *const pTblNd =
+ rContext.GetRepeatPaM().GetNode()->FindTableNode();
if( pTblNd )
- rUndoIter.GetDoc().SetRowsToRepeat( pTblNd->GetTable(), nNewHeadline );
+ {
+ rContext.GetDoc().SetRowsToRepeat( pTblNd->GetTable(), nNewHeadline );
+ }
}
-/* */
-
+//////////////////////////////////////////////////////////////////////////
_SaveTable::_SaveTable( const SwTable& rTbl, USHORT nLnCnt, BOOL bSaveFml )
@@ -1425,7 +1423,7 @@ void _SaveBox::CreateNew( SwTable& rTbl, SwTableLine& rParent, _SaveTable& rSTbl
}
-/* */
+//////////////////////////////////////////////////////////////////////////
// UndoObject fuer Attribut Aenderung an der Tabelle
@@ -1438,17 +1436,14 @@ SwUndoAttrTbl::SwUndoAttrTbl( const SwTableNode& rTblNd, BOOL bClearTabCols )
pSaveTbl = new _SaveTable( rTblNd.GetTable() );
}
-
SwUndoAttrTbl::~SwUndoAttrTbl()
{
delete pSaveTbl;
}
-
-
-void SwUndoAttrTbl::Undo( SwUndoIter& rUndoIter )
+void SwUndoAttrTbl::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc& rDoc = rUndoIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
SwTableNode* pTblNd = rDoc.GetNodes()[ nSttNode ]->GetTableNode();
ASSERT( pTblNd, "kein TabellenNode" );
@@ -1464,14 +1459,13 @@ void SwUndoAttrTbl::Undo( SwUndoIter& rUndoIter )
ClearFEShellTabCols();
}
-
-void SwUndoAttrTbl::Redo( SwUndoIter& rUndoIter )
+void SwUndoAttrTbl::RedoImpl(::sw::UndoRedoContext & rContext)
{
- Undo( rUndoIter );
+ UndoImpl(rContext);
}
-/* */
+//////////////////////////////////////////////////////////////////////////
// UndoObject fuer AutoFormat an der Tabelle
@@ -1493,7 +1487,6 @@ SwUndoTblAutoFmt::SwUndoTblAutoFmt( const SwTableNode& rTblNd,
}
}
-
SwUndoTblAutoFmt::~SwUndoTblAutoFmt()
{
delete pUndos;
@@ -1509,9 +1502,10 @@ void SwUndoTblAutoFmt::SaveBoxCntnt( const SwTableBox& rBox )
}
-void SwUndoTblAutoFmt::UndoRedo( BOOL bUndo, SwUndoIter& rUndoIter )
+void
+SwUndoTblAutoFmt::UndoRedo(bool const bUndo, ::sw::UndoRedoContext & rContext)
{
- SwDoc& rDoc = rUndoIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
SwTableNode* pTblNd = rDoc.GetNodes()[ nSttNode ]->GetTableNode();
ASSERT( pTblNd, "kein TabellenNode" );
@@ -1523,27 +1517,28 @@ void SwUndoTblAutoFmt::UndoRedo( BOOL bUndo, SwUndoIter& rUndoIter )
if( pUndos && bUndo )
for( USHORT n = pUndos->Count(); n; )
- pUndos->GetObject( --n )->Undo( rUndoIter );
+ {
+ static_cast<SwUndoTblNumFmt*>(pUndos->GetObject( --n ))
+ ->UndoImpl(rContext);
+ }
pSaveTbl->RestoreAttr( pTblNd->GetTable(), !bUndo );
delete pSaveTbl;
pSaveTbl = pOrig;
}
-void SwUndoTblAutoFmt::Undo( SwUndoIter& rUndoIter )
+void SwUndoTblAutoFmt::UndoImpl(::sw::UndoRedoContext & rContext)
{
- UndoRedo( TRUE, rUndoIter );
+ UndoRedo(true, rContext);
}
-
-void SwUndoTblAutoFmt::Redo( SwUndoIter& rUndoIter )
+void SwUndoTblAutoFmt::RedoImpl(::sw::UndoRedoContext & rContext)
{
- UndoRedo( FALSE, rUndoIter );
+ UndoRedo(false, rContext);
}
-/* */
-
+//////////////////////////////////////////////////////////////////////////
SwUndoTblNdsChg::SwUndoTblNdsChg( SwUndoId nAction,
const SwSelBoxes& rBoxes,
@@ -1767,9 +1762,9 @@ void SwUndoTblNdsChg::SaveSection( SwStartNode* pSttNd )
}
-void SwUndoTblNdsChg::Undo( SwUndoIter& rUndoIter )
+void SwUndoTblNdsChg::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc& rDoc = rUndoIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
SwNodeIndex aIdx( rDoc.GetNodes(), nSttNode );
SwTableNode *const pTblNd = aIdx.GetNode().GetTableNode();
@@ -1886,9 +1881,9 @@ void SwUndoTblNdsChg::Undo( SwUndoIter& rUndoIter )
}
-void SwUndoTblNdsChg::Redo( SwUndoIter& rUndoIter )
+void SwUndoTblNdsChg::RedoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc& rDoc = rUndoIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
SwTableNode* pTblNd = rDoc.GetNodes()[ nSttNode ]->GetTableNode();
ASSERT( pTblNd, "kein TabellenNode" );
@@ -2000,8 +1995,7 @@ void SwUndoTblNdsChg::Redo( SwUndoIter& rUndoIter )
}
-/* */
-
+//////////////////////////////////////////////////////////////////////////
SwUndoTblMerge::SwUndoTblMerge( const SwPaM& rTblSel )
: SwUndo( UNDO_TABLE_MERGE ), SwUndRng( rTblSel ), pHistory( 0 )
@@ -2013,7 +2007,6 @@ SwUndoTblMerge::SwUndoTblMerge( const SwPaM& rTblSel )
nTblNode = pTblNd->GetIndex();
}
-
SwUndoTblMerge::~SwUndoTblMerge()
{
delete pSaveTbl;
@@ -2021,10 +2014,9 @@ SwUndoTblMerge::~SwUndoTblMerge()
delete pHistory;
}
-
-void SwUndoTblMerge::Undo( SwUndoIter& rUndoIter )
+void SwUndoTblMerge::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc& rDoc = rUndoIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
SwNodeIndex aIdx( rDoc.GetNodes(), nTblNode );
SwTableNode *const pTblNd = aIdx.GetNode().GetTableNode();
@@ -2096,7 +2088,7 @@ CHECKTABLE(pTblNd->GetTable())
pTxtNd = rDoc.GetNodes()[ pUndo->GetDestSttNode() ]->GetTxtNode();
nDelPos = pUndo->GetDestSttCntnt() - 1;
}
- pUndo->Undo( rUndoIter );
+ pUndo->UndoImpl(rContext);
if( pUndo->IsMoveRange() )
{
// den ueberfluessigen Node loeschen
@@ -2169,7 +2161,7 @@ CHECKTABLE(pTblNd->GetTable())
}
// nTblNode = pTblNd->GetIndex();
- SwPaM* pPam = rUndoIter.pAktPam;
+ SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
pPam->DeleteMark();
pPam->GetPoint()->nNode = nSttNode;
pPam->GetPoint()->nContent.Assign( pPam->GetCntntNode(), nSttCntnt );
@@ -2180,14 +2172,11 @@ CHECKTABLE(pTblNd->GetTable())
ClearFEShellTabCols();
}
-
-void SwUndoTblMerge::Redo( SwUndoIter& rUndoIter )
+void SwUndoTblMerge::RedoImpl(::sw::UndoRedoContext & rContext)
{
- SwPaM* pPam = rUndoIter.pAktPam;
- SwDoc& rDoc = *pPam->GetDoc();
-
- SetPaM( *pPam );
- rDoc.MergeTbl( *pPam );
+ SwDoc & rDoc = rContext.GetDoc();
+ SwPaM & rPam( AddUndoRedoPaM(rContext) );
+ rDoc.MergeTbl(rPam);
}
void SwUndoTblMerge::MoveBoxCntnt( SwDoc* pDoc, SwNodeRange& rRg, SwNodeIndex& rPos )
@@ -2205,7 +2194,6 @@ void SwUndoTblMerge::MoveBoxCntnt( SwDoc* pDoc, SwNodeRange& rRg, SwNodeIndex& r
pMoves->Insert( pUndo, pMoves->Count() );
}
-
void SwUndoTblMerge::SetSelBoxes( const SwSelBoxes& rBoxes )
{
// die Selektion merken
@@ -2236,8 +2224,8 @@ void SwUndoTblMerge::SaveCollection( const SwTableBox& rBox )
pHistory->CopyFmtAttr( *pCNd->GetpSwAttrSet(), aIdx.GetIndex() );
}
-/* */
+//////////////////////////////////////////////////////////////////////////
SwUndoTblNumFmt::SwUndoTblNumFmt( const SwTableBox& rBox,
const SfxItemSet* pNewSet )
@@ -2300,18 +2288,17 @@ SwUndoTblNumFmt::SwUndoTblNumFmt( const SwTableBox& rBox,
DELETEZ( pHistory );
}
-
SwUndoTblNumFmt::~SwUndoTblNumFmt()
{
delete pHistory;
delete pBoxSet;
}
-void SwUndoTblNumFmt::Undo( SwUndoIter& rIter )
+void SwUndoTblNumFmt::UndoImpl(::sw::UndoRedoContext & rContext)
{
ASSERT( pBoxSet, "Where's the stored item set?" )
- SwDoc& rDoc = rIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
SwStartNode* pSttNd = rDoc.GetNodes()[ nNode ]->
FindSttNodeByType( SwTableBoxStartNode );
ASSERT( pSttNd, "ohne StartNode kein TabellenBox" );
@@ -2357,7 +2344,7 @@ void SwUndoTblNumFmt::Undo( SwUndoIter& rIter )
pHistory->SetTmpEnd( nTmpEnd );
}
- SwPaM* pPam = rIter.pAktPam;
+ SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
pPam->DeleteMark();
pPam->GetPoint()->nNode = nNode + 1;
pPam->GetPoint()->nContent.Assign( pTxtNd, 0 );
@@ -2400,15 +2387,15 @@ RedlineModeInternGuard::~RedlineModeInternGuard()
-void SwUndoTblNumFmt::Redo( SwUndoIter& rIter )
+void SwUndoTblNumFmt::RedoImpl(::sw::UndoRedoContext & rContext)
{
// konnte die Box veraendert werden ?
if( !pBoxSet )
return ;
- SwDoc& rDoc = rIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
+ SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
- SwPaM* pPam = rIter.pAktPam;
pPam->DeleteMark();
pPam->GetPoint()->nNode = nNode;
@@ -2500,7 +2487,8 @@ void SwUndoTblNumFmt::SetBox( const SwTableBox& rBox )
nNode = rBox.GetSttIdx();
}
-/* */
+
+//////////////////////////////////////////////////////////////////////////
_UndoTblCpyTbl_Entry::_UndoTblCpyTbl_Entry( const SwTableBox& rBox )
: nBoxIdx( rBox.GetSttIdx() ), nOffset( 0 ),
@@ -2527,9 +2515,9 @@ SwUndoTblCpyTbl::~SwUndoTblCpyTbl()
delete pInsRowUndo;
}
-void SwUndoTblCpyTbl::Undo( SwUndoIter& rIter )
+void SwUndoTblCpyTbl::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc& rDoc = rIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
_DEBUG_REDLINE( &rDoc )
SwTableNode* pTblNd = 0;
@@ -2604,8 +2592,9 @@ void SwUndoTblCpyTbl::Undo( SwUndoIter& rIter )
if( pEntry->pUndo )
{
- pEntry->pUndo->Undo( rIter );
+ pEntry->pUndo->UndoImpl(rContext);
delete pEntry->pUndo;
+ pEntry->pUndo = 0;
}
if( bShiftPam )
{
@@ -2628,8 +2617,9 @@ void SwUndoTblCpyTbl::Undo( SwUndoIter& rIter )
pUndo = new SwUndoDelete( aPam, true );
if( pEntry->pUndo )
{
- pEntry->pUndo->Undo( rIter );
+ pEntry->pUndo->UndoImpl(rContext);
delete pEntry->pUndo;
+ pEntry->pUndo = 0;
}
}
pEntry->pUndo = pUndo;
@@ -2665,17 +2655,21 @@ void SwUndoTblCpyTbl::Undo( SwUndoIter& rIter )
}
if( pInsRowUndo )
- pInsRowUndo->Undo( rIter );
+ {
+ pInsRowUndo->UndoImpl(rContext);
+ }
_DEBUG_REDLINE( &rDoc )
}
-void SwUndoTblCpyTbl::Redo( SwUndoIter& rIter )
+void SwUndoTblCpyTbl::RedoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc& rDoc = rIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
_DEBUG_REDLINE( &rDoc )
if( pInsRowUndo )
- pInsRowUndo->Redo( rIter );
+ {
+ pInsRowUndo->RedoImpl(rContext);
+ }
SwTableNode* pTblNd = 0;
for( USHORT n = 0; n < pArr->Count(); ++n )
@@ -2696,7 +2690,7 @@ void SwUndoTblCpyTbl::Redo( SwUndoIter& rIter )
SwUndo* pUndo = IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() ) ? 0 : new SwUndoDelete( aPam, TRUE );
if( pEntry->pUndo )
{
- pEntry->pUndo->Undo( rIter );
+ pEntry->pUndo->UndoImpl(rContext);
if( IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() ) )
{
// PrepareRedline has to be called with the beginning of the old content
@@ -2704,8 +2698,12 @@ void SwUndoTblCpyTbl::Redo( SwUndoIter& rIter )
// by the Undo operation to this point.
// Otherwise aInsIdx has been moved during the Undo operation
if( pEntry->bJoin )
- pUndo = PrepareRedline( &rDoc, rBox, *rIter.pAktPam->GetPoint(),
+ {
+ SwPaM const& rLastPam =
+ rContext.GetCursorSupplier().GetCurrentShellCursor();
+ pUndo = PrepareRedline( &rDoc, rBox, *rLastPam.GetPoint(),
pEntry->bJoin, true );
+ }
else
{
SwPosition aTmpPos( aInsIdx );
@@ -2713,6 +2711,7 @@ void SwUndoTblCpyTbl::Redo( SwUndoIter& rIter )
}
}
delete pEntry->pUndo;
+ pEntry->pUndo = 0;
}
pEntry->pUndo = pUndo;
// b62341295: Redline for copying tables - End.
@@ -2904,7 +2903,8 @@ BOOL SwUndoTblCpyTbl::IsEmpty() const
return !pInsRowUndo && !pArr->Count();
}
-/* */
+
+//////////////////////////////////////////////////////////////////////////
SwUndoCpyTbl::SwUndoCpyTbl()
: SwUndo( UNDO_CPYTBL ), pDel( 0 ), nTblNode( 0 )
@@ -2916,9 +2916,9 @@ SwUndoCpyTbl::~SwUndoCpyTbl()
delete pDel;
}
-void SwUndoCpyTbl::Undo( SwUndoIter& rIter )
+void SwUndoCpyTbl::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwDoc& rDoc = rIter.GetDoc();
+ SwDoc & rDoc = rContext.GetDoc();
SwTableNode* pTNd = rDoc.GetNodes()[ nTblNode ]->GetTableNode();
// harte SeitenUmbrueche am nachfolgenden Node verschieben
@@ -2941,14 +2941,14 @@ void SwUndoCpyTbl::Undo( SwUndoIter& rIter )
pDel = new SwUndoDelete( aPam, TRUE );
}
-void SwUndoCpyTbl::Redo( SwUndoIter& rIter )
+void SwUndoCpyTbl::RedoImpl(::sw::UndoRedoContext & rContext)
{
- pDel->Undo( rIter );
+ pDel->UndoImpl(rContext);
delete pDel, pDel = 0;
}
-/* */
+//////////////////////////////////////////////////////////////////////////
SwUndoSplitTbl::SwUndoSplitTbl( const SwTableNode& rTblNd,
SwSaveRowSpan* pRowSp, USHORT eMode, BOOL bNewSize )
@@ -2975,10 +2975,10 @@ SwUndoSplitTbl::~SwUndoSplitTbl()
delete mpSaveRowSpan;
}
-void SwUndoSplitTbl::Undo( SwUndoIter& rIter )
+void SwUndoSplitTbl::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwPaM* pPam = rIter.pAktPam;
- SwDoc* pDoc = pPam->GetDoc();
+ SwDoc *const pDoc = & rContext.GetDoc();
+ SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
pPam->DeleteMark();
SwNodeIndex& rIdx = pPam->GetPoint()->nNode;
@@ -3040,10 +3040,10 @@ void SwUndoSplitTbl::Undo( SwUndoIter& rIter )
ClearFEShellTabCols();
}
-void SwUndoSplitTbl::Redo( SwUndoIter& rIter )
+void SwUndoSplitTbl::RedoImpl(::sw::UndoRedoContext & rContext)
{
- SwPaM* pPam = rIter.pAktPam;
- SwDoc* pDoc = pPam->GetDoc();
+ SwDoc *const pDoc = & rContext.GetDoc();
+ SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
pPam->DeleteMark();
pPam->GetPoint()->nNode = nTblNode;
@@ -3052,10 +3052,10 @@ void SwUndoSplitTbl::Redo( SwUndoIter& rIter )
ClearFEShellTabCols();
}
-void SwUndoSplitTbl::Repeat( SwUndoIter& rIter )
+void SwUndoSplitTbl::RepeatImpl(::sw::RepeatContext & rContext)
{
- SwPaM* pPam = rIter.pAktPam;
- SwDoc* pDoc = pPam->GetDoc();
+ SwPaM *const pPam = & rContext.GetRepeatPaM();
+ SwDoc *const pDoc = & rContext.GetDoc();
pDoc->SplitTable( *pPam->GetPoint(), nMode, bCalcNewSize );
ClearFEShellTabCols();
@@ -3070,7 +3070,8 @@ void SwUndoSplitTbl::SaveFormula( SwHistory& rHistory )
pHistory->Move( 0, &rHistory );
}
-/* */
+
+//////////////////////////////////////////////////////////////////////////
SwUndoMergeTbl::SwUndoMergeTbl( const SwTableNode& rTblNd,
const SwTableNode& rDelTblNd,
@@ -3097,10 +3098,10 @@ SwUndoMergeTbl::~SwUndoMergeTbl()
delete pHistory;
}
-void SwUndoMergeTbl::Undo( SwUndoIter& rIter )
+void SwUndoMergeTbl::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwPaM* pPam = rIter.pAktPam;
- SwDoc* pDoc = pPam->GetDoc();
+ SwDoc *const pDoc = & rContext.GetDoc();
+ SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
pPam->DeleteMark();
SwNodeIndex& rIdx = pPam->GetPoint()->nNode;
@@ -3164,10 +3165,10 @@ void SwUndoMergeTbl::Undo( SwUndoIter& rIter )
}
}
-void SwUndoMergeTbl::Redo( SwUndoIter& rIter )
+void SwUndoMergeTbl::RedoImpl(::sw::UndoRedoContext & rContext)
{
- SwPaM* pPam = rIter.pAktPam;
- SwDoc* pDoc = pPam->GetDoc();
+ SwDoc *const pDoc = & rContext.GetDoc();
+ SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
pPam->DeleteMark();
pPam->GetPoint()->nNode = nTblNode;
@@ -3181,10 +3182,10 @@ void SwUndoMergeTbl::Redo( SwUndoIter& rIter )
ClearFEShellTabCols();
}
-void SwUndoMergeTbl::Repeat( SwUndoIter& rIter )
+void SwUndoMergeTbl::RepeatImpl(::sw::RepeatContext & rContext)
{
- SwPaM* pPam = rIter.pAktPam;
- SwDoc* pDoc = pPam->GetDoc();
+ SwDoc *const pDoc = & rContext.GetDoc();
+ SwPaM *const pPam = & rContext.GetRepeatPaM();
pDoc->MergeTable( *pPam->GetPoint(), bWithPrev, nMode );
ClearFEShellTabCols();
@@ -3197,8 +3198,8 @@ void SwUndoMergeTbl::SaveFormula( SwHistory& rHistory )
pHistory->Move( 0, &rHistory );
}
-/* */
+//////////////////////////////////////////////////////////////////////////
void InsertSort( SvUShorts& rArr, USHORT nIdx, USHORT* pInsPos )
{
diff --git a/sw/source/core/undo/untblk.cxx b/sw/source/core/undo/untblk.cxx
index b984d645dbf7..a32ef2c8b443 100644
--- a/sw/source/core/undo/untblk.cxx
+++ b/sw/source/core/undo/untblk.cxx
@@ -171,11 +171,10 @@ SwUndoInserts::~SwUndoInserts()
}
-void SwUndoInserts::Undo( SwUndoIter& rUndoIter )
+void SwUndoInserts::UndoImpl(::sw::UndoRedoContext & rContext)
{
- SwPaM * pPam = rUndoIter.pAktPam;
- SwDoc* pDoc = pPam->GetDoc();
- SetPaM( rUndoIter );
+ SwDoc *const pDoc = & rContext.GetDoc();
+ SwPaM *const pPam = & AddUndoRedoPaM(rContext);
if( IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() ))
pDoc->DeleteRedline( *pPam, true, USHRT_MAX );
@@ -198,7 +197,7 @@ void SwUndoInserts::Undo( SwUndoIter& rUndoIter )
}
RemoveIdxFromRange( *pPam, FALSE );
- SetPaM( rUndoIter );
+ SetPaM(*pPam);
// sind Fussnoten oder CntntFlyFrames im Text ??
nSetPos = pHistory->Count();
@@ -220,7 +219,9 @@ void SwUndoInserts::Undo( SwUndoIter& rUndoIter )
{
ULONG nTmp = pPam->GetPoint()->nNode.GetIndex();
for( USHORT n = pFlyUndos->Count(); n; )
- (*pFlyUndos)[ --n ]->Undo( rUndoIter );
+ {
+ (*pFlyUndos)[ --n ]->UndoImpl(rContext);
+ }
nNdDiff += nTmp - pPam->GetPoint()->nNode.GetIndex();
}
@@ -266,15 +267,12 @@ void SwUndoInserts::Undo( SwUndoIter& rUndoIter )
pHistory->TmpRollback( pDoc, 0, false );
}
}
-
- if( pPam != rUndoIter.pAktPam )
- delete pPam;
}
-void SwUndoInserts::Redo( SwUndoIter& rUndoIter )
+void SwUndoInserts::RedoImpl(::sw::UndoRedoContext & rContext)
{
// setze noch den Cursor auf den Redo-Bereich
- SwPaM* pPam = rUndoIter.pAktPam;
+ SwPaM *const pPam = & AddUndoRedoPaM(rContext);
SwDoc* pDoc = pPam->GetDoc();
pPam->DeleteMark();
pPam->GetPoint()->nNode = nSttNode - nNdDiff;
@@ -320,7 +318,9 @@ void SwUndoInserts::Redo( SwUndoIter& rUndoIter )
if( pFlyUndos )
for( USHORT n = pFlyUndos->Count(); n; )
- (*pFlyUndos)[ --n ]->Redo( rUndoIter );
+ {
+ (*pFlyUndos)[ --n ]->RedoImpl(rContext);
+ }
pHistory->Rollback( pDoc, nSetPos );
@@ -336,16 +336,16 @@ void SwUndoInserts::Redo( SwUndoIter& rUndoIter )
pDoc->SplitRedline( *pPam );
}
-void SwUndoInserts::Repeat( SwUndoIter& rUndoIter )
+void SwUndoInserts::RepeatImpl(::sw::RepeatContext & rContext)
{
- SwPaM aPam( *rUndoIter.pAktPam->GetPoint() );
+ SwPaM aPam( rContext.GetDoc().GetNodes().GetEndOfContent() );
SetPaM( aPam );
- aPam.GetDoc()->CopyRange( aPam, *rUndoIter.pAktPam->GetPoint(), false );
+ SwPaM & rRepeatPaM( rContext.GetRepeatPaM() );
+ aPam.GetDoc()->CopyRange( aPam, *rRepeatPaM.GetPoint(), false );
}
-/* */
-
+//////////////////////////////////////////////////////////////////////////
SwUndoInsDoc::SwUndoInsDoc( const SwPaM& rPam )
: SwUndoInserts( UNDO_INSDOKUMENT, rPam )
diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx
index 5331f1f0e8ae..9caf8e5f5d1e 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -61,7 +61,6 @@
#include <unoredline.hxx>
#include <unomap.hxx>
#include <unoprnms.hxx>
-#include <undobj.hxx>
#include <unoparagraph.hxx>
#include <unocrsrhelper.hxx>
#include <docsh.hxx>
@@ -1427,8 +1426,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException)
m_pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_END, NULL);
if (bIllegalException || bRuntimeException)
{
- SwUndoIter aUndoIter( &aPam, UNDO_EMPTY );
- m_pDoc->GetIDocumentUndoRedo().Undo(aUndoIter);
+ m_pDoc->GetIDocumentUndoRedo().Undo();
if (bIllegalException)
{
lang::IllegalArgumentException aEx;
@@ -1540,8 +1538,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException)
m_pImpl->m_pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_INSERT, NULL);
if (bIllegalException || bRuntimeException)
{
- SwUndoIter aUndoIter( pCursor, UNDO_EMPTY );
- m_pImpl->m_pDoc->GetIDocumentUndoRedo().Undo(aUndoIter);
+ m_pImpl->m_pDoc->GetIDocumentUndoRedo().Undo();
if (bIllegalException)
{
lang::IllegalArgumentException aEx;
@@ -1819,8 +1816,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException)
m_pImpl->m_pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_END, NULL);
if (bIllegalException || bRuntimeException)
{
- SwUndoIter aUndoIter( &aStartPam, UNDO_EMPTY );
- m_pImpl->m_pDoc->GetIDocumentUndoRedo().Undo(aUndoIter);
+ m_pImpl->m_pDoc->GetIDocumentUndoRedo().Undo();
if (bIllegalException)
{
lang::IllegalArgumentException aEx;
@@ -2300,8 +2296,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException)
if(bExcept)
{
- SwUndoIter aUndoIter( &aLastPaM, UNDO_EMPTY );
- m_pImpl->m_pDoc->GetIDocumentUndoRedo().Undo(aUndoIter);
+ m_pImpl->m_pDoc->GetIDocumentUndoRedo().Undo();
throw lang::IllegalArgumentException();
}
diff --git a/sw/source/ui/app/docst.cxx b/sw/source/ui/app/docst.cxx
index 5255a4c3452b..0e05e1893d11 100644
--- a/sw/source/ui/app/docst.cxx
+++ b/sw/source/ui/app/docst.cxx
@@ -766,7 +766,7 @@ USHORT SwDocShell::Edit( const String &rName, const String &rParent, USHORT nFam
{
// #116530#
//pBasePool->Erase( &aTmp );
- GetWrtShell()->Undo(UNDO_EMPTY, 1);
+ GetWrtShell()->Undo(1);
pDoc->GetIDocumentUndoRedo().ClearRedo();
}
diff --git a/sw/source/ui/wrtsh/select.cxx b/sw/source/ui/wrtsh/select.cxx
index 9acf40160bc3..8deacd017970 100644
--- a/sw/source/ui/wrtsh/select.cxx
+++ b/sw/source/ui/wrtsh/select.cxx
@@ -210,7 +210,7 @@ ULONG SwWrtShell::SearchPattern( const SearchOptions& rSearchOpt, BOOL bSearchIn
ULONG nRet = Find( rSearchOpt, bSearchInNotes, eStt, eEnd, bCancel, eFlags, bReplace );
if(bCancel)
{
- Undo(UNDO_EMPTY, 1);
+ Undo(1);
nRet = ULONG_MAX;
}
return nRet;
@@ -238,7 +238,7 @@ ULONG SwWrtShell::SearchTempl( const String &rTempl,
eStt,eEnd, bCancel, eFlags, pReplaceColl);
if(bCancel)
{
- Undo(UNDO_EMPTY, 1);
+ Undo(1);
nRet = ULONG_MAX;
}
return nRet;
@@ -263,7 +263,7 @@ ULONG SwWrtShell::SearchAttr( const SfxItemSet& rFindSet, BOOL bNoColls,
if(bCancel)
{
- Undo(UNDO_EMPTY, 1);
+ Undo(1);
nRet = ULONG_MAX;
}
return nRet;
diff --git a/sw/source/ui/wrtsh/wrtundo.cxx b/sw/source/ui/wrtsh/wrtundo.cxx
index 3e9349c409ba..2f45e528e017 100644
--- a/sw/source/ui/wrtsh/wrtundo.cxx
+++ b/sw/source/ui/wrtsh/wrtundo.cxx
@@ -59,7 +59,7 @@ void SwWrtShell::Do( DoType eDoType, USHORT nCnt )
DoUndo(sal_False); // #i21739#
// Modi zuruecksetzen
EnterStdMode();
- SwEditShell::Undo(UNDO_EMPTY, nCnt );
+ SwEditShell::Undo(nCnt);
break;
case REDO:
DoUndo(sal_False); // #i21739#