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 <tools/resid.hxx>
28cdf0e10cSrcweir #include <doc.hxx>
29cdf0e10cSrcweir #include <IDocumentUndoRedo.hxx>
30cdf0e10cSrcweir #include <swundo.hxx>
31cdf0e10cSrcweir #include <pagedesc.hxx>
32cdf0e10cSrcweir #include <SwUndoPageDesc.hxx>
33cdf0e10cSrcweir #include <SwRewriter.hxx>
34cdf0e10cSrcweir #include <undobj.hxx>
35cdf0e10cSrcweir #include <comcore.hrc>
36cdf0e10cSrcweir #include <fmtcntnt.hxx>
37cdf0e10cSrcweir #include <fmthdft.hxx>
38cdf0e10cSrcweir
39cdf0e10cSrcweir #ifdef DEBUG
40cdf0e10cSrcweir #include <ndindex.hxx>
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir
43cdf0e10cSrcweir
44cdf0e10cSrcweir #ifdef DEBUG
45cdf0e10cSrcweir // Pure debug help function to have a quick look at the header/footer attributes.
DebugHeaderFooterContent(const SwPageDesc & rPageDesc)46cdf0e10cSrcweir void DebugHeaderFooterContent( const SwPageDesc& rPageDesc )
47cdf0e10cSrcweir {
48cdf0e10cSrcweir sal_uLong nHeaderMaster = ULONG_MAX;
49cdf0e10cSrcweir sal_uLong nHeaderLeft = ULONG_MAX;
50cdf0e10cSrcweir sal_uLong nFooterMaster = ULONG_MAX;
51cdf0e10cSrcweir sal_uLong nFooterLeft = ULONG_MAX;
52cdf0e10cSrcweir int nHeaderCount = 0;
53cdf0e10cSrcweir int nLeftHeaderCount = 0;
54cdf0e10cSrcweir int nFooterCount = 0;
55cdf0e10cSrcweir int nLeftFooterCount = 0;
56cdf0e10cSrcweir bool bSharedHeader = false;
57cdf0e10cSrcweir bool bSharedFooter = false;
58cdf0e10cSrcweir
59cdf0e10cSrcweir SwFmtHeader& rHead = (SwFmtHeader&)rPageDesc.GetMaster().GetHeader();
60cdf0e10cSrcweir SwFmtFooter& rFoot = (SwFmtFooter&)rPageDesc.GetMaster().GetFooter();
61cdf0e10cSrcweir SwFmtHeader& rLeftHead = (SwFmtHeader&)rPageDesc.GetLeft().GetHeader();
62cdf0e10cSrcweir SwFmtFooter& rLeftFoot = (SwFmtFooter&)rPageDesc.GetLeft().GetFooter();
63cdf0e10cSrcweir if( rHead.IsActive() )
64cdf0e10cSrcweir {
65cdf0e10cSrcweir SwFrmFmt* pHeaderFmt = rHead.GetHeaderFmt();
66cdf0e10cSrcweir if( pHeaderFmt )
67cdf0e10cSrcweir {
68cdf0e10cSrcweir nHeaderCount = pHeaderFmt->GetClientCount();
69cdf0e10cSrcweir const SwFmtCntnt* pCntnt = &pHeaderFmt->GetCntnt();
70cdf0e10cSrcweir if( pCntnt->GetCntntIdx() )
71cdf0e10cSrcweir nHeaderMaster = pCntnt->GetCntntIdx()->GetIndex();
72cdf0e10cSrcweir else
73cdf0e10cSrcweir nHeaderMaster = 0;
74cdf0e10cSrcweir }
75cdf0e10cSrcweir bSharedHeader = rPageDesc.IsHeaderShared();
76cdf0e10cSrcweir SwFrmFmt* pLeftHeaderFmt = rLeftHead.GetHeaderFmt();
77cdf0e10cSrcweir if( pLeftHeaderFmt )
78cdf0e10cSrcweir {
79cdf0e10cSrcweir nLeftHeaderCount = pLeftHeaderFmt->GetClientCount();
80cdf0e10cSrcweir const SwFmtCntnt* pLeftCntnt = &pLeftHeaderFmt->GetCntnt();
81cdf0e10cSrcweir if( pLeftCntnt->GetCntntIdx() )
82cdf0e10cSrcweir nHeaderLeft = pLeftCntnt->GetCntntIdx()->GetIndex();
83cdf0e10cSrcweir else
84cdf0e10cSrcweir nHeaderLeft = 0;
85cdf0e10cSrcweir }
86cdf0e10cSrcweir }
87cdf0e10cSrcweir if( rFoot.IsActive() )
88cdf0e10cSrcweir {
89cdf0e10cSrcweir SwFrmFmt* pFooterFmt = rFoot.GetFooterFmt();
90cdf0e10cSrcweir if( pFooterFmt )
91cdf0e10cSrcweir {
92cdf0e10cSrcweir nFooterCount = pFooterFmt->GetClientCount();
93cdf0e10cSrcweir const SwFmtCntnt* pCntnt = &pFooterFmt->GetCntnt();
94cdf0e10cSrcweir if( pCntnt->GetCntntIdx() )
95cdf0e10cSrcweir nFooterMaster = pCntnt->GetCntntIdx()->GetIndex();
96cdf0e10cSrcweir else
97cdf0e10cSrcweir nFooterMaster = 0;
98cdf0e10cSrcweir }
99cdf0e10cSrcweir bSharedFooter = rPageDesc.IsFooterShared();
100cdf0e10cSrcweir SwFrmFmt* pLeftFooterFmt = rLeftFoot.GetFooterFmt();
101cdf0e10cSrcweir if( pLeftFooterFmt )
102cdf0e10cSrcweir {
103cdf0e10cSrcweir nLeftFooterCount = pLeftFooterFmt->GetClientCount();
104cdf0e10cSrcweir const SwFmtCntnt* pLeftCntnt = &pLeftFooterFmt->GetCntnt();
105cdf0e10cSrcweir if( pLeftCntnt->GetCntntIdx() )
106cdf0e10cSrcweir nFooterLeft = pLeftCntnt->GetCntntIdx()->GetIndex();
107cdf0e10cSrcweir else
108cdf0e10cSrcweir nFooterLeft = 0;
109cdf0e10cSrcweir }
110cdf0e10cSrcweir }
111cdf0e10cSrcweir int i = 0;
112cdf0e10cSrcweir ++i; // To set a breakpoint
113cdf0e10cSrcweir }
114cdf0e10cSrcweir #endif
115cdf0e10cSrcweir
SwUndoPageDesc(const SwPageDesc & _aOld,const SwPageDesc & _aNew,SwDoc * _pDoc)116cdf0e10cSrcweir SwUndoPageDesc::SwUndoPageDesc(const SwPageDesc & _aOld,
117cdf0e10cSrcweir const SwPageDesc & _aNew,
118cdf0e10cSrcweir SwDoc * _pDoc)
119cdf0e10cSrcweir : SwUndo( _aOld.GetName() != _aNew.GetName() ?
120cdf0e10cSrcweir UNDO_RENAME_PAGEDESC :
121cdf0e10cSrcweir UNDO_CHANGE_PAGEDESC ),
122cdf0e10cSrcweir aOld(_aOld, _pDoc), aNew(_aNew, _pDoc), pDoc(_pDoc), bExchange( false )
123cdf0e10cSrcweir {
124cdf0e10cSrcweir ASSERT(0 != pDoc, "no document?");
125cdf0e10cSrcweir
126cdf0e10cSrcweir #ifdef DEBUG
127cdf0e10cSrcweir DebugHeaderFooterContent( (SwPageDesc&)aOld );
128cdf0e10cSrcweir DebugHeaderFooterContent( (SwPageDesc&)aNew );
129cdf0e10cSrcweir #endif
130cdf0e10cSrcweir
131cdf0e10cSrcweir /*
132cdf0e10cSrcweir The page description changes.
133cdf0e10cSrcweir If there are no header/footer content changes like header on/off or change from shared content
134cdf0e10cSrcweir to unshared etc., there is no reason to duplicate the content nodes (Crash i55547)
135cdf0e10cSrcweir But this happens, this Undo Ctor will destroy the unnecessary duplicate and manipulate the
136cdf0e10cSrcweir content pointer of the both page descriptions.
137cdf0e10cSrcweir */
138cdf0e10cSrcweir SwPageDesc &rOldDesc = (SwPageDesc&)aOld;
139cdf0e10cSrcweir SwPageDesc &rNewDesc = (SwPageDesc&)aNew;
140cdf0e10cSrcweir const SwFmtHeader& rOldHead = rOldDesc.GetMaster().GetHeader();
141cdf0e10cSrcweir const SwFmtHeader& rNewHead = rNewDesc.GetMaster().GetHeader();
142cdf0e10cSrcweir const SwFmtFooter& rOldFoot = rOldDesc.GetMaster().GetFooter();
143cdf0e10cSrcweir const SwFmtFooter& rNewFoot = rNewDesc.GetMaster().GetFooter();
144cdf0e10cSrcweir /* bExchange must not be set, if the old page descriptor will stay active.
145cdf0e10cSrcweir Two known situations:
146cdf0e10cSrcweir #i67735#: renaming a page descriptor
147cdf0e10cSrcweir #i67334#: changing the follow style
148cdf0e10cSrcweir If header/footer will be activated or deactivated, this undo will not work.
149cdf0e10cSrcweir */
150cdf0e10cSrcweir bExchange = ( aOld.GetName() == aNew.GetName() ) &&
151cdf0e10cSrcweir ( _aOld.GetFollow() == _aNew.GetFollow() ) &&
152cdf0e10cSrcweir ( rOldHead.IsActive() == rNewHead.IsActive() ) &&
153cdf0e10cSrcweir ( rOldFoot.IsActive() == rNewFoot.IsActive() );
154cdf0e10cSrcweir if( rOldHead.IsActive() && ( rOldDesc.IsHeaderShared() != rNewDesc.IsHeaderShared() ) )
155cdf0e10cSrcweir bExchange = false;
156cdf0e10cSrcweir if( rOldFoot.IsActive() && ( rOldDesc.IsFooterShared() != rNewDesc.IsFooterShared() ) )
157cdf0e10cSrcweir bExchange = false;
158cdf0e10cSrcweir if( bExchange )
159cdf0e10cSrcweir {
160cdf0e10cSrcweir if( rNewHead.IsActive() )
161cdf0e10cSrcweir {
162cdf0e10cSrcweir SwFrmFmt* pFormat = new SwFrmFmt( *rNewHead.GetHeaderFmt() );
163cdf0e10cSrcweir // The Ctor of this object will remove the duplicate!
164cdf0e10cSrcweir SwFmtHeader aFmtHeader( pFormat );
165cdf0e10cSrcweir if( !rNewDesc.IsHeaderShared() )
166cdf0e10cSrcweir {
167cdf0e10cSrcweir pFormat = new SwFrmFmt( *rNewDesc.GetLeft().GetHeader().GetHeaderFmt() );
168cdf0e10cSrcweir // The Ctor of this object will remove the duplicate!
169cdf0e10cSrcweir SwFmtHeader aFormatHeader( pFormat );
170cdf0e10cSrcweir }
171cdf0e10cSrcweir }
172cdf0e10cSrcweir // Same procedure for footers...
173cdf0e10cSrcweir if( rNewFoot.IsActive() )
174cdf0e10cSrcweir {
175cdf0e10cSrcweir SwFrmFmt* pFormat = new SwFrmFmt( *rNewFoot.GetFooterFmt() );
176cdf0e10cSrcweir // The Ctor of this object will remove the duplicate!
177cdf0e10cSrcweir SwFmtFooter aFmtFooter( pFormat );
178cdf0e10cSrcweir if( !rNewDesc.IsFooterShared() )
179cdf0e10cSrcweir {
180cdf0e10cSrcweir pFormat = new SwFrmFmt( *rNewDesc.GetLeft().GetFooter().GetFooterFmt() );
181cdf0e10cSrcweir // The Ctor of this object will remove the duplicate!
182cdf0e10cSrcweir SwFmtFooter aFormatFooter( pFormat );
183cdf0e10cSrcweir }
184cdf0e10cSrcweir }
185cdf0e10cSrcweir
186cdf0e10cSrcweir // After this exchange method the old page description will point to zero,
187cdf0e10cSrcweir // the new one will point to the node position of the original content nodes.
188cdf0e10cSrcweir ExchangeContentNodes( (SwPageDesc&)aOld, (SwPageDesc&)aNew );
189cdf0e10cSrcweir #ifdef DEBUG
190cdf0e10cSrcweir DebugHeaderFooterContent( (SwPageDesc&)aOld );
191cdf0e10cSrcweir DebugHeaderFooterContent( (SwPageDesc&)aNew );
192cdf0e10cSrcweir #endif
193cdf0e10cSrcweir }
194cdf0e10cSrcweir }
195cdf0e10cSrcweir
~SwUndoPageDesc()196cdf0e10cSrcweir SwUndoPageDesc::~SwUndoPageDesc()
197cdf0e10cSrcweir {
198cdf0e10cSrcweir }
199cdf0e10cSrcweir
200cdf0e10cSrcweir
ExchangeContentNodes(SwPageDesc & rSource,SwPageDesc & rDest)201cdf0e10cSrcweir void SwUndoPageDesc::ExchangeContentNodes( SwPageDesc& rSource, SwPageDesc &rDest )
202cdf0e10cSrcweir {
203cdf0e10cSrcweir ASSERT( bExchange, "You shouldn't do that." );
204cdf0e10cSrcweir const SwFmtHeader& rDestHead = rDest.GetMaster().GetHeader();
205cdf0e10cSrcweir const SwFmtHeader& rSourceHead = rSource.GetMaster().GetHeader();
206cdf0e10cSrcweir if( rDestHead.IsActive() )
207cdf0e10cSrcweir {
208cdf0e10cSrcweir // Let the destination page descrition point to the source node position,
209cdf0e10cSrcweir // from now on this descriptor is responsible for the content nodes!
210cdf0e10cSrcweir const SfxPoolItem* pItem;
211cdf0e10cSrcweir rDest.GetMaster().GetAttrSet().GetItemState( RES_HEADER, sal_False, &pItem );
212cdf0e10cSrcweir SfxPoolItem *pNewItem = pItem->Clone();
213cdf0e10cSrcweir SwFrmFmt* pNewFmt = ((SwFmtHeader*)pNewItem)->GetHeaderFmt();
214cdf0e10cSrcweir #ifdef DEBUG
215cdf0e10cSrcweir const SwFmtCntnt& rSourceCntnt = rSourceHead.GetHeaderFmt()->GetCntnt();
216cdf0e10cSrcweir (void)rSourceCntnt;
217cdf0e10cSrcweir const SwFmtCntnt& rDestCntnt = rDestHead.GetHeaderFmt()->GetCntnt();
218cdf0e10cSrcweir (void)rDestCntnt;
219cdf0e10cSrcweir #endif
220cdf0e10cSrcweir pNewFmt->SetFmtAttr( rSourceHead.GetHeaderFmt()->GetCntnt() );
221cdf0e10cSrcweir delete pNewItem;
222cdf0e10cSrcweir
223cdf0e10cSrcweir // Let the source page description point to zero node position,
224cdf0e10cSrcweir // it loses the responsible and can be destroyed without removing the content nodes.
225cdf0e10cSrcweir rSource.GetMaster().GetAttrSet().GetItemState( RES_HEADER, sal_False, &pItem );
226cdf0e10cSrcweir pNewItem = pItem->Clone();
227cdf0e10cSrcweir pNewFmt = ((SwFmtHeader*)pNewItem)->GetHeaderFmt();
228cdf0e10cSrcweir pNewFmt->SetFmtAttr( SwFmtCntnt() );
229cdf0e10cSrcweir delete pNewItem;
230cdf0e10cSrcweir
231cdf0e10cSrcweir if( !rDest.IsHeaderShared() )
232cdf0e10cSrcweir {
233cdf0e10cSrcweir // Same procedure for unshared header..
234cdf0e10cSrcweir const SwFmtHeader& rSourceLeftHead = rSource.GetLeft().GetHeader();
235cdf0e10cSrcweir rDest.GetLeft().GetAttrSet().GetItemState( RES_HEADER, sal_False, &pItem );
236cdf0e10cSrcweir pNewItem = pItem->Clone();
237cdf0e10cSrcweir pNewFmt = ((SwFmtHeader*)pNewItem)->GetHeaderFmt();
238cdf0e10cSrcweir #ifdef DEBUG
239cdf0e10cSrcweir const SwFmtCntnt& rSourceCntnt1 = rSourceLeftHead.GetHeaderFmt()->GetCntnt();
240cdf0e10cSrcweir (void)rSourceCntnt1;
241cdf0e10cSrcweir const SwFmtCntnt& rDestCntnt1 = rDest.GetLeft().GetHeader().GetHeaderFmt()->GetCntnt();
242cdf0e10cSrcweir (void)rDestCntnt1;
243cdf0e10cSrcweir #endif
244cdf0e10cSrcweir pNewFmt->SetFmtAttr( rSourceLeftHead.GetHeaderFmt()->GetCntnt() );
245cdf0e10cSrcweir delete pNewItem;
246cdf0e10cSrcweir rSource.GetLeft().GetAttrSet().GetItemState( RES_HEADER, sal_False, &pItem );
247cdf0e10cSrcweir pNewItem = pItem->Clone();
248cdf0e10cSrcweir pNewFmt = ((SwFmtHeader*)pNewItem)->GetHeaderFmt();
249cdf0e10cSrcweir pNewFmt->SetFmtAttr( SwFmtCntnt() );
250cdf0e10cSrcweir delete pNewItem;
251cdf0e10cSrcweir }
252cdf0e10cSrcweir }
253cdf0e10cSrcweir // Same procedure for footers...
254cdf0e10cSrcweir const SwFmtFooter& rDestFoot = rDest.GetMaster().GetFooter();
255cdf0e10cSrcweir const SwFmtFooter& rSourceFoot = rSource.GetMaster().GetFooter();
256cdf0e10cSrcweir if( rDestFoot.IsActive() )
257cdf0e10cSrcweir {
258cdf0e10cSrcweir const SfxPoolItem* pItem;
259cdf0e10cSrcweir rDest.GetMaster().GetAttrSet().GetItemState( RES_FOOTER, sal_False, &pItem );
260cdf0e10cSrcweir SfxPoolItem *pNewItem = pItem->Clone();
261cdf0e10cSrcweir SwFrmFmt *pNewFmt = ((SwFmtFooter*)pNewItem)->GetFooterFmt();
262cdf0e10cSrcweir pNewFmt->SetFmtAttr( rSourceFoot.GetFooterFmt()->GetCntnt() );
263cdf0e10cSrcweir delete pNewItem;
264cdf0e10cSrcweir
265cdf0e10cSrcweir #ifdef DEBUG
266cdf0e10cSrcweir const SwFmtCntnt& rFooterSourceCntnt = rSourceFoot.GetFooterFmt()->GetCntnt();
267cdf0e10cSrcweir (void)rFooterSourceCntnt;
268cdf0e10cSrcweir const SwFmtCntnt& rFooterDestCntnt = rDestFoot.GetFooterFmt()->GetCntnt();
269cdf0e10cSrcweir (void)rFooterDestCntnt;
270cdf0e10cSrcweir #endif
271cdf0e10cSrcweir rSource.GetMaster().GetAttrSet().GetItemState( RES_FOOTER, sal_False, &pItem );
272cdf0e10cSrcweir pNewItem = pItem->Clone();
273cdf0e10cSrcweir pNewFmt = ((SwFmtFooter*)pNewItem)->GetFooterFmt();
274cdf0e10cSrcweir pNewFmt->SetFmtAttr( SwFmtCntnt() );
275cdf0e10cSrcweir delete pNewItem;
276cdf0e10cSrcweir
277cdf0e10cSrcweir if( !rDest.IsFooterShared() )
278cdf0e10cSrcweir {
279cdf0e10cSrcweir const SwFmtFooter& rSourceLeftFoot = rSource.GetLeft().GetFooter();
280cdf0e10cSrcweir #ifdef DEBUG
281cdf0e10cSrcweir const SwFmtCntnt& rFooterSourceCntnt2 = rSourceLeftFoot.GetFooterFmt()->GetCntnt();
282cdf0e10cSrcweir const SwFmtCntnt& rFooterDestCntnt2 =
283cdf0e10cSrcweir rDest.GetLeft().GetFooter().GetFooterFmt()->GetCntnt();
284cdf0e10cSrcweir (void)rFooterSourceCntnt2;
285cdf0e10cSrcweir (void)rFooterDestCntnt2;
286cdf0e10cSrcweir #endif
287cdf0e10cSrcweir rDest.GetLeft().GetAttrSet().GetItemState( RES_FOOTER, sal_False, &pItem );
288cdf0e10cSrcweir pNewItem = pItem->Clone();
289cdf0e10cSrcweir pNewFmt = ((SwFmtFooter*)pNewItem)->GetFooterFmt();
290cdf0e10cSrcweir pNewFmt->SetFmtAttr( rSourceLeftFoot.GetFooterFmt()->GetCntnt() );
291cdf0e10cSrcweir delete pNewItem;
292cdf0e10cSrcweir rSource.GetLeft().GetAttrSet().GetItemState( RES_FOOTER, sal_False, &pItem );
293cdf0e10cSrcweir pNewItem = pItem->Clone();
294cdf0e10cSrcweir pNewFmt = ((SwFmtFooter*)pNewItem)->GetFooterFmt();
295cdf0e10cSrcweir pNewFmt->SetFmtAttr( SwFmtCntnt() );
296cdf0e10cSrcweir delete pNewItem;
297cdf0e10cSrcweir }
298cdf0e10cSrcweir }
299cdf0e10cSrcweir }
300cdf0e10cSrcweir
UndoImpl(::sw::UndoRedoContext &)301cdf0e10cSrcweir void SwUndoPageDesc::UndoImpl(::sw::UndoRedoContext &)
302cdf0e10cSrcweir {
303cdf0e10cSrcweir // Move (header/footer)content node responsibility from new page descriptor to old one again.
304cdf0e10cSrcweir if( bExchange )
305cdf0e10cSrcweir ExchangeContentNodes( (SwPageDesc&)aNew, (SwPageDesc&)aOld );
306cdf0e10cSrcweir pDoc->ChgPageDesc(aOld.GetName(), aOld);
307cdf0e10cSrcweir }
308cdf0e10cSrcweir
RedoImpl(::sw::UndoRedoContext &)309cdf0e10cSrcweir void SwUndoPageDesc::RedoImpl(::sw::UndoRedoContext &)
310cdf0e10cSrcweir {
311cdf0e10cSrcweir // Move (header/footer)content node responsibility from old page descriptor to new one again.
312cdf0e10cSrcweir if( bExchange )
313cdf0e10cSrcweir ExchangeContentNodes( (SwPageDesc&)aOld, (SwPageDesc&)aNew );
314cdf0e10cSrcweir pDoc->ChgPageDesc(aNew.GetName(), aNew);
315cdf0e10cSrcweir }
316cdf0e10cSrcweir
GetRewriter() const317cdf0e10cSrcweir SwRewriter SwUndoPageDesc::GetRewriter() const
318cdf0e10cSrcweir {
319cdf0e10cSrcweir SwRewriter aResult;
320cdf0e10cSrcweir
321cdf0e10cSrcweir aResult.AddRule(UNDO_ARG1, aOld.GetName());
322cdf0e10cSrcweir aResult.AddRule(UNDO_ARG2, SW_RES(STR_YIELDS));
323cdf0e10cSrcweir aResult.AddRule(UNDO_ARG3, aNew.GetName());
324cdf0e10cSrcweir
325cdf0e10cSrcweir return aResult;
326cdf0e10cSrcweir }
327cdf0e10cSrcweir
328cdf0e10cSrcweir // #116530#
SwUndoPageDescCreate(const SwPageDesc * pNew,SwDoc * _pDoc)329cdf0e10cSrcweir SwUndoPageDescCreate::SwUndoPageDescCreate(const SwPageDesc * pNew,
330cdf0e10cSrcweir SwDoc * _pDoc)
331cdf0e10cSrcweir : SwUndo(UNDO_CREATE_PAGEDESC), pDesc(pNew), aNew(*pNew, _pDoc),
332cdf0e10cSrcweir pDoc(_pDoc)
333cdf0e10cSrcweir {
334cdf0e10cSrcweir ASSERT(0 != pDoc, "no document?");
335cdf0e10cSrcweir }
336cdf0e10cSrcweir
~SwUndoPageDescCreate()337cdf0e10cSrcweir SwUndoPageDescCreate::~SwUndoPageDescCreate()
338cdf0e10cSrcweir {
339cdf0e10cSrcweir }
340cdf0e10cSrcweir
UndoImpl(::sw::UndoRedoContext &)341cdf0e10cSrcweir void SwUndoPageDescCreate::UndoImpl(::sw::UndoRedoContext &)
342cdf0e10cSrcweir {
343cdf0e10cSrcweir // -> #116530#
344cdf0e10cSrcweir if (pDesc)
345cdf0e10cSrcweir {
346cdf0e10cSrcweir aNew = *pDesc;
347cdf0e10cSrcweir pDesc = NULL;
348cdf0e10cSrcweir }
349cdf0e10cSrcweir // <- #116530#
350cdf0e10cSrcweir
351cdf0e10cSrcweir pDoc->DelPageDesc(aNew.GetName(), sal_True);
352cdf0e10cSrcweir }
353cdf0e10cSrcweir
DoImpl()354cdf0e10cSrcweir void SwUndoPageDescCreate::DoImpl()
355cdf0e10cSrcweir {
356cdf0e10cSrcweir SwPageDesc aPageDesc = aNew;
357cdf0e10cSrcweir pDoc->MakePageDesc(aNew.GetName(), &aPageDesc, sal_False, sal_True); // #116530#
358cdf0e10cSrcweir }
359cdf0e10cSrcweir
RedoImpl(::sw::UndoRedoContext &)360cdf0e10cSrcweir void SwUndoPageDescCreate::RedoImpl(::sw::UndoRedoContext &)
361cdf0e10cSrcweir {
362cdf0e10cSrcweir DoImpl();
363cdf0e10cSrcweir }
364cdf0e10cSrcweir
RepeatImpl(::sw::RepeatContext &)365cdf0e10cSrcweir void SwUndoPageDescCreate::RepeatImpl(::sw::RepeatContext &)
366cdf0e10cSrcweir {
367cdf0e10cSrcweir ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
368cdf0e10cSrcweir DoImpl();
369cdf0e10cSrcweir }
370cdf0e10cSrcweir
GetRewriter() const371cdf0e10cSrcweir SwRewriter SwUndoPageDescCreate::GetRewriter() const
372cdf0e10cSrcweir {
373cdf0e10cSrcweir SwRewriter aResult;
374cdf0e10cSrcweir
375cdf0e10cSrcweir if (pDesc)
376cdf0e10cSrcweir aResult.AddRule(UNDO_ARG1, pDesc->GetName());
377cdf0e10cSrcweir else
378cdf0e10cSrcweir aResult.AddRule(UNDO_ARG1, aNew.GetName());
379cdf0e10cSrcweir
380cdf0e10cSrcweir
381cdf0e10cSrcweir return aResult;
382cdf0e10cSrcweir }
383cdf0e10cSrcweir
SwUndoPageDescDelete(const SwPageDesc & _aOld,SwDoc * _pDoc)384cdf0e10cSrcweir SwUndoPageDescDelete::SwUndoPageDescDelete(const SwPageDesc & _aOld,
385cdf0e10cSrcweir SwDoc * _pDoc)
386cdf0e10cSrcweir : SwUndo(UNDO_DELETE_PAGEDESC), aOld(_aOld, _pDoc), pDoc(_pDoc)
387cdf0e10cSrcweir {
388cdf0e10cSrcweir ASSERT(0 != pDoc, "no document?");
389cdf0e10cSrcweir }
390cdf0e10cSrcweir
~SwUndoPageDescDelete()391cdf0e10cSrcweir SwUndoPageDescDelete::~SwUndoPageDescDelete()
392cdf0e10cSrcweir {
393cdf0e10cSrcweir }
394cdf0e10cSrcweir
UndoImpl(::sw::UndoRedoContext &)395cdf0e10cSrcweir void SwUndoPageDescDelete::UndoImpl(::sw::UndoRedoContext &)
396cdf0e10cSrcweir {
397cdf0e10cSrcweir SwPageDesc aPageDesc = aOld;
398cdf0e10cSrcweir pDoc->MakePageDesc(aOld.GetName(), &aPageDesc, sal_False, sal_True); // #116530#
399cdf0e10cSrcweir }
400cdf0e10cSrcweir
DoImpl()401cdf0e10cSrcweir void SwUndoPageDescDelete::DoImpl()
402cdf0e10cSrcweir {
403cdf0e10cSrcweir pDoc->DelPageDesc(aOld.GetName(), sal_True); // #116530#
404cdf0e10cSrcweir }
405cdf0e10cSrcweir
RedoImpl(::sw::UndoRedoContext &)406cdf0e10cSrcweir void SwUndoPageDescDelete::RedoImpl(::sw::UndoRedoContext &)
407cdf0e10cSrcweir {
408cdf0e10cSrcweir DoImpl();
409cdf0e10cSrcweir }
410cdf0e10cSrcweir
RepeatImpl(::sw::RepeatContext &)411cdf0e10cSrcweir void SwUndoPageDescDelete::RepeatImpl(::sw::RepeatContext &)
412cdf0e10cSrcweir {
413cdf0e10cSrcweir ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
414cdf0e10cSrcweir DoImpl();
415cdf0e10cSrcweir }
416cdf0e10cSrcweir
GetRewriter() const417cdf0e10cSrcweir SwRewriter SwUndoPageDescDelete::GetRewriter() const
418cdf0e10cSrcweir {
419cdf0e10cSrcweir SwRewriter aResult;
420cdf0e10cSrcweir
421cdf0e10cSrcweir aResult.AddRule(UNDO_ARG1, aOld.GetName());
422cdf0e10cSrcweir
423cdf0e10cSrcweir return aResult;
424cdf0e10cSrcweir }
425