1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*efeef26fSAndrew Rist * distributed with this work for additional information
6*efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
10*efeef26fSAndrew Rist *
11*efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*efeef26fSAndrew Rist *
13*efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17*efeef26fSAndrew Rist * specific language governing permissions and limitations
18*efeef26fSAndrew Rist * under the License.
19*efeef26fSAndrew Rist *
20*efeef26fSAndrew Rist *************************************************************/
21*efeef26fSAndrew Rist
22*efeef26fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <svl/itemiter.hxx>
28cdf0e10cSrcweir
29cdf0e10cSrcweir #include <hintids.hxx>
30cdf0e10cSrcweir #include <hints.hxx>
31cdf0e10cSrcweir #include <fmtflcnt.hxx>
32cdf0e10cSrcweir #include <fmtanchr.hxx>
33cdf0e10cSrcweir #include <fmtcntnt.hxx>
34cdf0e10cSrcweir #include <txtflcnt.hxx>
35cdf0e10cSrcweir #include <frmfmt.hxx>
36cdf0e10cSrcweir #include <flyfrm.hxx>
37cdf0e10cSrcweir #include <UndoCore.hxx>
38cdf0e10cSrcweir #include <UndoDraw.hxx>
39cdf0e10cSrcweir #include <rolbck.hxx> // fuer die Attribut History
40cdf0e10cSrcweir #include <doc.hxx>
41cdf0e10cSrcweir #include <docary.hxx>
42cdf0e10cSrcweir #include <rootfrm.hxx>
43cdf0e10cSrcweir #include <swundo.hxx> // fuer die UndoIds
44cdf0e10cSrcweir #include <pam.hxx>
45cdf0e10cSrcweir #include <ndtxt.hxx>
46cdf0e10cSrcweir // OD 26.06.2003 #108784#
47cdf0e10cSrcweir #include <dcontact.hxx>
48cdf0e10cSrcweir #include <ndole.hxx>
49cdf0e10cSrcweir
50cdf0e10cSrcweir
51cdf0e10cSrcweir //---------------------------------------------------------------------
52cdf0e10cSrcweir // SwUndoLayBase /////////////////////////////////////////////////////////
53cdf0e10cSrcweir
SwUndoFlyBase(SwFrmFmt * pFormat,SwUndoId nUndoId)54cdf0e10cSrcweir SwUndoFlyBase::SwUndoFlyBase( SwFrmFmt* pFormat, SwUndoId nUndoId )
55cdf0e10cSrcweir : SwUndo( nUndoId ), pFrmFmt( pFormat )
56cdf0e10cSrcweir {
57cdf0e10cSrcweir }
58cdf0e10cSrcweir
~SwUndoFlyBase()59cdf0e10cSrcweir SwUndoFlyBase::~SwUndoFlyBase()
60cdf0e10cSrcweir {
61cdf0e10cSrcweir if( bDelFmt ) // loeschen waehrend eines Undo's ??
62cdf0e10cSrcweir delete pFrmFmt;
63cdf0e10cSrcweir }
64cdf0e10cSrcweir
InsFly(::sw::UndoRedoContext & rContext,bool bShowSelFrm)65cdf0e10cSrcweir void SwUndoFlyBase::InsFly(::sw::UndoRedoContext & rContext, bool bShowSelFrm)
66cdf0e10cSrcweir {
67cdf0e10cSrcweir SwDoc *const pDoc = & rContext.GetDoc();
68cdf0e10cSrcweir
69cdf0e10cSrcweir // ins Array wieder eintragen
70cdf0e10cSrcweir SwSpzFrmFmts& rFlyFmts = *(SwSpzFrmFmts*)pDoc->GetSpzFrmFmts();
71cdf0e10cSrcweir rFlyFmts.Insert( pFrmFmt, rFlyFmts.Count() );
72cdf0e10cSrcweir
73cdf0e10cSrcweir // OD 26.06.2003 #108784# - insert 'master' drawing object into drawing page
74cdf0e10cSrcweir if ( RES_DRAWFRMFMT == pFrmFmt->Which() )
75cdf0e10cSrcweir {
76cdf0e10cSrcweir SwDrawContact* pDrawContact =
77cdf0e10cSrcweir static_cast<SwDrawContact*>(pFrmFmt->FindContactObj());
78cdf0e10cSrcweir if ( pDrawContact )
79cdf0e10cSrcweir {
80cdf0e10cSrcweir pDrawContact->InsertMasterIntoDrawPage();
81cdf0e10cSrcweir // --> OD 2005-01-31 #i40845# - follow-up of #i35635#
82cdf0e10cSrcweir // move object to visible layer
83cdf0e10cSrcweir pDrawContact->MoveObjToVisibleLayer( pDrawContact->GetMaster() );
84cdf0e10cSrcweir // <--
85cdf0e10cSrcweir }
86cdf0e10cSrcweir }
87cdf0e10cSrcweir
88cdf0e10cSrcweir SwFmtAnchor aAnchor( (RndStdIds)nRndId );
89cdf0e10cSrcweir
90cdf0e10cSrcweir if (FLY_AT_PAGE == nRndId)
91cdf0e10cSrcweir {
92cdf0e10cSrcweir aAnchor.SetPageNum( (sal_uInt16)nNdPgPos );
93cdf0e10cSrcweir }
94cdf0e10cSrcweir else
95cdf0e10cSrcweir {
96cdf0e10cSrcweir SwPosition aNewPos(pDoc->GetNodes().GetEndOfContent());
97cdf0e10cSrcweir aNewPos.nNode = nNdPgPos;
98cdf0e10cSrcweir if ((FLY_AS_CHAR == nRndId) || (FLY_AT_CHAR == nRndId))
99cdf0e10cSrcweir {
100cdf0e10cSrcweir aNewPos.nContent.Assign( aNewPos.nNode.GetNode().GetCntntNode(),
101cdf0e10cSrcweir nCntPos );
102cdf0e10cSrcweir }
103cdf0e10cSrcweir aAnchor.SetAnchor( &aNewPos );
104cdf0e10cSrcweir }
105cdf0e10cSrcweir
106cdf0e10cSrcweir pFrmFmt->SetFmtAttr( aAnchor ); // Anker neu setzen
107cdf0e10cSrcweir
108cdf0e10cSrcweir if( RES_DRAWFRMFMT != pFrmFmt->Which() )
109cdf0e10cSrcweir {
110cdf0e10cSrcweir // Content holen und -Attribut neu setzen
111cdf0e10cSrcweir SwNodeIndex aIdx( pDoc->GetNodes() );
112cdf0e10cSrcweir RestoreSection( pDoc, &aIdx, SwFlyStartNode );
113cdf0e10cSrcweir pFrmFmt->SetFmtAttr( SwFmtCntnt( aIdx.GetNode().GetStartNode() ));
114cdf0e10cSrcweir }
115cdf0e10cSrcweir
116cdf0e10cSrcweir //JP 18.12.98: Bug 60505 - InCntntAttribut erst setzen, wenn der Inhalt
117cdf0e10cSrcweir // vorhanden ist! Sonst wuerde das Layout den Fly vorher
118cdf0e10cSrcweir // formatieren, aber keine Inhalt finden; so geschene bei
119cdf0e10cSrcweir // Grafiken aus dem Internet
120cdf0e10cSrcweir if (FLY_AS_CHAR == nRndId)
121cdf0e10cSrcweir {
122cdf0e10cSrcweir // es muss mindestens das Attribut im TextNode stehen
123cdf0e10cSrcweir SwCntntNode* pCNd = aAnchor.GetCntntAnchor()->nNode.GetNode().GetCntntNode();
124cdf0e10cSrcweir ASSERT( pCNd->IsTxtNode(), "no Text Node at position." );
125cdf0e10cSrcweir SwFmtFlyCnt aFmt( pFrmFmt );
126cdf0e10cSrcweir static_cast<SwTxtNode*>(pCNd)->InsertItem( aFmt, nCntPos, nCntPos );
127cdf0e10cSrcweir }
128cdf0e10cSrcweir
129cdf0e10cSrcweir pFrmFmt->MakeFrms();
130cdf0e10cSrcweir
131cdf0e10cSrcweir if( bShowSelFrm )
132cdf0e10cSrcweir {
133cdf0e10cSrcweir rContext.SetSelections(pFrmFmt, 0);
134cdf0e10cSrcweir }
135cdf0e10cSrcweir
136cdf0e10cSrcweir if( GetHistory() )
137cdf0e10cSrcweir GetHistory()->Rollback( pDoc );
138cdf0e10cSrcweir
139cdf0e10cSrcweir switch( nRndId )
140cdf0e10cSrcweir {
141cdf0e10cSrcweir case FLY_AS_CHAR:
142cdf0e10cSrcweir case FLY_AT_CHAR:
143cdf0e10cSrcweir {
144cdf0e10cSrcweir const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor();
145cdf0e10cSrcweir nNdPgPos = rAnchor.GetCntntAnchor()->nNode.GetIndex();
146cdf0e10cSrcweir nCntPos = rAnchor.GetCntntAnchor()->nContent.GetIndex();
147cdf0e10cSrcweir }
148cdf0e10cSrcweir break;
149cdf0e10cSrcweir case FLY_AT_PARA:
150cdf0e10cSrcweir case FLY_AT_FLY:
151cdf0e10cSrcweir {
152cdf0e10cSrcweir const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor();
153cdf0e10cSrcweir nNdPgPos = rAnchor.GetCntntAnchor()->nNode.GetIndex();
154cdf0e10cSrcweir }
155cdf0e10cSrcweir break;
156cdf0e10cSrcweir case FLY_AT_PAGE:
157cdf0e10cSrcweir break;
158cdf0e10cSrcweir }
159cdf0e10cSrcweir bDelFmt = sal_False;
160cdf0e10cSrcweir }
161cdf0e10cSrcweir
DelFly(SwDoc * pDoc)162cdf0e10cSrcweir void SwUndoFlyBase::DelFly( SwDoc* pDoc )
163cdf0e10cSrcweir {
164cdf0e10cSrcweir bDelFmt = sal_True; // im DTOR das Format loeschen
165cdf0e10cSrcweir pFrmFmt->DelFrms(); // Frms vernichten.
166cdf0e10cSrcweir
167cdf0e10cSrcweir // alle Uno-Objecte sollten sich jetzt abmelden
168cdf0e10cSrcweir {
169cdf0e10cSrcweir SwPtrMsgPoolItem aMsgHint( RES_REMOVE_UNO_OBJECT, pFrmFmt );
170cdf0e10cSrcweir pFrmFmt->ModifyNotification( &aMsgHint, &aMsgHint );
171cdf0e10cSrcweir }
172cdf0e10cSrcweir
173cdf0e10cSrcweir if ( RES_DRAWFRMFMT != pFrmFmt->Which() )
174cdf0e10cSrcweir {
175cdf0e10cSrcweir // gibt es ueberhaupt Inhalt, dann sicher diesen
176cdf0e10cSrcweir const SwFmtCntnt& rCntnt = pFrmFmt->GetCntnt();
177cdf0e10cSrcweir ASSERT( rCntnt.GetCntntIdx(), "Fly ohne Inhalt" );
178cdf0e10cSrcweir
179cdf0e10cSrcweir SaveSection( pDoc, *rCntnt.GetCntntIdx() );
180cdf0e10cSrcweir ((SwFmtCntnt&)rCntnt).SetNewCntntIdx( (const SwNodeIndex*)0 );
181cdf0e10cSrcweir }
182cdf0e10cSrcweir // OD 02.07.2003 #108784# - remove 'master' drawing object from drawing page
183cdf0e10cSrcweir else if ( RES_DRAWFRMFMT == pFrmFmt->Which() )
184cdf0e10cSrcweir {
185cdf0e10cSrcweir SwDrawContact* pDrawContact =
186cdf0e10cSrcweir static_cast<SwDrawContact*>(pFrmFmt->FindContactObj());
187cdf0e10cSrcweir if ( pDrawContact )
188cdf0e10cSrcweir {
189cdf0e10cSrcweir pDrawContact->RemoveMasterFromDrawPage();
190cdf0e10cSrcweir }
191cdf0e10cSrcweir }
192cdf0e10cSrcweir
193cdf0e10cSrcweir const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor();
194cdf0e10cSrcweir const SwPosition* pPos = rAnchor.GetCntntAnchor();
195cdf0e10cSrcweir // die Positionen im Nodes-Array haben sich verschoben
196cdf0e10cSrcweir nRndId = static_cast<sal_uInt16>(rAnchor.GetAnchorId());
197cdf0e10cSrcweir if (FLY_AS_CHAR == nRndId)
198cdf0e10cSrcweir {
199cdf0e10cSrcweir nNdPgPos = pPos->nNode.GetIndex();
200cdf0e10cSrcweir nCntPos = pPos->nContent.GetIndex();
201cdf0e10cSrcweir SwTxtNode *const pTxtNd = pPos->nNode.GetNode().GetTxtNode();
202cdf0e10cSrcweir OSL_ENSURE(pTxtNd, "no Textnode");
203cdf0e10cSrcweir SwTxtFlyCnt* const pAttr = static_cast<SwTxtFlyCnt*>(
204cdf0e10cSrcweir pTxtNd->GetTxtAttrForCharAt( nCntPos, RES_TXTATR_FLYCNT ) );
205cdf0e10cSrcweir // Attribut steht noch im TextNode, loeschen
206cdf0e10cSrcweir if( pAttr && pAttr->GetFlyCnt().GetFrmFmt() == pFrmFmt )
207cdf0e10cSrcweir {
208cdf0e10cSrcweir // Pointer auf 0, nicht loeschen
209cdf0e10cSrcweir ((SwFmtFlyCnt&)pAttr->GetFlyCnt()).SetFlyFmt();
210cdf0e10cSrcweir SwIndex aIdx( pPos->nContent );
211cdf0e10cSrcweir pTxtNd->EraseText( aIdx, 1 );
212cdf0e10cSrcweir }
213cdf0e10cSrcweir }
214cdf0e10cSrcweir else if (FLY_AT_CHAR == nRndId)
215cdf0e10cSrcweir {
216cdf0e10cSrcweir nNdPgPos = pPos->nNode.GetIndex();
217cdf0e10cSrcweir nCntPos = pPos->nContent.GetIndex();
218cdf0e10cSrcweir }
219cdf0e10cSrcweir else if ((FLY_AT_PARA == nRndId) || (FLY_AT_FLY == nRndId))
220cdf0e10cSrcweir {
221cdf0e10cSrcweir nNdPgPos = pPos->nNode.GetIndex();
222cdf0e10cSrcweir }
223cdf0e10cSrcweir else
224cdf0e10cSrcweir {
225cdf0e10cSrcweir nNdPgPos = rAnchor.GetPageNum();
226cdf0e10cSrcweir }
227cdf0e10cSrcweir
228cdf0e10cSrcweir pFrmFmt->ResetFmtAttr( RES_ANCHOR ); // Anchor loeschen
229cdf0e10cSrcweir
230cdf0e10cSrcweir
231cdf0e10cSrcweir // aus dem Array austragen
232cdf0e10cSrcweir SwSpzFrmFmts& rFlyFmts = *(SwSpzFrmFmts*)pDoc->GetSpzFrmFmts();
233cdf0e10cSrcweir rFlyFmts.Remove( rFlyFmts.GetPos( pFrmFmt ));
234cdf0e10cSrcweir }
235cdf0e10cSrcweir
236cdf0e10cSrcweir // SwUndoInsLayFmt ///////////////////////////////////////////////////////
237cdf0e10cSrcweir
SwUndoInsLayFmt(SwFrmFmt * pFormat,sal_uLong nNodeIdx,xub_StrLen nCntIdx)238cdf0e10cSrcweir SwUndoInsLayFmt::SwUndoInsLayFmt( SwFrmFmt* pFormat, sal_uLong nNodeIdx, xub_StrLen nCntIdx )
239cdf0e10cSrcweir : SwUndoFlyBase( pFormat, RES_DRAWFRMFMT == pFormat->Which() ?
240cdf0e10cSrcweir UNDO_INSDRAWFMT : UNDO_INSLAYFMT ),
241cdf0e10cSrcweir mnCrsrSaveIndexPara( nNodeIdx ), mnCrsrSaveIndexPos( nCntIdx )
242cdf0e10cSrcweir {
243cdf0e10cSrcweir const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor();
244cdf0e10cSrcweir nRndId = static_cast<sal_uInt16>(rAnchor.GetAnchorId());
245cdf0e10cSrcweir bDelFmt = sal_False;
246cdf0e10cSrcweir switch( nRndId )
247cdf0e10cSrcweir {
248cdf0e10cSrcweir case FLY_AT_PAGE:
249cdf0e10cSrcweir nNdPgPos = rAnchor.GetPageNum();
250cdf0e10cSrcweir break;
251cdf0e10cSrcweir case FLY_AT_PARA:
252cdf0e10cSrcweir case FLY_AT_FLY:
253cdf0e10cSrcweir nNdPgPos = rAnchor.GetCntntAnchor()->nNode.GetIndex();
254cdf0e10cSrcweir break;
255cdf0e10cSrcweir case FLY_AS_CHAR:
256cdf0e10cSrcweir case FLY_AT_CHAR:
257cdf0e10cSrcweir {
258cdf0e10cSrcweir const SwPosition* pPos = rAnchor.GetCntntAnchor();
259cdf0e10cSrcweir nCntPos = pPos->nContent.GetIndex();
260cdf0e10cSrcweir nNdPgPos = pPos->nNode.GetIndex();
261cdf0e10cSrcweir }
262cdf0e10cSrcweir break;
263cdf0e10cSrcweir default:
264cdf0e10cSrcweir ASSERT( sal_False, "Was denn fuer ein FlyFrame?" );
265cdf0e10cSrcweir }
266cdf0e10cSrcweir }
267cdf0e10cSrcweir
~SwUndoInsLayFmt()268cdf0e10cSrcweir SwUndoInsLayFmt::~SwUndoInsLayFmt()
269cdf0e10cSrcweir {
270cdf0e10cSrcweir }
271cdf0e10cSrcweir
UndoImpl(::sw::UndoRedoContext & rContext)272cdf0e10cSrcweir void SwUndoInsLayFmt::UndoImpl(::sw::UndoRedoContext & rContext)
273cdf0e10cSrcweir {
274cdf0e10cSrcweir SwDoc & rDoc(rContext.GetDoc());
275cdf0e10cSrcweir const SwFmtCntnt& rCntnt = pFrmFmt->GetCntnt();
276cdf0e10cSrcweir if( rCntnt.GetCntntIdx() ) // kein Inhalt
277cdf0e10cSrcweir {
278cdf0e10cSrcweir bool bRemoveIdx = true;
279cdf0e10cSrcweir if( mnCrsrSaveIndexPara > 0 )
280cdf0e10cSrcweir {
281cdf0e10cSrcweir SwTxtNode *const pNode =
282cdf0e10cSrcweir rDoc.GetNodes()[mnCrsrSaveIndexPara]->GetTxtNode();
283cdf0e10cSrcweir if( pNode )
284cdf0e10cSrcweir {
285cdf0e10cSrcweir SwNodeIndex aIdx( rDoc.GetNodes(),
286cdf0e10cSrcweir rCntnt.GetCntntIdx()->GetIndex() );
287cdf0e10cSrcweir SwNodeIndex aEndIdx( rDoc.GetNodes(),
288cdf0e10cSrcweir aIdx.GetNode().EndOfSectionIndex() );
289cdf0e10cSrcweir SwIndex aIndex( pNode, mnCrsrSaveIndexPos );
290cdf0e10cSrcweir SwPosition aPos( *pNode, aIndex );
291cdf0e10cSrcweir rDoc.CorrAbs( aIdx, aEndIdx, aPos, sal_True );
292cdf0e10cSrcweir bRemoveIdx = false;
293cdf0e10cSrcweir }
294cdf0e10cSrcweir }
295cdf0e10cSrcweir if( bRemoveIdx )
296cdf0e10cSrcweir {
297cdf0e10cSrcweir RemoveIdxFromSection( rDoc, rCntnt.GetCntntIdx()->GetIndex() );
298cdf0e10cSrcweir }
299cdf0e10cSrcweir }
300cdf0e10cSrcweir DelFly(& rDoc);
301cdf0e10cSrcweir }
302cdf0e10cSrcweir
RedoImpl(::sw::UndoRedoContext & rContext)303cdf0e10cSrcweir void SwUndoInsLayFmt::RedoImpl(::sw::UndoRedoContext & rContext)
304cdf0e10cSrcweir {
305cdf0e10cSrcweir InsFly(rContext);
306cdf0e10cSrcweir }
307cdf0e10cSrcweir
RepeatImpl(::sw::RepeatContext & rContext)308cdf0e10cSrcweir void SwUndoInsLayFmt::RepeatImpl(::sw::RepeatContext & rContext)
309cdf0e10cSrcweir {
310cdf0e10cSrcweir SwDoc *const pDoc = & rContext.GetDoc();
311cdf0e10cSrcweir // erfrage und setze den Anker neu
312cdf0e10cSrcweir SwFmtAnchor aAnchor( pFrmFmt->GetAnchor() );
313cdf0e10cSrcweir if ((FLY_AT_PARA == aAnchor.GetAnchorId()) ||
314cdf0e10cSrcweir (FLY_AT_CHAR == aAnchor.GetAnchorId()) ||
315cdf0e10cSrcweir (FLY_AS_CHAR == aAnchor.GetAnchorId()))
316cdf0e10cSrcweir {
317cdf0e10cSrcweir SwPosition aPos( *rContext.GetRepeatPaM().GetPoint() );
318cdf0e10cSrcweir if (FLY_AT_PARA == aAnchor.GetAnchorId())
319cdf0e10cSrcweir {
320cdf0e10cSrcweir aPos.nContent.Assign( 0, 0 );
321cdf0e10cSrcweir }
322cdf0e10cSrcweir aAnchor.SetAnchor( &aPos );
323cdf0e10cSrcweir }
324cdf0e10cSrcweir else if( FLY_AT_FLY == aAnchor.GetAnchorId() )
325cdf0e10cSrcweir {
326cdf0e10cSrcweir SwStartNode const*const pSttNd =
327cdf0e10cSrcweir rContext.GetRepeatPaM().GetNode()->FindFlyStartNode();
328cdf0e10cSrcweir if( pSttNd )
329cdf0e10cSrcweir {
330cdf0e10cSrcweir SwPosition aPos( *pSttNd );
331cdf0e10cSrcweir aAnchor.SetAnchor( &aPos );
332cdf0e10cSrcweir }
333cdf0e10cSrcweir else
334cdf0e10cSrcweir {
335cdf0e10cSrcweir return ;
336cdf0e10cSrcweir }
337cdf0e10cSrcweir }
338cdf0e10cSrcweir else if (FLY_AT_PAGE == aAnchor.GetAnchorId())
339cdf0e10cSrcweir {
340cdf0e10cSrcweir aAnchor.SetPageNum( pDoc->GetCurrentLayout()->GetCurrPage( &rContext.GetRepeatPaM() ));
341cdf0e10cSrcweir }
342cdf0e10cSrcweir else {
343cdf0e10cSrcweir ASSERT( sal_False, "was fuer ein Anker ist es denn nun?" );
344cdf0e10cSrcweir }
345cdf0e10cSrcweir
346cdf0e10cSrcweir SwFrmFmt* pFlyFmt = pDoc->CopyLayoutFmt( *pFrmFmt, aAnchor, true, true );
347cdf0e10cSrcweir (void) pFlyFmt;
348cdf0e10cSrcweir //FIXME nobody ever did anything with this selection:
349cdf0e10cSrcweir // rContext.SetSelections(pFlyFmt, 0);
350cdf0e10cSrcweir }
351cdf0e10cSrcweir
352cdf0e10cSrcweir // #111827#
GetComment() const353cdf0e10cSrcweir String SwUndoInsLayFmt::GetComment() const
354cdf0e10cSrcweir {
355cdf0e10cSrcweir String aResult;
356cdf0e10cSrcweir
357cdf0e10cSrcweir // HACK: disable caching:
358cdf0e10cSrcweir // the SfxUndoManager calls GetComment() too early: the pFrmFmt does not
359cdf0e10cSrcweir // have a SwDrawContact yet, so it will fall back to SwUndo::GetComment(),
360cdf0e10cSrcweir // which sets pComment to a wrong value.
361cdf0e10cSrcweir // if (! pComment)
362cdf0e10cSrcweir if (true)
363cdf0e10cSrcweir {
364cdf0e10cSrcweir /*
365cdf0e10cSrcweir If frame format is present and has an SdrObject use the undo
366cdf0e10cSrcweir comment of the SdrObject. Otherwise use the default comment.
367cdf0e10cSrcweir */
368cdf0e10cSrcweir
369cdf0e10cSrcweir bool bDone = false;
370cdf0e10cSrcweir if (pFrmFmt)
371cdf0e10cSrcweir {
372cdf0e10cSrcweir const SdrObject * pSdrObj = pFrmFmt->FindSdrObject();
373cdf0e10cSrcweir if ( pSdrObj )
374cdf0e10cSrcweir {
375cdf0e10cSrcweir aResult = SdrUndoNewObj::GetComment( *pSdrObj );
376cdf0e10cSrcweir bDone = true;
377cdf0e10cSrcweir }
378cdf0e10cSrcweir }
379cdf0e10cSrcweir
380cdf0e10cSrcweir if (! bDone)
381cdf0e10cSrcweir aResult = SwUndo::GetComment();
382cdf0e10cSrcweir }
383cdf0e10cSrcweir else
384cdf0e10cSrcweir aResult = *pComment;
385cdf0e10cSrcweir
386cdf0e10cSrcweir return aResult;
387cdf0e10cSrcweir }
388cdf0e10cSrcweir
389cdf0e10cSrcweir // SwUndoDelLayFmt ///////////////////////////////////////////////////////
390cdf0e10cSrcweir
391cdf0e10cSrcweir static SwUndoId
lcl_GetSwUndoId(SwFrmFmt * const pFrmFmt)392cdf0e10cSrcweir lcl_GetSwUndoId(SwFrmFmt *const pFrmFmt)
393cdf0e10cSrcweir {
394cdf0e10cSrcweir if (RES_DRAWFRMFMT != pFrmFmt->Which())
395cdf0e10cSrcweir {
396cdf0e10cSrcweir const SwFmtCntnt& rCntnt = pFrmFmt->GetCntnt();
397cdf0e10cSrcweir OSL_ENSURE( rCntnt.GetCntntIdx(), "Fly without content" );
398cdf0e10cSrcweir
399cdf0e10cSrcweir SwNodeIndex firstNode(*rCntnt.GetCntntIdx(), 1);
400cdf0e10cSrcweir SwNoTxtNode *const pNoTxtNode(firstNode.GetNode().GetNoTxtNode());
401cdf0e10cSrcweir if (pNoTxtNode && pNoTxtNode->IsGrfNode())
402cdf0e10cSrcweir {
403cdf0e10cSrcweir return UNDO_DELGRF;
404cdf0e10cSrcweir }
405cdf0e10cSrcweir else if (pNoTxtNode && pNoTxtNode->IsOLENode())
406cdf0e10cSrcweir {
407cdf0e10cSrcweir // surprisingly not UNDO_DELOLE, which does not seem to work
408cdf0e10cSrcweir return UNDO_DELETE;
409cdf0e10cSrcweir }
410cdf0e10cSrcweir }
411cdf0e10cSrcweir return UNDO_DELLAYFMT;
412cdf0e10cSrcweir }
413cdf0e10cSrcweir
SwUndoDelLayFmt(SwFrmFmt * pFormat)414cdf0e10cSrcweir SwUndoDelLayFmt::SwUndoDelLayFmt( SwFrmFmt* pFormat )
415cdf0e10cSrcweir : SwUndoFlyBase( pFormat, lcl_GetSwUndoId(pFormat) )
416cdf0e10cSrcweir , bShowSelFrm( sal_True )
417cdf0e10cSrcweir {
418cdf0e10cSrcweir SwDoc* pDoc = pFormat->GetDoc();
419cdf0e10cSrcweir DelFly( pDoc );
420cdf0e10cSrcweir }
421cdf0e10cSrcweir
GetRewriter() const422cdf0e10cSrcweir SwRewriter SwUndoDelLayFmt::GetRewriter() const
423cdf0e10cSrcweir {
424cdf0e10cSrcweir SwRewriter aRewriter;
425cdf0e10cSrcweir
426cdf0e10cSrcweir SwDoc * pDoc = pFrmFmt->GetDoc();
427cdf0e10cSrcweir
428cdf0e10cSrcweir if (pDoc)
429cdf0e10cSrcweir {
430cdf0e10cSrcweir SwNodeIndex* pIdx = GetMvSttIdx();
431cdf0e10cSrcweir if( 1 == GetMvNodeCnt() && pIdx)
432cdf0e10cSrcweir {
433cdf0e10cSrcweir SwNode *const pNd = & pIdx->GetNode();
434cdf0e10cSrcweir
435cdf0e10cSrcweir if ( pNd->IsNoTxtNode() && pNd->IsOLENode())
436cdf0e10cSrcweir {
437cdf0e10cSrcweir SwOLENode * pOLENd = pNd->GetOLENode();
438cdf0e10cSrcweir
439cdf0e10cSrcweir aRewriter.AddRule(UNDO_ARG1, pOLENd->GetDescription());
440cdf0e10cSrcweir }
441cdf0e10cSrcweir }
442cdf0e10cSrcweir }
443cdf0e10cSrcweir
444cdf0e10cSrcweir return aRewriter;
445cdf0e10cSrcweir }
446cdf0e10cSrcweir
UndoImpl(::sw::UndoRedoContext & rContext)447cdf0e10cSrcweir void SwUndoDelLayFmt::UndoImpl(::sw::UndoRedoContext & rContext)
448cdf0e10cSrcweir {
449cdf0e10cSrcweir InsFly( rContext, bShowSelFrm );
450cdf0e10cSrcweir }
451cdf0e10cSrcweir
RedoImpl(::sw::UndoRedoContext & rContext)452cdf0e10cSrcweir void SwUndoDelLayFmt::RedoImpl(::sw::UndoRedoContext & rContext)
453cdf0e10cSrcweir {
454cdf0e10cSrcweir SwDoc & rDoc(rContext.GetDoc());
455cdf0e10cSrcweir const SwFmtCntnt& rCntnt = pFrmFmt->GetCntnt();
456cdf0e10cSrcweir if( rCntnt.GetCntntIdx() ) // kein Inhalt
457cdf0e10cSrcweir {
458cdf0e10cSrcweir RemoveIdxFromSection(rDoc, rCntnt.GetCntntIdx()->GetIndex());
459cdf0e10cSrcweir }
460cdf0e10cSrcweir
461cdf0e10cSrcweir DelFly(& rDoc);
462cdf0e10cSrcweir }
463cdf0e10cSrcweir
RedoForRollback()464cdf0e10cSrcweir void SwUndoDelLayFmt::RedoForRollback()
465cdf0e10cSrcweir {
466cdf0e10cSrcweir const SwFmtCntnt& rCntnt = pFrmFmt->GetCntnt();
467cdf0e10cSrcweir if( rCntnt.GetCntntIdx() ) // kein Inhalt
468cdf0e10cSrcweir RemoveIdxFromSection( *pFrmFmt->GetDoc(),
469cdf0e10cSrcweir rCntnt.GetCntntIdx()->GetIndex() );
470cdf0e10cSrcweir
471cdf0e10cSrcweir DelFly( pFrmFmt->GetDoc() );
472cdf0e10cSrcweir }
473cdf0e10cSrcweir
474cdf0e10cSrcweir // SwUndoSetFlyFmt ///////////////////////////////////////////////////////
475cdf0e10cSrcweir
SwUndoSetFlyFmt(SwFrmFmt & rFlyFmt,SwFrmFmt & rNewFrmFmt)476cdf0e10cSrcweir SwUndoSetFlyFmt::SwUndoSetFlyFmt( SwFrmFmt& rFlyFmt, SwFrmFmt& rNewFrmFmt )
477cdf0e10cSrcweir : SwUndo( UNDO_SETFLYFRMFMT ), SwClient( &rFlyFmt ), pFrmFmt( &rFlyFmt ),
478cdf0e10cSrcweir pOldFmt( (SwFrmFmt*)rFlyFmt.DerivedFrom() ), pNewFmt( &rNewFrmFmt ),
479cdf0e10cSrcweir pItemSet( new SfxItemSet( *rFlyFmt.GetAttrSet().GetPool(),
480cdf0e10cSrcweir rFlyFmt.GetAttrSet().GetRanges() )),
481cdf0e10cSrcweir nOldNode( 0 ), nNewNode( 0 ),
482cdf0e10cSrcweir nOldCntnt( 0 ), nNewCntnt( 0 ),
483cdf0e10cSrcweir nOldAnchorTyp( 0 ), nNewAnchorTyp( 0 ), bAnchorChgd( sal_False )
484cdf0e10cSrcweir {
485cdf0e10cSrcweir }
486cdf0e10cSrcweir
GetRewriter() const487cdf0e10cSrcweir SwRewriter SwUndoSetFlyFmt::GetRewriter() const
488cdf0e10cSrcweir {
489cdf0e10cSrcweir SwRewriter aRewriter;
490cdf0e10cSrcweir
491cdf0e10cSrcweir if (pNewFmt)
492cdf0e10cSrcweir aRewriter.AddRule(UNDO_ARG1, pNewFmt->GetName());
493cdf0e10cSrcweir
494cdf0e10cSrcweir return aRewriter;
495cdf0e10cSrcweir }
496cdf0e10cSrcweir
497cdf0e10cSrcweir
~SwUndoSetFlyFmt()498cdf0e10cSrcweir SwUndoSetFlyFmt::~SwUndoSetFlyFmt()
499cdf0e10cSrcweir {
500cdf0e10cSrcweir delete pItemSet;
501cdf0e10cSrcweir }
502cdf0e10cSrcweir
DeRegisterFromFormat(SwFmt & rFmt)503cdf0e10cSrcweir void SwUndoSetFlyFmt::DeRegisterFromFormat( SwFmt& rFmt )
504cdf0e10cSrcweir {
505cdf0e10cSrcweir rFmt.Remove(this);
506cdf0e10cSrcweir }
507cdf0e10cSrcweir
GetAnchor(SwFmtAnchor & rAnchor,sal_uLong nNode,xub_StrLen nCntnt)508cdf0e10cSrcweir void SwUndoSetFlyFmt::GetAnchor( SwFmtAnchor& rAnchor,
509cdf0e10cSrcweir sal_uLong nNode, xub_StrLen nCntnt )
510cdf0e10cSrcweir {
511cdf0e10cSrcweir RndStdIds nAnchorTyp = rAnchor.GetAnchorId();
512cdf0e10cSrcweir if (FLY_AT_PAGE != nAnchorTyp)
513cdf0e10cSrcweir {
514cdf0e10cSrcweir SwNode* pNd = pFrmFmt->GetDoc()->GetNodes()[ nNode ];
515cdf0e10cSrcweir
516cdf0e10cSrcweir if( FLY_AT_FLY == nAnchorTyp
517cdf0e10cSrcweir ? ( !pNd->IsStartNode() || SwFlyStartNode !=
518cdf0e10cSrcweir ((SwStartNode*)pNd)->GetStartNodeType() )
519cdf0e10cSrcweir : !pNd->IsTxtNode() )
520cdf0e10cSrcweir {
521cdf0e10cSrcweir pNd = 0; // invalid position
522cdf0e10cSrcweir }
523cdf0e10cSrcweir else
524cdf0e10cSrcweir {
525cdf0e10cSrcweir SwPosition aPos( *pNd );
526cdf0e10cSrcweir if ((FLY_AS_CHAR == nAnchorTyp) ||
527cdf0e10cSrcweir (FLY_AT_CHAR == nAnchorTyp))
528cdf0e10cSrcweir {
529cdf0e10cSrcweir if ( nCntnt > static_cast<SwTxtNode*>(pNd)->GetTxt().Len() )
530cdf0e10cSrcweir {
531cdf0e10cSrcweir pNd = 0; // invalid position
532cdf0e10cSrcweir }
533cdf0e10cSrcweir else
534cdf0e10cSrcweir {
535cdf0e10cSrcweir aPos.nContent.Assign(static_cast<SwTxtNode*>(pNd), nCntnt);
536cdf0e10cSrcweir }
537cdf0e10cSrcweir }
538cdf0e10cSrcweir if ( pNd )
539cdf0e10cSrcweir {
540cdf0e10cSrcweir rAnchor.SetAnchor( &aPos );
541cdf0e10cSrcweir }
542cdf0e10cSrcweir }
543cdf0e10cSrcweir
544cdf0e10cSrcweir if( !pNd )
545cdf0e10cSrcweir {
546cdf0e10cSrcweir // ungueltige Position - setze auf 1. Seite
547cdf0e10cSrcweir rAnchor.SetType( FLY_AT_PAGE );
548cdf0e10cSrcweir rAnchor.SetPageNum( 1 );
549cdf0e10cSrcweir }
550cdf0e10cSrcweir }
551cdf0e10cSrcweir else
552cdf0e10cSrcweir rAnchor.SetPageNum( nCntnt );
553cdf0e10cSrcweir }
554cdf0e10cSrcweir
UndoImpl(::sw::UndoRedoContext & rContext)555cdf0e10cSrcweir void SwUndoSetFlyFmt::UndoImpl(::sw::UndoRedoContext & rContext)
556cdf0e10cSrcweir {
557cdf0e10cSrcweir SwDoc & rDoc = rContext.GetDoc();
558cdf0e10cSrcweir
559cdf0e10cSrcweir // ist das neue Format noch vorhanden ??
560cdf0e10cSrcweir if( USHRT_MAX != rDoc.GetFrmFmts()->GetPos( (const SwFrmFmtPtr)pOldFmt ) )
561cdf0e10cSrcweir {
562cdf0e10cSrcweir if( bAnchorChgd )
563cdf0e10cSrcweir pFrmFmt->DelFrms();
564cdf0e10cSrcweir
565cdf0e10cSrcweir if( pFrmFmt->DerivedFrom() != pOldFmt )
566cdf0e10cSrcweir pFrmFmt->SetDerivedFrom( pOldFmt );
567cdf0e10cSrcweir
568cdf0e10cSrcweir SfxItemIter aIter( *pItemSet );
569cdf0e10cSrcweir const SfxPoolItem* pItem = aIter.GetCurItem();
570cdf0e10cSrcweir while( pItem )
571cdf0e10cSrcweir {
572cdf0e10cSrcweir if( IsInvalidItem( pItem ))
573cdf0e10cSrcweir pFrmFmt->ResetFmtAttr( pItemSet->GetWhichByPos(
574cdf0e10cSrcweir aIter.GetCurPos() ));
575cdf0e10cSrcweir else
576cdf0e10cSrcweir pFrmFmt->SetFmtAttr( *pItem );
577cdf0e10cSrcweir
578cdf0e10cSrcweir if( aIter.IsAtEnd() )
579cdf0e10cSrcweir break;
580cdf0e10cSrcweir pItem = aIter.NextItem();
581cdf0e10cSrcweir }
582cdf0e10cSrcweir
583cdf0e10cSrcweir if( bAnchorChgd )
584cdf0e10cSrcweir {
585cdf0e10cSrcweir const SwFmtAnchor& rOldAnch = pFrmFmt->GetAnchor();
586cdf0e10cSrcweir if (FLY_AS_CHAR == rOldAnch.GetAnchorId())
587cdf0e10cSrcweir {
588cdf0e10cSrcweir // Bei InCntnt's wird es spannend: Das TxtAttribut muss
589cdf0e10cSrcweir // vernichtet werden. Leider reisst dies neben den Frms
590cdf0e10cSrcweir // auch noch das Format mit in sein Grab. Um dass zu
591cdf0e10cSrcweir // unterbinden loesen wir vorher die Verbindung zwischen
592cdf0e10cSrcweir // Attribut und Format.
593cdf0e10cSrcweir const SwPosition *pPos = rOldAnch.GetCntntAnchor();
594cdf0e10cSrcweir SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode();
595cdf0e10cSrcweir ASSERT( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." );
596cdf0e10cSrcweir const xub_StrLen nIdx = pPos->nContent.GetIndex();
597cdf0e10cSrcweir SwTxtAttr * pHnt = pTxtNode->GetTxtAttrForCharAt(
598cdf0e10cSrcweir nIdx, RES_TXTATR_FLYCNT );
599cdf0e10cSrcweir ASSERT( pHnt && pHnt->Which() == RES_TXTATR_FLYCNT,
600cdf0e10cSrcweir "Missing FlyInCnt-Hint." );
601cdf0e10cSrcweir ASSERT( pHnt && pHnt->GetFlyCnt().GetFrmFmt() == pFrmFmt,
602cdf0e10cSrcweir "Wrong TxtFlyCnt-Hint." );
603cdf0e10cSrcweir const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt()).SetFlyFmt();
604cdf0e10cSrcweir
605cdf0e10cSrcweir // Die Verbindung ist geloest, jetzt muss noch das Attribut
606cdf0e10cSrcweir // vernichtet werden.
607cdf0e10cSrcweir pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx, nIdx );
608cdf0e10cSrcweir }
609cdf0e10cSrcweir
610cdf0e10cSrcweir // Anker umsetzen
611cdf0e10cSrcweir SwFmtAnchor aNewAnchor( (RndStdIds) nOldAnchorTyp );
612cdf0e10cSrcweir GetAnchor( aNewAnchor, nOldNode, nOldCntnt );
613cdf0e10cSrcweir pFrmFmt->SetFmtAttr( aNewAnchor );
614cdf0e10cSrcweir
615cdf0e10cSrcweir if (FLY_AS_CHAR == aNewAnchor.GetAnchorId())
616cdf0e10cSrcweir {
617cdf0e10cSrcweir SwPosition* pPos = (SwPosition*)aNewAnchor.GetCntntAnchor();
618cdf0e10cSrcweir SwFmtFlyCnt aFmt( pFrmFmt );
619cdf0e10cSrcweir pPos->nNode.GetNode().GetTxtNode()->InsertItem( aFmt,
620cdf0e10cSrcweir nOldCntnt, 0 );
621cdf0e10cSrcweir }
622cdf0e10cSrcweir
623cdf0e10cSrcweir pFrmFmt->MakeFrms();
624cdf0e10cSrcweir }
625cdf0e10cSrcweir rContext.SetSelections(pFrmFmt, 0);
626cdf0e10cSrcweir }
627cdf0e10cSrcweir }
628cdf0e10cSrcweir
RedoImpl(::sw::UndoRedoContext & rContext)629cdf0e10cSrcweir void SwUndoSetFlyFmt::RedoImpl(::sw::UndoRedoContext & rContext)
630cdf0e10cSrcweir {
631cdf0e10cSrcweir SwDoc & rDoc = rContext.GetDoc();
632cdf0e10cSrcweir
633cdf0e10cSrcweir // ist das neue Format noch vorhanden ??
634cdf0e10cSrcweir if( USHRT_MAX != rDoc.GetFrmFmts()->GetPos( (const SwFrmFmtPtr)pNewFmt ) )
635cdf0e10cSrcweir {
636cdf0e10cSrcweir
637cdf0e10cSrcweir if( bAnchorChgd )
638cdf0e10cSrcweir {
639cdf0e10cSrcweir SwFmtAnchor aNewAnchor( (RndStdIds) nNewAnchorTyp );
640cdf0e10cSrcweir GetAnchor( aNewAnchor, nNewNode, nNewCntnt );
641cdf0e10cSrcweir SfxItemSet aSet( rDoc.GetAttrPool(), aFrmFmtSetRange );
642cdf0e10cSrcweir aSet.Put( aNewAnchor );
643cdf0e10cSrcweir rDoc.SetFrmFmtToFly( *pFrmFmt, *pNewFmt, &aSet );
644cdf0e10cSrcweir }
645cdf0e10cSrcweir else
646cdf0e10cSrcweir rDoc.SetFrmFmtToFly( *pFrmFmt, *pNewFmt, 0 );
647cdf0e10cSrcweir
648cdf0e10cSrcweir rContext.SetSelections(pFrmFmt, 0);
649cdf0e10cSrcweir }
650cdf0e10cSrcweir }
651cdf0e10cSrcweir
PutAttr(sal_uInt16 nWhich,const SfxPoolItem * pItem)652cdf0e10cSrcweir void SwUndoSetFlyFmt::PutAttr( sal_uInt16 nWhich, const SfxPoolItem* pItem )
653cdf0e10cSrcweir {
654cdf0e10cSrcweir if( pItem && pItem != GetDfltAttr( nWhich ) )
655cdf0e10cSrcweir {
656cdf0e10cSrcweir // Sonderbehandlung fuer den Anchor
657cdf0e10cSrcweir if( RES_ANCHOR == nWhich )
658cdf0e10cSrcweir {
659cdf0e10cSrcweir // nur den 1. Ankerwechsel vermerken
660cdf0e10cSrcweir ASSERT( !bAnchorChgd, "mehrfacher Ankerwechsel nicht erlaubt!" );
661cdf0e10cSrcweir
662cdf0e10cSrcweir bAnchorChgd = sal_True;
663cdf0e10cSrcweir
664cdf0e10cSrcweir const SwFmtAnchor* pAnchor = (SwFmtAnchor*)pItem;
665cdf0e10cSrcweir switch( nOldAnchorTyp = static_cast<sal_uInt16>(pAnchor->GetAnchorId()) )
666cdf0e10cSrcweir {
667cdf0e10cSrcweir case FLY_AS_CHAR:
668cdf0e10cSrcweir case FLY_AT_CHAR:
669cdf0e10cSrcweir nOldCntnt = pAnchor->GetCntntAnchor()->nContent.GetIndex();
670cdf0e10cSrcweir case FLY_AT_PARA:
671cdf0e10cSrcweir case FLY_AT_FLY:
672cdf0e10cSrcweir nOldNode = pAnchor->GetCntntAnchor()->nNode.GetIndex();
673cdf0e10cSrcweir break;
674cdf0e10cSrcweir
675cdf0e10cSrcweir default:
676cdf0e10cSrcweir nOldCntnt = pAnchor->GetPageNum();
677cdf0e10cSrcweir }
678cdf0e10cSrcweir
679cdf0e10cSrcweir pAnchor = (SwFmtAnchor*)&pFrmFmt->GetAnchor();
680cdf0e10cSrcweir switch( nNewAnchorTyp = static_cast<sal_uInt16>(pAnchor->GetAnchorId()) )
681cdf0e10cSrcweir {
682cdf0e10cSrcweir case FLY_AS_CHAR:
683cdf0e10cSrcweir case FLY_AT_CHAR:
684cdf0e10cSrcweir nNewCntnt = pAnchor->GetCntntAnchor()->nContent.GetIndex();
685cdf0e10cSrcweir case FLY_AT_PARA:
686cdf0e10cSrcweir case FLY_AT_FLY:
687cdf0e10cSrcweir nNewNode = pAnchor->GetCntntAnchor()->nNode.GetIndex();
688cdf0e10cSrcweir break;
689cdf0e10cSrcweir
690cdf0e10cSrcweir default:
691cdf0e10cSrcweir nNewCntnt = pAnchor->GetPageNum();
692cdf0e10cSrcweir }
693cdf0e10cSrcweir }
694cdf0e10cSrcweir else
695cdf0e10cSrcweir pItemSet->Put( *pItem );
696cdf0e10cSrcweir }
697cdf0e10cSrcweir else
698cdf0e10cSrcweir pItemSet->InvalidateItem( nWhich );
699cdf0e10cSrcweir }
700cdf0e10cSrcweir
Modify(const SfxPoolItem * pOld,const SfxPoolItem *)701cdf0e10cSrcweir void SwUndoSetFlyFmt::Modify( const SfxPoolItem* pOld, const SfxPoolItem* )
702cdf0e10cSrcweir {
703cdf0e10cSrcweir if( pOld )
704cdf0e10cSrcweir {
705cdf0e10cSrcweir sal_uInt16 nWhich = pOld->Which();
706cdf0e10cSrcweir
707cdf0e10cSrcweir if( nWhich < POOLATTR_END )
708cdf0e10cSrcweir PutAttr( nWhich, pOld );
709cdf0e10cSrcweir else if( RES_ATTRSET_CHG == nWhich )
710cdf0e10cSrcweir {
711cdf0e10cSrcweir SfxItemIter aIter( *((SwAttrSetChg*)pOld)->GetChgSet() );
712cdf0e10cSrcweir const SfxPoolItem* pItem = aIter.GetCurItem();
713cdf0e10cSrcweir while( pItem )
714cdf0e10cSrcweir {
715cdf0e10cSrcweir PutAttr( pItem->Which(), pItem );
716cdf0e10cSrcweir if( aIter.IsAtEnd() )
717cdf0e10cSrcweir break;
718cdf0e10cSrcweir pItem = aIter.NextItem();
719cdf0e10cSrcweir }
720cdf0e10cSrcweir }
721cdf0e10cSrcweir }
722cdf0e10cSrcweir }
723cdf0e10cSrcweir
724