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 <hintids.hxx>
30 : : #include <rtl/logfile.hxx>
31 : : #include <svl/itemiter.hxx>
32 : : #include <sfx2/app.hxx>
33 : : #include <editeng/tstpitem.hxx>
34 : : #include <editeng/eeitem.hxx>
35 : : #include <editeng/langitem.hxx>
36 : : #include <editeng/lrspitem.hxx>
37 : : #include <editeng/brkitem.hxx>
38 : : #include <svl/whiter.hxx>
39 : : #include <svl/zforlist.hxx>
40 : : #include <comphelper/processfactory.hxx>
41 : : #include <unotools/misccfg.hxx>
42 : : #include <com/sun/star/i18n/WordType.hpp>
43 : : #include <fmtpdsc.hxx>
44 : : #include <fmthdft.hxx>
45 : : #include <fmtcntnt.hxx>
46 : : #include <frmatr.hxx>
47 : : #include <doc.hxx>
48 : : #include <IDocumentUndoRedo.hxx>
49 : : #include <rootfrm.hxx>
50 : : #include <pagefrm.hxx>
51 : : #include <hints.hxx> // for SwHyphenBug (in SetDefault)
52 : : #include <ndtxt.hxx>
53 : : #include <pam.hxx>
54 : : #include <UndoCore.hxx>
55 : : #include <UndoAttribute.hxx>
56 : : #include <ndgrf.hxx>
57 : : #include <pagedesc.hxx> // For special treatment in InsFrmFmt
58 : : #include <rolbck.hxx> // Undo-Attr
59 : : #include <mvsave.hxx> // serve: Recognize changes
60 : : #include <txatbase.hxx>
61 : : #include <swtable.hxx>
62 : : #include <swtblfmt.hxx>
63 : : #include <charfmt.hxx>
64 : : #include <docary.hxx>
65 : : #include <paratr.hxx>
66 : : #include <redline.hxx>
67 : : #include <reffld.hxx>
68 : : #include <txtinet.hxx>
69 : : #include <fmtinfmt.hxx>
70 : : #include <breakit.hxx>
71 : : #include <SwStyleNameMapper.hxx>
72 : : #include <fmtautofmt.hxx>
73 : : #include <istyleaccess.hxx>
74 : : #include <SwUndoFmt.hxx>
75 : : #include <docsh.hxx>
76 : :
77 : : using namespace ::com::sun::star::i18n;
78 : : using namespace ::com::sun::star::lang;
79 : : using namespace ::com::sun::star::uno;
80 : :
81 : : /*
82 : : * Internal functions
83 : : */
84 : :
85 : 2 : static void SetTxtFmtCollNext( SwTxtFmtColl* pTxtColl, const SwTxtFmtColl* pDel )
86 : : {
87 [ - + ]: 2 : if ( &pTxtColl->GetNextTxtFmtColl() == pDel )
88 : : {
89 : 0 : pTxtColl->SetNextTxtFmtColl( *pTxtColl );
90 : : }
91 : 2 : }
92 : :
93 : : /*
94 : : * Reset the text's hard formatting
95 : : */
96 : :
97 : : // Parameters for _Rst and lcl_SetTxtFmtColl
98 : : struct ParaRstFmt
99 : : {
100 : : SwFmtColl* pFmtColl;
101 : : SwHistory* pHistory;
102 : : const SwPosition *pSttNd, *pEndNd;
103 : : const SfxItemSet* pDelSet;
104 : : sal_uInt16 nWhich;
105 : : bool bReset;
106 : : bool bResetListAttrs; // #i62575#
107 : : bool bResetAll;
108 : : bool bInclRefToxMark;
109 : :
110 : : bool bKeepOutlineLevelAttr;
111 : :
112 : 24773 : ParaRstFmt( const SwPosition* pStt, const SwPosition* pEnd,
113 : : SwHistory* pHst, sal_uInt16 nWhch = 0, const SfxItemSet* pSet = 0 )
114 : : : pFmtColl(0),
115 : : pHistory(pHst),
116 : : pSttNd(pStt),
117 : : pEndNd(pEnd),
118 : : pDelSet(pSet),
119 : : nWhich(nWhch),
120 : : bReset( false ), // #i62675#
121 : : bResetListAttrs( false ),
122 : : bResetAll( true ),
123 : : bInclRefToxMark( false ),
124 : 24773 : bKeepOutlineLevelAttr( false )
125 : 24773 : {}
126 : :
127 : : ParaRstFmt( SwHistory* pHst )
128 : : : pFmtColl(0),
129 : : pHistory(pHst),
130 : : pSttNd(0),
131 : : pEndNd(0),
132 : : pDelSet(0),
133 : : nWhich(0),
134 : : bReset( false ),
135 : : bResetListAttrs( false ), // #i62675#
136 : : bResetAll( true ),
137 : : bInclRefToxMark( false ),
138 : : bKeepOutlineLevelAttr( false )
139 : : {}
140 : : };
141 : :
142 : : /* pArgs contains the document's ChrFmtTable
143 : : * Is need for selections at the beginning/end and with no SSelection.
144 : : */
145 : :
146 : 15129 : sal_Bool lcl_RstTxtAttr( const SwNodePtr& rpNd, void* pArgs )
147 : : {
148 : 15129 : ParaRstFmt* pPara = (ParaRstFmt*)pArgs;
149 : 15129 : SwTxtNode * pTxtNode = (SwTxtNode*)rpNd->GetTxtNode();
150 [ + + ][ + + ]: 15129 : if( pTxtNode && pTxtNode->GetpSwpHints() )
[ + + ]
151 : : {
152 [ + - ][ + - ]: 4693 : SwIndex aSt( pTxtNode, 0 );
153 [ + - ]: 4693 : sal_uInt16 nEnd = pTxtNode->Len();
154 : :
155 [ + - ]: 9227 : if( &pPara->pSttNd->nNode.GetNode() == pTxtNode &&
[ + + - + ]
[ - + ]
156 : 4534 : pPara->pSttNd->nContent.GetIndex() )
157 [ # # ]: 0 : aSt = pPara->pSttNd->nContent.GetIndex();
158 : :
159 [ + + ]: 4693 : if( &pPara->pEndNd->nNode.GetNode() == rpNd )
160 : 4483 : nEnd = pPara->pEndNd->nContent.GetIndex();
161 : :
162 [ + + ]: 4693 : if( pPara->pHistory )
163 : : {
164 : : // Save all attributes for the Undo.
165 [ + - ]: 466 : SwRegHistory aRHst( *pTxtNode, pPara->pHistory );
166 : 466 : pTxtNode->GetpSwpHints()->Register( &aRHst );
167 : 466 : pTxtNode->RstAttr( aSt, nEnd - aSt.GetIndex(), pPara->nWhich,
168 [ + - ]: 466 : pPara->pDelSet, pPara->bInclRefToxMark );
169 [ + - ]: 466 : if( pTxtNode->GetpSwpHints() )
170 [ + - ]: 466 : pTxtNode->GetpSwpHints()->DeRegister();
171 : : }
172 : : else
173 : 4227 : pTxtNode->RstAttr( aSt, nEnd - aSt.GetIndex(), pPara->nWhich,
174 [ + - ][ + - ]: 4693 : pPara->pDelSet, pPara->bInclRefToxMark );
175 : : }
176 : 15129 : return sal_True;
177 : : }
178 : :
179 : 15372 : sal_Bool lcl_RstAttr( const SwNodePtr& rpNd, void* pArgs )
180 : : {
181 : 15372 : ParaRstFmt* pPara = (ParaRstFmt*)pArgs;
182 : 15372 : SwCntntNode* pNode = (SwCntntNode*)rpNd->GetCntntNode();
183 [ + + ][ + + ]: 15372 : if( pNode && pNode->HasSwAttrSet() )
[ + - ]
184 : : {
185 : 3717 : const sal_Bool bLocked = pNode->IsModifyLocked();
186 : 3717 : pNode->LockModify();
187 : :
188 : 3717 : SwDoc* pDoc = pNode->GetDoc();
189 : :
190 : : // remove unused attribute RES_LR_SPACE
191 : : // add list attributes
192 : 3717 : SfxItemSet aSet( pDoc->GetAttrPool(),
193 : : RES_PAGEDESC, RES_BREAK,
194 : : RES_PARATR_NUMRULE, RES_PARATR_NUMRULE,
195 : : RES_PARATR_OUTLINELEVEL,RES_PARATR_OUTLINELEVEL,//#outline level,removed by zhaojianwei
196 : : RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END - 1,
197 [ + - ]: 3717 : 0 );
198 [ + - ]: 3717 : const SfxItemSet* pSet = pNode->GetpSwAttrSet();
199 : :
200 [ + - ]: 3717 : std::vector<sal_uInt16> aClearWhichIds;
201 : : // restoring all paragraph list attributes
202 : : {
203 [ + - ]: 3717 : SfxItemSet aListAttrSet( pDoc->GetAttrPool(), RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END - 1 );
204 [ + - ]: 3717 : aListAttrSet.Set( *pSet );
205 [ + + ]: 3717 : if ( aListAttrSet.Count() )
206 : : {
207 [ + - ]: 2300 : aSet.Put( aListAttrSet );
208 [ + - ]: 2300 : SfxItemIter aIter( aListAttrSet );
209 : 2300 : const SfxPoolItem* pItem = aIter.GetCurItem();
210 [ + + ]: 4600 : while( pItem )
211 : : {
212 [ + - ]: 2300 : aClearWhichIds.push_back( pItem->Which() );
213 [ + - ]: 2300 : pItem = aIter.NextItem();
214 [ + - ]: 2300 : }
215 [ + - ]: 3717 : }
216 : : }
217 : :
218 : : const SfxPoolItem* pItem;
219 : :
220 : : sal_uInt16 const aSavIds[ 4 ] = { RES_PAGEDESC, RES_BREAK, //->add by zhaojianwei
221 : : RES_PARATR_NUMRULE,
222 : 3717 : RES_PARATR_OUTLINELEVEL };
223 [ + + ]: 18585 : for( sal_uInt16 n = 0; n < 4; ++n ) //<-end,zhaojianwei
224 : : {
225 [ + - ][ + + ]: 14868 : if( SFX_ITEM_SET == pSet->GetItemState( aSavIds[ n ], sal_False, &pItem ))
226 : : {
227 : 637 : bool bSave = false;
228 [ + + + - : 637 : switch( aSavIds[ n ] )
- ]
229 : : {
230 : : case RES_PAGEDESC:
231 : 4 : bSave = 0 != ((SwFmtPageDesc*)pItem)->GetPageDesc();
232 : 4 : break;
233 : : case RES_BREAK:
234 : 6 : bSave = SVX_BREAK_NONE != ((SvxFmtBreakItem*)pItem)->GetBreak();
235 : 6 : break;
236 : : case RES_PARATR_NUMRULE:
237 : : {
238 : 627 : bSave = 0 != ((SwNumRuleItem*)pItem)->GetValue().Len();
239 : : }
240 : 627 : break;
241 : : case RES_PARATR_OUTLINELEVEL: //#outline level,add by zhaojianwei
242 : : {
243 [ # # ][ # # ]: 0 : bSave = pPara && pPara->bKeepOutlineLevelAttr;
244 : : }
245 : 0 : break; //<-end,zhaojianwei
246 : : }
247 [ + - ]: 637 : if( bSave )
248 : : {
249 [ + - ]: 637 : aSet.Put( *pItem );
250 [ + - ]: 637 : aClearWhichIds.push_back( aSavIds[n] );
251 : : }
252 : : }
253 : : }
254 : :
255 : : // do not clear items directly from item set and only clear to be kept
256 : : // attributes, if no deletion item set is found.
257 : : const bool bKeepAttributes =
258 [ + - ][ + + ]: 3717 : !pPara || !pPara->pDelSet || pPara->pDelSet->Count() == 0;
[ - + ]
259 [ + + ]: 3717 : if ( bKeepAttributes )
260 : : {
261 [ + - ]: 3621 : pNode->ResetAttr( aClearWhichIds );
262 : : }
263 : :
264 [ + - ]: 3717 : if( !bLocked )
265 : 3717 : pNode->UnlockModify();
266 : :
267 [ + - ]: 3717 : if( pPara )
268 : : {
269 [ + - ]: 3717 : SwRegHistory aRegH( pNode, *pNode, pPara->pHistory );
270 : :
271 [ + + ][ + - ]: 3717 : if( pPara->pDelSet && pPara->pDelSet->Count() )
[ + + ]
272 : : {
273 : : OSL_ENSURE( !bKeepAttributes,
274 : : "<lcl_RstAttr(..)> - certain attributes are kept, but not needed. -> please inform OD" );
275 [ + - ]: 96 : SfxItemIter aIter( *pPara->pDelSet );
276 : 96 : pItem = aIter.FirstItem();
277 : 480 : while( sal_True )
278 : : {
279 [ + + + + : 1728 : if ( ( pItem->Which() != RES_PAGEDESC &&
+ + ][ + - ]
[ + - ]
280 : 574 : pItem->Which() != RES_BREAK &&
281 : 572 : pItem->Which() != RES_PARATR_NUMRULE ) ||
282 [ + - ]: 6 : ( aSet.GetItemState( pItem->Which(), sal_False ) != SFX_ITEM_SET ) )
283 : : {
284 [ + - ]: 576 : pNode->ResetAttr( pItem->Which() );
285 : : }
286 [ + + ]: 576 : if( aIter.IsAtEnd() )
287 : 96 : break;
288 [ + - ]: 480 : pItem = aIter.NextItem();
289 [ + - ]: 96 : }
290 : : }
291 [ + - ]: 3621 : else if( pPara->bResetAll )
292 [ + - ]: 3621 : pNode->ResetAllAttr();
293 : : else
294 [ # # ][ + - ]: 3717 : pNode->ResetAttr( RES_PARATR_BEGIN, POOLATTR_END - 1 );
295 : : }
296 : : else
297 [ # # ]: 0 : pNode->ResetAllAttr();
298 : :
299 : : // only restore saved attributes, if needed
300 [ + + ][ + + ]: 3717 : if ( bKeepAttributes && aSet.Count() )
[ + + ]
301 : : {
302 : 2218 : pNode->LockModify();
303 : :
304 [ + - ]: 2218 : pNode->SetAttr( aSet );
305 : :
306 [ + - ]: 2218 : if( !bLocked )
307 : 2218 : pNode->UnlockModify();
308 [ + - ]: 3717 : }
309 : : }
310 : 15372 : return sal_True;
311 : : }
312 : :
313 : 0 : void SwDoc::RstTxtAttrs(const SwPaM &rRg, sal_Bool bInclRefToxMark )
314 : : {
315 : 0 : SwHistory* pHst = 0;
316 [ # # ]: 0 : SwDataChanged aTmp( rRg, 0 );
317 [ # # ][ # # ]: 0 : if (GetIDocumentUndoRedo().DoesUndo())
[ # # ]
318 : : {
319 [ # # ][ # # ]: 0 : SwUndoResetAttr* pUndo = new SwUndoResetAttr( rRg, RES_CHRFMT );
320 : 0 : pHst = &pUndo->GetHistory();
321 [ # # ][ # # ]: 0 : GetIDocumentUndoRedo().AppendUndo(pUndo);
322 : : }
323 [ # # ][ # # ]: 0 : const SwPosition *pStt = rRg.Start(), *pEnd = rRg.End();
324 : 0 : ParaRstFmt aPara( pStt, pEnd, pHst );
325 : 0 : aPara.bInclRefToxMark = ( bInclRefToxMark == sal_True );
326 [ # # ]: 0 : GetNodes().ForEach( pStt->nNode.GetIndex(), pEnd->nNode.GetIndex()+1,
327 [ # # ]: 0 : lcl_RstTxtAttr, &aPara );
328 [ # # ][ # # ]: 0 : SetModified();
329 : 0 : }
330 : :
331 : 1574 : void SwDoc::ResetAttrs( const SwPaM &rRg,
332 : : sal_Bool bTxtAttr,
333 : : const std::set<sal_uInt16> &rAttrs,
334 : : const bool bSendDataChangedEvents )
335 : : {
336 : 1574 : SwPaM* pPam = (SwPaM*)&rRg;
337 [ + + ][ + - ]: 1574 : if( !bTxtAttr && !rAttrs.empty() && RES_TXTATR_END > *(rAttrs.begin()) )
[ + - ][ - + ]
[ + + ]
[ - + # # ]
338 : 0 : bTxtAttr = sal_True;
339 : :
340 [ + + ]: 1574 : if( !rRg.HasMark() )
341 : : {
342 : 1568 : SwTxtNode* pTxtNd = rRg.GetPoint()->nNode.GetNode().GetTxtNode();
343 [ + - ]: 1568 : if( !pTxtNd )
344 : 1574 : return ;
345 : :
346 [ + - ][ + - ]: 1568 : pPam = new SwPaM( *rRg.GetPoint() );
347 : :
348 : 1568 : SwIndex& rSt = pPam->GetPoint()->nContent;
349 : 1568 : sal_uInt16 nMkPos, nPtPos = rSt.GetIndex();
350 : :
351 : : // Special case: if the Crsr is located within a URL attribute, we take over it's area
352 : : SwTxtAttr const*const pURLAttr(
353 [ + - ]: 1568 : pTxtNd->GetTxtAttrAt(rSt.GetIndex(), RES_TXTATR_INETFMT));
354 [ + + ][ + - ]: 1568 : if (pURLAttr && pURLAttr->GetINetFmt().GetValue().Len())
[ + + ]
355 : : {
356 : 2 : nMkPos = *pURLAttr->GetStart();
357 [ + - ]: 2 : nPtPos = *pURLAttr->GetEnd();
358 : : }
359 : : else
360 : : {
361 : 1566 : Boundary aBndry;
362 [ + - ][ + - ]: 1566 : if( pBreakIt->GetBreakIter().is() )
363 [ + - ][ + - ]: 3132 : aBndry = pBreakIt->GetBreakIter()->getWordBoundary(
364 : 1566 : pTxtNd->GetTxt(), nPtPos,
365 [ + - ][ + - ]: 1566 : pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos ) ),
366 : : WordType::ANY_WORD /*ANYWORD_IGNOREWHITESPACES*/,
367 [ + - ][ + - ]: 1566 : sal_True );
368 : :
369 [ - + ][ # # ]: 1566 : if( aBndry.startPos < nPtPos && nPtPos < aBndry.endPos )
370 : : {
371 : 0 : nMkPos = (xub_StrLen)aBndry.startPos;
372 : 0 : nPtPos = (xub_StrLen)aBndry.endPos;
373 : : }
374 : : else
375 : : {
376 : 1566 : nPtPos = nMkPos = rSt.GetIndex();
377 [ + + ]: 1566 : if( bTxtAttr )
378 [ + - ]: 1566 : pTxtNd->DontExpandFmt( rSt, sal_True );
379 : : }
380 : : }
381 : :
382 [ + - ]: 1568 : rSt = nMkPos;
383 [ + - ]: 1568 : pPam->SetMark();
384 [ + - ]: 1568 : pPam->GetPoint()->nContent = nPtPos;
385 : : }
386 : :
387 : : // #i96644#
388 : : // SwDataChanged aTmp( *pPam, 0 );
389 : 1574 : std::auto_ptr< SwDataChanged > pDataChanged;
390 [ + + ]: 1574 : if ( bSendDataChangedEvents )
391 : : {
392 [ + - ][ + - ]: 1484 : pDataChanged.reset( new SwDataChanged( *pPam, 0 ) );
393 : : }
394 : 1574 : SwHistory* pHst = 0;
395 [ + - ][ + - ]: 1574 : if (GetIDocumentUndoRedo().DoesUndo())
[ + + ]
396 : : {
397 : : SwUndoResetAttr* pUndo = new SwUndoResetAttr( rRg,
398 [ + - ][ + - ]: 10 : static_cast<sal_uInt16>(bTxtAttr ? RES_CONDTXTFMTCOLL : RES_TXTFMTCOLL ));
[ + - ]
399 [ + - ]: 10 : if( !rAttrs.empty() )
400 : : {
401 [ + - ]: 10 : pUndo->SetAttrs( rAttrs );
402 : : }
403 : 10 : pHst = &pUndo->GetHistory();
404 [ + - ][ + - ]: 10 : GetIDocumentUndoRedo().AppendUndo(pUndo);
405 : : }
406 : :
407 [ + - ][ + - ]: 1574 : const SwPosition *pStt = pPam->Start(), *pEnd = pPam->End();
408 : 1574 : ParaRstFmt aPara( pStt, pEnd, pHst );
409 : :
410 : : // mst: not including META here; it seems attrs with CH_TXTATR are omitted
411 : : sal_uInt16 aResetableSetRange[] = {
412 : : RES_FRMATR_BEGIN, RES_FRMATR_END-1,
413 : : RES_CHRATR_BEGIN, RES_CHRATR_END-1,
414 : : RES_PARATR_BEGIN, RES_PARATR_END-1,
415 : : RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1,
416 : : RES_TXTATR_INETFMT, RES_TXTATR_INETFMT,
417 : : RES_TXTATR_CHARFMT, RES_TXTATR_CHARFMT,
418 : : RES_TXTATR_CJK_RUBY, RES_TXTATR_CJK_RUBY,
419 : : RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER,
420 : : RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
421 : : 0
422 : 1574 : };
423 : :
424 [ + - ]: 1574 : SfxItemSet aDelSet( GetAttrPool(), aResetableSetRange );
425 [ + + ]: 1574 : if( !rAttrs.empty() )
426 : : {
427 [ + - ][ + - ]: 756 : for( std::set<sal_uInt16>::const_reverse_iterator it = rAttrs.rbegin(); it != rAttrs.rend(); ++it )
[ + + ]
428 : : {
429 [ + - ][ + - ]: 656 : if( POOLATTR_END > *it )
430 [ + - ][ + - ]: 656 : aDelSet.Put( *GetDfltAttr( *it ));
[ + - ]
431 : : }
432 [ + - ]: 100 : if( aDelSet.Count() )
433 : 100 : aPara.pDelSet = &aDelSet;
434 : : }
435 : :
436 : 1574 : sal_Bool bAdd = sal_True;
437 [ + - ]: 1574 : SwNodeIndex aTmpStt( pStt->nNode );
438 [ + - ]: 1574 : SwNodeIndex aTmpEnd( pEnd->nNode );
439 [ + + ]: 1574 : if( pStt->nContent.GetIndex() ) // just one part
440 : : {
441 : : // set up a later, and all CharFmtAttr -> TxtFmtAttr
442 : 2 : SwTxtNode* pTNd = aTmpStt.GetNode().GetTxtNode();
443 [ + - ][ - + ]: 2 : if( pTNd && pTNd->HasSwAttrSet() && pTNd->GetpSwAttrSet()->Count() )
[ # # ][ # # ]
[ - + ][ + - ]
444 : : {
445 [ # # ]: 0 : if (pHst)
446 : : {
447 [ # # ]: 0 : SwRegHistory history(pTNd, *pTNd, pHst);
448 [ # # ][ # # ]: 0 : pTNd->FmtToTxtAttr(pTNd);
449 : : }
450 : : else
451 : : {
452 [ # # ]: 0 : pTNd->FmtToTxtAttr(pTNd);
453 : : }
454 : : }
455 : :
456 [ + - ]: 2 : aTmpStt++;
457 : : }
458 [ + - ][ + - ]: 1574 : if( pEnd->nContent.GetIndex() == pEnd->nNode.GetNode().GetCntntNode()->Len() )
459 : : // set up a later, and all CharFmtAttr -> TxtFmtAttr
460 [ + - ]: 1574 : aTmpEnd++, bAdd = sal_False;
461 [ # # ][ # # ]: 0 : else if( pStt->nNode != pEnd->nNode || !pStt->nContent.GetIndex() )
[ # # ]
462 : : {
463 : 0 : SwTxtNode* pTNd = aTmpEnd.GetNode().GetTxtNode();
464 [ # # ][ # # ]: 0 : if( pTNd && pTNd->HasSwAttrSet() && pTNd->GetpSwAttrSet()->Count() )
[ # # ][ # # ]
[ # # ][ # # ]
465 : : {
466 [ # # ]: 0 : if (pHst)
467 : : {
468 [ # # ]: 0 : SwRegHistory history(pTNd, *pTNd, pHst);
469 [ # # ][ # # ]: 0 : pTNd->FmtToTxtAttr(pTNd);
470 : : }
471 : : else
472 : : {
473 [ # # ]: 0 : pTNd->FmtToTxtAttr(pTNd);
474 : : }
475 : : }
476 : : }
477 : :
478 [ + + ]: 1574 : if( aTmpStt < aTmpEnd )
479 [ + - ][ + - ]: 1572 : GetNodes().ForEach( pStt->nNode, aTmpEnd, lcl_RstAttr, &aPara );
480 [ + - ]: 2 : else if( !rRg.HasMark() )
481 : : {
482 : 2 : aPara.bResetAll = false ;
483 [ + - ]: 2 : ::lcl_RstAttr( &pStt->nNode.GetNode(), &aPara );
484 : 2 : aPara.bResetAll = true ;
485 : : }
486 : :
487 [ + + ]: 1574 : if( bTxtAttr )
488 : : {
489 [ - + ]: 1484 : if( bAdd )
490 [ # # ]: 0 : aTmpEnd++;
491 [ + - ][ + - ]: 1484 : GetNodes().ForEach( pStt->nNode, aTmpEnd, lcl_RstTxtAttr, &aPara );
492 : : }
493 : :
494 [ + + ]: 1574 : if( pPam != &rRg )
495 [ + - ][ + - ]: 1568 : delete pPam;
496 : :
497 [ + - ][ + - ]: 1574 : SetModified();
[ + - ][ + - ]
[ + - ]
498 : : }
499 : :
500 : : #define DELETECHARSETS if ( bDelete ) { delete pCharSet; delete pOtherSet; }
501 : :
502 : : // Insert Hints according to content types;
503 : : // Is used in SwDoc::Insert(..., SwFmtHint &rHt)
504 : :
505 : : static bool
506 : 27209 : lcl_InsAttr(SwDoc *const pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet,
507 : : const SetAttrMode nFlags, SwUndoAttr *const pUndo)
508 : : {
509 : : // Divide the Sets (for selections in Nodes)
510 : 27209 : const SfxItemSet* pCharSet = 0;
511 : 27209 : const SfxItemSet* pOtherSet = 0;
512 : 27209 : bool bDelete = false;
513 : 27209 : bool bCharAttr = false;
514 : 27209 : bool bOtherAttr = false;
515 : :
516 : : // Check, if we can work with rChgSet or if we have to create additional SfxItemSets
517 [ + + ]: 27209 : if ( 1 == rChgSet.Count() )
518 : : {
519 [ + - ]: 24585 : SfxItemIter aIter( rChgSet );
520 : 24585 : const SfxPoolItem* pItem = aIter.FirstItem();
521 [ + - ]: 24585 : if (!IsInvalidItem(pItem))
522 : : {
523 : 24585 : const sal_uInt16 nWhich = pItem->Which();
524 : :
525 [ + + ][ + + ]: 24585 : if ( isCHRATR(nWhich) ||
[ + + ][ + + ]
[ + + ][ + + ]
526 : : (RES_TXTATR_CHARFMT == nWhich) ||
527 : : (RES_TXTATR_INETFMT == nWhich) ||
528 : : (RES_TXTATR_AUTOFMT == nWhich) ||
529 : : (RES_TXTATR_UNKNOWN_CONTAINER == nWhich) )
530 : : {
531 : 17443 : pCharSet = &rChgSet;
532 : 17443 : bCharAttr = true;
533 : : }
534 : :
535 [ + + + - : 107579 : if ( isPARATR(nWhich)
+ + + - -
+ ][ + + ]
536 : 21765 : || isPARATR_LIST(nWhich)
537 : 21765 : || isFRMATR(nWhich)
538 : 19732 : || isGRFATR(nWhich)
539 : 19732 : || isUNKNOWNATR(nWhich) )
540 : : {
541 : 4853 : pOtherSet = &rChgSet;
542 : 4853 : bOtherAttr = true;
543 : : }
544 [ + - ]: 24585 : }
545 : : }
546 : :
547 : : // Build new itemset if either
548 : : // - rChgSet.Count() > 1 or
549 : : // - The attribute in rChgSet does not belong to one of the above categories
550 [ + + ][ + + ]: 27209 : if ( !bCharAttr && !bOtherAttr )
551 : : {
552 : 4913 : SfxItemSet* pTmpCharItemSet = new SfxItemSet( pDoc->GetAttrPool(),
553 : : RES_CHRATR_BEGIN, RES_CHRATR_END-1,
554 : : RES_TXTATR_AUTOFMT, RES_TXTATR_AUTOFMT,
555 : : RES_TXTATR_INETFMT, RES_TXTATR_INETFMT,
556 : : RES_TXTATR_CHARFMT, RES_TXTATR_CHARFMT,
557 : : RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER,
558 [ + - ][ + - ]: 4913 : 0 );
559 : :
560 : 4913 : SfxItemSet* pTmpOtherItemSet = new SfxItemSet( pDoc->GetAttrPool(),
561 : : RES_PARATR_BEGIN, RES_PARATR_END-1,
562 : : RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1,
563 : : RES_FRMATR_BEGIN, RES_FRMATR_END-1,
564 : : RES_GRFATR_BEGIN, RES_GRFATR_END-1,
565 : : RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
566 [ + - ][ + - ]: 4913 : 0 );
567 : :
568 [ + - ]: 4913 : pTmpCharItemSet->Put( rChgSet );
569 [ + - ]: 4913 : pTmpOtherItemSet->Put( rChgSet );
570 : :
571 : 4913 : pCharSet = pTmpCharItemSet;
572 : 4913 : pOtherSet = pTmpOtherItemSet;
573 : :
574 : 4913 : bDelete = true;
575 : : }
576 : :
577 [ + + ]: 27209 : SwHistory* pHistory = pUndo ? &pUndo->GetHistory() : 0;
578 : 27209 : bool bRet = false;
579 [ + - ][ + - ]: 27209 : const SwPosition *pStt = rRg.Start(), *pEnd = rRg.End();
580 : 27209 : SwCntntNode* pNode = pStt->nNode.GetNode().GetCntntNode();
581 : :
582 [ + - ][ + - ]: 27209 : if( pNode && pNode->IsTxtNode() )
[ + - ]
583 : : {
584 : : // #i27615#
585 [ - + ]: 27209 : if (rRg.IsInFrontOfLabel())
586 : : {
587 : 0 : SwTxtNode * pTxtNd = pNode->GetTxtNode();
588 [ # # ]: 0 : SwNumRule * pNumRule = pTxtNd->GetNumRule();
589 : :
590 : : // make code robust:
591 [ # # ]: 0 : if ( !pNumRule )
592 : : {
593 : : OSL_FAIL( "<InsAttr(..)> - PaM in front of label, but text node has no numbering rule set. This is a serious defect, please inform OD." );
594 [ # # ][ # # ]: 0 : DELETECHARSETS
[ # # ][ # # ]
[ # # ]
595 : 0 : return false;
596 : : }
597 : :
598 [ # # ][ # # ]: 0 : SwNumFmt aNumFmt = pNumRule->Get(static_cast<sal_uInt16>(pTxtNd->GetActualListLevel()));
[ # # ]
599 : : SwCharFmt * pCharFmt =
600 [ # # ][ # # ]: 0 : pDoc->FindCharFmtByName(aNumFmt.GetCharFmtName());
601 : :
602 [ # # ]: 0 : if (pCharFmt)
603 : : {
604 [ # # ]: 0 : if (pHistory)
605 [ # # ]: 0 : pHistory->Add(pCharFmt->GetAttrSet(), *pCharFmt);
606 : :
607 [ # # ]: 0 : if ( pCharSet )
608 [ # # ]: 0 : pCharFmt->SetFmtAttr(*pCharSet);
609 : : }
610 : :
611 [ # # ][ # # ]: 0 : DELETECHARSETS
[ # # ][ # # ]
[ # # ]
612 [ # # ]: 0 : return true;
613 : : }
614 : :
615 : 27209 : const SwIndex& rSt = pStt->nContent;
616 : :
617 : : // Attributes without an end do not have a range
618 [ + + ][ + + ]: 27209 : if ( !bCharAttr && !bOtherAttr )
619 : : {
620 : 4913 : SfxItemSet aTxtSet( pDoc->GetAttrPool(),
621 [ + - ]: 4913 : RES_TXTATR_NOEND_BEGIN, RES_TXTATR_NOEND_END-1 );
622 [ + - ]: 4913 : aTxtSet.Put( rChgSet );
623 [ + + ]: 4913 : if( aTxtSet.Count() )
624 : : {
625 [ + - ]: 1609 : SwRegHistory history( pNode, *pNode, pHistory );
626 : : bRet = history.InsertItems(
627 [ + - ][ - + ]: 1609 : aTxtSet, rSt.GetIndex(), rSt.GetIndex(), nFlags ) || bRet;
[ # # ]
628 : :
629 [ + - ][ + - ]: 3218 : if (bRet && (pDoc->IsRedlineOn() || (!pDoc->IsIgnoreRedline()
[ + - ][ + - ]
[ + - - + ]
[ - + ]
630 [ + - ]: 1609 : && !pDoc->GetRedlineTbl().empty())))
631 : : {
632 : 0 : SwPaM aPam( pStt->nNode, pStt->nContent.GetIndex()-1,
633 [ # # ]: 0 : pStt->nNode, pStt->nContent.GetIndex() );
634 : :
635 [ # # ]: 0 : if( pUndo )
636 [ # # ]: 0 : pUndo->SaveRedlineData( aPam, sal_True );
637 : :
638 [ # # ][ # # ]: 0 : if( pDoc->IsRedlineOn() )
639 [ # # ][ # # ]: 0 : pDoc->AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true);
[ # # ]
640 : : else
641 [ # # ][ # # ]: 0 : pDoc->SplitRedline( aPam );
642 [ + - ]: 1609 : }
643 [ + - ]: 4913 : }
644 : : }
645 : :
646 : : // TextAttributes with an end never expand their range
647 [ + + ][ + + ]: 27209 : if ( !bCharAttr && !bOtherAttr )
648 : : {
649 : : // CharFmt and URL attributes are treated seperately!
650 : : // TEST_TEMP ToDo: AutoFmt!
651 : 4913 : SfxItemSet aTxtSet( pDoc->GetAttrPool(),
652 : : RES_TXTATR_REFMARK, RES_TXTATR_TOXMARK,
653 : : RES_TXTATR_META, RES_TXTATR_METAFIELD,
654 : : RES_TXTATR_CJK_RUBY, RES_TXTATR_CJK_RUBY,
655 [ + - ]: 4913 : 0 );
656 : :
657 [ + - ]: 4913 : aTxtSet.Put( rChgSet );
658 [ + + ]: 4913 : if( aTxtSet.Count() )
659 : : {
660 : 680 : sal_uInt16 nInsCnt = rSt.GetIndex();
661 : 680 : sal_uInt16 nEnd = pStt->nNode == pEnd->nNode
662 : 680 : ? pEnd->nContent.GetIndex()
663 [ # # ][ + - ]: 680 : : pNode->Len();
664 [ + - ]: 680 : SwRegHistory history( pNode, *pNode, pHistory );
665 [ + - ]: 680 : bRet = history.InsertItems( aTxtSet, nInsCnt, nEnd, nFlags )
666 [ + + ][ - + ]: 680 : || bRet;
667 : :
668 [ + + ][ + - ]: 1356 : if (bRet && (pDoc->IsRedlineOn() || (!pDoc->IsIgnoreRedline()
[ + - ][ + - ]
[ + - - + ]
[ - + ]
669 [ + - ]: 676 : && !pDoc->GetRedlineTbl().empty())))
670 : : {
671 : : // Was text content inserted? (RefMark/TOXMarks without an end)
672 : 0 : sal_Bool bTxtIns = nInsCnt != rSt.GetIndex();
673 : : // Was content inserted or set over the selection?
674 : : SwPaM aPam( pStt->nNode, bTxtIns ? nInsCnt + 1 : nEnd,
675 [ # # ][ # # ]: 0 : pStt->nNode, nInsCnt );
676 [ # # ]: 0 : if( pUndo )
677 [ # # ]: 0 : pUndo->SaveRedlineData( aPam, bTxtIns );
678 : :
679 [ # # ][ # # ]: 0 : if( pDoc->IsRedlineOn() )
680 : : pDoc->AppendRedline( new SwRedline( bTxtIns
681 [ # # ][ # # ]: 0 : ? nsRedlineType_t::REDLINE_INSERT : nsRedlineType_t::REDLINE_FORMAT, aPam ), true);
[ # # ][ # # ]
682 [ # # ]: 0 : else if( bTxtIns )
683 [ # # ][ # # ]: 0 : pDoc->SplitRedline( aPam );
684 [ + - ]: 680 : }
685 [ + - ]: 4913 : }
686 : : }
687 : : }
688 : :
689 : : // We always have to set the auto flag for PageDescs that are set at the Node!
690 [ + + ][ + + ]: 27209 : if( pOtherSet && pOtherSet->Count() )
[ + + ]
691 : : {
692 : : SwTableNode* pTblNd;
693 : : const SwFmtPageDesc* pDesc;
694 [ + + ]: 4853 : if( SFX_ITEM_SET == pOtherSet->GetItemState( RES_PAGEDESC,
695 [ + - ]: 4853 : sal_False, (const SfxPoolItem**)&pDesc ))
696 : : {
697 [ + - ]: 595 : if( pNode )
698 : : {
699 : : // Set auto flag. Only in the template it's without auto!
700 [ + - ]: 595 : SwFmtPageDesc aNew( *pDesc );
701 : : // 38479: AutoFlag is now being set in the WrtShell
702 : : // aNew.SetAuto();
703 : :
704 : : // Tables now also know line breaks
705 [ + + ][ + - ]: 595 : if( 0 == (nFlags & nsSetAttrMode::SETATTR_APICALL) &&
[ - + ][ - + ]
706 : 90 : 0 != ( pTblNd = pNode->FindTableNode() ) )
707 : : {
708 : 0 : SwTableNode* pCurTblNd = pTblNd;
709 [ # # ][ # # ]: 0 : while ( 0 != ( pCurTblNd = pCurTblNd->StartOfSectionNode()->FindTableNode() ) )
710 : 0 : pTblNd = pCurTblNd;
711 : :
712 : : // set the table format
713 : 0 : SwFrmFmt* pFmt = pTblNd->GetTable().GetFrmFmt();
714 [ # # ]: 0 : SwRegHistory aRegH( pFmt, *pTblNd, pHistory );
715 [ # # ]: 0 : pFmt->SetFmtAttr( aNew );
716 [ # # ]: 0 : bRet = true;
717 : : }
718 : : else
719 : : {
720 [ + - ]: 595 : SwRegHistory aRegH( pNode, *pNode, pHistory );
721 [ + - ][ - + ]: 595 : bRet = pNode->SetAttr( aNew ) || bRet;
[ # # ][ + - ]
722 [ + - ]: 595 : }
723 : : }
724 : :
725 : : // bOtherAttr = true means that pOtherSet == rChgSet. In this case
726 : : // we know, that there is only one attribute in pOtherSet. We cannot
727 : : // perform the following operations, instead we return:
728 [ + - ]: 595 : if ( bOtherAttr )
729 : 595 : return bRet;
730 : :
731 [ # # ]: 0 : const_cast<SfxItemSet*>(pOtherSet)->ClearItem( RES_PAGEDESC );
732 [ # # ]: 0 : if( !pOtherSet->Count() )
733 : : {
734 [ # # ][ # # ]: 0 : DELETECHARSETS
[ # # ][ # # ]
[ # # ]
735 : 0 : return bRet;
736 : : }
737 : : }
738 : :
739 : : // Tables now also know line breaks
740 : : const SvxFmtBreakItem* pBreak;
741 [ + - ][ + + ]: 4528 : if( pNode && 0 == (nFlags & nsSetAttrMode::SETATTR_APICALL) &&
[ + - ][ + + ]
[ - + ][ - + ]
742 : 1146 : 0 != (pTblNd = pNode->FindTableNode() ) &&
743 : : SFX_ITEM_SET == pOtherSet->GetItemState( RES_BREAK,
744 [ + - ]: 270 : sal_False, (const SfxPoolItem**)&pBreak ) )
745 : : {
746 : 0 : SwTableNode* pCurTblNd = pTblNd;
747 [ # # ][ # # ]: 0 : while ( 0 != ( pCurTblNd = pCurTblNd->StartOfSectionNode()->FindTableNode() ) )
748 : 0 : pTblNd = pCurTblNd;
749 : :
750 : : // set the table format
751 : 0 : SwFrmFmt* pFmt = pTblNd->GetTable().GetFrmFmt();
752 [ # # ]: 0 : SwRegHistory aRegH( pFmt, *pTblNd, pHistory );
753 [ # # ]: 0 : pFmt->SetFmtAttr( *pBreak );
754 : 0 : bRet = true;
755 : :
756 : : // bOtherAttr = true means that pOtherSet == rChgSet. In this case
757 : : // we know, that there is only one attribute in pOtherSet. We cannot
758 : : // perform the following operations, instead we return:
759 [ # # ]: 0 : if ( bOtherAttr )
760 : 0 : return bRet;
761 : :
762 [ # # ]: 0 : const_cast<SfxItemSet*>(pOtherSet)->ClearItem( RES_BREAK );
763 [ # # ]: 0 : if( !pOtherSet->Count() )
764 : : {
765 [ # # ][ # # ]: 0 : DELETECHARSETS
[ # # ][ # # ]
[ # # ]
766 : 0 : return bRet;
767 [ # # ][ # # ]: 0 : }
768 : : }
769 : :
770 : : {
771 : : // If we have a PoolNumRule, create it if needed
772 : : const SwNumRuleItem* pRule;
773 : : sal_uInt16 nPoolId;
774 [ + + ]: 4390 : if( SFX_ITEM_SET == pOtherSet->GetItemState( RES_PARATR_NUMRULE,
[ - + # # ]
[ # # ][ - + ]
775 [ + - ]: 4258 : sal_False, (const SfxPoolItem**)&pRule ) &&
776 [ + - ]: 132 : !pDoc->FindNumRulePtr( pRule->GetValue() ) &&
777 : 0 : USHRT_MAX != (nPoolId = SwStyleNameMapper::GetPoolIdFromUIName ( pRule->GetValue(),
778 : : nsSwGetPoolIdFromName::GET_POOLID_NUMRULE )) )
779 [ # # ]: 4853 : pDoc->GetNumRuleFromPool( nPoolId );
780 : : }
781 : :
782 : : }
783 : :
784 [ + + ]: 26614 : if( !rRg.HasMark() ) // no range
785 : : {
786 [ - + ]: 8307 : if( !pNode )
787 : : {
788 [ # # ][ # # ]: 0 : DELETECHARSETS
[ # # ][ # # ]
[ # # ]
789 : 0 : return bRet;
790 : : }
791 : :
792 [ + - ][ + + ]: 8307 : if( pNode->IsTxtNode() && pCharSet && pCharSet->Count() )
[ + + ][ + + ]
793 : : {
794 : 2277 : SwTxtNode* pTxtNd = static_cast<SwTxtNode*>(pNode);
795 : 2277 : const SwIndex& rSt = pStt->nContent;
796 : 2277 : sal_uInt16 nMkPos, nPtPos = rSt.GetIndex();
797 : 2277 : const String& rStr = pTxtNd->GetTxt();
798 : :
799 : : // Special case: if the Crsr is located within a URL attribute, we take over it's area
800 : : SwTxtAttr const*const pURLAttr(
801 [ + - ]: 2277 : pTxtNd->GetTxtAttrAt(rSt.GetIndex(), RES_TXTATR_INETFMT));
802 [ + + ][ + - ]: 2277 : if (pURLAttr && pURLAttr->GetINetFmt().GetValue().Len())
[ + + ]
803 : : {
804 : 2 : nMkPos = *pURLAttr->GetStart();
805 [ + - ]: 2 : nPtPos = *pURLAttr->GetEnd();
806 : : }
807 : : else
808 : : {
809 : 2275 : Boundary aBndry;
810 [ + - ][ + - ]: 2275 : if( pBreakIt->GetBreakIter().is() )
811 [ + - ][ + - ]: 4550 : aBndry = pBreakIt->GetBreakIter()->getWordBoundary(
812 : 2275 : pTxtNd->GetTxt(), nPtPos,
813 [ + - ][ + - ]: 2275 : pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos ) ),
814 : : WordType::ANY_WORD /*ANYWORD_IGNOREWHITESPACES*/,
815 [ + - ][ + - ]: 2275 : sal_True );
816 : :
817 [ - + ][ # # ]: 2275 : if( aBndry.startPos < nPtPos && nPtPos < aBndry.endPos )
818 : : {
819 : 0 : nMkPos = (xub_StrLen)aBndry.startPos;
820 : 0 : nPtPos = (xub_StrLen)aBndry.endPos;
821 : : }
822 : : else
823 : 2275 : nPtPos = nMkPos = rSt.GetIndex();
824 : : }
825 : :
826 : : // Remove the overriding attributes from the SwpHintsArray,
827 : : // if the selection spans across the whole paragraph.
828 : : // These attributes are inserted as FormatAttributes and
829 : : // never override the TextAttributes!
830 [ + - + + ]: 4574 : if( !(nFlags & nsSetAttrMode::SETATTR_DONTREPLACE ) &&
[ + + + + ]
[ + + ]
831 : 2297 : pTxtNd->HasHints() && !nMkPos && nPtPos == rStr.Len() )
832 : : {
833 [ + - ][ + - ]: 2 : SwIndex aSt( pTxtNd );
834 [ + - ]: 2 : if( pHistory )
835 : : {
836 : : // Save all attributes for the Undo.
837 [ + - ]: 2 : SwRegHistory aRHst( *pTxtNd, pHistory );
838 : 2 : pTxtNd->GetpSwpHints()->Register( &aRHst );
839 [ + - ]: 2 : pTxtNd->RstAttr( aSt, nPtPos, 0, pCharSet );
840 [ + - ]: 2 : if( pTxtNd->GetpSwpHints() )
841 [ + - ]: 2 : pTxtNd->GetpSwpHints()->DeRegister();
842 : : }
843 : : else
844 [ # # ][ + - ]: 2 : pTxtNd->RstAttr( aSt, nPtPos, 0, pCharSet );
845 : : }
846 : :
847 : : // the SwRegHistory inserts the attribute into the TxtNode!
848 [ + - ]: 2277 : SwRegHistory history( pNode, *pNode, pHistory );
849 [ + - ]: 2277 : bRet = history.InsertItems( *pCharSet, nMkPos, nPtPos, nFlags )
850 [ + + ][ - + ]: 2277 : || bRet;
851 : :
852 [ + - ][ - + ]: 2277 : if( pDoc->IsRedlineOn() )
853 : : {
854 [ # # ]: 0 : SwPaM aPam( *pNode, nMkPos, *pNode, nPtPos );
855 : :
856 [ # # ]: 0 : if( pUndo )
857 [ # # ]: 0 : pUndo->SaveRedlineData( aPam, sal_False );
858 [ # # ][ # # ]: 0 : pDoc->AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_FORMAT, aPam ), true);
[ # # ][ # # ]
859 [ + - ]: 2277 : }
860 : : }
861 [ + + ][ + + ]: 8307 : if( pOtherSet && pOtherSet->Count() )
[ + + ]
862 : : {
863 [ + - ]: 2739 : SwRegHistory aRegH( pNode, *pNode, pHistory );
864 [ + - ][ + + ]: 2739 : bRet = pNode->SetAttr( *pOtherSet ) || bRet;
[ - + ][ + - ]
865 : : }
866 : :
867 [ + + ][ + - ]: 8307 : DELETECHARSETS
[ + - ][ + - ]
[ + - ]
868 : 8307 : return bRet;
869 : : }
870 : :
871 [ + - ][ - + ]: 18307 : if( pDoc->IsRedlineOn() && pCharSet && pCharSet->Count() )
[ # # ][ # # ]
[ - + ]
872 : : {
873 [ # # ]: 0 : if( pUndo )
874 [ # # ]: 0 : pUndo->SaveRedlineData( rRg, sal_False );
875 [ # # ][ # # ]: 0 : pDoc->AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_FORMAT, rRg ), true);
[ # # ]
876 : : }
877 : :
878 : : /* now if range */
879 : 18307 : sal_uLong nNodes = 0;
880 : :
881 [ + - ][ + - ]: 18307 : SwNodeIndex aSt( pDoc->GetNodes() );
882 [ + - ][ + - ]: 18307 : SwNodeIndex aEnd( pDoc->GetNodes() );
883 [ + - ]: 18307 : SwIndex aCntEnd( pEnd->nContent );
884 : :
885 [ + - ]: 18307 : if( pNode )
886 : : {
887 [ + - ]: 18307 : sal_uInt16 nLen = pNode->Len();
888 [ + + ]: 18307 : if( pStt->nNode != pEnd->nNode )
889 [ + - ][ + - ]: 1371 : aCntEnd.Assign( pNode, nLen );
890 : :
891 [ + + ][ + + ]: 18307 : if( pStt->nContent.GetIndex() != 0 || aCntEnd.GetIndex() != nLen )
[ + + ]
892 : : {
893 : : // the SwRegHistory inserts the attribute into the TxtNode!
894 [ + - ][ + + ]: 6453 : if( pNode->IsTxtNode() && pCharSet && pCharSet->Count() )
[ + + ][ + + ]
895 : : {
896 [ + - ]: 6039 : SwRegHistory history( pNode, *pNode, pHistory );
897 : : bRet = history.InsertItems(*pCharSet,
898 [ + - ]: 6039 : pStt->nContent.GetIndex(), aCntEnd.GetIndex(), nFlags)
899 [ - + ][ # # ]: 6039 : || bRet;
[ + - ]
900 : : }
901 : :
902 [ + + ][ + + ]: 6453 : if( pOtherSet && pOtherSet->Count() )
[ + + ]
903 : : {
904 [ + - ]: 72 : SwRegHistory aRegH( pNode, *pNode, pHistory );
905 [ + - ][ + + ]: 72 : bRet = pNode->SetAttr( *pOtherSet ) || bRet;
[ - + ][ + - ]
906 : : }
907 : :
908 : : // Only selection in a Node.
909 [ + + ]: 6453 : if( pStt->nNode == pEnd->nNode )
910 : : {
911 [ + + ][ + - ]: 6177 : DELETECHARSETS
[ + - ][ + - ]
[ + - ]
912 : 6177 : return bRet;
913 : : }
914 : 276 : ++nNodes;
915 [ + - ]: 276 : aSt.Assign( pStt->nNode.GetNode(), +1 );
916 : : }
917 : : else
918 [ + - ]: 11854 : aSt = pStt->nNode;
919 [ + - ]: 12130 : aCntEnd = pEnd->nContent; // aEnd was changed!
920 : : }
921 : : else
922 [ # # ]: 0 : aSt.Assign( pStt->nNode.GetNode(), +1 );
923 : :
924 : : // aSt points to the first full Node now
925 : :
926 : : /*
927 : : * The selection spans more than one Node.
928 : : */
929 [ + + ]: 12130 : if( pStt->nNode < pEnd->nNode )
930 : : {
931 : 1371 : pNode = pEnd->nNode.GetNode().GetCntntNode();
932 [ + - ]: 1371 : if(pNode)
933 : : {
934 [ + - ]: 1371 : sal_uInt16 nLen = pNode->Len();
935 [ + + ]: 1371 : if( aCntEnd.GetIndex() != nLen )
936 : : {
937 : : // the SwRegHistory inserts the attribute into the TxtNode!
938 [ + - ][ + - ]: 318 : if( pNode->IsTxtNode() && pCharSet && pCharSet->Count() )
[ + - ][ + - ]
939 : : {
940 [ + - ]: 318 : SwRegHistory history( pNode, *pNode, pHistory );
941 : : history.InsertItems(*pCharSet,
942 [ + - ][ + - ]: 318 : 0, aCntEnd.GetIndex(), nFlags);
943 : : }
944 : :
945 [ - + ][ # # ]: 318 : if( pOtherSet && pOtherSet->Count() )
[ - + ]
946 : : {
947 [ # # ]: 0 : SwRegHistory aRegH( pNode, *pNode, pHistory );
948 [ # # ][ # # ]: 0 : pNode->SetAttr( *pOtherSet );
949 : : }
950 : :
951 : 318 : ++nNodes;
952 [ + - ]: 318 : aEnd = pEnd->nNode;
953 : : }
954 : : else
955 [ + - ]: 1053 : aEnd.Assign( pEnd->nNode.GetNode(), +1 );
956 : : }
957 : : else
958 [ # # ]: 0 : aEnd = pEnd->nNode;
959 : : }
960 : : else
961 [ + - ]: 10759 : aEnd.Assign( pEnd->nNode.GetNode(), +1 );
962 : :
963 : : // aEnd points BEHIND the last full node now
964 : :
965 : : /* Edit the fully selected Nodes. */
966 : : // Reset all attributes from the set!
967 [ + + ][ + + ]: 12130 : if( pCharSet && pCharSet->Count() && !( nsSetAttrMode::SETATTR_DONTREPLACE & nFlags ) )
[ + - ][ + + ]
968 : : {
969 : :
970 : 9403 : ParaRstFmt aPara( pStt, pEnd, pHistory, 0, pCharSet );
971 [ + - ][ + - ]: 9403 : pDoc->GetNodes().ForEach( aSt, aEnd, lcl_RstTxtAttr, &aPara );
972 : : }
973 : :
974 : : sal_Bool bCreateSwpHints = pCharSet && (
975 [ + - ]: 10683 : SFX_ITEM_SET == pCharSet->GetItemState( RES_TXTATR_CHARFMT, sal_False ) ||
976 [ + + ][ + + ]: 22813 : SFX_ITEM_SET == pCharSet->GetItemState( RES_TXTATR_INETFMT, sal_False ) );
[ + - ][ + + ]
977 : :
978 [ + - ][ + + ]: 28538 : for(; aSt < aEnd; aSt++ )
979 : : {
980 : 16408 : pNode = aSt.GetNode().GetCntntNode();
981 [ + + ]: 16408 : if( !pNode )
982 : 60 : continue;
983 : :
984 : 16348 : SwTxtNode* pTNd = pNode->GetTxtNode();
985 [ + + ]: 16348 : if( pHistory )
986 : : {
987 [ + - ]: 2928 : SwRegHistory aRegH( pNode, *pNode, pHistory );
988 : : SwpHints *pSwpHints;
989 : :
990 [ + - ][ + + ]: 2928 : if( pTNd && pCharSet && pCharSet->Count() )
[ + + ][ + + ]
991 : : {
992 : : pSwpHints = bCreateSwpHints ? &pTNd->GetOrCreateSwpHints()
993 [ + + ][ + - ]: 2374 : : pTNd->GetpSwpHints();
994 [ + + ]: 2374 : if( pSwpHints )
995 : 474 : pSwpHints->Register( &aRegH );
996 : :
997 [ + - ]: 2374 : pTNd->SetAttr( *pCharSet, 0, pTNd->GetTxt().Len(), nFlags );
998 [ + + ]: 2374 : if( pSwpHints )
999 : 474 : pSwpHints->DeRegister();
1000 : : }
1001 [ + + ][ + + ]: 2928 : if( pOtherSet && pOtherSet->Count() )
[ + + ]
1002 [ + - ][ + - ]: 2928 : pNode->SetAttr( *pOtherSet );
1003 : : }
1004 : : else
1005 : : {
1006 [ + - ][ + + ]: 13420 : if( pTNd && pCharSet && pCharSet->Count() )
[ + + ][ + + ]
1007 [ + - ]: 11211 : pTNd->SetAttr( *pCharSet, 0, pTNd->GetTxt().Len(), nFlags );
1008 [ + + ][ + + ]: 13420 : if( pOtherSet && pOtherSet->Count() )
[ + + ]
1009 [ + - ]: 1171 : pNode->SetAttr( *pOtherSet );
1010 : : }
1011 : 16348 : ++nNodes;
1012 : : }
1013 : :
1014 [ + + ][ + - ]: 12130 : DELETECHARSETS
[ + - ][ + - ]
[ + - ]
1015 [ - + ][ # # ]: 27209 : return (nNodes != 0) || bRet;
[ + - ][ + - ]
[ + - ]
1016 : : }
1017 : :
1018 : :
1019 : 8138 : bool SwDoc::InsertPoolItem( const SwPaM &rRg, const SfxPoolItem &rHt,
1020 : : const SetAttrMode nFlags )
1021 : : {
1022 [ + - ]: 8138 : SwDataChanged aTmp( rRg, 0 );
1023 : 8138 : SwUndoAttr* pUndoAttr = 0;
1024 [ + - ][ + - ]: 8138 : if (GetIDocumentUndoRedo().DoesUndo())
[ + + ]
1025 : : {
1026 [ + - ][ + - ]: 382 : GetIDocumentUndoRedo().ClearRedo();
1027 [ + - ][ + - ]: 382 : pUndoAttr = new SwUndoAttr( rRg, rHt, nFlags );
1028 : : }
1029 : :
1030 [ + - ]: 8138 : SfxItemSet aSet( GetAttrPool(), rHt.Which(), rHt.Which() );
1031 [ + - ]: 8138 : aSet.Put( rHt );
1032 [ + - ]: 8138 : bool bRet = lcl_InsAttr( this, rRg, aSet, nFlags, pUndoAttr );
1033 : :
1034 [ + - ][ + - ]: 8138 : if (GetIDocumentUndoRedo().DoesUndo())
[ + + ]
1035 : : {
1036 [ + - ][ + - ]: 382 : GetIDocumentUndoRedo().AppendUndo( pUndoAttr );
1037 : : }
1038 : :
1039 [ + + ]: 8138 : if( bRet )
1040 [ + - ]: 8074 : SetModified();
1041 [ + - ][ + - ]: 8138 : return bRet;
1042 : : }
1043 : :
1044 : 19071 : bool SwDoc::InsertItemSet ( const SwPaM &rRg, const SfxItemSet &rSet,
1045 : : const SetAttrMode nFlags )
1046 : : {
1047 [ + - ]: 19071 : SwDataChanged aTmp( rRg, 0 );
1048 : 19071 : SwUndoAttr* pUndoAttr = 0;
1049 [ + - ][ + - ]: 19071 : if (GetIDocumentUndoRedo().DoesUndo())
[ + + ]
1050 : : {
1051 [ + - ][ + - ]: 3154 : GetIDocumentUndoRedo().ClearRedo();
1052 [ + - ][ + - ]: 3154 : pUndoAttr = new SwUndoAttr( rRg, rSet, nFlags );
1053 : : }
1054 : :
1055 [ + - ]: 19071 : bool bRet = lcl_InsAttr( this, rRg, rSet, nFlags, pUndoAttr );
1056 : :
1057 [ + - ][ + - ]: 19071 : if (GetIDocumentUndoRedo().DoesUndo())
[ + + ]
1058 : : {
1059 [ + - ][ + - ]: 3154 : GetIDocumentUndoRedo().AppendUndo( pUndoAttr );
1060 : : }
1061 : :
1062 [ + + ]: 19071 : if( bRet )
1063 [ + - ]: 16607 : SetModified();
1064 [ + - ]: 19071 : return bRet;
1065 : : }
1066 : :
1067 : :
1068 : : // Set the attribute according to the stated format. If Undo is enabled, the old values is
1069 : : // added to the Undo history.
1070 : 582 : void SwDoc::SetAttr( const SfxPoolItem& rAttr, SwFmt& rFmt )
1071 : : {
1072 [ + - ]: 582 : SfxItemSet aSet( GetAttrPool(), rAttr.Which(), rAttr.Which() );
1073 [ + - ]: 582 : aSet.Put( rAttr );
1074 [ + - ][ + - ]: 582 : SetAttr( aSet, rFmt );
1075 : 582 : }
1076 : :
1077 : :
1078 : : // Set the attribute according to the stated format. If Undo is enabled, the old values is
1079 : : // added to the Undo history.
1080 : 4266 : void SwDoc::SetAttr( const SfxItemSet& rSet, SwFmt& rFmt )
1081 : : {
1082 [ + + ]: 4266 : if (GetIDocumentUndoRedo().DoesUndo())
1083 : : {
1084 [ + - ]: 94 : SwUndoFmtAttrHelper aTmp( rFmt );
1085 [ + - ]: 94 : rFmt.SetFmtAttr( rSet );
1086 [ + - ]: 94 : if ( aTmp.GetUndo() )
1087 : : {
1088 [ + - ][ + - ]: 94 : GetIDocumentUndoRedo().AppendUndo( aTmp.ReleaseUndo() );
1089 : : }
1090 : : else
1091 : : {
1092 [ # # ][ # # ]: 0 : GetIDocumentUndoRedo().ClearRedo();
1093 [ + - ]: 94 : }
1094 : : }
1095 : : else
1096 : : {
1097 : 4172 : rFmt.SetFmtAttr( rSet );
1098 : : }
1099 : 4266 : SetModified();
1100 : 4266 : }
1101 : :
1102 : 0 : void SwDoc::ResetAttrAtFormat( const sal_uInt16 nWhichId,
1103 : : SwFmt& rChangedFormat )
1104 : : {
1105 : 0 : SwUndo *const pUndo = (GetIDocumentUndoRedo().DoesUndo())
1106 [ # # ]: 0 : ? new SwUndoFmtResetAttr( rChangedFormat, nWhichId )
1107 [ # # ]: 0 : : 0;
1108 : :
1109 : 0 : const sal_Bool bAttrReset = rChangedFormat.ResetFmtAttr( nWhichId );
1110 : :
1111 [ # # ]: 0 : if ( bAttrReset )
1112 : : {
1113 [ # # ]: 0 : if ( pUndo )
1114 : : {
1115 : 0 : GetIDocumentUndoRedo().AppendUndo( pUndo );
1116 : : }
1117 : :
1118 : 0 : SetModified();
1119 : : }
1120 : : else
1121 [ # # ]: 0 : delete pUndo;
1122 : 0 : }
1123 : :
1124 : 3987 : int lcl_SetNewDefTabStops( SwTwips nOldWidth, SwTwips nNewWidth,
1125 : : SvxTabStopItem& rChgTabStop )
1126 : : {
1127 : : // Set the default values of all TabStops to the new value.
1128 : : // Attention: we always work with the PoolAttribut here, so that
1129 : : // we don't calculate the same value on the same TabStop (pooled!) for all sets.
1130 : : // We send a FmtChg to modify.
1131 : :
1132 : 3987 : sal_uInt16 nOldCnt = rChgTabStop.Count();
1133 [ + + ][ + - ]: 3987 : if( !nOldCnt || nOldWidth == nNewWidth )
1134 : 51 : return sal_False;
1135 : :
1136 : : // Find the default's beginning
1137 : : sal_uInt16 n;
1138 [ + + ]: 7872 : for( n = nOldCnt; n ; --n )
1139 [ - + ]: 3936 : if( SVX_TAB_ADJUST_DEFAULT != rChgTabStop[n - 1].GetAdjustment() )
1140 : 0 : break;
1141 : 3936 : ++n;
1142 [ - + ]: 3936 : if( n < nOldCnt ) // delete the DefTabStops
1143 : 0 : rChgTabStop.Remove( n, nOldCnt - n );
1144 : 3987 : return sal_True;
1145 : : }
1146 : :
1147 : : // Set the attribute as new default attribute in this document.
1148 : : // If Undi is enabled, the old value is added to the Undo history.
1149 : 19918 : void SwDoc::SetDefault( const SfxPoolItem& rAttr )
1150 : : {
1151 [ + - ]: 19918 : SfxItemSet aSet( GetAttrPool(), rAttr.Which(), rAttr.Which() );
1152 [ + - ]: 19918 : aSet.Put( rAttr );
1153 [ + - ][ + - ]: 19918 : SetDefault( aSet );
1154 : 19918 : }
1155 : :
1156 : 21411 : void SwDoc::SetDefault( const SfxItemSet& rSet )
1157 : : {
1158 [ + - ]: 21411 : if( !rSet.Count() )
1159 : 21411 : return;
1160 : :
1161 [ + - ]: 21411 : SwModify aCallMod( 0 );
1162 [ + - ]: 21411 : SwAttrSet aOld( GetAttrPool(), rSet.GetRanges() ),
1163 [ + - ]: 21411 : aNew( GetAttrPool(), rSet.GetRanges() );
1164 [ + - ]: 21411 : SfxItemIter aIter( rSet );
1165 : : sal_uInt16 nWhich;
1166 : 21411 : const SfxPoolItem* pItem = aIter.GetCurItem();
1167 [ + - ]: 21411 : SfxItemPool* pSdrPool = GetAttrPool().GetSecondaryPool();
1168 : 7418 : while( sal_True )
1169 : : {
1170 : 28829 : sal_Bool bCheckSdrDflt = sal_False;
1171 : 28829 : nWhich = pItem->Which();
1172 [ + - ][ + - ]: 28829 : aOld.Put( GetAttrPool().GetDefaultItem( nWhich ) );
1173 [ + - ]: 28829 : GetAttrPool().SetPoolDefaultItem( *pItem );
1174 [ + - ][ + - ]: 28829 : aNew.Put( GetAttrPool().GetDefaultItem( nWhich ) );
1175 : :
1176 [ + + ][ + + ]: 28829 : if (isCHRATR(nWhich) || isTXTATR(nWhich))
[ + + ]
1177 : : {
1178 [ + - ]: 19917 : aCallMod.Add( pDfltTxtFmtColl );
1179 [ + - ]: 19917 : aCallMod.Add( pDfltCharFmt );
1180 : 19917 : bCheckSdrDflt = 0 != pSdrPool;
1181 : : }
1182 [ + + - + ]: 12381 : else if ( isPARATR(nWhich) ||
[ + + ]
1183 : 3469 : isPARATR_LIST(nWhich) )
1184 : : {
1185 [ + - ]: 5443 : aCallMod.Add( pDfltTxtFmtColl );
1186 : 5443 : bCheckSdrDflt = 0 != pSdrPool;
1187 : : }
1188 [ - + ]: 3469 : else if (isGRFATR(nWhich))
1189 : : {
1190 [ # # ]: 0 : aCallMod.Add( pDfltGrfFmtColl );
1191 : : }
1192 [ + - ]: 3469 : else if (isFRMATR(nWhich))
1193 : : {
1194 [ + - ]: 3469 : aCallMod.Add( pDfltGrfFmtColl );
1195 [ + - ]: 3469 : aCallMod.Add( pDfltTxtFmtColl );
1196 [ + - ]: 3469 : aCallMod.Add( pDfltFrmFmt );
1197 : : }
1198 [ # # ]: 0 : else if (isBOXATR(nWhich))
1199 : : {
1200 [ # # ]: 0 : aCallMod.Add( pDfltFrmFmt );
1201 : : }
1202 : :
1203 : : // also copy the defaults
1204 [ + + ]: 28829 : if( bCheckSdrDflt )
1205 : : {
1206 : : sal_uInt16 nEdtWhich, nSlotId;
1207 [ + - ][ + - ]: 5722 : if( 0 != (nSlotId = GetAttrPool().GetSlotId( nWhich ) ) &&
[ + + ][ + - ]
[ + - ][ + + ]
[ + + ]
1208 : : nSlotId != nWhich &&
1209 : 4425 : 0 != (nEdtWhich = pSdrPool->GetWhich( nSlotId )) &&
1210 : : nSlotId != nEdtWhich )
1211 : : {
1212 [ + - ]: 2876 : SfxPoolItem* pCpy = pItem->Clone();
1213 : 2876 : pCpy->SetWhich( nEdtWhich );
1214 [ + - ]: 2876 : pSdrPool->SetPoolDefaultItem( *pCpy );
1215 [ + - ][ + - ]: 2876 : delete pCpy;
1216 : : }
1217 : : }
1218 : :
1219 [ + + ]: 28829 : if( aIter.IsAtEnd() )
1220 : 21411 : break;
1221 [ + - ]: 7418 : pItem = aIter.NextItem();
1222 : : }
1223 : :
1224 [ + - ][ + - ]: 21411 : if( aNew.Count() && aCallMod.GetDepends() )
[ + - ]
1225 : : {
1226 [ + - ][ + - ]: 21411 : if (GetIDocumentUndoRedo().DoesUndo())
[ + + ]
1227 : : {
1228 [ + - ][ + - ]: 2 : GetIDocumentUndoRedo().AppendUndo( new SwUndoDefaultAttr( aOld ) );
[ + - ][ + - ]
1229 : : }
1230 : :
1231 : : const SfxPoolItem* pTmpItem;
1232 [ + + + - ]: 23409 : if( ( SFX_ITEM_SET ==
[ + + ]
1233 [ + - ]: 21411 : aNew.GetItemState( RES_PARATR_TABSTOP, sal_False, &pTmpItem ) ) &&
1234 : 1998 : ((SvxTabStopItem*)pTmpItem)->Count() )
1235 : : {
1236 : : // Set the default values of all TabStops to the new value.
1237 : : // Attention: we always work with the PoolAttribut here, so that
1238 : : // we don't calculate the same value on the same TabStop (pooled!) for all sets.
1239 : : // We send a FmtChg to modify.
1240 [ + - ]: 1998 : SwTwips nNewWidth = (*(SvxTabStopItem*)pTmpItem)[ 0 ].GetTabPos(),
1241 [ + - ][ + - ]: 1998 : nOldWidth = ((SvxTabStopItem&)aOld.Get(RES_PARATR_TABSTOP))[ 0 ].GetTabPos();
1242 : :
1243 : 1998 : int bChg = sal_False;
1244 [ + - ]: 1998 : sal_uInt32 nMaxItems = GetAttrPool().GetItemCount2( RES_PARATR_TABSTOP );
1245 [ + + ]: 5994 : for( sal_uInt32 n = 0; n < nMaxItems; ++n )
1246 [ + - ][ + + ]: 3996 : if( 0 != (pTmpItem = GetAttrPool().GetItem2( RES_PARATR_TABSTOP, n ) ))
1247 : : bChg |= lcl_SetNewDefTabStops( nOldWidth, nNewWidth,
1248 [ + - ]: 3987 : *(SvxTabStopItem*)pTmpItem );
1249 : :
1250 [ + - ]: 1998 : aNew.ClearItem( RES_PARATR_TABSTOP );
1251 [ + - ]: 1998 : aOld.ClearItem( RES_PARATR_TABSTOP );
1252 [ + + ]: 1998 : if( bChg )
1253 : : {
1254 [ + - ]: 1968 : SwFmtChg aChgFmt( pDfltCharFmt );
1255 : : // notify the frames
1256 [ + - ][ + - ]: 21411 : aCallMod.ModifyNotification( &aChgFmt, &aChgFmt );
1257 : : }
1258 : : }
1259 : : }
1260 : :
1261 [ + + ][ + - ]: 21411 : if( aNew.Count() && aCallMod.GetDepends() )
[ + + ]
1262 : : {
1263 [ + - ]: 20893 : SwAttrSetChg aChgOld( aOld, aOld );
1264 [ + - ]: 20893 : SwAttrSetChg aChgNew( aNew, aNew );
1265 [ + - ][ + - ]: 20893 : aCallMod.ModifyNotification( &aChgOld, &aChgNew ); // all changed are sent
[ + - ]
1266 : : }
1267 : :
1268 : : // remove the default formats from the object again
1269 : : SwClient* pDep;
1270 [ + + ]: 65219 : while( 0 != ( pDep = (SwClient*)aCallMod.GetDepends()) )
1271 [ + - ]: 43808 : aCallMod.Remove( pDep );
1272 : :
1273 [ + - ][ + - ]: 21411 : SetModified();
[ + - ][ + - ]
[ + - ]
1274 : : }
1275 : :
1276 : : // Get the default attribute in this document
1277 : 43455 : const SfxPoolItem& SwDoc::GetDefault( sal_uInt16 nFmtHint ) const
1278 : : {
1279 : 43455 : return GetAttrPool().GetDefaultItem( nFmtHint );
1280 : : }
1281 : :
1282 : : /*
1283 : : * Delete the formats
1284 : : */
1285 : 10 : void SwDoc::DelCharFmt(sal_uInt16 nFmt, sal_Bool bBroadcast)
1286 : : {
1287 : 10 : SwCharFmt * pDel = (*pCharFmtTbl)[nFmt];
1288 : :
1289 [ - + ]: 10 : if (bBroadcast)
1290 : 0 : BroadcastStyleOperation(pDel->GetName(), SFX_STYLE_FAMILY_CHAR,
1291 [ # # ]: 0 : SFX_STYLESHEET_ERASED);
1292 : :
1293 [ + + ]: 10 : if (GetIDocumentUndoRedo().DoesUndo())
1294 : : {
1295 : : SwUndo * pUndo =
1296 [ + - ]: 2 : new SwUndoCharFmtDelete(pDel, this);
1297 : :
1298 : 2 : GetIDocumentUndoRedo().AppendUndo(pUndo);
1299 : : }
1300 : :
1301 [ + - ]: 10 : delete (*pCharFmtTbl)[nFmt];
1302 [ + - ][ + - ]: 10 : pCharFmtTbl->erase(pCharFmtTbl->begin() + nFmt);
1303 : :
1304 : 10 : SetModified();
1305 : 10 : }
1306 : :
1307 : 2 : void SwDoc::DelCharFmt( SwCharFmt *pFmt, sal_Bool bBroadcast )
1308 : : {
1309 : 2 : sal_uInt16 nFmt = pCharFmtTbl->GetPos( pFmt );
1310 : : OSL_ENSURE( USHRT_MAX != nFmt, "Fmt not found," );
1311 : 2 : DelCharFmt( nFmt, bBroadcast );
1312 : 2 : }
1313 : :
1314 : 2145 : void SwDoc::DelFrmFmt( SwFrmFmt *pFmt, sal_Bool bBroadcast )
1315 : : {
1316 [ + - ][ - + ]: 2145 : if( pFmt->ISA( SwTableBoxFmt ) || pFmt->ISA( SwTableLineFmt ))
[ - + ]
1317 : : {
1318 : : OSL_ENSURE( !this, "Format is not in the DocArray any more, "
1319 : : "so it can be deleted with delete" );
1320 [ # # ]: 0 : delete pFmt;
1321 : : }
1322 : : else
1323 : : {
1324 : :
1325 : : // The format has to be in the one or the other, we'll see in which one.
1326 [ + - ]: 2145 : SwFrmFmts::iterator it = std::find( pFrmFmtTbl->begin(), pFrmFmtTbl->end(), pFmt );
1327 [ + - ][ + + ]: 2145 : if ( it != pFrmFmtTbl->end() )
1328 : : {
1329 [ - + ]: 1273 : if (bBroadcast)
1330 : 0 : BroadcastStyleOperation(pFmt->GetName(),
1331 : : SFX_STYLE_FAMILY_FRAME,
1332 [ # # ][ # # ]: 0 : SFX_STYLESHEET_ERASED);
[ # # ]
1333 : :
1334 [ + - ][ + - ]: 1273 : if (GetIDocumentUndoRedo().DoesUndo())
[ + + ]
1335 : : {
1336 [ + - ][ + - ]: 1269 : SwUndo * pUndo = new SwUndoFrmFmtDelete(pFmt, this);
1337 : :
1338 [ + - ][ + - ]: 1269 : GetIDocumentUndoRedo().AppendUndo(pUndo);
1339 : : }
1340 : :
1341 [ + - ][ + - ]: 1273 : delete *it;
1342 [ + - ]: 1273 : pFrmFmtTbl->erase(it);
1343 : : }
1344 : : else
1345 : : {
1346 [ + - ]: 872 : SwFrmFmts::iterator it2 = std::find( GetSpzFrmFmts()->begin(), GetSpzFrmFmts()->end(), pFmt );
1347 : : OSL_ENSURE( it2 != GetSpzFrmFmts()->end(), "FrmFmt not found." );
1348 [ + - ][ + - ]: 872 : if( it2 != GetSpzFrmFmts()->end() )
1349 : : {
1350 [ + - ][ + - ]: 872 : delete *it2;
1351 [ + - ]: 2145 : GetSpzFrmFmts()->erase( it2 );
1352 : : }
1353 : : }
1354 : : }
1355 : 2145 : }
1356 : :
1357 : 232 : void SwDoc::DelTblFrmFmt( SwTableFmt *pFmt )
1358 : : {
1359 [ + - ]: 232 : SwFrmFmts::iterator it = std::find( pTblFrmFmtTbl->begin(), pTblFrmFmtTbl->end(), pFmt );
1360 : : OSL_ENSURE( it != pTblFrmFmtTbl->end(), "Fmt not found," );
1361 [ + - ][ + - ]: 232 : delete *it;
1362 [ + - ]: 232 : pTblFrmFmtTbl->erase(it);
1363 : 232 : }
1364 : :
1365 : : /*
1366 : : * Create the formats
1367 : : */
1368 : 655 : SwFlyFrmFmt *SwDoc::MakeFlyFrmFmt( const String &rFmtName,
1369 : : SwFrmFmt *pDerivedFrom )
1370 : : {
1371 [ + - ]: 655 : SwFlyFrmFmt *pFmt = new SwFlyFrmFmt( GetAttrPool(), rFmtName, pDerivedFrom );
1372 [ + - ]: 655 : GetSpzFrmFmts()->push_back(pFmt);
1373 : 655 : SetModified();
1374 : 655 : return pFmt;
1375 : : }
1376 : :
1377 : 688 : SwDrawFrmFmt *SwDoc::MakeDrawFrmFmt( const String &rFmtName,
1378 : : SwFrmFmt *pDerivedFrom )
1379 : : {
1380 [ + - ]: 688 : SwDrawFrmFmt *pFmt = new SwDrawFrmFmt( GetAttrPool(), rFmtName, pDerivedFrom);
1381 [ + - ]: 688 : GetSpzFrmFmts()->push_back(pFmt);
1382 : 688 : SetModified();
1383 : 688 : return pFmt;
1384 : : }
1385 : :
1386 : :
1387 : 81 : sal_uInt16 SwDoc::GetTblFrmFmtCount(sal_Bool bUsed) const
1388 : : {
1389 : 81 : sal_uInt16 nCount = pTblFrmFmtTbl->size();
1390 [ + - ]: 81 : if(bUsed)
1391 : : {
1392 [ + - ][ + - ]: 81 : SwAutoFmtGetDocNode aGetHt( &GetNodes() );
1393 [ + + ]: 148 : for ( sal_uInt16 i = nCount; i; )
1394 : : {
1395 [ + - ][ + - ]: 67 : if((*pTblFrmFmtTbl)[--i]->GetInfo( aGetHt ))
[ - + ]
1396 : 0 : --nCount;
1397 [ + - ]: 81 : }
1398 : : }
1399 : :
1400 : 81 : return nCount;
1401 : : }
1402 : :
1403 : :
1404 : 30 : SwFrmFmt& SwDoc::GetTblFrmFmt(sal_uInt16 nFmt, sal_Bool bUsed ) const
1405 : : {
1406 : 30 : sal_uInt16 nRemoved = 0;
1407 [ + - ]: 30 : if(bUsed)
1408 : : {
1409 [ + - ][ + - ]: 30 : SwAutoFmtGetDocNode aGetHt( &GetNodes() );
1410 [ + + ]: 70 : for ( sal_uInt16 i = 0; i <= nFmt; i++ )
1411 : : {
1412 [ + - ][ + - ]: 40 : while ( (*pTblFrmFmtTbl)[ i + nRemoved]->GetInfo( aGetHt ))
[ - + ]
1413 : : {
1414 : 0 : nRemoved++;
1415 : : }
1416 [ + - ]: 30 : }
1417 : : }
1418 : 30 : return *((*pTblFrmFmtTbl)[nRemoved + nFmt]);
1419 : : }
1420 : :
1421 : 232 : SwTableFmt* SwDoc::MakeTblFrmFmt( const String &rFmtName,
1422 : : SwFrmFmt *pDerivedFrom )
1423 : : {
1424 [ + - ]: 232 : SwTableFmt* pFmt = new SwTableFmt( GetAttrPool(), rFmtName, pDerivedFrom );
1425 [ + - ]: 232 : pTblFrmFmtTbl->push_back( pFmt );
1426 : 232 : SetModified();
1427 : :
1428 : 232 : return pFmt;
1429 : : }
1430 : :
1431 : 2197 : SwFrmFmt *SwDoc::MakeFrmFmt(const String &rFmtName,
1432 : : SwFrmFmt *pDerivedFrom,
1433 : : sal_Bool bBroadcast, sal_Bool bAuto)
1434 : : {
1435 : :
1436 [ + - ][ + - ]: 2197 : SwFrmFmt *pFmt = new SwFrmFmt( GetAttrPool(), rFmtName, pDerivedFrom );
1437 : :
1438 : 2197 : pFmt->SetAuto(bAuto);
1439 [ + - ]: 2197 : pFrmFmtTbl->push_back( pFmt );
1440 [ + - ]: 2197 : SetModified();
1441 : :
1442 [ - + ]: 2197 : if (bBroadcast)
1443 : : {
1444 : : BroadcastStyleOperation(rFmtName, SFX_STYLE_FAMILY_PARA,
1445 [ # # ][ # # ]: 0 : SFX_STYLESHEET_CREATED);
[ # # ]
1446 : :
1447 [ # # ][ # # ]: 0 : if (GetIDocumentUndoRedo().DoesUndo())
[ # # ]
1448 : : {
1449 [ # # ][ # # ]: 0 : SwUndo * pUndo = new SwUndoFrmFmtCreate(pFmt, pDerivedFrom, this);
1450 : :
1451 [ # # ][ # # ]: 0 : GetIDocumentUndoRedo().AppendUndo(pUndo);
1452 : : }
1453 : : }
1454 : :
1455 : 2197 : return pFmt;
1456 : : }
1457 : :
1458 : 837 : SwFmt *SwDoc::_MakeFrmFmt(const String &rFmtName,
1459 : : SwFmt *pDerivedFrom,
1460 : : sal_Bool bBroadcast, sal_Bool bAuto)
1461 : : {
1462 [ - + ]: 837 : SwFrmFmt *pFrmFmt = dynamic_cast<SwFrmFmt*>(pDerivedFrom);
1463 : 837 : pFrmFmt = MakeFrmFmt( rFmtName, pFrmFmt, bBroadcast, bAuto );
1464 : 837 : return dynamic_cast<SwFmt*>(pFrmFmt);
1465 : : }
1466 : :
1467 : :
1468 : : // #i40550# - add parameter <bAuto> - not relevant
1469 : 1060 : SwCharFmt *SwDoc::MakeCharFmt( const String &rFmtName,
1470 : : SwCharFmt *pDerivedFrom,
1471 : : sal_Bool bBroadcast,
1472 : : sal_Bool )
1473 : : {
1474 [ + - ][ + - ]: 1060 : SwCharFmt *pFmt = new SwCharFmt( GetAttrPool(), rFmtName, pDerivedFrom );
[ + - ]
1475 [ + - ]: 1060 : pCharFmtTbl->push_back( pFmt );
1476 : 1060 : pFmt->SetAuto( sal_False );
1477 [ + - ]: 1060 : SetModified();
1478 : :
1479 [ + - ][ + - ]: 1060 : if (GetIDocumentUndoRedo().DoesUndo())
[ + + ]
1480 : : {
1481 [ + - ][ + - ]: 12 : SwUndo * pUndo = new SwUndoCharFmtCreate(pFmt, pDerivedFrom, this);
1482 : :
1483 [ + - ][ + - ]: 12 : GetIDocumentUndoRedo().AppendUndo(pUndo);
1484 : : }
1485 : :
1486 [ - + ]: 1060 : if (bBroadcast)
1487 : : {
1488 : : BroadcastStyleOperation(rFmtName, SFX_STYLE_FAMILY_CHAR,
1489 [ # # ][ # # ]: 0 : SFX_STYLESHEET_CREATED);
[ # # ]
1490 : : }
1491 : :
1492 : 1060 : return pFmt;
1493 : : }
1494 : :
1495 : 318 : SwFmt *SwDoc::_MakeCharFmt(const String &rFmtName,
1496 : : SwFmt *pDerivedFrom,
1497 : : sal_Bool bBroadcast, sal_Bool bAuto)
1498 : : {
1499 [ - + ]: 318 : SwCharFmt *pCharFmt = dynamic_cast<SwCharFmt*>(pDerivedFrom);
1500 : 318 : pCharFmt = MakeCharFmt( rFmtName, pCharFmt, bBroadcast, bAuto );
1501 : 318 : return dynamic_cast<SwFmt*>(pCharFmt);
1502 : : }
1503 : :
1504 : :
1505 : : /*
1506 : : * Create the FormatCollections
1507 : : */
1508 : : // TXT
1509 : : // #i40550# - add parameter <bAuto> - not relevant
1510 : 358 : SwTxtFmtColl* SwDoc::MakeTxtFmtColl( const String &rFmtName,
1511 : : SwTxtFmtColl *pDerivedFrom,
1512 : : sal_Bool bBroadcast,
1513 : : sal_Bool )
1514 : : {
1515 : : SwTxtFmtColl *pFmtColl = new SwTxtFmtColl( GetAttrPool(), rFmtName,
1516 [ + - ][ + - ]: 358 : pDerivedFrom );
1517 [ + - ]: 358 : pTxtFmtCollTbl->push_back(pFmtColl);
1518 : 358 : pFmtColl->SetAuto( sal_False );
1519 [ + - ]: 358 : SetModified();
1520 : :
1521 [ + - ][ + - ]: 358 : if (GetIDocumentUndoRedo().DoesUndo())
[ + + ]
1522 : : {
1523 : : SwUndo * pUndo = new SwUndoTxtFmtCollCreate(pFmtColl, pDerivedFrom,
1524 [ + - ][ + - ]: 2 : this);
1525 [ + - ][ + - ]: 2 : GetIDocumentUndoRedo().AppendUndo(pUndo);
1526 : : }
1527 : :
1528 [ - + ]: 358 : if (bBroadcast)
1529 : : BroadcastStyleOperation(rFmtName, SFX_STYLE_FAMILY_PARA,
1530 [ # # ][ # # ]: 0 : SFX_STYLESHEET_CREATED);
[ # # ]
1531 : :
1532 : 358 : return pFmtColl;
1533 : : }
1534 : :
1535 : 0 : SwFmt *SwDoc::_MakeTxtFmtColl(const String &rFmtName,
1536 : : SwFmt *pDerivedFrom,
1537 : : sal_Bool bBroadcast, sal_Bool bAuto)
1538 : : {
1539 [ # # ]: 0 : SwTxtFmtColl *pTxtFmtColl = dynamic_cast<SwTxtFmtColl*>(pDerivedFrom);
1540 : 0 : pTxtFmtColl = MakeTxtFmtColl( rFmtName, pTxtFmtColl, bBroadcast, bAuto );
1541 : 0 : return dynamic_cast<SwFmt*>(pTxtFmtColl);
1542 : : }
1543 : :
1544 : :
1545 : : //FEATURE::CONDCOLL
1546 : 4 : SwConditionTxtFmtColl* SwDoc::MakeCondTxtFmtColl( const String &rFmtName,
1547 : : SwTxtFmtColl *pDerivedFrom,
1548 : : sal_Bool bBroadcast)
1549 : : {
1550 : : SwConditionTxtFmtColl*pFmtColl = new SwConditionTxtFmtColl( GetAttrPool(),
1551 [ + - ]: 4 : rFmtName, pDerivedFrom );
1552 [ + - ]: 4 : pTxtFmtCollTbl->push_back(pFmtColl);
1553 : 4 : pFmtColl->SetAuto( sal_False );
1554 : 4 : SetModified();
1555 : :
1556 [ - + ]: 4 : if (bBroadcast)
1557 : : BroadcastStyleOperation(rFmtName, SFX_STYLE_FAMILY_PARA,
1558 [ # # ]: 0 : SFX_STYLESHEET_CREATED);
1559 : :
1560 : 4 : return pFmtColl;
1561 : : }
1562 : : //FEATURE::CONDCOLL
1563 : :
1564 : : // GRF
1565 : :
1566 : 0 : SwGrfFmtColl* SwDoc::MakeGrfFmtColl( const String &rFmtName,
1567 : : SwGrfFmtColl *pDerivedFrom )
1568 : : {
1569 : : SwGrfFmtColl *pFmtColl = new SwGrfFmtColl( GetAttrPool(), rFmtName,
1570 [ # # ][ # # ]: 0 : pDerivedFrom );
1571 [ # # ]: 0 : pGrfFmtCollTbl->push_back( pFmtColl );
1572 : 0 : pFmtColl->SetAuto( sal_False );
1573 [ # # ]: 0 : SetModified();
1574 : 0 : return pFmtColl;
1575 : : }
1576 : :
1577 : 2 : void SwDoc::DelTxtFmtColl(sal_uInt16 nFmtColl, sal_Bool bBroadcast)
1578 : : {
1579 : : OSL_ENSURE( nFmtColl, "Remove fuer Coll 0." );
1580 : :
1581 : : // Who has the to-be-deleted as their Next?
1582 : 2 : SwTxtFmtColl *pDel = (*pTxtFmtCollTbl)[nFmtColl];
1583 [ - + ]: 2 : if( pDfltTxtFmtColl == pDel )
1584 : 2 : return; // never delete default!
1585 : :
1586 [ - + ]: 2 : if (bBroadcast)
1587 : 0 : BroadcastStyleOperation(pDel->GetName(), SFX_STYLE_FAMILY_PARA,
1588 [ # # ]: 0 : SFX_STYLESHEET_ERASED);
1589 : :
1590 [ - + ]: 2 : if (GetIDocumentUndoRedo().DoesUndo())
1591 : : {
1592 : : SwUndoTxtFmtCollDelete * pUndo =
1593 [ # # ]: 0 : new SwUndoTxtFmtCollDelete(pDel, this);
1594 : :
1595 : 0 : GetIDocumentUndoRedo().AppendUndo(pUndo);
1596 : : }
1597 : :
1598 : : // Remove the FmtColl
1599 [ + - ][ + - ]: 2 : pTxtFmtCollTbl->erase(pTxtFmtCollTbl->begin() + nFmtColl);
1600 : : // Correct next
1601 [ + - ][ + - ]: 4 : for( SwTxtFmtColls::const_iterator it = pTxtFmtCollTbl->begin() + 1; it != pTxtFmtCollTbl->end(); ++it )
[ + - ][ + - ]
[ + + ]
1602 [ + - ]: 2 : SetTxtFmtCollNext( *it, pDel );
1603 [ + - ]: 2 : delete pDel;
1604 : 2 : SetModified();
1605 : : }
1606 : :
1607 : 0 : void SwDoc::DelTxtFmtColl( SwTxtFmtColl *pColl, sal_Bool bBroadcast )
1608 : : {
1609 : 0 : sal_uInt16 nFmt = pTxtFmtCollTbl->GetPos( pColl );
1610 : : OSL_ENSURE( USHRT_MAX != nFmt, "Collection not found," );
1611 : 0 : DelTxtFmtColl( nFmt, bBroadcast );
1612 : 0 : }
1613 : :
1614 : 13798 : sal_Bool lcl_SetTxtFmtColl( const SwNodePtr& rpNode, void* pArgs )
1615 : : {
1616 : : // ParaSetFmtColl * pPara = (ParaSetFmtColl*)pArgs;
1617 : 13798 : SwCntntNode* pCNd = (SwCntntNode*)rpNode->GetTxtNode();
1618 [ + - ]: 13798 : if( pCNd )
1619 : : {
1620 : 13798 : ParaRstFmt* pPara = (ParaRstFmt*)pArgs;
1621 : :
1622 : 13798 : SwTxtFmtColl* pFmt = static_cast<SwTxtFmtColl*>(pPara->pFmtColl);
1623 [ + - ]: 13798 : if ( pPara->bReset )
1624 : : {
1625 : :
1626 [ + + ][ + - ]: 13798 : if( pFmt->GetAttrOutlineLevel() == 0 && pPara )
[ + + ]
1627 : 12856 : pPara->bKeepOutlineLevelAttr = true;
1628 : :
1629 [ + - ][ + - ]: 13798 : lcl_RstAttr( pCNd, pPara );
1630 : :
1631 : : // #i62675# check, if paragraph style has changed
1632 [ - + # # : 13798 : if ( pPara->bResetListAttrs &&
# # ][ - + ]
1633 : 0 : pFmt != pCNd->GetFmtColl() &&
1634 : 0 : pFmt->GetItemState( RES_PARATR_NUMRULE ) == SFX_ITEM_SET )
1635 : : {
1636 : : // Check, if the list style of the paragraph will change.
1637 : 0 : bool bChangeOfListStyleAtParagraph( true );
1638 [ # # ]: 0 : SwTxtNode* pTNd( dynamic_cast<SwTxtNode*>(pCNd) );
1639 : : OSL_ENSURE( pTNd,
1640 : : "<lcl_SetTxtFmtColl(..)> - text node expected -> crash" );
1641 : : {
1642 : 0 : SwNumRule* pNumRuleAtParagraph( pTNd->GetNumRule() );
1643 [ # # ]: 0 : if ( pNumRuleAtParagraph )
1644 : : {
1645 : : const SwNumRuleItem& rNumRuleItemAtParagraphStyle =
1646 : 0 : pFmt->GetNumRule();
1647 [ # # ]: 0 : if ( rNumRuleItemAtParagraphStyle.GetValue() ==
1648 : 0 : pNumRuleAtParagraph->GetName() )
1649 : : {
1650 : 0 : bChangeOfListStyleAtParagraph = false;
1651 : : }
1652 : : }
1653 : : }
1654 : :
1655 [ # # ]: 0 : if ( bChangeOfListStyleAtParagraph )
1656 : : {
1657 : 0 : std::auto_ptr< SwRegHistory > pRegH;
1658 [ # # ]: 0 : if ( pPara->pHistory )
1659 : : {
1660 [ # # ][ # # ]: 0 : pRegH.reset( new SwRegHistory( pTNd, *pTNd, pPara->pHistory ) );
1661 : : }
1662 : :
1663 [ # # ]: 0 : pCNd->ResetAttr( RES_PARATR_NUMRULE );
1664 : :
1665 : : // reset all list attributes
1666 [ # # ]: 0 : pCNd->ResetAttr( RES_PARATR_LIST_LEVEL );
1667 [ # # ]: 0 : pCNd->ResetAttr( RES_PARATR_LIST_ISRESTART );
1668 [ # # ]: 0 : pCNd->ResetAttr( RES_PARATR_LIST_RESTARTVALUE );
1669 [ # # ]: 0 : pCNd->ResetAttr( RES_PARATR_LIST_ISCOUNTED );
1670 [ # # ][ # # ]: 0 : pCNd->ResetAttr( RES_PARATR_LIST_ID );
1671 : : }
1672 : : }
1673 : : }
1674 : :
1675 : : // add to History so that old data is saved, if necessary
1676 [ + + ]: 13798 : if( pPara->pHistory )
1677 : : pPara->pHistory->Add( pCNd->GetFmtColl(), pCNd->GetIndex(),
1678 : 10 : ND_TEXTNODE );
1679 : :
1680 : 13798 : pCNd->ChgFmtColl( pFmt );
1681 : :
1682 : 13798 : pPara->nWhich++;
1683 : : }
1684 : 13798 : return sal_True;
1685 : : }
1686 : :
1687 : 13796 : sal_Bool SwDoc::SetTxtFmtColl( const SwPaM &rRg,
1688 : : SwTxtFmtColl *pFmt,
1689 : : bool bReset,
1690 : : bool bResetListAttrs )
1691 : : {
1692 [ + - ]: 13796 : SwDataChanged aTmp( rRg, 0 );
1693 [ + - ][ + - ]: 13796 : const SwPosition *pStt = rRg.Start(), *pEnd = rRg.End();
1694 : 13796 : SwHistory* pHst = 0;
1695 : 13796 : sal_Bool bRet = sal_True;
1696 : :
1697 [ + - ][ + - ]: 13796 : if (GetIDocumentUndoRedo().DoesUndo())
[ + + ]
1698 : : {
1699 : : SwUndoFmtColl* pUndo = new SwUndoFmtColl( rRg, pFmt,
1700 : : bReset,
1701 [ + - ][ + - ]: 8 : bResetListAttrs );
1702 : 8 : pHst = pUndo->GetHistory();
1703 [ + - ][ + - ]: 8 : GetIDocumentUndoRedo().AppendUndo(pUndo);
1704 : : }
1705 : :
1706 : 13796 : ParaRstFmt aPara( pStt, pEnd, pHst );
1707 : 13796 : aPara.pFmtColl = pFmt;
1708 : 13796 : aPara.bReset = bReset;
1709 : : // #i62675#
1710 : 13796 : aPara.bResetListAttrs = bResetListAttrs;
1711 : :
1712 [ + - ]: 27592 : GetNodes().ForEach( pStt->nNode.GetIndex(), pEnd->nNode.GetIndex()+1,
1713 [ + - ]: 27592 : lcl_SetTxtFmtColl, &aPara );
1714 [ - + ]: 13796 : if( !aPara.nWhich )
1715 : 0 : bRet = sal_False; // didn't find a valid Node
1716 : :
1717 [ + - ]: 13796 : if( bRet )
1718 [ + - ]: 13796 : SetModified();
1719 [ + - ]: 13796 : return bRet;
1720 : : }
1721 : :
1722 : :
1723 : : // ---- Copy the formats to itself (SwDoc) ----------------------
1724 : :
1725 : 3 : SwFmt* SwDoc::CopyFmt( const SwFmt& rFmt,
1726 : : const SwFmtsBase& rFmtArr,
1727 : : FNCopyFmt fnCopyFmt, const SwFmt& rDfltFmt )
1728 : : {
1729 : : // It's no autoformat, default format or collection format,
1730 : : // then search for it.
1731 [ - + ][ # # ]: 3 : if( !rFmt.IsAuto() || !rFmt.GetRegisteredIn() )
[ + - ]
1732 [ + - ]: 6 : for( sal_uInt16 n = 0; n < rFmtArr.GetFmtCount(); n++ )
1733 : : {
1734 : : // Does the Doc already contain the template?
1735 [ + + ]: 6 : if( rFmtArr.GetFmt(n)->GetName().Equals( rFmt.GetName() ))
1736 : 3 : return (SwFmt*)rFmtArr.GetFmt(n);
1737 : : }
1738 : :
1739 : : // Search for the "parent" first
1740 : 0 : SwFmt* pParent = (SwFmt*)&rDfltFmt;
1741 [ # # ][ # # ]: 0 : if( rFmt.DerivedFrom() && pParent != rFmt.DerivedFrom() )
[ # # ]
1742 : 0 : pParent = CopyFmt( *rFmt.DerivedFrom(), rFmtArr,
1743 : 0 : fnCopyFmt, rDfltFmt );
1744 : :
1745 : : // Create the format and copy the attributes
1746 : : // #i40550#
1747 [ # # ]: 0 : SwFmt* pNewFmt = (this->*fnCopyFmt)( rFmt.GetName(), pParent, sal_False, sal_True );
1748 : 0 : pNewFmt->SetAuto( rFmt.IsAuto() );
1749 : 0 : pNewFmt->CopyAttrs( rFmt, sal_True ); // copy the attributes
1750 : :
1751 : 0 : pNewFmt->SetPoolFmtId( rFmt.GetPoolFmtId() );
1752 : 0 : pNewFmt->SetPoolHelpId( rFmt.GetPoolHelpId() );
1753 : :
1754 : : // Always set the HelpFile Id to dflt!
1755 : 0 : pNewFmt->SetPoolHlpFileId( UCHAR_MAX );
1756 : :
1757 : 3 : return pNewFmt;
1758 : : }
1759 : :
1760 : :
1761 : : // ---- copy the frame format --------
1762 : 3 : SwFrmFmt* SwDoc::CopyFrmFmt( const SwFrmFmt& rFmt )
1763 : : {
1764 : :
1765 : 3 : return (SwFrmFmt*)CopyFmt( rFmt, *GetFrmFmts(), &SwDoc::_MakeFrmFmt,
1766 : 6 : *GetDfltFrmFmt() );
1767 : : }
1768 : :
1769 : : // ---- copy the char format --------
1770 : 0 : SwCharFmt* SwDoc::CopyCharFmt( const SwCharFmt& rFmt )
1771 : : {
1772 : 0 : return (SwCharFmt*)CopyFmt( rFmt, *GetCharFmts(),
1773 : : &SwDoc::_MakeCharFmt,
1774 : 0 : *GetDfltCharFmt() );
1775 : : }
1776 : :
1777 : :
1778 : : // --- copy TextNodes ----
1779 : :
1780 : 165 : SwTxtFmtColl* SwDoc::CopyTxtColl( const SwTxtFmtColl& rColl )
1781 : : {
1782 [ + - ]: 165 : SwTxtFmtColl* pNewColl = FindTxtFmtCollByName( rColl.GetName() );
1783 [ + - ]: 165 : if( pNewColl )
1784 : 165 : return pNewColl;
1785 : :
1786 : : // search for the "parent" first
1787 : 0 : SwTxtFmtColl* pParent = pDfltTxtFmtColl;
1788 [ # # ]: 0 : if( pParent != rColl.DerivedFrom() )
1789 [ # # ]: 0 : pParent = CopyTxtColl( *(SwTxtFmtColl*)rColl.DerivedFrom() );
1790 : :
1791 : :
1792 : : //FEATURE::CONDCOLL
1793 [ # # ]: 0 : if( RES_CONDTXTFMTCOLL == rColl.Which() )
1794 : : {
1795 : 0 : pNewColl = new SwConditionTxtFmtColl( GetAttrPool(), rColl.GetName(),
1796 [ # # ][ # # ]: 0 : pParent);
1797 [ # # ]: 0 : pTxtFmtCollTbl->push_back( pNewColl );
1798 : 0 : pNewColl->SetAuto( sal_False );
1799 [ # # ]: 0 : SetModified();
1800 : :
1801 : : // copy the conditions
1802 : : ((SwConditionTxtFmtColl*)pNewColl)->SetConditions(
1803 [ # # ]: 0 : ((SwConditionTxtFmtColl&)rColl).GetCondColls() );
1804 : : }
1805 : : else
1806 : : //FEATURE::CONDCOLL
1807 [ # # ]: 0 : pNewColl = MakeTxtFmtColl( rColl.GetName(), pParent );
1808 : :
1809 : : // copy the auto formats or the attributes
1810 [ # # ]: 0 : pNewColl->CopyAttrs( rColl, sal_True );
1811 : :
1812 [ # # ]: 0 : if(rColl.IsAssignedToListLevelOfOutlineStyle())
1813 [ # # ][ # # ]: 0 : pNewColl->AssignToListLevelOfOutlineStyle(rColl.GetAssignedOutlineStyleLevel());//<-end,zhaojianwei
1814 : : //<-end
1815 : 0 : pNewColl->SetPoolFmtId( rColl.GetPoolFmtId() );
1816 : 0 : pNewColl->SetPoolHelpId( rColl.GetPoolHelpId() );
1817 : :
1818 : : // Always set the HelpFile Id to dflt!
1819 : 0 : pNewColl->SetPoolHlpFileId( UCHAR_MAX );
1820 : :
1821 [ # # ]: 0 : if( &rColl.GetNextTxtFmtColl() != &rColl )
1822 [ # # ]: 0 : pNewColl->SetNextTxtFmtColl( *CopyTxtColl( rColl.GetNextTxtFmtColl() ));
1823 : :
1824 : : // create the NumRule if necessary
1825 [ # # ]: 0 : if( this != rColl.GetDoc() )
1826 : : {
1827 : : const SfxPoolItem* pItem;
1828 [ # # ]: 0 : if( SFX_ITEM_SET == pNewColl->GetItemState( RES_PARATR_NUMRULE,
1829 [ # # ]: 0 : sal_False, &pItem ))
1830 : : {
1831 : : const SwNumRule* pRule;
1832 : 0 : const String& rName = ((SwNumRuleItem*)pItem)->GetValue();
1833 [ # # # # ]: 0 : if( rName.Len() &&
[ # # ]
[ # # # # ]
1834 : 0 : 0 != ( pRule = rColl.GetDoc()->FindNumRulePtr( rName )) &&
1835 : 0 : !pRule->IsAutoRule() )
1836 : : {
1837 [ # # ]: 0 : SwNumRule* pDestRule = FindNumRulePtr( rName );
1838 [ # # ]: 0 : if( pDestRule )
1839 [ # # ]: 0 : pDestRule->SetInvalidRule( sal_True );
1840 : : else
1841 [ # # ]: 0 : MakeNumRule( rName, pRule );
1842 : : }
1843 : : }
1844 : : }
1845 : 165 : return pNewColl;
1846 : : }
1847 : :
1848 : : // --- copy the graphic nodes ----
1849 : :
1850 : 3 : SwGrfFmtColl* SwDoc::CopyGrfColl( const SwGrfFmtColl& rColl )
1851 : : {
1852 : 3 : SwGrfFmtColl* pNewColl = FindGrfFmtCollByName( rColl.GetName() );
1853 [ + - ]: 3 : if( pNewColl )
1854 : 3 : return pNewColl;
1855 : :
1856 : : // Search for the "parent" first
1857 : 0 : SwGrfFmtColl* pParent = pDfltGrfFmtColl;
1858 [ # # ]: 0 : if( pParent != rColl.DerivedFrom() )
1859 : 0 : pParent = CopyGrfColl( *(SwGrfFmtColl*)rColl.DerivedFrom() );
1860 : :
1861 : : // if not, copy them
1862 : 0 : pNewColl = MakeGrfFmtColl( rColl.GetName(), pParent );
1863 : :
1864 : : // copy the attributes
1865 : 0 : pNewColl->CopyAttrs( rColl );
1866 : :
1867 : 0 : pNewColl->SetPoolFmtId( rColl.GetPoolFmtId() );
1868 : 0 : pNewColl->SetPoolHelpId( rColl.GetPoolHelpId() );
1869 : :
1870 : : // Always set the HelpFile Id to dflt!
1871 : 0 : pNewColl->SetPoolHlpFileId( UCHAR_MAX );
1872 : :
1873 : 3 : return pNewColl;
1874 : : }
1875 : :
1876 : 137 : SwPageDesc* lcl_FindPageDesc( const SwPageDescs& rArr, const String& rName )
1877 : : {
1878 [ + + ]: 371 : for( sal_uInt16 n = rArr.size(); n; )
1879 : : {
1880 : 369 : SwPageDesc* pDesc = rArr[ --n ];
1881 [ + + ]: 369 : if( pDesc->GetName() == rName )
1882 : 135 : return pDesc;
1883 : : }
1884 : 137 : return 0;
1885 : : }
1886 : :
1887 : 12 : void SwDoc::CopyFmtArr( const SwFmtsBase& rSourceArr,
1888 : : SwFmtsBase& rDestArr,
1889 : : FNCopyFmt fnCopyFmt,
1890 : : SwFmt& rDfltFmt )
1891 : : {
1892 : : sal_uInt16 nSrc;
1893 : : SwFmt* pSrc, *pDest;
1894 : :
1895 : : // 1st step: Create all formats (skip the 0th - it's the default one)
1896 [ + + ]: 16 : for( nSrc = rSourceArr.GetFmtCount(); nSrc > 1; )
1897 : : {
1898 : 4 : pSrc = (SwFmt*)rSourceArr.GetFmt( --nSrc );
1899 [ - + ][ - + ]: 4 : if( pSrc->IsDefault() || pSrc->IsAuto() )
[ + - ]
1900 : 0 : continue;
1901 : :
1902 [ - + ]: 4 : if( 0 == FindFmtByName( rDestArr, pSrc->GetName() ) )
1903 : : {
1904 [ # # ]: 0 : if( RES_CONDTXTFMTCOLL == pSrc->Which() )
1905 : 0 : MakeCondTxtFmtColl( pSrc->GetName(), (SwTxtFmtColl*)&rDfltFmt );
1906 : : else
1907 : : // #i40550#
1908 [ # # ]: 0 : (this->*fnCopyFmt)( pSrc->GetName(), &rDfltFmt, sal_False, sal_True );
1909 : : }
1910 : : }
1911 : :
1912 : : // 2nd step: Copy all attributes, set the right parents
1913 [ + + ]: 16 : for( nSrc = rSourceArr.GetFmtCount(); nSrc > 1; )
1914 : : {
1915 [ + - ]: 4 : pSrc = (SwFmt*)rSourceArr.GetFmt( --nSrc );
1916 [ + - ][ - + ]: 4 : if( pSrc->IsDefault() || pSrc->IsAuto() )
[ - + ]
1917 : 0 : continue;
1918 : :
1919 [ + - ]: 4 : pDest = FindFmtByName( rDestArr, pSrc->GetName() );
1920 : 4 : pDest->SetAuto( sal_False );
1921 [ + - ]: 4 : pDest->DelDiffs( *pSrc );
1922 : :
1923 : : // #i94285#: existing <SwFmtPageDesc> instance, before copying attributes
1924 : : const SfxPoolItem* pItem;
1925 [ + - ]: 8 : if( &GetAttrPool() != pSrc->GetAttrSet().GetPool() &&
[ - + # # ]
[ - + ]
1926 : 4 : SFX_ITEM_SET == pSrc->GetAttrSet().GetItemState(
1927 [ + - ]: 4 : RES_PAGEDESC, sal_False, &pItem ) &&
1928 : 0 : ((SwFmtPageDesc*)pItem)->GetPageDesc() )
1929 : : {
1930 [ # # ]: 0 : SwFmtPageDesc aPageDesc( *(SwFmtPageDesc*)pItem );
1931 : 0 : const String& rNm = aPageDesc.GetPageDesc()->GetName();
1932 [ # # ]: 0 : SwPageDesc* pPageDesc = ::lcl_FindPageDesc( aPageDescs, rNm );
1933 [ # # ]: 0 : if( !pPageDesc )
1934 : : {
1935 [ # # ]: 0 : pPageDesc = aPageDescs[ MakePageDesc( rNm ) ];
1936 : : }
1937 [ # # ]: 0 : aPageDesc.RegisterToPageDesc( *pPageDesc );
1938 [ # # ]: 0 : SwAttrSet aTmpAttrSet( pSrc->GetAttrSet() );
1939 [ # # ]: 0 : aTmpAttrSet.Put( aPageDesc );
1940 [ # # ][ # # ]: 0 : pDest->SetFmtAttr( aTmpAttrSet );
[ # # ]
1941 : : }
1942 : : else
1943 : : {
1944 [ + - ]: 4 : pDest->SetFmtAttr( pSrc->GetAttrSet() );
1945 : : }
1946 : :
1947 : 4 : pDest->SetPoolFmtId( pSrc->GetPoolFmtId() );
1948 : 4 : pDest->SetPoolHelpId( pSrc->GetPoolHelpId() );
1949 : :
1950 : : // Always set the HelpFile Id to dflt!
1951 : 4 : pDest->SetPoolHlpFileId( UCHAR_MAX );
1952 : :
1953 [ + - ]: 4 : if( pSrc->DerivedFrom() )
1954 : : pDest->SetDerivedFrom( FindFmtByName( rDestArr,
1955 [ + - ][ + - ]: 4 : pSrc->DerivedFrom()->GetName() ) );
1956 [ - + # # ]: 4 : if( RES_TXTFMTCOLL == pSrc->Which() ||
[ + - ]
1957 : 0 : RES_CONDTXTFMTCOLL == pSrc->Which() )
1958 : : {
1959 : 4 : SwTxtFmtColl* pSrcColl = (SwTxtFmtColl*)pSrc,
1960 : 4 : * pDstColl = (SwTxtFmtColl*)pDest;
1961 [ - + ]: 4 : if( &pSrcColl->GetNextTxtFmtColl() != pSrcColl )
1962 : : pDstColl->SetNextTxtFmtColl( *(SwTxtFmtColl*)FindFmtByName(
1963 [ # # ]: 0 : rDestArr, pSrcColl->GetNextTxtFmtColl().GetName() ) );
1964 : :
1965 [ - + ]: 4 : if(pSrcColl->IsAssignedToListLevelOfOutlineStyle())
1966 [ # # ][ # # ]: 0 : pDstColl->AssignToListLevelOfOutlineStyle(pSrcColl->GetAssignedOutlineStyleLevel());//<-end,zhaojianwei
1967 : : //<-end
1968 : :
1969 : : //FEATURE::CONDCOLL
1970 [ - + ]: 4 : if( RES_CONDTXTFMTCOLL == pSrc->Which() )
1971 : : // Copy the conditions, but delete the old ones first!
1972 : : ((SwConditionTxtFmtColl*)pDstColl)->SetConditions(
1973 [ # # ]: 4 : ((SwConditionTxtFmtColl*)pSrc)->GetCondColls() );
1974 : : //FEATURE::CONDCOLL
1975 : : }
1976 : : }
1977 : 12 : }
1978 : :
1979 : 3588 : void SwDoc::CopyPageDescHeaderFooterImpl( bool bCpyHeader,
1980 : : const SwFrmFmt& rSrcFmt, SwFrmFmt& rDestFmt )
1981 : : {
1982 : : // Treat the header and footer attributes in the right way:
1983 : : // Copy content nodes across documents!
1984 [ + + ]: 3588 : sal_uInt16 nAttr = static_cast<sal_uInt16>( bCpyHeader ? RES_HEADER : RES_FOOTER );
1985 : : const SfxPoolItem* pItem;
1986 [ + - ][ + + ]: 3588 : if( SFX_ITEM_SET != rSrcFmt.GetAttrSet().GetItemState( nAttr, sal_False, &pItem ))
1987 : 3588 : return ;
1988 : :
1989 : : // The header only contains the reference to the format from the other document!
1990 [ + - ]: 1518 : SfxPoolItem* pNewItem = pItem->Clone();
1991 : :
1992 : : SwFrmFmt* pOldFmt;
1993 [ + + ]: 1518 : if( bCpyHeader )
1994 : 759 : pOldFmt = ((SwFmtHeader*)pNewItem)->GetHeaderFmt();
1995 : : else
1996 : 759 : pOldFmt = ((SwFmtFooter*)pNewItem)->GetFooterFmt();
1997 : :
1998 [ + + ]: 1518 : if( pOldFmt )
1999 : : {
2000 : : SwFrmFmt* pNewFmt = new SwFrmFmt( GetAttrPool(), "CpyDesc",
2001 [ + - ][ + - ]: 114 : GetDfltFrmFmt() );
2002 [ + - ]: 114 : pNewFmt->CopyAttrs( *pOldFmt, sal_True );
2003 : :
2004 [ + - ]: 228 : if( SFX_ITEM_SET == pNewFmt->GetAttrSet().GetItemState(
2005 [ + - ]: 114 : RES_CNTNT, sal_False, &pItem ))
2006 : : {
2007 : 114 : SwFmtCntnt* pCntnt = (SwFmtCntnt*)pItem;
2008 [ + - ]: 114 : if( pCntnt->GetCntntIdx() )
2009 : : {
2010 [ + - ][ + - ]: 114 : SwNodeIndex aTmpIdx( GetNodes().GetEndOfAutotext() );
2011 [ + - ]: 114 : const SwNodes& rSrcNds = rSrcFmt.GetDoc()->GetNodes();
2012 [ + - ]: 114 : SwStartNode* pSttNd = GetNodes().MakeEmptySection( aTmpIdx,
2013 : : bCpyHeader
2014 : : ? SwHeaderStartNode
2015 [ + + ][ + - ]: 228 : : SwFooterStartNode );
2016 : 114 : const SwNode& rCSttNd = pCntnt->GetCntntIdx()->GetNode();
2017 [ + - ]: 114 : SwNodeRange aRg( rCSttNd, 0, *rCSttNd.EndOfSectionNode() );
2018 [ + - ]: 114 : aTmpIdx = *pSttNd->EndOfSectionNode();
2019 [ + - ]: 114 : rSrcNds._Copy( aRg, aTmpIdx );
2020 [ + - ]: 114 : aTmpIdx = *pSttNd;
2021 [ + - ]: 114 : rSrcFmt.GetDoc()->CopyFlyInFlyImpl( aRg, 0, aTmpIdx );
2022 [ + - ][ + - ]: 114 : pNewFmt->SetFmtAttr( SwFmtCntnt( pSttNd ));
[ + - ][ + - ]
[ + - ]
2023 : : }
2024 : : else
2025 [ # # ]: 0 : pNewFmt->ResetFmtAttr( RES_CNTNT );
2026 : : }
2027 [ + + ]: 114 : if( bCpyHeader )
2028 [ + - ]: 77 : ((SwFmtHeader*)pNewItem)->RegisterToFormat(*pNewFmt);
2029 : : else
2030 [ + - ]: 37 : ((SwFmtFooter*)pNewItem)->RegisterToFormat(*pNewFmt);
2031 [ + - ]: 114 : rDestFmt.SetFmtAttr( *pNewItem );
2032 : : }
2033 [ + - ][ + - ]: 3588 : delete pNewItem;
2034 : : }
2035 : :
2036 : 953 : void SwDoc::CopyPageDesc( const SwPageDesc& rSrcDesc, SwPageDesc& rDstDesc,
2037 : : sal_Bool bCopyPoolIds )
2038 : : {
2039 : 953 : bool bNotifyLayout = false;
2040 : 953 : SwRootFrm* pTmpRoot = GetCurrentLayout();//swmod 080219
2041 : :
2042 : 953 : rDstDesc.SetLandscape( rSrcDesc.GetLandscape() );
2043 : 953 : rDstDesc.SetNumType( rSrcDesc.GetNumType() );
2044 [ + + ]: 953 : if( rDstDesc.ReadUseOn() != rSrcDesc.ReadUseOn() )
2045 : : {
2046 : 2 : rDstDesc.WriteUseOn( rSrcDesc.ReadUseOn() );
2047 : 2 : bNotifyLayout = true;
2048 : : }
2049 : :
2050 [ + - ]: 953 : if( bCopyPoolIds )
2051 : : {
2052 : 953 : rDstDesc.SetPoolFmtId( rSrcDesc.GetPoolFmtId() );
2053 : 953 : rDstDesc.SetPoolHelpId( rSrcDesc.GetPoolHelpId() );
2054 : : // Always set the HelpFile Id to dflt!
2055 : 953 : rDstDesc.SetPoolHlpFileId( UCHAR_MAX );
2056 : : }
2057 : :
2058 [ + + ]: 953 : if( rSrcDesc.GetFollow() != &rSrcDesc )
2059 : : {
2060 : : SwPageDesc* pFollow = ::lcl_FindPageDesc( aPageDescs,
2061 : 125 : rSrcDesc.GetFollow()->GetName() );
2062 [ - + ]: 125 : if( !pFollow )
2063 : : {
2064 : : // copy
2065 : 0 : sal_uInt16 nPos = MakePageDesc( rSrcDesc.GetFollow()->GetName() );
2066 : 0 : pFollow = aPageDescs[ nPos ];
2067 : 0 : CopyPageDesc( *rSrcDesc.GetFollow(), *pFollow );
2068 : : }
2069 : 125 : rDstDesc.SetFollow( pFollow );
2070 : 125 : bNotifyLayout = true;
2071 : : }
2072 : :
2073 : : // the header and footer attributes are copied seperately
2074 : : // the content sections have to be copied in their entirety
2075 : : {
2076 [ + - ]: 953 : SfxItemSet aAttrSet( rSrcDesc.GetMaster().GetAttrSet() );
2077 [ + - ]: 953 : aAttrSet.ClearItem( RES_HEADER );
2078 [ + - ]: 953 : aAttrSet.ClearItem( RES_FOOTER );
2079 : :
2080 [ + - ]: 953 : rDstDesc.GetMaster().DelDiffs( aAttrSet );
2081 [ + - ]: 953 : rDstDesc.GetMaster().SetFmtAttr( aAttrSet );
2082 : :
2083 [ + - ]: 953 : aAttrSet.ClearItem();
2084 [ + - ]: 953 : aAttrSet.Put( rSrcDesc.GetLeft().GetAttrSet() );
2085 [ + - ]: 953 : aAttrSet.ClearItem( RES_HEADER );
2086 [ + - ]: 953 : aAttrSet.ClearItem( RES_FOOTER );
2087 : :
2088 [ + - ]: 953 : rDstDesc.GetLeft().DelDiffs( aAttrSet );
2089 [ + - ][ + - ]: 953 : rDstDesc.GetLeft().SetFmtAttr( aAttrSet );
2090 : : }
2091 : :
2092 : 953 : CopyHeader( rSrcDesc.GetMaster(), rDstDesc.GetMaster() );
2093 : 953 : CopyFooter( rSrcDesc.GetMaster(), rDstDesc.GetMaster() );
2094 [ - + ]: 953 : if( !rDstDesc.IsHeaderShared() )
2095 : 0 : CopyHeader( rSrcDesc.GetLeft(), rDstDesc.GetLeft() );
2096 : : else
2097 : 953 : rDstDesc.GetLeft().SetFmtAttr( rDstDesc.GetMaster().GetHeader() );
2098 [ + + ]: 953 : if( !rDstDesc.IsFirstShared() )
2099 : 841 : CopyHeader( rSrcDesc.GetFirst(), rDstDesc.GetFirst() );
2100 : : else
2101 : 112 : rDstDesc.GetFirst().SetFmtAttr( rDstDesc.GetMaster().GetHeader() );
2102 : :
2103 [ - + ]: 953 : if( !rDstDesc.IsFooterShared() )
2104 : 0 : CopyFooter( rSrcDesc.GetLeft(), rDstDesc.GetLeft() );
2105 : : else
2106 : 953 : rDstDesc.GetLeft().SetFmtAttr( rDstDesc.GetMaster().GetFooter() );
2107 [ + + ]: 953 : if( !rDstDesc.IsFirstShared() )
2108 : 841 : CopyFooter( rSrcDesc.GetFirst(), rDstDesc.GetFirst() );
2109 : : else
2110 : 112 : rDstDesc.GetFirst().SetFmtAttr( rDstDesc.GetMaster().GetFooter() );
2111 : :
2112 [ + + ][ + + ]: 953 : if( bNotifyLayout && pTmpRoot )
2113 : : {
2114 [ + - ]: 2 : std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();//swmod 080225
2115 [ + - ][ + - ]: 2 : std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::mem_fun(&SwRootFrm::AllCheckPageDescs));//swmod 080226
2116 : : }
2117 : :
2118 : : // If foot notes change the pages have to be triggered
2119 [ - + ]: 953 : if( !(rDstDesc.GetFtnInfo() == rSrcDesc.GetFtnInfo()) )
2120 : : {
2121 [ # # ]: 0 : rDstDesc.SetFtnInfo( rSrcDesc.GetFtnInfo() );
2122 [ # # ]: 0 : SwMsgPoolItem aInfo( RES_PAGEDESC_FTNINFO );
2123 : : {
2124 [ # # ][ # # ]: 0 : rDstDesc.GetMaster().ModifyBroadcast( &aInfo, 0, TYPE(SwFrm) );
2125 : : }
2126 : : {
2127 [ # # ][ # # ]: 0 : rDstDesc.GetLeft().ModifyBroadcast( &aInfo, 0, TYPE(SwFrm) );
2128 [ # # ]: 0 : }
2129 : : }
2130 : 953 : }
2131 : :
2132 : 4 : void SwDoc::ReplaceStyles( const SwDoc& rSource, bool bIncludePageStyles )
2133 : : {
2134 [ + - ][ + - ]: 4 : ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
2135 : :
2136 : : CopyFmtArr( *rSource.pCharFmtTbl, *pCharFmtTbl,
2137 [ + - ]: 4 : &SwDoc::_MakeCharFmt, *pDfltCharFmt );
2138 : : CopyFmtArr( *rSource.pFrmFmtTbl, *pFrmFmtTbl,
2139 [ + - ]: 4 : &SwDoc::_MakeFrmFmt, *pDfltFrmFmt );
2140 : : CopyFmtArr( *rSource.pTxtFmtCollTbl, *pTxtFmtCollTbl,
2141 [ + - ]: 4 : &SwDoc::_MakeTxtFmtColl, *pDfltTxtFmtColl );
2142 : :
2143 : : sal_uInt16 nCnt;
2144 : :
2145 : : //To-Do:
2146 : : // a) in rtf export don't export our hideous pgdsctbl
2147 : : // extension to rtf anymore
2148 : : // b) in sd rtf import (View::InsertData) don't use
2149 : : // a super-fragile test for mere presence of \trowd to
2150 : : // indicate import of rtf into a table
2151 : : // c) then drop use of bIncludePageStyles
2152 [ + - ]: 4 : if (bIncludePageStyles)
2153 : : {
2154 : : // and now the page templates
2155 : 4 : nCnt = rSource.aPageDescs.size();
2156 [ + - ]: 4 : if( nCnt )
2157 : : {
2158 : : // a different Doc -> Number formatter needs to be merged
2159 [ + - ]: 4 : SwTblNumFmtMerge aTNFM( rSource, *this );
2160 : :
2161 : : // 1st step: Create all formats (skip the 0th - it's the default!)
2162 [ + + ]: 10 : while( nCnt )
2163 : : {
2164 : 6 : SwPageDesc *pSrc = rSource.aPageDescs[ --nCnt ];
2165 [ + + ][ + - ]: 6 : if( 0 == ::lcl_FindPageDesc( aPageDescs, pSrc->GetName() ) )
2166 [ + - ]: 2 : MakePageDesc( pSrc->GetName() );
2167 : : }
2168 : :
2169 : : // 2nd step: Copy all attributes, set the right parents
2170 [ + + ]: 10 : for( nCnt = rSource.aPageDescs.size(); nCnt; )
2171 : : {
2172 : 6 : SwPageDesc *pSrc = rSource.aPageDescs[ --nCnt ];
2173 [ + - ][ + - ]: 6 : CopyPageDesc( *pSrc, *::lcl_FindPageDesc( aPageDescs, pSrc->GetName() ));
2174 [ + - ]: 4 : }
2175 : : }
2176 : : }
2177 : :
2178 : : // then there are the numbering templates
2179 : 4 : nCnt = rSource.GetNumRuleTbl().size();
2180 [ + - ]: 4 : if( nCnt )
2181 : : {
2182 : 4 : const SwNumRuleTbl& rArr = rSource.GetNumRuleTbl();
2183 [ + + ]: 8 : for( sal_uInt16 n = 0; n < nCnt; ++n )
2184 : : {
2185 : 4 : const SwNumRule& rR = *rArr[ n ];
2186 [ - + ]: 4 : if( !rR.IsAutoRule() )
2187 : : {
2188 [ # # ]: 0 : SwNumRule* pNew = FindNumRulePtr( rR.GetName());
2189 [ # # ]: 0 : if( pNew )
2190 [ # # ]: 0 : pNew->CopyNumRule( this, rR );
2191 : : else
2192 [ # # ]: 0 : MakeNumRule( rR.GetName(), &rR );
2193 : : }
2194 : : }
2195 : : }
2196 : :
2197 [ - + ]: 4 : if (undoGuard.UndoWasEnabled())
2198 : : {
2199 : : // nodes array was modified!
2200 [ # # ][ # # ]: 0 : GetIDocumentUndoRedo().DelAllUndoObj();
2201 : : }
2202 : :
2203 [ + - ][ + - ]: 4 : SetModified();
2204 : 4 : }
2205 : :
2206 : 62553 : SwFmt* SwDoc::FindFmtByName( const SwFmtsBase& rFmtArr,
2207 : : const String& rName ) const
2208 : : {
2209 : 62553 : SwFmt* pFnd = 0;
2210 [ + + ]: 416169 : for( sal_uInt16 n = 0; n < rFmtArr.GetFmtCount(); n++ )
2211 : : {
2212 : : // Does the Doc already contain the template?
2213 [ + + ]: 384900 : if( rFmtArr.GetFmt(n)->GetName() == rName )
2214 : : {
2215 : 31284 : pFnd = (SwFmt*)rFmtArr.GetFmt(n);
2216 : 31284 : break;
2217 : : }
2218 : : }
2219 : 62553 : return pFnd;
2220 : : }
2221 : :
2222 : 0 : void SwDoc::MoveLeftMargin( const SwPaM& rPam, sal_Bool bRight, sal_Bool bModulus )
2223 : : {
2224 : 0 : SwHistory* pHistory = 0;
2225 [ # # ][ # # ]: 0 : if (GetIDocumentUndoRedo().DoesUndo())
[ # # ]
2226 : : {
2227 : : SwUndoMoveLeftMargin* pUndo = new SwUndoMoveLeftMargin( rPam, bRight,
2228 [ # # ][ # # ]: 0 : bModulus );
2229 : 0 : pHistory = &pUndo->GetHistory();
2230 [ # # ][ # # ]: 0 : GetIDocumentUndoRedo().AppendUndo( pUndo );
2231 : : }
2232 : :
2233 [ # # ]: 0 : const SvxTabStopItem& rTabItem = (SvxTabStopItem&)GetDefault( RES_PARATR_TABSTOP );
2234 : 0 : sal_uInt16 nDefDist = rTabItem.Count() ?
2235 [ # # ][ # # ]: 0 : static_cast<sal_uInt16>(rTabItem[0].GetTabPos()) : 1134;
2236 [ # # ][ # # ]: 0 : const SwPosition &rStt = *rPam.Start(), &rEnd = *rPam.End();
2237 [ # # ]: 0 : SwNodeIndex aIdx( rStt.nNode );
2238 [ # # ]: 0 : while( aIdx <= rEnd.nNode )
2239 : : {
2240 : 0 : SwTxtNode* pTNd = aIdx.GetNode().GetTxtNode();
2241 [ # # ]: 0 : if( pTNd )
2242 : : {
2243 [ # # ][ # # ]: 0 : SvxLRSpaceItem aLS( (SvxLRSpaceItem&)pTNd->SwCntntNode::GetAttr( RES_LR_SPACE ) );
2244 : :
2245 : : // #i93873# See also lcl_MergeListLevelIndentAsLRSpaceItem in thints.cxx
2246 [ # # ][ # # ]: 0 : if ( pTNd->AreListLevelIndentsApplicable() )
2247 : : {
2248 [ # # ]: 0 : const SwNumRule* pRule = pTNd->GetNumRule();
2249 [ # # ]: 0 : if ( pRule )
2250 : : {
2251 [ # # ]: 0 : const int nListLevel = pTNd->GetActualListLevel();
2252 [ # # ]: 0 : if ( nListLevel >= 0 )
2253 : : {
2254 [ # # ]: 0 : const SwNumFmt& rFmt = pRule->Get(static_cast<sal_uInt16>(nListLevel));
2255 [ # # ][ # # ]: 0 : if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
2256 : : {
2257 [ # # ][ # # ]: 0 : aLS.SetTxtLeft( rFmt.GetIndentAt() );
2258 [ # # ][ # # ]: 0 : aLS.SetTxtFirstLineOfst( static_cast<short>(rFmt.GetFirstLineIndent()) );
2259 : : }
2260 : : }
2261 : : }
2262 : : }
2263 : :
2264 : 0 : long nNext = aLS.GetTxtLeft();
2265 [ # # ]: 0 : if( bModulus )
2266 : 0 : nNext = ( nNext / nDefDist ) * nDefDist;
2267 : :
2268 [ # # ]: 0 : if( bRight )
2269 : 0 : nNext += nDefDist;
2270 : : else
2271 : 0 : nNext -= nDefDist;
2272 : :
2273 [ # # ]: 0 : aLS.SetTxtLeft( nNext );
2274 : :
2275 [ # # ]: 0 : SwRegHistory aRegH( pTNd, *pTNd, pHistory );
2276 [ # # ][ # # ]: 0 : pTNd->SetAttr( aLS );
[ # # ]
2277 : : }
2278 [ # # ]: 0 : aIdx++;
2279 : : }
2280 [ # # ][ # # ]: 0 : SetModified();
2281 : 0 : }
2282 : :
2283 : 1966 : sal_Bool SwDoc::DontExpandFmt( const SwPosition& rPos, sal_Bool bFlag )
2284 : : {
2285 : 1966 : sal_Bool bRet = sal_False;
2286 : 1966 : SwTxtNode* pTxtNd = rPos.nNode.GetNode().GetTxtNode();
2287 [ + - ]: 1966 : if( pTxtNd )
2288 : : {
2289 : 1966 : bRet = pTxtNd->DontExpandFmt( rPos.nContent, bFlag );
2290 [ - + ][ - + ]: 1966 : if( bRet && GetIDocumentUndoRedo().DoesUndo() )
[ + + ]
2291 : : {
2292 [ # # ]: 0 : GetIDocumentUndoRedo().AppendUndo( new SwUndoDontExpandFmt(rPos) );
2293 : : }
2294 : : }
2295 : 1966 : return bRet;
2296 : : }
2297 : :
2298 : 1491 : SwTableBoxFmt* SwDoc::MakeTableBoxFmt()
2299 : : {
2300 : : SwTableBoxFmt* pFmt = new SwTableBoxFmt( GetAttrPool(), aEmptyStr,
2301 [ + - ]: 1491 : pDfltFrmFmt );
2302 : 1491 : SetModified();
2303 : 1491 : return pFmt;
2304 : : }
2305 : :
2306 : 313 : SwTableLineFmt* SwDoc::MakeTableLineFmt()
2307 : : {
2308 : : SwTableLineFmt* pFmt = new SwTableLineFmt( GetAttrPool(), aEmptyStr,
2309 [ + - ]: 313 : pDfltFrmFmt );
2310 : 313 : SetModified();
2311 : 313 : return pFmt;
2312 : : }
2313 : :
2314 : 1320 : void SwDoc::_CreateNumberFormatter()
2315 : : {
2316 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722", "SwDoc::_CreateNumberFormatter" );
2317 : :
2318 : : OSL_ENSURE( !pNumberFormatter, "is already there" );
2319 : :
2320 : :
2321 : 1320 : LanguageType eLang = LANGUAGE_SYSTEM;
2322 : :
2323 [ + - ]: 1320 : Reference< XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
2324 [ + - ][ + - ]: 1320 : pNumberFormatter = new SvNumberFormatter( xMSF, eLang );
2325 : 1320 : pNumberFormatter->SetEvalDateFormat( NF_EVALDATEFORMAT_FORMAT_INTL );
2326 [ + - ][ + - ]: 1320 : pNumberFormatter->SetYear2000(static_cast<sal_uInt16>(::utl::MiscCfg().GetYear2000()));
[ + - ][ + - ]
2327 : :
2328 : 1320 : }
2329 : :
2330 : 32 : SwTblNumFmtMerge::SwTblNumFmtMerge( const SwDoc& rSrc, SwDoc& rDest )
2331 : 32 : : pNFmt( 0 )
2332 : : {
2333 : : // a different Doc -> Number formatter needs to be merged
2334 : : SvNumberFormatter* pN;
2335 [ + + ][ + + ]: 32 : if( &rSrc != &rDest && 0 != ( pN = ((SwDoc&)rSrc).GetNumberFormatter( sal_False ) ))
[ + + ]
2336 : 2 : ( pNFmt = rDest.GetNumberFormatter( sal_True ))->MergeFormatter( *pN );
2337 : :
2338 [ + + ]: 32 : if( &rSrc != &rDest )
2339 : 14 : ((SwGetRefFieldType*)rSrc.GetSysFldType( RES_GETREFFLD ))->
2340 : 14 : MergeWithOtherDoc( rDest );
2341 : 32 : }
2342 : :
2343 : 32 : SwTblNumFmtMerge::~SwTblNumFmtMerge()
2344 : : {
2345 [ + + ]: 32 : if( pNFmt )
2346 : 2 : pNFmt->ClearMergeTable();
2347 : 32 : }
2348 : :
2349 : :
2350 : 0 : void SwDoc::SetTxtFmtCollByAutoFmt( const SwPosition& rPos, sal_uInt16 nPoolId,
2351 : : const SfxItemSet* pSet )
2352 : : {
2353 [ # # ]: 0 : SwPaM aPam( rPos );
2354 : 0 : SwTxtNode* pTNd = rPos.nNode.GetNode().GetTxtNode();
2355 : :
2356 [ # # ][ # # ]: 0 : if( mbIsAutoFmtRedline && pTNd )
2357 : : {
2358 : : // create the redline object
2359 : 0 : const SwTxtFmtColl& rColl = *pTNd->GetTxtColl();
2360 [ # # ][ # # ]: 0 : SwRedline* pRedl = new SwRedline( nsRedlineType_t::REDLINE_FMTCOLL, aPam );
2361 [ # # ]: 0 : pRedl->SetMark();
2362 : :
2363 : : // Only those items that are not set by the Set again in the Node
2364 : : // are of interest. Thus, we take the difference.
2365 : 0 : SwRedlineExtraData_FmtColl aExtraData( rColl.GetName(),
2366 [ # # ]: 0 : rColl.GetPoolFmtId() );
2367 [ # # ][ # # ]: 0 : if( pSet && pTNd->HasSwAttrSet() )
[ # # ][ # # ]
2368 : : {
2369 [ # # ][ # # ]: 0 : SfxItemSet aTmp( *pTNd->GetpSwAttrSet() );
2370 [ # # ]: 0 : aTmp.Differentiate( *pSet );
2371 : : // we handle the adjust item seperately
2372 : : const SfxPoolItem* pItem;
2373 [ # # ][ # # ]: 0 : if( SFX_ITEM_SET == pTNd->GetpSwAttrSet()->GetItemState(
2374 [ # # ]: 0 : RES_PARATR_ADJUST, sal_False, &pItem ))
2375 [ # # ]: 0 : aTmp.Put( *pItem );
2376 [ # # ][ # # ]: 0 : aExtraData.SetItemSet( aTmp );
2377 : : }
2378 [ # # ]: 0 : pRedl->SetExtraData( &aExtraData );
2379 : :
2380 : : //TODO: Undo is still missing!
2381 [ # # ][ # # ]: 0 : AppendRedline( pRedl, true );
2382 : : }
2383 : :
2384 [ # # ][ # # ]: 0 : SetTxtFmtColl( aPam, GetTxtCollFromPool( nPoolId ) );
2385 : :
2386 [ # # ][ # # ]: 0 : if( pSet && pTNd && pSet->Count() )
[ # # ][ # # ]
2387 : : {
2388 [ # # ]: 0 : aPam.SetMark();
2389 [ # # ][ # # ]: 0 : aPam.GetMark()->nContent.Assign( pTNd, pTNd->GetTxt().Len() );
2390 [ # # ]: 0 : InsertItemSet( aPam, *pSet, 0 );
2391 [ # # ]: 0 : }
2392 : 0 : }
2393 : :
2394 : 0 : void SwDoc::SetFmtItemByAutoFmt( const SwPaM& rPam, const SfxItemSet& rSet )
2395 : : {
2396 : 0 : SwTxtNode* pTNd = rPam.GetPoint()->nNode.GetNode().GetTxtNode();
2397 : :
2398 : 0 : RedlineMode_t eOld = GetRedlineMode();
2399 : :
2400 [ # # ][ # # ]: 0 : if( mbIsAutoFmtRedline && pTNd )
2401 : : {
2402 : : // create the redline object
2403 [ # # ][ # # ]: 0 : SwRedline* pRedl = new SwRedline( nsRedlineType_t::REDLINE_FORMAT, rPam );
2404 [ # # ]: 0 : if( !pRedl->HasMark() )
2405 [ # # ]: 0 : pRedl->SetMark();
2406 : :
2407 : : // Only those items that are not set by the Set again in the Node
2408 : : // are of interest. Thus, we take the difference.
2409 [ # # ]: 0 : SwRedlineExtraData_Format aExtraData( rSet );
2410 : :
2411 [ # # ]: 0 : pRedl->SetExtraData( &aExtraData );
2412 : :
2413 : : //TODO: Undo is still missing!
2414 [ # # ]: 0 : AppendRedline( pRedl, true );
2415 : :
2416 [ # # ][ # # ]: 0 : SetRedlineMode_intern( (RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE));
2417 : : }
2418 : :
2419 : 0 : InsertItemSet( rPam, rSet, nsSetAttrMode::SETATTR_DONTEXPAND );
2420 : 0 : SetRedlineMode_intern( eOld );
2421 : 0 : }
2422 : :
2423 : 4502 : void SwDoc::ChgFmt(SwFmt & rFmt, const SfxItemSet & rSet)
2424 : : {
2425 [ + + ]: 4502 : if (GetIDocumentUndoRedo().DoesUndo())
2426 : : {
2427 : : // copying <rSet> to <aSet>
2428 [ + - ]: 298 : SfxItemSet aSet(rSet);
2429 : : // remove from <aSet> all items, which are already set at the format
2430 [ + - ]: 298 : aSet.Differentiate(rFmt.GetAttrSet());
2431 : : // <aSet> contains now all *new* items for the format
2432 : :
2433 : : // copying current format item set to <aOldSet>
2434 [ + - ]: 298 : SfxItemSet aOldSet(rFmt.GetAttrSet());
2435 : : // insert new items into <aOldSet>
2436 [ + - ]: 298 : aOldSet.Put(aSet);
2437 : : // invalidate all new items in <aOldSet> in order to clear these items,
2438 : : // if the undo action is triggered.
2439 : : {
2440 [ + - ]: 298 : SfxItemIter aIter(aSet);
2441 : :
2442 : 298 : const SfxPoolItem * pItem = aIter.FirstItem();
2443 [ + + ]: 540 : while (pItem != NULL)
2444 : : {
2445 [ + - ]: 242 : aOldSet.InvalidateItem(pItem->Which());
2446 : :
2447 [ + - ]: 242 : pItem = aIter.NextItem();
2448 [ + - ]: 298 : }
2449 : : }
2450 : :
2451 [ + - ][ + - ]: 298 : SwUndo * pUndo = new SwUndoFmtAttr(aOldSet, rFmt);
2452 : :
2453 [ + - ][ + - ]: 298 : GetIDocumentUndoRedo().AppendUndo(pUndo);
[ + - ][ + - ]
2454 : : }
2455 : :
2456 : 4502 : rFmt.SetFmtAttr(rSet);
2457 : 4502 : }
2458 : :
2459 : 8 : void SwDoc::RenameFmt(SwFmt & rFmt, const String & sNewName,
2460 : : sal_Bool bBroadcast)
2461 : : {
2462 : 8 : SfxStyleFamily eFamily = SFX_STYLE_FAMILY_ALL;
2463 : :
2464 [ + - ]: 8 : if (GetIDocumentUndoRedo().DoesUndo())
2465 : : {
2466 : 8 : SwUndo * pUndo = NULL;
2467 : :
2468 [ - + - + ]: 8 : switch (rFmt.Which())
2469 : : {
2470 : : case RES_CHRFMT:
2471 [ # # ]: 0 : pUndo = new SwUndoRenameCharFmt(rFmt.GetName(), sNewName, this);
2472 : 0 : eFamily = SFX_STYLE_FAMILY_PARA;
2473 : 0 : break;
2474 : : case RES_TXTFMTCOLL:
2475 [ + - ]: 4 : pUndo = new SwUndoRenameFmtColl(rFmt.GetName(), sNewName, this);
2476 : 4 : eFamily = SFX_STYLE_FAMILY_CHAR;
2477 : 4 : break;
2478 : : case RES_FRMFMT:
2479 [ # # ]: 0 : pUndo = new SwUndoRenameFrmFmt(rFmt.GetName(), sNewName, this);
2480 : 0 : eFamily = SFX_STYLE_FAMILY_FRAME;
2481 : 0 : break;
2482 : :
2483 : : default:
2484 : 4 : break;
2485 : : }
2486 : :
2487 [ + + ]: 8 : if (pUndo)
2488 : : {
2489 : 4 : GetIDocumentUndoRedo().AppendUndo(pUndo);
2490 : : }
2491 : : }
2492 : :
2493 : 8 : rFmt.SetName(sNewName);
2494 : :
2495 [ - + ]: 8 : if (bBroadcast)
2496 [ # # ]: 0 : BroadcastStyleOperation(sNewName, eFamily, SFX_STYLESHEET_MODIFIED);
2497 : 8 : }
2498 : :
2499 : : // #i69627#
2500 : : namespace docfunc
2501 : : {
2502 : 17 : bool HasOutlineStyleToBeWrittenAsNormalListStyle( SwDoc& rDoc )
2503 : : {
2504 : : // If a parent paragraph style of one of the parargraph styles, which
2505 : : // are assigned to the list levels of the outline style, has a list style
2506 : : // set or inherits a list style from its parent style, the outline style
2507 : : // has to be written as a normal list style to the OpenDocument file
2508 : : // format or the OpenOffice.org file format.
2509 : 17 : bool bRet( false );
2510 : :
2511 : 17 : const SwTxtFmtColls* pTxtFmtColls( rDoc.GetTxtFmtColls() );
2512 [ + - ]: 17 : if ( pTxtFmtColls )
2513 : : {
2514 : 17 : const sal_uInt16 nCount = pTxtFmtColls->size();
2515 [ + + ]: 149 : for ( sal_uInt16 i = 0; i < nCount; ++i )
2516 : : {
2517 : 132 : SwTxtFmtColl* pTxtFmtColl = (*pTxtFmtColls)[i];
2518 : :
2519 [ + - ]: 247 : if ( pTxtFmtColl->IsDefault() ||
[ + + + - ]
2520 : 115 : ! pTxtFmtColl->IsAssignedToListLevelOfOutlineStyle() ) //<-end,zhaojianwei
2521 : : {
2522 : 132 : continue;
2523 : : }
2524 : :
2525 : : const SwTxtFmtColl* pParentTxtFmtColl =
2526 [ # # ]: 0 : dynamic_cast<const SwTxtFmtColl*>( pTxtFmtColl->DerivedFrom());
2527 [ # # ]: 0 : if ( !pParentTxtFmtColl )
2528 : 0 : continue;
2529 : :
2530 [ # # ]: 0 : if ( SFX_ITEM_SET == pParentTxtFmtColl->GetItemState( RES_PARATR_NUMRULE ) )
2531 : : {
2532 : : // #i106218# consider that the outline style is set
2533 : 0 : const SwNumRuleItem& rDirectItem = pParentTxtFmtColl->GetNumRule();
2534 [ # # ]: 0 : if ( rDirectItem.GetValue() != rDoc.GetOutlineNumRule()->GetName() )
2535 : : {
2536 : 0 : bRet = true;
2537 : 0 : break;
2538 : : }
2539 : : }
2540 : : }
2541 : :
2542 : : }
2543 : 17 : return bRet;
2544 : : }
2545 : : }
2546 : :
2547 [ - + ]: 11926 : SwFmtsBase::~SwFmtsBase() {}
2548 : :
2549 : 234 : sal_uInt16 SwFrmFmts::GetPos(const SwFrmFmt* p) const
2550 : : {
2551 [ + - ]: 234 : const_iterator it = std::find(begin(), end(), p);
2552 [ + - ][ + + ]: 234 : return it == end() ? USHRT_MAX : it - begin();
[ + - ][ + + ]
[ # # ]
2553 : : }
2554 : :
2555 : 96 : bool SwFrmFmts::Contains(const SwFrmFmt* p) const
2556 : : {
2557 [ + - ][ + - ]: 96 : return std::find(begin(), end(), p) != end();
2558 : : }
2559 : :
2560 : 6094 : SwFrmFmts::~SwFrmFmts()
2561 : : {
2562 [ + - ][ + - ]: 6811 : for(const_iterator it = begin(); it != end(); ++it)
[ + + ]
2563 [ + - ][ + - ]: 717 : delete *it;
2564 [ - + ]: 10468 : }
2565 : :
2566 : 2 : sal_uInt16 SwCharFmts::GetPos(const SwCharFmt* p) const
2567 : : {
2568 [ + - ]: 2 : const_iterator it = std::find(begin(), end(), p);
2569 [ + - ][ - + ]: 2 : return it == end() ? USHRT_MAX : it - begin();
[ + - ][ + - ]
[ # # ]
2570 : : }
2571 : :
2572 : 0 : bool SwCharFmts::Contains(const SwCharFmt* p) const
2573 : : {
2574 [ # # ][ # # ]: 0 : return std::find(begin(), end(), p) != end();
2575 : : }
2576 : :
2577 : 1458 : SwCharFmts::~SwCharFmts()
2578 : : {
2579 [ + - ][ + - ]: 2418 : for(const_iterator it = begin(); it != end(); ++it)
[ + - ][ + + ]
2580 [ + - ][ + - ]: 960 : delete *it;
[ + - ]
2581 [ - + ]: 2916 : }
2582 : :
2583 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|