xref: /trunk/main/sw/source/core/undo/unattr.cxx (revision 26ea3662)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 // MARKER(update_precomp.py): autogen include statement, do not remove
23 #include "precompiled_sw.hxx"
24 
25 #define _SVSTDARR_USHORTS
26 #define _SVSTDARR_USHORTSSORT
27 #include <UndoAttribute.hxx>
28 #include <svl/itemiter.hxx>
29 #include <editeng/tstpitem.hxx>
30 #include <svx/svdmodel.hxx>
31 #include <svx/svdpage.hxx>
32 #include <hintids.hxx>
33 #include <fmtflcnt.hxx>
34 #include <txtftn.hxx>
35 #include <fmtornt.hxx>
36 #include <fmtanchr.hxx>
37 #include <fmtfsize.hxx>
38 #include <frmfmt.hxx>
39 #include <fmtcntnt.hxx>
40 #include <ftnidx.hxx>
41 #include <doc.hxx>
42 #include <IDocumentUndoRedo.hxx>
43 #include <IShellCursorSupplier.hxx>
44 #include <docary.hxx>
45 #include <swundo.hxx>			// fuer die UndoIds
46 #include <pam.hxx>
47 #include <ndtxt.hxx>
48 #include <swtable.hxx>
49 #include <swtblfmt.hxx>
50 #include <UndoCore.hxx>
51 #include <hints.hxx>
52 #include <rolbck.hxx>
53 #include <ndnotxt.hxx>
54 #include <dcontact.hxx>
55 #include <ftninfo.hxx>
56 #include <redline.hxx>
57 #include <section.hxx>
58 #include <charfmt.hxx>
59 #include <switerator.hxx>
60 #include <drawdoc.hxx>
61 
62 // -----------------------------------------------------
63 
SwUndoFmtAttrHelper(SwFmt & rFmt,bool bSvDrwPt)64 SwUndoFmtAttrHelper::SwUndoFmtAttrHelper( SwFmt& rFmt, bool bSvDrwPt )
65     : SwClient( &rFmt )
66     , m_pUndo( 0 )
67     , m_bSaveDrawPt( bSvDrwPt )
68 {
69 }
70 
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)71 void SwUndoFmtAttrHelper::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
72 {
73 	if( pOld )
74 	{
75         if ( pOld->Which() == RES_OBJECTDYING )
76         {
77             CheckRegistration( pOld, pNew );
78         }
79         else if ( pNew )
80         {
81 		    if( POOLATTR_END >= pOld->Which() )
82 		    {
83                 if ( GetUndo() )
84                 {
85                     m_pUndo->PutAttr( *pOld );
86                 }
87                 else
88                 {
89                     m_pUndo.reset( new SwUndoFmtAttr( *pOld,
90                             *static_cast<SwFmt*>(GetRegisteredInNonConst()), m_bSaveDrawPt ) );
91                 }
92             }
93             else if ( RES_ATTRSET_CHG == pOld->Which() )
94             {
95                 if ( GetUndo() )
96                 {
97                     SfxItemIter aIter(
98                             *(static_cast<const SwAttrSetChg*>(pOld))->GetChgSet() );
99                     const SfxPoolItem* pItem = aIter.GetCurItem();
100                     while ( pItem )
101                     {
102                         m_pUndo->PutAttr( *pItem );
103 					    if( aIter.IsAtEnd() )
104 						    break;
105 					    pItem = aIter.NextItem();
106 				    }
107                 }
108                 else
109                 {
110                     m_pUndo.reset( new SwUndoFmtAttr(
111                             *static_cast<const SwAttrSetChg*>(pOld)->GetChgSet(),
112                             *static_cast<SwFmt*>(GetRegisteredInNonConst()), m_bSaveDrawPt ) );
113                 }
114             }
115         }
116 	}
117 }
118 
119 // -----------------------------------------------------
120 
SwUndoFmtAttr(const SfxItemSet & rOldSet,SwFmt & rChgFmt,bool bSaveDrawPt)121 SwUndoFmtAttr::SwUndoFmtAttr( const SfxItemSet& rOldSet,
122                               SwFmt& rChgFmt,
123                               bool bSaveDrawPt )
124     : SwUndo( UNDO_INSFMTATTR )
125     , m_pFmt( &rChgFmt )
126       // --> OD 2007-07-11 #i56253#
127     , m_pOldSet( new SfxItemSet( rOldSet ) )
128       // <--
129     , m_nNodeIndex( 0 )
130     , m_nFmtWhich( rChgFmt.Which() )
131     , m_bSaveDrawPt( bSaveDrawPt )
132 {
133     Init();
134 }
135 
SwUndoFmtAttr(const SfxPoolItem & rItem,SwFmt & rChgFmt,bool bSaveDrawPt)136 SwUndoFmtAttr::SwUndoFmtAttr( const SfxPoolItem& rItem, SwFmt& rChgFmt,
137                               bool bSaveDrawPt )
138     : SwUndo( UNDO_INSFMTATTR )
139     , m_pFmt( &rChgFmt )
140     , m_pOldSet( m_pFmt->GetAttrSet().Clone( sal_False ) )
141     , m_nNodeIndex( 0 )
142     , m_nFmtWhich( rChgFmt.Which() )
143     , m_bSaveDrawPt( bSaveDrawPt )
144 {
145     m_pOldSet->Put( rItem );
146     Init();
147 }
148 
Init()149 void SwUndoFmtAttr::Init()
150 {
151     // treat change of anchor specially
152     if ( SFX_ITEM_SET == m_pOldSet->GetItemState( RES_ANCHOR, sal_False ))
153     {
154         SaveFlyAnchor( m_bSaveDrawPt );
155     }
156     else if ( RES_FRMFMT == m_nFmtWhich )
157     {
158         SwDoc* pDoc = m_pFmt->GetDoc();
159         if (USHRT_MAX != pDoc->GetTblFrmFmts()->GetPos(
160                             static_cast<const SwFrmFmtPtr>(m_pFmt)))
161         {
162             // Table Format: save table position, table formats are volatile!
163             SwTable * pTbl = SwIterator<SwTable,SwFmt>::FirstElement( *m_pFmt );
164             if ( pTbl )
165             {
166                 m_nNodeIndex = pTbl->GetTabSortBoxes()[ 0 ]->GetSttNd()
167                     ->FindTableNode()->GetIndex();
168             }
169         }
170         else if (USHRT_MAX != pDoc->GetSections().GetPos(
171                                 static_cast<const SwSectionFmtPtr>(m_pFmt)))
172         {
173             m_nNodeIndex = m_pFmt->GetCntnt().GetCntntIdx()->GetIndex();
174         }
175         else if ( 0 != dynamic_cast< SwTableBoxFmt* >( m_pFmt ) )
176         {
177             SwTableBox * pTblBox = SwIterator<SwTableBox,SwFmt>::FirstElement( *m_pFmt );
178             if ( pTblBox )
179             {
180                 m_nNodeIndex = pTblBox->GetSttIdx();
181             }
182         }
183     }
184 }
185 
~SwUndoFmtAttr()186 SwUndoFmtAttr::~SwUndoFmtAttr()
187 {
188 }
189 
UndoImpl(::sw::UndoRedoContext & rContext)190 void SwUndoFmtAttr::UndoImpl(::sw::UndoRedoContext & rContext)
191 {
192     // OD 2004-10-26 #i35443#
193     // Important note: <Undo(..)> also called by <ReDo(..)>
194 
195     if ( !m_pOldSet.get() || !m_pFmt || !IsFmtInDoc( &rContext.GetDoc() ))
196         return;
197 
198     // --> OD 2004-10-26 #i35443# - If anchor attribute has been successful
199     // restored, all other attributes are also restored.
200     // Thus, keep track of its restoration
201     bool bAnchorAttrRestored( false );
202     if ( SFX_ITEM_SET == m_pOldSet->GetItemState( RES_ANCHOR, sal_False ))
203     {
204         bAnchorAttrRestored = RestoreFlyAnchor(rContext);
205         if ( bAnchorAttrRestored )
206         {
207             // Anchor attribute successful restored.
208             // Thus, keep anchor position for redo
209             SaveFlyAnchor();
210         }
211         else
212         {
213             // Anchor attribute not restored due to invalid anchor position.
214             // Thus, delete anchor attribute.
215             m_pOldSet->ClearItem( RES_ANCHOR );
216         }
217     }
218 
219     if ( !bAnchorAttrRestored )
220     // <--
221     {
222         SwUndoFmtAttrHelper aTmp( *m_pFmt, m_bSaveDrawPt );
223         m_pFmt->SetFmtAttr( *m_pOldSet );
224         if ( aTmp.GetUndo() )
225         {
226             // transfer ownership of helper object's old set
227             m_pOldSet = aTmp.GetUndo()->m_pOldSet;
228         }
229         else
230         {
231             m_pOldSet->ClearItem();
232         }
233 
234         if ( RES_FLYFRMFMT == m_nFmtWhich || RES_DRAWFRMFMT == m_nFmtWhich )
235         {
236             rContext.SetSelections(static_cast<SwFrmFmt*>(m_pFmt), 0);
237         }
238     }
239 }
240 
IsFmtInDoc(SwDoc * pDoc)241 bool SwUndoFmtAttr::IsFmtInDoc( SwDoc* pDoc )
242 {
243     // search for the Format in the Document; if it does not exist any more,
244     // the attribute is not restored!
245     sal_uInt16 nPos = USHRT_MAX;
246     switch ( m_nFmtWhich )
247     {
248         case RES_TXTFMTCOLL:
249             nPos = pDoc->GetTxtFmtColls()->GetPos(
250                     static_cast<const SwTxtFmtCollPtr>(m_pFmt) );
251             break;
252 
253         case RES_GRFFMTCOLL:
254             nPos = pDoc->GetGrfFmtColls()->GetPos(
255                     static_cast<const SwGrfFmtCollPtr>(m_pFmt) );
256             break;
257 
258         case RES_CHRFMT:
259             nPos = pDoc->GetCharFmts()->GetPos(
260                     static_cast<SwCharFmtPtr>(m_pFmt) );
261             break;
262 
263         case RES_FRMFMT:
264             if ( m_nNodeIndex && (m_nNodeIndex < pDoc->GetNodes().Count()) )
265             {
266                 SwNode* pNd = pDoc->GetNodes()[ m_nNodeIndex ];
267                 if ( pNd->IsTableNode() )
268                 {
269                     m_pFmt =
270                         static_cast<SwTableNode*>(pNd)->GetTable().GetFrmFmt();
271                     nPos = 0;
272                     break;
273                 }
274                 else if ( pNd->IsSectionNode() )
275                 {
276                     m_pFmt =
277                         static_cast<SwSectionNode*>(pNd)->GetSection().GetFmt();
278                     nPos = 0;
279                     break;
280                 }
281                 else if ( pNd->IsStartNode() && (SwTableBoxStartNode ==
282                     static_cast< SwStartNode* >(pNd)->GetStartNodeType()) )
283                 {
284                     SwTableNode* pTblNode = pNd->FindTableNode();
285                     if ( pTblNode )
286                     {
287                         SwTableBox* pBox =
288                             pTblNode->GetTable().GetTblBox( m_nNodeIndex );
289                         if ( pBox )
290                         {
291                             m_pFmt = pBox->GetFrmFmt();
292                             nPos = 0;
293                             break;
294                         }
295                     }
296                 }
297             }
298             // no break!
299         case RES_DRAWFRMFMT:
300         case RES_FLYFRMFMT:
301             nPos = pDoc->GetSpzFrmFmts()->GetPos(
302                     static_cast<const SwFrmFmtPtr>(m_pFmt) );
303             if ( USHRT_MAX == nPos )
304             {
305                 nPos = pDoc->GetFrmFmts()->GetPos(
306                     static_cast<const SwFrmFmtPtr>(m_pFmt) );
307             }
308             break;
309     }
310 
311     if ( USHRT_MAX == nPos )
312     {
313         // Format does not exist; reset
314         m_pFmt = 0;
315     }
316 
317     return 0 != m_pFmt;
318 }
319 
320 // prueft, ob es noch im Doc ist!
GetFmt(SwDoc & rDoc)321 SwFmt* SwUndoFmtAttr::GetFmt( SwDoc& rDoc )
322 {
323     return m_pFmt && IsFmtInDoc( &rDoc ) ? m_pFmt : 0;
324 }
325 
RedoImpl(::sw::UndoRedoContext & rContext)326 void SwUndoFmtAttr::RedoImpl(::sw::UndoRedoContext & rContext)
327 {
328     // --> OD 2004-10-26 #i35443# - Because the undo stores the attributes for
329     // redo, the same code as for <Undo(..)> can be applied for <Redo(..)>
330     UndoImpl(rContext);
331     // <--
332 }
333 
RepeatImpl(::sw::RepeatContext & rContext)334 void SwUndoFmtAttr::RepeatImpl(::sw::RepeatContext & rContext)
335 {
336     if ( !m_pOldSet.get() )
337         return;
338 
339     SwDoc & rDoc(rContext.GetDoc());
340 
341     switch ( m_nFmtWhich )
342     {
343 	case RES_GRFFMTCOLL:
344 		{
345             SwNoTxtNode *const pNd =
346                 rContext.GetRepeatPaM().GetNode()->GetNoTxtNode();
347 			if( pNd )
348             {
349                 rDoc.SetAttr( m_pFmt->GetAttrSet(), *pNd->GetFmtColl() );
350             }
351         }
352 		break;
353 
354 	case RES_TXTFMTCOLL:
355 		{
356             SwTxtNode *const pNd =
357                 rContext.GetRepeatPaM().GetNode()->GetTxtNode();
358 			if( pNd )
359             {
360                 rDoc.SetAttr( m_pFmt->GetAttrSet(), *pNd->GetFmtColl() );
361             }
362         }
363 		break;
364 
365 //	case RES_CHRFMT:
366 //	case RES_FRMFMT:
367 
368 	case RES_FLYFRMFMT:
369 		{
370 			// erstal pruefen, ob der Cursor ueberhaupt in einem fliegenden
371 			// Rahmen steht. Der Weg ist: suche in allen FlyFrmFormaten
372 			// nach dem FlyCntnt-Attribut und teste ob der Cursor in der
373 			// entsprechenden Section liegt.
374             SwFrmFmt *const pFly =
375                 rContext.GetRepeatPaM().GetNode()->GetFlyFmt();
376 			if( pFly )
377 			{
378 				// Bug 43672: es duerfen nicht alle Attribute gesetzt werden!
379                 if (SFX_ITEM_SET ==
380                         m_pFmt->GetAttrSet().GetItemState( RES_CNTNT ))
381                 {
382                     SfxItemSet aTmpSet( m_pFmt->GetAttrSet() );
383 					aTmpSet.ClearItem( RES_CNTNT );
384 					if( aTmpSet.Count() )
385                     {
386 						rDoc.SetAttr( aTmpSet, *pFly );
387                     }
388                 }
389                 else
390                 {
391                     rDoc.SetAttr( m_pFmt->GetAttrSet(), *pFly );
392                 }
393             }
394 			break;
395 		}
396 	}
397 }
398 
GetRewriter() const399 SwRewriter SwUndoFmtAttr::GetRewriter() const
400 {
401     SwRewriter aRewriter;
402 
403     if (m_pFmt)
404     {
405         aRewriter.AddRule(UNDO_ARG1, m_pFmt->GetName());
406     }
407 
408     return aRewriter;
409 }
410 
PutAttr(const SfxPoolItem & rItem)411 void SwUndoFmtAttr::PutAttr( const SfxPoolItem& rItem )
412 {
413     m_pOldSet->Put( rItem );
414     if ( RES_ANCHOR == rItem.Which() )
415     {
416         SaveFlyAnchor( m_bSaveDrawPt );
417     }
418 }
419 
SaveFlyAnchor(bool bSvDrwPt)420 void SwUndoFmtAttr::SaveFlyAnchor( bool bSvDrwPt )
421 {
422 	// das Format ist gueltig, sonst wuerde man gar bis hier kommen
423 	if( bSvDrwPt )
424     {
425         if ( RES_DRAWFRMFMT == m_pFmt->Which() )
426         {
427             Point aPt( static_cast<SwFrmFmt*>(m_pFmt)->FindSdrObject()
428                             ->GetRelativePos() );
429             // store old value as attribute, to keep SwUndoFmtAttr small
430             m_pOldSet->Put( SwFmtFrmSize( ATT_VAR_SIZE, aPt.X(), aPt.Y() ) );
431         }
432 /*		else
433 		{
434 			pOldSet->Put( pFmt->GetVertOrient() );
435 			pOldSet->Put( pFmt->GetHoriOrient() );
436 		}
437 */	}
438 
439     const SwFmtAnchor& rAnchor =
440         static_cast<const SwFmtAnchor&>( m_pOldSet->Get( RES_ANCHOR, sal_False ) );
441 	if( !rAnchor.GetCntntAnchor() )
442 		return;
443 
444 	xub_StrLen nCntnt = 0;
445 	switch( rAnchor.GetAnchorId() )
446 	{
447     case FLY_AS_CHAR:
448     case FLY_AT_CHAR:
449 		nCntnt = rAnchor.GetCntntAnchor()->nContent.GetIndex();
450     case FLY_AT_PARA:
451     case FLY_AT_FLY:
452         m_nNodeIndex = rAnchor.GetCntntAnchor()->nNode.GetIndex();
453 		break;
454 	default:
455 		return;
456 	}
457 
458 	SwFmtAnchor aAnchor( rAnchor.GetAnchorId(), nCntnt );
459     m_pOldSet->Put( aAnchor );
460 }
461 
462 // --> OD 2004-10-26 #i35443# - Add return value, type <bool>.
463 // Return value indicates, if anchor attribute is restored.
464 // Note: If anchor attribute is restored, all other existing attributes
465 //       are also restored.
RestoreFlyAnchor(::sw::UndoRedoContext & rContext)466 bool SwUndoFmtAttr::RestoreFlyAnchor(::sw::UndoRedoContext & rContext)
467 {
468     SwDoc *const pDoc = & rContext.GetDoc();
469     SwFlyFrmFmt* pFrmFmt = static_cast<SwFlyFrmFmt*>(m_pFmt);
470     const SwFmtAnchor& rAnchor =
471         static_cast<const SwFmtAnchor&>( m_pOldSet->Get( RES_ANCHOR, sal_False ) );
472 
473 	SwFmtAnchor aNewAnchor( rAnchor.GetAnchorId() );
474     if (FLY_AT_PAGE != rAnchor.GetAnchorId())
475     {
476         SwNode* pNd = pDoc->GetNodes()[ m_nNodeIndex  ];
477 
478         if (  (FLY_AT_FLY == rAnchor.GetAnchorId())
479             ? ( !pNd->IsStartNode() || (SwFlyStartNode !=
480                     static_cast<SwStartNode*>(pNd)->GetStartNodeType()) )
481             : !pNd->IsTxtNode() )
482         {
483             // --> OD 2004-10-26 #i35443# - invalid position.
484             // Thus, anchor attribute not restored
485             return false;
486             // <--
487         }
488 
489 		SwPosition aPos( *pNd );
490         if ((FLY_AS_CHAR == rAnchor.GetAnchorId()) ||
491             (FLY_AT_CHAR == rAnchor.GetAnchorId()))
492         {
493 			aPos.nContent.Assign( (SwTxtNode*)pNd, rAnchor.GetPageNum() );
494             if ( aPos.nContent.GetIndex() >
495                     static_cast<SwTxtNode*>(pNd)->GetTxt().Len() )
496             {
497                 // --> OD 2004-10-26 #i35443# - invalid position.
498                 // Thus, anchor attribute not restored
499                 return false;
500                 // <--
501             }
502 		}
503 		aNewAnchor.SetAnchor( &aPos );
504 	}
505 	else
506 		aNewAnchor.SetPageNum( rAnchor.GetPageNum() );
507 
508 	Point aDrawSavePt, aDrawOldPt;
509 	if( pDoc->GetCurrentViewShell() )	//swmod 071108//swmod 071225
510 	{
511 		if( RES_DRAWFRMFMT == pFrmFmt->Which() )
512 		{
513 			// den alten zwischengespeicherten Wert herausholen.
514             const SwFmtFrmSize& rOldSize = static_cast<const SwFmtFrmSize&>(
515                     m_pOldSet->Get( RES_FRM_SIZE ) );
516 			aDrawSavePt.X() = rOldSize.GetWidth();
517 			aDrawSavePt.Y() = rOldSize.GetHeight();
518             m_pOldSet->ClearItem( RES_FRM_SIZE );
519 
520 			// den akt. wieder zwischenspeichern
521 			aDrawOldPt = pFrmFmt->FindSdrObject()->GetRelativePos();
522 //JP 08.10.97: ist laut AMA/MA nicht mehr noetig
523 //			pCont->DisconnectFromLayout();
524         }
525         else
526         {
527             pFrmFmt->DelFrms();         // delete Frms
528         }
529     }
530 
531 	const SwFmtAnchor &rOldAnch = pFrmFmt->GetAnchor();
532     // --> OD 2006-03-13 #i54336#
533     // Consider case, that as-character anchored object has moved its anchor position.
534     if (FLY_AS_CHAR == rOldAnch.GetAnchorId())
535     // <--
536 	{
537 		//Bei InCntnt's wird es spannend: Das TxtAttribut muss vernichtet
538 		//werden. Leider reisst dies neben den Frms auch noch das Format mit
539 		//in sein Grab. Um dass zu unterbinden loesen wir vorher die
540 		//Verbindung zwischen Attribut und Format.
541 		const SwPosition *pPos = rOldAnch.GetCntntAnchor();
542 		SwTxtNode *pTxtNode = (SwTxtNode*)&pPos->nNode.GetNode();
543 		ASSERT( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." );
544 		const xub_StrLen nIdx = pPos->nContent.GetIndex();
545         SwTxtAttr * const pHnt =
546             pTxtNode->GetTxtAttrForCharAt( nIdx, RES_TXTATR_FLYCNT );
547 		ASSERT( pHnt && pHnt->Which() == RES_TXTATR_FLYCNT,
548 					"Missing FlyInCnt-Hint." );
549 		ASSERT( pHnt && pHnt->GetFlyCnt().GetFrmFmt() == pFrmFmt,
550 					"Wrong TxtFlyCnt-Hint." );
551         const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt()).SetFlyFmt();
552 
553 		//Die Verbindung ist geloest, jetzt muss noch das Attribut vernichtet
554 		//werden.
555         pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx, nIdx );
556     }
557 
558     {
559         m_pOldSet->Put( aNewAnchor );
560         SwUndoFmtAttrHelper aTmp( *m_pFmt, m_bSaveDrawPt );
561         m_pFmt->SetFmtAttr( *m_pOldSet );
562         if ( aTmp.GetUndo() )
563         {
564             m_nNodeIndex = aTmp.GetUndo()->m_nNodeIndex;
565             // transfer ownership of helper object's old set
566             m_pOldSet = aTmp.GetUndo()->m_pOldSet;
567         }
568         else
569         {
570             m_pOldSet->ClearItem();
571         }
572     }
573 
574     if ( RES_DRAWFRMFMT == pFrmFmt->Which() )
575     {
576         SwDrawContact *pCont =
577             static_cast<SwDrawContact*>(pFrmFmt->FindContactObj());
578 		// das Draw-Model hat auch noch ein Undo-Object fuer die
579 		// richtige Position vorbereitet; dieses ist aber relativ.
580 		// Darum verhinder hier, das durch setzen des Ankers das
581 		// Contact-Object seine Position aendert.
582 //JP 08.10.97: ist laut AMA/MA nicht mehr noetig
583 //			pCont->ConnectToLayout();
584 		SdrObject* pObj = pCont->GetMaster();
585 
586         if( pCont->GetAnchorFrm() && !pObj->IsInserted() )
587 		{
588 			ASSERT( pDoc->GetDrawModel(), "RestoreFlyAnchor without DrawModel" );
589 			pDoc->GetDrawModel()->GetPage( 0 )->InsertObject( pObj );
590 		}
591 		pObj->SetRelativePos( aDrawSavePt );
592 
593 		// den alten Wert wieder zwischenspeichern.
594         m_pOldSet->Put(
595             SwFmtFrmSize( ATT_VAR_SIZE, aDrawOldPt.X(), aDrawOldPt.Y() ) );
596     }
597 
598     if (FLY_AS_CHAR == aNewAnchor.GetAnchorId())
599     {
600 		const SwPosition* pPos = aNewAnchor.GetCntntAnchor();
601 		SwTxtNode* pTxtNd = pPos->nNode.GetNode().GetTxtNode();
602         ASSERT( pTxtNd, "no Text Node at position." );
603         SwFmtFlyCnt aFmt( pFrmFmt );
604         pTxtNd->InsertItem( aFmt, pPos->nContent.GetIndex(), 0 );
605     }
606 
607 
608 	if( RES_DRAWFRMFMT != pFrmFmt->Which() )
609 		pFrmFmt->MakeFrms();
610 
611     rContext.SetSelections(pFrmFmt, 0);
612 
613     // --> OD 2004-10-26 #i35443# - anchor attribute restored.
614     return true;
615     // <--
616 }
617 
618 // -----------------------------------------------------
619 
620 // --> OD 2008-02-12 #newlistlevelattrs#
SwUndoFmtResetAttr(SwFmt & rChangedFormat,const sal_uInt16 nWhichId)621 SwUndoFmtResetAttr::SwUndoFmtResetAttr( SwFmt& rChangedFormat,
622                                         const sal_uInt16 nWhichId )
623     : SwUndo( UNDO_RESETATTR )
624     , m_pChangedFormat( &rChangedFormat )
625     , m_nWhichId( nWhichId )
626     , m_pOldItem( 0 )
627 {
628     const SfxPoolItem* pItem = 0;
629     if (rChangedFormat.GetItemState( nWhichId, sal_False, &pItem ) == SFX_ITEM_SET)
630     {
631         m_pOldItem.reset( pItem->Clone() );
632     }
633 }
634 
~SwUndoFmtResetAttr()635 SwUndoFmtResetAttr::~SwUndoFmtResetAttr()
636 {
637 }
638 
UndoImpl(::sw::UndoRedoContext &)639 void SwUndoFmtResetAttr::UndoImpl(::sw::UndoRedoContext &)
640 {
641     if ( m_pOldItem.get() )
642     {
643         m_pChangedFormat->SetFmtAttr( *m_pOldItem );
644     }
645 }
646 
RedoImpl(::sw::UndoRedoContext &)647 void SwUndoFmtResetAttr::RedoImpl(::sw::UndoRedoContext &)
648 {
649     if ( m_pOldItem.get() )
650     {
651         m_pChangedFormat->ResetFmtAttr( m_nWhichId );
652     }
653 }
654 // <--
655 
656 // -----------------------------------------------------
657 
SwUndoResetAttr(const SwPaM & rRange,sal_uInt16 nFmtId)658 SwUndoResetAttr::SwUndoResetAttr( const SwPaM& rRange, sal_uInt16 nFmtId )
659     : SwUndo( UNDO_RESETATTR ), SwUndRng( rRange )
660     , m_pHistory( new SwHistory )
661     , m_nFormatId( nFmtId )
662 {
663 }
664 
SwUndoResetAttr(const SwPosition & rPos,sal_uInt16 nFmtId)665 SwUndoResetAttr::SwUndoResetAttr( const SwPosition& rPos, sal_uInt16 nFmtId )
666     : SwUndo( UNDO_RESETATTR )
667     , m_pHistory( new SwHistory )
668     , m_nFormatId( nFmtId )
669 {
670     nSttNode = nEndNode = rPos.nNode.GetIndex();
671     nSttCntnt = nEndCntnt = rPos.nContent.GetIndex();
672 }
673 
~SwUndoResetAttr()674 SwUndoResetAttr::~SwUndoResetAttr()
675 {
676 }
677 
UndoImpl(::sw::UndoRedoContext & rContext)678 void SwUndoResetAttr::UndoImpl(::sw::UndoRedoContext & rContext)
679 {
680     // reset old values
681     SwDoc & rDoc = rContext.GetDoc();
682     m_pHistory->TmpRollback( &rDoc, 0 );
683     m_pHistory->SetTmpEnd( m_pHistory->Count() );
684 
685     if ((RES_CONDTXTFMTCOLL == m_nFormatId) &&
686         (nSttNode == nEndNode) && (nSttCntnt == nEndCntnt))
687     {
688 		SwTxtNode* pTNd = rDoc.GetNodes()[ nSttNode ]->GetTxtNode();
689 		if( pTNd )
690 		{
691 			SwIndex aIdx( pTNd, nSttCntnt );
692 			pTNd->DontExpandFmt( aIdx, sal_False );
693 		}
694 	}
695 
696     AddUndoRedoPaM(rContext);
697 }
698 
RedoImpl(::sw::UndoRedoContext & rContext)699 void SwUndoResetAttr::RedoImpl(::sw::UndoRedoContext & rContext)
700 {
701     SwDoc & rDoc = rContext.GetDoc();
702     SwPaM & rPam = AddUndoRedoPaM(rContext);
703     SvUShortsSort* pIdArr = m_Ids.Count() ? &m_Ids : 0;
704 
705     switch ( m_nFormatId )
706     {
707 	case RES_CHRFMT:
708         rDoc.RstTxtAttrs(rPam);
709 		break;
710 	case RES_TXTFMTCOLL:
711         rDoc.ResetAttrs(rPam, sal_False, pIdArr );
712 		break;
713 	case RES_CONDTXTFMTCOLL:
714         rDoc.ResetAttrs(rPam, sal_True, pIdArr );
715 
716 		break;
717 	case RES_TXTATR_TOXMARK:
718         // special treatment for TOXMarks
719         {
720 			SwTOXMarks aArr;
721 			SwNodeIndex aIdx( rDoc.GetNodes(), nSttNode );
722 			SwPosition aPos( aIdx, SwIndex( aIdx.GetNode().GetCntntNode(),
723 																nSttCntnt ));
724 
725 			sal_uInt16 nCnt = rDoc.GetCurTOXMark( aPos, aArr );
726 			if( nCnt )
727 			{
728 				if( 1 < nCnt )
729 				{
730                     // search for the right one
731                     SwHistoryHint* pHHint = (GetHistory())[ 0 ];
732 					if( pHHint && HSTRY_SETTOXMARKHNT == pHHint->Which() )
733 					{
734 						while( nCnt )
735                         {
736                             if ( static_cast<SwHistorySetTOXMark*>(pHHint)
737                                     ->IsEqual( *aArr[ --nCnt ] ) )
738                             {
739 								++nCnt;
740 								break;
741                             }
742                         }
743 					}
744 					else
745 						nCnt = 0;
746 				}
747 				// gefunden, also loeschen
748 				if( nCnt-- )
749                 {
750                     rDoc.DeleteTOXMark( aArr[ nCnt ] );
751                 }
752 			}
753 		}
754 		break;
755 	}
756 }
757 
RepeatImpl(::sw::RepeatContext & rContext)758 void SwUndoResetAttr::RepeatImpl(::sw::RepeatContext & rContext)
759 {
760     if (m_nFormatId < RES_FMT_BEGIN)
761     {
762         return;
763     }
764 
765     SvUShortsSort* pIdArr = m_Ids.Count() ? &m_Ids : 0;
766     switch ( m_nFormatId )
767     {
768 	case RES_CHRFMT:
769         rContext.GetDoc().RstTxtAttrs(rContext.GetRepeatPaM());
770 		break;
771 	case RES_TXTFMTCOLL:
772         rContext.GetDoc().ResetAttrs(rContext.GetRepeatPaM(), false, pIdArr);
773 		break;
774 	case RES_CONDTXTFMTCOLL:
775         rContext.GetDoc().ResetAttrs(rContext.GetRepeatPaM(), true, pIdArr);
776 		break;
777 	}
778 }
779 
780 
SetAttrs(const SvUShortsSort & rArr)781 void SwUndoResetAttr::SetAttrs( const SvUShortsSort& rArr )
782 {
783     if ( m_Ids.Count() )
784     {
785         m_Ids.Remove( 0, m_Ids.Count() );
786     }
787     m_Ids.Insert( &rArr );
788 }
789 
790 // -----------------------------------------------------
791 
792 
SwUndoAttr(const SwPaM & rRange,const SfxPoolItem & rAttr,const SetAttrMode nFlags)793 SwUndoAttr::SwUndoAttr( const SwPaM& rRange, const SfxPoolItem& rAttr,
794                         const SetAttrMode nFlags )
795     : SwUndo( UNDO_INSATTR ), SwUndRng( rRange )
796     , m_AttrSet( rRange.GetDoc()->GetAttrPool(), rAttr.Which(), rAttr.Which() )
797     , m_pHistory( new SwHistory )
798     , m_pRedlineData( 0 )
799     , m_pRedlineSaveData( 0 )
800     , m_nNodeIndex( ULONG_MAX )
801     , m_nInsertFlags( nFlags )
802 {
803     m_AttrSet.Put( rAttr );
804 }
805 
SwUndoAttr(const SwPaM & rRange,const SfxItemSet & rSet,const SetAttrMode nFlags)806 SwUndoAttr::SwUndoAttr( const SwPaM& rRange, const SfxItemSet& rSet,
807                         const SetAttrMode nFlags )
808     : SwUndo( UNDO_INSATTR ), SwUndRng( rRange )
809     , m_AttrSet( rSet )
810     , m_pHistory( new SwHistory )
811     , m_pRedlineData( 0 )
812     , m_pRedlineSaveData( 0 )
813     , m_nNodeIndex( ULONG_MAX )
814     , m_nInsertFlags( nFlags )
815 {
816 }
817 
~SwUndoAttr()818 SwUndoAttr::~SwUndoAttr()
819 {
820 }
821 
SaveRedlineData(const SwPaM & rPam,sal_Bool bIsCntnt)822 void SwUndoAttr::SaveRedlineData( const SwPaM& rPam, sal_Bool bIsCntnt )
823 {
824     SwDoc* pDoc = rPam.GetDoc();
825     if ( pDoc->IsRedlineOn() )
826     {
827         m_pRedlineData.reset( new SwRedlineData( bIsCntnt
828                                     ? nsRedlineType_t::REDLINE_INSERT
829                                     : nsRedlineType_t::REDLINE_FORMAT,
830                                 pDoc->GetRedlineAuthor() ) );
831     }
832 
833     m_pRedlineSaveData.reset( new SwRedlineSaveDatas );
834     if ( !FillSaveDataForFmt( rPam, *m_pRedlineSaveData ))
835     {
836         m_pRedlineSaveData.reset(0);
837     }
838 
839     SetRedlineMode( pDoc->GetRedlineMode() );
840     if ( bIsCntnt )
841     {
842         m_nNodeIndex = rPam.GetPoint()->nNode.GetIndex();
843     }
844 }
845 
UndoImpl(::sw::UndoRedoContext & rContext)846 void SwUndoAttr::UndoImpl(::sw::UndoRedoContext & rContext)
847 {
848     SwDoc *const pDoc = & rContext.GetDoc();
849 
850 	RemoveIdx( *pDoc );
851 
852 	if( IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() ) )
853 	{
854         SwPaM aPam(pDoc->GetNodes().GetEndOfContent());
855         if ( ULONG_MAX != m_nNodeIndex )
856         {
857             aPam.DeleteMark();
858             aPam.GetPoint()->nNode = m_nNodeIndex;
859             aPam.GetPoint()->nContent.Assign( aPam.GetCntntNode(), nSttCntnt );
860             aPam.SetMark();
861             aPam.GetPoint()->nContent++;
862             pDoc->DeleteRedline(aPam, false, USHRT_MAX);
863 		}
864 		else
865 		{
866 			// alle Format-Redlines entfernen, werden ggfs. neu gesetzt
867             SetPaM(aPam);
868             pDoc->DeleteRedline(aPam, false, nsRedlineType_t::REDLINE_FORMAT);
869             if ( m_pRedlineSaveData.get() )
870             {
871                 SetSaveData( *pDoc, *m_pRedlineSaveData );
872             }
873         }
874     }
875 
876     const bool bToLast =  (1 == m_AttrSet.Count())
877                        && (RES_TXTATR_FIELD <= *m_AttrSet.GetRanges())
878                        && (*m_AttrSet.GetRanges() <= RES_TXTATR_ANNOTATION);
879 
880     // restore old values
881     m_pHistory->TmpRollback( pDoc, 0, !bToLast );
882     m_pHistory->SetTmpEnd( m_pHistory->Count() );
883 
884     // set cursor onto Undo area
885     AddUndoRedoPaM(rContext);
886 }
887 
RepeatImpl(::sw::RepeatContext & rContext)888 void SwUndoAttr::RepeatImpl(::sw::RepeatContext & rContext)
889 {
890     // RefMarks are not repeat capable
891     if ( SFX_ITEM_SET != m_AttrSet.GetItemState( RES_TXTATR_REFMARK, sal_False ) )
892     {
893         rContext.GetDoc().InsertItemSet( rContext.GetRepeatPaM(),
894                                            m_AttrSet, m_nInsertFlags );
895     }
896     else if ( 1 < m_AttrSet.Count() )
897     {
898         SfxItemSet aTmpSet( m_AttrSet );
899         aTmpSet.ClearItem( RES_TXTATR_REFMARK );
900         rContext.GetDoc().InsertItemSet( rContext.GetRepeatPaM(),
901                                            aTmpSet, m_nInsertFlags );
902     }
903 }
904 
RedoImpl(::sw::UndoRedoContext & rContext)905 void SwUndoAttr::RedoImpl(::sw::UndoRedoContext & rContext)
906 {
907     SwDoc & rDoc = rContext.GetDoc();
908     SwPaM & rPam = AddUndoRedoPaM(rContext);
909 
910     if ( m_pRedlineData.get() &&
911          IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() ) )
912     {
913         RedlineMode_t eOld = rDoc.GetRedlineMode();
914         rDoc.SetRedlineMode_intern(static_cast<RedlineMode_t>(
915                     eOld & ~nsRedlineMode_t::REDLINE_IGNORE));
916         rDoc.InsertItemSet( rPam, m_AttrSet, m_nInsertFlags );
917 
918         if ( ULONG_MAX != m_nNodeIndex )
919         {
920             rPam.SetMark();
921             if ( rPam.Move( fnMoveBackward ) )
922             {
923                 rDoc.AppendRedline( new SwRedline( *m_pRedlineData, rPam ),
924                         true);
925             }
926             rPam.DeleteMark();
927         }
928         else
929         {
930             rDoc.AppendRedline( new SwRedline( *m_pRedlineData, rPam ), true);
931         }
932 
933         rDoc.SetRedlineMode_intern( eOld );
934     }
935     else
936     {
937         rDoc.InsertItemSet( rPam, m_AttrSet, m_nInsertFlags );
938     }
939 }
940 
941 
RemoveIdx(SwDoc & rDoc)942 void SwUndoAttr::RemoveIdx( SwDoc& rDoc )
943 {
944     if ( SFX_ITEM_SET != m_AttrSet.GetItemState( RES_TXTATR_FTN, sal_False ))
945 		return ;
946 
947     SwHistoryHint* pHstHnt;
948 	SwNodes& rNds = rDoc.GetNodes();
949     for ( sal_uInt16 n = 0; n < m_pHistory->Count(); ++n )
950     {
951 		xub_StrLen nCntnt = 0;
952 		sal_uLong nNode = 0;
953         pHstHnt = (*m_pHistory)[ n ];
954         switch ( pHstHnt->Which() )
955         {
956             case HSTRY_RESETTXTHNT:
957                 {
958                     SwHistoryResetTxt * pHistoryHint
959                         = static_cast<SwHistoryResetTxt*>(pHstHnt);
960                     if ( RES_TXTATR_FTN == pHistoryHint->GetWhich() )
961                     {
962                         nNode = pHistoryHint->GetNode();
963                         nCntnt = pHistoryHint->GetCntnt();
964                     }
965                 }
966                 break;
967 
968             case HSTRY_RESETATTRSET:
969                 {
970                     SwHistoryResetAttrSet * pHistoryHint
971                         = static_cast<SwHistoryResetAttrSet*>(pHstHnt);
972                     nCntnt = pHistoryHint->GetCntnt();
973                     if ( STRING_MAXLEN != nCntnt )
974                     {
975                         const SvUShorts& rArr = pHistoryHint->GetArr();
976                         for ( sal_uInt16 i = rArr.Count(); i; )
977                         {
978                             if ( RES_TXTATR_FTN == rArr[ --i ] )
979                             {
980                                 nNode = pHistoryHint->GetNode();
981                                 break;
982                             }
983                         }
984                     }
985                 }
986                 break;
987 
988             default:
989                 break;
990         }
991 
992 		if( nNode )
993 		{
994 			SwTxtNode* pTxtNd = rNds[ nNode ]->GetTxtNode();
995 			if( pTxtNd )
996 			{
997                 SwTxtAttr *const pTxtHt =
998                     pTxtNd->GetTxtAttrForCharAt(nCntnt, RES_TXTATR_FTN);
999 				if( pTxtHt )
1000 				{
1001 					// ok, dann hole mal die Werte
1002                     SwTxtFtn* pFtn = static_cast<SwTxtFtn*>(pTxtHt);
1003 					RemoveIdxFromSection( rDoc, pFtn->GetStartNode()->GetIndex() );
1004 					return ;
1005 				}
1006 			}
1007 		}
1008 	}
1009 }
1010 
1011 // -----------------------------------------------------
1012 
SwUndoDefaultAttr(const SfxItemSet & rSet)1013 SwUndoDefaultAttr::SwUndoDefaultAttr( const SfxItemSet& rSet )
1014     : SwUndo( UNDO_SETDEFTATTR )
1015     , m_pOldSet( 0 )
1016     , m_pTabStop( 0 )
1017 {
1018 	const SfxPoolItem* pItem;
1019 	if( SFX_ITEM_SET == rSet.GetItemState( RES_PARATR_TABSTOP, sal_False, &pItem ) )
1020     {
1021         // store separately, because it may change!
1022         m_pTabStop.reset( static_cast<SvxTabStopItem*>(pItem->Clone()) );
1023         if ( 1 != rSet.Count() ) // are there more attributes?
1024         {
1025             m_pOldSet.reset( new SfxItemSet( rSet ) );
1026         }
1027     }
1028     else
1029     {
1030         m_pOldSet.reset( new SfxItemSet( rSet ) );
1031     }
1032 }
1033 
~SwUndoDefaultAttr()1034 SwUndoDefaultAttr::~SwUndoDefaultAttr()
1035 {
1036 }
1037 
UndoImpl(::sw::UndoRedoContext & rContext)1038 void SwUndoDefaultAttr::UndoImpl(::sw::UndoRedoContext & rContext)
1039 {
1040     SwDoc & rDoc = rContext.GetDoc();
1041     if ( m_pOldSet.get() )
1042     {
1043         SwUndoFmtAttrHelper aTmp(
1044                 *const_cast<SwTxtFmtColl*>(rDoc.GetDfltTxtFmtColl()) );
1045         rDoc.SetDefault( *m_pOldSet );
1046         m_pOldSet.reset( 0 );
1047         if ( aTmp.GetUndo() )
1048         {
1049             // transfer ownership of helper object's old set
1050             m_pOldSet = aTmp.GetUndo()->m_pOldSet;
1051         }
1052     }
1053     if ( m_pTabStop.get() )
1054     {
1055         SvxTabStopItem* pOld = static_cast<SvxTabStopItem*>(
1056                 rDoc.GetDefault( RES_PARATR_TABSTOP ).Clone() );
1057         rDoc.SetDefault( *m_pTabStop );
1058         m_pTabStop.reset( pOld );
1059     }
1060 }
1061 
RedoImpl(::sw::UndoRedoContext & rContext)1062 void SwUndoDefaultAttr::RedoImpl(::sw::UndoRedoContext & rContext)
1063 {
1064     UndoImpl(rContext);
1065 }
1066 
1067 // -----------------------------------------------------
1068 
SwUndoMoveLeftMargin(const SwPaM & rPam,sal_Bool bFlag,sal_Bool bMod)1069 SwUndoMoveLeftMargin::SwUndoMoveLeftMargin(
1070             const SwPaM& rPam, sal_Bool bFlag, sal_Bool bMod )
1071     : SwUndo( bFlag ? UNDO_INC_LEFTMARGIN : UNDO_DEC_LEFTMARGIN )
1072     , SwUndRng( rPam )
1073     , m_pHistory( new SwHistory )
1074     , m_bModulus( bMod )
1075 {
1076 }
1077 
~SwUndoMoveLeftMargin()1078 SwUndoMoveLeftMargin::~SwUndoMoveLeftMargin()
1079 {
1080 }
1081 
UndoImpl(::sw::UndoRedoContext & rContext)1082 void SwUndoMoveLeftMargin::UndoImpl(::sw::UndoRedoContext & rContext)
1083 {
1084     SwDoc & rDoc = rContext.GetDoc();
1085 
1086     // restore old values
1087     m_pHistory->TmpRollback( & rDoc, 0 );
1088     m_pHistory->SetTmpEnd( m_pHistory->Count() );
1089 
1090     AddUndoRedoPaM(rContext);
1091 }
1092 
RedoImpl(::sw::UndoRedoContext & rContext)1093 void SwUndoMoveLeftMargin::RedoImpl(::sw::UndoRedoContext & rContext)
1094 {
1095     SwDoc & rDoc = rContext.GetDoc();
1096     SwPaM & rPam = AddUndoRedoPaM(rContext);
1097 
1098     rDoc.MoveLeftMargin( rPam,
1099             GetId() == UNDO_INC_LEFTMARGIN, m_bModulus );
1100 }
1101 
RepeatImpl(::sw::RepeatContext & rContext)1102 void SwUndoMoveLeftMargin::RepeatImpl(::sw::RepeatContext & rContext)
1103 {
1104     SwDoc & rDoc = rContext.GetDoc();
1105     rDoc.MoveLeftMargin(rContext.GetRepeatPaM(), GetId() == UNDO_INC_LEFTMARGIN,
1106             m_bModulus );
1107 }
1108 
1109 // -----------------------------------------------------
1110 
SwUndoChangeFootNote(const SwPaM & rRange,const String & rTxt,sal_uInt16 nNum,bool bIsEndNote)1111 SwUndoChangeFootNote::SwUndoChangeFootNote(
1112             const SwPaM& rRange, const String& rTxt,
1113             sal_uInt16 nNum, bool bIsEndNote )
1114     : SwUndo( UNDO_CHGFTN ), SwUndRng( rRange )
1115     , m_pHistory( new SwHistory() )
1116     , m_Text( rTxt )
1117     , m_nNumber( nNum )
1118     , m_bEndNote( bIsEndNote )
1119 {
1120 }
1121 
~SwUndoChangeFootNote()1122 SwUndoChangeFootNote::~SwUndoChangeFootNote()
1123 {
1124 }
1125 
UndoImpl(::sw::UndoRedoContext & rContext)1126 void SwUndoChangeFootNote::UndoImpl(::sw::UndoRedoContext & rContext)
1127 {
1128     SwDoc & rDoc = rContext.GetDoc();
1129 
1130     m_pHistory->TmpRollback( &rDoc, 0 );
1131     m_pHistory->SetTmpEnd( m_pHistory->Count() );
1132 
1133 	rDoc.GetFtnIdxs().UpdateAllFtn();
1134 
1135     AddUndoRedoPaM(rContext);
1136 }
1137 
RedoImpl(::sw::UndoRedoContext & rContext)1138 void SwUndoChangeFootNote::RedoImpl(::sw::UndoRedoContext & rContext)
1139 {
1140     SwDoc & rDoc( rContext.GetDoc() );
1141     SwPaM & rPaM = AddUndoRedoPaM(rContext);
1142     rDoc.SetCurFtn(rPaM, m_Text, m_nNumber, m_bEndNote);
1143     SetPaM(rPaM);
1144 }
1145 
RepeatImpl(::sw::RepeatContext & rContext)1146 void SwUndoChangeFootNote::RepeatImpl(::sw::RepeatContext & rContext)
1147 {
1148     SwDoc & rDoc = rContext.GetDoc();
1149     rDoc.SetCurFtn( rContext.GetRepeatPaM(), m_Text, m_nNumber, m_bEndNote );
1150 }
1151 
1152 
1153 // -----------------------------------------------------
1154 
1155 
SwUndoFootNoteInfo(const SwFtnInfo & rInfo)1156 SwUndoFootNoteInfo::SwUndoFootNoteInfo( const SwFtnInfo &rInfo )
1157     : SwUndo( UNDO_FTNINFO )
1158     , m_pFootNoteInfo( new SwFtnInfo( rInfo ) )
1159 {
1160 }
1161 
~SwUndoFootNoteInfo()1162 SwUndoFootNoteInfo::~SwUndoFootNoteInfo()
1163 {
1164 }
1165 
UndoImpl(::sw::UndoRedoContext & rContext)1166 void SwUndoFootNoteInfo::UndoImpl(::sw::UndoRedoContext & rContext)
1167 {
1168     SwDoc & rDoc = rContext.GetDoc();
1169 	SwFtnInfo *pInf = new SwFtnInfo( rDoc.GetFtnInfo() );
1170     rDoc.SetFtnInfo( *m_pFootNoteInfo );
1171     m_pFootNoteInfo.reset( pInf );
1172 }
1173 
RedoImpl(::sw::UndoRedoContext & rContext)1174 void SwUndoFootNoteInfo::RedoImpl(::sw::UndoRedoContext & rContext)
1175 {
1176     SwDoc & rDoc = rContext.GetDoc();
1177 	SwFtnInfo *pInf = new SwFtnInfo( rDoc.GetFtnInfo() );
1178     rDoc.SetFtnInfo( *m_pFootNoteInfo );
1179     m_pFootNoteInfo.reset( pInf );
1180 }
1181 
1182 
1183 // -----------------------------------------------------
1184 
SwUndoEndNoteInfo(const SwEndNoteInfo & rInfo)1185 SwUndoEndNoteInfo::SwUndoEndNoteInfo( const SwEndNoteInfo &rInfo )
1186     : SwUndo( UNDO_FTNINFO )
1187     , m_pEndNoteInfo( new SwEndNoteInfo( rInfo ) )
1188 {
1189 }
1190 
~SwUndoEndNoteInfo()1191 SwUndoEndNoteInfo::~SwUndoEndNoteInfo()
1192 {
1193 }
1194 
UndoImpl(::sw::UndoRedoContext & rContext)1195 void SwUndoEndNoteInfo::UndoImpl(::sw::UndoRedoContext & rContext)
1196 {
1197     SwDoc & rDoc = rContext.GetDoc();
1198 	SwEndNoteInfo *pInf = new SwEndNoteInfo( rDoc.GetEndNoteInfo() );
1199     rDoc.SetEndNoteInfo( *m_pEndNoteInfo );
1200     m_pEndNoteInfo.reset( pInf );
1201 }
1202 
RedoImpl(::sw::UndoRedoContext & rContext)1203 void SwUndoEndNoteInfo::RedoImpl(::sw::UndoRedoContext & rContext)
1204 {
1205     SwDoc & rDoc = rContext.GetDoc();
1206 	SwEndNoteInfo *pInf = new SwEndNoteInfo( rDoc.GetEndNoteInfo() );
1207     rDoc.SetEndNoteInfo( *m_pEndNoteInfo );
1208     m_pEndNoteInfo.reset( pInf );
1209 }
1210 
1211 // -----------------------------------------------------
1212 
SwUndoDontExpandFmt(const SwPosition & rPos)1213 SwUndoDontExpandFmt::SwUndoDontExpandFmt( const SwPosition& rPos )
1214     : SwUndo( UNDO_DONTEXPAND )
1215     , m_nNodeIndex( rPos.nNode.GetIndex() )
1216     , m_nContentIndex( rPos.nContent.GetIndex() )
1217 {
1218 }
1219 
UndoImpl(::sw::UndoRedoContext & rContext)1220 void SwUndoDontExpandFmt::UndoImpl(::sw::UndoRedoContext & rContext)
1221 {
1222     SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
1223     SwDoc *const pDoc = & rContext.GetDoc();
1224 
1225 	SwPosition& rPos = *pPam->GetPoint();
1226     rPos.nNode = m_nNodeIndex;
1227     rPos.nContent.Assign( rPos.nNode.GetNode().GetCntntNode(), m_nContentIndex);
1228 	pDoc->DontExpandFmt( rPos, sal_False );
1229 }
1230 
1231 
RedoImpl(::sw::UndoRedoContext & rContext)1232 void SwUndoDontExpandFmt::RedoImpl(::sw::UndoRedoContext & rContext)
1233 {
1234     SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
1235     SwDoc *const pDoc = & rContext.GetDoc();
1236 
1237 	SwPosition& rPos = *pPam->GetPoint();
1238     rPos.nNode = m_nNodeIndex;
1239     rPos.nContent.Assign( rPos.nNode.GetNode().GetCntntNode(), m_nContentIndex);
1240 	pDoc->DontExpandFmt( rPos );
1241 }
1242 
RepeatImpl(::sw::RepeatContext & rContext)1243 void SwUndoDontExpandFmt::RepeatImpl(::sw::RepeatContext & rContext)
1244 {
1245     SwPaM & rPam = rContext.GetRepeatPaM();
1246     SwDoc & rDoc = rContext.GetDoc();
1247     rDoc.DontExpandFmt( *rPam.GetPoint() );
1248 }
1249 
1250