1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sd.hxx" 30 31 #include <com/sun/star/beans/PropertyAttribute.hpp> 32 #include <com/sun/star/lang/DisposedException.hpp> 33 #include <com/sun/star/style/XStyle.hpp> 34 35 #include <osl/mutex.hxx> 36 #include <vos/mutex.hxx> 37 #include <vcl/svapp.hxx> 38 #include <comphelper/serviceinfohelper.hxx> 39 #include <boost/bind.hpp> 40 41 #include "eetext.hxx" 42 #include <editeng/eeitem.hxx> 43 #include <editeng/fhgtitem.hxx> 44 #include <svx/svdoattr.hxx> 45 #include <editeng/ulspitem.hxx> 46 #include <svl/smplhint.hxx> 47 #include <svl/itemset.hxx> 48 49 #include <svx/xflbmtit.hxx> 50 #include <svx/xflbstit.hxx> 51 #include <editeng/bulitem.hxx> 52 #include <editeng/lrspitem.hxx> 53 #include <svx/unoshprp.hxx> 54 #include <svx/unoshape.hxx> 55 #include <svx/svdpool.hxx> 56 #include "stlsheet.hxx" 57 #include "sdresid.hxx" 58 #include "sdpage.hxx" 59 #include "drawdoc.hxx" 60 #include "stlpool.hxx" 61 #include "glob.hrc" 62 #include "app.hrc" 63 #include "glob.hxx" 64 #include "helpids.h" 65 #include "../ui/inc/DrawViewShell.hxx" 66 #include "../ui/inc/ViewShellBase.hxx" 67 68 using ::rtl::OUString; 69 using ::osl::MutexGuard; 70 using ::osl::ClearableMutexGuard; 71 using ::cppu::OInterfaceContainerHelper; 72 using namespace ::vos; 73 using namespace ::com::sun::star::uno; 74 using namespace ::com::sun::star::util; 75 using namespace ::com::sun::star::lang; 76 using namespace ::com::sun::star::style; 77 using namespace ::com::sun::star::beans; 78 using namespace ::com::sun::star::container; 79 using namespace ::com::sun::star::drawing; 80 81 #define WID_STYLE_DISPNAME 7998 82 #define WID_STYLE_FAMILY 7999 83 84 static SvxItemPropertySet& GetStylePropertySet() 85 { 86 static const SfxItemPropertyMapEntry aFullPropertyMap_Impl[] = 87 { 88 { RTL_CONSTASCII_STRINGPARAM("Family"), WID_STYLE_FAMILY, &::getCppuType((const OUString*)0), PropertyAttribute::READONLY, 0}, 89 { RTL_CONSTASCII_STRINGPARAM("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &XNameContainer::static_type(), 0, 0}, 90 { RTL_CONSTASCII_STRINGPARAM("DisplayName"), WID_STYLE_DISPNAME, &::getCppuType((const OUString*)0), PropertyAttribute::READONLY, 0}, 91 92 SVX_UNOEDIT_NUMBERING_PROPERTIE, 93 SHADOW_PROPERTIES 94 LINE_PROPERTIES 95 LINE_PROPERTIES_START_END 96 FILL_PROPERTIES 97 EDGERADIUS_PROPERTIES 98 TEXT_PROPERTIES_DEFAULTS 99 CONNECTOR_PROPERTIES 100 SPECIAL_DIMENSIONING_PROPERTIES_DEFAULTS 101 {0,0,0,0,0,0} 102 }; 103 104 static SvxItemPropertySet aPropSet( aFullPropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() ); 105 return aPropSet; 106 } 107 108 class ModifyListenerForewarder : public SfxListener 109 { 110 public: 111 ModifyListenerForewarder( SdStyleSheet* pStyleSheet ); 112 113 virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint); 114 115 private: 116 SdStyleSheet* mpStyleSheet; 117 }; 118 119 ModifyListenerForewarder::ModifyListenerForewarder( SdStyleSheet* pStyleSheet ) 120 : mpStyleSheet( pStyleSheet ) 121 { 122 if( pStyleSheet ) 123 { 124 SfxBroadcaster& rBC = static_cast< SfxBroadcaster& >( *pStyleSheet ); 125 StartListening( rBC ); 126 } 127 } 128 129 void ModifyListenerForewarder::Notify(SfxBroadcaster& /*rBC*/, const SfxHint& /*rHint*/) 130 { 131 if( mpStyleSheet ) 132 mpStyleSheet->notifyModifyListener(); 133 } 134 135 SdStyleSheet::SdStyleSheet(const OUString& rDisplayName, SfxStyleSheetBasePool& _rPool, SfxStyleFamily eFamily, sal_uInt16 _nMask) 136 : SdStyleSheetBase( UniString( rDisplayName ), _rPool, eFamily, _nMask) 137 , ::cppu::BaseMutex() 138 , msApiName( rDisplayName ) 139 , mxPool( const_cast< SfxStyleSheetBasePool* >(&_rPool) ) 140 , mrBHelper( m_aMutex ) 141 { 142 } 143 144 SdStyleSheet::SdStyleSheet( const SdStyleSheet & r ) 145 : SdStyleSheetBase( r ) 146 , ::cppu::BaseMutex() 147 , msApiName( r.msApiName ) 148 , mxPool( r.mxPool ) 149 , mrBHelper( m_aMutex ) 150 { 151 } 152 153 SdStyleSheet::~SdStyleSheet() 154 { 155 delete pSet; 156 pSet = NULL; // damit nachfolgende Destruktoren eine Chance haben 157 } 158 159 void SdStyleSheet::SetApiName( const OUString& rApiName ) 160 { 161 msApiName = rApiName; 162 } 163 164 rtl::OUString SdStyleSheet::GetApiName() const 165 { 166 if( msApiName.getLength() ) 167 return msApiName; 168 else 169 return GetName(); 170 } 171 172 173 void SdStyleSheet::Load (SvStream& rIn, sal_uInt16 nVersion) 174 { 175 SfxStyleSheetBase::Load(rIn, nVersion); 176 177 // Die Default-Maske war frueher 0xAFFE. 178 // Aus dieser Default-Maske wurden die benoetigten Flags ausmaskiert. 179 // Nun wurde das Flag SFXSTYLEBIT_READONLY eingefuehrt, was dazu 180 // das alle StyleSheets read-only waren. 181 // Da im Draw kein StyleSheet read-only sein soll, wird an dieser Stelle 182 // das Flag zurueckgesetzt. 183 nMask &= ~SFXSTYLEBIT_READONLY; 184 } 185 186 /************************************************************************* 187 |* 188 |* Store 189 |* 190 \************************************************************************/ 191 192 void SdStyleSheet::Store(SvStream& rOut) 193 { 194 SfxStyleSheetBase::Store(rOut); 195 } 196 197 /************************************************************************* 198 |* 199 |* Parent setzen 200 |* 201 \************************************************************************/ 202 203 sal_Bool SdStyleSheet::SetParent(const String& rParentName) 204 { 205 sal_Bool bResult = sal_False; 206 207 if (SfxStyleSheet::SetParent(rParentName)) 208 { 209 // PseudoStyleSheets haben keine eigenen ItemSets 210 if (nFamily != SD_STYLE_FAMILY_PSEUDO) 211 { 212 if( rParentName.Len() ) 213 { 214 SfxStyleSheetBase* pStyle = rPool.Find(rParentName, nFamily); 215 if (pStyle) 216 { 217 bResult = sal_True; 218 SfxItemSet& rParentSet = pStyle->GetItemSet(); 219 GetItemSet().SetParent(&rParentSet); 220 Broadcast( SfxSimpleHint( SFX_HINT_DATACHANGED ) ); 221 } 222 } 223 else 224 { 225 bResult = sal_True; 226 GetItemSet().SetParent(NULL); 227 Broadcast( SfxSimpleHint( SFX_HINT_DATACHANGED ) ); 228 } 229 } 230 else 231 { 232 bResult = sal_True; 233 } 234 } 235 return bResult; 236 } 237 238 /************************************************************************* 239 |* 240 |* ItemSet ggfs. erzeugen und herausreichen 241 |* 242 \************************************************************************/ 243 244 SfxItemSet& SdStyleSheet::GetItemSet() 245 { 246 if (nFamily == SD_STYLE_FAMILY_GRAPHICS || nFamily == SD_STYLE_FAMILY_MASTERPAGE) 247 { 248 // ggfs. das ItemSet 'on demand' anlegen 249 if (!pSet) 250 { 251 sal_uInt16 nWhichPairTable[] = { XATTR_LINE_FIRST, XATTR_LINE_LAST, 252 XATTR_FILL_FIRST, XATTR_FILL_LAST, 253 254 SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST, 255 SDRATTR_TEXT_MINFRAMEHEIGHT, SDRATTR_TEXT_CONTOURFRAME, 256 257 SDRATTR_TEXT_WORDWRAP, SDRATTR_TEXT_AUTOGROWSIZE, 258 259 SDRATTR_EDGE_FIRST, SDRATTR_EDGE_LAST, 260 SDRATTR_MEASURE_FIRST, SDRATTR_MEASURE_LAST, 261 262 EE_PARA_START, EE_CHAR_END, 263 264 SDRATTR_XMLATTRIBUTES, SDRATTR_TEXT_USEFIXEDCELLHEIGHT, 265 266 SDRATTR_3D_FIRST, SDRATTR_3D_LAST, 267 0, 0 }; 268 269 pSet = new SfxItemSet(GetPool().GetPool(), nWhichPairTable); 270 } 271 272 return *pSet; 273 } 274 275 else if( nFamily == SD_STYLE_FAMILY_CELL ) 276 { 277 if (!pSet) 278 { 279 sal_uInt16 nWhichPairTable[] = { XATTR_LINE_FIRST, XATTR_LINE_LAST, 280 XATTR_FILL_FIRST, XATTR_FILL_LAST, 281 282 SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST, 283 SDRATTR_TEXT_MINFRAMEHEIGHT, SDRATTR_TEXT_CONTOURFRAME, 284 285 SDRATTR_TEXT_WORDWRAP, SDRATTR_TEXT_AUTOGROWSIZE, 286 287 EE_PARA_START, EE_CHAR_END, 288 289 SDRATTR_TABLE_FIRST, SDRATTR_TABLE_LAST, 290 SDRATTR_XMLATTRIBUTES, SDRATTR_XMLATTRIBUTES, 291 292 0, 0 }; 293 294 pSet = new SfxItemSet(GetPool().GetPool(), nWhichPairTable); 295 } 296 297 return *pSet; 298 } 299 300 // dies ist eine Stellvertretervorlage fuer die interne Vorlage des 301 // aktuellen Praesentationslayouts: dessen ItemSet returnieren 302 else 303 { 304 // return (GetRealStyleSheet()->GetItemSet()); 305 306 SdStyleSheet* pSdSheet = GetRealStyleSheet(); 307 308 if (pSdSheet) 309 { 310 return(pSdSheet->GetItemSet()); 311 } 312 else 313 { 314 if (!pSet) 315 { 316 sal_uInt16 nWhichPairTable[] = { XATTR_LINE_FIRST, XATTR_LINE_LAST, 317 XATTR_FILL_FIRST, XATTR_FILL_LAST, 318 319 SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST, 320 SDRATTR_TEXT_MINFRAMEHEIGHT, SDRATTR_TEXT_CONTOURFRAME, 321 322 SDRATTR_TEXT_WORDWRAP, SDRATTR_TEXT_AUTOGROWSIZE, 323 324 SDRATTR_EDGE_FIRST, SDRATTR_EDGE_LAST, 325 SDRATTR_MEASURE_FIRST, SDRATTR_MEASURE_LAST, 326 327 EE_PARA_START, EE_CHAR_END, 328 329 SDRATTR_XMLATTRIBUTES, SDRATTR_TEXT_USEFIXEDCELLHEIGHT, 330 331 SDRATTR_3D_FIRST, SDRATTR_3D_LAST, 332 0, 0 }; 333 334 pSet = new SfxItemSet(GetPool().GetPool(), nWhichPairTable); 335 } 336 337 return(*pSet); 338 } 339 } 340 } 341 342 /************************************************************************* 343 |* 344 |* IsUsed(), eine Vorlage gilt als benutzt, wenn sie von eingefuegten Objekten 345 |* oder von benutzten Vorlagen referenziert wird 346 |* 347 \************************************************************************/ 348 349 sal_Bool SdStyleSheet::IsUsed() const 350 { 351 sal_Bool bResult = sal_False; 352 353 sal_uInt16 nListenerCount = GetListenerCount(); 354 if (nListenerCount > 0) 355 { 356 for (sal_uInt16 n = 0; n < nListenerCount; n++) 357 { 358 SfxListener* pListener = GetListener(n); 359 if( pListener == this ) 360 continue; 361 362 // NULL-Pointer ist im Listener-Array erlaubt 363 if (pListener && pListener->ISA(SdrAttrObj)) 364 { 365 bResult = ((SdrAttrObj*)pListener)->IsInserted(); 366 } 367 else if (pListener && pListener->ISA(SfxStyleSheet)) 368 { 369 bResult = ((SfxStyleSheet*)pListener)->IsUsed(); 370 } 371 if (bResult) 372 break; 373 } 374 } 375 376 if( !bResult ) 377 { 378 MutexGuard aGuard( mrBHelper.rMutex ); 379 380 OInterfaceContainerHelper * pContainer = mrBHelper.getContainer( XModifyListener::static_type() ); 381 if( pContainer ) 382 { 383 Sequence< Reference< XInterface > > aModifyListeners( pContainer->getElements() ); 384 Reference< XInterface > *p = aModifyListeners.getArray(); 385 sal_Int32 nCount = aModifyListeners.getLength(); 386 while( nCount-- && !bResult ) 387 { 388 Reference< XStyle > xStyle( *p++, UNO_QUERY ); 389 if( xStyle.is() ) 390 bResult = xStyle->isInUse(); 391 } 392 } 393 } 394 return bResult; 395 } 396 397 /************************************************************************* 398 |* 399 |* das StyleSheet ermitteln, fuer das dieses StyleSheet steht 400 |* 401 \************************************************************************/ 402 403 SdStyleSheet* SdStyleSheet::GetRealStyleSheet() const 404 { 405 String aRealStyle; 406 String aSep( RTL_CONSTASCII_USTRINGPARAM( SD_LT_SEPARATOR )); 407 SdStyleSheet* pRealStyle = NULL; 408 SdDrawDocument* pDoc = ((SdStyleSheetPool&) rPool).GetDoc(); 409 410 ::sd::DrawViewShell* pDrawViewShell = 0; 411 412 ::sd::ViewShellBase* pBase = dynamic_cast< ::sd::ViewShellBase* >( SfxViewShell::Current() ); 413 if( pBase ) 414 pDrawViewShell = dynamic_cast< ::sd::DrawViewShell* >( pBase->GetMainViewShell().get() ); 415 416 if (pDrawViewShell && pDrawViewShell->GetDoc() == pDoc) 417 { 418 SdPage* pPage = pDrawViewShell->getCurrentPage(); 419 if( pPage ) 420 { 421 aRealStyle = pPage->GetLayoutName(); 422 // cut after seperator string 423 aRealStyle.Erase(aRealStyle.Search(aSep) + aSep.Len()); 424 } 425 } 426 427 if (aRealStyle.Len() == 0) 428 { 429 SdPage* pPage = pDoc->GetSdPage(0, PK_STANDARD); 430 431 if (pPage) 432 { 433 aRealStyle = pDoc->GetSdPage(0, PK_STANDARD)->GetLayoutName(); 434 } 435 else 436 { 437 // Noch keine Seite vorhanden 438 // Dieses kann beim Aktualisieren vonDokumentvorlagen vorkommen 439 SfxStyleSheetIterator aIter(&rPool, SD_STYLE_FAMILY_MASTERPAGE); 440 SfxStyleSheetBase* pSheet = aIter.First(); 441 if( pSheet ) 442 aRealStyle = pSheet->GetName(); 443 } 444 445 aRealStyle.Erase(aRealStyle.Search(aSep) + aSep.Len()); 446 } 447 448 // jetzt vom Namen (landessprachlich angepasst) auf den internen 449 // Namen (unabhaengig von der Landessprache) mappen 450 String aInternalName; 451 452 if (aName == String(SdResId(STR_PSEUDOSHEET_TITLE))) 453 { 454 aInternalName = String(SdResId(STR_LAYOUT_TITLE)); 455 } 456 else if (aName == String(SdResId(STR_PSEUDOSHEET_SUBTITLE))) 457 { 458 aInternalName = String(SdResId(STR_LAYOUT_SUBTITLE)); 459 } 460 else if (aName == String(SdResId(STR_PSEUDOSHEET_BACKGROUND))) 461 { 462 aInternalName = String(SdResId(STR_LAYOUT_BACKGROUND)); 463 } 464 else if (aName == String(SdResId(STR_PSEUDOSHEET_BACKGROUNDOBJECTS))) 465 { 466 aInternalName = String(SdResId(STR_LAYOUT_BACKGROUNDOBJECTS)); 467 } 468 else if (aName == String(SdResId(STR_PSEUDOSHEET_NOTES))) 469 { 470 aInternalName = String(SdResId(STR_LAYOUT_NOTES)); 471 } 472 else 473 { 474 String aOutlineStr(SdResId(STR_PSEUDOSHEET_OUTLINE)); 475 sal_uInt16 nPos = aName.Search(aOutlineStr); 476 if (nPos != STRING_NOTFOUND) 477 { 478 String aNumStr(aName.Copy(aOutlineStr.Len())); 479 aInternalName = String(SdResId(STR_LAYOUT_OUTLINE)); 480 aInternalName += aNumStr; 481 } 482 } 483 484 aRealStyle += aInternalName; 485 pRealStyle = static_cast< SdStyleSheet* >( rPool.Find(aRealStyle, SD_STYLE_FAMILY_MASTERPAGE) ); 486 487 #ifdef DBG_UTIL 488 if( !pRealStyle ) 489 { 490 SfxStyleSheetIterator aIter(&rPool, SD_STYLE_FAMILY_MASTERPAGE); 491 if( aIter.Count() > 0 ) 492 // StyleSheet not found, but pool already loaded 493 DBG_ASSERT(pRealStyle, "Internal StyleSheet not found"); 494 } 495 #endif 496 497 return pRealStyle; 498 } 499 500 /************************************************************************* 501 |* 502 |* das PseudoStyleSheet ermitteln, durch das dieses StyleSheet vertreten wird 503 |* 504 \************************************************************************/ 505 506 SdStyleSheet* SdStyleSheet::GetPseudoStyleSheet() const 507 { 508 SdStyleSheet* pPseudoStyle = NULL; 509 String aSep( RTL_CONSTASCII_USTRINGPARAM( SD_LT_SEPARATOR )); 510 String aStyleName(aName); 511 // ohne Layoutnamen und Separator 512 aStyleName.Erase(0, aStyleName.Search(aSep) + aSep.Len()); 513 514 if (aStyleName == String(SdResId(STR_LAYOUT_TITLE))) 515 { 516 aStyleName = String(SdResId(STR_PSEUDOSHEET_TITLE)); 517 } 518 else if (aStyleName == String(SdResId(STR_LAYOUT_SUBTITLE))) 519 { 520 aStyleName = String(SdResId(STR_PSEUDOSHEET_SUBTITLE)); 521 } 522 else if (aStyleName == String(SdResId(STR_LAYOUT_BACKGROUND))) 523 { 524 aStyleName = String(SdResId(STR_PSEUDOSHEET_BACKGROUND)); 525 } 526 else if (aStyleName == String(SdResId(STR_LAYOUT_BACKGROUNDOBJECTS))) 527 { 528 aStyleName = String(SdResId(STR_PSEUDOSHEET_BACKGROUNDOBJECTS)); 529 } 530 else if (aStyleName == String(SdResId(STR_LAYOUT_NOTES))) 531 { 532 aStyleName = String(SdResId(STR_PSEUDOSHEET_NOTES)); 533 } 534 else 535 { 536 String aOutlineStr((SdResId(STR_LAYOUT_OUTLINE))); 537 sal_uInt16 nPos = aStyleName.Search(aOutlineStr); 538 if (nPos != STRING_NOTFOUND) 539 { 540 String aNumStr(aStyleName.Copy(aOutlineStr.Len())); 541 aStyleName = String(SdResId(STR_PSEUDOSHEET_OUTLINE)); 542 aStyleName += aNumStr; 543 } 544 } 545 546 pPseudoStyle = static_cast<SdStyleSheet*>(rPool.Find(aStyleName, SD_STYLE_FAMILY_PSEUDO)); 547 DBG_ASSERT(pPseudoStyle, "PseudoStyleSheet nicht gefunden"); 548 549 return pPseudoStyle; 550 } 551 552 553 /************************************************************************* 554 |* 555 |* Notify 556 |* 557 \************************************************************************/ 558 559 void SdStyleSheet::Notify(SfxBroadcaster& rBC, const SfxHint& rHint) 560 { 561 // erstmal die Basisklassenfunktionalitaet 562 SfxStyleSheet::Notify(rBC, rHint); 563 564 // wenn der Stellvertreter ein Notify bezueglich geaenderter Attribute 565 // bekommt, sorgt er dafuer, dass das eigentlich gemeinte StyleSheet 566 // broadcastet 567 SfxSimpleHint* pSimple = PTR_CAST(SfxSimpleHint, &rHint); 568 sal_uLong nId = pSimple == NULL ? 0 : pSimple->GetId(); 569 if (nId == SFX_HINT_DATACHANGED && nFamily == SD_STYLE_FAMILY_PSEUDO) 570 { 571 SdStyleSheet* pRealStyle = GetRealStyleSheet(); 572 if (pRealStyle) 573 pRealStyle->Broadcast(rHint); 574 } 575 } 576 577 /************************************************************************* 578 |* AdjustToFontHeight passt die Bulletbreite und den linken Texteinzug 579 |* des uebergebenen ItemSets dessen Fonthoehe an. Die neuen Werte werden so 580 |* berechnet, dass das Verhaeltnis zur Fonthoehe so ist wie im StyleSheet. 581 |* 582 |* bOnlyMissingItems legt fest, ob lediglich nicht gesetzte Items ergaenzt 583 |* (sal_True) oder explizit gesetzte Items ueberschreiben werden sollen (sal_False) 584 |* 585 \************************************************************************/ 586 587 void SdStyleSheet::AdjustToFontHeight(SfxItemSet& rSet, sal_Bool bOnlyMissingItems) 588 { 589 // Bulletbreite und Texteinzug an neue Fonthoehe 590 // anpassen, wenn sie nicht explizit gesetzt wurden 591 SfxStyleFamily eFamily = nFamily; 592 String aStyleName(aName); 593 if (eFamily == SD_STYLE_FAMILY_PSEUDO) 594 { 595 SfxStyleSheet* pRealStyle = GetRealStyleSheet(); 596 eFamily = pRealStyle->GetFamily(); 597 aStyleName = pRealStyle->GetName(); 598 } 599 600 if (eFamily == SD_STYLE_FAMILY_MASTERPAGE && 601 aStyleName.Search(String(SdResId(STR_LAYOUT_OUTLINE))) != STRING_NOTFOUND && 602 rSet.GetItemState(EE_CHAR_FONTHEIGHT) == SFX_ITEM_SET) 603 { 604 const SfxItemSet* pCurSet = &GetItemSet(); 605 sal_uInt32 nNewHeight = ((SvxFontHeightItem&)rSet.Get(EE_CHAR_FONTHEIGHT)).GetHeight(); 606 sal_uInt32 nOldHeight = ((SvxFontHeightItem&)pCurSet->Get(EE_CHAR_FONTHEIGHT)).GetHeight(); 607 608 if (rSet.GetItemState(EE_PARA_BULLET) != SFX_ITEM_SET || !bOnlyMissingItems) 609 { 610 const SvxBulletItem& rBItem = (const SvxBulletItem&)pCurSet->Get(EE_PARA_BULLET); 611 double fBulletFraction = double(rBItem.GetWidth()) / nOldHeight; 612 SvxBulletItem aNewBItem(rBItem); 613 aNewBItem.SetWidth((sal_uInt32)(fBulletFraction * nNewHeight)); 614 rSet.Put(aNewBItem); 615 } 616 617 if (rSet.GetItemState(EE_PARA_LRSPACE) != SFX_ITEM_SET || !bOnlyMissingItems) 618 { 619 const SvxLRSpaceItem& rLRItem = (const SvxLRSpaceItem&)pCurSet->Get(EE_PARA_LRSPACE); 620 double fIndentFraction = double(rLRItem.GetTxtLeft()) / nOldHeight; 621 SvxLRSpaceItem aNewLRItem(rLRItem); 622 aNewLRItem.SetTxtLeft((sal_uInt16)(fIndentFraction * nNewHeight)); 623 double fFirstIndentFraction = double(rLRItem.GetTxtFirstLineOfst()) / nOldHeight; 624 aNewLRItem.SetTxtFirstLineOfst((short)(fFirstIndentFraction * nNewHeight)); 625 rSet.Put(aNewLRItem); 626 } 627 628 if (rSet.GetItemState(EE_PARA_ULSPACE) != SFX_ITEM_SET || !bOnlyMissingItems) 629 { 630 const SvxULSpaceItem& rULItem = (const SvxULSpaceItem&)pCurSet->Get(EE_PARA_ULSPACE); 631 SvxULSpaceItem aNewULItem(rULItem); 632 double fLowerFraction = double(rULItem.GetLower()) / nOldHeight; 633 aNewULItem.SetLower((sal_uInt16)(fLowerFraction * nNewHeight)); 634 double fUpperFraction = double(rULItem.GetUpper()) / nOldHeight; 635 aNewULItem.SetUpper((sal_uInt16)(fUpperFraction * nNewHeight)); 636 rSet.Put(aNewULItem); 637 } 638 } 639 } 640 641 // -------------------------------------------------------------------- 642 643 sal_Bool SdStyleSheet::HasFollowSupport() const 644 { 645 return sal_False; 646 } 647 648 // -------------------------------------------------------------------- 649 650 sal_Bool SdStyleSheet::HasParentSupport() const 651 { 652 return sal_True; 653 } 654 655 // -------------------------------------------------------------------- 656 657 sal_Bool SdStyleSheet::HasClearParentSupport() const 658 { 659 return sal_True; 660 } 661 662 // -------------------------------------------------------------------- 663 664 sal_Bool SdStyleSheet::SetName( const UniString& rName ) 665 { 666 return SfxStyleSheet::SetName( rName ); 667 } 668 669 // -------------------------------------------------------------------- 670 671 void SdStyleSheet::SetHelpId( const String& r, sal_uLong nId ) 672 { 673 SfxStyleSheet::SetHelpId( r, nId ); 674 675 if( (nId >= HID_PSEUDOSHEET_OUTLINE1) && ( nId <= HID_PSEUDOSHEET_OUTLINE9 ) ) 676 { 677 msApiName = OUString( RTL_CONSTASCII_USTRINGPARAM("outline") ); 678 msApiName += OUString( (sal_Unicode)( '1' + (nId - HID_PSEUDOSHEET_OUTLINE1) ) ); 679 } 680 else 681 { 682 static struct ApiNameMap 683 { 684 const sal_Char* mpApiName; 685 sal_uInt32 mnApiNameLength; 686 sal_uInt32 mnHelpId; 687 } 688 pApiNameMap[] = 689 { 690 { RTL_CONSTASCII_STRINGPARAM( "title" ), HID_PSEUDOSHEET_TITLE }, 691 { RTL_CONSTASCII_STRINGPARAM( "subtitle" ), HID_PSEUDOSHEET_SUBTITLE }, 692 { RTL_CONSTASCII_STRINGPARAM( "background" ), HID_PSEUDOSHEET_BACKGROUND }, 693 { RTL_CONSTASCII_STRINGPARAM( "backgroundobjects" ),HID_PSEUDOSHEET_BACKGROUNDOBJECTS }, 694 { RTL_CONSTASCII_STRINGPARAM( "notes" ), HID_PSEUDOSHEET_NOTES }, 695 { RTL_CONSTASCII_STRINGPARAM( "standard" ), HID_STANDARD_STYLESHEET_NAME }, 696 { RTL_CONSTASCII_STRINGPARAM( "objectwitharrow" ), HID_POOLSHEET_OBJWITHARROW }, 697 { RTL_CONSTASCII_STRINGPARAM( "objectwithshadow" ), HID_POOLSHEET_OBJWITHSHADOW }, 698 { RTL_CONSTASCII_STRINGPARAM( "objectwithoutfill" ),HID_POOLSHEET_OBJWITHOUTFILL }, 699 { RTL_CONSTASCII_STRINGPARAM( "text" ), HID_POOLSHEET_TEXT }, 700 { RTL_CONSTASCII_STRINGPARAM( "textbody" ), HID_POOLSHEET_TEXTBODY }, 701 { RTL_CONSTASCII_STRINGPARAM( "textbodyjustfied" ), HID_POOLSHEET_TEXTBODY_JUSTIFY }, 702 { RTL_CONSTASCII_STRINGPARAM( "textbodyindent" ), HID_POOLSHEET_TEXTBODY_INDENT }, 703 { RTL_CONSTASCII_STRINGPARAM( "title" ), HID_POOLSHEET_TITLE }, 704 { RTL_CONSTASCII_STRINGPARAM( "title1" ), HID_POOLSHEET_TITLE1 }, 705 { RTL_CONSTASCII_STRINGPARAM( "title2" ), HID_POOLSHEET_TITLE2 }, 706 { RTL_CONSTASCII_STRINGPARAM( "headline" ), HID_POOLSHEET_HEADLINE }, 707 { RTL_CONSTASCII_STRINGPARAM( "headline1" ), HID_POOLSHEET_HEADLINE1 }, 708 { RTL_CONSTASCII_STRINGPARAM( "headline2" ), HID_POOLSHEET_HEADLINE2 }, 709 { RTL_CONSTASCII_STRINGPARAM( "measure" ), HID_POOLSHEET_MEASURE }, 710 { 0, 0, 0 } 711 }; 712 713 ApiNameMap* p = pApiNameMap; 714 while( p->mpApiName ) 715 { 716 if( nId == p->mnHelpId ) 717 { 718 msApiName = OUString( p->mpApiName, p->mnApiNameLength, RTL_TEXTENCODING_ASCII_US ); 719 break; 720 } 721 p++; 722 } 723 } 724 } 725 726 // -------------------------------------------------------------------- 727 728 OUString SdStyleSheet::GetFamilyString( SfxStyleFamily eFamily ) 729 { 730 switch( eFamily ) 731 { 732 case SD_STYLE_FAMILY_CELL: 733 return OUString( RTL_CONSTASCII_USTRINGPARAM( "cell" ) ); 734 default: 735 DBG_ERROR( "SdStyleSheet::GetFamilyString(), illegal family!" ); 736 case SD_STYLE_FAMILY_GRAPHICS: 737 return OUString( RTL_CONSTASCII_USTRINGPARAM( "graphics" ) ); 738 } 739 } 740 741 // -------------------------------------------------------------------- 742 743 void SdStyleSheet::throwIfDisposed() throw (RuntimeException) 744 { 745 if( !mxPool.is() ) 746 throw DisposedException(); 747 } 748 749 // -------------------------------------------------------------------- 750 751 SdStyleSheet* SdStyleSheet::CreateEmptyUserStyle( SfxStyleSheetBasePool& rPool, SfxStyleFamily eFamily ) 752 { 753 OUString aPrefix( RTL_CONSTASCII_USTRINGPARAM("user") ); 754 OUString aName; 755 sal_Int32 nIndex = 1; 756 do 757 { 758 aName = aPrefix + OUString::valueOf( nIndex++ ); 759 } 760 while( rPool.Find( aName, eFamily ) != 0 ); 761 762 return new SdStyleSheet(aName, rPool, eFamily, SFXSTYLEBIT_USERDEF); 763 } 764 765 // -------------------------------------------------------------------- 766 // XInterface 767 // -------------------------------------------------------------------- 768 769 /* 770 Any SAL_CALL SdStyleSheet::queryInterface( const ::com::sun::star::uno::Type& aType ) throw (RuntimeException) 771 { 772 return SdStyleSheetBase::queryInterface( aType ); 773 } 774 775 // -------------------------------------------------------------------- 776 777 void SAL_CALL SdStyleSheet::acquire( ) throw () 778 { 779 SdStyleSheetBase::acquire(); 780 } 781 782 // -------------------------------------------------------------------- 783 */ 784 void SAL_CALL SdStyleSheet::release( ) throw () 785 { 786 if (osl_decrementInterlockedCount( &m_refCount ) == 0) 787 { 788 // restore reference count: 789 osl_incrementInterlockedCount( &m_refCount ); 790 if (! mrBHelper.bDisposed) try 791 { 792 dispose(); 793 } 794 catch (RuntimeException const& exc) 795 { // don't break throw () 796 OSL_ENSURE( 797 false, OUStringToOString( 798 exc.Message, RTL_TEXTENCODING_ASCII_US ).getStr() ); 799 static_cast<void>(exc); 800 } 801 OSL_ASSERT( mrBHelper.bDisposed ); 802 SdStyleSheetBase::release(); 803 } 804 } 805 806 // -------------------------------------------------------------------- 807 // XWeak 808 // -------------------------------------------------------------------- 809 /* 810 Reference< XAdapter > SAL_CALL SdStyleSheet::queryAdapter( ) throw (RuntimeException) 811 { 812 return SdStyleSheetBase::queryAdapter(); 813 } 814 815 // -------------------------------------------------------------------- 816 // XTypeProvider 817 // -------------------------------------------------------------------- 818 819 Sequence< Type > SAL_CALL SdStyleSheet::getTypes( ) throw (RuntimeException) 820 { 821 return SdStyleSheetBase::getTypes(); 822 } 823 824 // -------------------------------------------------------------------- 825 826 Sequence< ::sal_Int8 > SAL_CALL SdStyleSheet::getImplementationId( ) throw (RuntimeException) 827 { 828 return SdStyleSheetBase::getImplementationId(); 829 } 830 */ 831 // -------------------------------------------------------------------- 832 // XComponent 833 // -------------------------------------------------------------------- 834 835 void SAL_CALL SdStyleSheet::dispose( ) throw (RuntimeException) 836 { 837 ClearableMutexGuard aGuard( mrBHelper.rMutex ); 838 if (!mrBHelper.bDisposed && !mrBHelper.bInDispose) 839 { 840 mrBHelper.bInDispose = sal_True; 841 aGuard.clear(); 842 try 843 { 844 // side effect: keeping a reference to this 845 EventObject aEvt( static_cast< OWeakObject * >( this ) ); 846 try 847 { 848 mrBHelper.aLC.disposeAndClear( aEvt ); 849 disposing(); 850 } 851 catch (...) 852 { 853 MutexGuard aGuard2( mrBHelper.rMutex ); 854 // bDisposed and bInDispose must be set in this order: 855 mrBHelper.bDisposed = sal_True; 856 mrBHelper.bInDispose = sal_False; 857 throw; 858 } 859 MutexGuard aGuard2( mrBHelper.rMutex ); 860 // bDisposed and bInDispose must be set in this order: 861 mrBHelper.bDisposed = sal_True; 862 mrBHelper.bInDispose = sal_False; 863 } 864 catch (RuntimeException &) 865 { 866 throw; 867 } 868 catch (Exception & exc) 869 { 870 throw RuntimeException( 871 OUString( RTL_CONSTASCII_USTRINGPARAM( 872 "unexpected UNO exception caught: ") ) + 873 exc.Message, Reference< XInterface >() ); 874 } 875 } 876 } 877 878 // -------------------------------------------------------------------- 879 880 void SdStyleSheet::disposing() 881 { 882 mxPool.clear(); 883 } 884 885 // -------------------------------------------------------------------- 886 887 void SAL_CALL SdStyleSheet::addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException) 888 { 889 ClearableMutexGuard aGuard( mrBHelper.rMutex ); 890 if (mrBHelper.bDisposed || mrBHelper.bInDispose) 891 { 892 aGuard.clear(); 893 EventObject aEvt( static_cast< OWeakObject * >( this ) ); 894 xListener->disposing( aEvt ); 895 } 896 else 897 { 898 mrBHelper.addListener( ::getCppuType( &xListener ), xListener ); 899 } 900 } 901 902 // -------------------------------------------------------------------- 903 904 void SAL_CALL SdStyleSheet::removeEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException) 905 { 906 mrBHelper.removeListener( ::getCppuType( &xListener ), xListener ); 907 } 908 909 //------------------------------------------------------------------------ 910 // XModifyBroadcaster 911 //------------------------------------------------------------------------ 912 913 void SAL_CALL SdStyleSheet::addModifyListener( const Reference< XModifyListener >& xListener ) throw (RuntimeException) 914 { 915 ClearableMutexGuard aGuard( mrBHelper.rMutex ); 916 if (mrBHelper.bDisposed || mrBHelper.bInDispose) 917 { 918 aGuard.clear(); 919 EventObject aEvt( static_cast< OWeakObject * >( this ) ); 920 xListener->disposing( aEvt ); 921 } 922 else 923 { 924 if( !mpModifyListenerForewarder.get() ) 925 mpModifyListenerForewarder.reset( new ModifyListenerForewarder( this ) ); 926 mrBHelper.addListener( XModifyListener::static_type(), xListener ); 927 } 928 } 929 930 //------------------------------------------------------------------------ 931 932 void SAL_CALL SdStyleSheet::removeModifyListener( const Reference< XModifyListener >& xListener ) throw (RuntimeException) 933 { 934 mrBHelper.removeListener( XModifyListener::static_type(), xListener ); 935 } 936 937 //------------------------------------------------------------------------ 938 939 void SdStyleSheet::notifyModifyListener() 940 { 941 MutexGuard aGuard( mrBHelper.rMutex ); 942 943 OInterfaceContainerHelper * pContainer = mrBHelper.getContainer( XModifyListener::static_type() ); 944 if( pContainer ) 945 { 946 EventObject aEvt( static_cast< OWeakObject * >( this ) ); 947 pContainer->forEach<XModifyListener>( boost::bind( &XModifyListener::modified, _1, boost::cref( aEvt ) ) ); 948 } 949 } 950 951 952 // -------------------------------------------------------------------- 953 // XServiceInfo 954 // -------------------------------------------------------------------- 955 956 OUString SAL_CALL SdStyleSheet::getImplementationName() throw(RuntimeException) 957 { 958 return OUString::createFromAscii( "SdStyleSheet" ); 959 } 960 961 // -------------------------------------------------------------------- 962 963 sal_Bool SAL_CALL SdStyleSheet::supportsService( const OUString& ServiceName ) throw(RuntimeException) 964 { 965 return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() ); 966 } 967 968 // -------------------------------------------------------------------- 969 970 Sequence< OUString > SAL_CALL SdStyleSheet::getSupportedServiceNames() throw(RuntimeException) 971 { 972 Sequence< OUString > aNameSequence( 10 ); 973 OUString* pStrings = aNameSequence.getArray(); 974 975 *pStrings++ = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.style.Style" ) ); 976 *pStrings++ = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.FillProperties" ) ); 977 *pStrings++ = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.LineProperties" ) ); 978 *pStrings++ = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.ShadowProperties" ) ); 979 *pStrings++ = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.ConnectorProperties" ) ); 980 *pStrings++ = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.MeasureProperties" ) ); 981 *pStrings++ = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.style.ParagraphProperties" ) ); 982 *pStrings++ = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.style.CharacterProperties" ) ); 983 *pStrings++ = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.TextProperties" ) ); 984 *pStrings++ = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.Text" ) ); 985 986 return aNameSequence; 987 } 988 989 // -------------------------------------------------------------------- 990 // XNamed 991 // -------------------------------------------------------------------- 992 993 OUString SAL_CALL SdStyleSheet::getName() throw(RuntimeException) 994 { 995 OGuard aGuard( Application::GetSolarMutex() ); 996 throwIfDisposed(); 997 return GetApiName(); 998 } 999 1000 // -------------------------------------------------------------------- 1001 1002 void SAL_CALL SdStyleSheet::setName( const OUString& rName ) throw(RuntimeException) 1003 { 1004 OGuard aGuard( Application::GetSolarMutex() ); 1005 throwIfDisposed(); 1006 1007 if( SetName( rName ) ) 1008 { 1009 msApiName = rName; 1010 Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED)); 1011 } 1012 } 1013 1014 // -------------------------------------------------------------------- 1015 // XStyle 1016 // -------------------------------------------------------------------- 1017 1018 sal_Bool SAL_CALL SdStyleSheet::isUserDefined() throw(RuntimeException) 1019 { 1020 OGuard aGuard( Application::GetSolarMutex() ); 1021 throwIfDisposed(); 1022 return IsUserDefined() ? sal_True : sal_False; 1023 } 1024 1025 // -------------------------------------------------------------------- 1026 1027 sal_Bool SAL_CALL SdStyleSheet::isInUse() throw(RuntimeException) 1028 { 1029 OGuard aGuard( Application::GetSolarMutex() ); 1030 throwIfDisposed(); 1031 return IsUsed() ? sal_True : sal_False; 1032 } 1033 1034 // -------------------------------------------------------------------- 1035 1036 OUString SAL_CALL SdStyleSheet::getParentStyle() throw(RuntimeException) 1037 { 1038 OGuard aGuard( Application::GetSolarMutex() ); 1039 throwIfDisposed(); 1040 1041 if( GetParent().Len() ) 1042 { 1043 SdStyleSheet* pParentStyle = static_cast< SdStyleSheet* >( mxPool->Find( GetParent(), nFamily ) ); 1044 if( pParentStyle ) 1045 return pParentStyle->msApiName; 1046 } 1047 return OUString(); 1048 } 1049 1050 // -------------------------------------------------------------------- 1051 1052 void SAL_CALL SdStyleSheet::setParentStyle( const OUString& rParentName ) throw(NoSuchElementException, RuntimeException) 1053 { 1054 OGuard aGuard( Application::GetSolarMutex() ); 1055 throwIfDisposed(); 1056 1057 if( rParentName.getLength() ) 1058 { 1059 const SfxStyles& rStyles = mxPool->GetStyles(); 1060 1061 for( SfxStyles::const_iterator iter( rStyles.begin() ); iter != rStyles.end(); iter++ ) 1062 { 1063 SdStyleSheet* pStyle = static_cast< SdStyleSheet* >( (*iter).get() ); 1064 if( pStyle && (pStyle->nFamily == nFamily) && (pStyle->msApiName == rParentName) ) 1065 { 1066 if( pStyle != this ) 1067 SetParent( pStyle->GetName() ); 1068 return; 1069 } 1070 } 1071 throw NoSuchElementException(); 1072 } 1073 else 1074 { 1075 SetParent( rParentName ); 1076 } 1077 } 1078 1079 // -------------------------------------------------------------------- 1080 // XPropertySet 1081 // -------------------------------------------------------------------- 1082 1083 Reference< XPropertySetInfo > SdStyleSheet::getPropertySetInfo() throw(RuntimeException) 1084 { 1085 throwIfDisposed(); 1086 static Reference< XPropertySetInfo > xInfo; 1087 if( !xInfo.is() ) 1088 xInfo = GetStylePropertySet().getPropertySetInfo(); 1089 return xInfo; 1090 } 1091 1092 // -------------------------------------------------------------------- 1093 1094 void SAL_CALL SdStyleSheet::setPropertyValue( const OUString& aPropertyName, const Any& aValue ) throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException) 1095 { 1096 OGuard aGuard( Application::GetSolarMutex() ); 1097 throwIfDisposed(); 1098 1099 const SfxItemPropertySimpleEntry* pEntry = getPropertyMapEntry( aPropertyName ); 1100 if( pEntry == NULL ) 1101 { 1102 throw UnknownPropertyException(); 1103 } 1104 else 1105 { 1106 if( pEntry->nWID == SDRATTR_TEXTDIRECTION ) 1107 return; // not yet implemented for styles 1108 1109 if( pEntry->nWID == WID_STYLE_FAMILY ) 1110 throw PropertyVetoException(); 1111 1112 if( (pEntry->nWID == EE_PARA_NUMBULLET) && (GetFamily() == SD_STYLE_FAMILY_MASTERPAGE) ) 1113 { 1114 String aStr; 1115 const sal_uInt32 nTempHelpId = GetHelpId( aStr ); 1116 1117 if( (nTempHelpId >= HID_PSEUDOSHEET_OUTLINE2) && (nTempHelpId <= HID_PSEUDOSHEET_OUTLINE9) ) 1118 return; 1119 } 1120 1121 SfxItemSet &rStyleSet = GetItemSet(); 1122 1123 if( pEntry->nWID == OWN_ATTR_FILLBMP_MODE ) 1124 { 1125 BitmapMode eMode; 1126 if( aValue >>= eMode ) 1127 { 1128 rStyleSet.Put( XFillBmpStretchItem( eMode == BitmapMode_STRETCH ) ); 1129 rStyleSet.Put( XFillBmpTileItem( eMode == BitmapMode_REPEAT ) ); 1130 return; 1131 } 1132 throw IllegalArgumentException(); 1133 } 1134 1135 SfxItemSet aSet( GetPool().GetPool(), pEntry->nWID, pEntry->nWID); 1136 aSet.Put( rStyleSet ); 1137 1138 if( !aSet.Count() ) 1139 { 1140 if( EE_PARA_NUMBULLET == pEntry->nWID ) 1141 { 1142 Font aBulletFont; 1143 SdStyleSheetPool::PutNumBulletItem( this, aBulletFont ); 1144 aSet.Put( rStyleSet ); 1145 } 1146 else 1147 { 1148 aSet.Put( GetPool().GetPool().GetDefaultItem( pEntry->nWID ) ); 1149 } 1150 } 1151 1152 if( pEntry->nMemberId == MID_NAME && 1153 ( pEntry->nWID == XATTR_FILLBITMAP || pEntry->nWID == XATTR_FILLGRADIENT || 1154 pEntry->nWID == XATTR_FILLHATCH || pEntry->nWID == XATTR_FILLFLOATTRANSPARENCE || 1155 pEntry->nWID == XATTR_LINESTART || pEntry->nWID == XATTR_LINEEND || pEntry->nWID == XATTR_LINEDASH) ) 1156 { 1157 OUString aTempName; 1158 if(!(aValue >>= aTempName )) 1159 throw IllegalArgumentException(); 1160 1161 SvxShape::SetFillAttribute( pEntry->nWID, aTempName, aSet ); 1162 } 1163 else if(!SvxUnoTextRangeBase::SetPropertyValueHelper( aSet, pEntry, aValue, aSet )) 1164 { 1165 SvxItemPropertySet_setPropertyValue( GetStylePropertySet(), pEntry, aValue, aSet ); 1166 } 1167 1168 rStyleSet.Put( aSet ); 1169 Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED)); 1170 } 1171 } 1172 1173 // -------------------------------------------------------------------- 1174 1175 Any SAL_CALL SdStyleSheet::getPropertyValue( const OUString& PropertyName ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException) 1176 { 1177 OGuard aGuard( Application::GetSolarMutex() ); 1178 1179 throwIfDisposed(); 1180 1181 const SfxItemPropertySimpleEntry* pEntry = getPropertyMapEntry( PropertyName ); 1182 if( pEntry == NULL ) 1183 { 1184 throw UnknownPropertyException(); 1185 } 1186 else 1187 { 1188 Any aAny; 1189 1190 if( pEntry->nWID == WID_STYLE_FAMILY ) 1191 { 1192 if( nFamily == SD_STYLE_FAMILY_MASTERPAGE ) 1193 { 1194 const OUString aLayoutName( GetName() ); 1195 aAny <<= aLayoutName.copy( 0, aLayoutName.indexOf(OUString( RTL_CONSTASCII_USTRINGPARAM(SD_LT_SEPARATOR) ) ) ); 1196 } 1197 else 1198 { 1199 aAny <<= GetFamilyString(nFamily); 1200 } 1201 } 1202 else if( pEntry->nWID == WID_STYLE_DISPNAME ) 1203 { 1204 aAny <<= maDisplayName; 1205 } 1206 else if( pEntry->nWID == SDRATTR_TEXTDIRECTION ) 1207 { 1208 aAny <<= sal_False; 1209 } 1210 else if( pEntry->nWID == OWN_ATTR_FILLBMP_MODE ) 1211 { 1212 SfxItemSet &rStyleSet = GetItemSet(); 1213 1214 XFillBmpStretchItem* pStretchItem = (XFillBmpStretchItem*)rStyleSet.GetItem(XATTR_FILLBMP_STRETCH); 1215 XFillBmpTileItem* pTileItem = (XFillBmpTileItem*)rStyleSet.GetItem(XATTR_FILLBMP_TILE); 1216 1217 if( pStretchItem && pTileItem ) 1218 { 1219 if( pTileItem->GetValue() ) 1220 aAny <<= BitmapMode_REPEAT; 1221 else if( pStretchItem->GetValue() ) 1222 aAny <<= BitmapMode_STRETCH; 1223 else 1224 aAny <<= BitmapMode_NO_REPEAT; 1225 } 1226 } 1227 else 1228 { 1229 SfxItemSet aSet( GetPool().GetPool(), pEntry->nWID, pEntry->nWID); 1230 1231 const SfxPoolItem* pItem; 1232 SfxItemSet& rStyleSet = GetItemSet(); 1233 1234 if( rStyleSet.GetItemState( pEntry->nWID, sal_True, &pItem ) == SFX_ITEM_SET ) 1235 aSet.Put( *pItem ); 1236 1237 if( !aSet.Count() ) 1238 aSet.Put( GetPool().GetPool().GetDefaultItem( pEntry->nWID ) ); 1239 1240 if(SvxUnoTextRangeBase::GetPropertyValueHelper( aSet, pEntry, aAny )) 1241 return aAny; 1242 1243 // Hole Wert aus ItemSet 1244 aAny = SvxItemPropertySet_getPropertyValue( GetStylePropertySet(),pEntry, aSet ); 1245 } 1246 1247 if( *pEntry->pType != aAny.getValueType() ) 1248 { 1249 // since the sfx uint16 item now exports a sal_Int32, we may have to fix this here 1250 if( ( *pEntry->pType == ::getCppuType((const sal_Int16*)0)) && aAny.getValueType() == ::getCppuType((const sal_Int32*)0) ) 1251 { 1252 sal_Int32 nValue = 0; 1253 aAny >>= nValue; 1254 aAny <<= (sal_Int16)nValue; 1255 } 1256 else 1257 { 1258 DBG_ERROR("SvxShape::GetAnyForItem() Returnvalue has wrong Type!" ); 1259 } 1260 } 1261 1262 return aAny; 1263 } 1264 } 1265 1266 // -------------------------------------------------------------------- 1267 1268 void SAL_CALL SdStyleSheet::addPropertyChangeListener( const OUString& , const Reference< XPropertyChangeListener >& ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException) {} 1269 void SAL_CALL SdStyleSheet::removePropertyChangeListener( const OUString& , const Reference< XPropertyChangeListener >& ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException) {} 1270 void SAL_CALL SdStyleSheet::addVetoableChangeListener( const OUString& , const Reference< XVetoableChangeListener >& ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException) {} 1271 void SAL_CALL SdStyleSheet::removeVetoableChangeListener( const OUString& , const Reference< XVetoableChangeListener >& ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException) {} 1272 1273 // -------------------------------------------------------------------- 1274 // XPropertyState 1275 // -------------------------------------------------------------------- 1276 1277 PropertyState SAL_CALL SdStyleSheet::getPropertyState( const OUString& PropertyName ) throw(UnknownPropertyException, RuntimeException) 1278 { 1279 OGuard aGuard( Application::GetSolarMutex() ); 1280 1281 throwIfDisposed(); 1282 1283 const SfxItemPropertySimpleEntry* pEntry = getPropertyMapEntry( PropertyName ); 1284 1285 if( pEntry == NULL ) 1286 throw UnknownPropertyException(); 1287 1288 if( pEntry->nWID == WID_STYLE_FAMILY ) 1289 { 1290 return PropertyState_DIRECT_VALUE; 1291 } 1292 else if( pEntry->nWID == SDRATTR_TEXTDIRECTION ) 1293 { 1294 return PropertyState_DEFAULT_VALUE; 1295 } 1296 else if( pEntry->nWID == OWN_ATTR_FILLBMP_MODE ) 1297 { 1298 const SfxItemSet& rSet = GetItemSet(); 1299 1300 if( rSet.GetItemState( XATTR_FILLBMP_STRETCH, false ) == SFX_ITEM_SET || 1301 rSet.GetItemState( XATTR_FILLBMP_TILE, false ) == SFX_ITEM_SET ) 1302 { 1303 return PropertyState_DIRECT_VALUE; 1304 } 1305 else 1306 { 1307 return PropertyState_AMBIGUOUS_VALUE; 1308 } 1309 } 1310 else 1311 { 1312 SfxItemSet &rStyleSet = GetItemSet(); 1313 1314 PropertyState eState; 1315 1316 switch( rStyleSet.GetItemState( pEntry->nWID, sal_False ) ) 1317 { 1318 case SFX_ITEM_READONLY: 1319 case SFX_ITEM_SET: 1320 eState = PropertyState_DIRECT_VALUE; 1321 break; 1322 case SFX_ITEM_DEFAULT: 1323 eState = PropertyState_DEFAULT_VALUE; 1324 break; 1325 // case SFX_ITEM_DONTCARE: 1326 // case SFX_ITEM_DISABLED: 1327 default: 1328 eState = PropertyState_AMBIGUOUS_VALUE; 1329 break; 1330 } 1331 1332 // if a item is set, this doesn't mean we want it :) 1333 if( ( PropertyState_DIRECT_VALUE == eState ) ) 1334 { 1335 switch( pEntry->nWID ) 1336 { 1337 case XATTR_FILLBITMAP: 1338 case XATTR_FILLGRADIENT: 1339 case XATTR_FILLHATCH: 1340 case XATTR_FILLFLOATTRANSPARENCE: 1341 case XATTR_LINEEND: 1342 case XATTR_LINESTART: 1343 case XATTR_LINEDASH: 1344 { 1345 NameOrIndex* pItem = (NameOrIndex*)rStyleSet.GetItem((sal_uInt16)pEntry->nWID); 1346 if( ( pItem == NULL ) || ( pItem->GetName().Len() == 0) ) 1347 eState = PropertyState_DEFAULT_VALUE; 1348 } 1349 } 1350 } 1351 1352 return eState; 1353 } 1354 } 1355 1356 // -------------------------------------------------------------------- 1357 1358 Sequence< PropertyState > SAL_CALL SdStyleSheet::getPropertyStates( const Sequence< OUString >& aPropertyName ) throw(UnknownPropertyException, RuntimeException) 1359 { 1360 OGuard aGuard( Application::GetSolarMutex() ); 1361 1362 throwIfDisposed(); 1363 1364 sal_Int32 nCount = aPropertyName.getLength(); 1365 const OUString* pNames = aPropertyName.getConstArray(); 1366 1367 Sequence< PropertyState > aPropertyStateSequence( nCount ); 1368 PropertyState* pState = aPropertyStateSequence.getArray(); 1369 1370 while( nCount-- ) 1371 *pState++ = getPropertyState( *pNames++ ); 1372 1373 return aPropertyStateSequence; 1374 } 1375 1376 // -------------------------------------------------------------------- 1377 1378 void SAL_CALL SdStyleSheet::setPropertyToDefault( const OUString& PropertyName ) throw(UnknownPropertyException, RuntimeException) 1379 { 1380 OGuard aGuard( Application::GetSolarMutex() ); 1381 1382 throwIfDisposed(); 1383 1384 const SfxItemPropertySimpleEntry* pEntry = getPropertyMapEntry( PropertyName ); 1385 if( pEntry == NULL ) 1386 throw UnknownPropertyException(); 1387 1388 SfxItemSet &rStyleSet = GetItemSet(); 1389 1390 if( pEntry->nWID == OWN_ATTR_FILLBMP_MODE ) 1391 { 1392 rStyleSet.ClearItem( XATTR_FILLBMP_STRETCH ); 1393 rStyleSet.ClearItem( XATTR_FILLBMP_TILE ); 1394 } 1395 else 1396 { 1397 rStyleSet.ClearItem( pEntry->nWID ); 1398 } 1399 Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED)); 1400 } 1401 1402 // -------------------------------------------------------------------- 1403 1404 Any SAL_CALL SdStyleSheet::getPropertyDefault( const OUString& aPropertyName ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException) 1405 { 1406 OGuard aGuard( Application::GetSolarMutex() ); 1407 1408 throwIfDisposed(); 1409 1410 const SfxItemPropertySimpleEntry* pEntry = getPropertyMapEntry( aPropertyName ); 1411 if( pEntry == NULL ) 1412 throw UnknownPropertyException(); 1413 Any aRet; 1414 if( pEntry->nWID == WID_STYLE_FAMILY ) 1415 { 1416 aRet <<= GetFamilyString(nFamily); 1417 } 1418 else if( pEntry->nWID == SDRATTR_TEXTDIRECTION ) 1419 { 1420 aRet <<= sal_False; 1421 } 1422 else if( pEntry->nWID == OWN_ATTR_FILLBMP_MODE ) 1423 { 1424 aRet <<= BitmapMode_REPEAT; 1425 } 1426 else 1427 { 1428 SfxItemPool& rMyPool = GetPool().GetPool(); 1429 SfxItemSet aSet( rMyPool, pEntry->nWID, pEntry->nWID); 1430 aSet.Put( rMyPool.GetDefaultItem( pEntry->nWID ) ); 1431 aRet = SvxItemPropertySet_getPropertyValue( GetStylePropertySet(), pEntry, aSet ); 1432 } 1433 return aRet; 1434 } 1435 1436 // -------------------------------------------------------------------- 1437 1438 /** this is used because our property map is not sorted yet */ 1439 const SfxItemPropertySimpleEntry* SdStyleSheet::getPropertyMapEntry( const OUString& rPropertyName ) const throw() 1440 { 1441 return GetStylePropertySet().getPropertyMapEntry(rPropertyName); 1442 } 1443 1444