Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <rolbck.hxx>
30 : : #include <tools/resid.hxx>
31 : : #include <svl/itemiter.hxx>
32 : : #include <editeng/brkitem.hxx>
33 : : #include <hints.hxx>
34 : : #include <hintids.hxx>
35 : : #include <fmtftn.hxx>
36 : : #include <fchrfmt.hxx>
37 : : #include <fmtflcnt.hxx>
38 : : #include <fmtrfmrk.hxx>
39 : : #include <fmtfld.hxx>
40 : : #include <fmtpdsc.hxx>
41 : : #include <txtfld.hxx>
42 : : #include <txtrfmrk.hxx>
43 : : #include <txttxmrk.hxx>
44 : : #include <txtftn.hxx>
45 : : #include <txtflcnt.hxx>
46 : : #include <fmtanchr.hxx>
47 : : #include <fmtcnct.hxx>
48 : : #include <frmfmt.hxx>
49 : : #include <ftnidx.hxx>
50 : : #include <doc.hxx> // SwDoc.GetNodes()
51 : : #include <IDocumentUndoRedo.hxx>
52 : : #include <docary.hxx>
53 : : #include <ndtxt.hxx> // SwTxtNode
54 : : #include <paratr.hxx>
55 : : #include <cellatr.hxx>
56 : : #include <fldbas.hxx>
57 : : #include <pam.hxx>
58 : : #include <swtable.hxx>
59 : : #include <ndgrf.hxx> // SwGrfNode
60 : : #include <UndoCore.hxx>
61 : : #include <IMark.hxx>
62 : : #include <charfmt.hxx> // #i27615#
63 : : #include <comcore.hrc>
64 : : #include <undo.hrc>
65 : : #include <bookmrk.hxx>
66 : :
67 : 687 : String SwHistoryHint::GetDescription() const
68 : : {
69 : 687 : return String();
70 : : }
71 : :
72 : 3148 : SwHistorySetFmt::SwHistorySetFmt( const SfxPoolItem* pFmtHt, sal_uLong nNd )
73 : : : SwHistoryHint( HSTRY_SETFMTHNT )
74 : 3148 : , m_pAttr( pFmtHt->Clone() )
75 [ + - ]: 3148 : , m_nNodeIndex( nNd )
76 : : {
77 [ - - - + ]: 3148 : switch ( m_pAttr->Which() )
78 : : {
79 : : case RES_PAGEDESC:
80 : 0 : static_cast<SwFmtPageDesc&>(*m_pAttr).ChgDefinedIn( 0 );
81 : 0 : break;
82 : : case RES_PARATR_DROP:
83 : 0 : static_cast<SwFmtDrop&>(*m_pAttr).ChgDefinedIn( 0 );
84 : 0 : break;
85 : : case RES_BOXATR_FORMULA:
86 : : {
87 : : // save formulas always in plain text
88 : 0 : SwTblBoxFormula& rNew = static_cast<SwTblBoxFormula&>(*m_pAttr);
89 [ # # ]: 0 : if ( rNew.IsIntrnlName() )
90 : : {
91 : : const SwTblBoxFormula& rOld =
92 : 0 : *static_cast<const SwTblBoxFormula*>(pFmtHt);
93 [ # # ]: 0 : const SwNode* pNd = rOld.GetNodeOfFormula();
94 [ # # ]: 0 : if ( pNd )
95 : : {
96 [ # # ]: 0 : const SwTableNode* pTableNode = pNd->FindTableNode();
97 [ # # ]: 0 : if (pTableNode)
98 : : {
99 [ # # ]: 0 : SwTableFmlUpdate aMsgHnt( &pTableNode->GetTable() );
100 : 0 : aMsgHnt.eFlags = TBL_BOXNAME;
101 : 0 : rNew.ChgDefinedIn( rOld.GetDefinedIn() );
102 [ # # ][ # # ]: 0 : rNew.ChangeState( &aMsgHnt );
103 : : }
104 : : }
105 : : }
106 : 0 : rNew.ChgDefinedIn( 0 );
107 : : }
108 : 0 : break;
109 : : }
110 : 3148 : }
111 : :
112 : 60 : String SwHistorySetFmt::GetDescription() const
113 : : {
114 : 60 : String aResult;
115 : :
116 : 60 : sal_uInt16 nWhich = m_pAttr->Which();
117 [ - + ]: 60 : switch (nWhich)
118 : : {
119 : : case RES_BREAK:
120 [ # # # ]: 0 : switch ((static_cast<SvxFmtBreakItem &>(*m_pAttr)).GetBreak())
121 : : {
122 : : case SVX_BREAK_PAGE_BEFORE:
123 : : case SVX_BREAK_PAGE_AFTER:
124 : : case SVX_BREAK_PAGE_BOTH:
125 [ # # ][ # # ]: 0 : aResult = SW_RESSTR(STR_UNDO_PAGEBREAKS);
126 : :
127 : 0 : break;
128 : : case SVX_BREAK_COLUMN_BEFORE:
129 : : case SVX_BREAK_COLUMN_AFTER:
130 : : case SVX_BREAK_COLUMN_BOTH:
131 [ # # ][ # # ]: 0 : aResult = SW_RESSTR(STR_UNDO_COLBRKS);
132 : :
133 : 0 : break;
134 : : default:
135 : 0 : break;
136 : : }
137 : 0 : break;
138 : : default:
139 : 60 : break;
140 : : }
141 : :
142 : 60 : return aResult;
143 : : }
144 : :
145 : 0 : void SwHistorySetFmt::SetInDoc( SwDoc* pDoc, bool bTmpSet )
146 : : {
147 : 0 : SwNode * pNode = pDoc->GetNodes()[ m_nNodeIndex ];
148 [ # # ]: 0 : if ( pNode->IsCntntNode() )
149 : : {
150 [ # # ][ # # ]: 0 : static_cast<SwCntntNode*>(pNode)->SetAttr( *m_pAttr );
[ # # ]
151 : : }
152 [ # # ]: 0 : else if ( pNode->IsTableNode() )
153 : : {
154 : 0 : static_cast<SwTableNode*>(pNode)->GetTable().GetFrmFmt()->SetFmtAttr(
155 : 0 : *m_pAttr );
156 : : }
157 [ # # # # ]: 0 : else if ( pNode->IsStartNode() && (SwTableBoxStartNode ==
[ # # ]
158 : 0 : static_cast<SwStartNode*>(pNode)->GetStartNodeType()) )
159 : : {
160 : 0 : SwTableNode* pTNd = pNode->FindTableNode();
161 [ # # ]: 0 : if ( pTNd )
162 : : {
163 : 0 : SwTableBox* pBox = pTNd->GetTable().GetTblBox( m_nNodeIndex );
164 [ # # ]: 0 : if (pBox)
165 : : {
166 : 0 : pBox->ClaimFrmFmt()->SetFmtAttr( *m_pAttr );
167 : : }
168 : : }
169 : : }
170 : :
171 [ # # ]: 0 : if ( !bTmpSet )
172 : : {
173 : 0 : m_pAttr.reset();
174 : : }
175 : 0 : }
176 : :
177 [ + - ]: 3142 : SwHistorySetFmt::~SwHistorySetFmt()
178 : : {
179 [ - + ]: 6284 : }
180 : :
181 : 1772 : SwHistoryResetFmt::SwHistoryResetFmt(const SfxPoolItem* pFmtHt, sal_uLong nNodeIdx)
182 : : : SwHistoryHint( HSTRY_RESETFMTHNT )
183 : : , m_nNodeIndex( nNodeIdx )
184 : 1772 : , m_nWhich( pFmtHt->Which() )
185 : : {
186 : 1772 : }
187 : :
188 : 0 : void SwHistoryResetFmt::SetInDoc( SwDoc* pDoc, bool )
189 : : {
190 : 0 : SwNode * pNode = pDoc->GetNodes()[ m_nNodeIndex ];
191 [ # # ]: 0 : if ( pNode->IsCntntNode() )
192 : : {
193 [ # # ][ # # ]: 0 : static_cast<SwCntntNode*>(pNode)->ResetAttr( m_nWhich );
[ # # ]
194 : : }
195 [ # # ]: 0 : else if ( pNode->IsTableNode() )
196 : : {
197 : 0 : static_cast<SwTableNode*>(pNode)->GetTable().GetFrmFmt()->
198 : 0 : ResetFmtAttr( m_nWhich );
199 : : }
200 : 0 : }
201 : :
202 : 414 : SwHistorySetTxt::SwHistorySetTxt( SwTxtAttr* pTxtHt, sal_uLong nNodePos )
203 : : : SwHistoryHint( HSTRY_SETTXTHNT )
204 : : , m_nNodeIndex( nNodePos )
205 : 414 : , m_nStart( *pTxtHt->GetStart() )
206 [ + - ]: 828 : , m_nEnd( *pTxtHt->GetAnyEnd() )
207 : : {
208 : : // Caution: the following attributes generate no format attributes:
209 : : // - NoLineBreak, NoHypen, Inserted, Deleted
210 : : // These cases must be handled separately !!!
211 : :
212 : : // a little bit complicated but works: first assign a copy of the
213 : : // default value and afterwards the values from text attribute
214 [ + - ]: 414 : sal_uInt16 nWhich = pTxtHt->Which();
215 [ + + ]: 414 : if ( RES_TXTATR_CHARFMT == nWhich )
216 : : {
217 [ + - ][ + - ]: 4 : m_pAttr.reset( new SwFmtCharFmt( pTxtHt->GetCharFmt().GetCharFmt() ) );
218 : : }
219 : : else
220 : : {
221 [ + - ]: 410 : m_pAttr.reset( pTxtHt->GetAttr().Clone() );
222 : : }
223 : 414 : }
224 : :
225 [ + - ]: 414 : SwHistorySetTxt::~SwHistorySetTxt()
226 : : {
227 [ - + ]: 828 : }
228 : :
229 : 0 : void SwHistorySetTxt::SetInDoc( SwDoc* pDoc, bool )
230 : : {
231 [ # # ]: 0 : if ( !m_pAttr.get() )
232 : 0 : return;
233 : :
234 [ # # ]: 0 : if ( RES_TXTATR_CHARFMT == m_pAttr->Which() )
235 : : {
236 : : // ask the Doc if the CharFmt still exists
237 [ # # ]: 0 : if ( !pDoc->GetCharFmts()->Contains( (static_cast<SwFmtCharFmt&>(*m_pAttr)).GetCharFmt() ) )
238 : 0 : return; // do not set, format does not exist
239 : : }
240 : :
241 : 0 : SwTxtNode * pTxtNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetTxtNode();
242 : : OSL_ENSURE( pTxtNd, "SwHistorySetTxt::SetInDoc: not a TextNode" );
243 : :
244 [ # # ]: 0 : if ( pTxtNd )
245 : : {
246 : 0 : pTxtNd->InsertItem( *m_pAttr, m_nStart, m_nEnd,
247 : : nsSetAttrMode::SETATTR_NOTXTATRCHR |
248 : 0 : nsSetAttrMode::SETATTR_NOHINTADJUST );
249 : : }
250 : : }
251 : :
252 : 44 : SwHistorySetTxtFld::SwHistorySetTxtFld( SwTxtFld* pTxtFld, sal_uLong nNodePos )
253 : : : SwHistoryHint( HSTRY_SETTXTFLDHNT )
254 : : , m_pFldType( 0 )
255 [ + - ][ + - ]: 44 : , m_pFld( new SwFmtFld( *pTxtFld->GetFld().GetFld() ) )
256 : : {
257 : : // only copy if not Sys-FieldType
258 : 44 : SwDoc* pDoc = pTxtFld->GetTxtNode().GetDoc();
259 : :
260 : 44 : m_nFldWhich = m_pFld->GetFld()->GetTyp()->Which();
261 [ + - ][ + - ]: 86 : if (m_nFldWhich == RES_DBFLD ||
[ + - ][ - + ]
[ + + ][ + + ]
262 : : m_nFldWhich == RES_USERFLD ||
263 : : m_nFldWhich == RES_SETEXPFLD ||
264 : : m_nFldWhich == RES_DDEFLD ||
265 [ + - ]: 42 : !pDoc->GetSysFldType( m_nFldWhich ))
266 : : {
267 [ + - ]: 2 : m_pFldType.reset( m_pFld->GetFld()->GetTyp()->Copy() );
268 [ + - ]: 2 : m_pFld->GetFld()->ChgTyp( m_pFldType.get() ); // change field type
269 : : }
270 : 44 : m_nNodeIndex = nNodePos;
271 : 44 : m_nPos = *pTxtFld->GetStart();
272 : 44 : }
273 : :
274 : 25 : String SwHistorySetTxtFld::GetDescription() const
275 : : {
276 : 25 : return m_pFld->GetFld()->GetDescription();
277 : : }
278 : :
279 [ + - ][ + - ]: 42 : SwHistorySetTxtFld::~SwHistorySetTxtFld()
280 : : {
281 [ - + ]: 84 : }
282 : :
283 : 0 : void SwHistorySetTxtFld::SetInDoc( SwDoc* pDoc, bool )
284 : : {
285 [ # # ]: 0 : if ( !m_pFld.get() )
286 : 0 : return;
287 : :
288 : 0 : SwFieldType* pNewFldType = m_pFldType.get();
289 [ # # ]: 0 : if ( !pNewFldType )
290 : : {
291 : 0 : pNewFldType = pDoc->GetSysFldType( m_nFldWhich );
292 : : }
293 : : else
294 : : {
295 : : // register type with the document
296 : 0 : pNewFldType = pDoc->InsertFldType( *m_pFldType );
297 : : }
298 : :
299 : 0 : m_pFld->GetFld()->ChgTyp( pNewFldType ); // change field type
300 : :
301 : 0 : SwTxtNode * pTxtNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetTxtNode();
302 : : OSL_ENSURE( pTxtNd, "SwHistorySetTxtFld: no TextNode" );
303 : :
304 [ # # ]: 0 : if ( pTxtNd )
305 : : {
306 : 0 : pTxtNd->InsertItem( *m_pFld, m_nPos, m_nPos,
307 : 0 : nsSetAttrMode::SETATTR_NOTXTATRCHR );
308 : : }
309 : : }
310 : :
311 : 24 : SwHistorySetRefMark::SwHistorySetRefMark( SwTxtRefMark* pTxtHt, sal_uLong nNodePos )
312 : : : SwHistoryHint( HSTRY_SETREFMARKHNT )
313 : 24 : , m_RefName( pTxtHt->GetRefMark().GetRefName() )
314 : : , m_nNodeIndex( nNodePos )
315 : 24 : , m_nStart( *pTxtHt->GetStart() )
316 [ + - + - ]: 72 : , m_nEnd( *pTxtHt->GetAnyEnd() )
317 : : {
318 : 24 : }
319 : :
320 : 0 : void SwHistorySetRefMark::SetInDoc( SwDoc* pDoc, bool )
321 : : {
322 [ # # ][ # # ]: 0 : SwTxtNode * pTxtNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetTxtNode();
323 : : OSL_ENSURE( pTxtNd, "SwHistorySetRefMark: no TextNode" );
324 [ # # ]: 0 : if ( !pTxtNd )
325 : 0 : return;
326 : :
327 [ # # ]: 0 : SwFmtRefMark aRefMark( m_RefName );
328 : :
329 : : // if a reference mark without an end already exists here: must not insert!
330 [ # # ][ # # ]: 0 : if ( m_nStart != m_nEnd ||
[ # # ]
331 [ # # ]: 0 : !pTxtNd->GetTxtAttrForCharAt( m_nStart, RES_TXTATR_REFMARK ) )
332 : : {
333 : : pTxtNd->InsertItem( aRefMark, m_nStart, m_nEnd,
334 [ # # ]: 0 : nsSetAttrMode::SETATTR_NOTXTATRCHR );
335 [ # # ]: 0 : }
336 : : }
337 : :
338 : 26 : SwHistorySetTOXMark::SwHistorySetTOXMark( SwTxtTOXMark* pTxtHt, sal_uLong nNodePos )
339 : : : SwHistoryHint( HSTRY_SETTOXMARKHNT )
340 : 26 : , m_TOXMark( pTxtHt->GetTOXMark() )
341 : 26 : , m_TOXName( m_TOXMark.GetTOXType()->GetTypeName() )
342 : 26 : , m_eTOXTypes( m_TOXMark.GetTOXType()->GetType() )
343 : : , m_nNodeIndex( nNodePos )
344 : 26 : , m_nStart( *pTxtHt->GetStart() )
345 [ + - + - : 104 : , m_nEnd( *pTxtHt->GetAnyEnd() )
+ - ]
346 : : {
347 [ + - ]: 26 : m_TOXMark.DeRegister();
348 : 26 : }
349 : :
350 : 0 : void SwHistorySetTOXMark::SetInDoc( SwDoc* pDoc, bool )
351 : : {
352 [ # # ][ # # ]: 0 : SwTxtNode * pTxtNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetTxtNode();
353 : : OSL_ENSURE( pTxtNd, "SwHistorySetTOXMark: no TextNode" );
354 [ # # ]: 0 : if ( !pTxtNd )
355 : 0 : return;
356 : :
357 : : // search for respective TOX type
358 [ # # ]: 0 : sal_uInt16 nCnt = pDoc->GetTOXTypeCount( m_eTOXTypes );
359 : 0 : SwTOXType* pToxType = 0;
360 [ # # ]: 0 : for ( sal_uInt16 n = 0; n < nCnt; ++n )
361 : : {
362 [ # # ]: 0 : pToxType = const_cast<SwTOXType*>(pDoc->GetTOXType( m_eTOXTypes, n ));
363 [ # # ][ # # ]: 0 : if ( pToxType->GetTypeName() == m_TOXName )
364 : 0 : break;
365 : 0 : pToxType = 0;
366 : : }
367 : :
368 [ # # ]: 0 : if ( !pToxType ) // TOX type not found, create new
369 : : {
370 : : pToxType = const_cast<SwTOXType*>(
371 [ # # ][ # # ]: 0 : pDoc->InsertTOXType( SwTOXType( m_eTOXTypes, m_TOXName )));
[ # # ]
372 : : }
373 : :
374 [ # # ]: 0 : SwTOXMark aNew( m_TOXMark );
375 [ # # ]: 0 : aNew.RegisterToTOXType( *pToxType );
376 : :
377 : : pTxtNd->InsertItem( aNew, m_nStart, m_nEnd,
378 [ # # ][ # # ]: 0 : nsSetAttrMode::SETATTR_NOTXTATRCHR );
379 : : }
380 : :
381 : 0 : int SwHistorySetTOXMark::IsEqual( const SwTOXMark& rCmp ) const
382 : : {
383 : 0 : return m_TOXName == rCmp.GetTOXType()->GetTypeName() &&
384 : 0 : m_eTOXTypes == rCmp.GetTOXType()->GetType() &&
385 : 0 : m_TOXMark.GetAlternativeText() == rCmp.GetAlternativeText() &&
386 : : ( (TOX_INDEX == m_eTOXTypes)
387 : 0 : ? ( m_TOXMark.GetPrimaryKey() == rCmp.GetPrimaryKey() &&
388 : 0 : m_TOXMark.GetSecondaryKey() == rCmp.GetSecondaryKey() )
389 : 0 : : m_TOXMark.GetLevel() == rCmp.GetLevel()
390 [ # # # # : 0 : );
# # # # ]
[ # # # #
# # ]
391 : : }
392 : :
393 : 660 : SwHistoryResetTxt::SwHistoryResetTxt( sal_uInt16 nWhich,
394 : : xub_StrLen nAttrStart, xub_StrLen nAttrEnd, sal_uLong nNodePos )
395 : : : SwHistoryHint( HSTRY_RESETTXTHNT )
396 : : , m_nNodeIndex( nNodePos ), m_nStart( nAttrStart ), m_nEnd( nAttrEnd )
397 : 660 : , m_nAttr( nWhich )
398 : : {
399 : 660 : }
400 : :
401 : 0 : void SwHistoryResetTxt::SetInDoc( SwDoc* pDoc, bool )
402 : : {
403 : 0 : SwTxtNode * pTxtNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetTxtNode();
404 : : OSL_ENSURE( pTxtNd, "SwHistoryResetTxt: no TextNode" );
405 [ # # ]: 0 : if ( pTxtNd )
406 : : {
407 : 0 : pTxtNd->DeleteAttributes( m_nAttr, m_nStart, m_nEnd );
408 : : }
409 : 0 : }
410 : :
411 : 26 : SwHistorySetFootnote::SwHistorySetFootnote( SwTxtFtn* pTxtFtn, sal_uLong nNodePos )
412 : : : SwHistoryHint( HSTRY_SETFTNHNT )
413 [ + - ]: 26 : , m_pUndo( new SwUndoSaveSection )
414 : 26 : , m_FootnoteNumber( pTxtFtn->GetFtn().GetNumStr() )
415 : : , m_nNodeIndex( nNodePos )
416 : 26 : , m_nStart( *pTxtFtn->GetStart() )
417 [ + - ][ + - ]: 104 : , m_bEndNote( pTxtFtn->GetFtn().IsEndNote() )
418 : : {
419 : : OSL_ENSURE( pTxtFtn->GetStartNode(),
420 : : "SwHistorySetFootnote: Footnote without Section" );
421 : :
422 : : // keep the old NodePos (because who knows what later will be saved/deleted
423 : : // in SaveSection)
424 : 26 : SwDoc* pDoc = const_cast<SwDoc*>(pTxtFtn->GetTxtNode().GetDoc());
425 [ + - ][ + - ]: 26 : SwNode* pSaveNd = pDoc->GetNodes()[ m_nNodeIndex ];
426 : :
427 : : // keep pointer to StartNode of FtnSection and reset its attribute for now
428 : : // (as a result, its/all Frms will be deleted automatically)
429 [ + - ]: 26 : SwNodeIndex aSttIdx( *pTxtFtn->GetStartNode() );
430 [ + - ]: 26 : pTxtFtn->SetStartNode( 0, sal_False );
431 : :
432 [ + - ]: 26 : m_pUndo->SaveSection( pDoc, aSttIdx );
433 [ + - ]: 26 : m_nNodeIndex = pSaveNd->GetIndex();
434 : 26 : }
435 : :
436 : 4 : SwHistorySetFootnote::SwHistorySetFootnote( const SwTxtFtn &rTxtFtn )
437 : : : SwHistoryHint( HSTRY_SETFTNHNT )
438 : : , m_pUndo( 0 )
439 : 4 : , m_FootnoteNumber( rTxtFtn.GetFtn().GetNumStr() )
440 : 4 : , m_nNodeIndex( _SwTxtFtn_GetIndex( (&rTxtFtn) ) )
441 : 4 : , m_nStart( *rTxtFtn.GetStart() )
442 [ + - ]: 12 : , m_bEndNote( rTxtFtn.GetFtn().IsEndNote() )
443 : : {
444 : : OSL_ENSURE( rTxtFtn.GetStartNode(),
445 : : "SwHistorySetFootnote: Footnote without Section" );
446 : 4 : }
447 : :
448 : 20 : String SwHistorySetFootnote::GetDescription() const
449 : : {
450 [ + - ]: 20 : return SW_RES(STR_FOOTNOTE);
451 : : }
452 : :
453 [ + - ][ + - ]: 30 : SwHistorySetFootnote::~SwHistorySetFootnote()
454 : : {
455 [ - + ]: 60 : }
456 : :
457 : 0 : void SwHistorySetFootnote::SetInDoc( SwDoc* pDoc, bool )
458 : : {
459 : 0 : SwTxtNode * pTxtNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetTxtNode();
460 : : OSL_ENSURE( pTxtNd, "SwHistorySetFootnote: no TextNode" );
461 [ # # ]: 0 : if ( !pTxtNd )
462 : 0 : return;
463 : :
464 [ # # ]: 0 : if ( m_pUndo.get() )
465 : : {
466 : : // set the footnote in the TextNode
467 [ # # ]: 0 : SwFmtFtn aTemp( m_bEndNote );
468 : : SwFmtFtn& rNew = const_cast<SwFmtFtn&>(
469 [ # # ]: 0 : static_cast<const SwFmtFtn&>(pDoc->GetAttrPool().Put(aTemp)) );
470 [ # # ]: 0 : if ( m_FootnoteNumber.Len() )
471 : : {
472 [ # # ]: 0 : rNew.SetNumStr( m_FootnoteNumber );
473 : : }
474 [ # # ][ # # ]: 0 : SwTxtFtn* pTxtFtn = new SwTxtFtn( rNew, m_nStart );
475 : :
476 : : // create the section of the Footnote
477 [ # # ]: 0 : SwNodeIndex aIdx( *pTxtNd );
478 [ # # ]: 0 : m_pUndo->RestoreSection( pDoc, &aIdx, SwFootnoteStartNode );
479 [ # # ]: 0 : pTxtFtn->SetStartNode( &aIdx );
480 [ # # ]: 0 : if ( m_pUndo->GetHistory() )
481 : : {
482 : : // create frames only now
483 [ # # ]: 0 : m_pUndo->GetHistory()->Rollback( pDoc );
484 : : }
485 : :
486 [ # # ][ # # ]: 0 : pTxtNd->InsertHint( pTxtFtn );
[ # # ]
487 : : }
488 : : else
489 : : {
490 : : SwTxtFtn * const pFtn =
491 : : const_cast<SwTxtFtn*>( static_cast<const SwTxtFtn*>(
492 : 0 : pTxtNd->GetTxtAttrForCharAt( m_nStart )));
493 : 0 : SwFmtFtn &rFtn = const_cast<SwFmtFtn&>(pFtn->GetFtn());
494 : 0 : rFtn.SetNumStr( m_FootnoteNumber );
495 [ # # ]: 0 : if ( rFtn.IsEndNote() != m_bEndNote )
496 : : {
497 : 0 : rFtn.SetEndNote( m_bEndNote );
498 : 0 : pFtn->CheckCondColl();
499 : : }
500 : : }
501 : : }
502 : :
503 : 62 : SwHistoryChangeFmtColl::SwHistoryChangeFmtColl( SwFmtColl* pFmtColl, sal_uLong nNd,
504 : : sal_uInt8 nNodeWhich )
505 : : : SwHistoryHint( HSTRY_CHGFMTCOLL )
506 : : , m_pColl( pFmtColl )
507 : : , m_nNodeIndex( nNd )
508 : 62 : , m_nNodeType( nNodeWhich )
509 : : {
510 : 62 : }
511 : :
512 : 0 : void SwHistoryChangeFmtColl::SetInDoc( SwDoc* pDoc, bool )
513 : : {
514 : 0 : SwCntntNode * pCntntNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetCntntNode();
515 : : OSL_ENSURE( pCntntNd, "SwHistoryChangeFmtColl: no ContentNode" );
516 : :
517 : : // before setting the format, check if it is still available in the
518 : : // document. if it has been deleted, there is no undo!
519 [ # # ][ # # ]: 0 : if ( pCntntNd && m_nNodeType == pCntntNd->GetNodeType() )
[ # # ]
520 : : {
521 [ # # ]: 0 : if ( ND_TEXTNODE == m_nNodeType )
522 : : {
523 [ # # ]: 0 : if ( USHRT_MAX != pDoc->GetTxtFmtColls()->GetPos(
524 : 0 : static_cast<SwTxtFmtColl * const>(m_pColl) ))
525 : : {
526 : 0 : pCntntNd->ChgFmtColl( m_pColl );
527 : : }
528 : : }
529 [ # # ]: 0 : else if ( USHRT_MAX != pDoc->GetGrfFmtColls()->GetPos(
530 : 0 : static_cast<SwGrfFmtColl * const>(m_pColl) ))
531 : : {
532 : 0 : pCntntNd->ChgFmtColl( m_pColl );
533 : : }
534 : : }
535 : 0 : }
536 : :
537 : 0 : SwHistoryTxtFlyCnt::SwHistoryTxtFlyCnt( SwFrmFmt* const pFlyFmt )
538 : : : SwHistoryHint( HSTRY_FLYCNT )
539 [ # # ][ # # ]: 0 : , m_pUndo( new SwUndoDelLayFmt( pFlyFmt ) )
540 : : {
541 : : OSL_ENSURE( pFlyFmt, "SwHistoryTxtFlyCnt: no Format" );
542 : 0 : m_pUndo->ChgShowSel( sal_False );
543 : 0 : }
544 : :
545 [ # # ]: 0 : SwHistoryTxtFlyCnt::~SwHistoryTxtFlyCnt()
546 : : {
547 [ # # ]: 0 : }
548 : :
549 : 0 : void SwHistoryTxtFlyCnt::SetInDoc( SwDoc* pDoc, bool )
550 : : {
551 [ # # ]: 0 : ::sw::IShellCursorSupplier *const pISCS(pDoc->GetIShellCursorSupplier());
552 : : OSL_ASSERT(pISCS);
553 [ # # ]: 0 : ::sw::UndoRedoContext context(*pDoc, *pISCS);
554 [ # # ][ # # ]: 0 : m_pUndo->UndoImpl(context);
555 : 0 : }
556 : :
557 : 2646 : SwHistoryBookmark::SwHistoryBookmark(
558 : : const ::sw::mark::IMark& rBkmk,
559 : : bool bSavePos,
560 : : bool bSaveOtherPos)
561 : : : SwHistoryHint(HSTRY_BOOKMARK)
562 [ + - ]: 2646 : , m_aName(rBkmk.GetName())
563 : : , m_aShortName()
564 : : , m_aKeycode()
565 : : , m_nNode(bSavePos ?
566 [ + - ]: 2457 : rBkmk.GetMarkPos().nNode.GetIndex() : 0)
567 : : , m_nOtherNode(bSaveOtherPos ?
568 [ + - ]: 2386 : rBkmk.GetOtherMarkPos().nNode.GetIndex() : 0)
569 : : , m_nCntnt(bSavePos ?
570 [ + - ]: 2457 : rBkmk.GetMarkPos().nContent.GetIndex() : 0)
571 : : , m_nOtherCntnt(bSaveOtherPos ?
572 [ + - ]: 2386 : rBkmk.GetOtherMarkPos().nContent.GetIndex() :0)
573 : : , m_bSavePos(bSavePos)
574 : : , m_bSaveOtherPos(bSaveOtherPos)
575 [ + - ]: 2646 : , m_bHadOtherPos(rBkmk.IsExpanded())
576 [ + + ][ + + ]: 17624 : , m_eBkmkType(IDocumentMarkAccess::GetType(rBkmk))
[ + + ][ + + ]
[ + - ][ + - ]
577 : : {
578 [ - + ]: 2646 : const ::sw::mark::IBookmark* const pBookmark = dynamic_cast< const ::sw::mark::IBookmark* >(&rBkmk);
579 [ + + ]: 2646 : if(pBookmark)
580 : : {
581 [ + - ][ + - ]: 2532 : m_aKeycode = pBookmark->GetKeyCode();
582 [ + - ]: 2532 : m_aShortName = pBookmark->GetShortName();
583 : :
584 : : ::sfx2::Metadatable const*const pMetadatable(
585 [ - + ]: 2532 : dynamic_cast< ::sfx2::Metadatable const* >(pBookmark));
586 [ + - ]: 2532 : if (pMetadatable)
587 : : {
588 [ + - ][ + - ]: 2532 : m_pMetadataUndo = pMetadatable->CreateUndo();
[ + - ]
589 : : }
590 : : }
591 : 2646 : }
592 : :
593 : 0 : void SwHistoryBookmark::SetInDoc( SwDoc* pDoc, bool )
594 : : {
595 [ # # ][ # # ]: 0 : ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
596 : :
597 [ # # ]: 0 : SwNodes& rNds = pDoc->GetNodes();
598 [ # # ]: 0 : IDocumentMarkAccess* pMarkAccess = pDoc->getIDocumentMarkAccess();
599 : 0 : ::std::auto_ptr<SwPaM> pPam;
600 : 0 : ::sw::mark::IMark* pMark = NULL;
601 : :
602 [ # # ]: 0 : if(m_bSavePos)
603 : : {
604 [ # # ]: 0 : SwCntntNode* const pCntntNd = rNds[m_nNode]->GetCntntNode();
605 : : OSL_ENSURE(pCntntNd,
606 : : "<SwHistoryBookmark::SetInDoc(..)>"
607 : : " - wrong node for a mark");
608 : :
609 : : // #111660# don't crash when nNode1 doesn't point to content node.
610 [ # # ]: 0 : if(pCntntNd)
611 [ # # ][ # # ]: 0 : pPam = ::std::auto_ptr<SwPaM>(new SwPaM(*pCntntNd, m_nCntnt));
[ # # ]
612 : : }
613 : : else
614 : : {
615 [ # # ]: 0 : pMark = pMarkAccess->findMark(m_aName)->get();
616 [ # # ][ # # ]: 0 : pPam = ::std::auto_ptr<SwPaM>(new SwPaM(pMark->GetMarkPos()));
[ # # ][ # # ]
617 : : }
618 : :
619 [ # # ]: 0 : if(m_bSaveOtherPos)
620 : : {
621 [ # # ]: 0 : SwCntntNode* const pCntntNd = rNds[m_nOtherNode]->GetCntntNode();
622 : : OSL_ENSURE(pCntntNd,
623 : : "<SwHistoryBookmark::SetInDoc(..)>"
624 : : " - wrong node for a mark");
625 : :
626 [ # # ][ # # ]: 0 : if(pPam.get() != NULL && pCntntNd)
[ # # ]
627 : : {
628 [ # # ]: 0 : pPam->SetMark();
629 [ # # ]: 0 : pPam->GetMark()->nNode = m_nOtherNode;
630 [ # # ][ # # ]: 0 : pPam->GetMark()->nContent.Assign(pCntntNd, m_nOtherCntnt);
631 : : }
632 : : }
633 [ # # ]: 0 : else if(m_bHadOtherPos)
634 : : {
635 [ # # ]: 0 : if(!pMark)
636 [ # # ]: 0 : pMark = pMarkAccess->findMark(m_aName)->get();
637 : : OSL_ENSURE(pMark->IsExpanded(),
638 : : "<SwHistoryBookmark::SetInDoc(..)>"
639 : : " - missing pos on old mark");
640 [ # # ]: 0 : pPam->SetMark();
641 [ # # ][ # # ]: 0 : *pPam->GetMark() = pMark->GetOtherMarkPos();
642 : : }
643 : :
644 [ # # ]: 0 : if(pPam.get())
645 : : {
646 [ # # ]: 0 : if(pMark)
647 [ # # ]: 0 : pMarkAccess->deleteMark(pMark);
648 : : ::sw::mark::IBookmark* const pBookmark = dynamic_cast< ::sw::mark::IBookmark* >(
649 [ # # ][ # # ]: 0 : pMarkAccess->makeMark(*pPam, m_aName, m_eBkmkType));
650 [ # # ]: 0 : if(pBookmark)
651 : : {
652 [ # # ]: 0 : pBookmark->SetKeyCode(m_aKeycode);
653 [ # # ]: 0 : pBookmark->SetShortName(m_aShortName);
654 [ # # ]: 0 : if (m_pMetadataUndo)
655 : : {
656 : : ::sfx2::Metadatable * const pMeta(
657 [ # # ]: 0 : dynamic_cast< ::sfx2::Metadatable* >(pBookmark));
658 : : OSL_ENSURE(pMeta, "metadata undo, but not metadatable?");
659 [ # # ]: 0 : if (pMeta)
660 : : {
661 [ # # ]: 0 : pMeta->RestoreMetadata(m_pMetadataUndo);
662 : : }
663 : : }
664 : : }
665 [ # # ][ # # ]: 0 : }
666 : 0 : }
667 : :
668 : 0 : bool SwHistoryBookmark::IsEqualBookmark(const ::sw::mark::IMark& rBkmk)
669 : : {
670 : 0 : return m_nNode == rBkmk.GetMarkPos().nNode.GetIndex()
671 : 0 : && m_nCntnt == rBkmk.GetMarkPos().nContent.GetIndex()
672 [ # # ]: 0 : && m_aName == rBkmk.GetName();
[ # # # # ]
673 : : }
674 : :
675 : 2068 : const ::rtl::OUString& SwHistoryBookmark::GetName() const
676 : : {
677 : 2068 : return m_aName;
678 : : }
679 : :
680 : 0 : SwHistorySetAttrSet::SwHistorySetAttrSet( const SfxItemSet& rSet,
681 : : sal_uLong nNodePos, const std::set<sal_uInt16> &rSetArr )
682 : : : SwHistoryHint( HSTRY_SETATTRSET )
683 : : , m_OldSet( rSet )
684 : : , m_ResetArray( 0, 4 )
685 [ # # ][ # # ]: 0 : , m_nNodeIndex( nNodePos )
686 : : {
687 [ # # ][ # # ]: 0 : SfxItemIter aIter( m_OldSet ), aOrigIter( rSet );
688 : 0 : const SfxPoolItem* pItem = aIter.FirstItem(),
689 : 0 : * pOrigItem = aOrigIter.FirstItem();
690 : 0 : do {
691 [ # # ][ # # ]: 0 : if( !rSetArr.count( pOrigItem->Which() ))
692 : : {
693 [ # # ]: 0 : m_ResetArray.push_back( pOrigItem->Which() );
694 [ # # ]: 0 : m_OldSet.ClearItem( pOrigItem->Which() );
695 : : }
696 : : else
697 : : {
698 [ # # # # ]: 0 : switch ( pItem->Which() )
699 : : {
700 : : case RES_PAGEDESC:
701 : : static_cast<SwFmtPageDesc*>(
702 : 0 : const_cast<SfxPoolItem*>(pItem))->ChgDefinedIn( 0 );
703 : 0 : break;
704 : :
705 : : case RES_PARATR_DROP:
706 : : static_cast<SwFmtDrop*>(
707 : 0 : const_cast<SfxPoolItem*>(pItem))->ChgDefinedIn( 0 );
708 : 0 : break;
709 : :
710 : : case RES_BOXATR_FORMULA:
711 : : {
712 : : // When a formula is set, never save the value. It
713 : : // possibly must be recalculated!
714 : : // Save formulas always in plain text
715 [ # # ]: 0 : m_OldSet.ClearItem( RES_BOXATR_VALUE );
716 : :
717 : : SwTblBoxFormula& rNew =
718 : : *static_cast<SwTblBoxFormula*>(
719 : 0 : const_cast<SfxPoolItem*>(pItem));
720 [ # # ]: 0 : if ( rNew.IsIntrnlName() )
721 : : {
722 : : const SwTblBoxFormula& rOld =
723 : : static_cast<const SwTblBoxFormula&>(
724 [ # # ]: 0 : rSet.Get( RES_BOXATR_FORMULA ));
725 [ # # ]: 0 : const SwNode* pNd = rOld.GetNodeOfFormula();
726 [ # # ]: 0 : if ( pNd )
727 : : {
728 : : const SwTableNode* pTableNode
729 [ # # ]: 0 : = pNd->FindTableNode();
730 [ # # ]: 0 : if (pTableNode)
731 : : {
732 : : SwTableFmlUpdate aMsgHnt(
733 [ # # ]: 0 : &pTableNode->GetTable() );
734 : 0 : aMsgHnt.eFlags = TBL_BOXNAME;
735 : 0 : rNew.ChgDefinedIn( rOld.GetDefinedIn() );
736 [ # # ][ # # ]: 0 : rNew.ChangeState( &aMsgHnt );
737 : : }
738 : : }
739 : : }
740 : 0 : rNew.ChgDefinedIn( 0 );
741 : : }
742 : 0 : break;
743 : : }
744 : : }
745 : :
746 [ # # ]: 0 : if( aIter.IsAtEnd() )
747 : 0 : break;
748 [ # # ]: 0 : pItem = aIter.NextItem();
749 [ # # ]: 0 : pOrigItem = aOrigIter.NextItem();
750 [ # # ][ # # ]: 0 : } while( sal_True );
751 : 0 : }
752 : :
753 : 0 : void SwHistorySetAttrSet::SetInDoc( SwDoc* pDoc, bool )
754 : : {
755 [ # # ][ # # ]: 0 : ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
756 : :
757 [ # # ][ # # ]: 0 : SwNode * pNode = pDoc->GetNodes()[ m_nNodeIndex ];
758 [ # # ]: 0 : if ( pNode->IsCntntNode() )
759 : : {
760 [ # # ][ # # ]: 0 : static_cast<SwCntntNode*>(pNode)->SetAttr( m_OldSet );
[ # # ][ # # ]
761 [ # # ]: 0 : if ( !m_ResetArray.empty() )
762 : : {
763 [ # # ][ # # ]: 0 : static_cast<SwCntntNode*>(pNode)->ResetAttr( m_ResetArray );
[ # # ][ # # ]
764 : : }
765 : : }
766 [ # # ]: 0 : else if ( pNode->IsTableNode() )
767 : : {
768 : : SwFmt& rFmt =
769 : 0 : *static_cast<SwTableNode*>(pNode)->GetTable().GetFrmFmt();
770 [ # # ]: 0 : rFmt.SetFmtAttr( m_OldSet );
771 [ # # ]: 0 : if ( !m_ResetArray.empty() )
772 : : {
773 [ # # ][ # # ]: 0 : rFmt.ResetFmtAttr( m_ResetArray.front() );
774 : : }
775 [ # # ]: 0 : }
776 : 0 : }
777 : :
778 : 790 : SwHistoryResetAttrSet::SwHistoryResetAttrSet( const SfxItemSet& rSet,
779 : : sal_uLong nNodePos, xub_StrLen nAttrStt, xub_StrLen nAttrEnd )
780 : : : SwHistoryHint( HSTRY_RESETATTRSET )
781 : : , m_nNodeIndex( nNodePos ), m_nStart( nAttrStt ), m_nEnd( nAttrEnd )
782 [ + - ]: 790 : , m_Array( (sal_uInt8)rSet.Count() )
783 : : {
784 [ + - ]: 790 : SfxItemIter aIter( rSet );
785 : 790 : bool bAutoStyle = false;
786 : :
787 : 0 : while( sal_True )
788 : : {
789 : 790 : const sal_uInt16 nWhich = aIter.GetCurItem()->Which();
790 : :
791 : : #ifdef DBG_UTIL
792 : : switch (nWhich)
793 : : {
794 : : case RES_TXTATR_REFMARK:
795 : : case RES_TXTATR_TOXMARK:
796 : : if (m_nStart != m_nEnd) break; // else: fall through!
797 : : case RES_TXTATR_FIELD:
798 : : case RES_TXTATR_FLYCNT:
799 : : case RES_TXTATR_FTN:
800 : : case RES_TXTATR_META:
801 : : case RES_TXTATR_METAFIELD:
802 : : OSL_ENSURE(rSet.Count() == 1,
803 : : "text attribute with CH_TXTATR, but not the only one:"
804 : : "\nnot such a good idea");
805 : : break;
806 : : }
807 : : #endif // DBG_UTIL
808 : :
809 : : // Character attribute cannot be inserted into the hints array
810 : : // anymore. Therefore we have to treat them as one RES_TXTATR_AUTOFMT:
811 [ + + ]: 790 : if (isCHRATR(nWhich))
812 : : {
813 : 108 : bAutoStyle = true;
814 : : }
815 : : else
816 : : {
817 [ + - ]: 682 : m_Array.push_back( aIter.GetCurItem()->Which() );
818 : : }
819 : :
820 [ + - ]: 790 : if( aIter.IsAtEnd() )
821 : 790 : break;
822 : :
823 [ # # ]: 0 : aIter.NextItem();
824 : : }
825 : :
826 [ + + ]: 790 : if ( bAutoStyle )
827 : : {
828 [ + - ]: 108 : m_Array.push_back( RES_TXTATR_AUTOFMT );
829 [ + - ]: 790 : }
830 : 790 : }
831 : :
832 : 0 : void SwHistoryResetAttrSet::SetInDoc( SwDoc* pDoc, bool )
833 : : {
834 [ # # ][ # # ]: 0 : ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
835 : :
836 [ # # ][ # # ]: 0 : SwCntntNode * pCntntNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetCntntNode();
837 : : OSL_ENSURE( pCntntNd, "SwHistoryResetAttrSet: no CntntNode" );
838 : :
839 [ # # ]: 0 : if (pCntntNd)
840 : : {
841 : 0 : std::vector<sal_uInt16>::iterator it;
842 [ # # ][ # # ]: 0 : if ( USHRT_MAX == m_nEnd && USHRT_MAX == m_nStart )
843 : : {
844 : : // no area: use ContentNode
845 [ # # ][ # # ]: 0 : for ( it = m_Array.begin(); it != m_Array.end(); ++it )
[ # # ]
846 : : {
847 [ # # ][ # # ]: 0 : pCntntNd->ResetAttr( *it );
848 : : }
849 : : }
850 : : else
851 : : {
852 : : // area: use TextNode
853 [ # # ][ # # ]: 0 : for ( it = m_Array.begin(); it != m_Array.end(); ++it )
[ # # ]
854 : : {
855 : : static_cast<SwTxtNode*>(pCntntNd)->
856 [ # # ][ # # ]: 0 : DeleteAttributes( *it, m_nStart, m_nEnd );
857 : : }
858 : : }
859 [ # # ]: 0 : }
860 : 0 : }
861 : :
862 : 0 : SwHistoryChangeFlyAnchor::SwHistoryChangeFlyAnchor( SwFrmFmt& rFmt )
863 : : : SwHistoryHint( HSTRY_CHGFLYANCHOR )
864 : : , m_rFmt( rFmt )
865 [ # # ][ # # ]: 0 : , m_nOldNodeIndex( rFmt.GetAnchor().GetCntntAnchor()->nNode.GetIndex() )
866 [ # # ]: 0 : , m_nOldContentIndex( (FLY_AT_CHAR == rFmt.GetAnchor().GetAnchorId())
867 [ # # ][ # # ]: 0 : ? rFmt.GetAnchor().GetCntntAnchor()->nContent.GetIndex()
868 [ # # ]: 0 : : STRING_MAXLEN )
869 : : {
870 : 0 : }
871 : :
872 : :
873 : 0 : void SwHistoryChangeFlyAnchor::SetInDoc( SwDoc* pDoc, bool )
874 : : {
875 [ # # ][ # # ]: 0 : ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
876 : :
877 [ # # ]: 0 : sal_uInt16 nPos = pDoc->GetSpzFrmFmts()->GetPos( &m_rFmt );
878 [ # # ]: 0 : if ( USHRT_MAX != nPos ) // Format does still exist
879 : : {
880 [ # # ][ # # ]: 0 : SwFmtAnchor aTmp( m_rFmt.GetAnchor() );
881 : :
882 [ # # ][ # # ]: 0 : SwNode* pNd = pDoc->GetNodes()[ m_nOldNodeIndex ];
883 : 0 : SwCntntNode* pCNd = pNd->GetCntntNode();
884 [ # # ]: 0 : SwPosition aPos( *pNd );
885 [ # # ]: 0 : if ( STRING_MAXLEN != m_nOldContentIndex )
886 : : {
887 : : OSL_ENSURE(pCNd, "SwHistoryChangeFlyAnchor: no ContentNode");
888 [ # # ]: 0 : if (pCNd)
889 : : {
890 [ # # ][ # # ]: 0 : aPos.nContent.Assign( pCNd, m_nOldContentIndex );
891 : : }
892 : : }
893 [ # # ]: 0 : aTmp.SetAnchor( &aPos );
894 : :
895 : : // so the Layout does not get confused
896 [ # # ][ # # ]: 0 : if ( !pCNd || !pCNd->getLayoutFrm( pDoc->GetCurrentLayout(), 0, 0, sal_False ) )
[ # # ][ # # ]
[ # # ]
897 : : {
898 [ # # ]: 0 : m_rFmt.DelFrms();
899 : : }
900 : :
901 [ # # ][ # # ]: 0 : m_rFmt.SetFmtAttr( aTmp );
[ # # ]
902 [ # # ]: 0 : }
903 : 0 : }
904 : :
905 : 0 : SwHistoryChangeFlyChain::SwHistoryChangeFlyChain( SwFlyFrmFmt& rFmt,
906 : : const SwFmtChain& rAttr )
907 : : : SwHistoryHint( HSTRY_CHGFLYCHAIN )
908 : 0 : , m_pPrevFmt( rAttr.GetPrev() )
909 : 0 : , m_pNextFmt( rAttr.GetNext() )
910 : 0 : , m_pFlyFmt( &rFmt )
911 : : {
912 : 0 : }
913 : :
914 : 0 : void SwHistoryChangeFlyChain::SetInDoc( SwDoc* pDoc, bool )
915 : : {
916 [ # # ]: 0 : if ( USHRT_MAX != pDoc->GetSpzFrmFmts()->GetPos( m_pFlyFmt ) )
917 : : {
918 [ # # ]: 0 : SwFmtChain aChain;
919 : :
920 [ # # ][ # # ]: 0 : if ( m_pPrevFmt &&
[ # # ]
921 [ # # ]: 0 : USHRT_MAX != pDoc->GetSpzFrmFmts()->GetPos( m_pPrevFmt ) )
922 : : {
923 [ # # ]: 0 : aChain.SetPrev( m_pPrevFmt );
924 [ # # ][ # # ]: 0 : SwFmtChain aTmp( m_pPrevFmt->GetChain() );
925 [ # # ]: 0 : aTmp.SetNext( m_pFlyFmt );
926 [ # # ][ # # ]: 0 : m_pPrevFmt->SetFmtAttr( aTmp );
927 : : }
928 : :
929 [ # # ][ # # ]: 0 : if ( m_pNextFmt &&
[ # # ]
930 [ # # ]: 0 : USHRT_MAX != pDoc->GetSpzFrmFmts()->GetPos( m_pNextFmt ) )
931 : : {
932 [ # # ]: 0 : aChain.SetNext( m_pNextFmt );
933 [ # # ][ # # ]: 0 : SwFmtChain aTmp( m_pNextFmt->GetChain() );
934 [ # # ]: 0 : aTmp.SetPrev( m_pFlyFmt );
935 [ # # ][ # # ]: 0 : m_pNextFmt->SetFmtAttr( aTmp );
936 : : }
937 : :
938 [ # # ][ # # ]: 0 : if ( aChain.GetNext() || aChain.GetPrev() )
[ # # ]
939 : : {
940 [ # # ]: 0 : m_pFlyFmt->SetFmtAttr( aChain );
941 [ # # ]: 0 : }
942 : : }
943 : 0 : }
944 : :
945 : : // -> #i27615#
946 : 0 : SwHistoryChangeCharFmt::SwHistoryChangeCharFmt(const SfxItemSet & rSet,
947 : : const String & sFmt)
948 : : : SwHistoryHint(HSTRY_CHGCHARFMT)
949 [ # # ][ # # ]: 0 : , m_OldSet(rSet), m_Fmt(sFmt)
950 : : {
951 : 0 : }
952 : :
953 : 0 : void SwHistoryChangeCharFmt::SetInDoc(SwDoc * pDoc, bool )
954 : : {
955 : 0 : SwCharFmt * pCharFmt = pDoc->FindCharFmtByName(m_Fmt);
956 : :
957 [ # # ]: 0 : if (pCharFmt)
958 : : {
959 : 0 : pCharFmt->SetFmtAttr(m_OldSet);
960 : : }
961 : 0 : }
962 : : // <- #i27615#
963 : :
964 : :
965 : 4774 : SwHistory::SwHistory( sal_uInt16 nInitSz )
966 : : : m_SwpHstry()
967 : 4774 : , m_nEndDiff( 0 )
968 : : {
969 [ + - ]: 4774 : m_SwpHstry.reserve( (sal_uInt8)nInitSz );
970 : 4774 : }
971 : :
972 : 4768 : SwHistory::~SwHistory()
973 : : {
974 [ + - ]: 4768 : Delete( 0 );
975 : 4768 : }
976 : :
977 : 2246 : void SwHistory::Add( const SfxPoolItem* pOldValue, const SfxPoolItem* pNewValue,
978 : : sal_uLong nNodeIdx )
979 : : {
980 : : OSL_ENSURE( !m_nEndDiff, "History was not deleted after REDO" );
981 : :
982 : 2246 : sal_uInt16 nWhich = pNewValue->Which();
983 [ + - ][ + - ]: 2246 : if( (nWhich >= POOLATTR_END) || (nWhich == RES_TXTATR_FIELD) )
984 : 2246 : return;
985 : :
986 : : // no default attribute?
987 : : SwHistoryHint * pHt;
988 [ + + ][ + - ]: 2246 : if ( pOldValue && pOldValue != GetDfltAttr( pOldValue->Which() ) )
[ + - ][ + + ]
989 : : {
990 [ + - ][ + - ]: 2226 : pHt = new SwHistorySetFmt( pOldValue, nNodeIdx );
991 : : }
992 : : else
993 : : {
994 [ + - ]: 20 : pHt = new SwHistoryResetFmt( pNewValue, nNodeIdx );
995 : : }
996 [ + - ]: 2246 : m_SwpHstry.push_back( pHt );
997 : : }
998 : :
999 : : // FIXME: refactor the following "Add" methods (DRY)?
1000 : 1194 : void SwHistory::Add( SwTxtAttr* pHint, sal_uLong nNodeIdx, bool bNewAttr )
1001 : : {
1002 : : OSL_ENSURE( !m_nEndDiff, "History was not deleted after REDO" );
1003 : :
1004 : : SwHistoryHint * pHt;
1005 [ + - ]: 1194 : sal_uInt16 nAttrWhich = pHint->Which();
1006 : :
1007 [ + + ]: 1194 : if( !bNewAttr )
1008 : : {
1009 [ + - + + : 534 : switch ( nAttrWhich )
+ + ]
1010 : : {
1011 : : case RES_TXTATR_FTN:
1012 : : pHt = new SwHistorySetFootnote(
1013 [ + - ][ + - ]: 26 : static_cast<SwTxtFtn*>(pHint), nNodeIdx );
1014 : 26 : break;
1015 : : case RES_TXTATR_FLYCNT:
1016 : : pHt = new SwHistoryTxtFlyCnt( static_cast<SwTxtFlyCnt*>(pHint)
1017 [ # # ][ # # ]: 0 : ->GetFlyCnt().GetFrmFmt() );
1018 : 0 : break;
1019 : : case RES_TXTATR_FIELD:
1020 : : pHt = new SwHistorySetTxtFld(
1021 [ + - ][ + - ]: 44 : static_cast<SwTxtFld*>(pHint), nNodeIdx );
1022 : 44 : break;
1023 : : case RES_TXTATR_TOXMARK:
1024 : : pHt = new SwHistorySetTOXMark(
1025 [ + - ][ + - ]: 26 : static_cast<SwTxtTOXMark*>(pHint), nNodeIdx );
1026 : 26 : break;
1027 : : case RES_TXTATR_REFMARK:
1028 : : pHt = new SwHistorySetRefMark(
1029 [ + - ][ + - ]: 24 : static_cast<SwTxtRefMark*>(pHint), nNodeIdx );
1030 : 24 : break;
1031 : : default:
1032 : : pHt = new SwHistorySetTxt(
1033 [ + - ][ + - ]: 534 : static_cast<SwTxtAttr*>(pHint), nNodeIdx );
1034 : : }
1035 : : }
1036 : : else
1037 : : {
1038 [ + - ]: 660 : pHt = new SwHistoryResetTxt( pHint->Which(), *pHint->GetStart(),
1039 [ + - ][ + - ]: 660 : *pHint->GetAnyEnd(), nNodeIdx );
1040 : : }
1041 [ + - ]: 1194 : m_SwpHstry.push_back( pHt );
1042 : 1194 : }
1043 : :
1044 : 62 : void SwHistory::Add( SwFmtColl* pColl, sal_uLong nNodeIdx, sal_uInt8 nWhichNd )
1045 : : {
1046 : : OSL_ENSURE( !m_nEndDiff, "History was not deleted after REDO" );
1047 : :
1048 : : SwHistoryHint * pHt =
1049 [ + - ]: 62 : new SwHistoryChangeFmtColl( pColl, nNodeIdx, nWhichNd );
1050 [ + - ]: 62 : m_SwpHstry.push_back( pHt );
1051 : 62 : }
1052 : :
1053 : 578 : void SwHistory::Add(const ::sw::mark::IMark& rBkmk, bool bSavePos, bool bSaveOtherPos)
1054 : : {
1055 : : OSL_ENSURE( !m_nEndDiff, "History was not deleted after REDO" );
1056 : :
1057 [ + - ][ + - ]: 578 : SwHistoryHint * pHt = new SwHistoryBookmark(rBkmk, bSavePos, bSaveOtherPos);
1058 [ + - ]: 578 : m_SwpHstry.push_back( pHt );
1059 : 578 : }
1060 : :
1061 : 0 : void SwHistory::Add( SwFrmFmt& rFmt )
1062 : : {
1063 [ # # ][ # # ]: 0 : SwHistoryHint * pHt = new SwHistoryChangeFlyAnchor( rFmt );
1064 [ # # ]: 0 : m_SwpHstry.push_back( pHt );
1065 : 0 : }
1066 : :
1067 : 0 : void SwHistory::Add( SwFlyFrmFmt& rFmt, sal_uInt16& rSetPos )
1068 : : {
1069 : : OSL_ENSURE( !m_nEndDiff, "History was not deleted after REDO" );
1070 : :
1071 : : SwHistoryHint * pHint;
1072 : 0 : const sal_uInt16 nWh = rFmt.Which();
1073 [ # # ][ # # ]: 0 : if( RES_FLYFRMFMT == nWh || RES_DRAWFRMFMT == nWh )
1074 : : {
1075 [ # # ][ # # ]: 0 : pHint = new SwHistoryTxtFlyCnt( &rFmt );
1076 [ # # ]: 0 : m_SwpHstry.push_back( pHint );
1077 : :
1078 : : const SwFmtChain* pChainItem;
1079 [ # # ]: 0 : if( SFX_ITEM_SET == rFmt.GetItemState( RES_CHAIN, sal_False,
1080 [ # # ]: 0 : (const SfxPoolItem**)&pChainItem ))
1081 : : {
1082 [ # # ][ # # ]: 0 : if( pChainItem->GetNext() || pChainItem->GetPrev() )
[ # # ]
1083 : : {
1084 : : SwHistoryHint * pHt =
1085 [ # # ]: 0 : new SwHistoryChangeFlyChain( rFmt, *pChainItem );
1086 [ # # ][ # # ]: 0 : m_SwpHstry.insert( m_SwpHstry.begin() + rSetPos++, pHt );
1087 [ # # ]: 0 : if ( pChainItem->GetNext() )
1088 : : {
1089 [ # # ][ # # ]: 0 : SwFmtChain aTmp( pChainItem->GetNext()->GetChain() );
1090 [ # # ]: 0 : aTmp.SetPrev( 0 );
1091 [ # # ][ # # ]: 0 : pChainItem->GetNext()->SetFmtAttr( aTmp );
1092 : : }
1093 [ # # ]: 0 : if ( pChainItem->GetPrev() )
1094 : : {
1095 [ # # ][ # # ]: 0 : SwFmtChain aTmp( pChainItem->GetPrev()->GetChain() );
1096 [ # # ]: 0 : aTmp.SetNext( 0 );
1097 [ # # ][ # # ]: 0 : pChainItem->GetPrev()->SetFmtAttr( aTmp );
1098 : : }
1099 : : }
1100 [ # # ]: 0 : rFmt.ResetFmtAttr( RES_CHAIN );
1101 : : }
1102 : : }
1103 : 0 : }
1104 : :
1105 : 4 : void SwHistory::Add( const SwTxtFtn& rFtn )
1106 : : {
1107 [ + - ][ + - ]: 4 : SwHistoryHint *pHt = new SwHistorySetFootnote( rFtn );
1108 [ + - ]: 4 : m_SwpHstry.push_back( pHt );
1109 : 4 : }
1110 : :
1111 : : // #i27615#
1112 : 0 : void SwHistory::Add(const SfxItemSet & rSet, const SwCharFmt & rFmt)
1113 : : {
1114 [ # # ][ # # ]: 0 : SwHistoryHint * pHt = new SwHistoryChangeCharFmt(rSet, rFmt.GetName());
1115 [ # # ]: 0 : m_SwpHstry.push_back( pHt );
1116 : 0 : }
1117 : :
1118 : 0 : bool SwHistory::Rollback( SwDoc* pDoc, sal_uInt16 nStart )
1119 : : {
1120 [ # # ]: 0 : if ( !Count() )
1121 : 0 : return false;
1122 : :
1123 : : SwHistoryHint * pHHt;
1124 : : sal_uInt16 i;
1125 [ # # ]: 0 : for ( i = Count(); i > nStart ; )
1126 : : {
1127 : 0 : pHHt = m_SwpHstry[ --i ];
1128 : 0 : pHHt->SetInDoc( pDoc, false );
1129 [ # # ]: 0 : delete pHHt;
1130 : : }
1131 [ # # ][ # # ]: 0 : m_SwpHstry.erase( m_SwpHstry.begin() + nStart, m_SwpHstry.end() );
1132 : 0 : m_nEndDiff = 0;
1133 : 0 : return true;
1134 : : }
1135 : :
1136 : 0 : bool SwHistory::TmpRollback( SwDoc* pDoc, sal_uInt16 nStart, bool bToFirst )
1137 : : {
1138 : 0 : sal_uInt16 nEnd = Count() - m_nEndDiff;
1139 [ # # ][ # # ]: 0 : if ( !Count() || !nEnd || nStart >= nEnd )
[ # # ][ # # ]
1140 : 0 : return false;
1141 : :
1142 : : SwHistoryHint * pHHt;
1143 [ # # ]: 0 : if ( bToFirst )
1144 : : {
1145 [ # # ]: 0 : for ( ; nEnd > nStart; ++m_nEndDiff )
1146 : : {
1147 : 0 : pHHt = m_SwpHstry[ --nEnd ];
1148 : 0 : pHHt->SetInDoc( pDoc, true );
1149 : : }
1150 : : }
1151 : : else
1152 : : {
1153 [ # # ]: 0 : for ( ; nStart < nEnd; ++m_nEndDiff, ++nStart )
1154 : : {
1155 : 0 : pHHt = m_SwpHstry[ nStart ];
1156 : 0 : pHHt->SetInDoc( pDoc, true );
1157 : : }
1158 : : }
1159 : 0 : return true;
1160 : : }
1161 : :
1162 : 4768 : void SwHistory::Delete( sal_uInt16 nStart )
1163 : : {
1164 [ + + ]: 12302 : for ( sal_uInt16 n = Count(); n > nStart; )
1165 : : {
1166 [ + - ]: 7534 : delete m_SwpHstry[ --n ];
1167 [ + - ][ + - ]: 7534 : m_SwpHstry.erase( m_SwpHstry.begin() + n );
1168 : : }
1169 : 4768 : m_nEndDiff = 0;
1170 : 4768 : }
1171 : :
1172 : 0 : sal_uInt16 SwHistory::SetTmpEnd( sal_uInt16 nNewTmpEnd )
1173 : : {
1174 : : OSL_ENSURE( nNewTmpEnd <= Count(), "SwHistory::SetTmpEnd: out of bounds" );
1175 : :
1176 : 0 : sal_uInt16 nOld = Count() - m_nEndDiff;
1177 : 0 : m_nEndDiff = Count() - nNewTmpEnd;
1178 : :
1179 : : // for every SwHistoryFlyCnt, call the Redo of its UndoObject.
1180 : : // this saves the formats of the flys!
1181 [ # # ]: 0 : for ( sal_uInt16 n = nOld; n < nNewTmpEnd; n++ )
1182 : : {
1183 [ # # ]: 0 : if ( HSTRY_FLYCNT == (*this)[ n ]->Which() )
1184 : : {
1185 : 0 : static_cast<SwHistoryTxtFlyCnt*>((*this)[ n ])
1186 : 0 : ->GetUDelLFmt()->RedoForRollback();
1187 : : }
1188 : : }
1189 : :
1190 : 0 : return nOld;
1191 : : }
1192 : :
1193 : 102 : void SwHistory::CopyFmtAttr( const SfxItemSet& rSet, sal_uLong nNodeIdx )
1194 : : {
1195 [ + - ]: 102 : if( rSet.Count() )
1196 : : {
1197 [ + - ]: 102 : SfxItemIter aIter( rSet );
1198 : 2124 : do {
1199 [ + - ]: 2226 : if( (SfxPoolItem*)-1 != aIter.GetCurItem() )
1200 : : {
1201 : 2226 : const SfxPoolItem* pNew = aIter.GetCurItem();
1202 [ + - ]: 2226 : Add( pNew, pNew, nNodeIdx );
1203 : : }
1204 [ + + ]: 2226 : if( aIter.IsAtEnd() )
1205 : 102 : break;
1206 [ + - ]: 2124 : aIter.NextItem();
1207 [ + - ]: 102 : } while( sal_True );
1208 : : }
1209 : 102 : }
1210 : :
1211 : 1124 : void SwHistory::CopyAttr( SwpHints* pHts, sal_uLong nNodeIdx,
1212 : : xub_StrLen nStart, xub_StrLen nEnd, bool bFields )
1213 : : {
1214 [ + + ]: 1124 : if( !pHts )
1215 : 1124 : return;
1216 : :
1217 : : // copy all attributes of the TextNode in the area from nStart to nEnd
1218 : : SwTxtAttr* pHt;
1219 : : xub_StrLen nAttrStt;
1220 : : const xub_StrLen * pEndIdx;
1221 [ + + ]: 360 : for( sal_uInt16 n = 0; n < pHts->Count(); n++ )
1222 : : {
1223 : : // nAttrStt must even be set when !pEndIdx
1224 : 246 : pHt = pHts->GetTextHint(n);
1225 : 246 : nAttrStt = *pHt->GetStart();
1226 [ - + ][ - + ]: 246 : if( 0 != ( pEndIdx = pHt->GetEnd() ) && nAttrStt > nEnd )
[ + + ]
1227 : 0 : break;
1228 : :
1229 : : // never copy Flys and Ftn !!
1230 : 246 : sal_Bool bNextAttr = sal_False;
1231 [ + - + ]: 246 : switch( pHt->Which() )
1232 : : {
1233 : : case RES_TXTATR_FIELD:
1234 : : // no fields, ... copy ??
1235 [ - + ]: 44 : if( !bFields )
1236 : 0 : bNextAttr = sal_True;
1237 : 44 : break;
1238 : : case RES_TXTATR_FLYCNT:
1239 : : case RES_TXTATR_FTN:
1240 : 0 : bNextAttr = sal_True;
1241 : 0 : break;
1242 : : }
1243 : :
1244 [ - + ]: 246 : if( bNextAttr )
1245 : 0 : continue;
1246 : :
1247 : : // save all attributes that are somehow in this area
1248 [ + - ]: 246 : if ( nStart <= nAttrStt )
1249 : : {
1250 [ + + ]: 246 : if ( nEnd > nAttrStt
1251 : : )
1252 : : {
1253 : 166 : Add( pHt, nNodeIdx, false );
1254 : : }
1255 : : }
1256 [ # # ][ # # ]: 0 : else if ( pEndIdx && nStart < *pEndIdx )
1257 : : {
1258 : 0 : Add( pHt, nNodeIdx, false );
1259 : : }
1260 : : }
1261 : : }
1262 : :
1263 : : // Class to register the history at a Node, Format, HintsArray, ...
1264 : 0 : SwRegHistory::SwRegHistory( SwHistory* pHst )
1265 : : : SwClient( 0 )
1266 : : , m_pHistory( pHst )
1267 [ # # ]: 0 : , m_nNodeIndex( ULONG_MAX )
1268 : : {
1269 [ # # ]: 0 : _MakeSetWhichIds();
1270 : 0 : }
1271 : :
1272 : 20974 : SwRegHistory::SwRegHistory( SwModify* pRegIn, const SwNode& rNd,
1273 : : SwHistory* pHst )
1274 : : : SwClient( pRegIn )
1275 : : , m_pHistory( pHst )
1276 [ + - ]: 20974 : , m_nNodeIndex( rNd.GetIndex() )
1277 : : {
1278 [ + - ]: 20974 : _MakeSetWhichIds();
1279 : 20974 : }
1280 : :
1281 : 1596 : SwRegHistory::SwRegHistory( const SwNode& rNd, SwHistory* pHst )
1282 : : : SwClient( 0 )
1283 : : , m_pHistory( pHst )
1284 [ + - ]: 1596 : , m_nNodeIndex( rNd.GetIndex() )
1285 : : {
1286 [ + - ]: 1596 : _MakeSetWhichIds();
1287 : 1596 : }
1288 : :
1289 : 21836 : void SwRegHistory::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
1290 : : {
1291 : : // #i114861#
1292 : : // Do not handle a "noop" modify
1293 : : // - e.g. <SwTxtNode::NumRuleChgd()> uses such a "noop" modify
1294 [ + + ][ + + ]: 21836 : if ( m_pHistory && ( pOld || pNew ) &&
[ + - ][ + - ]
1295 : : pOld != pNew )
1296 : : {
1297 [ + + ]: 3882 : if ( pNew->Which() < POOLATTR_END )
1298 : : {
1299 : 20 : m_pHistory->Add( pOld, pNew, m_nNodeIndex );
1300 : : }
1301 [ + + ]: 3862 : else if ( RES_ATTRSET_CHG == pNew->Which() )
1302 : : {
1303 : : SwHistoryHint* pNewHstr;
1304 : : const SfxItemSet& rSet =
1305 : 2674 : *static_cast<const SwAttrSetChg*>(pOld)->GetChgSet();
1306 [ - + ]: 2674 : if ( 1 < rSet.Count() )
1307 : : {
1308 : : pNewHstr =
1309 [ # # ][ # # ]: 0 : new SwHistorySetAttrSet( rSet, m_nNodeIndex, m_WhichIdSet );
1310 : : }
1311 : : else
1312 : : {
1313 [ + - ][ + - ]: 2674 : const SfxPoolItem* pItem = SfxItemIter( rSet ).FirstItem();
1314 [ + - ][ + + ]: 2674 : if ( m_WhichIdSet.count( pItem->Which() ) )
1315 : : {
1316 [ + - ][ + - ]: 922 : pNewHstr = new SwHistorySetFmt( pItem, m_nNodeIndex );
1317 : : }
1318 : : else
1319 : : {
1320 [ + - ]: 1752 : pNewHstr = new SwHistoryResetFmt( pItem, m_nNodeIndex );
1321 : : }
1322 : : }
1323 [ + - ]: 2674 : m_pHistory->m_SwpHstry.push_back( pNewHstr );
1324 : : }
1325 : : }
1326 : 21836 : }
1327 : :
1328 : 1002 : void SwRegHistory::AddHint( SwTxtAttr* pHt, const bool bNew )
1329 : : {
1330 : 1002 : m_pHistory->Add( pHt, m_nNodeIndex, bNew );
1331 : 1002 : }
1332 : :
1333 : 10923 : bool SwRegHistory::InsertItems( const SfxItemSet& rSet,
1334 : : xub_StrLen const nStart, xub_StrLen const nEnd, SetAttrMode const nFlags )
1335 : : {
1336 [ - + ]: 10923 : if( !rSet.Count() )
1337 : 0 : return false;
1338 : :
1339 : : SwTxtNode * const pTxtNode =
1340 [ - + ]: 10923 : dynamic_cast<SwTxtNode *>(const_cast<SwModify *>(GetRegisteredIn()));
1341 : :
1342 : : OSL_ENSURE(pTxtNode, "SwRegHistory not registered at text node?");
1343 [ - + ]: 10923 : if (!pTxtNode)
1344 : 0 : return false;
1345 : :
1346 [ + + ][ + + ]: 10923 : if ( pTxtNode->GetpSwpHints() && m_pHistory )
[ + + ]
1347 : : {
1348 : 516 : pTxtNode->GetpSwpHints()->Register( this );
1349 : : }
1350 : :
1351 : 10923 : const bool bInserted = pTxtNode->SetAttr( rSet, nStart, nEnd, nFlags );
1352 : :
1353 : : // Caution: The array can be deleted when inserting an attribute!
1354 : : // This can happen when the value that should be added first deletes
1355 : : // an existing attribute but does not need to be added itself because
1356 : : // the paragraph attributes are identical
1357 : : // ( -> bForgetAttr in SwpHints::Insert )
1358 [ + + ][ + + ]: 10923 : if ( pTxtNode->GetpSwpHints() && m_pHistory )
[ + + ]
1359 : : {
1360 : 722 : pTxtNode->GetpSwpHints()->DeRegister();
1361 : : }
1362 : :
1363 [ + + ][ + + ]: 10923 : if ( m_pHistory && bInserted )
1364 : : {
1365 : : SwHistoryHint* pNewHstr = new SwHistoryResetAttrSet( rSet,
1366 [ + - ][ + - ]: 790 : pTxtNode->GetIndex(), nStart, nEnd );
1367 : : // the NodeIndex might be moved!
1368 : :
1369 [ + - ]: 790 : m_pHistory->m_SwpHstry.push_back( pNewHstr );
1370 : : }
1371 : :
1372 : 10923 : return bInserted;
1373 : : }
1374 : :
1375 : 0 : void SwRegHistory::RegisterInModify( SwModify* pRegIn, const SwNode& rNd )
1376 : : {
1377 [ # # ][ # # ]: 0 : if ( m_pHistory && pRegIn )
1378 : : {
1379 : 0 : pRegIn->Add( this );
1380 : 0 : m_nNodeIndex = rNd.GetIndex();
1381 : 0 : _MakeSetWhichIds();
1382 : : }
1383 : : else
1384 : : {
1385 : 0 : m_WhichIdSet.clear();
1386 : : }
1387 : 0 : }
1388 : :
1389 : 22570 : void SwRegHistory::_MakeSetWhichIds()
1390 : : {
1391 [ + + ]: 27940 : if (!m_pHistory) return;
1392 : :
1393 : 5370 : m_WhichIdSet.clear();
1394 : :
1395 [ + + ]: 5370 : if( GetRegisteredIn() )
1396 : : {
1397 : 3774 : const SfxItemSet* pSet = 0;
1398 [ + - ]: 3774 : if( GetRegisteredIn()->ISA( SwCntntNode ) )
1399 : : {
1400 : : pSet = static_cast<SwCntntNode*>(
1401 : 3774 : const_cast<SwModify*>(GetRegisteredIn()))->GetpSwAttrSet();
1402 : : }
1403 [ # # ]: 0 : else if ( GetRegisteredIn()->ISA( SwFmt ) )
1404 : : {
1405 : : pSet = &static_cast<SwFmt*>(
1406 : 0 : const_cast<SwModify*>(GetRegisteredIn()))->GetAttrSet();
1407 : : }
1408 [ + + ][ + - ]: 3774 : if( pSet && pSet->Count() )
[ + + ]
1409 : : {
1410 [ + - ]: 3098 : SfxItemIter aIter( *pSet );
1411 : 3098 : sal_uInt16 nW = aIter.FirstItem()->Which();
1412 : 39238 : while( sal_True )
1413 : : {
1414 [ + - ]: 42336 : m_WhichIdSet.insert( nW );
1415 [ + + ]: 42336 : if( aIter.IsAtEnd() )
1416 : 3098 : break;
1417 [ + - ]: 39238 : nW = aIter.NextItem()->Which();
1418 [ + - ]: 3098 : }
1419 : : }
1420 : : }
1421 : : }
1422 : :
1423 : 4768 : SwpHstry::~SwpHstry()
1424 : : {
1425 [ + - ][ + - ]: 4768 : for(const_iterator it = begin(); it != end(); ++it)
[ - + ]
1426 [ # # ][ # # ]: 0 : delete *it;
1427 : 4768 : }
1428 : :
1429 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|