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 #include <IDocumentContentOperations.hxx>
53 // --> OD 2006-11-01 #130889#
57 #include <boost/shared_ptr.hpp>
76 class SwHistoryBookmark
;
89 struct SwUndoGroupObjImpl
;
99 class SwTableSortBoxes
;
100 class SwUndoSaveSections
;
104 class SwTblToTxtSaves
;
106 class SwRedlineSaveData
;
108 struct SwSaveRowSpan
;
111 class MetadatableUndo
;
115 class TransliterationWrapper
;
121 #define OUT_UNDOBJ( name ) \
122 friend Writer& OutUndo_ ## name( Writer&, const SwUndo& );
124 #define OUT_UNDOBJ( name )
128 const String
UNDO_ARG1("$1", RTL_TEXTENCODING_ASCII_US
);
129 const String
UNDO_ARG2("$2", RTL_TEXTENCODING_ASCII_US
);
130 const String
UNDO_ARG3("$3", RTL_TEXTENCODING_ASCII_US
);
132 typedef SwRedlineSaveData
* SwRedlineSaveDataPtr
;
133 SV_DECL_PTRARR_DEL( SwRedlineSaveDatas
, SwRedlineSaveDataPtr
, 8, 8 )
138 USHORT nOrigRedlineMode
;
142 mutable String
* pComment
;
144 void RemoveIdxFromSection( SwDoc
&, ULONG nSttIdx
, ULONG
* pEndIdx
= 0 );
145 void RemoveIdxFromRange( SwPaM
& rPam
, BOOL bMoveNext
);
146 void RemoveIdxRel( ULONG
, const SwPosition
& );
148 void SetId( SwUndoId nNew
) { nId
= nNew
; }
150 static BOOL
CanRedlineGroup( SwRedlineSaveDatas
& rCurr
,
151 const SwRedlineSaveDatas
& rCheck
,
156 Returns the rewriter for this object.
158 @return the rewriter for this object
160 virtual SwRewriter
GetRewriter() const;
162 SwUndo( SwUndoId nI
);
165 SwUndoId
GetId() const { return nId
; }
166 virtual SwUndoId
GetEffectiveId() const;
167 virtual void Undo( SwUndoIter
& ) = 0;
168 virtual void Redo( SwUndoIter
& ) = 0;
169 virtual void Repeat( SwUndoIter
& );
173 Returns textual comment for this undo object.
175 The textual comment is created from the resource string
176 corresponding to this object's ID. The rewriter of this object
177 is applied to the resource string to get the final comment.
179 @return textual comment for this undo object
181 virtual String
GetComment() const;
183 // das UndoObject merkt sich, welcher Mode eingeschaltet war.
184 // In Undo/Redo/Repeat wird dann immer auf diesen zurueck geschaltet
185 USHORT
GetRedlineMode() const { return nOrigRedlineMode
; }
186 void SetRedlineMode( USHORT eMode
) { nOrigRedlineMode
= eMode
; }
188 bool IsDelBox() const;
190 // sicher und setze die RedlineDaten
191 static BOOL
FillSaveData( const SwPaM
& rRange
, SwRedlineSaveDatas
& rSData
,
192 BOOL bDelRange
= TRUE
, BOOL bCopyNext
= TRUE
);
193 static BOOL
FillSaveDataForFmt( const SwPaM
& , SwRedlineSaveDatas
& );
194 static void SetSaveData( SwDoc
& rDoc
, const SwRedlineSaveDatas
& rSData
);
195 static BOOL
HasHiddenRedlines( const SwRedlineSaveDatas
& rSData
);
198 typedef USHORT DelCntntType
;
199 namespace nsDelCntntType
201 const DelCntntType DELCNT_FTN
= 0x01;
202 const DelCntntType DELCNT_FLY
= 0x02;
203 const DelCntntType DELCNT_TOC
= 0x04;
204 const DelCntntType DELCNT_BKM
= 0x08;
205 const DelCntntType DELCNT_ALL
= 0x0F;
206 const DelCntntType DELCNT_CHKNOCNTNT
= 0x80;
209 // diese Klasse muss in ein Undo-Object vererbt werden, wenn dieses Inhalt
210 // fuers Redo/Undo ... speichert
211 class SwUndoSaveCntnt
217 // wird fuer das loeschen von Inhalt benoetigt. Fuer das ReDo werden
218 // Inhalte in das UndoNodesArray verschoben. Diese Methoden fuegen
219 // am Ende eines TextNodes ein Trenner fuer die Attribute. Damit werden
220 // Attribute nicht expandiert.
221 // MoveTo.. verschiebt aus dem NodesArray in das UndoNodesArray
222 // MoveFrom.. verschiebt aus dem UndoNodesArray in das NodesArray
223 void MoveToUndoNds( SwPaM
& rPam
,
224 SwNodeIndex
* pNodeIdx
= 0, SwIndex
* pCntIdx
= 0,
225 ULONG
* pEndNdIdx
= 0, xub_StrLen
* pEndCntIdx
= 0 );
226 void MoveFromUndoNds( SwDoc
& rDoc
, ULONG nNodeIdx
, xub_StrLen nCntntIdx
,
228 ULONG
* pEndNdIdx
= 0, xub_StrLen
* pEndCntIdx
= 0 );
230 // diese beiden Methoden bewegen den SPoint vom Pam zurueck/vor. Damit
231 // kann fuer ein Undo/Redo ein Bereich aufgespannt werden. (Der
232 // SPoint liegt dann vor dem manipuliertem Bereich !!)
233 // Das Flag gibt an, ob noch vorm SPoint Inhalt steht.
234 BOOL
MovePtBackward( SwPaM
& rPam
);
235 void MovePtForward( SwPaM
& rPam
, BOOL bMvBkwrd
);
237 // vor dem Move ins UndoNodes-Array muss dafuer gesorgt werden, das
238 // die Inhaltstragenden Attribute aus dem Nodes-Array entfernt werden.
239 void DelCntntIndex( const SwPosition
& pMark
, const SwPosition
& pPoint
,
240 DelCntntType nDelCntntType
= nsDelCntntType::DELCNT_ALL
);
245 OUT_UNDOBJ( SaveCntnt
)
249 // sicher eine vollstaendige Section im Nodes-Array
250 class SwUndoSaveSection
: private SwUndoSaveCntnt
253 SwRedlineSaveDatas
* pRedlSaveData
;
254 ULONG nMvLen
; // Index ins UndoNodes-Array
258 SwNodeIndex
* GetMvSttIdx() const { return pMvStt
; }
259 ULONG
GetMvNodeCnt() const { return nMvLen
; }
263 ~SwUndoSaveSection();
265 void SaveSection( SwDoc
* pDoc
, const SwNodeIndex
& rSttIdx
);
266 void SaveSection( SwDoc
* pDoc
, const SwNodeRange
& rRange
);
267 void RestoreSection( SwDoc
* pDoc
, SwNodeIndex
* pIdx
, USHORT nSectType
);
268 void RestoreSection( SwDoc
* pDoc
, const SwNodeIndex
& rInsPos
);
270 const SwHistory
* GetHistory() const { return pHistory
; }
271 SwHistory
* GetHistory() { return pHistory
; }
272 OUT_UNDOBJ( SaveSection
)
276 // Diese Klasse speichert den Pam als USHORT's und kann diese wieder zu
277 // einem PaM zusammensetzen
281 ULONG nSttNode
, nEndNode
;
282 xub_StrLen nSttCntnt
, nEndCntnt
;
285 SwUndRng( const SwPaM
& );
287 void SetValues( const SwPaM
& rPam
);
288 void SetPaM( SwPaM
&, BOOL bCorrToCntnt
= FALSE
) const;
289 void SetPaM( SwUndoIter
&, BOOL bCorrToCntnt
= FALSE
) const;
293 class SwUndoStart
: public SwUndo
295 // Um innerhalb von Undo zuerkennen, wann ein Start vorliegt, gibt
296 // GetId() immer die UNDO_START zurueck. Die UserId kann ueber
297 // GetUserId() erfragt werden.
299 // fuer die "Verpointerung" von Start- und End-Undos
302 SwRewriter mRewriter
;
305 SwUndoStart( SwUndoId nId
);
306 virtual void Undo( SwUndoIter
& );
307 virtual void Redo( SwUndoIter
& );
308 virtual void Repeat( SwUndoIter
& );
311 virtual String
GetComment() const;
312 void SetRewriter(const SwRewriter
& rRewriter
);
313 virtual SwRewriter
GetRewriter() const;
316 virtual SwUndoId
GetEffectiveId() const;
317 SwUndoId
GetUserId() const { return nUserId
; }
318 // Setzen vom End-Undo-Offset geschieht im Doc::EndUndo
319 USHORT
GetEndOffset() const { return nEndOffset
; }
320 void SetEndOffset( USHORT n
) { nEndOffset
= n
; }
324 class SwUndoEnd
: public SwUndo
326 // Um innerhalb von Undo zuerkennen, wann ein Ende vorliegt, gibt
327 // GetId() immer die UNDO_END zurueck. Die UserId kann ueber
328 // GetUserId() erfragt werden.
330 // fuer die "Verpointerung" von Start- und End-Undos
333 SwRewriter mRewriter
;
336 SwUndoEnd( SwUndoId nId
);
337 virtual void Undo( SwUndoIter
& );
338 virtual void Redo( SwUndoIter
& );
339 virtual void Repeat( SwUndoIter
& );
342 virtual String
GetComment() const;
343 void SetRewriter(const SwRewriter
& rRewriter
);
344 virtual SwRewriter
GetRewriter() const;
347 virtual SwUndoId
GetEffectiveId() const;
348 SwUndoId
GetUserId() const { return nUserId
; }
350 // Setzen vom Start-Undo-Offset geschieht im Doc::EndUndo
351 void SetSttOffset(USHORT _nSttOffSet
) { nSttOffset
= _nSttOffSet
; }
352 USHORT
GetSttOffset() const { return nSttOffset
; }
356 class SwUndoInsert
: public SwUndo
, private SwUndoSaveCntnt
358 SwPosition
*pPos
; // Inhalt fuers Redo
359 String
*pTxt
, *pUndoTxt
;
360 SwRedlineData
* pRedlData
;
362 xub_StrLen nCntnt
, nLen
;
363 BOOL bIsWordDelim
: 1;
366 const IDocumentContentOperations::InsertFlags m_nInsertFlags
;
368 friend class SwDoc
; // eigentlich nur SwDoc::Insert( String )
369 BOOL
CanGrouping( sal_Unicode cIns
);
370 BOOL
CanGrouping( const SwPosition
& rPos
);
374 void Init(const SwNodeIndex
& rNode
);
375 String
* GetTxtFromDoc() const;
378 SwUndoInsert( const SwNodeIndex
& rNode
, xub_StrLen nCntnt
, xub_StrLen nLen
,
379 const IDocumentContentOperations::InsertFlags nInsertFlags
,
380 BOOL bWDelim
= TRUE
);
381 SwUndoInsert( const SwNodeIndex
& rNode
);
382 virtual ~SwUndoInsert();
384 virtual void Undo( SwUndoIter
& );
385 virtual void Redo( SwUndoIter
& );
386 virtual void Repeat( SwUndoIter
& );
390 Returns rewriter for this undo object.
392 The returned rewriter has the following rule:
394 $1 -> '<inserted text>'
396 <inserted text> is shortened to a length of nUndoStringLength.
398 @return rewriter for this undo object
400 virtual SwRewriter
GetRewriter() const;
402 BOOL
CanGrouping( const SwPosition
&, sal_Unicode cIns
);
405 DECL_FIXEDMEMPOOL_NEWDEL(SwUndoInsert
)
409 class SwUndoDelete
: public SwUndo
, private SwUndRng
, private SwUndoSaveCntnt
411 SwNodeIndex
* pMvStt
; // Position der Nodes im UndoNodes-Array
412 String
*pSttStr
, *pEndStr
;
413 SwRedlineData
* pRedlData
;
414 SwRedlineSaveDatas
* pRedlSaveData
;
415 ::boost::shared_ptr
< ::sfx2::MetadatableUndo
> m_pMetadataUndoStart
;
416 ::boost::shared_ptr
< ::sfx2::MetadatableUndo
> m_pMetadataUndoEnd
;
421 ULONG nNdDiff
; // Differenz von Nodes vor-nach Delete
422 ULONG nSectDiff
; // Diff. von Nodes vor/nach Move mit SectionNodes
423 ULONG nReplaceDummy
; // Diff. to a temporary dummy object
426 BOOL bGroup
: 1; // TRUE: ist schon eine Gruppe; wird in CanGrouping() ausgwertet !!
427 BOOL bBackSp
: 1; // TRUE: wenn Gruppierung und der Inhalt davor geloescht wird
428 BOOL bJoinNext
: 1; // TRUE: wenn der Bereich von Oben nach unten geht
429 BOOL bTblDelLastNd
: 1; // TRUE: TextNode hinter der Tabelle einf./loeschen
430 BOOL bDelFullPara
: 1; // TRUE: gesamte Nodes wurden geloescht
431 BOOL bResetPgDesc
: 1; // TRUE: am nachfolgenden Node das PgDsc zuruecksetzen
432 BOOL bResetPgBrk
: 1; // TRUE: am nachfolgenden Node das PgBreak zuruecksetzen
433 BOOL bFromTableCopy
: 1; // TRUE: called by SwUndoTblCpyTbl
435 BOOL
SaveCntnt( const SwPosition
* pStt
, const SwPosition
* pEnd
,
436 SwTxtNode
* pSttTxtNd
, SwTxtNode
* pEndTxtNd
);
438 SwUndoDelete( SwPaM
&, BOOL bFullPara
= FALSE
, BOOL bCalledByTblCpy
= FALSE
);
439 virtual ~SwUndoDelete();
440 virtual void Undo( SwUndoIter
& );
441 virtual void Redo( SwUndoIter
& );
442 virtual void Repeat( SwUndoIter
& );
446 Returns rewriter for this undo object.
448 The rewriter consists of the following rule:
450 $1 -> '<deleted text>'
452 <deleted text> is shortened to nUndoStringLength characters.
454 @return rewriter for this undo object
456 virtual SwRewriter
GetRewriter() const;
458 BOOL
CanGrouping( SwDoc
*, const SwPaM
& );
460 void SetTblDelLastNd() { bTblDelLastNd
= TRUE
; }
462 // fuer die PageDesc/PageBreak Attribute einer Tabelle
463 void SetPgBrkFlags( BOOL bPageBreak
, BOOL bPageDesc
)
464 { bResetPgDesc
= bPageDesc
; bResetPgBrk
= bPageBreak
; }
466 void SetTableName(const String
& rName
);
468 // SwUndoTblCpyTbl needs this information:
469 long NodeDiff() const { return nSttNode
- nEndNode
; }
470 xub_StrLen
ContentStart() const { return nSttCntnt
; }
471 BOOL
IsDelFullPara() const { return bDelFullPara
; }
475 DECL_FIXEDMEMPOOL_NEWDEL(SwUndoDelete
)
479 class SwUndoOverwrite
: public SwUndo
, private SwUndoSaveCntnt
481 String aDelStr
, aInsStr
;
482 SwRedlineSaveDatas
* pRedlSaveData
;
484 xub_StrLen nSttCntnt
;
485 BOOL bInsChar
: 1; // kein Overwrite mehr; sondern Insert
486 BOOL bGroup
: 1; // TRUE: ist schon eine Gruppe; wird in
487 // CanGrouping() ausgwertet !!
489 SwUndoOverwrite( SwDoc
*, SwPosition
&, sal_Unicode cIns
);
490 virtual ~SwUndoOverwrite();
491 virtual void Undo( SwUndoIter
& );
492 virtual void Redo( SwUndoIter
& );
493 virtual void Repeat( SwUndoIter
& );
497 Returns the rewriter of this undo object.
499 The rewriter contains the following rule:
501 $1 -> '<overwritten text>'
503 <overwritten text> is shortened to nUndoStringLength characters.
505 @return the rewriter of this undo object
507 virtual SwRewriter
GetRewriter() const;
509 BOOL
CanGrouping( SwDoc
*, SwPosition
&, sal_Unicode cIns
);
510 OUT_UNDOBJ( Overwrite
)
514 class SwUndoSplitNode
: public SwUndo
517 SwRedlineData
* pRedlData
;
523 SwUndoSplitNode( SwDoc
* pDoc
, const SwPosition
& rPos
, BOOL bChkTbl
);
524 virtual ~SwUndoSplitNode();
525 virtual void Undo( SwUndoIter
& );
526 virtual void Redo( SwUndoIter
& );
527 virtual void Repeat( SwUndoIter
& );
528 void SetTblFlag() { bTblFlag
= TRUE
; }
529 OUT_UNDOBJ( SplitNode
)
533 class SwUndoMove
: public SwUndo
, private SwUndRng
, private SwUndoSaveCntnt
535 // nDest.. - Bereich, in den verschoben wurde (nach dem Move!)
536 // nIns.. - Position, von der verschoben wurde und wieder die neue InsPos. ist
537 // nMv.. Position auf die verschoben wird (vor dem Move!) ; fuers REDO
538 ULONG nDestSttNode
, nDestEndNode
, nInsPosNode
, nMvDestNode
;
539 xub_StrLen nDestSttCntnt
, nDestEndCntnt
, nInsPosCntnt
, nMvDestCntnt
;
541 USHORT nFtnStt
; // StartPos der Fussnoten in der History
547 bool bMoveRedlines
; // use DOC_MOVEREDLINES when calling SwDoc::Move
549 void DelFtn( const SwPaM
& );
551 SwUndoMove( const SwPaM
&, const SwPosition
& );
552 SwUndoMove( SwDoc
* pDoc
, const SwNodeRange
&, const SwNodeIndex
& );
553 virtual void Undo( SwUndoIter
& );
554 virtual void Redo( SwUndoIter
& );
555 // setze den Destination-Bereich nach dem Verschieben.
556 void SetDestRange( const SwPaM
&, const SwPosition
&, BOOL
, BOOL
);
557 void SetDestRange( const SwNodeIndex
& rStt
, const SwNodeIndex
& rEnd
,
558 const SwNodeIndex
& rInsPos
);
560 BOOL
IsMoveRange() const { return bMoveRange
; }
561 ULONG
GetEndNode() const { return nEndNode
; }
562 ULONG
GetDestSttNode() const { return nDestSttNode
; }
563 xub_StrLen
GetDestSttCntnt() const { return nDestSttCntnt
; }
564 void AddTblMrgFlyHstry( SwHistory
& rHstr
);
566 void SetMoveRedlines( bool b
) { bMoveRedlines
= b
; }
572 class SwUndoAttr
: public SwUndo
, private SwUndRng
574 SfxItemSet m_AttrSet
; // attributes for Redo
575 const ::std::auto_ptr
<SwHistory
> m_pHistory
; // History for Undo
576 ::std::auto_ptr
<SwRedlineData
> m_pRedlineData
; // Redlining
577 ::std::auto_ptr
<SwRedlineSaveDatas
> m_pRedlineSaveData
;
578 ULONG m_nNodeIndex
; // Offset: for Redlining
579 const SetAttrMode m_nInsertFlags
; // insert flags
581 void RemoveIdx( SwDoc
& rDoc
);
584 SwUndoAttr( const SwPaM
&, const SfxItemSet
&, const SetAttrMode nFlags
);
585 SwUndoAttr( const SwPaM
&, const SfxPoolItem
&, const SetAttrMode nFlags
);
586 virtual ~SwUndoAttr();
587 virtual void Undo( SwUndoIter
& );
588 virtual void Redo( SwUndoIter
& );
589 virtual void Repeat( SwUndoIter
& );
590 void SaveRedlineData( const SwPaM
& rPam
, BOOL bInsCntnt
);
592 SwHistory
& GetHistory() { return *m_pHistory
; }
594 OUT_UNDOBJ( InsAttr
)
597 class SwUndoResetAttr
: public SwUndo
, private SwUndRng
599 const ::std::auto_ptr
<SwHistory
> m_pHistory
;
601 const USHORT m_nFormatId
; // Format-Id for Redo
604 SwUndoResetAttr( const SwPaM
&, USHORT nFmtId
);
605 SwUndoResetAttr( const SwPosition
&, USHORT nFmtId
);
606 virtual ~SwUndoResetAttr();
607 virtual void Undo( SwUndoIter
& );
608 virtual void Redo( SwUndoIter
& );
609 virtual void Repeat( SwUndoIter
& );
610 void SetAttrs( const SvUShortsSort
& rArr
);
612 SwHistory
& GetHistory() { return *m_pHistory
; }
614 OUT_UNDOBJ( ResetAttr
)
617 class SwUndoFmtAttr
: public SwUndo
619 friend class SwUndoDefaultAttr
;
621 ::std::auto_ptr
<SfxItemSet
> m_pOldSet
; // old attributes
623 const USHORT m_nFmtWhich
;
624 const bool m_bSaveDrawPt
;
626 bool IsFmtInDoc( SwDoc
* ); //is the attribute format still in the Doc?
627 void SaveFlyAnchor( bool bSaveDrawPt
= false );
628 // --> OD 2004-10-26 #i35443# - Add return value, type <bool>.
629 // Return value indicates, if anchor attribute is restored.
630 // Notes: - If anchor attribute is restored, all other existing attributes
631 // are also restored.
632 // - Anchor attribute isn't restored successfully, if it contains
633 // an invalid anchor position and all other existing attributes
635 // This situation occurs for undo of styles.
636 bool RestoreFlyAnchor( SwUndoIter
& rIter
);
638 // --> OD 2008-02-27 #refactorlists# - removed <rAffectedItemSet>
643 // register at the Format and save old attributes
644 // --> OD 2008-02-27 #refactorlists# - removed <rNewSet>
645 SwUndoFmtAttr( const SfxItemSet
& rOldSet
,
647 bool bSaveDrawPt
= true );
649 SwUndoFmtAttr( const SfxPoolItem
& rItem
,
651 bool bSaveDrawPt
= true );
652 virtual ~SwUndoFmtAttr();
653 virtual void Undo( SwUndoIter
& );
654 // --> OD 2004-10-26 #i35443# - <Redo(..)> calls <Undo(..)> - nothing else
655 virtual void Redo( SwUndoIter
& );
657 virtual void Repeat( SwUndoIter
& );
658 virtual SwRewriter
GetRewriter() const;
660 OUT_UNDOBJ( InsFmtAttr
)
662 void PutAttr( const SfxPoolItem
& rItem
);
663 SwFmt
* GetFmt( SwDoc
& rDoc
); // checks if it is still in the Doc!
666 // --> OD 2008-02-12 #newlistlevelattrs#
667 class SwUndoFmtResetAttr
: public SwUndo
670 SwUndoFmtResetAttr( SwFmt
& rChangedFormat
,
671 const USHORT nWhichId
);
672 ~SwUndoFmtResetAttr();
674 virtual void Undo( SwUndoIter
& );
675 virtual void Redo( SwUndoIter
& );
678 // format at which a certain attribute is reset.
679 SwFmt
* const m_pChangedFormat
;
680 // which ID of the reset attribute
681 const USHORT m_nWhichId
;
682 // old attribute which has been reset - needed for undo.
683 ::std::auto_ptr
<SfxPoolItem
> m_pOldItem
;
687 class SwUndoDontExpandFmt
: public SwUndo
689 const ULONG m_nNodeIndex
;
690 const xub_StrLen m_nContentIndex
;
693 SwUndoDontExpandFmt( const SwPosition
& rPos
);
694 virtual void Undo( SwUndoIter
& );
695 virtual void Redo( SwUndoIter
& );
696 virtual void Repeat( SwUndoIter
& );
699 // helper class to receive changed attribute sets
700 class SwUndoFmtAttrHelper
: public SwClient
702 ::std::auto_ptr
<SwUndoFmtAttr
> m_pUndo
;
703 const bool m_bSaveDrawPt
;
706 SwUndoFmtAttrHelper( SwFmt
& rFmt
, bool bSaveDrawPt
= true );
708 virtual void Modify( SfxPoolItem
*, SfxPoolItem
* );
710 SwUndoFmtAttr
* GetUndo() const { return m_pUndo
.get(); }
711 // release the undo object (so it is not deleted here), and return it
712 SwUndoFmtAttr
* ReleaseUndo() { return m_pUndo
.release(); }
716 class SwUndoFmtColl
: public SwUndo
, private SwUndRng
721 // --> OD 2008-04-15 #refactorlists# - for correct <ReDo(..)> and <Repeat(..)>
722 // boolean, which indicates that the attributes are reseted at the nodes
723 // before the format has been applied.
725 // boolean, which indicates that the list attributes had been reseted at
726 // the nodes before the format has been applied.
727 const bool mbResetListAttrs
;
730 // --> OD 2008-04-15 #refactorlists#
731 // SwUndoFmtColl( const SwPaM&, SwFmtColl* );
732 SwUndoFmtColl( const SwPaM
&, SwFmtColl
*,
734 const bool bResetListAttrs
);
736 virtual ~SwUndoFmtColl();
737 virtual void Undo( SwUndoIter
& );
738 virtual void Redo( SwUndoIter
& );
739 virtual void Repeat( SwUndoIter
& );
743 Returns the rewriter for this undo object.
745 The rewriter contains one rule:
747 $1 -> <name of format collection>
749 <name of format collection> is the name of the format
750 collection that is applied by the action recorded by this undo
753 @return the rewriter for this undo object
755 virtual SwRewriter
GetRewriter() const;
757 SwHistory
* GetHistory() { return pHistory
; }
758 OUT_UNDOBJ( SetFmtColl
)
762 class SwUndoMoveLeftMargin
: public SwUndo
, private SwUndRng
764 const ::std::auto_ptr
<SwHistory
> m_pHistory
;
765 const bool m_bModulus
;
768 SwUndoMoveLeftMargin( const SwPaM
&, BOOL bRight
, BOOL bModulus
);
769 virtual ~SwUndoMoveLeftMargin();
770 virtual void Undo( SwUndoIter
& );
771 virtual void Redo( SwUndoIter
& );
772 virtual void Repeat( SwUndoIter
& );
774 SwHistory
& GetHistory() { return *m_pHistory
; }
776 OUT_UNDOBJ( MoveLeftMargin
)
779 // Basis-Klasse fuer Insert von Dokument, Glossaries und Kopieren
780 class SwUndoInserts
: public SwUndo
, public SwUndRng
, private SwUndoSaveCntnt
782 SwTxtFmtColl
*pTxtFmtColl
, *pLastNdColl
;
785 SwRedlineData
* pRedlData
;
789 SwPosition
*pPos
; // Inhalt fuers Redo
790 USHORT nSetPos
; // Start in der History-Liste
792 SwUndoInserts( SwUndoId nUndoId
, const SwPaM
& );
794 virtual ~SwUndoInserts();
796 virtual void Undo( SwUndoIter
& );
797 virtual void Redo( SwUndoIter
& );
798 virtual void Repeat( SwUndoIter
& );
799 // setze den Destination-Bereich nach dem Einlesen.
800 void SetInsertRange( const SwPaM
&, BOOL bScanFlys
= TRUE
,
801 BOOL bSttWasTxtNd
= TRUE
);
802 OUT_UNDOBJ( Inserts
)
805 class SwUndoInsDoc
: public SwUndoInserts
808 SwUndoInsDoc( const SwPaM
& );
812 class SwUndoCpyDoc
: public SwUndoInserts
815 SwUndoCpyDoc( const SwPaM
& );
819 class SwUndoInsTbl
: public SwUndo
822 SwInsertTableOptions aInsTblOpts
;
823 SwDDEFieldType
* pDDEFldType
;
824 SvUShorts
* pColWidth
;
825 SwRedlineData
* pRedlData
;
826 SwTableAutoFmt
* pAutoFmt
;
832 SwUndoInsTbl( const SwPosition
&, USHORT nCols
, USHORT nRows
,
833 USHORT eAdjust
, const SwInsertTableOptions
& rInsTblOpts
,
834 const SwTableAutoFmt
* pTAFmt
, const SvUShorts
* pColArr
,
835 const String
& rName
);
836 virtual ~SwUndoInsTbl();
837 virtual void Undo( SwUndoIter
& );
838 virtual void Redo( SwUndoIter
& );
839 virtual void Repeat( SwUndoIter
& );
841 virtual SwRewriter
GetRewriter() const;
843 OUT_UNDOBJ( InsTable
)
846 class SwUndoTxtToTbl
: public SwUndo
, public SwUndRng
849 SwInsertTableOptions aInsTblOpts
;
851 SwTableAutoFmt
* pAutoFmt
;
853 sal_Unicode cTrenner
;
858 SwUndoTxtToTbl( const SwPaM
&, const SwInsertTableOptions
&, sal_Unicode
, USHORT
,
859 const SwTableAutoFmt
* pAFmt
);
860 virtual ~SwUndoTxtToTbl();
862 virtual void Undo( SwUndoIter
& );
863 virtual void Redo( SwUndoIter
& );
864 virtual void Repeat( SwUndoIter
& );
866 SwHistory
& GetHistory(); // wird ggfs. angelegt
867 void AddFillBox( const SwTableBox
& rBox
);
868 OUT_UNDOBJ( TextToTable
)
871 class SwUndoTblToTxt
: public SwUndo
874 SwDDEFieldType
* pDDEFldType
;
875 _SaveTable
* pTblSave
;
876 SwTblToTxtSaves
* pBoxSaves
;
878 ULONG nSttNd
, nEndNd
;
880 sal_Unicode cTrenner
;
882 BOOL bCheckNumFmt
: 1;
885 SwUndoTblToTxt( const SwTable
& rTbl
, sal_Unicode cCh
);
886 virtual ~SwUndoTblToTxt();
887 virtual void Undo( SwUndoIter
& );
888 virtual void Redo( SwUndoIter
& );
889 virtual void Repeat( SwUndoIter
& );
891 void SetRange( const SwNodeRange
& );
892 void AddBoxPos( SwDoc
& rDoc
, ULONG nNdIdx
, ULONG nEndIdx
,
893 xub_StrLen nCntntIdx
= STRING_MAXLEN
);
894 OUT_UNDOBJ( TableToText
)
897 class SwUndoAttrTbl
: public SwUndo
900 _SaveTable
* pSaveTbl
;
901 BOOL bClearTabCol
: 1;
903 SwUndoAttrTbl( const SwTableNode
& rTblNd
, BOOL bClearTabCols
= FALSE
);
904 virtual ~SwUndoAttrTbl();
905 virtual void Undo( SwUndoIter
& );
906 virtual void Redo( SwUndoIter
& );
907 OUT_UNDOBJ( SetTableAttr
)
910 class SwUndoTblAutoFmt
: public SwUndo
913 _SaveTable
* pSaveTbl
;
917 void UndoRedo( BOOL bUndo
, SwUndoIter
& rUndoIter
);
920 SwUndoTblAutoFmt( const SwTableNode
& rTblNd
, const SwTableAutoFmt
& );
921 virtual ~SwUndoTblAutoFmt();
922 virtual void Undo( SwUndoIter
& );
923 virtual void Redo( SwUndoIter
& );
924 void SaveBoxCntnt( const SwTableBox
& rBox
);
925 OUT_UNDOBJ( TableAutoFmt
)
928 class SwUndoTblNdsChg
: public SwUndo
930 _SaveTable
* pSaveTbl
;
934 SvULongs
* pNewSttNds
;
935 SwUndoSaveSections
* pDelSects
;
937 SvBools aMvBoxes
; // fuers SplitRow (aufgeteilte Nodes einer Box)
938 long nMin
, nMax
; // for redo of delete column
939 ULONG nSttNode
, nCurrBox
;
940 USHORT nCount
, nRelDiff
, nAbsDiff
, nSetColType
;
942 BOOL bSameHeight
; // only used for SplitRow
944 SwUndoTblNdsChg( SwUndoId UndoId
,
945 const SwSelBoxes
& rBoxes
,
946 const SwTableNode
& rTblNd
,
948 USHORT nCnt
, BOOL bFlg
, BOOL bSameHeight
);
951 SwUndoTblNdsChg( SwUndoId UndoId
, const SwSelBoxes
& rBoxes
,
952 const SwTableNode
& rTblNd
);
954 virtual ~SwUndoTblNdsChg();
955 virtual void Undo( SwUndoIter
& );
956 virtual void Redo( SwUndoIter
& );
958 void SaveNewBoxes( const SwTableNode
& rTblNd
, const SwTableSortBoxes
& rOld
);
959 void SaveNewBoxes( const SwTableNode
& rTblNd
, const SwTableSortBoxes
& rOld
,
960 const SwSelBoxes
& rBoxes
, const SvULongs
& rNodeCnts
);
961 void SaveSection( SwStartNode
* pSttNd
);
962 void ReNewBoxes( const SwSelBoxes
& rBoxes
);
965 void SetColWidthParam( ULONG nBoxIdx
, USHORT nMode
, USHORT nType
,
966 SwTwips nAbsDif
, SwTwips nRelDif
)
971 nAbsDiff
= (USHORT
)nAbsDif
;
972 nRelDiff
= (USHORT
)nRelDif
;
975 OUT_UNDOBJ( TblNodesChg
)
978 class SwUndoTblMerge
: public SwUndo
, private SwUndRng
981 _SaveTable
* pSaveTbl
;
982 SvULongs aBoxes
, aNewSttNds
;
987 SwUndoTblMerge( const SwPaM
& rTblSel
);
988 virtual ~SwUndoTblMerge();
989 virtual void Undo( SwUndoIter
& );
990 virtual void Redo( SwUndoIter
& );
992 void MoveBoxCntnt( SwDoc
* pDoc
, SwNodeRange
& rRg
, SwNodeIndex
& rPos
);
994 void SetSelBoxes( const SwSelBoxes
& rBoxes
);
996 void AddNewBox( ULONG nSttNdIdx
)
997 { aNewSttNds
.Insert( nSttNdIdx
, aNewSttNds
.Count() ); }
999 void SaveCollection( const SwTableBox
& rBox
);
1001 OUT_UNDOBJ( TblMerge
)
1005 class SwUndoTblNumFmt
: public SwUndo
1007 SfxItemSet
*pBoxSet
;
1008 SwHistory
* pHistory
;
1009 String aStr
, aNewFml
;
1011 ULONG nFmtIdx
, nNewFmtIdx
;
1012 double fNum
, fNewNum
;
1021 SwUndoTblNumFmt( const SwTableBox
& rBox
, const SfxItemSet
* pNewSet
= 0 );
1022 virtual ~SwUndoTblNumFmt();
1023 virtual void Undo( SwUndoIter
& );
1024 virtual void Redo( SwUndoIter
& );
1026 void SetNumFmt( ULONG nNewNumFmtIdx
, const double& rNewNumber
)
1027 { nFmtIdx
= nNewNumFmtIdx
; fNum
= rNewNumber
; }
1028 void SetBox( const SwTableBox
& rBox
);
1029 OUT_UNDOBJ( TblNumFmt
)
1032 class _UndoTblCpyTbl_Entries
;
1034 class SwUndoTblCpyTbl
: public SwUndo
1036 _UndoTblCpyTbl_Entries
* pArr
;
1037 SwUndoTblNdsChg
* pInsRowUndo
;
1039 //b6341295: When redlining is active, PrepareRedline has to create the redlining attributes
1040 //for the new and the old table cell content
1041 SwUndo
* PrepareRedline( SwDoc
* pDoc
, const SwTableBox
& rBox
, const SwPosition
& rPos
,
1042 bool& rJoin
, bool bRedo
);
1045 virtual ~SwUndoTblCpyTbl();
1046 virtual void Undo( SwUndoIter
& );
1047 virtual void Redo( SwUndoIter
& );
1049 void AddBoxBefore( const SwTableBox
& rBox
, BOOL bDelCntnt
);
1050 void AddBoxAfter( const SwTableBox
& rBox
, const SwNodeIndex
& rIdx
, BOOL bDelCntnt
);
1052 BOOL
IsEmpty() const;
1053 BOOL
InsertRow( SwTable
& rTbl
, const SwSelBoxes
& rBoxes
, USHORT nCnt
);
1054 OUT_UNDOBJ( TblCpyTbl
)
1057 class SwUndoCpyTbl
: public SwUndo
1063 virtual ~SwUndoCpyTbl();
1064 virtual void Undo( SwUndoIter
& );
1065 virtual void Redo( SwUndoIter
& );
1067 void SetTableSttIdx( ULONG nIdx
) { nTblNode
= nIdx
; }
1068 OUT_UNDOBJ( CpyTbl
)
1071 class SwUndoSplitTbl
: public SwUndo
1073 ULONG nTblNode
, nOffset
;
1074 SwSaveRowSpan
* mpSaveRowSpan
; // stores the row span values at the splitting row
1075 _SaveTable
* pSavTbl
;
1076 SwHistory
* pHistory
;
1077 USHORT nMode
, nFmlEnd
;
1080 SwUndoSplitTbl( const SwTableNode
& rTblNd
, SwSaveRowSpan
* pRowSp
, USHORT nMode
, BOOL bCalcNewSize
);
1081 virtual ~SwUndoSplitTbl();
1082 virtual void Undo( SwUndoIter
& );
1083 virtual void Redo( SwUndoIter
& );
1084 virtual void Repeat( SwUndoIter
& );
1086 void SetTblNodeOffset( ULONG nIdx
) { nOffset
= nIdx
- nTblNode
; }
1087 SwHistory
* GetHistory() { return pHistory
; }
1088 void SaveFormula( SwHistory
& rHistory
);
1091 class SwUndoMergeTbl
: public SwUndo
1095 _SaveTable
* pSavTbl
, *pSavHdl
;
1096 SwHistory
* pHistory
;
1100 SwUndoMergeTbl( const SwTableNode
& rTblNd
, const SwTableNode
& rDelTblNd
,
1101 BOOL bWithPrev
, USHORT nMode
);
1102 virtual ~SwUndoMergeTbl();
1103 virtual void Undo( SwUndoIter
& );
1104 virtual void Redo( SwUndoIter
& );
1105 virtual void Repeat( SwUndoIter
& );
1107 void SaveFormula( SwHistory
& rHistory
);
1111 class SwUndoBookmark
: public SwUndo
1113 const ::std::auto_ptr
<SwHistoryBookmark
> m_pHistoryBookmark
;
1116 SwUndoBookmark( SwUndoId nUndoId
, const ::sw::mark::IMark
& );
1118 void SetInDoc( SwDoc
* );
1119 void ResetInDoc( SwDoc
* );
1122 virtual ~SwUndoBookmark();
1126 Returns the rewriter for this undo object.
1128 The rewriter contains the following rule:
1130 $1 -> <name of bookmark>
1132 <name of bookmark> is the name of the bookmark whose
1133 insertion/deletion is recorded by this undo object.
1135 @return the rewriter for this undo object
1137 virtual SwRewriter
GetRewriter() const;
1141 class SwUndoDelBookmark
: public SwUndoBookmark
1144 SwUndoDelBookmark( const ::sw::mark::IMark
& );
1145 virtual void Undo( SwUndoIter
& );
1146 virtual void Redo( SwUndoIter
& );
1147 OUT_UNDOBJ( DelBookmark
)
1150 class SwUndoInsBookmark
: public SwUndoBookmark
1153 SwUndoInsBookmark( const ::sw::mark::IMark
& );
1154 virtual void Undo( SwUndoIter
& );
1155 virtual void Redo( SwUndoIter
& );
1156 OUT_UNDOBJ( InsBookmark
)
1160 /*--------------------------------------------------------------------
1161 Beschreibung: Undo auf Sorting
1162 --------------------------------------------------------------------*/
1164 struct SwSortUndoElement
1169 ULONG nSource
, nTarget
;
1172 String
*pSource
, *pTarget
;
1176 SwSortUndoElement( const String
& aS
, const String
& aT
)
1178 SORT_TXT_TBL
.TBL
.pSource
= new String( aS
);
1179 SORT_TXT_TBL
.TBL
.pTarget
= new String( aT
);
1181 SwSortUndoElement( ULONG nS
, ULONG nT
)
1183 SORT_TXT_TBL
.TXT
.nSource
= nS
;
1184 SORT_TXT_TBL
.TXT
.nTarget
= nT
;
1185 SORT_TXT_TBL
.TXT
.nKenn
= 0xffffffff;
1187 ~SwSortUndoElement();
1190 SV_DECL_PTRARR_DEL(SwSortList
, SwSortUndoElement
*, 10,30)
1191 SV_DECL_PTRARR(SwUndoSortList
, SwNodeIndex
*, 10,30)
1193 class SwUndoSort
: public SwUndo
, private SwUndRng
1195 SwSortOptions
* pSortOpt
; // die Optionen mit den Sortier-Kriterien
1196 SwSortList aSortList
;
1197 SwUndoAttrTbl
* pUndoTblAttr
;
1198 SwRedlineData
* pRedlData
;
1201 void RemoveIdx( SwPaM
& rPam
);
1203 SwUndoSort( const SwPaM
&, const SwSortOptions
& );
1204 SwUndoSort( ULONG nStt
, ULONG nEnd
, const SwTableNode
&,
1205 const SwSortOptions
&, BOOL bSaveTable
);
1206 virtual ~SwUndoSort();
1208 virtual void Undo( SwUndoIter
& );
1209 virtual void Redo( SwUndoIter
& );
1210 virtual void Repeat( SwUndoIter
& );
1212 void Insert( const String
& rOrgPos
, const String
& rNewPos
);
1213 void Insert( ULONG nOrgPos
, ULONG nNewPos
);
1220 //--------------------------------------------------------------------
1222 class SwUndoFlyBase
: public SwUndo
, private SwUndoSaveSection
1225 SwFrmFmt
* pFrmFmt
; // das gespeicherte FlyFormat
1227 xub_StrLen nCntPos
; // Seite/am Absatz/im Absatz
1229 BOOL bDelFmt
; // loesche das gespeicherte Format
1231 void InsFly( SwUndoIter
&, BOOL bShowSel
= TRUE
);
1232 void DelFly( SwDoc
* );
1234 SwUndoFlyBase( SwFrmFmt
* pFormat
, SwUndoId nUndoId
);
1236 SwNodeIndex
* GetMvSttIdx() const { return SwUndoSaveSection::GetMvSttIdx(); }
1237 ULONG
GetMvNodeCnt() const { return SwUndoSaveSection::GetMvNodeCnt(); }
1240 virtual ~SwUndoFlyBase();
1242 virtual void Undo( SwUndoIter
& ) = 0;
1243 virtual void Redo( SwUndoIter
& ) = 0;
1245 OUT_UNDOBJ( FlyBase
)
1248 class SwUndoInsLayFmt
: public SwUndoFlyBase
1250 ULONG mnCrsrSaveIndexPara
; // Cursor position
1251 xub_StrLen mnCrsrSaveIndexPos
; // for undo
1253 SwUndoInsLayFmt( SwFrmFmt
* pFormat
, ULONG nNodeIdx
, xub_StrLen nCntIdx
);
1256 virtual void Undo( SwUndoIter
& );
1257 virtual void Redo( SwUndoIter
& );
1258 virtual void Repeat( SwUndoIter
& );
1260 String
GetComment() const;
1262 OUT_UNDOBJ( InsLayFmt
)
1265 class SwUndoDelLayFmt
: public SwUndoFlyBase
1269 SwUndoDelLayFmt( SwFrmFmt
* pFormat
);
1271 virtual void Undo( SwUndoIter
& );
1272 virtual void Redo( SwUndoIter
& );
1273 void Redo(); // Schnittstelle fuers Rollback
1275 void ChgShowSel( BOOL bNew
) { bShowSelFrm
= bNew
; }
1277 virtual SwRewriter
GetRewriter() const;
1279 OUT_UNDOBJ( DelLayFmt
)
1283 class SwUndoSetFlyFmt
: public SwUndo
, public SwClient
1285 SwFrmFmt
* pFrmFmt
; // das gespeicherte FlyFormat
1286 SwFrmFmt
* pOldFmt
; // die alte Fly Vorlage
1287 SwFrmFmt
* pNewFmt
; // die neue Fly Vorlage
1288 SfxItemSet
* pItemSet
; // die zurueck-/ gesetzten Attribute
1289 ULONG nOldNode
, nNewNode
;
1290 xub_StrLen nOldCntnt
, nNewCntnt
;
1291 USHORT nOldAnchorTyp
, nNewAnchorTyp
;
1294 void PutAttr( USHORT nWhich
, const SfxPoolItem
* pItem
);
1295 void Modify( SfxPoolItem
*, SfxPoolItem
* );
1296 void GetAnchor( SwFmtAnchor
& rAnhor
, ULONG nNode
, xub_StrLen nCntnt
);
1299 SwUndoSetFlyFmt( SwFrmFmt
& rFlyFmt
, SwFrmFmt
& rNewFrmFmt
);
1300 virtual ~SwUndoSetFlyFmt();
1302 virtual void Undo( SwUndoIter
& );
1303 virtual void Redo( SwUndoIter
& );
1305 virtual SwRewriter
GetRewriter() const;
1308 //--------------------------------------------------------------------
1310 class _UnReplaceData
;
1311 SV_DECL_PTRARR_DEL( _UnReplaceDatas
, _UnReplaceData
*, 10, 25 )
1313 class SwUndoReplace
: public SwUndo
1317 BOOL bOldIterFlag
; // Status vom Undo-Iter vorm 1. Aufruf
1318 USHORT nAktPos
; // fuer GetUndoRange und Undo/Redo
1319 _UnReplaceDatas aArr
;
1320 SwRedlineData
* pRedlData
;
1324 virtual ~SwUndoReplace();
1325 virtual void Undo( SwUndoIter
& );
1326 virtual void Redo( SwUndoIter
& );
1330 Returns the rewriter of this undo object.
1332 If this undo object represents several replacements the
1333 rewriter contains the following rules:
1335 $1 -> <number of replacements>
1336 $2 -> occurrences of
1337 $3 -> <replaced text>
1339 If this undo object represents one replacement the rewriter
1340 contains these rules:
1342 $1 -> <replaced text>
1343 $2 -> "->" (STR_YIELDS)
1344 $3 -> <replacing text>
1346 @return the rewriter of this undo object
1348 virtual SwRewriter
GetRewriter() const;
1350 void AddEntry( const SwPaM
& rPam
, const String
& rInsert
, BOOL bRegExp
);
1351 void SetEntryEnd( const SwPaM
& rPam
);
1354 { return ((USHRT_MAX
/ sizeof( void* )) - 50 ) < aArr
.Count(); }
1356 OUT_UNDOBJ( Replace
)
1360 //--------------------------------------------------------------------
1363 class SwUndoTblHeadline
: public SwUndo
1366 USHORT nOldHeadline
;
1367 USHORT nNewHeadline
;
1369 SwUndoTblHeadline( const SwTable
&, USHORT nOldHdl
, USHORT nNewHdl
);
1370 virtual void Undo( SwUndoIter
& );
1371 virtual void Redo( SwUndoIter
& );
1372 virtual void Repeat( SwUndoIter
& );
1373 OUT_UNDOBJ( SwUndoTblHeadline
)
1377 //------------ Undo von Insert-/Delete-Sections ----------------------
1379 class SwUndoInsSection
: public SwUndo
, private SwUndRng
1381 SwHistory
* pHistory
;
1382 SwSection
* pSection
;
1383 SwRedlineData
* pRedlData
;
1386 BOOL bSplitAtStt
: 1;
1387 BOOL bSplitAtEnd
: 1;
1388 BOOL bUpdateFtn
: 1;
1390 void Join( SwDoc
& rDoc
, ULONG nNode
);
1393 SwUndoInsSection( const SwPaM
&, const SwSection
&,
1394 const SfxItemSet
* pSet
);
1395 virtual ~SwUndoInsSection();
1396 virtual void Undo( SwUndoIter
& );
1397 virtual void Redo( SwUndoIter
& );
1398 virtual void Repeat( SwUndoIter
& );
1399 OUT_UNDOBJ( SwUndoInsSection
)
1401 void SetSectNdPos( ULONG nPos
) { nSectNodePos
= nPos
; }
1402 void SaveSplitNode( SwTxtNode
* pTxtNd
, BOOL bAtStt
);
1403 void SetUpdtFtnFlag( BOOL bFlag
) { bUpdateFtn
= bFlag
; }
1406 class SwUndoDelSection
: public SwUndo
1408 ULONG nSttNd
, nEndNd
;
1409 SwSection
* pSection
;
1412 SwUndoDelSection( const SwSectionFmt
& );
1413 virtual ~SwUndoDelSection();
1414 virtual void Undo( SwUndoIter
& );
1415 virtual void Redo( SwUndoIter
& );
1416 OUT_UNDOBJ( SwUndoDelSection
)
1419 class SwUndoChgSection
: public SwUndo
1422 SwSection
* pSection
;
1426 SwUndoChgSection( const SwSectionFmt
&, BOOL bOnlyAttrChgd
);
1427 virtual ~SwUndoChgSection();
1428 virtual void Undo( SwUndoIter
& );
1429 virtual void Redo( SwUndoIter
& );
1430 OUT_UNDOBJ( SwUndoChgSection
)
1433 //------------ Undo von verschieben/stufen von Gliederung ----------------
1435 class SwUndoOutlineLeftRight
: public SwUndo
, private SwUndRng
1439 SwUndoOutlineLeftRight( const SwPaM
& rPam
, short nOffset
);
1440 virtual void Undo( SwUndoIter
& );
1441 virtual void Redo( SwUndoIter
& );
1442 virtual void Repeat( SwUndoIter
& );
1443 OUT_UNDOBJ( SwUndoOutlineLeftRight
)
1446 //--------------------------------------------------------------------
1448 class SwUndoDefaultAttr
: public SwUndo
1450 ::std::auto_ptr
<SfxItemSet
> m_pOldSet
; // the old attributes
1451 ::std::auto_ptr
<SvxTabStopItem
> m_pTabStop
;
1454 // registers at the format and saves old attributes
1455 SwUndoDefaultAttr( const SfxItemSet
& rOldSet
);
1456 virtual ~SwUndoDefaultAttr();
1457 virtual void Undo( SwUndoIter
& );
1458 virtual void Redo( SwUndoIter
& );
1459 OUT_UNDOBJ( DefaultAttr
)
1462 //--------------------------------------------------------------------
1463 // ---------- Undo fuer Numerierung ----------------------------------
1465 class SwUndoInsNum
: public SwUndo
, private SwUndRng
1468 SwHistory
* pHistory
;
1470 SwNumRule
* pOldNumRule
;
1471 String sReplaceRule
;
1474 SwUndoInsNum( const SwPaM
& rPam
, const SwNumRule
& rRule
);
1475 SwUndoInsNum( const SwNumRule
& rOldRule
, const SwNumRule
& rNewRule
,
1476 SwUndoId nUndoId
= UNDO_INSFMTATTR
);
1477 SwUndoInsNum( const SwPosition
& rPos
, const SwNumRule
& rRule
,
1478 const String
& rReplaceRule
);
1479 virtual ~SwUndoInsNum();
1480 virtual void Undo( SwUndoIter
& );
1481 virtual void Redo( SwUndoIter
& );
1482 virtual void Repeat( SwUndoIter
& );
1483 virtual SwRewriter
GetRewriter() const;
1485 SwHistory
* GetHistory(); // wird ggfs. neu angelegt!
1486 void SetSttNum( ULONG nNdIdx
) { nSttSet
= nNdIdx
; }
1487 void SaveOldNumRule( const SwNumRule
& rOld
);
1489 void SetLRSpaceEndPos();
1491 OUT_UNDOBJ( InsNum
)
1494 class SwUndoDelNum
: public SwUndo
, private SwUndRng
1498 SvBools aRstLRSpaces
;
1499 SwHistory
* pHistory
;
1501 SwUndoDelNum( const SwPaM
& rPam
);
1502 virtual ~SwUndoDelNum();
1503 virtual void Undo( SwUndoIter
& );
1504 virtual void Redo( SwUndoIter
& );
1505 virtual void Repeat( SwUndoIter
& );
1507 void AddNode( const SwTxtNode
& rNd
, BOOL bResetLRSpace
);
1508 SwHistory
* GetHistory() { return pHistory
; }
1510 OUT_UNDOBJ( DelNum
)
1513 class SwUndoMoveNum
: public SwUndo
, private SwUndRng
1518 SwUndoMoveNum( const SwPaM
& rPam
, long nOffset
, BOOL bIsOutlMv
= FALSE
);
1519 virtual void Undo( SwUndoIter
& );
1520 virtual void Redo( SwUndoIter
& );
1521 virtual void Repeat( SwUndoIter
& );
1522 void SetStartNode( ULONG nValue
) { nNewStt
= nValue
; }
1523 OUT_UNDOBJ( MoveNum
)
1526 class SwUndoNumUpDown
: public SwUndo
, private SwUndRng
1530 SwUndoNumUpDown( const SwPaM
& rPam
, short nOffset
);
1531 virtual void Undo( SwUndoIter
& );
1532 virtual void Redo( SwUndoIter
& );
1533 virtual void Repeat( SwUndoIter
& );
1534 OUT_UNDOBJ( NumUpDown
)
1537 class SwUndoNumOrNoNum
: public SwUndo
1540 BOOL mbNewNum
, mbOldNum
;
1543 SwUndoNumOrNoNum( const SwNodeIndex
& rIdx
, BOOL mbOldNum
,
1545 virtual void Undo( SwUndoIter
& );
1546 virtual void Redo( SwUndoIter
& );
1547 virtual void Repeat( SwUndoIter
& );
1548 OUT_UNDOBJ( NumOrNoNum
)
1551 class SwUndoNumRuleStart
: public SwUndo
1554 USHORT nOldStt
, nNewStt
;
1555 BOOL bSetSttValue
: 1;
1558 SwUndoNumRuleStart( const SwPosition
& rPos
, BOOL bDelete
);
1559 SwUndoNumRuleStart( const SwPosition
& rPos
, USHORT nStt
);
1560 virtual void Undo( SwUndoIter
& );
1561 virtual void Redo( SwUndoIter
& );
1562 virtual void Repeat( SwUndoIter
& );
1563 OUT_UNDOBJ( NumRuleStart
)
1566 //--------------------------------------------------------------------
1567 // ---------- Undo fuer DrawObjecte ----------------------------------
1569 class SwSdrUndo
: public SwUndo
1571 SdrUndoAction
* pSdrUndo
;
1572 SdrMarkList
* pMarkList
; // MarkList for all selected SdrObjects
1574 SwSdrUndo( SdrUndoAction
* , const SdrMarkList
* pMarkList
);
1575 virtual ~SwSdrUndo();
1576 virtual void Undo( SwUndoIter
& );
1577 virtual void Redo( SwUndoIter
& );
1579 String
GetComment() const;
1582 class SwUndoDrawGroup
: public SwUndo
1584 SwUndoGroupObjImpl
* pObjArr
;
1589 SwUndoDrawGroup( USHORT nCnt
);
1590 virtual ~SwUndoDrawGroup();
1591 virtual void Undo( SwUndoIter
& );
1592 virtual void Redo( SwUndoIter
& );
1594 void AddObj( USHORT nPos
, SwDrawFrmFmt
*, SdrObject
* );
1595 void SetGroupFmt( SwDrawFrmFmt
* );
1598 // --> OD 2006-11-01 #130889#
1599 // Action "ungroup drawing object" is now splitted into three parts - see
1600 // method <SwDoc::UnGroupSelection(..)>:
1601 // - creation for <SwDrawFrmFmt> instances for the group members of the
1602 // selected group objects
1603 // - intrinsic ungroup of the selected group objects
1604 // - creation of <SwDrawContact> instances for the former group members and
1605 // connection to the Writer layout.
1606 // Thus, two undo actions (instances of <SwUndo>) are needed:
1607 // - Existing class <SwUndoDrawUnGroup> takes over the part for the formats.
1608 // - New class <SwUndoDrawUnGroupConnectToLayout> takes over the part for
1610 class SwUndoDrawUnGroup
: public SwUndo
1612 SwUndoGroupObjImpl
* pObjArr
;
1617 SwUndoDrawUnGroup( SdrObjGroup
* );
1618 virtual ~SwUndoDrawUnGroup();
1619 virtual void Undo( SwUndoIter
& );
1620 virtual void Redo( SwUndoIter
& );
1622 void AddObj( USHORT nPos
, SwDrawFrmFmt
* );
1625 // --> OD 2006-11-01 #130889#
1626 class SwUndoDrawUnGroupConnectToLayout
: public SwUndo
1629 std::vector
< std::pair
< SwDrawFrmFmt
*, SdrObject
* > > aDrawFmtsAndObjs
;
1632 SwUndoDrawUnGroupConnectToLayout();
1633 virtual ~SwUndoDrawUnGroupConnectToLayout();
1634 virtual void Undo( SwUndoIter
& );
1635 virtual void Redo( SwUndoIter
& );
1637 void AddFmtAndObj( SwDrawFrmFmt
* pDrawFrmFmt
,
1638 SdrObject
* pDrawObject
);
1643 class SwUndoDrawDelete
: public SwUndo
1645 SwUndoGroupObjImpl
* pObjArr
;
1646 SdrMarkList
* pMarkLst
; // MarkList for all selected SdrObjects
1651 SwUndoDrawDelete( USHORT nCnt
);
1652 virtual ~SwUndoDrawDelete();
1653 virtual void Undo( SwUndoIter
& );
1654 virtual void Redo( SwUndoIter
& );
1656 void AddObj( USHORT nPos
, SwDrawFrmFmt
*, const SdrMark
& );
1659 //--------------------------------------------------------------------
1661 class SwUndoReRead
: public SwUndo
1664 String
*pNm
, *pFltr
;
1668 void SaveGraphicData( const SwGrfNode
& );
1669 void SetAndSave( SwUndoIter
& );
1672 SwUndoReRead( const SwPaM
& rPam
, const SwGrfNode
& pGrfNd
);
1673 virtual ~SwUndoReRead();
1675 virtual void Undo( SwUndoIter
& );
1676 virtual void Redo( SwUndoIter
& );
1679 //--------------------------------------------------------------------
1681 class SwUndoInsertLabel
: public SwUndo
1686 SwUndoInsLayFmt
* pUndoFly
;
1687 SwUndoFmtAttr
* pUndoAttr
;
1690 // fuer Tabelle/TextRahmen
1691 SwUndoDelete
* pUndoInsNd
;
1697 // --> PB 2005-01-06 #i39983# - the separator will be drawed with a character style
1700 String sNumberSeparator
;
1701 String sCharacterStyle
;
1702 // OD 2004-04-15 #i26791# - re-store of drawing object position no longer needed
1705 BYTE nLayerId
; // fuer Zeichen-Objekte
1711 SwUndoInsertLabel( const SwLabelType eTyp
, const String
&rText
,
1712 // --> PB 2005-01-06 #i39983# - the separator will be drawed with a character style
1713 const String
& rSeparator
,
1715 const String
& rNumberSeparator
, //#i61007# order of captions
1716 const BOOL bBefore
, const USHORT nId
,
1717 const String
& rCharacterStyle
,
1718 const BOOL bCpyBrd
);
1719 virtual ~SwUndoInsertLabel();
1721 virtual void Undo( SwUndoIter
& );
1722 virtual void Redo( SwUndoIter
& );
1723 virtual void Repeat( SwUndoIter
& );
1727 Returns the rewriter of this undo object.
1729 The rewriter contains this rule:
1731 $1 -> '<text of inserted label>'
1733 <text of inserted label> is shortened to nUndoStringLength
1736 @return the rewriter of this undo object
1738 virtual SwRewriter
GetRewriter() const;
1740 void SetNodePos( ULONG nNd
)
1741 { if( LTYPE_OBJECT
!= eType
) NODE
.nNode
= nNd
; }
1743 void SetUndoKeep() { bUndoKeep
= TRUE
; }
1744 void SetFlys( SwFrmFmt
& rOldFly
, SfxItemSet
& rChgSet
, SwFrmFmt
& rNewFly
);
1745 void SetDrawObj( BYTE nLayerId
);
1748 //--------------------------------------------------------------------
1750 class SwUndoChangeFootNote
: public SwUndo
, private SwUndRng
1752 const ::std::auto_ptr
<SwHistory
> m_pHistory
;
1753 const String m_Text
;
1754 const USHORT m_nNumber
;
1755 const bool m_bEndNote
;
1758 SwUndoChangeFootNote( const SwPaM
& rRange
, const String
& rTxt
,
1759 USHORT nNum
, bool bIsEndNote
);
1760 virtual ~SwUndoChangeFootNote();
1762 virtual void Undo( SwUndoIter
& );
1763 virtual void Redo( SwUndoIter
& );
1764 virtual void Repeat( SwUndoIter
& );
1766 SwHistory
& GetHistory() { return *m_pHistory
; }
1769 class SwUndoFootNoteInfo
: public SwUndo
1771 ::std::auto_ptr
<SwFtnInfo
> m_pFootNoteInfo
;
1774 SwUndoFootNoteInfo( const SwFtnInfo
&rInfo
);
1775 virtual ~SwUndoFootNoteInfo();
1777 virtual void Undo( SwUndoIter
& );
1778 virtual void Redo( SwUndoIter
& );
1781 class SwUndoEndNoteInfo
: public SwUndo
1783 ::std::auto_ptr
<SwEndNoteInfo
> m_pEndNoteInfo
;
1786 SwUndoEndNoteInfo( const SwEndNoteInfo
&rInfo
);
1787 virtual ~SwUndoEndNoteInfo();
1789 virtual void Undo( SwUndoIter
& );
1790 virtual void Redo( SwUndoIter
& );
1794 //--------------------------------------------------------------------
1796 struct _UndoTransliterate_Data
;
1797 class SwUndoTransliterate
: public SwUndo
, public SwUndRng
1799 _UndoTransliterate_Data
*pData
, *pLastData
;
1803 SwUndoTransliterate( const SwPaM
& rPam
,
1804 const utl::TransliterationWrapper
& rTrans
);
1805 virtual ~SwUndoTransliterate();
1807 virtual void Undo( SwUndoIter
& rUndoIter
);
1808 virtual void Redo( SwUndoIter
& rUndoIter
);
1809 virtual void Repeat( SwUndoIter
& rUndoIter
);
1811 void AddChanges( SwTxtNode
& rTNd
, xub_StrLen nStart
, xub_StrLen nLen
,
1812 ::com::sun::star::uno::Sequence
<sal_Int32
>& rOffsets
);
1813 BOOL
HasData() const {return 0 != pData
; }
1816 //--------------------------------------------------------------------
1818 class SwUndoRedline
: public SwUndo
, public SwUndRng
1821 SwRedlineData
* pRedlData
;
1822 SwRedlineSaveDatas
* pRedlSaveData
;
1824 BOOL bHiddenRedlines
;
1826 virtual void _Undo( SwUndoIter
& );
1827 virtual void _Redo( SwUndoIter
& );
1830 SwUndoRedline( SwUndoId nUserId
, const SwPaM
& rRange
);
1831 virtual ~SwUndoRedline();
1832 virtual void Undo( SwUndoIter
& );
1833 virtual void Redo( SwUndoIter
& );
1835 SwUndoId
GetUserId() const { return nUserId
; }
1836 USHORT
GetRedlSaveCount() const
1837 { return pRedlSaveData
? pRedlSaveData
->Count() : 0; }
1840 class SwUndoRedlineDelete
: public SwUndoRedline
1844 BOOL bIsBackspace
: 1;
1846 virtual void _Undo( SwUndoIter
& );
1847 virtual void _Redo( SwUndoIter
& );
1850 SwUndoRedlineDelete( const SwPaM
& rRange
, SwUndoId nUserId
= UNDO_EMPTY
);
1852 BOOL
CanGrouping( const SwUndoRedlineDelete
& rPrev
);
1855 class SwUndoRedlineSort
: public SwUndoRedline
1857 SwSortOptions
* pOpt
;
1858 ULONG nSaveEndNode
, nOffset
;
1859 xub_StrLen nSaveEndCntnt
;
1861 virtual void _Undo( SwUndoIter
& );
1862 virtual void _Redo( SwUndoIter
& );
1865 SwUndoRedlineSort( const SwPaM
& rRange
, const SwSortOptions
& rOpt
);
1866 virtual ~SwUndoRedlineSort();
1867 virtual void Repeat( SwUndoIter
& );
1869 void SetSaveRange( const SwPaM
& rRange
);
1870 void SetOffset( const SwNodeIndex
& rIdx
);
1873 class SwUndoAcceptRedline
: public SwUndoRedline
1875 virtual void _Redo( SwUndoIter
& );
1877 SwUndoAcceptRedline( const SwPaM
& rRange
);
1878 virtual void Repeat( SwUndoIter
& );
1881 class SwUndoRejectRedline
: public SwUndoRedline
1883 virtual void _Redo( SwUndoIter
& );
1885 SwUndoRejectRedline( const SwPaM
& rRange
);
1886 virtual void Repeat( SwUndoIter
& );
1889 //--------------------------------------------------------------------
1891 class SwUndoCompDoc
: public SwUndo
, public SwUndRng
1893 SwRedlineData
* pRedlData
;
1894 SwUndoDelete
* pUnDel
, *pUnDel2
;
1895 SwRedlineSaveDatas
* pRedlSaveData
;
1898 SwUndoCompDoc( const SwPaM
& rRg
, BOOL bIns
);
1899 SwUndoCompDoc( const SwRedline
& rRedl
);
1901 virtual ~SwUndoCompDoc();
1902 virtual void Undo( SwUndoIter
& );
1903 virtual void Redo( SwUndoIter
& );
1907 //--------------------------------------------------------------------
1909 // Object der als Iterator durch die Undo-Liste laeuft, bis die
1910 // letze oder die angegebene Klammerung/Id erreicht ist.
1914 friend class SwDoc
; // um im SwDoc::Undo bWeiter zu stezen
1915 friend void SwUndoEnd::Undo( SwUndoIter
& );
1916 friend void SwUndoStart::Undo( SwUndoIter
& );
1917 friend void SwUndoEnd::Redo( SwUndoIter
& );
1918 friend void SwUndoStart::Redo( SwUndoIter
& );
1919 friend void SwUndoEnd::Repeat( SwUndoIter
& );
1920 friend void SwUndoStart::Repeat( SwUndoIter
& );
1921 friend void SwUndoReplace::Undo( SwUndoIter
& );
1922 friend void SwUndoReplace::Redo( SwUndoIter
& );
1927 BOOL bUpdateAttr
: 1; // Setze das GCAttr an der CursorShell
1930 SwPaM
* pAktPam
; // Member fuer das Undo
1931 SwUndo
* pLastUndoObj
; // fuers Redo, das vorherige UndoObj.
1932 SwFrmFmt
* pSelFmt
; // ggfs. das Format Rahmen/Object-Selektionen
1933 SdrMarkList
* pMarkList
; // MarkList for all selected SdrObjects
1935 SwUndoIter( SwPaM
* pPam
, SwUndoId nId
= UNDO_EMPTY
);
1937 BOOL
IsNextUndo() const { return bWeiter
; }
1938 BOOL
IsUpdateAttr() const { return bUpdateAttr
; }
1939 void SetUpdateAttr( BOOL bNew
) { bUpdateAttr
= bNew
; }
1941 inline SwDoc
& GetDoc() const;
1942 SwUndoId
GetId() const { return nUndoId
; }
1943 SwUndoId
GetLastUndoId() const
1944 { return pLastUndoObj
? pLastUndoObj
->GetId() : UNDO_EMPTY
; }
1945 void ClearSelections() { pSelFmt
= 0; pMarkList
= 0; }
1950 const int nUndoStringLength
= 20;
1953 Shortens a string to a maximum length.
1955 @param rStr the string to be shortened
1956 @param nLength the maximum length for rStr
1957 @param rFillStr string to replace cut out characters with
1959 If rStr has less than nLength characters it will be returned unaltered.
1961 If rStr has more than nLength characters the following algorithm
1962 generates the shortened string:
1964 frontLength = (nLength - length(rFillStr)) / 2
1965 rearLength = nLength - length(rFillStr) - frontLength
1966 shortenedString = concat(<first frontLength characters of rStr,
1968 <last rearLength characters of rStr>)
1971 - nLength - length(rFillStr) >= 2
1973 @return the shortened string
1975 String
ShortenString(const String
& rStr
, xub_StrLen nLength
, const String
& rFillStr
);
1980 Denotes special characters in a string.
1982 The rStr is split into parts containing special characters and
1983 parts not containing special characters. In a part containing
1984 special characters all characters are equal. These parts are
1987 @param rStr the string to denote in
1989 The resulting string is generated by concatenating the found
1990 parts. The parts without special characters are surrounded by
1991 "'". The parts containing special characters are denoted as "n x",
1992 where n is the length of the part and x is the representation of
1993 the special character (i. e. "tab(s)").
1995 @return the denoted string
1997 String
DenoteSpecialCharacters(const String
& rStr
);