1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 // MARKER(update_precomp.py): autogen include statement, do not remove 23 #include "precompiled_sw.hxx" 24 25 #include <hintids.hxx> // fuer RES_.. 26 #include <frame.hxx> // fuer AttrCache 27 #include <format.hxx> 28 #include <hints.hxx> // fuer SwFmtChg 29 #include <doc.hxx> 30 #include <paratr.hxx> // fuer SwParaFmt - SwHyphenBug 31 #include <swcache.hxx> 32 #include <fmtcolfunc.hxx> 33 //UUUU 34 #include <unobrushitemhelper.hxx> 35 #include <svx/xdef.hxx> 36 #include <frmatr.hxx> 37 38 TYPEINIT1( SwFmt, SwClient ); //rtti fuer SwFmt 39 40 /************************************************************************* 41 |* SwFmt::SwFmt 42 *************************************************************************/ 43 44 45 SwFmt::SwFmt( SwAttrPool& rPool, const sal_Char* pFmtNm, 46 const sal_uInt16* pWhichRanges, SwFmt *pDrvdFrm, sal_uInt16 nFmtWhich ) 47 : SwModify( pDrvdFrm ), 48 aSet( rPool, pWhichRanges ), 49 nWhichId( nFmtWhich ), 50 nFmtId( 0 ), 51 nPoolFmtId( USHRT_MAX ), 52 nPoolHelpId( USHRT_MAX ), 53 nPoolHlpFileId( UCHAR_MAX ) 54 { 55 aFmtName.AssignAscii( pFmtNm ); 56 bWritten = bFmtInDTOR = bAutoUpdateFmt = sal_False; // LAYER_IMPL 57 bAutoFmt = sal_True; 58 59 if( pDrvdFrm ) 60 aSet.SetParent( &pDrvdFrm->aSet ); 61 } 62 63 64 SwFmt::SwFmt( SwAttrPool& rPool, const String &rFmtNm, 65 const sal_uInt16* pWhichRanges, SwFmt *pDrvdFrm, sal_uInt16 nFmtWhich ) 66 : SwModify( pDrvdFrm ), 67 aFmtName( rFmtNm ), 68 aSet( rPool, pWhichRanges ), 69 nWhichId( nFmtWhich ), 70 nFmtId( 0 ), 71 nPoolFmtId( USHRT_MAX ), 72 nPoolHelpId( USHRT_MAX ), 73 nPoolHlpFileId( UCHAR_MAX ) 74 { 75 bWritten = bFmtInDTOR = bAutoUpdateFmt = sal_False; // LAYER_IMPL 76 bAutoFmt = sal_True; 77 78 if( pDrvdFrm ) 79 aSet.SetParent( &pDrvdFrm->aSet ); 80 } 81 82 83 SwFmt::SwFmt( const SwFmt& rFmt ) 84 : SwModify( rFmt.DerivedFrom() ), 85 aFmtName( rFmt.aFmtName ), 86 aSet( rFmt.aSet ), 87 nWhichId( rFmt.nWhichId ), 88 nFmtId( 0 ), 89 nPoolFmtId( rFmt.GetPoolFmtId() ), 90 nPoolHelpId( rFmt.GetPoolHelpId() ), 91 nPoolHlpFileId( rFmt.GetPoolHlpFileId() ) 92 { 93 bWritten = bFmtInDTOR = sal_False; // LAYER_IMPL 94 bAutoFmt = rFmt.bAutoFmt; 95 bAutoUpdateFmt = rFmt.bAutoUpdateFmt; 96 97 if( rFmt.DerivedFrom() ) 98 aSet.SetParent( &rFmt.DerivedFrom()->aSet ); 99 // einige Sonderbehandlungen fuer Attribute 100 aSet.SetModifyAtAttr( this ); 101 } 102 103 /************************************************************************* 104 |* SwFmt &SwFmt::operator=(const SwFmt& aFmt) 105 |* 106 |* Beschreibung Dokument 1.14 107 |* Ersterstellung JP 22.11.90 108 |* Letzte Aenderung JP 05.08.94 109 *************************************************************************/ 110 111 112 SwFmt &SwFmt::operator=(const SwFmt& rFmt) 113 { 114 nWhichId = rFmt.nWhichId; 115 nPoolFmtId = rFmt.GetPoolFmtId(); 116 nPoolHelpId = rFmt.GetPoolHelpId(); 117 nPoolHlpFileId = rFmt.GetPoolHlpFileId(); 118 119 if ( IsInCache() ) 120 { 121 SwFrm::GetCache().Delete( this ); 122 SetInCache( sal_False ); 123 } 124 SetInSwFntCache( sal_False ); 125 126 // kopiere nur das Attribut-Delta Array 127 SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ), 128 aNew( *aSet.GetPool(), aSet.GetRanges() ); 129 aSet.Intersect_BC( rFmt.aSet, &aOld, &aNew ); 130 aSet.Put_BC( rFmt.aSet, &aOld, &aNew ); 131 132 // einige Sonderbehandlungen fuer Attribute 133 aSet.SetModifyAtAttr( this ); 134 135 // PoolItem-Attr erzeugen fuers Modify !!! 136 if( aOld.Count() ) 137 { 138 SwAttrSetChg aChgOld( aSet, aOld ); 139 SwAttrSetChg aChgNew( aSet, aNew ); 140 ModifyNotification( &aChgOld, &aChgNew ); // alle veraenderten werden verschickt 141 } 142 143 if( GetRegisteredIn() != rFmt.GetRegisteredIn() ) 144 { 145 if( GetRegisteredIn() ) 146 GetRegisteredInNonConst()->Remove(this); 147 if(rFmt.GetRegisteredIn()) 148 { 149 const_cast<SwFmt&>(rFmt).GetRegisteredInNonConst()->Add(this); 150 aSet.SetParent( &rFmt.aSet ); 151 } 152 else 153 aSet.SetParent( 0 ); 154 } 155 bAutoFmt = rFmt.bAutoFmt; 156 bAutoUpdateFmt = rFmt.bAutoUpdateFmt; 157 return *this; 158 } 159 160 void SwFmt::SetName( const String& rNewName, sal_Bool bBroadcast ) 161 { 162 ASSERT(!IsDefault(), "SetName: Defaultformat" ); 163 if( bBroadcast ) 164 { 165 SwStringMsgPoolItem aOld( RES_NAME_CHANGED, aFmtName ); 166 SwStringMsgPoolItem aNew( RES_NAME_CHANGED, rNewName ); 167 aFmtName = rNewName; 168 ModifyNotification( &aOld, &aNew ); 169 } 170 else 171 { 172 aFmtName = rNewName; 173 } 174 } 175 176 /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 177 * diese Funktion wird in jedem Copy-Ctor gerufen, damit die 178 * Attribute kopiert werden. Diese koennen erst kopiert werden, 179 * wenn die abgeleitet Klasse existiert, denn beim Setzen der 180 * Attribute wird die Which()-Methode gerufen, die hier in der 181 * Basis-Klasse auf 0 defaultet ist. 182 * 183 * Zusatz: JP 8.4.1994 184 * Wird ueber Dokumentgrenzen kopiert, so muss das neue Dokument 185 * mit angeben werden, in dem this steht. Z.Z. ist das fuers 186 * DropCaps wichtig, dieses haelt Daten, die tief kopiert werden 187 * muessen !! 188 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ 189 190 191 void SwFmt::CopyAttrs( const SwFmt& rFmt, sal_Bool bReplace ) 192 { 193 // kopiere nur das Attribut-Delta Array 194 195 if ( IsInCache() ) 196 { 197 SwFrm::GetCache().Delete( this ); 198 SetInCache( sal_False ); 199 } 200 SetInSwFntCache( sal_False ); 201 202 // Sonderbehandlung fuer einige Attribute 203 SwAttrSet* pChgSet = (SwAttrSet*)&rFmt.aSet; 204 205 if( !bReplace ) // nur die neu, die nicht gesetzt sind ?? 206 { 207 if( pChgSet == (SwAttrSet*)&rFmt.aSet ) // Set hier kopieren 208 pChgSet = new SwAttrSet( rFmt.aSet ); 209 pChgSet->Differentiate( aSet ); 210 } 211 212 // kopiere nur das Attribut-Delta Array 213 if( pChgSet->GetPool() != aSet.GetPool() ) 214 pChgSet->CopyToModify( *this ); 215 else 216 { 217 SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ), 218 aNew( *aSet.GetPool(), aSet.GetRanges() ); 219 220 if ( 0 != aSet.Put_BC( *pChgSet, &aOld, &aNew ) ) 221 { 222 // einige Sonderbehandlungen fuer Attribute 223 aSet.SetModifyAtAttr( this ); 224 225 SwAttrSetChg aChgOld( aSet, aOld ); 226 SwAttrSetChg aChgNew( aSet, aNew ); 227 ModifyNotification( &aChgOld, &aChgNew ); // alle veraenderten werden verschickt 228 } 229 } 230 231 if( pChgSet != (SwAttrSet*)&rFmt.aSet ) // Set hier angelegt ? 232 delete pChgSet; 233 } 234 235 /************************************************************************* 236 |* SwFmt::~SwFmt() 237 |* 238 |* Beschreibung Dokument 1.14 239 |* Ersterstellung JP 22.11.90 240 |* Letzte Aenderung JP 14.02.91 241 *************************************************************************/ 242 243 244 SwFmt::~SwFmt() 245 { 246 /* das passiert bei der ObjectDying Message */ 247 /* alle Abhaengigen auf DerivedFrom umhaengen */ 248 if( GetDepends() ) 249 { 250 ASSERT(DerivedFrom(), "SwFmt::~SwFmt: Def Abhaengige!" ); 251 252 bFmtInDTOR = sal_True; 253 254 SwFmt *pParentFmt = DerivedFrom(); 255 if (!pParentFmt) // see #112405# 256 { 257 DBG_ERROR( "~SwFmt: parent format missing" ); 258 } 259 else 260 { 261 while( GetDepends() && pParentFmt) 262 { 263 SwFmtChg aOldFmt(this); 264 SwFmtChg aNewFmt(pParentFmt); 265 SwClient * pDepend = (SwClient*)GetDepends(); 266 pParentFmt->Add(pDepend); 267 pDepend->ModifyNotification(&aOldFmt, &aNewFmt); 268 } 269 } 270 } 271 } 272 273 274 /************************************************************************* 275 |* void SwFmt::Modify( const SfxPoolItem* pOldValue, const SfxPoolItem* pNewValue ) 276 |* 277 |* Beschreibung Dokument 1.14 278 |* Ersterstellung JP 22.11.90 279 |* Letzte Aenderung JP 05.08.94 280 *************************************************************************/ 281 282 283 void SwFmt::Modify( const SfxPoolItem* pOldValue, const SfxPoolItem* pNewValue ) 284 { 285 sal_Bool bWeiter = sal_True; // sal_True = Propagierung an die Abhaengigen 286 287 sal_uInt16 nWhich = pOldValue ? pOldValue->Which() : 288 pNewValue ? pNewValue->Which() : 0 ; 289 switch( nWhich ) 290 { 291 case 0: break; // Which-Id von 0 ??? 292 293 case RES_OBJECTDYING : 294 { 295 // ist das sterbende Object das "Parent"-Format von diesen Format, 296 // dann haengt sich dieses Format an den Parent vom Parent 297 SwFmt * pFmt = (SwFmt *) ((SwPtrMsgPoolItem *)pNewValue)->pObject; 298 299 // nicht umhaengen wenn dieses das oberste Format ist !! 300 if( GetRegisteredIn() && GetRegisteredIn() == pFmt ) 301 { 302 if( pFmt->GetRegisteredIn() ) 303 { 304 // wenn Parent, dann im neuen Parent wieder anmelden 305 pFmt->DerivedFrom()->Add( this ); 306 aSet.SetParent( &DerivedFrom()->aSet ); 307 } 308 else 309 { 310 // sonst auf jeden Fall beim sterbenden abmelden 311 DerivedFrom()->Remove( this ); 312 aSet.SetParent( 0 ); 313 } 314 } 315 } // OBJECTDYING 316 break; 317 318 case RES_ATTRSET_CHG: 319 if( ((SwAttrSetChg*)pOldValue)->GetTheChgdSet() != &aSet ) 320 { 321 //nur die weiter geben, die hier nicht gesetzt sind !! 322 SwAttrSetChg aOld( *(SwAttrSetChg*)pOldValue ); 323 SwAttrSetChg aNew( *(SwAttrSetChg*)pNewValue ); 324 325 aOld.GetChgSet()->Differentiate( aSet ); 326 aNew.GetChgSet()->Differentiate( aSet ); 327 328 if( aNew.Count() ) 329 // keine mehr gesetzt, dann Ende !! 330 NotifyClients( &aOld, &aNew ); 331 bWeiter = sal_False; 332 } 333 break; 334 case RES_FMT_CHG: 335 // falls mein Format Parent umgesetzt wird, dann melde ich 336 // meinen Attrset beim Neuen an. 337 338 // sein eigenes Modify ueberspringen !! 339 if( ((SwFmtChg*)pOldValue)->pChangedFmt != this && 340 ((SwFmtChg*)pNewValue)->pChangedFmt == DerivedFrom() ) 341 { 342 // den Set an den neuen Parent haengen 343 aSet.SetParent( DerivedFrom() ? &DerivedFrom()->aSet : 0 ); 344 } 345 break; 346 347 case RES_RESET_FMTWRITTEN: 348 { 349 // IsWritten-Flag zuruecksetzen. Hint nur an abhanegige 350 // Formate (und keine Frames) propagieren. 351 // mba: the code does the opposite from what is written in the comment! 352 ResetWritten(); 353 // mba: here we don't use the additional stuff from NotifyClients(). 354 // should we?! 355 // mba: move the code that ignores this event to the clients 356 ModifyBroadcast( pOldValue, pNewValue, TYPE(SwFmt) ); 357 bWeiter = sal_False; 358 } 359 break; 360 361 default: 362 { 363 // Ist das Attribut in diesem Format definiert, dann auf 364 // NICHT weiter propagieren !! 365 if( SFX_ITEM_SET == aSet.GetItemState( nWhich, sal_False )) 366 { 367 // wie finde ich heraus, ob nicht ich die Message versende ?? 368 // aber wer ruft das hier ???? 369 //ASSERT( sal_False, "Modify ohne Absender verschickt" ); 370 //JP 11.06.96: DropCaps koennen hierher kommen 371 ASSERT( RES_PARATR_DROP == nWhich, "Modify ohne Absender verschickt" ); 372 bWeiter = sal_False; 373 } 374 375 } // default 376 } // switch 377 378 if( bWeiter ) 379 { 380 // laufe durch alle abhaengigen Formate 381 NotifyClients( pOldValue, pNewValue ); 382 } 383 384 } 385 386 387 sal_Bool SwFmt::SetDerivedFrom(SwFmt *pDerFrom) 388 { 389 if ( pDerFrom ) 390 { 391 // Zyklus? 392 const SwFmt* pFmt = pDerFrom; 393 while ( pFmt != 0 ) 394 { 395 if ( pFmt == this ) 396 return sal_False; 397 398 pFmt=pFmt->DerivedFrom(); 399 } 400 } 401 else 402 { 403 // Nichts angegeben, Dflt-Format suchen 404 pDerFrom = this; 405 while ( pDerFrom->DerivedFrom() ) 406 pDerFrom = pDerFrom->DerivedFrom(); 407 } 408 if ( (pDerFrom == DerivedFrom()) || (pDerFrom == this) ) 409 return sal_False; 410 411 ASSERT( Which()==pDerFrom->Which() 412 || ( Which()==RES_CONDTXTFMTCOLL && pDerFrom->Which()==RES_TXTFMTCOLL) 413 || ( Which()==RES_TXTFMTCOLL && pDerFrom->Which()==RES_CONDTXTFMTCOLL) 414 || ( Which()==RES_FLYFRMFMT && pDerFrom->Which()==RES_FRMFMT ), 415 "SetDerivedFrom: Aepfel von Birnen ableiten?"); 416 417 if ( IsInCache() ) 418 { 419 SwFrm::GetCache().Delete( this ); 420 SetInCache( sal_False ); 421 } 422 SetInSwFntCache( sal_False ); 423 424 pDerFrom->Add(this); 425 aSet.SetParent( &pDerFrom->aSet ); 426 427 SwFmtChg aOldFmt(this); 428 SwFmtChg aNewFmt(this); 429 ModifyNotification( &aOldFmt, &aNewFmt ); 430 431 return sal_True; 432 } 433 434 435 const SfxPoolItem& SwFmt::GetFmtAttr( sal_uInt16 nWhich, sal_Bool bInParents ) const 436 { 437 if(RES_BACKGROUND == nWhich && RES_FLYFRMFMT == Which()) 438 { 439 //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] 440 OSL_ENSURE(false, "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)"); 441 static SvxBrushItem aSvxBrushItem(RES_BACKGROUND); 442 443 // fill the local static SvxBrushItem from the current ItemSet so that 444 // the fill attributes [XATTR_FILL_FIRST .. XATTR_FILL_LAST] are used 445 // as good as possible to create a fallback representation and return that 446 aSvxBrushItem = getSvxBrushItemFromSourceSet(aSet, bInParents); 447 448 return aSvxBrushItem; 449 } 450 451 return aSet.Get( nWhich, bInParents ); 452 } 453 454 455 SfxItemState SwFmt::GetItemState( sal_uInt16 nWhich, sal_Bool bSrchInParent, const SfxPoolItem **ppItem ) const 456 { 457 if(RES_BACKGROUND == nWhich && RES_FLYFRMFMT == Which()) 458 { 459 //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] 460 OSL_ENSURE(false, "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)"); 461 const FillAttributesPtr aFill = getFillAttributes(); 462 463 // check if the new fill attributes are used 464 if(aFill.get() && aFill->isUsed()) 465 { 466 // if yes, fill the local SvxBrushItem using the new fill attributes 467 // as good as possible to have an instance for the pointer to point 468 // to and return as state that it is set 469 static SvxBrushItem aSvxBrushItem(RES_BACKGROUND); 470 471 aSvxBrushItem = getSvxBrushItemFromSourceSet(aSet, bSrchInParent); 472 *ppItem = &aSvxBrushItem; 473 474 return SFX_ITEM_SET; 475 } 476 477 // if not, reset pointer and return SFX_ITEM_DEFAULT to signal that 478 // the item is not set 479 *ppItem = 0; 480 481 return SFX_ITEM_DEFAULT; 482 } 483 484 return aSet.GetItemState( nWhich, bSrchInParent, ppItem ); 485 } 486 487 488 sal_Bool SwFmt::SetFmtAttr(const SfxPoolItem& rAttr ) 489 { 490 if ( IsInCache() || IsInSwFntCache() ) 491 { 492 const sal_uInt16 nWhich = rAttr.Which(); 493 CheckCaching( nWhich ); 494 } 495 496 sal_Bool bRet = sal_False; 497 498 //UUUU 499 if(RES_BACKGROUND == rAttr.Which() && RES_FLYFRMFMT == Which()) 500 { 501 //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] 502 OSL_ENSURE(false, "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)"); 503 SfxItemSet aTempSet(*aSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST, 0, 0); 504 const SvxBrushItem& rSource = static_cast< const SvxBrushItem& >(rAttr); 505 506 // fill a local ItemSet with the attributes corresponding as good as possible 507 // to the new fill properties [XATTR_FILL_FIRST .. XATTR_FILL_LAST] and set these 508 // as ItemSet 509 setSvxBrushItemAsFillAttributesToTargetSet(rSource, aTempSet); 510 511 if(IsModifyLocked()) 512 { 513 if( 0 != ( bRet = (0 != aSet.Put( aTempSet ))) ) 514 { 515 aSet.SetModifyAtAttr( this ); 516 } 517 } 518 else 519 { 520 SwAttrSet aOld(*aSet.GetPool(), aSet.GetRanges()), aNew(*aSet.GetPool(), aSet.GetRanges()); 521 522 bRet = 0 != aSet.Put_BC(aTempSet, &aOld, &aNew); 523 524 if(bRet) 525 { 526 aSet.SetModifyAtAttr(this); 527 528 SwAttrSetChg aChgOld(aSet, aOld); 529 SwAttrSetChg aChgNew(aSet, aNew); 530 531 ModifyNotification(&aChgOld, &aChgNew); 532 } 533 } 534 535 return bRet; 536 } 537 538 // wenn Modify gelockt ist, werden keine Modifies verschickt; 539 // fuer FrmFmt's immer das Modify verschicken! 540 const sal_uInt16 nFmtWhich = Which(); 541 if( IsModifyLocked() || (!GetDepends() && 542 (RES_GRFFMTCOLL == nFmtWhich || 543 RES_TXTFMTCOLL == nFmtWhich ) ) ) 544 { 545 if( 0 != ( bRet = (0 != aSet.Put( rAttr ))) ) 546 aSet.SetModifyAtAttr( this ); 547 // --> OD 2006-11-22 #i71574# 548 if ( nFmtWhich == RES_TXTFMTCOLL && rAttr.Which() == RES_PARATR_NUMRULE ) 549 { 550 TxtFmtCollFunc::CheckTxtFmtCollForDeletionOfAssignmentToOutlineStyle( this ); 551 } 552 // <-- 553 } 554 else 555 { 556 // kopiere nur das Attribut-Delta Array 557 SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ), 558 aNew( *aSet.GetPool(), aSet.GetRanges() ); 559 560 bRet = 0 != aSet.Put_BC( rAttr, &aOld, &aNew ); 561 if( bRet ) 562 { 563 // einige Sonderbehandlungen fuer Attribute 564 aSet.SetModifyAtAttr( this ); 565 566 SwAttrSetChg aChgOld( aSet, aOld ); 567 SwAttrSetChg aChgNew( aSet, aNew ); 568 ModifyNotification( &aChgOld, &aChgNew ); // alle veraenderten werden verschickt 569 } 570 } 571 return bRet; 572 } 573 574 575 sal_Bool SwFmt::SetFmtAttr( const SfxItemSet& rSet ) 576 { 577 if( !rSet.Count() ) 578 return sal_False; 579 580 if ( IsInCache() ) 581 { 582 SwFrm::GetCache().Delete( this ); 583 SetInCache( sal_False ); 584 } 585 SetInSwFntCache( sal_False ); 586 587 sal_Bool bRet = sal_False; 588 589 //UUUU 590 if(RES_FLYFRMFMT == Which()) 591 { 592 const SfxPoolItem* pSource = 0; 593 594 if(SFX_ITEM_SET == rSet.GetItemState(RES_BACKGROUND, sal_False, &pSource)) 595 { 596 //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] 597 OSL_ENSURE(false, "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)"); 598 SfxItemSet aTempSet(rSet); 599 600 // copy all items to be set anyways to a local ItemSet with is also prepared for the new 601 // fill attribute ranges [XATTR_FILL_FIRST .. XATTR_FILL_LAST]. Add the attributes 602 // corresponding as good as possible to the new fill properties and set the whole ItemSet 603 const SvxBrushItem& rSource(static_cast< const SvxBrushItem& >(*pSource)); 604 setSvxBrushItemAsFillAttributesToTargetSet(rSource, aTempSet); 605 606 if(IsModifyLocked()) 607 { 608 if( 0 != ( bRet = (0 != aSet.Put( aTempSet ))) ) 609 { 610 aSet.SetModifyAtAttr( this ); 611 } 612 } 613 else 614 { 615 SwAttrSet aOld(*aSet.GetPool(), aSet.GetRanges()), aNew(*aSet.GetPool(), aSet.GetRanges()); 616 617 bRet = 0 != aSet.Put_BC(aTempSet, &aOld, &aNew); 618 619 if(bRet) 620 { 621 aSet.SetModifyAtAttr(this); 622 623 SwAttrSetChg aChgOld(aSet, aOld); 624 SwAttrSetChg aChgNew(aSet, aNew); 625 626 ModifyNotification(&aChgOld, &aChgNew); 627 } 628 } 629 630 return bRet; 631 } 632 } 633 634 // wenn Modify gelockt ist, werden keine Modifies verschickt; 635 // fuer FrmFmt's immer das Modify verschicken! 636 const sal_uInt16 nFmtWhich = Which(); 637 if ( IsModifyLocked() || 638 ( !GetDepends() && 639 ( RES_GRFFMTCOLL == nFmtWhich || 640 RES_TXTFMTCOLL == nFmtWhich ) ) ) 641 { 642 if( 0 != ( bRet = (0 != aSet.Put( rSet ))) ) 643 aSet.SetModifyAtAttr( this ); 644 // --> OD 2006-11-22 #i71574# 645 if ( nFmtWhich == RES_TXTFMTCOLL ) 646 { 647 TxtFmtCollFunc::CheckTxtFmtCollForDeletionOfAssignmentToOutlineStyle( this ); 648 } 649 // <-- 650 } 651 else 652 { 653 SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ), 654 aNew( *aSet.GetPool(), aSet.GetRanges() ); 655 bRet = 0 != aSet.Put_BC( rSet, &aOld, &aNew ); 656 if( bRet ) 657 { 658 // einige Sonderbehandlungen fuer Attribute 659 aSet.SetModifyAtAttr( this ); 660 SwAttrSetChg aChgOld( aSet, aOld ); 661 SwAttrSetChg aChgNew( aSet, aNew ); 662 ModifyNotification( &aChgOld, &aChgNew ); // alle veraenderten werden verschickt 663 } 664 } 665 return bRet; 666 } 667 668 // Nimmt den Hint mit nWhich aus dem Delta-Array 669 670 671 sal_Bool SwFmt::ResetFmtAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 ) 672 { 673 if( !aSet.Count() ) 674 return sal_False; 675 676 if( !nWhich2 || nWhich2 < nWhich1 ) 677 nWhich2 = nWhich1; // dann setze auf 1. Id, nur dieses Item 678 679 if ( IsInCache() || IsInSwFntCache() ) 680 { 681 for( sal_uInt16 n = nWhich1; n < nWhich2; ++n ) 682 CheckCaching( n ); 683 } 684 685 // wenn Modify gelockt ist, werden keine Modifies verschickt 686 if( IsModifyLocked() ) 687 return 0 != (( nWhich2 == nWhich1 ) 688 ? aSet.ClearItem( nWhich1 ) 689 : aSet.ClearItem_BC( nWhich1, nWhich2 )); 690 691 SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ), 692 aNew( *aSet.GetPool(), aSet.GetRanges() ); 693 sal_Bool bRet = 0 != aSet.ClearItem_BC( nWhich1, nWhich2, &aOld, &aNew ); 694 695 if( bRet ) 696 { 697 SwAttrSetChg aChgOld( aSet, aOld ); 698 SwAttrSetChg aChgNew( aSet, aNew ); 699 ModifyNotification( &aChgOld, &aChgNew ); // alle veraenderten werden verschickt 700 } 701 return bRet; 702 } 703 704 705 706 // --> OD 2007-01-24 #i73790# 707 // method renamed 708 sal_uInt16 SwFmt::ResetAllFmtAttr() 709 // <-- 710 { 711 if( !aSet.Count() ) 712 return 0; 713 714 if ( IsInCache() ) 715 { 716 SwFrm::GetCache().Delete( this ); 717 SetInCache( sal_False ); 718 } 719 SetInSwFntCache( sal_False ); 720 721 // wenn Modify gelockt ist, werden keine Modifies verschickt 722 if( IsModifyLocked() ) 723 return aSet.ClearItem( 0 ); 724 725 SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ), 726 aNew( *aSet.GetPool(), aSet.GetRanges() ); 727 sal_Bool bRet = 0 != aSet.ClearItem_BC( 0, &aOld, &aNew ); 728 729 if( bRet ) 730 { 731 SwAttrSetChg aChgOld( aSet, aOld ); 732 SwAttrSetChg aChgNew( aSet, aNew ); 733 ModifyNotification( &aChgOld, &aChgNew ); // alle veraenderten werden verschickt 734 } 735 return aNew.Count(); 736 } 737 738 739 /************************************************************************* 740 |* void SwFmt::GetInfo( const SfxPoolItem& ) const 741 |* 742 |* Beschreibung 743 |* Ersterstellung JP 18.04.94 744 |* Letzte Aenderung JP 05.08.94 745 *************************************************************************/ 746 747 748 sal_Bool SwFmt::GetInfo( SfxPoolItem& rInfo ) const 749 { 750 sal_Bool bRet = SwModify::GetInfo( rInfo ); 751 return bRet; 752 } 753 754 755 void SwFmt::DelDiffs( const SfxItemSet& rSet ) 756 { 757 if( !aSet.Count() ) 758 return; 759 760 if ( IsInCache() ) 761 { 762 SwFrm::GetCache().Delete( this ); 763 SetInCache( sal_False ); 764 } 765 SetInSwFntCache( sal_False ); 766 767 // wenn Modify gelockt ist, werden keine Modifies verschickt 768 if( IsModifyLocked() ) 769 { 770 aSet.Intersect( rSet ); 771 return; 772 } 773 774 SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ), 775 aNew( *aSet.GetPool(), aSet.GetRanges() ); 776 sal_Bool bRet = 0 != aSet.Intersect_BC( rSet, &aOld, &aNew ); 777 778 if( bRet ) 779 { 780 SwAttrSetChg aChgOld( aSet, aOld ); 781 SwAttrSetChg aChgNew( aSet, aNew ); 782 ModifyNotification( &aChgOld, &aChgNew ); // alle veraenderten werden verschickt 783 } 784 } 785 786 /** SwFmt::IsBackgroundTransparent - for feature #99657# 787 788 OD 22.08.2002 789 Virtual method to determine, if background of format is transparent. 790 Default implementation returns false. Thus, subclasses have to overload 791 method, if the specific subclass can have a transparent background. 792 793 @author OD 794 795 @return false, default implementation 796 */ 797 sal_Bool SwFmt::IsBackgroundTransparent() const 798 { 799 return sal_False; 800 } 801 802 /** SwFmt::IsShadowTransparent - for feature #99657# 803 804 OD 22.08.2002 805 Virtual method to determine, if shadow of format is transparent. 806 Default implementation returns false. Thus, subclasses have to overload 807 method, if the specific subclass can have a transparent shadow. 808 809 @author OD 810 811 @return false, default implementation 812 */ 813 sal_Bool SwFmt::IsShadowTransparent() const 814 { 815 return sal_False; 816 } 817 818 /* 819 * Document Interface Access 820 */ 821 const IDocumentSettingAccess* SwFmt::getIDocumentSettingAccess() const { return GetDoc(); } 822 const IDocumentDrawModelAccess* SwFmt::getIDocumentDrawModelAccess() const { return GetDoc(); } 823 IDocumentDrawModelAccess* SwFmt::getIDocumentDrawModelAccess() { return GetDoc(); } 824 const IDocumentLayoutAccess* SwFmt::getIDocumentLayoutAccess() const { return GetDoc(); } 825 IDocumentLayoutAccess* SwFmt::getIDocumentLayoutAccess() { return GetDoc(); } 826 IDocumentTimerAccess* SwFmt::getIDocumentTimerAccess() { return GetDoc(); } 827 IDocumentFieldsAccess* SwFmt::getIDocumentFieldsAccess() { return GetDoc(); } 828 IDocumentChartDataProviderAccess* SwFmt::getIDocumentChartDataProviderAccess() { return GetDoc(); } 829 830 //UUUU 831 const SvxBrushItem& SwFmt::GetBackground(sal_Bool bInP) const 832 { 833 if(RES_FLYFRMFMT == Which()) 834 { 835 //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] 836 OSL_ENSURE(false, "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)"); 837 static SvxBrushItem aSvxBrushItem(RES_BACKGROUND); 838 839 // fill the local static SvxBrushItem from the current ItemSet so that 840 // the fill attributes [XATTR_FILL_FIRST .. XATTR_FILL_LAST] are used 841 // as good as possible to create a fallback representation and return that 842 aSvxBrushItem = getSvxBrushItemFromSourceSet(aSet, bInP); 843 844 return aSvxBrushItem; 845 } 846 847 return aSet.GetBackground(bInP); 848 } 849 850 //UUUU 851 FillAttributesPtr SwFmt::getFillAttributes() const 852 { 853 // FALLBACKBREAKHERE return empty pointer 854 OSL_ENSURE(false, "getFillAttributes() call only valid for RES_FLYFRMFMT currently (!)"); 855 856 return FillAttributesPtr(); 857 } 858 859 // eof 860