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