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 <doc.hxx>
30 : : #include <fmtcolfunc.hxx>
31 : : #include <frame.hxx>
32 : : #include <format.hxx>
33 : : #include <hintids.hxx>
34 : : #include <hints.hxx>
35 : : #include <paratr.hxx>
36 : : #include <rtl/strbuf.hxx>
37 : : #include <swcache.hxx>
38 : :
39 [ - + ][ + + ]: 306429 : TYPEINIT1( SwFmt, SwClient );
40 : :
41 : 9539 : SwFmt::SwFmt( SwAttrPool& rPool, const sal_Char* pFmtNm,
42 : : const sal_uInt16* pWhichRanges, SwFmt *pDrvdFrm,
43 : : sal_uInt16 nFmtWhich )
44 : : : SwModify( pDrvdFrm ),
45 : : aSet( rPool, pWhichRanges ),
46 : : nWhichId( nFmtWhich ),
47 : : nFmtId( 0 ),
48 : : nPoolFmtId( USHRT_MAX ),
49 : : nPoolHelpId( USHRT_MAX ),
50 [ + - ][ + - ]: 9539 : nPoolHlpFileId( UCHAR_MAX )
51 : : {
52 [ + - ]: 9539 : aFmtName.AssignAscii( pFmtNm );
53 : 9539 : bWritten = bFmtInDTOR = bAutoUpdateFmt = sal_False; // LAYER_IMPL
54 : 9539 : bAutoFmt = sal_True;
55 : :
56 [ + + ]: 9539 : if( pDrvdFrm )
57 : 3343 : aSet.SetParent( &pDrvdFrm->aSet );
58 : 9539 : }
59 : :
60 : 23025 : SwFmt::SwFmt( SwAttrPool& rPool, const String& rFmtNm,
61 : : const sal_uInt16* pWhichRanges, SwFmt* pDrvdFrm,
62 : : sal_uInt16 nFmtWhich )
63 : : : SwModify( pDrvdFrm ),
64 : : aFmtName( rFmtNm ),
65 : : aSet( rPool, pWhichRanges ),
66 : : nWhichId( nFmtWhich ),
67 : : nFmtId( 0 ),
68 : : nPoolFmtId( USHRT_MAX ),
69 : : nPoolHelpId( USHRT_MAX ),
70 [ + - ][ + - ]: 23025 : nPoolHlpFileId( UCHAR_MAX )
71 : : {
72 : 23025 : bWritten = bFmtInDTOR = bAutoUpdateFmt = sal_False; // LAYER_IMPL
73 : 23025 : bAutoFmt = sal_True;
74 : :
75 [ + - ]: 23025 : if( pDrvdFrm )
76 : 23025 : aSet.SetParent( &pDrvdFrm->aSet );
77 : 23025 : }
78 : :
79 : 2979 : SwFmt::SwFmt( const SwFmt& rFmt )
80 : 2979 : : SwModify( rFmt.DerivedFrom() ),
81 : : aFmtName( rFmt.aFmtName ),
82 : : aSet( rFmt.aSet ),
83 : : nWhichId( rFmt.nWhichId ),
84 : : nFmtId( 0 ),
85 : 2979 : nPoolFmtId( rFmt.GetPoolFmtId() ),
86 : 2979 : nPoolHelpId( rFmt.GetPoolHelpId() ),
87 [ + - ][ + - ]: 5958 : nPoolHlpFileId( rFmt.GetPoolHlpFileId() )
88 : : {
89 : 2979 : bWritten = bFmtInDTOR = sal_False; // LAYER_IMPL
90 : 2979 : bAutoFmt = rFmt.bAutoFmt;
91 : 2979 : bAutoUpdateFmt = rFmt.bAutoUpdateFmt;
92 : :
93 [ + - ]: 2979 : if( rFmt.DerivedFrom() )
94 : 2979 : aSet.SetParent( &rFmt.DerivedFrom()->aSet );
95 : : // a few special treatments for attributes
96 [ + - ]: 2979 : aSet.SetModifyAtAttr( this );
97 : 2979 : }
98 : :
99 : 1205 : SwFmt &SwFmt::operator=(const SwFmt& rFmt)
100 : : {
101 : 1205 : nWhichId = rFmt.nWhichId;
102 : 1205 : nPoolFmtId = rFmt.GetPoolFmtId();
103 : 1205 : nPoolHelpId = rFmt.GetPoolHelpId();
104 : 1205 : nPoolHlpFileId = rFmt.GetPoolHlpFileId();
105 : :
106 [ - + ]: 1205 : if ( IsInCache() )
107 : : {
108 [ # # ]: 0 : SwFrm::GetCache().Delete( this );
109 : 0 : SetInCache( sal_False );
110 : : }
111 : 1205 : SetInSwFntCache( sal_False );
112 : :
113 : : // copy only array with attributes delta
114 [ + - ]: 1205 : SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
115 [ + - ]: 1205 : aNew( *aSet.GetPool(), aSet.GetRanges() );
116 [ + - ]: 1205 : aSet.Intersect_BC( rFmt.aSet, &aOld, &aNew );
117 [ + - ]: 1205 : aSet.Put_BC( rFmt.aSet, &aOld, &aNew );
118 : :
119 : : // a few special treatments for attributes
120 [ + - ]: 1205 : aSet.SetModifyAtAttr( this );
121 : :
122 : : // create PoolItem attribute for Modify
123 [ + + ]: 1205 : if( aOld.Count() )
124 : : {
125 [ + - ]: 1145 : SwAttrSetChg aChgOld( aSet, aOld );
126 [ + - ]: 1145 : SwAttrSetChg aChgNew( aSet, aNew );
127 [ + - ][ + - ]: 1145 : ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
[ + - ]
128 : : }
129 : :
130 [ - + ]: 1205 : if( GetRegisteredIn() != rFmt.GetRegisteredIn() )
131 : : {
132 [ # # ]: 0 : if( GetRegisteredIn() )
133 [ # # ]: 0 : GetRegisteredInNonConst()->Remove(this);
134 [ # # ]: 0 : if( rFmt.GetRegisteredIn() )
135 : : {
136 [ # # ]: 0 : const_cast<SwFmt&>(rFmt).GetRegisteredInNonConst()->Add(this);
137 : 0 : aSet.SetParent( &rFmt.aSet );
138 : : }
139 : : else
140 : : {
141 : 0 : aSet.SetParent( 0 );
142 : : }
143 : : }
144 : 1205 : bAutoFmt = rFmt.bAutoFmt;
145 : 1205 : bAutoUpdateFmt = rFmt.bAutoUpdateFmt;
146 [ + - ][ + - ]: 1205 : return *this;
147 : : }
148 : :
149 : 221 : void SwFmt::SetName( const String& rNewName, sal_Bool bBroadcast )
150 : : {
151 : : OSL_ENSURE( !IsDefault(), "SetName: Defaultformat" );
152 [ + + ]: 221 : if( bBroadcast )
153 : : {
154 [ + - ]: 121 : SwStringMsgPoolItem aOld( RES_NAME_CHANGED, aFmtName );
155 [ + - ]: 121 : SwStringMsgPoolItem aNew( RES_NAME_CHANGED, rNewName );
156 [ + - ]: 121 : aFmtName = rNewName;
157 [ + - ][ + - ]: 121 : ModifyNotification( &aOld, &aNew );
[ + - ]
158 : : }
159 : : else
160 : : {
161 : 100 : aFmtName = rNewName;
162 : : }
163 : 221 : }
164 : :
165 : : /** Copy attributes
166 : :
167 : : This function is called in every Copy-Ctor for copying the attributes.
168 : : The latter can be only copied as soon as the derived class exists since
169 : : for setting them the Which() function is called and that has the default
170 : : value of 0 in the base class and is then overridden by the derived class.
171 : :
172 : : If we copy over multiple documents then the new document has to be provided
173 : : in which <this> is defined. Currently this is important for DropCaps
174 : : because that contains data that needs to be copied deeply.
175 : : */
176 : 132 : void SwFmt::CopyAttrs( const SwFmt& rFmt, sal_Bool bReplace )
177 : : {
178 : : // copy only array with attributes delta
179 [ - + ]: 132 : if ( IsInCache() )
180 : : {
181 : 0 : SwFrm::GetCache().Delete( this );
182 : 0 : SetInCache( sal_False );
183 : : }
184 : 132 : SetInSwFntCache( sal_False );
185 : :
186 : : // special treatments for some attributes
187 : 132 : SwAttrSet* pChgSet = (SwAttrSet*)&rFmt.aSet;
188 : :
189 [ - + ]: 132 : if( !bReplace ) // refresh only those that are not set?
190 : : {
191 [ # # ]: 0 : if( pChgSet == (SwAttrSet*)&rFmt.aSet )
192 [ # # ]: 0 : pChgSet = new SwAttrSet( rFmt.aSet );
193 : 0 : pChgSet->Differentiate( aSet );
194 : : }
195 : :
196 : : // copy only array with attributes delta
197 [ - + ]: 132 : if( pChgSet->GetPool() != aSet.GetPool() )
198 : 0 : pChgSet->CopyToModify( *this );
199 : : else
200 : : {
201 [ + - ]: 132 : SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
202 [ + - ]: 132 : aNew( *aSet.GetPool(), aSet.GetRanges() );
203 : :
204 [ + - ][ + - ]: 132 : if ( 0 != aSet.Put_BC( *pChgSet, &aOld, &aNew ) )
205 : : {
206 : : // a few special treatments for attributes
207 [ + - ]: 132 : aSet.SetModifyAtAttr( this );
208 : :
209 [ + - ]: 132 : SwAttrSetChg aChgOld( aSet, aOld );
210 [ + - ]: 132 : SwAttrSetChg aChgNew( aSet, aNew );
211 [ + - ][ + - ]: 132 : ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
[ + - ]
212 [ + - ][ + - ]: 132 : }
213 : : }
214 : :
215 [ - + ]: 132 : if( pChgSet != (SwAttrSet*)&rFmt.aSet ) // was a Set created?
216 [ # # ]: 0 : delete pChgSet;
217 : 132 : }
218 : :
219 [ + - ][ + - ]: 33563 : SwFmt::~SwFmt()
220 : : {
221 : : // This happens at a ObjectDying message. Thus put all dependent
222 : : // ones on DerivedFrom.
223 [ + + ]: 33563 : if( GetDepends() )
224 : : {
225 : : OSL_ENSURE( DerivedFrom(), "SwFmt::~SwFmt: Def dependents!" );
226 : :
227 : 4022 : bFmtInDTOR = sal_True;
228 : :
229 : 4022 : SwFmt* pParentFmt = DerivedFrom();
230 [ + + ]: 4022 : if( !pParentFmt )
231 : : {
232 : : OSL_FAIL(rtl::OStringBuffer(
233 : : RTL_CONSTASCII_STRINGPARAM("~SwFmt: parent format missing from: ")).
234 : : append(rtl::OUStringToOString(GetName(), osl_getThreadTextEncoding())).getStr());
235 : : }
236 : : else
237 : : {
238 [ + + ]: 9012 : while( GetDepends() )
239 : : {
240 [ + - ]: 5036 : SwFmtChg aOldFmt( this );
241 [ + - ]: 5036 : SwFmtChg aNewFmt( pParentFmt );
242 : 5036 : SwClient* pDepend = (SwClient*)GetDepends();
243 [ + - ]: 5036 : pParentFmt->Add( pDepend );
244 [ + - ]: 5036 : pDepend->ModifyNotification( &aOldFmt, &aNewFmt );
245 [ + - ][ + - ]: 5036 : }
246 : : }
247 : : }
248 [ - + ]: 33563 : }
249 : :
250 : 222644 : void SwFmt::Modify( const SfxPoolItem* pOldValue, const SfxPoolItem* pNewValue )
251 : : {
252 : 222644 : sal_Bool bContinue = sal_True; // sal_True = pass on to dependent ones
253 : :
254 : : sal_uInt16 nWhich = pOldValue ? pOldValue->Which() :
255 [ + - ][ # # ]: 222644 : pNewValue ? pNewValue->Which() : 0 ;
256 [ - - + + : 222644 : switch( nWhich )
- + ]
257 : : {
258 : 0 : case 0: break; // Which-Id of 0?
259 : :
260 : : case RES_OBJECTDYING :
261 : : {
262 : : // If the dying object is the parent format of this format so
263 : : // attach this to the parent of the parent
264 : 0 : SwFmt* pFmt = (SwFmt*) ((SwPtrMsgPoolItem*)pNewValue)->pObject;
265 : :
266 : : // do not move if this is the topmost format
267 [ # # ][ # # ]: 0 : if( GetRegisteredIn() && GetRegisteredIn() == pFmt )
[ # # ]
268 : : {
269 [ # # ]: 0 : if( pFmt->GetRegisteredIn() )
270 : : {
271 : : // if parent so register in new parent
272 : 0 : pFmt->DerivedFrom()->Add( this );
273 : 0 : aSet.SetParent( &DerivedFrom()->aSet );
274 : : }
275 : : else
276 : : {
277 : : // otherwise de-register at least from dying one
278 : 0 : DerivedFrom()->Remove( this );
279 : 0 : aSet.SetParent( 0 );
280 : : }
281 : : }
282 : : }
283 : 0 : break;
284 : : case RES_ATTRSET_CHG:
285 [ + + ]: 210735 : if( ((SwAttrSetChg*)pOldValue)->GetTheChgdSet() != &aSet )
286 : : {
287 : : // pass only those that are not set
288 [ + - ]: 138292 : SwAttrSetChg aOld( *(SwAttrSetChg*)pOldValue );
289 [ + - ]: 138292 : SwAttrSetChg aNew( *(SwAttrSetChg*)pNewValue );
290 : :
291 [ + - ]: 138292 : aOld.GetChgSet()->Differentiate( aSet );
292 [ + - ]: 138292 : aNew.GetChgSet()->Differentiate( aSet );
293 : :
294 [ + + ]: 138292 : if( aNew.Count() )
295 [ + - ]: 135517 : NotifyClients( &aOld, &aNew );
296 [ + - ][ + - ]: 138292 : bContinue = sal_False;
297 : : }
298 : 210735 : break;
299 : : case RES_FMT_CHG:
300 : : // if the format parent will be moved so register my attribute set at
301 : : // the new one
302 : :
303 : : // skip my own Modify
304 [ + + + + ]: 19585 : if( ((SwFmtChg*)pOldValue)->pChangedFmt != this &&
[ + + ]
305 : 8157 : ((SwFmtChg*)pNewValue)->pChangedFmt == DerivedFrom() )
306 : : {
307 : : // attach Set to new parent
308 [ + - ]: 2046 : aSet.SetParent( DerivedFrom() ? &DerivedFrom()->aSet : 0 );
309 : : }
310 : 11428 : break;
311 : : case RES_RESET_FMTWRITTEN:
312 : : {
313 : 0 : ResetWritten();
314 : :
315 : : // mba: here we don't use the additional stuff from NotifyClients().
316 : : // should we?!
317 : : // mba: move the code that ignores this event to the clients
318 : :
319 : : // pass Hint only to dependent formats (no Frames)
320 : 0 : ModifyBroadcast( pOldValue, pNewValue, TYPE(SwFmt) );
321 : 0 : bContinue = sal_False;
322 : : }
323 : 0 : break;
324 : : default:
325 : : {
326 : : // attribute is defined in this format
327 [ - + ]: 481 : if( SFX_ITEM_SET == aSet.GetItemState( nWhich, sal_False ))
328 : : {
329 : : // DropCaps might come into this block
330 : : OSL_ENSURE( RES_PARATR_DROP == nWhich, "Modify was sent without sender" );
331 : 0 : bContinue = sal_False;
332 : : }
333 : : }
334 : : }
335 : :
336 [ + + ]: 222644 : if( bContinue )
337 : : {
338 : : // walk over all dependent formats
339 : 84352 : NotifyClients( pOldValue, pNewValue );
340 : : }
341 : 222644 : }
342 : :
343 : 2174 : sal_Bool SwFmt::SetDerivedFrom(SwFmt *pDerFrom)
344 : : {
345 [ + + ]: 2174 : if ( pDerFrom )
346 : : {
347 : 1574 : const SwFmt* pFmt = pDerFrom;
348 [ + + ]: 5065 : while ( pFmt != 0 )
349 : : {
350 [ - + ]: 3491 : if ( pFmt == this )
351 : 0 : return sal_False;
352 : :
353 : 3491 : pFmt=pFmt->DerivedFrom();
354 : : }
355 : : }
356 : : else
357 : : {
358 : : // nothing provided, search for Dflt format
359 : 600 : pDerFrom = this;
360 [ + + ]: 1680 : while ( pDerFrom->DerivedFrom() )
361 : 1080 : pDerFrom = pDerFrom->DerivedFrom();
362 : : }
363 [ + + ][ - + ]: 2174 : if ( (pDerFrom == DerivedFrom()) || (pDerFrom == this) )
[ + + ]
364 : 383 : return sal_False;
365 : :
366 : : OSL_ENSURE( Which()==pDerFrom->Which()
367 : : || ( Which()==RES_CONDTXTFMTCOLL && pDerFrom->Which()==RES_TXTFMTCOLL)
368 : : || ( Which()==RES_TXTFMTCOLL && pDerFrom->Which()==RES_CONDTXTFMTCOLL)
369 : : || ( Which()==RES_FLYFRMFMT && pDerFrom->Which()==RES_FRMFMT ),
370 : : "SetDerivedFrom: derive apples from oranges?");
371 : :
372 [ + + ]: 1791 : if ( IsInCache() )
373 : : {
374 [ + - ]: 6 : SwFrm::GetCache().Delete( this );
375 : 6 : SetInCache( sal_False );
376 : : }
377 : 1791 : SetInSwFntCache( sal_False );
378 : :
379 [ + - ]: 1791 : pDerFrom->Add( this );
380 : 1791 : aSet.SetParent( &pDerFrom->aSet );
381 : :
382 [ + - ]: 1791 : SwFmtChg aOldFmt( this );
383 [ + - ]: 1791 : SwFmtChg aNewFmt( this );
384 [ + - ]: 1791 : ModifyNotification( &aOldFmt, &aNewFmt );
385 : :
386 [ + - ][ + - ]: 2174 : return sal_True;
387 : : }
388 : :
389 : 108660 : sal_Bool SwFmt::SetFmtAttr( const SfxPoolItem& rAttr )
390 : : {
391 [ + + ][ - + ]: 108660 : if ( IsInCache() || IsInSwFntCache() )
[ + + ]
392 : : {
393 : 989 : const sal_uInt16 nWhich = rAttr.Which();
394 : 989 : CheckCaching( nWhich );
395 : : }
396 : :
397 : : // if Modify is locked then no modifications will be sent;
398 : : // but call Modify always for FrmFmts
399 : 108660 : sal_Bool bRet = sal_False;
400 : 108660 : const sal_uInt16 nFmtWhich = Which();
401 [ + - ][ + + ]: 215510 : if( IsModifyLocked() ||
[ + + ]
[ + + + + ]
402 : 106850 : ( !GetDepends() &&
403 : : (RES_GRFFMTCOLL == nFmtWhich ||
404 : : RES_TXTFMTCOLL == nFmtWhich ) ) )
405 : : {
406 [ + + ]: 25267 : if( 0 != ( bRet = (0 != aSet.Put( rAttr ))) )
407 : 24751 : aSet.SetModifyAtAttr( this );
408 : : // #i71574#
409 [ + + ][ + + ]: 25267 : if ( nFmtWhich == RES_TXTFMTCOLL && rAttr.Which() == RES_PARATR_NUMRULE )
[ + + ]
410 : : {
411 : 340 : TxtFmtCollFunc::CheckTxtFmtCollForDeletionOfAssignmentToOutlineStyle( this );
412 : : }
413 : : }
414 : : else
415 : : {
416 : : // copy only array with attributes delta
417 [ + - ]: 83393 : SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
418 [ + - ]: 83393 : aNew( *aSet.GetPool(), aSet.GetRanges() );
419 : :
420 [ + - ]: 83393 : bRet = 0 != aSet.Put_BC( rAttr, &aOld, &aNew );
421 [ + + ]: 83393 : if( bRet )
422 : : {
423 : : // some special treatments for attributes
424 [ + - ]: 56167 : aSet.SetModifyAtAttr( this );
425 : :
426 [ + - ]: 56167 : SwAttrSetChg aChgOld( aSet, aOld );
427 [ + - ]: 56167 : SwAttrSetChg aChgNew( aSet, aNew );
428 [ + - ][ + - ]: 56167 : ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
[ + - ]
429 [ + - ][ + - ]: 83393 : }
430 : : }
431 : 108660 : return bRet;
432 : : }
433 : :
434 : 25903 : sal_Bool SwFmt::SetFmtAttr( const SfxItemSet& rSet )
435 : : {
436 [ + + ]: 25903 : if( !rSet.Count() )
437 : 6 : return sal_False;
438 : :
439 [ + + ]: 25897 : if ( IsInCache() )
440 : : {
441 : 169 : SwFrm::GetCache().Delete( this );
442 : 169 : SetInCache( sal_False );
443 : : }
444 : 25897 : SetInSwFntCache( sal_False );
445 : :
446 : : // if Modify is locked then no modifications will be sent;
447 : : // but call Modify always for FrmFmts
448 : 25897 : sal_Bool bRet = sal_False;
449 : 25897 : const sal_uInt16 nFmtWhich = Which();
450 [ + - ][ + + ]: 51705 : if ( IsModifyLocked() ||
[ + + ]
[ + + + + ]
451 : 25808 : ( !GetDepends() &&
452 : : ( RES_GRFFMTCOLL == nFmtWhich ||
453 : : RES_TXTFMTCOLL == nFmtWhich ) ) )
454 : : {
455 [ + + ]: 8045 : if( 0 != ( bRet = (0 != aSet.Put( rSet ))) )
456 : 7145 : aSet.SetModifyAtAttr( this );
457 : : // #i71574#
458 [ + + ]: 8045 : if ( nFmtWhich == RES_TXTFMTCOLL )
459 : : {
460 : 7956 : TxtFmtCollFunc::CheckTxtFmtCollForDeletionOfAssignmentToOutlineStyle( this );
461 : : }
462 : : }
463 : : else
464 : : {
465 [ + - ]: 17852 : SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
466 [ + - ]: 17852 : aNew( *aSet.GetPool(), aSet.GetRanges() );
467 [ + - ]: 17852 : bRet = 0 != aSet.Put_BC( rSet, &aOld, &aNew );
468 [ + + ]: 17852 : if( bRet )
469 : : {
470 : : // some special treatments for attributes
471 [ + - ]: 12696 : aSet.SetModifyAtAttr( this );
472 [ + - ]: 12696 : SwAttrSetChg aChgOld( aSet, aOld );
473 [ + - ]: 12696 : SwAttrSetChg aChgNew( aSet, aNew );
474 [ + - ][ + - ]: 12696 : ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
[ + - ]
475 [ + - ][ + - ]: 17852 : }
476 : : }
477 : 25903 : return bRet;
478 : : }
479 : :
480 : : // remove Hint using nWhich from array with delta
481 : 53765 : sal_Bool SwFmt::ResetFmtAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 )
482 : : {
483 [ + + ]: 53765 : if( !aSet.Count() )
484 : 9796 : return sal_False;
485 : :
486 [ + + ][ - + ]: 43969 : if( !nWhich2 || nWhich2 < nWhich1 )
487 : 42833 : nWhich2 = nWhich1; // then set to 1st ID, only this item
488 : :
489 [ + + ][ - + ]: 43969 : if ( IsInCache() || IsInSwFntCache() )
[ + + ]
490 : : {
491 [ + + ]: 479 : for( sal_uInt16 n = nWhich1; n < nWhich2; ++n )
492 [ + - ]: 80 : CheckCaching( n );
493 : : }
494 : :
495 : : // if Modify is locked then no modifications will be sent
496 [ + + ]: 43969 : if( IsModifyLocked() )
497 : : return 0 != (( nWhich2 == nWhich1 )
498 [ + - ]: 782 : ? aSet.ClearItem( nWhich1 )
499 [ + + ][ + - ]: 2666 : : aSet.ClearItem_BC( nWhich1, nWhich2 ));
500 : :
501 [ + - ]: 42085 : SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
502 [ + - ]: 42085 : aNew( *aSet.GetPool(), aSet.GetRanges() );
503 [ + - ]: 42085 : sal_Bool bRet = 0 != aSet.ClearItem_BC( nWhich1, nWhich2, &aOld, &aNew );
504 [ + + ]: 42085 : if( bRet )
505 : : {
506 [ + - ]: 626 : SwAttrSetChg aChgOld( aSet, aOld );
507 [ + - ]: 626 : SwAttrSetChg aChgNew( aSet, aNew );
508 [ + - ][ + - ]: 626 : ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
[ + - ]
509 : : }
510 [ + - ][ + - ]: 53765 : return bRet;
511 : : }
512 : :
513 : : // #i73790#
514 : 1692 : sal_uInt16 SwFmt::ResetAllFmtAttr()
515 : : {
516 [ + + ]: 1692 : if( !aSet.Count() )
517 : 497 : return 0;
518 : :
519 [ - + ]: 1195 : if ( IsInCache() )
520 : : {
521 [ # # ]: 0 : SwFrm::GetCache().Delete( this );
522 : 0 : SetInCache( sal_False );
523 : : }
524 : 1195 : SetInSwFntCache( sal_False );
525 : :
526 : : // if Modify is locked then no modifications will be sent
527 [ - + ]: 1195 : if( IsModifyLocked() )
528 [ # # ]: 0 : return aSet.ClearItem( 0 );
529 : :
530 [ + - ]: 1195 : SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
531 [ + - ]: 1195 : aNew( *aSet.GetPool(), aSet.GetRanges() );
532 [ + - ]: 1195 : sal_Bool bRet = 0 != aSet.ClearItem_BC( 0, &aOld, &aNew );
533 [ + - ]: 1195 : if( bRet )
534 : : {
535 [ + - ]: 1195 : SwAttrSetChg aChgOld( aSet, aOld );
536 [ + - ]: 1195 : SwAttrSetChg aChgNew( aSet, aNew );
537 [ + - ][ + - ]: 1195 : ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
[ + - ]
538 : : }
539 [ + - ][ + - ]: 1692 : return aNew.Count();
540 : : }
541 : :
542 : 141862 : sal_Bool SwFmt::GetInfo( SfxPoolItem& rInfo ) const
543 : : {
544 : 141862 : sal_Bool bRet = SwModify::GetInfo( rInfo );
545 : 141862 : return bRet;
546 : : }
547 : :
548 : 1910 : void SwFmt::DelDiffs( const SfxItemSet& rSet )
549 : : {
550 [ + + ]: 1910 : if( !aSet.Count() )
551 : : return;
552 : :
553 [ - + ]: 1906 : if ( IsInCache() )
554 : : {
555 [ # # ]: 0 : SwFrm::GetCache().Delete( this );
556 : 0 : SetInCache( sal_False );
557 : : }
558 : 1906 : SetInSwFntCache( sal_False );
559 : :
560 : : // if Modify is locked then no modifications will be sent
561 [ - + ]: 1906 : if( IsModifyLocked() )
562 : : {
563 [ # # ]: 0 : aSet.Intersect( rSet );
564 : : return;
565 : : }
566 : :
567 [ + - ]: 1906 : SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
568 [ + - ]: 1906 : aNew( *aSet.GetPool(), aSet.GetRanges() );
569 [ + - ]: 1906 : sal_Bool bRet = 0 != aSet.Intersect_BC( rSet, &aOld, &aNew );
570 [ + + ]: 1906 : if( bRet )
571 : : {
572 [ + - ]: 838 : SwAttrSetChg aChgOld( aSet, aOld );
573 [ + - ]: 838 : SwAttrSetChg aChgNew( aSet, aNew );
574 [ + - ][ + - ]: 838 : ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
[ + - ]
575 [ + - ][ + - ]: 1910 : }
576 : : }
577 : :
578 : : /** SwFmt::IsBackgroundTransparent
579 : :
580 : : Virtual method to determine, if background of format is transparent.
581 : : Default implementation returns false. Thus, subclasses have to overload
582 : : method, if the specific subclass can have a transparent background.
583 : :
584 : : @return false, default implementation
585 : : */
586 : 0 : sal_Bool SwFmt::IsBackgroundTransparent() const
587 : : {
588 : 0 : return sal_False;
589 : : }
590 : :
591 : : /** SwFmt::IsShadowTransparent
592 : :
593 : : Virtual method to determine, if shadow of format is transparent.
594 : : Default implementation returns false. Thus, subclasses have to overload
595 : : method, if the specific subclass can have a transparent shadow.
596 : :
597 : : @return false, default implementation
598 : : */
599 : 739 : sal_Bool SwFmt::IsShadowTransparent() const
600 : : {
601 : 739 : return sal_False;
602 : : }
603 : :
604 : : /*
605 : : * Document Interface Access
606 : : */
607 [ + - ]: 60477 : const IDocumentSettingAccess* SwFmt::getIDocumentSettingAccess() const { return GetDoc(); }
608 [ + - ]: 3476 : const IDocumentDrawModelAccess* SwFmt::getIDocumentDrawModelAccess() const { return GetDoc(); }
609 [ + - ]: 13149 : IDocumentDrawModelAccess* SwFmt::getIDocumentDrawModelAccess() { return GetDoc(); }
610 [ # # ]: 0 : const IDocumentLayoutAccess* SwFmt::getIDocumentLayoutAccess() const { return GetDoc(); }
611 [ + - ]: 33312 : IDocumentLayoutAccess* SwFmt::getIDocumentLayoutAccess() { return GetDoc(); }
612 [ + - ]: 1976 : IDocumentTimerAccess* SwFmt::getIDocumentTimerAccess() { return GetDoc(); }
613 [ + - ]: 1318 : IDocumentFieldsAccess* SwFmt::getIDocumentFieldsAccess() { return GetDoc(); }
614 [ # # ]: 0 : IDocumentChartDataProviderAccess* SwFmt::getIDocumentChartDataProviderAccess() { return GetDoc(); }
615 : :
616 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|