1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: undobj.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 #include <tools/mempool.hxx>
34 #define _SVSTDARR_USHORTS
35 #define _SVSTDARR_ULONGS
36 #define _SVSTDARR_BOOLS
37 #define _SVSTDARR_BYTES
38 #define _SVSTDARR_USHORTSSORT
39 #include <svtools/svstdarr.hxx>
41 #include <svtools/itemset.hxx>
42 #include <com/sun/star/uno/Sequence.h>
43 #include <numrule.hxx>
44 #include <itabenum.hxx>
46 #include <SwRewriter.hxx>
47 #include <svx/svdundo.hxx> // #111827#
52 // --> OD 2006-11-01 #130889#
72 class SwHstryBookmark
;
85 struct SwUndoGroupObjImpl
;
95 class SwTableSortBoxes
;
96 class SwUndoSaveSections
;
100 class SwTblToTxtSaves
;
102 class SwRedlineSaveData
;
104 struct SwSaveRowSpan
;
107 class TransliterationWrapper
;
113 #define OUT_UNDOBJ( name ) \
114 friend Writer& OutUndo_ ## name( Writer&, const SwUndo& );
116 #define OUT_UNDOBJ( name )
120 const String
UNDO_ARG1("$1", RTL_TEXTENCODING_ASCII_US
);
121 const String
UNDO_ARG2("$2", RTL_TEXTENCODING_ASCII_US
);
122 const String
UNDO_ARG3("$3", RTL_TEXTENCODING_ASCII_US
);
124 typedef SwRedlineSaveData
* SwRedlineSaveDataPtr
;
125 SV_DECL_PTRARR_DEL( SwRedlineSaveDatas
, SwRedlineSaveDataPtr
, 8, 8 )
130 USHORT nOrigRedlineMode
;
134 mutable String
* pComment
;
136 void RemoveIdxFromSection( SwDoc
&, ULONG nSttIdx
, ULONG
* pEndIdx
= 0 );
137 void RemoveIdxFromRange( SwPaM
& rPam
, BOOL bMoveNext
);
138 void RemoveIdxRel( ULONG
, const SwPosition
& );
140 void SetId( SwUndoId nNew
) { nId
= nNew
; }
142 static BOOL
CanRedlineGroup( SwRedlineSaveDatas
& rCurr
,
143 const SwRedlineSaveDatas
& rCheck
,
148 Returns the rewriter for this object.
150 @return the rewriter for this object
152 virtual SwRewriter
GetRewriter() const;
154 SwUndo( SwUndoId nI
);
157 SwUndoId
GetId() const { return nId
; }
158 virtual SwUndoId
GetEffectiveId() const;
159 virtual void Undo( SwUndoIter
& ) = 0;
160 virtual void Redo( SwUndoIter
& ) = 0;
161 virtual void Repeat( SwUndoIter
& );
165 Returns textual comment for this undo object.
167 The textual comment is created from the resource string
168 corresponding to this object's ID. The rewriter of this object
169 is applied to the resource string to get the final comment.
171 @return textual comment for this undo object
173 virtual String
GetComment() const;
175 // das UndoObject merkt sich, welcher Mode eingeschaltet war.
176 // In Undo/Redo/Repeat wird dann immer auf diesen zurueck geschaltet
177 USHORT
GetRedlineMode() const { return nOrigRedlineMode
; }
178 void SetRedlineMode( USHORT eMode
) { nOrigRedlineMode
= eMode
; }
180 bool IsDelBox() const;
182 // sicher und setze die RedlineDaten
183 static BOOL
FillSaveData( const SwPaM
& rRange
, SwRedlineSaveDatas
& rSData
,
184 BOOL bDelRange
= TRUE
, BOOL bCopyNext
= TRUE
);
185 static BOOL
FillSaveDataForFmt( const SwPaM
& , SwRedlineSaveDatas
& );
186 static void SetSaveData( SwDoc
& rDoc
, const SwRedlineSaveDatas
& rSData
);
187 static BOOL
HasHiddenRedlines( const SwRedlineSaveDatas
& rSData
);
190 typedef USHORT DelCntntType
;
191 namespace nsDelCntntType
193 const DelCntntType DELCNT_FTN
= 0x01;
194 const DelCntntType DELCNT_FLY
= 0x02;
195 const DelCntntType DELCNT_TOC
= 0x04;
196 const DelCntntType DELCNT_BKM
= 0x08;
197 const DelCntntType DELCNT_ALL
= 0x0F;
198 const DelCntntType DELCNT_CHKNOCNTNT
= 0x80;
201 // diese Klasse muss in ein Undo-Object vererbt werden, wenn dieses Inhalt
202 // fuers Redo/Undo ... speichert
203 class SwUndoSaveCntnt
209 // wird fuer das loeschen von Inhalt benoetigt. Fuer das ReDo werden
210 // Inhalte in das UndoNodesArray verschoben. Diese Methoden fuegen
211 // am Ende eines TextNodes ein Trenner fuer die Attribute. Damit werden
212 // Attribute nicht expandiert.
213 // MoveTo.. verschiebt aus dem NodesArray in das UndoNodesArray
214 // MoveFrom.. verschiebt aus dem UndoNodesArray in das NodesArray
215 void MoveToUndoNds( SwPaM
& rPam
,
216 SwNodeIndex
* pNodeIdx
= 0, SwIndex
* pCntIdx
= 0,
217 ULONG
* pEndNdIdx
= 0, xub_StrLen
* pEndCntIdx
= 0 );
218 void MoveFromUndoNds( SwDoc
& rDoc
, ULONG nNodeIdx
, xub_StrLen nCntntIdx
,
220 ULONG
* pEndNdIdx
= 0, xub_StrLen
* pEndCntIdx
= 0 );
222 // diese beiden Methoden bewegen den SPoint vom Pam zurueck/vor. Damit
223 // kann fuer ein Undo/Redo ein Bereich aufgespannt werden. (Der
224 // SPoint liegt dann vor dem manipuliertem Bereich !!)
225 // Das Flag gibt an, ob noch vorm SPoint Inhalt steht.
226 BOOL
MovePtBackward( SwPaM
& rPam
);
227 void MovePtForward( SwPaM
& rPam
, BOOL bMvBkwrd
);
229 // vor dem Move ins UndoNodes-Array muss dafuer gesorgt werden, das
230 // die Inhaltstragenden Attribute aus dem Nodes-Array entfernt werden.
231 void DelCntntIndex( const SwPosition
& pMark
, const SwPosition
& pPoint
,
232 DelCntntType nDelCntntType
= nsDelCntntType::DELCNT_ALL
);
237 OUT_UNDOBJ( SaveCntnt
)
241 // sicher eine vollstaendige Section im Nodes-Array
242 class SwUndoSaveSection
: private SwUndoSaveCntnt
245 SwRedlineSaveDatas
* pRedlSaveData
;
246 ULONG nMvLen
; // Index ins UndoNodes-Array
250 SwNodeIndex
* GetMvSttIdx() const { return pMvStt
; }
251 ULONG
GetMvNodeCnt() const { return nMvLen
; }
255 ~SwUndoSaveSection();
257 void SaveSection( SwDoc
* pDoc
, const SwNodeIndex
& rSttIdx
);
258 void SaveSection( SwDoc
* pDoc
, const SwNodeRange
& rRange
);
259 void RestoreSection( SwDoc
* pDoc
, SwNodeIndex
* pIdx
, USHORT nSectType
);
260 void RestoreSection( SwDoc
* pDoc
, const SwNodeIndex
& rInsPos
);
262 const SwHistory
* GetHistory() const { return pHistory
; }
263 SwHistory
* GetHistory() { return pHistory
; }
264 OUT_UNDOBJ( SaveSection
)
268 // Diese Klasse speichert den Pam als USHORT's und kann diese wieder zu
269 // einem PaM zusammensetzen
273 ULONG nSttNode
, nEndNode
;
274 xub_StrLen nSttCntnt
, nEndCntnt
;
277 SwUndRng( const SwPaM
& );
279 void SetValues( const SwPaM
& rPam
);
280 void SetPaM( SwPaM
&, BOOL bCorrToCntnt
= FALSE
) const;
281 void SetPaM( SwUndoIter
&, BOOL bCorrToCntnt
= FALSE
) const;
285 class SwUndoStart
: public SwUndo
287 // Um innerhalb von Undo zuerkennen, wann ein Start vorliegt, gibt
288 // GetId() immer die UNDO_START zurueck. Die UserId kann ueber
289 // GetUserId() erfragt werden.
291 // fuer die "Verpointerung" von Start- und End-Undos
294 SwRewriter mRewriter
;
297 SwUndoStart( SwUndoId nId
);
298 virtual void Undo( SwUndoIter
& );
299 virtual void Redo( SwUndoIter
& );
300 virtual void Repeat( SwUndoIter
& );
303 virtual String
GetComment() const;
304 void SetRewriter(const SwRewriter
& rRewriter
);
305 virtual SwRewriter
GetRewriter() const;
308 virtual SwUndoId
GetEffectiveId() const;
309 SwUndoId
GetUserId() const { return nUserId
; }
310 // Setzen vom End-Undo-Offset geschieht im Doc::EndUndo
311 USHORT
GetEndOffset() const { return nEndOffset
; }
312 void SetEndOffset( USHORT n
) { nEndOffset
= n
; }
316 class SwUndoEnd
: public SwUndo
318 // Um innerhalb von Undo zuerkennen, wann ein Ende vorliegt, gibt
319 // GetId() immer die UNDO_END zurueck. Die UserId kann ueber
320 // GetUserId() erfragt werden.
322 // fuer die "Verpointerung" von Start- und End-Undos
325 SwRewriter mRewriter
;
328 SwUndoEnd( SwUndoId nId
);
329 virtual void Undo( SwUndoIter
& );
330 virtual void Redo( SwUndoIter
& );
331 virtual void Repeat( SwUndoIter
& );
334 virtual String
GetComment() const;
335 void SetRewriter(const SwRewriter
& rRewriter
);
336 virtual SwRewriter
GetRewriter() const;
339 virtual SwUndoId
GetEffectiveId() const;
340 SwUndoId
GetUserId() const { return nUserId
; }
342 // Setzen vom Start-Undo-Offset geschieht im Doc::EndUndo
343 void SetSttOffset(USHORT _nSttOffSet
) { nSttOffset
= _nSttOffSet
; }
344 USHORT
GetSttOffset() const { return nSttOffset
; }
348 class SwUndoInsert
: public SwUndo
, private SwUndoSaveCntnt
350 SwPosition
*pPos
; // Inhalt fuers Redo
351 String
*pTxt
, *pUndoTxt
;
352 SwRedlineData
* pRedlData
;
354 xub_StrLen nCntnt
, nLen
;
355 BOOL bIsWordDelim
: 1;
358 friend class SwDoc
; // eigentlich nur SwDoc::Insert( String )
359 BOOL
CanGrouping( sal_Unicode cIns
);
360 BOOL
CanGrouping( const SwPosition
& rPos
);
364 void Init(const SwNodeIndex
& rNode
);
365 String
* GetTxtFromDoc() const;
368 SwUndoInsert( const SwNodeIndex
& rNode
, xub_StrLen nCntnt
, xub_StrLen nLen
,
369 BOOL bWDelim
= TRUE
);
370 SwUndoInsert( const SwNodeIndex
& rNode
);
371 virtual ~SwUndoInsert();
373 virtual void Undo( SwUndoIter
& );
374 virtual void Redo( SwUndoIter
& );
375 virtual void Repeat( SwUndoIter
& );
379 Returns rewriter for this undo object.
381 The returned rewriter has the following rule:
383 $1 -> '<inserted text>'
385 <inserted text> is shortened to a length of nUndoStringLength.
387 @return rewriter for this undo object
389 virtual SwRewriter
GetRewriter() const;
391 BOOL
CanGrouping( const SwPosition
&, sal_Unicode cIns
);
394 DECL_FIXEDMEMPOOL_NEWDEL(SwUndoInsert
)
398 class SwUndoDelete
: public SwUndo
, private SwUndRng
, private SwUndoSaveCntnt
400 SwNodeIndex
* pMvStt
; // Position der Nodes im UndoNodes-Array
401 String
*pSttStr
, *pEndStr
;
402 SwRedlineData
* pRedlData
;
403 SwRedlineSaveDatas
* pRedlSaveData
;
408 ULONG nNdDiff
; // Differenz von Nodes vor-nach Delete
409 ULONG nSectDiff
; // Diff. von Nodes vor/nach Move mit SectionNodes
410 ULONG nReplaceDummy
; // Diff. to a temporary dummy object
413 BOOL bGroup
: 1; // TRUE: ist schon eine Gruppe; wird in CanGrouping() ausgwertet !!
414 BOOL bBackSp
: 1; // TRUE: wenn Gruppierung und der Inhalt davor geloescht wird
415 BOOL bJoinNext
: 1; // TRUE: wenn der Bereich von Oben nach unten geht
416 BOOL bTblDelLastNd
: 1; // TRUE: TextNode hinter der Tabelle einf./loeschen
417 BOOL bDelFullPara
: 1; // TRUE: gesamte Nodes wurden geloescht
418 BOOL bResetPgDesc
: 1; // TRUE: am nachfolgenden Node das PgDsc zuruecksetzen
419 BOOL bResetPgBrk
: 1; // TRUE: am nachfolgenden Node das PgBreak zuruecksetzen
420 BOOL bFromTableCopy
: 1; // TRUE: called by SwUndoTblCpyTbl
422 BOOL
SaveCntnt( const SwPosition
* pStt
, const SwPosition
* pEnd
,
423 SwTxtNode
* pSttTxtNd
, SwTxtNode
* pEndTxtNd
);
425 SwUndoDelete( SwPaM
&, BOOL bFullPara
= FALSE
, BOOL bCalledByTblCpy
= FALSE
);
426 virtual ~SwUndoDelete();
427 virtual void Undo( SwUndoIter
& );
428 virtual void Redo( SwUndoIter
& );
429 virtual void Repeat( SwUndoIter
& );
433 Returns rewriter for this undo object.
435 The rewriter consists of the following rule:
437 $1 -> '<deleted text>'
439 <deleted text> is shortened to nUndoStringLength characters.
441 @return rewriter for this undo object
443 virtual SwRewriter
GetRewriter() const;
445 BOOL
CanGrouping( SwDoc
*, const SwPaM
& );
447 void SetTblDelLastNd() { bTblDelLastNd
= TRUE
; }
449 // fuer die PageDesc/PageBreak Attribute einer Tabelle
450 void SetPgBrkFlags( BOOL bPageBreak
, BOOL bPageDesc
)
451 { bResetPgDesc
= bPageDesc
; bResetPgBrk
= bPageBreak
; }
453 void SetTableName(const String
& rName
);
455 // SwUndoTblCpyTbl needs this information:
456 long NodeDiff() const { return nSttNode
- nEndNode
; }
457 xub_StrLen
ContentStart() const { return nSttCntnt
; }
458 BOOL
IsDelFullPara() const { return bDelFullPara
; }
462 DECL_FIXEDMEMPOOL_NEWDEL(SwUndoDelete
)
466 class SwUndoOverwrite
: public SwUndo
, private SwUndoSaveCntnt
468 String aDelStr
, aInsStr
;
469 SwRedlineSaveDatas
* pRedlSaveData
;
471 xub_StrLen nSttCntnt
;
472 BOOL bInsChar
: 1; // kein Overwrite mehr; sondern Insert
473 BOOL bGroup
: 1; // TRUE: ist schon eine Gruppe; wird in
474 // CanGrouping() ausgwertet !!
476 SwUndoOverwrite( SwDoc
*, SwPosition
&, sal_Unicode cIns
);
477 virtual ~SwUndoOverwrite();
478 virtual void Undo( SwUndoIter
& );
479 virtual void Redo( SwUndoIter
& );
480 virtual void Repeat( SwUndoIter
& );
484 Returns the rewriter of this undo object.
486 The rewriter contains the following rule:
488 $1 -> '<overwritten text>'
490 <overwritten text> is shortened to nUndoStringLength characters.
492 @return the rewriter of this undo object
494 virtual SwRewriter
GetRewriter() const;
496 BOOL
CanGrouping( SwDoc
*, SwPosition
&, sal_Unicode cIns
);
497 OUT_UNDOBJ( Overwrite
)
501 class SwUndoSplitNode
: public SwUndo
504 SwRedlineData
* pRedlData
;
510 SwUndoSplitNode( SwDoc
* pDoc
, const SwPosition
& rPos
, BOOL bChkTbl
);
511 virtual ~SwUndoSplitNode();
512 virtual void Undo( SwUndoIter
& );
513 virtual void Redo( SwUndoIter
& );
514 virtual void Repeat( SwUndoIter
& );
515 void SetTblFlag() { bTblFlag
= TRUE
; }
516 OUT_UNDOBJ( SplitNode
)
520 class SwUndoMove
: public SwUndo
, private SwUndRng
, private SwUndoSaveCntnt
522 // nDest.. - Bereich, in den verschoben wurde (nach dem Move!)
523 // nIns.. - Position, von der verschoben wurde und wieder die neue InsPos. ist
524 // nMv.. Position auf die verschoben wird (vor dem Move!) ; fuers REDO
525 ULONG nDestSttNode
, nDestEndNode
, nInsPosNode
, nMvDestNode
;
526 xub_StrLen nDestSttCntnt
, nDestEndCntnt
, nInsPosCntnt
, nMvDestCntnt
;
528 USHORT nFtnStt
; // StartPos der Fussnoten in der History
534 bool bMoveRedlines
; // use DOC_MOVEREDLINES when calling SwDoc::Move
536 void DelFtn( const SwPaM
& );
538 SwUndoMove( const SwPaM
&, const SwPosition
& );
539 SwUndoMove( SwDoc
* pDoc
, const SwNodeRange
&, const SwNodeIndex
& );
540 virtual void Undo( SwUndoIter
& );
541 virtual void Redo( SwUndoIter
& );
542 // setze den Destination-Bereich nach dem Verschieben.
543 void SetDestRange( const SwPaM
&, const SwPosition
&, BOOL
, BOOL
);
544 void SetDestRange( const SwNodeIndex
& rStt
, const SwNodeIndex
& rEnd
,
545 const SwNodeIndex
& rInsPos
);
547 BOOL
IsMoveRange() const { return bMoveRange
; }
548 ULONG
GetEndNode() const { return nEndNode
; }
549 ULONG
GetDestSttNode() const { return nDestSttNode
; }
550 xub_StrLen
GetDestSttCntnt() const { return nDestSttCntnt
; }
551 void AddTblMrgFlyHstry( SwHistory
& rHstr
);
553 void SetMoveRedlines( bool b
) { bMoveRedlines
= b
; }
559 class SwUndoAttr
: public SwUndo
, private SwUndRng
561 SfxItemSet aSet
; // Attribute fuers Redo
562 SwHistory
* pHistory
; // History fuers Undo
563 SwRedlineData
* pRedlData
; // Redlining
564 SwRedlineSaveDatas
* pRedlSaveData
;
565 ULONG nNdIdx
; // fuers Redlining - Offset
566 USHORT nInsFlags
; // Einfuege Flags
568 void RemoveIdx( SwDoc
& rDoc
);
570 SwUndoAttr( const SwPaM
&, const SfxItemSet
&, USHORT nFlags
= 0 );
571 SwUndoAttr( const SwPaM
&, const SfxPoolItem
&, USHORT nFlags
= 0 );
572 virtual ~SwUndoAttr();
573 virtual void Undo( SwUndoIter
& );
574 virtual void Redo( SwUndoIter
& );
575 virtual void Repeat( SwUndoIter
& );
576 SwHistory
* GetHistory() { return pHistory
; }
577 void SaveRedlineData( const SwPaM
& rPam
, BOOL bInsCntnt
);
579 OUT_UNDOBJ( InsAttr
)
582 class SwUndoRstAttr
: public SwUndo
, private SwUndRng
586 USHORT nFmtId
; // Format-Id fuer das Redo
588 SwUndoRstAttr( const SwPaM
&, USHORT nFmtId
);
589 SwUndoRstAttr( const SwDoc
&, const SwPosition
&, USHORT nWhichId
);
590 virtual ~SwUndoRstAttr();
591 virtual void Undo( SwUndoIter
& );
592 virtual void Redo( SwUndoIter
& );
593 virtual void Repeat( SwUndoIter
& );
594 void SetAttrs( const SvUShortsSort
& rArr
);
595 SwHistory
* GetHistory() { return pHistory
; }
596 OUT_UNDOBJ( ResetAttr
)
599 class SwUndoFmtAttr
: public SwUndo
601 friend class SwUndoDefaultAttr
;
603 SfxItemSet
* pOldSet
; // die alten Attribute
605 const USHORT nFmtWhich
;
606 const BOOL bSaveDrawPt
;
608 int IsFmtInDoc( SwDoc
* ); // ist das Attribut-Format noch im Doc ?
609 void SaveFlyAnchor( BOOL bSaveDrawPt
= FALSE
);
610 // --> OD 2004-10-26 #i35443# - Add return value, type <bool>.
611 // Return value indicates, if anchor attribute is restored.
612 // Notes: - If anchor attribute is restored, all other existing attributes
613 // are also restored.
614 // - Anchor attribute isn't restored successfully, if it contains
615 // an invalid anchor position and all other existing attributes
617 // This situation occurs for undo of styles.
618 bool RestoreFlyAnchor( SwUndoIter
& rIter
);
620 // --> OD 2008-02-27 #refactorlists# - removed <rAffectedItemSet>
625 // meldet sich im Format an und sichert sich die alten Attribute
626 // --> OD 2008-02-27 #refactorlists# - removed <rNewSet>
627 SwUndoFmtAttr( const SfxItemSet
& rOldSet
,
629 BOOL bSaveDrawPt
= TRUE
);
631 SwUndoFmtAttr( const SfxPoolItem
& rItem
,
633 BOOL bSaveDrawPt
= TRUE
);
634 virtual ~SwUndoFmtAttr();
635 virtual void Undo( SwUndoIter
& );
636 // --> OD 2004-10-26 #i35443# - <Redo(..)> calls <Undo(..)> - nothing else
637 virtual void Redo( SwUndoIter
& );
639 virtual void Repeat( SwUndoIter
& );
640 virtual SwRewriter
GetRewriter() const;
642 OUT_UNDOBJ( InsFmtAttr
)
644 void PutAttr( const SfxPoolItem
& rItem
);
645 SwFmt
* GetFmt( SwDoc
& rDoc
); // prueft, ob es noch im Doc ist!
648 // --> OD 2008-02-12 #newlistlevelattrs#
649 class SwUndoFmtResetAttr
: public SwUndo
652 SwUndoFmtResetAttr( SwFmt
& rChangedFormat
,
653 const USHORT nWhichId
);
654 ~SwUndoFmtResetAttr();
656 virtual void Undo( SwUndoIter
& );
657 virtual void Redo( SwUndoIter
& );
660 // format at which a certain attribute is reset.
661 SwFmt
* mpChangedFormat
;
662 // which ID of the reset attribute
664 // old attribute which has been reset - needed for undo.
665 SfxPoolItem
* mpOldItem
;
669 class SwUndoDontExpandFmt
: public SwUndo
674 SwUndoDontExpandFmt( const SwPosition
& rPos
);
675 virtual void Undo( SwUndoIter
& );
676 virtual void Redo( SwUndoIter
& );
677 virtual void Repeat( SwUndoIter
& );
680 // Hilfs-Klasse, um die geaenderten Sets zu "empfangen"
681 struct _UndoFmtAttr
: public SwClient
683 SwUndoFmtAttr
* pUndo
;
686 _UndoFmtAttr( SwFmt
& rFmt
, BOOL bSaveDrawPt
= TRUE
);
687 virtual void Modify( SfxPoolItem
*, SfxPoolItem
* );
691 class SwUndoFmtColl
: public SwUndo
, private SwUndRng
696 // --> OD 2008-04-15 #refactorlists# - for correct <ReDo(..)> and <Repeat(..)>
697 // boolean, which indicates that the attributes are reseted at the nodes
698 // before the format has been applied.
700 // boolean, which indicates that the list attributes had been reseted at
701 // the nodes before the format has been applied.
702 const bool mbResetListAttrs
;
705 // --> OD 2008-04-15 #refactorlists#
706 // SwUndoFmtColl( const SwPaM&, SwFmtColl* );
707 SwUndoFmtColl( const SwPaM
&, SwFmtColl
*,
709 const bool bResetListAttrs
);
711 virtual ~SwUndoFmtColl();
712 virtual void Undo( SwUndoIter
& );
713 virtual void Redo( SwUndoIter
& );
714 virtual void Repeat( SwUndoIter
& );
718 Returns the rewriter for this undo object.
720 The rewriter contains one rule:
722 $1 -> <name of format collection>
724 <name of format collection> is the name of the format
725 collection that is applied by the action recorded by this undo
728 @return the rewriter for this undo object
730 virtual SwRewriter
GetRewriter() const;
732 SwHistory
* GetHistory() { return pHistory
; }
733 OUT_UNDOBJ( SetFmtColl
)
737 class SwUndoMoveLeftMargin
: public SwUndo
, private SwUndRng
742 SwUndoMoveLeftMargin( const SwPaM
&, BOOL bRight
, BOOL bModulus
);
743 virtual ~SwUndoMoveLeftMargin();
744 virtual void Undo( SwUndoIter
& );
745 virtual void Redo( SwUndoIter
& );
746 virtual void Repeat( SwUndoIter
& );
747 SwHistory
* GetHistory() { return pHistory
; }
748 OUT_UNDOBJ( MoveLeftMargin
)
751 // Basis-Klasse fuer Insert von Dokument, Glossaries und Kopieren
752 class SwUndoInserts
: public SwUndo
, public SwUndRng
, private SwUndoSaveCntnt
754 SwTxtFmtColl
*pTxtFmtColl
, *pLastNdColl
;
757 SwRedlineData
* pRedlData
;
761 SwPosition
*pPos
; // Inhalt fuers Redo
762 USHORT nSetPos
; // Start in der History-Liste
764 SwUndoInserts( SwUndoId nUndoId
, const SwPaM
& );
766 virtual ~SwUndoInserts();
768 virtual void Undo( SwUndoIter
& );
769 virtual void Redo( SwUndoIter
& );
770 virtual void Repeat( SwUndoIter
& );
771 // setze den Destination-Bereich nach dem Einlesen.
772 void SetInsertRange( const SwPaM
&, BOOL bScanFlys
= TRUE
,
773 BOOL bSttWasTxtNd
= TRUE
);
774 OUT_UNDOBJ( Inserts
)
777 class SwUndoInsDoc
: public SwUndoInserts
780 SwUndoInsDoc( const SwPaM
& );
784 class SwUndoCpyDoc
: public SwUndoInserts
787 SwUndoCpyDoc( const SwPaM
& );
791 class SwUndoInsTbl
: public SwUndo
794 SwInsertTableOptions aInsTblOpts
;
795 SwDDEFieldType
* pDDEFldType
;
796 SvUShorts
* pColWidth
;
797 SwRedlineData
* pRedlData
;
798 SwTableAutoFmt
* pAutoFmt
;
804 SwUndoInsTbl( const SwPosition
&, USHORT nCols
, USHORT nRows
,
805 USHORT eAdjust
, const SwInsertTableOptions
& rInsTblOpts
,
806 const SwTableAutoFmt
* pTAFmt
, const SvUShorts
* pColArr
,
807 const String
& rName
);
808 virtual ~SwUndoInsTbl();
809 virtual void Undo( SwUndoIter
& );
810 virtual void Redo( SwUndoIter
& );
811 virtual void Repeat( SwUndoIter
& );
813 virtual SwRewriter
GetRewriter() const;
815 OUT_UNDOBJ( InsTable
)
818 class SwUndoTxtToTbl
: public SwUndo
, public SwUndRng
821 SwInsertTableOptions aInsTblOpts
;
823 SwTableAutoFmt
* pAutoFmt
;
825 sal_Unicode cTrenner
;
830 SwUndoTxtToTbl( const SwPaM
&, const SwInsertTableOptions
&, sal_Unicode
, USHORT
,
831 const SwTableAutoFmt
* pAFmt
);
832 virtual ~SwUndoTxtToTbl();
834 virtual void Undo( SwUndoIter
& );
835 virtual void Redo( SwUndoIter
& );
836 virtual void Repeat( SwUndoIter
& );
838 SwHistory
& GetHistory(); // wird ggfs. angelegt
839 void AddFillBox( const SwTableBox
& rBox
);
840 OUT_UNDOBJ( TextToTable
)
843 class SwUndoTblToTxt
: public SwUndo
846 SwDDEFieldType
* pDDEFldType
;
847 _SaveTable
* pTblSave
;
848 SwTblToTxtSaves
* pBoxSaves
;
850 ULONG nSttNd
, nEndNd
;
852 sal_Unicode cTrenner
;
854 BOOL bCheckNumFmt
: 1;
857 SwUndoTblToTxt( const SwTable
& rTbl
, sal_Unicode cCh
);
858 virtual ~SwUndoTblToTxt();
859 virtual void Undo( SwUndoIter
& );
860 virtual void Redo( SwUndoIter
& );
861 virtual void Repeat( SwUndoIter
& );
863 void SetRange( const SwNodeRange
& );
864 void AddBoxPos( SwDoc
& rDoc
, ULONG nNdIdx
, ULONG nEndIdx
,
865 xub_StrLen nCntntIdx
= STRING_MAXLEN
);
866 OUT_UNDOBJ( TableToText
)
869 class SwUndoAttrTbl
: public SwUndo
872 _SaveTable
* pSaveTbl
;
873 BOOL bClearTabCol
: 1;
875 SwUndoAttrTbl( const SwTableNode
& rTblNd
, BOOL bClearTabCols
= FALSE
);
876 virtual ~SwUndoAttrTbl();
877 virtual void Undo( SwUndoIter
& );
878 virtual void Redo( SwUndoIter
& );
879 OUT_UNDOBJ( SetTableAttr
)
882 class SwUndoTblAutoFmt
: public SwUndo
885 _SaveTable
* pSaveTbl
;
889 void UndoRedo( BOOL bUndo
, SwUndoIter
& rUndoIter
);
892 SwUndoTblAutoFmt( const SwTableNode
& rTblNd
, const SwTableAutoFmt
& );
893 virtual ~SwUndoTblAutoFmt();
894 virtual void Undo( SwUndoIter
& );
895 virtual void Redo( SwUndoIter
& );
896 void SaveBoxCntnt( const SwTableBox
& rBox
);
897 OUT_UNDOBJ( TableAutoFmt
)
900 class SwUndoTblNdsChg
: public SwUndo
902 _SaveTable
* pSaveTbl
;
906 SvULongs
* pNewSttNds
;
907 SwUndoSaveSections
* pDelSects
;
909 SvBools aMvBoxes
; // fuers SplitRow (aufgeteilte Nodes einer Box)
910 long nMin
, nMax
; // for redo of delete column
911 ULONG nSttNode
, nCurrBox
;
912 USHORT nCount
, nRelDiff
, nAbsDiff
, nSetColType
;
914 BOOL bSameHeight
; // only used for SplitRow
916 SwUndoTblNdsChg( SwUndoId UndoId
,
917 const SwSelBoxes
& rBoxes
,
918 const SwTableNode
& rTblNd
,
920 USHORT nCnt
, BOOL bFlg
, BOOL bSameHeight
);
923 SwUndoTblNdsChg( SwUndoId UndoId
, const SwSelBoxes
& rBoxes
,
924 const SwTableNode
& rTblNd
);
926 virtual ~SwUndoTblNdsChg();
927 virtual void Undo( SwUndoIter
& );
928 virtual void Redo( SwUndoIter
& );
930 void SaveNewBoxes( const SwTableNode
& rTblNd
, const SwTableSortBoxes
& rOld
);
931 void SaveNewBoxes( const SwTableNode
& rTblNd
, const SwTableSortBoxes
& rOld
,
932 const SwSelBoxes
& rBoxes
, const SvULongs
& rNodeCnts
);
933 void SaveSection( SwStartNode
* pSttNd
);
934 void ReNewBoxes( const SwSelBoxes
& rBoxes
);
937 void SetColWidthParam( ULONG nBoxIdx
, USHORT nMode
, USHORT nType
,
938 SwTwips nAbsDif
, SwTwips nRelDif
)
943 nAbsDiff
= (USHORT
)nAbsDif
;
944 nRelDiff
= (USHORT
)nRelDif
;
947 OUT_UNDOBJ( TblNodesChg
)
950 class SwUndoTblMerge
: public SwUndo
, private SwUndRng
953 _SaveTable
* pSaveTbl
;
954 SvULongs aBoxes
, aNewSttNds
;
959 SwUndoTblMerge( const SwPaM
& rTblSel
);
960 virtual ~SwUndoTblMerge();
961 virtual void Undo( SwUndoIter
& );
962 virtual void Redo( SwUndoIter
& );
964 void MoveBoxCntnt( SwDoc
* pDoc
, SwNodeRange
& rRg
, SwNodeIndex
& rPos
);
966 void SetSelBoxes( const SwSelBoxes
& rBoxes
);
968 void AddNewBox( ULONG nSttNdIdx
)
969 { aNewSttNds
.Insert( nSttNdIdx
, aNewSttNds
.Count() ); }
971 void SaveCollection( const SwTableBox
& rBox
);
973 OUT_UNDOBJ( TblMerge
)
977 class SwUndoTblNumFmt
: public SwUndo
981 String aStr
, aNewFml
;
983 ULONG nFmtIdx
, nNewFmtIdx
;
984 double fNum
, fNewNum
;
993 SwUndoTblNumFmt( const SwTableBox
& rBox
, const SfxItemSet
* pNewSet
= 0 );
994 virtual ~SwUndoTblNumFmt();
995 virtual void Undo( SwUndoIter
& );
996 virtual void Redo( SwUndoIter
& );
998 void SetNumFmt( ULONG nNewNumFmtIdx
, const double& rNewNumber
)
999 { nFmtIdx
= nNewNumFmtIdx
; fNum
= rNewNumber
; }
1000 void SetBox( const SwTableBox
& rBox
);
1001 OUT_UNDOBJ( TblNumFmt
)
1004 class _UndoTblCpyTbl_Entries
;
1006 class SwUndoTblCpyTbl
: public SwUndo
1008 _UndoTblCpyTbl_Entries
* pArr
;
1009 SwUndoTblNdsChg
* pInsRowUndo
;
1011 //b6341295: When redlining is active, PrepareRedline has to create the redlining attributes
1012 //for the new and the old table cell content
1013 SwUndo
* PrepareRedline( SwDoc
* pDoc
, const SwTableBox
& rBox
, const SwPosition
& rPos
,
1014 bool& rJoin
, bool bRedo
);
1017 virtual ~SwUndoTblCpyTbl();
1018 virtual void Undo( SwUndoIter
& );
1019 virtual void Redo( SwUndoIter
& );
1021 void AddBoxBefore( const SwTableBox
& rBox
, BOOL bDelCntnt
);
1022 void AddBoxAfter( const SwTableBox
& rBox
, const SwNodeIndex
& rIdx
, BOOL bDelCntnt
);
1024 BOOL
IsEmpty() const;
1025 BOOL
InsertRow( SwTable
& rTbl
, const SwSelBoxes
& rBoxes
, USHORT nCnt
);
1026 OUT_UNDOBJ( TblCpyTbl
)
1029 class SwUndoCpyTbl
: public SwUndo
1035 virtual ~SwUndoCpyTbl();
1036 virtual void Undo( SwUndoIter
& );
1037 virtual void Redo( SwUndoIter
& );
1039 void SetTableSttIdx( ULONG nIdx
) { nTblNode
= nIdx
; }
1040 OUT_UNDOBJ( CpyTbl
)
1043 class SwUndoSplitTbl
: public SwUndo
1045 ULONG nTblNode
, nOffset
;
1046 SwSaveRowSpan
* mpSaveRowSpan
; // stores the row span values at the splitting row
1047 _SaveTable
* pSavTbl
;
1048 SwHistory
* pHistory
;
1049 USHORT nMode
, nFmlEnd
;
1052 SwUndoSplitTbl( const SwTableNode
& rTblNd
, SwSaveRowSpan
* pRowSp
, USHORT nMode
, BOOL bCalcNewSize
);
1053 virtual ~SwUndoSplitTbl();
1054 virtual void Undo( SwUndoIter
& );
1055 virtual void Redo( SwUndoIter
& );
1056 virtual void Repeat( SwUndoIter
& );
1058 void SetTblNodeOffset( ULONG nIdx
) { nOffset
= nIdx
- nTblNode
; }
1059 SwHistory
* GetHistory() { return pHistory
; }
1060 void SaveFormula( SwHistory
& rHistory
);
1063 class SwUndoMergeTbl
: public SwUndo
1067 _SaveTable
* pSavTbl
, *pSavHdl
;
1068 SwHistory
* pHistory
;
1072 SwUndoMergeTbl( const SwTableNode
& rTblNd
, const SwTableNode
& rDelTblNd
,
1073 BOOL bWithPrev
, USHORT nMode
);
1074 virtual ~SwUndoMergeTbl();
1075 virtual void Undo( SwUndoIter
& );
1076 virtual void Redo( SwUndoIter
& );
1077 virtual void Repeat( SwUndoIter
& );
1079 void SaveFormula( SwHistory
& rHistory
);
1083 class SwUndoBookmark
: public SwUndo
1085 SwHstryBookmark
* pHBookmark
;
1087 SwUndoBookmark( SwUndoId nUndoId
, const SwBookmark
& );
1089 void SetInDoc( SwDoc
* );
1090 void ResetInDoc( SwDoc
* );
1093 virtual ~SwUndoBookmark();
1097 Returns the rewriter for this undo object.
1099 The rewriter contains the following rule:
1101 $1 -> <name of bookmark>
1103 <name of bookmark> is the name of the bookmark whose
1104 insertion/deletion is recorded by this undo object.
1106 @return the rewriter for this undo object
1108 virtual SwRewriter
GetRewriter() const;
1112 class SwUndoDelBookmark
: public SwUndoBookmark
1115 SwUndoDelBookmark( const SwBookmark
& );
1116 virtual void Undo( SwUndoIter
& );
1117 virtual void Redo( SwUndoIter
& );
1118 OUT_UNDOBJ( DelBookmark
)
1121 class SwUndoInsBookmark
: public SwUndoBookmark
1124 SwUndoInsBookmark( const SwBookmark
& );
1125 virtual void Undo( SwUndoIter
& );
1126 virtual void Redo( SwUndoIter
& );
1127 OUT_UNDOBJ( InsBookmark
)
1131 /*--------------------------------------------------------------------
1132 Beschreibung: Undo auf Sorting
1133 --------------------------------------------------------------------*/
1135 struct SwSortUndoElement
1140 ULONG nSource
, nTarget
;
1143 String
*pSource
, *pTarget
;
1147 SwSortUndoElement( const String
& aS
, const String
& aT
)
1149 SORT_TXT_TBL
.TBL
.pSource
= new String( aS
);
1150 SORT_TXT_TBL
.TBL
.pTarget
= new String( aT
);
1152 SwSortUndoElement( ULONG nS
, ULONG nT
)
1154 SORT_TXT_TBL
.TXT
.nSource
= nS
;
1155 SORT_TXT_TBL
.TXT
.nTarget
= nT
;
1156 SORT_TXT_TBL
.TXT
.nKenn
= 0xffffffff;
1158 ~SwSortUndoElement();
1161 SV_DECL_PTRARR_DEL(SwSortList
, SwSortUndoElement
*, 10,30)
1162 SV_DECL_PTRARR(SwUndoSortList
, SwNodeIndex
*, 10,30)
1164 class SwUndoSort
: public SwUndo
, private SwUndRng
1166 SwSortOptions
* pSortOpt
; // die Optionen mit den Sortier-Kriterien
1167 SwSortList aSortList
;
1168 SwUndoAttrTbl
* pUndoTblAttr
;
1169 SwRedlineData
* pRedlData
;
1172 void RemoveIdx( SwPaM
& rPam
);
1174 SwUndoSort( const SwPaM
&, const SwSortOptions
& );
1175 SwUndoSort( ULONG nStt
, ULONG nEnd
, const SwTableNode
&,
1176 const SwSortOptions
&, BOOL bSaveTable
);
1177 virtual ~SwUndoSort();
1179 virtual void Undo( SwUndoIter
& );
1180 virtual void Redo( SwUndoIter
& );
1181 virtual void Repeat( SwUndoIter
& );
1183 void Insert( const String
& rOrgPos
, const String
& rNewPos
);
1184 void Insert( ULONG nOrgPos
, ULONG nNewPos
);
1191 //--------------------------------------------------------------------
1193 class SwUndoFlyBase
: public SwUndo
, private SwUndoSaveSection
1196 SwFrmFmt
* pFrmFmt
; // das gespeicherte FlyFormat
1198 xub_StrLen nCntPos
; // Seite/am Absatz/im Absatz
1200 BOOL bDelFmt
; // loesche das gespeicherte Format
1202 void InsFly( SwUndoIter
&, BOOL bShowSel
= TRUE
);
1203 void DelFly( SwDoc
* );
1205 SwUndoFlyBase( SwFrmFmt
* pFormat
, SwUndoId nUndoId
);
1207 SwNodeIndex
* GetMvSttIdx() const { return SwUndoSaveSection::GetMvSttIdx(); }
1208 ULONG
GetMvNodeCnt() const { return SwUndoSaveSection::GetMvNodeCnt(); }
1211 virtual ~SwUndoFlyBase();
1213 virtual void Undo( SwUndoIter
& ) = 0;
1214 virtual void Redo( SwUndoIter
& ) = 0;
1216 OUT_UNDOBJ( FlyBase
)
1219 class SwUndoInsLayFmt
: public SwUndoFlyBase
1221 ULONG mnCrsrSaveIndexPara
; // Cursor position
1222 xub_StrLen mnCrsrSaveIndexPos
; // for undo
1224 SwUndoInsLayFmt( SwFrmFmt
* pFormat
, ULONG nNodeIdx
, xub_StrLen nCntIdx
);
1227 virtual void Undo( SwUndoIter
& );
1228 virtual void Redo( SwUndoIter
& );
1229 virtual void Repeat( SwUndoIter
& );
1231 String
GetComment() const;
1233 OUT_UNDOBJ( InsLayFmt
)
1236 class SwUndoDelLayFmt
: public SwUndoFlyBase
1240 SwUndoDelLayFmt( SwFrmFmt
* pFormat
);
1242 virtual void Undo( SwUndoIter
& );
1243 virtual void Redo( SwUndoIter
& );
1244 void Redo(); // Schnittstelle fuers Rollback
1246 void ChgShowSel( BOOL bNew
) { bShowSelFrm
= bNew
; }
1248 virtual SwRewriter
GetRewriter() const;
1250 OUT_UNDOBJ( DelLayFmt
)
1254 class SwUndoSetFlyFmt
: public SwUndo
, public SwClient
1256 SwFrmFmt
* pFrmFmt
; // das gespeicherte FlyFormat
1257 SwFrmFmt
* pOldFmt
; // die alte Fly Vorlage
1258 SwFrmFmt
* pNewFmt
; // die neue Fly Vorlage
1259 SfxItemSet
* pItemSet
; // die zurueck-/ gesetzten Attribute
1260 ULONG nOldNode
, nNewNode
;
1261 xub_StrLen nOldCntnt
, nNewCntnt
;
1262 USHORT nOldAnchorTyp
, nNewAnchorTyp
;
1265 void PutAttr( USHORT nWhich
, const SfxPoolItem
* pItem
);
1266 void Modify( SfxPoolItem
*, SfxPoolItem
* );
1267 void GetAnchor( SwFmtAnchor
& rAnhor
, ULONG nNode
, xub_StrLen nCntnt
);
1270 SwUndoSetFlyFmt( SwFrmFmt
& rFlyFmt
, SwFrmFmt
& rNewFrmFmt
);
1271 virtual ~SwUndoSetFlyFmt();
1273 virtual void Undo( SwUndoIter
& );
1274 virtual void Redo( SwUndoIter
& );
1276 virtual SwRewriter
GetRewriter() const;
1279 //--------------------------------------------------------------------
1281 class _UnReplaceData
;
1282 SV_DECL_PTRARR_DEL( _UnReplaceDatas
, _UnReplaceData
*, 10, 25 )
1284 class SwUndoReplace
: public SwUndo
1288 BOOL bOldIterFlag
; // Status vom Undo-Iter vorm 1. Aufruf
1289 USHORT nAktPos
; // fuer GetUndoRange und Undo/Redo
1290 _UnReplaceDatas aArr
;
1291 SwRedlineData
* pRedlData
;
1295 virtual ~SwUndoReplace();
1296 virtual void Undo( SwUndoIter
& );
1297 virtual void Redo( SwUndoIter
& );
1301 Returns the rewriter of this undo object.
1303 If this undo object represents several replacements the
1304 rewriter contains the following rules:
1306 $1 -> <number of replacements>
1307 $2 -> occurrences of
1308 $3 -> <replaced text>
1310 If this undo object represents one replacement the rewriter
1311 contains these rules:
1313 $1 -> <replaced text>
1314 $2 -> "->" (STR_YIELDS)
1315 $3 -> <replacing text>
1317 @return the rewriter of this undo object
1319 virtual SwRewriter
GetRewriter() const;
1321 void AddEntry( const SwPaM
& rPam
, const String
& rInsert
, BOOL bRegExp
);
1322 void SetEntryEnd( const SwPaM
& rPam
);
1325 { return ((USHRT_MAX
/ sizeof( void* )) - 50 ) < aArr
.Count(); }
1327 OUT_UNDOBJ( Replace
)
1331 //--------------------------------------------------------------------
1334 class SwUndoTblHeadline
: public SwUndo
1337 USHORT nOldHeadline
;
1338 USHORT nNewHeadline
;
1340 SwUndoTblHeadline( const SwTable
&, USHORT nOldHdl
, USHORT nNewHdl
);
1341 virtual void Undo( SwUndoIter
& );
1342 virtual void Redo( SwUndoIter
& );
1343 virtual void Repeat( SwUndoIter
& );
1344 OUT_UNDOBJ( SwUndoTblHeadline
)
1348 //------------ Undo von Insert-/Delete-Sections ----------------------
1350 class SwUndoInsSection
: public SwUndo
, private SwUndRng
1352 SwHistory
* pHistory
;
1353 SwSection
* pSection
;
1354 SwRedlineData
* pRedlData
;
1357 BOOL bSplitAtStt
: 1;
1358 BOOL bSplitAtEnd
: 1;
1359 BOOL bUpdateFtn
: 1;
1361 void Join( SwDoc
& rDoc
, ULONG nNode
);
1364 SwUndoInsSection( const SwPaM
&, const SwSection
&,
1365 const SfxItemSet
* pSet
);
1366 virtual ~SwUndoInsSection();
1367 virtual void Undo( SwUndoIter
& );
1368 virtual void Redo( SwUndoIter
& );
1369 virtual void Repeat( SwUndoIter
& );
1370 OUT_UNDOBJ( SwUndoInsSection
)
1372 void SetSectNdPos( ULONG nPos
) { nSectNodePos
= nPos
; }
1373 void SaveSplitNode( SwTxtNode
* pTxtNd
, BOOL bAtStt
);
1374 void SetUpdtFtnFlag( BOOL bFlag
) { bUpdateFtn
= bFlag
; }
1377 class SwUndoDelSection
: public SwUndo
1379 ULONG nSttNd
, nEndNd
;
1380 SwSection
* pSection
;
1383 SwUndoDelSection( const SwSectionFmt
& );
1384 virtual ~SwUndoDelSection();
1385 virtual void Undo( SwUndoIter
& );
1386 virtual void Redo( SwUndoIter
& );
1387 OUT_UNDOBJ( SwUndoDelSection
)
1390 class SwUndoChgSection
: public SwUndo
1393 SwSection
* pSection
;
1397 SwUndoChgSection( const SwSectionFmt
&, BOOL bOnlyAttrChgd
);
1398 virtual ~SwUndoChgSection();
1399 virtual void Undo( SwUndoIter
& );
1400 virtual void Redo( SwUndoIter
& );
1401 OUT_UNDOBJ( SwUndoChgSection
)
1404 //------------ Undo von verschieben/stufen von Gliederung ----------------
1406 class SwUndoOutlineLeftRight
: public SwUndo
, private SwUndRng
1410 SwUndoOutlineLeftRight( const SwPaM
& rPam
, short nOffset
);
1411 virtual void Undo( SwUndoIter
& );
1412 virtual void Redo( SwUndoIter
& );
1413 virtual void Repeat( SwUndoIter
& );
1414 OUT_UNDOBJ( SwUndoOutlineLeftRight
)
1417 //--------------------------------------------------------------------
1419 class SwUndoDefaultAttr
: public SwUndo
1421 SfxItemSet
* pOldSet
; // die alten Attribute
1422 SvxTabStopItem
* pTabStop
;
1424 // meldet sich im Format an und sichert sich die alten Attribute
1425 SwUndoDefaultAttr( const SfxItemSet
& rOldSet
);
1426 virtual ~SwUndoDefaultAttr();
1427 virtual void Undo( SwUndoIter
& );
1428 virtual void Redo( SwUndoIter
& );
1429 OUT_UNDOBJ( DefaultAttr
)
1432 //--------------------------------------------------------------------
1433 // ---------- Undo fuer Numerierung ----------------------------------
1435 class SwUndoInsNum
: public SwUndo
, private SwUndRng
1438 SwHistory
* pHistory
;
1440 SwNumRule
* pOldNumRule
;
1441 String sReplaceRule
;
1444 SwUndoInsNum( const SwPaM
& rPam
, const SwNumRule
& rRule
);
1445 SwUndoInsNum( const SwNumRule
& rOldRule
, const SwNumRule
& rNewRule
,
1446 SwUndoId nUndoId
= UNDO_INSFMTATTR
);
1447 SwUndoInsNum( const SwPosition
& rPos
, const SwNumRule
& rRule
,
1448 const String
& rReplaceRule
);
1449 virtual ~SwUndoInsNum();
1450 virtual void Undo( SwUndoIter
& );
1451 virtual void Redo( SwUndoIter
& );
1452 virtual void Repeat( SwUndoIter
& );
1453 virtual SwRewriter
GetRewriter() const;
1455 SwHistory
* GetHistory(); // wird ggfs. neu angelegt!
1456 void SetSttNum( ULONG nNdIdx
) { nSttSet
= nNdIdx
; }
1457 void SaveOldNumRule( const SwNumRule
& rOld
);
1459 void SetLRSpaceEndPos();
1461 OUT_UNDOBJ( InsNum
)
1464 class SwUndoDelNum
: public SwUndo
, private SwUndRng
1468 SvBools aRstLRSpaces
;
1469 SwHistory
* pHistory
;
1471 SwUndoDelNum( const SwPaM
& rPam
);
1472 virtual ~SwUndoDelNum();
1473 virtual void Undo( SwUndoIter
& );
1474 virtual void Redo( SwUndoIter
& );
1475 virtual void Repeat( SwUndoIter
& );
1477 void AddNode( const SwTxtNode
& rNd
, BOOL bResetLRSpace
);
1478 SwHistory
* GetHistory() { return pHistory
; }
1480 OUT_UNDOBJ( DelNum
)
1483 class SwUndoMoveNum
: public SwUndo
, private SwUndRng
1488 SwUndoMoveNum( const SwPaM
& rPam
, long nOffset
, BOOL bIsOutlMv
= FALSE
);
1489 virtual void Undo( SwUndoIter
& );
1490 virtual void Redo( SwUndoIter
& );
1491 virtual void Repeat( SwUndoIter
& );
1492 void SetStartNode( ULONG nValue
) { nNewStt
= nValue
; }
1493 OUT_UNDOBJ( MoveNum
)
1496 class SwUndoNumUpDown
: public SwUndo
, private SwUndRng
1500 SwUndoNumUpDown( const SwPaM
& rPam
, short nOffset
);
1501 virtual void Undo( SwUndoIter
& );
1502 virtual void Redo( SwUndoIter
& );
1503 virtual void Repeat( SwUndoIter
& );
1504 OUT_UNDOBJ( NumUpDown
)
1507 class SwUndoNumOrNoNum
: public SwUndo
1510 BOOL mbNewNum
, mbOldNum
;
1513 SwUndoNumOrNoNum( const SwNodeIndex
& rIdx
, BOOL mbOldNum
,
1515 virtual void Undo( SwUndoIter
& );
1516 virtual void Redo( SwUndoIter
& );
1517 virtual void Repeat( SwUndoIter
& );
1518 OUT_UNDOBJ( NumOrNoNum
)
1521 class SwUndoNumRuleStart
: public SwUndo
1524 USHORT nOldStt
, nNewStt
;
1525 BOOL bSetSttValue
: 1;
1528 SwUndoNumRuleStart( const SwPosition
& rPos
, BOOL bDelete
);
1529 SwUndoNumRuleStart( const SwPosition
& rPos
, USHORT nStt
);
1530 virtual void Undo( SwUndoIter
& );
1531 virtual void Redo( SwUndoIter
& );
1532 virtual void Repeat( SwUndoIter
& );
1533 OUT_UNDOBJ( NumRuleStart
)
1536 //--------------------------------------------------------------------
1537 // ---------- Undo fuer DrawObjecte ----------------------------------
1539 class SwSdrUndo
: public SwUndo
1541 SdrUndoAction
* pSdrUndo
;
1542 SdrMarkList
* pMarkList
; // MarkList for all selected SdrObjects
1544 SwSdrUndo( SdrUndoAction
* , const SdrMarkList
* pMarkList
);
1545 virtual ~SwSdrUndo();
1546 virtual void Undo( SwUndoIter
& );
1547 virtual void Redo( SwUndoIter
& );
1549 String
GetComment() const;
1552 class SwUndoDrawGroup
: public SwUndo
1554 SwUndoGroupObjImpl
* pObjArr
;
1559 SwUndoDrawGroup( USHORT nCnt
);
1560 virtual ~SwUndoDrawGroup();
1561 virtual void Undo( SwUndoIter
& );
1562 virtual void Redo( SwUndoIter
& );
1564 void AddObj( USHORT nPos
, SwDrawFrmFmt
*, SdrObject
* );
1565 void SetGroupFmt( SwDrawFrmFmt
* );
1568 // --> OD 2006-11-01 #130889#
1569 // Action "ungroup drawing object" is now splitted into three parts - see
1570 // method <SwDoc::UnGroupSelection(..)>:
1571 // - creation for <SwDrawFrmFmt> instances for the group members of the
1572 // selected group objects
1573 // - intrinsic ungroup of the selected group objects
1574 // - creation of <SwDrawContact> instances for the former group members and
1575 // connection to the Writer layout.
1576 // Thus, two undo actions (instances of <SwUndo>) are needed:
1577 // - Existing class <SwUndoDrawUnGroup> takes over the part for the formats.
1578 // - New class <SwUndoDrawUnGroupConnectToLayout> takes over the part for
1580 class SwUndoDrawUnGroup
: public SwUndo
1582 SwUndoGroupObjImpl
* pObjArr
;
1587 SwUndoDrawUnGroup( SdrObjGroup
* );
1588 virtual ~SwUndoDrawUnGroup();
1589 virtual void Undo( SwUndoIter
& );
1590 virtual void Redo( SwUndoIter
& );
1592 void AddObj( USHORT nPos
, SwDrawFrmFmt
* );
1595 // --> OD 2006-11-01 #130889#
1596 class SwUndoDrawUnGroupConnectToLayout
: public SwUndo
1599 std::vector
< std::pair
< SwDrawFrmFmt
*, SdrObject
* > > aDrawFmtsAndObjs
;
1602 SwUndoDrawUnGroupConnectToLayout();
1603 virtual ~SwUndoDrawUnGroupConnectToLayout();
1604 virtual void Undo( SwUndoIter
& );
1605 virtual void Redo( SwUndoIter
& );
1607 void AddFmtAndObj( SwDrawFrmFmt
* pDrawFrmFmt
,
1608 SdrObject
* pDrawObject
);
1613 class SwUndoDrawDelete
: public SwUndo
1615 SwUndoGroupObjImpl
* pObjArr
;
1616 SdrMarkList
* pMarkLst
; // MarkList for all selected SdrObjects
1621 SwUndoDrawDelete( USHORT nCnt
);
1622 virtual ~SwUndoDrawDelete();
1623 virtual void Undo( SwUndoIter
& );
1624 virtual void Redo( SwUndoIter
& );
1626 void AddObj( USHORT nPos
, SwDrawFrmFmt
*, const SdrMark
& );
1629 //--------------------------------------------------------------------
1631 class SwUndoReRead
: public SwUndo
1634 String
*pNm
, *pFltr
;
1638 void SaveGraphicData( const SwGrfNode
& );
1639 void SetAndSave( SwUndoIter
& );
1642 SwUndoReRead( const SwPaM
& rPam
, const SwGrfNode
& pGrfNd
);
1643 virtual ~SwUndoReRead();
1645 virtual void Undo( SwUndoIter
& );
1646 virtual void Redo( SwUndoIter
& );
1649 //--------------------------------------------------------------------
1651 class SwUndoInsertLabel
: public SwUndo
1656 SwUndoInsLayFmt
* pUndoFly
;
1657 SwUndoFmtAttr
* pUndoAttr
;
1660 // fuer Tabelle/TextRahmen
1661 SwUndoDelete
* pUndoInsNd
;
1667 // --> PB 2005-01-06 #i39983# - the separator will be drawed with a character style
1670 String sNumberSeparator
;
1671 String sCharacterStyle
;
1672 // OD 2004-04-15 #i26791# - re-store of drawing object position no longer needed
1675 BYTE nLayerId
; // fuer Zeichen-Objekte
1681 SwUndoInsertLabel( const SwLabelType eTyp
, const String
&rText
,
1682 // --> PB 2005-01-06 #i39983# - the separator will be drawed with a character style
1683 const String
& rSeparator
,
1685 const String
& rNumberSeparator
, //#i61007# order of captions
1686 const BOOL bBefore
, const USHORT nId
,
1687 const String
& rCharacterStyle
,
1688 const BOOL bCpyBrd
);
1689 virtual ~SwUndoInsertLabel();
1691 virtual void Undo( SwUndoIter
& );
1692 virtual void Redo( SwUndoIter
& );
1693 virtual void Repeat( SwUndoIter
& );
1697 Returns the rewriter of this undo object.
1699 The rewriter contains this rule:
1701 $1 -> '<text of inserted label>'
1703 <text of inserted label> is shortened to nUndoStringLength
1706 @return the rewriter of this undo object
1708 virtual SwRewriter
GetRewriter() const;
1710 void SetNodePos( ULONG nNd
)
1711 { if( LTYPE_OBJECT
!= eType
) NODE
.nNode
= nNd
; }
1713 void SetUndoKeep() { bUndoKeep
= TRUE
; }
1714 void SetFlys( SwFrmFmt
& rOldFly
, SfxItemSet
& rChgSet
, SwFrmFmt
& rNewFly
);
1715 void SetDrawObj( BYTE nLayerId
);
1718 //--------------------------------------------------------------------
1720 class SwUndoChgFtn
: public SwUndo
, private SwUndRng
1722 SwHistory
* pHistory
;
1727 SwUndoChgFtn( const SwPaM
& rRange
, const String
& rTxt
,
1728 USHORT nNum
, BOOL bIsEndNote
);
1729 virtual ~SwUndoChgFtn();
1731 virtual void Undo( SwUndoIter
& );
1732 virtual void Redo( SwUndoIter
& );
1733 virtual void Repeat( SwUndoIter
& );
1735 SwHistory
* GetHistory() { return pHistory
; }
1738 class SwUndoFtnInfo
: public SwUndo
1740 SwFtnInfo
*pFtnInfo
;
1743 SwUndoFtnInfo( const SwFtnInfo
&rInfo
);
1744 virtual ~SwUndoFtnInfo();
1746 virtual void Undo( SwUndoIter
& );
1747 virtual void Redo( SwUndoIter
& );
1750 class SwUndoEndNoteInfo
: public SwUndo
1752 SwEndNoteInfo
*pEndNoteInfo
;
1755 SwUndoEndNoteInfo( const SwEndNoteInfo
&rInfo
);
1756 virtual ~SwUndoEndNoteInfo();
1758 virtual void Undo( SwUndoIter
& );
1759 virtual void Redo( SwUndoIter
& );
1763 //--------------------------------------------------------------------
1765 struct _UndoTransliterate_Data
;
1766 class SwUndoTransliterate
: public SwUndo
, public SwUndRng
1768 _UndoTransliterate_Data
*pData
, *pLastData
;
1772 SwUndoTransliterate( const SwPaM
& rPam
,
1773 const utl::TransliterationWrapper
& rTrans
);
1774 virtual ~SwUndoTransliterate();
1776 virtual void Undo( SwUndoIter
& rUndoIter
);
1777 virtual void Redo( SwUndoIter
& rUndoIter
);
1778 virtual void Repeat( SwUndoIter
& rUndoIter
);
1780 void AddChanges( const SwTxtNode
& rTNd
, xub_StrLen nStart
, xub_StrLen nLen
,
1781 ::com::sun::star::uno::Sequence
<sal_Int32
>& rOffsets
);
1782 BOOL
HasData() const {return 0 != pData
; }
1785 //--------------------------------------------------------------------
1787 class SwUndoRedline
: public SwUndo
, public SwUndRng
1790 SwRedlineData
* pRedlData
;
1791 SwRedlineSaveDatas
* pRedlSaveData
;
1793 BOOL bHiddenRedlines
;
1795 virtual void _Undo( SwUndoIter
& );
1796 virtual void _Redo( SwUndoIter
& );
1799 SwUndoRedline( SwUndoId nUserId
, const SwPaM
& rRange
);
1800 virtual ~SwUndoRedline();
1801 virtual void Undo( SwUndoIter
& );
1802 virtual void Redo( SwUndoIter
& );
1804 SwUndoId
GetUserId() const { return nUserId
; }
1805 USHORT
GetRedlSaveCount() const
1806 { return pRedlSaveData
? pRedlSaveData
->Count() : 0; }
1809 class SwUndoRedlineDelete
: public SwUndoRedline
1813 BOOL bIsBackspace
: 1;
1815 virtual void _Undo( SwUndoIter
& );
1816 virtual void _Redo( SwUndoIter
& );
1819 SwUndoRedlineDelete( const SwPaM
& rRange
, SwUndoId nUserId
= UNDO_EMPTY
);
1821 BOOL
CanGrouping( const SwUndoRedlineDelete
& rPrev
);
1824 class SwUndoRedlineSort
: public SwUndoRedline
1826 SwSortOptions
* pOpt
;
1827 ULONG nSaveEndNode
, nOffset
;
1828 xub_StrLen nSaveEndCntnt
;
1830 virtual void _Undo( SwUndoIter
& );
1831 virtual void _Redo( SwUndoIter
& );
1834 SwUndoRedlineSort( const SwPaM
& rRange
, const SwSortOptions
& rOpt
);
1835 virtual ~SwUndoRedlineSort();
1836 virtual void Repeat( SwUndoIter
& );
1838 void SetSaveRange( const SwPaM
& rRange
);
1839 void SetOffset( const SwNodeIndex
& rIdx
);
1842 class SwUndoAcceptRedline
: public SwUndoRedline
1844 virtual void _Redo( SwUndoIter
& );
1846 SwUndoAcceptRedline( const SwPaM
& rRange
);
1847 virtual void Repeat( SwUndoIter
& );
1850 class SwUndoRejectRedline
: public SwUndoRedline
1852 virtual void _Redo( SwUndoIter
& );
1854 SwUndoRejectRedline( const SwPaM
& rRange
);
1855 virtual void Repeat( SwUndoIter
& );
1858 //--------------------------------------------------------------------
1860 class SwUndoCompDoc
: public SwUndo
, public SwUndRng
1862 SwRedlineData
* pRedlData
;
1863 SwUndoDelete
* pUnDel
, *pUnDel2
;
1864 SwRedlineSaveDatas
* pRedlSaveData
;
1867 SwUndoCompDoc( const SwPaM
& rRg
, BOOL bIns
);
1868 SwUndoCompDoc( const SwRedline
& rRedl
);
1870 virtual ~SwUndoCompDoc();
1871 virtual void Undo( SwUndoIter
& );
1872 virtual void Redo( SwUndoIter
& );
1876 //--------------------------------------------------------------------
1878 // Object der als Iterator durch die Undo-Liste laeuft, bis die
1879 // letze oder die angegebene Klammerung/Id erreicht ist.
1883 friend class SwDoc
; // um im SwDoc::Undo bWeiter zu stezen
1884 friend void SwUndoEnd::Undo( SwUndoIter
& );
1885 friend void SwUndoStart::Undo( SwUndoIter
& );
1886 friend void SwUndoEnd::Redo( SwUndoIter
& );
1887 friend void SwUndoStart::Redo( SwUndoIter
& );
1888 friend void SwUndoEnd::Repeat( SwUndoIter
& );
1889 friend void SwUndoStart::Repeat( SwUndoIter
& );
1890 friend void SwUndoReplace::Undo( SwUndoIter
& );
1891 friend void SwUndoReplace::Redo( SwUndoIter
& );
1896 BOOL bUpdateAttr
: 1; // Setze das GCAttr an der CursorShell
1899 SwPaM
* pAktPam
; // Member fuer das Undo
1900 SwUndo
* pLastUndoObj
; // fuers Redo, das vorherige UndoObj.
1901 SwFrmFmt
* pSelFmt
; // ggfs. das Format Rahmen/Object-Selektionen
1902 SdrMarkList
* pMarkList
; // MarkList for all selected SdrObjects
1904 SwUndoIter( SwPaM
* pPam
, SwUndoId nId
= UNDO_EMPTY
);
1906 BOOL
IsNextUndo() const { return bWeiter
; }
1907 BOOL
IsUpdateAttr() const { return bUpdateAttr
; }
1908 void SetUpdateAttr( BOOL bNew
) { bUpdateAttr
= bNew
; }
1910 inline SwDoc
& GetDoc() const;
1911 SwUndoId
GetId() const { return nUndoId
; }
1912 SwUndoId
GetLastUndoId() const
1913 { return pLastUndoObj
? pLastUndoObj
->GetId() : UNDO_EMPTY
; }
1914 void ClearSelections() { pSelFmt
= 0; pMarkList
= 0; }
1919 const int nUndoStringLength
= 20;
1922 Shortens a string to a maximum length.
1924 @param rStr the string to be shortened
1925 @param nLength the maximum length for rStr
1926 @param rFillStr string to replace cut out characters with
1928 If rStr has less than nLength characters it will be returned unaltered.
1930 If rStr has more than nLength characters the following algorithm
1931 generates the shortened string:
1933 frontLength = (nLength - length(rFillStr)) / 2
1934 rearLength = nLength - length(rFillStr) - frontLength
1935 shortenedString = concat(<first frontLength characters of rStr,
1937 <last rearLength characters of rStr>)
1940 - nLength - length(rFillStr) >= 2
1942 @return the shortened string
1944 String
ShortenString(const String
& rStr
, xub_StrLen nLength
, const String
& rFillStr
);
1949 Denotes special characters in a string.
1951 The rStr is split into parts containing special characters and
1952 parts not containing special characters. In a part containing
1953 special characters all characters are equal. These parts are
1956 @param rStr the string to denote in
1958 The resulting string is generated by concatenating the found
1959 parts. The parts without special characters are surrounded by
1960 "'". The parts containing special characters are denoted as "n x",
1961 where n is the length of the part and x is the representation of
1962 the special character (i. e. "tab(s)").
1964 @return the denoted string
1966 String
DenoteSpecialCharacters(const String
& rStr
);