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