update dev300-m58
[ooovba.git] / sd / source / core / stlsheet.cxx
blob93a0783124890d0b8d7528a927bd8a29d5562fc1
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: stlsheet.cxx,v $
10 * $Revision: 1.23.32.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include <com/sun/star/beans/PropertyAttribute.hpp>
35 #include <com/sun/star/lang/DisposedException.hpp>
36 #include <com/sun/star/style/XStyle.hpp>
38 #include <osl/mutex.hxx>
39 #include <vos/mutex.hxx>
40 #include <vcl/svapp.hxx>
42 #include <boost/bind.hpp>
44 #include "eetext.hxx"
45 #include <svx/eeitem.hxx>
46 #include <svx/fhgtitem.hxx>
47 #include <svx/svdoattr.hxx>
48 #include <svx/ulspitem.hxx>
49 #include <svtools/smplhint.hxx>
50 #include <svtools/itemset.hxx>
52 #include <svx/xflbmtit.hxx>
53 #include <svx/xflbstit.hxx>
54 #include <svx/bulitem.hxx>
55 #include <svx/lrspitem.hxx>
56 #include <svx/unoshprp.hxx>
57 #include <svx/unoshape.hxx>
59 #include "stlsheet.hxx"
60 #include "sdresid.hxx"
61 #include "sdpage.hxx"
62 #include "drawdoc.hxx"
63 #include "stlpool.hxx"
64 #include "glob.hrc"
65 #include "app.hrc"
66 #include "glob.hxx"
67 #include "helpids.h"
68 #include "../ui/inc/DrawViewShell.hxx"
69 #include "../ui/inc/ViewShellBase.hxx"
71 using ::rtl::OUString;
72 using ::osl::MutexGuard;
73 using ::osl::ClearableMutexGuard;
74 using ::cppu::OInterfaceContainerHelper;
75 using namespace ::vos;
76 using namespace ::com::sun::star::uno;
77 using namespace ::com::sun::star::util;
78 using namespace ::com::sun::star::lang;
79 using namespace ::com::sun::star::style;
80 using namespace ::com::sun::star::beans;
81 using namespace ::com::sun::star::container;
82 using namespace ::com::sun::star::drawing;
84 #define WID_STYLE_DISPNAME 7998
85 #define WID_STYLE_FAMILY 7999
87 static SvxItemPropertySet& GetStylePropertySet()
89 static const SfxItemPropertyMapEntry aFullPropertyMap_Impl[] =
91 { RTL_CONSTASCII_STRINGPARAM("Family"), WID_STYLE_FAMILY, &::getCppuType((const OUString*)0), PropertyAttribute::READONLY, 0},
92 { RTL_CONSTASCII_STRINGPARAM("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &XNameContainer::static_type(), 0, 0},
93 { RTL_CONSTASCII_STRINGPARAM("DisplayName"), WID_STYLE_DISPNAME, &::getCppuType((const OUString*)0), PropertyAttribute::READONLY, 0},
95 SVX_UNOEDIT_NUMBERING_PROPERTIE,
96 SHADOW_PROPERTIES
97 LINE_PROPERTIES
98 LINE_PROPERTIES_START_END
99 FILL_PROPERTIES
100 EDGERADIUS_PROPERTIES
101 TEXT_PROPERTIES_DEFAULTS
102 CONNECTOR_PROPERTIES
103 SPECIAL_DIMENSIONING_PROPERTIES_DEFAULTS
104 {0,0,0,0,0,0}
107 static SvxItemPropertySet aPropSet( aFullPropertyMap_Impl );
108 return aPropSet;
111 class ModifyListenerForewarder : public SfxListener
113 public:
114 ModifyListenerForewarder( SdStyleSheet* pStyleSheet );
116 virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint);
118 private:
119 SdStyleSheet* mpStyleSheet;
122 ModifyListenerForewarder::ModifyListenerForewarder( SdStyleSheet* pStyleSheet )
123 : mpStyleSheet( pStyleSheet )
125 if( pStyleSheet )
127 SfxBroadcaster& rBC = static_cast< SfxBroadcaster& >( *pStyleSheet );
128 StartListening( rBC );
132 void ModifyListenerForewarder::Notify(SfxBroadcaster& /*rBC*/, const SfxHint& /*rHint*/)
134 if( mpStyleSheet )
135 mpStyleSheet->notifyModifyListener();
138 SdStyleSheet::SdStyleSheet(const OUString& rDisplayName, SfxStyleSheetBasePool& _rPool, SfxStyleFamily eFamily, USHORT _nMask)
139 : SdStyleSheetBase( UniString( rDisplayName ), _rPool, eFamily, _nMask)
140 , ::cppu::BaseMutex()
141 , msApiName( rDisplayName )
142 , mxPool( const_cast< SfxStyleSheetBasePool* >(&_rPool) )
143 , mrBHelper( m_aMutex )
147 SdStyleSheet::SdStyleSheet( const SdStyleSheet & r )
148 : SdStyleSheetBase( r )
149 , ::cppu::BaseMutex()
150 , msApiName( r.msApiName )
151 , mxPool( r.mxPool )
152 , mrBHelper( m_aMutex )
156 SdStyleSheet::~SdStyleSheet()
158 delete pSet;
159 pSet = NULL; // damit nachfolgende Destruktoren eine Chance haben
162 void SdStyleSheet::SetApiName( const OUString& rApiName )
164 msApiName = rApiName;
167 rtl::OUString SdStyleSheet::GetApiName() const
169 if( msApiName.getLength() )
170 return msApiName;
171 else
172 return GetName();
176 void SdStyleSheet::Load (SvStream& rIn, USHORT nVersion)
178 SfxStyleSheetBase::Load(rIn, nVersion);
180 // Die Default-Maske war frueher 0xAFFE.
181 // Aus dieser Default-Maske wurden die benoetigten Flags ausmaskiert.
182 // Nun wurde das Flag SFXSTYLEBIT_READONLY eingefuehrt, was dazu
183 // das alle StyleSheets read-only waren.
184 // Da im Draw kein StyleSheet read-only sein soll, wird an dieser Stelle
185 // das Flag zurueckgesetzt.
186 nMask &= ~SFXSTYLEBIT_READONLY;
189 /*************************************************************************
191 |* Store
193 \************************************************************************/
195 void SdStyleSheet::Store(SvStream& rOut)
197 SfxStyleSheetBase::Store(rOut);
200 /*************************************************************************
202 |* Parent setzen
204 \************************************************************************/
206 BOOL SdStyleSheet::SetParent(const String& rParentName)
208 BOOL bResult = FALSE;
210 if (SfxStyleSheet::SetParent(rParentName))
212 // PseudoStyleSheets haben keine eigenen ItemSets
213 if (nFamily != SD_STYLE_FAMILY_PSEUDO)
215 if( rParentName.Len() )
217 SfxStyleSheetBase* pStyle = rPool.Find(rParentName, nFamily);
218 if (pStyle)
220 bResult = TRUE;
221 SfxItemSet& rParentSet = pStyle->GetItemSet();
222 GetItemSet().SetParent(&rParentSet);
223 Broadcast( SfxSimpleHint( SFX_HINT_DATACHANGED ) );
226 else
228 bResult = TRUE;
229 GetItemSet().SetParent(NULL);
230 Broadcast( SfxSimpleHint( SFX_HINT_DATACHANGED ) );
233 else
235 bResult = TRUE;
238 return bResult;
241 /*************************************************************************
243 |* ItemSet ggfs. erzeugen und herausreichen
245 \************************************************************************/
247 SfxItemSet& SdStyleSheet::GetItemSet()
249 if (nFamily == SD_STYLE_FAMILY_GRAPHICS || nFamily == SD_STYLE_FAMILY_MASTERPAGE)
251 // ggfs. das ItemSet 'on demand' anlegen
252 if (!pSet)
254 USHORT nWhichPairTable[] = { XATTR_LINE_FIRST, XATTR_LINE_LAST,
255 XATTR_FILL_FIRST, XATTR_FILL_LAST,
257 SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST,
258 SDRATTR_TEXT_MINFRAMEHEIGHT, SDRATTR_TEXT_CONTOURFRAME,
260 SDRATTR_TEXT_WORDWRAP, SDRATTR_TEXT_AUTOGROWSIZE,
262 SDRATTR_EDGE_FIRST, SDRATTR_EDGE_LAST,
263 SDRATTR_MEASURE_FIRST, SDRATTR_MEASURE_LAST,
265 EE_PARA_START, EE_CHAR_END,
267 SDRATTR_XMLATTRIBUTES, SDRATTR_TEXT_USEFIXEDCELLHEIGHT,
269 SDRATTR_3D_FIRST, SDRATTR_3D_LAST,
270 0, 0 };
272 pSet = new SfxItemSet(GetPool().GetPool(), nWhichPairTable);
275 return *pSet;
278 else if( nFamily == SD_STYLE_FAMILY_CELL )
280 if (!pSet)
282 USHORT nWhichPairTable[] = { XATTR_LINE_FIRST, XATTR_LINE_LAST,
283 XATTR_FILL_FIRST, XATTR_FILL_LAST,
285 SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST,
286 SDRATTR_TEXT_MINFRAMEHEIGHT, SDRATTR_TEXT_CONTOURFRAME,
288 SDRATTR_TEXT_WORDWRAP, SDRATTR_TEXT_AUTOGROWSIZE,
290 EE_PARA_START, EE_CHAR_END,
292 SDRATTR_TABLE_FIRST, SDRATTR_TABLE_LAST,
293 SDRATTR_XMLATTRIBUTES, SDRATTR_XMLATTRIBUTES,
295 0, 0 };
297 pSet = new SfxItemSet(GetPool().GetPool(), nWhichPairTable);
300 return *pSet;
303 // dies ist eine Stellvertretervorlage fuer die interne Vorlage des
304 // aktuellen Praesentationslayouts: dessen ItemSet returnieren
305 else
307 // return (GetRealStyleSheet()->GetItemSet());
309 SdStyleSheet* pSdSheet = GetRealStyleSheet();
311 if (pSdSheet)
313 return(pSdSheet->GetItemSet());
315 else
317 if (!pSet)
319 USHORT nWhichPairTable[] = { XATTR_LINE_FIRST, XATTR_LINE_LAST,
320 XATTR_FILL_FIRST, XATTR_FILL_LAST,
322 SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST,
323 SDRATTR_TEXT_MINFRAMEHEIGHT, SDRATTR_TEXT_CONTOURFRAME,
325 SDRATTR_TEXT_WORDWRAP, SDRATTR_TEXT_AUTOGROWSIZE,
327 SDRATTR_EDGE_FIRST, SDRATTR_EDGE_LAST,
328 SDRATTR_MEASURE_FIRST, SDRATTR_MEASURE_LAST,
330 EE_PARA_START, EE_CHAR_END,
332 SDRATTR_XMLATTRIBUTES, SDRATTR_TEXT_USEFIXEDCELLHEIGHT,
334 SDRATTR_3D_FIRST, SDRATTR_3D_LAST,
335 0, 0 };
337 pSet = new SfxItemSet(GetPool().GetPool(), nWhichPairTable);
340 return(*pSet);
345 /*************************************************************************
347 |* IsUsed(), eine Vorlage gilt als benutzt, wenn sie von eingefuegten Objekten
348 |* oder von benutzten Vorlagen referenziert wird
350 \************************************************************************/
352 BOOL SdStyleSheet::IsUsed() const
354 BOOL bResult = FALSE;
356 USHORT nListenerCount = GetListenerCount();
357 if (nListenerCount > 0)
359 for (USHORT n = 0; n < nListenerCount; n++)
361 SfxListener* pListener = GetListener(n);
362 if( pListener == this )
363 continue;
365 // NULL-Pointer ist im Listener-Array erlaubt
366 if (pListener && pListener->ISA(SdrAttrObj))
368 bResult = ((SdrAttrObj*)pListener)->IsInserted();
370 else if (pListener && pListener->ISA(SfxStyleSheet))
372 bResult = ((SfxStyleSheet*)pListener)->IsUsed();
374 if (bResult)
375 break;
379 if( !bResult )
381 MutexGuard aGuard( mrBHelper.rMutex );
383 OInterfaceContainerHelper * pContainer = mrBHelper.getContainer( XModifyListener::static_type() );
384 if( pContainer )
386 Sequence< Reference< XInterface > > aModifyListeners( pContainer->getElements() );
387 Reference< XInterface > *p = aModifyListeners.getArray();
388 sal_Int32 nCount = aModifyListeners.getLength();
389 while( nCount-- && !bResult )
391 Reference< XStyle > xStyle( *p++, UNO_QUERY );
392 if( xStyle.is() )
393 bResult = xStyle->isInUse();
397 return bResult;
400 /*************************************************************************
402 |* das StyleSheet ermitteln, fuer das dieses StyleSheet steht
404 \************************************************************************/
406 SdStyleSheet* SdStyleSheet::GetRealStyleSheet() const
408 String aRealStyle;
409 String aSep( RTL_CONSTASCII_USTRINGPARAM( SD_LT_SEPARATOR ));
410 SdStyleSheet* pRealStyle = NULL;
411 SdDrawDocument* pDoc = ((SdStyleSheetPool&) rPool).GetDoc();
413 ::sd::DrawViewShell* pDrawViewShell = 0;
415 ::sd::ViewShellBase* pBase = dynamic_cast< ::sd::ViewShellBase* >( SfxViewShell::Current() );
416 if( pBase )
417 pDrawViewShell = dynamic_cast< ::sd::DrawViewShell* >( pBase->GetMainViewShell().get() );
419 if (pDrawViewShell && pDrawViewShell->GetDoc() == pDoc)
421 SdPage* pPage = pDrawViewShell->getCurrentPage();
422 if( pPage )
424 aRealStyle = pPage->GetLayoutName();
425 // cut after seperator string
426 aRealStyle.Erase(aRealStyle.Search(aSep) + aSep.Len());
430 if (aRealStyle.Len() == 0)
432 SdPage* pPage = pDoc->GetSdPage(0, PK_STANDARD);
434 if (pPage)
436 aRealStyle = pDoc->GetSdPage(0, PK_STANDARD)->GetLayoutName();
438 else
440 // Noch keine Seite vorhanden
441 // Dieses kann beim Aktualisieren vonDokumentvorlagen vorkommen
442 SfxStyleSheetIterator aIter(&rPool, SD_STYLE_FAMILY_MASTERPAGE);
443 SfxStyleSheetBase* pSheet = aIter.First();
444 if( pSheet )
445 aRealStyle = pSheet->GetName();
448 aRealStyle.Erase(aRealStyle.Search(aSep) + aSep.Len());
451 // jetzt vom Namen (landessprachlich angepasst) auf den internen
452 // Namen (unabhaengig von der Landessprache) mappen
453 String aInternalName;
455 if (aName == String(SdResId(STR_PSEUDOSHEET_TITLE)))
457 aInternalName = String(SdResId(STR_LAYOUT_TITLE));
459 else if (aName == String(SdResId(STR_PSEUDOSHEET_SUBTITLE)))
461 aInternalName = String(SdResId(STR_LAYOUT_SUBTITLE));
463 else if (aName == String(SdResId(STR_PSEUDOSHEET_BACKGROUND)))
465 aInternalName = String(SdResId(STR_LAYOUT_BACKGROUND));
467 else if (aName == String(SdResId(STR_PSEUDOSHEET_BACKGROUNDOBJECTS)))
469 aInternalName = String(SdResId(STR_LAYOUT_BACKGROUNDOBJECTS));
471 else if (aName == String(SdResId(STR_PSEUDOSHEET_NOTES)))
473 aInternalName = String(SdResId(STR_LAYOUT_NOTES));
475 else
477 String aOutlineStr(SdResId(STR_PSEUDOSHEET_OUTLINE));
478 USHORT nPos = aName.Search(aOutlineStr);
479 if (nPos != STRING_NOTFOUND)
481 String aNumStr(aName.Copy(aOutlineStr.Len()));
482 aInternalName = String(SdResId(STR_LAYOUT_OUTLINE));
483 aInternalName += aNumStr;
487 aRealStyle += aInternalName;
488 pRealStyle = static_cast< SdStyleSheet* >( rPool.Find(aRealStyle, SD_STYLE_FAMILY_MASTERPAGE) );
490 #ifdef DBG_UTIL
491 if( !pRealStyle )
493 SfxStyleSheetIterator aIter(&rPool, SD_STYLE_FAMILY_MASTERPAGE);
494 if( aIter.Count() > 0 )
495 // StyleSheet not found, but pool already loaded
496 DBG_ASSERT(pRealStyle, "Internal StyleSheet not found");
498 #endif
500 return pRealStyle;
503 /*************************************************************************
505 |* das PseudoStyleSheet ermitteln, durch das dieses StyleSheet vertreten wird
507 \************************************************************************/
509 SdStyleSheet* SdStyleSheet::GetPseudoStyleSheet() const
511 SdStyleSheet* pPseudoStyle = NULL;
512 String aSep( RTL_CONSTASCII_USTRINGPARAM( SD_LT_SEPARATOR ));
513 String aStyleName(aName);
514 // ohne Layoutnamen und Separator
515 aStyleName.Erase(0, aStyleName.Search(aSep) + aSep.Len());
517 if (aStyleName == String(SdResId(STR_LAYOUT_TITLE)))
519 aStyleName = String(SdResId(STR_PSEUDOSHEET_TITLE));
521 else if (aStyleName == String(SdResId(STR_LAYOUT_SUBTITLE)))
523 aStyleName = String(SdResId(STR_PSEUDOSHEET_SUBTITLE));
525 else if (aStyleName == String(SdResId(STR_LAYOUT_BACKGROUND)))
527 aStyleName = String(SdResId(STR_PSEUDOSHEET_BACKGROUND));
529 else if (aStyleName == String(SdResId(STR_LAYOUT_BACKGROUNDOBJECTS)))
531 aStyleName = String(SdResId(STR_PSEUDOSHEET_BACKGROUNDOBJECTS));
533 else if (aStyleName == String(SdResId(STR_LAYOUT_NOTES)))
535 aStyleName = String(SdResId(STR_PSEUDOSHEET_NOTES));
537 else
539 String aOutlineStr((SdResId(STR_LAYOUT_OUTLINE)));
540 USHORT nPos = aStyleName.Search(aOutlineStr);
541 if (nPos != STRING_NOTFOUND)
543 String aNumStr(aStyleName.Copy(aOutlineStr.Len()));
544 aStyleName = String(SdResId(STR_PSEUDOSHEET_OUTLINE));
545 aStyleName += aNumStr;
549 pPseudoStyle = static_cast<SdStyleSheet*>(rPool.Find(aStyleName, SD_STYLE_FAMILY_PSEUDO));
550 DBG_ASSERT(pPseudoStyle, "PseudoStyleSheet nicht gefunden");
552 return pPseudoStyle;
556 /*************************************************************************
558 |* Notify
560 \************************************************************************/
562 void SdStyleSheet::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
564 // erstmal die Basisklassenfunktionalitaet
565 SfxStyleSheet::Notify(rBC, rHint);
567 // wenn der Stellvertreter ein Notify bezueglich geaenderter Attribute
568 // bekommt, sorgt er dafuer, dass das eigentlich gemeinte StyleSheet
569 // broadcastet
570 SfxSimpleHint* pSimple = PTR_CAST(SfxSimpleHint, &rHint);
571 ULONG nId = pSimple == NULL ? 0 : pSimple->GetId();
572 if (nId == SFX_HINT_DATACHANGED && nFamily == SD_STYLE_FAMILY_PSEUDO)
574 SdStyleSheet* pRealStyle = GetRealStyleSheet();
575 if (pRealStyle)
576 pRealStyle->Broadcast(rHint);
580 /*************************************************************************
581 |* AdjustToFontHeight passt die Bulletbreite und den linken Texteinzug
582 |* des uebergebenen ItemSets dessen Fonthoehe an. Die neuen Werte werden so
583 |* berechnet, dass das Verhaeltnis zur Fonthoehe so ist wie im StyleSheet.
585 |* bOnlyMissingItems legt fest, ob lediglich nicht gesetzte Items ergaenzt
586 |* (TRUE) oder explizit gesetzte Items ueberschreiben werden sollen (FALSE)
588 \************************************************************************/
590 void SdStyleSheet::AdjustToFontHeight(SfxItemSet& rSet, BOOL bOnlyMissingItems)
592 // Bulletbreite und Texteinzug an neue Fonthoehe
593 // anpassen, wenn sie nicht explizit gesetzt wurden
594 SfxStyleFamily eFamily = nFamily;
595 String aStyleName(aName);
596 if (eFamily == SD_STYLE_FAMILY_PSEUDO)
598 SfxStyleSheet* pRealStyle = GetRealStyleSheet();
599 eFamily = pRealStyle->GetFamily();
600 aStyleName = pRealStyle->GetName();
603 if (eFamily == SD_STYLE_FAMILY_MASTERPAGE &&
604 aStyleName.Search(String(SdResId(STR_LAYOUT_OUTLINE))) != STRING_NOTFOUND &&
605 rSet.GetItemState(EE_CHAR_FONTHEIGHT) == SFX_ITEM_SET)
607 const SfxItemSet* pCurSet = &GetItemSet();
608 UINT32 nNewHeight = ((SvxFontHeightItem&)rSet.Get(EE_CHAR_FONTHEIGHT)).GetHeight();
609 UINT32 nOldHeight = ((SvxFontHeightItem&)pCurSet->Get(EE_CHAR_FONTHEIGHT)).GetHeight();
611 if (rSet.GetItemState(EE_PARA_BULLET) != SFX_ITEM_SET || !bOnlyMissingItems)
613 const SvxBulletItem& rBItem = (const SvxBulletItem&)pCurSet->Get(EE_PARA_BULLET);
614 double fBulletFraction = double(rBItem.GetWidth()) / nOldHeight;
615 SvxBulletItem aNewBItem(rBItem);
616 aNewBItem.SetWidth((UINT32)(fBulletFraction * nNewHeight));
617 rSet.Put(aNewBItem);
620 if (rSet.GetItemState(EE_PARA_LRSPACE) != SFX_ITEM_SET || !bOnlyMissingItems)
622 const SvxLRSpaceItem& rLRItem = (const SvxLRSpaceItem&)pCurSet->Get(EE_PARA_LRSPACE);
623 double fIndentFraction = double(rLRItem.GetTxtLeft()) / nOldHeight;
624 SvxLRSpaceItem aNewLRItem(rLRItem);
625 aNewLRItem.SetTxtLeft((USHORT)(fIndentFraction * nNewHeight));
626 double fFirstIndentFraction = double(rLRItem.GetTxtFirstLineOfst()) / nOldHeight;
627 aNewLRItem.SetTxtFirstLineOfst((short)(fFirstIndentFraction * nNewHeight));
628 rSet.Put(aNewLRItem);
631 if (rSet.GetItemState(EE_PARA_ULSPACE) != SFX_ITEM_SET || !bOnlyMissingItems)
633 const SvxULSpaceItem& rULItem = (const SvxULSpaceItem&)pCurSet->Get(EE_PARA_ULSPACE);
634 SvxULSpaceItem aNewULItem(rULItem);
635 double fLowerFraction = double(rULItem.GetLower()) / nOldHeight;
636 aNewULItem.SetLower((USHORT)(fLowerFraction * nNewHeight));
637 double fUpperFraction = double(rULItem.GetUpper()) / nOldHeight;
638 aNewULItem.SetUpper((USHORT)(fUpperFraction * nNewHeight));
639 rSet.Put(aNewULItem);
644 // --------------------------------------------------------------------
646 BOOL SdStyleSheet::HasFollowSupport() const
648 return FALSE;
651 // --------------------------------------------------------------------
653 BOOL SdStyleSheet::HasParentSupport() const
655 return TRUE;
658 // --------------------------------------------------------------------
660 BOOL SdStyleSheet::HasClearParentSupport() const
662 return TRUE;
665 // --------------------------------------------------------------------
667 BOOL SdStyleSheet::SetName( const UniString& rName )
669 return SfxStyleSheet::SetName( rName );
672 // --------------------------------------------------------------------
674 void SdStyleSheet::SetHelpId( const String& r, ULONG nId )
676 SfxStyleSheet::SetHelpId( r, nId );
678 if( (nId >= HID_PSEUDOSHEET_OUTLINE1) && ( nId <= HID_PSEUDOSHEET_OUTLINE9 ) )
680 msApiName = OUString( RTL_CONSTASCII_USTRINGPARAM("outline") );
681 msApiName += OUString( (sal_Unicode)( '1' + (nId - HID_PSEUDOSHEET_OUTLINE1) ) );
683 else
685 static struct ApiNameMap
687 const sal_Char* mpApiName;
688 sal_uInt32 mnApiNameLength;
689 sal_uInt32 mnHelpId;
691 pApiNameMap[] =
693 { RTL_CONSTASCII_STRINGPARAM( "title" ), HID_PSEUDOSHEET_TITLE },
694 { RTL_CONSTASCII_STRINGPARAM( "subtitle" ), HID_PSEUDOSHEET_SUBTITLE },
695 { RTL_CONSTASCII_STRINGPARAM( "background" ), HID_PSEUDOSHEET_BACKGROUND },
696 { RTL_CONSTASCII_STRINGPARAM( "backgroundobjects" ),HID_PSEUDOSHEET_BACKGROUNDOBJECTS },
697 { RTL_CONSTASCII_STRINGPARAM( "notes" ), HID_PSEUDOSHEET_NOTES },
698 { RTL_CONSTASCII_STRINGPARAM( "standard" ), HID_STANDARD_STYLESHEET_NAME },
699 { RTL_CONSTASCII_STRINGPARAM( "objectwitharrow" ), HID_POOLSHEET_OBJWITHARROW },
700 { RTL_CONSTASCII_STRINGPARAM( "objectwithshadow" ), HID_POOLSHEET_OBJWITHSHADOW },
701 { RTL_CONSTASCII_STRINGPARAM( "objectwithoutfill" ),HID_POOLSHEET_OBJWITHOUTFILL },
702 { RTL_CONSTASCII_STRINGPARAM( "text" ), HID_POOLSHEET_TEXT },
703 { RTL_CONSTASCII_STRINGPARAM( "textbody" ), HID_POOLSHEET_TEXTBODY },
704 { RTL_CONSTASCII_STRINGPARAM( "textbodyjustfied" ), HID_POOLSHEET_TEXTBODY_JUSTIFY },
705 { RTL_CONSTASCII_STRINGPARAM( "textbodyindent" ), HID_POOLSHEET_TEXTBODY_INDENT },
706 { RTL_CONSTASCII_STRINGPARAM( "title" ), HID_POOLSHEET_TITLE },
707 { RTL_CONSTASCII_STRINGPARAM( "title1" ), HID_POOLSHEET_TITLE1 },
708 { RTL_CONSTASCII_STRINGPARAM( "title2" ), HID_POOLSHEET_TITLE2 },
709 { RTL_CONSTASCII_STRINGPARAM( "headline" ), HID_POOLSHEET_HEADLINE },
710 { RTL_CONSTASCII_STRINGPARAM( "headline1" ), HID_POOLSHEET_HEADLINE1 },
711 { RTL_CONSTASCII_STRINGPARAM( "headline2" ), HID_POOLSHEET_HEADLINE2 },
712 { RTL_CONSTASCII_STRINGPARAM( "measure" ), HID_POOLSHEET_MEASURE },
713 { 0, 0, 0 }
716 ApiNameMap* p = pApiNameMap;
717 while( p->mpApiName )
719 if( nId == p->mnHelpId )
721 msApiName = OUString( p->mpApiName, p->mnApiNameLength, RTL_TEXTENCODING_ASCII_US );
722 break;
724 p++;
729 // --------------------------------------------------------------------
731 OUString SdStyleSheet::GetFamilyString( SfxStyleFamily eFamily )
733 switch( eFamily )
735 case SD_STYLE_FAMILY_CELL:
736 return OUString( RTL_CONSTASCII_USTRINGPARAM( "cell" ) );
737 default:
738 DBG_ERROR( "SdStyleSheet::GetFamilyString(), illegal family!" );
739 case SD_STYLE_FAMILY_GRAPHICS:
740 return OUString( RTL_CONSTASCII_USTRINGPARAM( "graphics" ) );
744 // --------------------------------------------------------------------
746 void SdStyleSheet::throwIfDisposed() throw (RuntimeException)
748 if( !mxPool.is() )
749 throw DisposedException();
752 // --------------------------------------------------------------------
754 SdStyleSheet* SdStyleSheet::CreateEmptyUserStyle( SfxStyleSheetBasePool& rPool, SfxStyleFamily eFamily )
756 OUString aPrefix( RTL_CONSTASCII_USTRINGPARAM("user") );
757 OUString aName;
758 sal_Int32 nIndex = 1;
761 aName = aPrefix + OUString::valueOf( nIndex++ );
763 while( rPool.Find( aName, eFamily ) != 0 );
765 return new SdStyleSheet(aName, rPool, eFamily, SFXSTYLEBIT_USERDEF);
768 // --------------------------------------------------------------------
769 // XInterface
770 // --------------------------------------------------------------------
773 Any SAL_CALL SdStyleSheet::queryInterface( const ::com::sun::star::uno::Type& aType ) throw (RuntimeException)
775 return SdStyleSheetBase::queryInterface( aType );
778 // --------------------------------------------------------------------
780 void SAL_CALL SdStyleSheet::acquire( ) throw ()
782 SdStyleSheetBase::acquire();
785 // --------------------------------------------------------------------
787 void SAL_CALL SdStyleSheet::release( ) throw ()
789 if (osl_decrementInterlockedCount( &m_refCount ) == 0)
791 // restore reference count:
792 osl_incrementInterlockedCount( &m_refCount );
793 if (! mrBHelper.bDisposed) try
795 dispose();
797 catch (RuntimeException const& exc)
798 { // don't break throw ()
799 OSL_ENSURE(
800 false, OUStringToOString(
801 exc.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
802 static_cast<void>(exc);
804 OSL_ASSERT( mrBHelper.bDisposed );
805 SdStyleSheetBase::release();
809 // --------------------------------------------------------------------
810 // XWeak
811 // --------------------------------------------------------------------
813 Reference< XAdapter > SAL_CALL SdStyleSheet::queryAdapter( ) throw (RuntimeException)
815 return SdStyleSheetBase::queryAdapter();
818 // --------------------------------------------------------------------
819 // XTypeProvider
820 // --------------------------------------------------------------------
822 Sequence< Type > SAL_CALL SdStyleSheet::getTypes( ) throw (RuntimeException)
824 return SdStyleSheetBase::getTypes();
827 // --------------------------------------------------------------------
829 Sequence< ::sal_Int8 > SAL_CALL SdStyleSheet::getImplementationId( ) throw (RuntimeException)
831 return SdStyleSheetBase::getImplementationId();
834 // --------------------------------------------------------------------
835 // XComponent
836 // --------------------------------------------------------------------
838 void SAL_CALL SdStyleSheet::dispose( ) throw (RuntimeException)
840 ClearableMutexGuard aGuard( mrBHelper.rMutex );
841 if (!mrBHelper.bDisposed && !mrBHelper.bInDispose)
843 mrBHelper.bInDispose = sal_True;
844 aGuard.clear();
847 // side effect: keeping a reference to this
848 EventObject aEvt( static_cast< OWeakObject * >( this ) );
851 mrBHelper.aLC.disposeAndClear( aEvt );
852 disposing();
854 catch (...)
856 MutexGuard aGuard2( mrBHelper.rMutex );
857 // bDisposed and bInDispose must be set in this order:
858 mrBHelper.bDisposed = sal_True;
859 mrBHelper.bInDispose = sal_False;
860 throw;
862 MutexGuard aGuard2( mrBHelper.rMutex );
863 // bDisposed and bInDispose must be set in this order:
864 mrBHelper.bDisposed = sal_True;
865 mrBHelper.bInDispose = sal_False;
867 catch (RuntimeException &)
869 throw;
871 catch (Exception & exc)
873 throw RuntimeException(
874 OUString( RTL_CONSTASCII_USTRINGPARAM(
875 "unexpected UNO exception caught: ") ) +
876 exc.Message, Reference< XInterface >() );
881 // --------------------------------------------------------------------
883 void SdStyleSheet::disposing()
885 mxPool.clear();
888 // --------------------------------------------------------------------
890 void SAL_CALL SdStyleSheet::addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException)
892 ClearableMutexGuard aGuard( mrBHelper.rMutex );
893 if (mrBHelper.bDisposed || mrBHelper.bInDispose)
895 aGuard.clear();
896 EventObject aEvt( static_cast< OWeakObject * >( this ) );
897 xListener->disposing( aEvt );
899 else
901 mrBHelper.addListener( ::getCppuType( &xListener ), xListener );
905 // --------------------------------------------------------------------
907 void SAL_CALL SdStyleSheet::removeEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException)
909 mrBHelper.removeListener( ::getCppuType( &xListener ), xListener );
912 //------------------------------------------------------------------------
913 // XModifyBroadcaster
914 //------------------------------------------------------------------------
916 void SAL_CALL SdStyleSheet::addModifyListener( const Reference< XModifyListener >& xListener ) throw (RuntimeException)
918 ClearableMutexGuard aGuard( mrBHelper.rMutex );
919 if (mrBHelper.bDisposed || mrBHelper.bInDispose)
921 aGuard.clear();
922 EventObject aEvt( static_cast< OWeakObject * >( this ) );
923 xListener->disposing( aEvt );
925 else
927 if( !mpModifyListenerForewarder.get() )
928 mpModifyListenerForewarder.reset( new ModifyListenerForewarder( this ) );
929 mrBHelper.addListener( XModifyListener::static_type(), xListener );
933 //------------------------------------------------------------------------
935 void SAL_CALL SdStyleSheet::removeModifyListener( const Reference< XModifyListener >& xListener ) throw (RuntimeException)
937 mrBHelper.removeListener( XModifyListener::static_type(), xListener );
940 //------------------------------------------------------------------------
942 void SdStyleSheet::notifyModifyListener()
944 MutexGuard aGuard( mrBHelper.rMutex );
946 OInterfaceContainerHelper * pContainer = mrBHelper.getContainer( XModifyListener::static_type() );
947 if( pContainer )
949 EventObject aEvt( static_cast< OWeakObject * >( this ) );
950 pContainer->forEach<XModifyListener>( boost::bind( &XModifyListener::modified, _1, boost::cref( aEvt ) ) );
955 // --------------------------------------------------------------------
956 // XServiceInfo
957 // --------------------------------------------------------------------
959 OUString SAL_CALL SdStyleSheet::getImplementationName() throw(RuntimeException)
961 return OUString::createFromAscii( "SdStyleSheet" );
964 // --------------------------------------------------------------------
966 sal_Bool SAL_CALL SdStyleSheet::supportsService( const OUString& ServiceName ) throw(RuntimeException)
968 return SvxServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
971 // --------------------------------------------------------------------
973 Sequence< OUString > SAL_CALL SdStyleSheet::getSupportedServiceNames() throw(RuntimeException)
975 Sequence< OUString > aNameSequence( 10 );
976 OUString* pStrings = aNameSequence.getArray();
978 *pStrings++ = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.style.Style" ) );
979 *pStrings++ = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.FillProperties" ) );
980 *pStrings++ = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.LineProperties" ) );
981 *pStrings++ = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.ShadowProperties" ) );
982 *pStrings++ = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.ConnectorProperties" ) );
983 *pStrings++ = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.MeasureProperties" ) );
984 *pStrings++ = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.style.ParagraphProperties" ) );
985 *pStrings++ = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.style.CharacterProperties" ) );
986 *pStrings++ = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.TextProperties" ) );
987 *pStrings++ = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.Text" ) );
989 return aNameSequence;
992 // --------------------------------------------------------------------
993 // XNamed
994 // --------------------------------------------------------------------
996 OUString SAL_CALL SdStyleSheet::getName() throw(RuntimeException)
998 OGuard aGuard( Application::GetSolarMutex() );
999 throwIfDisposed();
1000 return GetApiName();
1003 // --------------------------------------------------------------------
1005 void SAL_CALL SdStyleSheet::setName( const OUString& rName ) throw(RuntimeException)
1007 OGuard aGuard( Application::GetSolarMutex() );
1008 throwIfDisposed();
1009 if( IsUserDefined() )
1011 if( SetName( rName ) )
1013 msApiName = rName;
1014 Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
1019 // --------------------------------------------------------------------
1020 // XStyle
1021 // --------------------------------------------------------------------
1023 sal_Bool SAL_CALL SdStyleSheet::isUserDefined() throw(RuntimeException)
1025 OGuard aGuard( Application::GetSolarMutex() );
1026 throwIfDisposed();
1027 return IsUserDefined() ? sal_True : sal_False;
1030 // --------------------------------------------------------------------
1032 sal_Bool SAL_CALL SdStyleSheet::isInUse() throw(RuntimeException)
1034 OGuard aGuard( Application::GetSolarMutex() );
1035 throwIfDisposed();
1036 return IsUsed() ? sal_True : sal_False;
1039 // --------------------------------------------------------------------
1041 OUString SAL_CALL SdStyleSheet::getParentStyle() throw(RuntimeException)
1043 OGuard aGuard( Application::GetSolarMutex() );
1044 throwIfDisposed();
1046 if( GetParent().Len() )
1048 SdStyleSheet* pParentStyle = static_cast< SdStyleSheet* >( mxPool->Find( GetParent(), nFamily ) );
1049 if( pParentStyle )
1050 return pParentStyle->msApiName;
1052 return OUString();
1055 // --------------------------------------------------------------------
1057 void SAL_CALL SdStyleSheet::setParentStyle( const OUString& rParentName ) throw(NoSuchElementException, RuntimeException)
1059 OGuard aGuard( Application::GetSolarMutex() );
1060 throwIfDisposed();
1062 if( IsUserDefined() )
1064 if( rParentName.getLength() )
1066 const SfxStyles& rStyles = mxPool->GetStyles();
1068 for( SfxStyles::const_iterator iter( rStyles.begin() ); iter != rStyles.end(); iter++ )
1070 SdStyleSheet* pStyle = static_cast< SdStyleSheet* >( (*iter).get() );
1071 if( pStyle && (pStyle->nFamily == nFamily) && (pStyle->msApiName == rParentName) )
1073 if( pStyle != this )
1074 SetParent( pStyle->GetName() );
1075 return;
1078 throw NoSuchElementException();
1080 else
1082 SetParent( rParentName );
1087 // --------------------------------------------------------------------
1088 // XPropertySet
1089 // --------------------------------------------------------------------
1091 Reference< XPropertySetInfo > SdStyleSheet::getPropertySetInfo() throw(RuntimeException)
1093 throwIfDisposed();
1094 static Reference< XPropertySetInfo > xInfo;
1095 if( !xInfo.is() )
1096 xInfo = GetStylePropertySet().getPropertySetInfo();
1097 return xInfo;
1100 // --------------------------------------------------------------------
1102 void SAL_CALL SdStyleSheet::setPropertyValue( const OUString& aPropertyName, const Any& aValue ) throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
1104 OGuard aGuard( Application::GetSolarMutex() );
1105 throwIfDisposed();
1107 const SfxItemPropertySimpleEntry* pEntry = getPropertyMapEntry( aPropertyName );
1108 if( pEntry == NULL )
1110 throw UnknownPropertyException();
1112 else
1114 if( pEntry->nWID == SDRATTR_TEXTDIRECTION )
1115 return; // not yet implemented for styles
1117 if( pEntry->nWID == WID_STYLE_FAMILY )
1118 throw PropertyVetoException();
1120 if( (pEntry->nWID == EE_PARA_NUMBULLET) && (GetFamily() == SD_STYLE_FAMILY_MASTERPAGE) )
1122 String aStr;
1123 const sal_uInt32 nTempHelpId = GetHelpId( aStr );
1125 if( (nTempHelpId >= HID_PSEUDOSHEET_OUTLINE2) && (nTempHelpId <= HID_PSEUDOSHEET_OUTLINE9) )
1126 return;
1129 SfxItemSet &rStyleSet = GetItemSet();
1131 if( pEntry->nWID == OWN_ATTR_FILLBMP_MODE )
1133 BitmapMode eMode;
1134 if( aValue >>= eMode )
1136 rStyleSet.Put( XFillBmpStretchItem( eMode == BitmapMode_STRETCH ) );
1137 rStyleSet.Put( XFillBmpTileItem( eMode == BitmapMode_REPEAT ) );
1138 return;
1140 throw IllegalArgumentException();
1143 SfxItemSet aSet( GetPool().GetPool(), pEntry->nWID, pEntry->nWID);
1144 aSet.Put( rStyleSet );
1146 if( !aSet.Count() )
1148 if( EE_PARA_NUMBULLET == pEntry->nWID )
1150 Font aBulletFont;
1151 SdStyleSheetPool::PutNumBulletItem( this, aBulletFont );
1152 aSet.Put( rStyleSet );
1154 else
1156 aSet.Put( GetPool().GetPool().GetDefaultItem( pEntry->nWID ) );
1160 if( pEntry->nMemberId == MID_NAME &&
1161 ( pEntry->nWID == XATTR_FILLBITMAP || pEntry->nWID == XATTR_FILLGRADIENT ||
1162 pEntry->nWID == XATTR_FILLHATCH || pEntry->nWID == XATTR_FILLFLOATTRANSPARENCE ||
1163 pEntry->nWID == XATTR_LINESTART || pEntry->nWID == XATTR_LINEEND || pEntry->nWID == XATTR_LINEDASH) )
1165 OUString aTempName;
1166 if(!(aValue >>= aTempName ))
1167 throw IllegalArgumentException();
1169 SvxShape::SetFillAttribute( pEntry->nWID, aTempName, aSet );
1171 else if(!SvxUnoTextRangeBase::SetPropertyValueHelper( aSet, pEntry, aValue, aSet ))
1173 GetStylePropertySet().setPropertyValue( pEntry, aValue, aSet );
1176 rStyleSet.Put( aSet );
1177 Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
1181 // --------------------------------------------------------------------
1183 Any SAL_CALL SdStyleSheet::getPropertyValue( const OUString& PropertyName ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
1185 OGuard aGuard( Application::GetSolarMutex() );
1187 throwIfDisposed();
1189 const SfxItemPropertySimpleEntry* pEntry = getPropertyMapEntry( PropertyName );
1190 if( pEntry == NULL )
1192 throw UnknownPropertyException();
1194 else
1196 Any aAny;
1198 if( pEntry->nWID == WID_STYLE_FAMILY )
1200 if( nFamily == SD_STYLE_FAMILY_MASTERPAGE )
1202 const OUString aLayoutName( GetName() );
1203 aAny <<= aLayoutName.copy( 0, aLayoutName.indexOf(OUString( RTL_CONSTASCII_USTRINGPARAM(SD_LT_SEPARATOR) ) ) );
1205 else
1207 aAny <<= GetFamilyString(nFamily);
1210 else if( pEntry->nWID == WID_STYLE_DISPNAME )
1212 aAny <<= maDisplayName;
1214 else if( pEntry->nWID == SDRATTR_TEXTDIRECTION )
1216 aAny <<= sal_False;
1218 else if( pEntry->nWID == OWN_ATTR_FILLBMP_MODE )
1220 SfxItemSet &rStyleSet = GetItemSet();
1222 XFillBmpStretchItem* pStretchItem = (XFillBmpStretchItem*)rStyleSet.GetItem(XATTR_FILLBMP_STRETCH);
1223 XFillBmpTileItem* pTileItem = (XFillBmpTileItem*)rStyleSet.GetItem(XATTR_FILLBMP_TILE);
1225 if( pStretchItem && pTileItem )
1227 if( pTileItem->GetValue() )
1228 aAny <<= BitmapMode_REPEAT;
1229 else if( pStretchItem->GetValue() )
1230 aAny <<= BitmapMode_STRETCH;
1231 else
1232 aAny <<= BitmapMode_NO_REPEAT;
1235 else
1237 SfxItemSet aSet( GetPool().GetPool(), pEntry->nWID, pEntry->nWID);
1239 const SfxPoolItem* pItem;
1240 SfxItemSet& rStyleSet = GetItemSet();
1242 if( rStyleSet.GetItemState( pEntry->nWID, sal_True, &pItem ) == SFX_ITEM_SET )
1243 aSet.Put( *pItem );
1245 if( !aSet.Count() )
1246 aSet.Put( GetPool().GetPool().GetDefaultItem( pEntry->nWID ) );
1248 if(SvxUnoTextRangeBase::GetPropertyValueHelper( aSet, pEntry, aAny ))
1249 return aAny;
1251 // Hole Wert aus ItemSet
1252 aAny = GetStylePropertySet().getPropertyValue( pEntry, aSet );
1255 if( *pEntry->pType != aAny.getValueType() )
1257 // since the sfx uint16 item now exports a sal_Int32, we may have to fix this here
1258 if( ( *pEntry->pType == ::getCppuType((const sal_Int16*)0)) && aAny.getValueType() == ::getCppuType((const sal_Int32*)0) )
1260 sal_Int32 nValue = 0;
1261 aAny >>= nValue;
1262 aAny <<= (sal_Int16)nValue;
1264 else
1266 DBG_ERROR("SvxShape::GetAnyForItem() Returnvalue has wrong Type!" );
1270 return aAny;
1274 // --------------------------------------------------------------------
1276 void SAL_CALL SdStyleSheet::addPropertyChangeListener( const OUString& , const Reference< XPropertyChangeListener >& ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException) {}
1277 void SAL_CALL SdStyleSheet::removePropertyChangeListener( const OUString& , const Reference< XPropertyChangeListener >& ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException) {}
1278 void SAL_CALL SdStyleSheet::addVetoableChangeListener( const OUString& , const Reference< XVetoableChangeListener >& ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException) {}
1279 void SAL_CALL SdStyleSheet::removeVetoableChangeListener( const OUString& , const Reference< XVetoableChangeListener >& ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException) {}
1281 // --------------------------------------------------------------------
1282 // XPropertyState
1283 // --------------------------------------------------------------------
1285 PropertyState SAL_CALL SdStyleSheet::getPropertyState( const OUString& PropertyName ) throw(UnknownPropertyException, RuntimeException)
1287 OGuard aGuard( Application::GetSolarMutex() );
1289 throwIfDisposed();
1291 const SfxItemPropertySimpleEntry* pEntry = getPropertyMapEntry( PropertyName );
1293 if( pEntry == NULL )
1294 throw UnknownPropertyException();
1296 if( pEntry->nWID == WID_STYLE_FAMILY )
1298 return PropertyState_DIRECT_VALUE;
1300 else if( pEntry->nWID == SDRATTR_TEXTDIRECTION )
1302 return PropertyState_DEFAULT_VALUE;
1304 else if( pEntry->nWID == OWN_ATTR_FILLBMP_MODE )
1306 const SfxItemSet& rSet = GetItemSet();
1308 if( rSet.GetItemState( XATTR_FILLBMP_STRETCH, false ) == SFX_ITEM_SET ||
1309 rSet.GetItemState( XATTR_FILLBMP_TILE, false ) == SFX_ITEM_SET )
1311 return PropertyState_DIRECT_VALUE;
1313 else
1315 return PropertyState_AMBIGUOUS_VALUE;
1318 else
1320 SfxItemSet &rStyleSet = GetItemSet();
1322 PropertyState eState;
1324 switch( rStyleSet.GetItemState( pEntry->nWID, sal_False ) )
1326 case SFX_ITEM_READONLY:
1327 case SFX_ITEM_SET:
1328 eState = PropertyState_DIRECT_VALUE;
1329 break;
1330 case SFX_ITEM_DEFAULT:
1331 eState = PropertyState_DEFAULT_VALUE;
1332 break;
1333 // case SFX_ITEM_DONTCARE:
1334 // case SFX_ITEM_DISABLED:
1335 default:
1336 eState = PropertyState_AMBIGUOUS_VALUE;
1337 break;
1340 // if a item is set, this doesn't mean we want it :)
1341 if( ( PropertyState_DIRECT_VALUE == eState ) )
1343 switch( pEntry->nWID )
1345 case XATTR_FILLBITMAP:
1346 case XATTR_FILLGRADIENT:
1347 case XATTR_FILLHATCH:
1348 case XATTR_FILLFLOATTRANSPARENCE:
1349 case XATTR_LINEEND:
1350 case XATTR_LINESTART:
1351 case XATTR_LINEDASH:
1353 NameOrIndex* pItem = (NameOrIndex*)rStyleSet.GetItem((USHORT)pEntry->nWID);
1354 if( ( pItem == NULL ) || ( pItem->GetName().Len() == 0) )
1355 eState = PropertyState_DEFAULT_VALUE;
1360 return eState;
1364 // --------------------------------------------------------------------
1366 Sequence< PropertyState > SAL_CALL SdStyleSheet::getPropertyStates( const Sequence< OUString >& aPropertyName ) throw(UnknownPropertyException, RuntimeException)
1368 OGuard aGuard( Application::GetSolarMutex() );
1370 throwIfDisposed();
1372 sal_Int32 nCount = aPropertyName.getLength();
1373 const OUString* pNames = aPropertyName.getConstArray();
1375 Sequence< PropertyState > aPropertyStateSequence( nCount );
1376 PropertyState* pState = aPropertyStateSequence.getArray();
1378 while( nCount-- )
1379 *pState++ = getPropertyState( *pNames++ );
1381 return aPropertyStateSequence;
1384 // --------------------------------------------------------------------
1386 void SAL_CALL SdStyleSheet::setPropertyToDefault( const OUString& PropertyName ) throw(UnknownPropertyException, RuntimeException)
1388 OGuard aGuard( Application::GetSolarMutex() );
1390 throwIfDisposed();
1392 const SfxItemPropertySimpleEntry* pEntry = getPropertyMapEntry( PropertyName );
1393 if( pEntry == NULL )
1394 throw UnknownPropertyException();
1396 SfxItemSet &rStyleSet = GetItemSet();
1398 if( pEntry->nWID == OWN_ATTR_FILLBMP_MODE )
1400 rStyleSet.ClearItem( XATTR_FILLBMP_STRETCH );
1401 rStyleSet.ClearItem( XATTR_FILLBMP_TILE );
1403 else
1405 rStyleSet.ClearItem( pEntry->nWID );
1407 Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
1410 // --------------------------------------------------------------------
1412 Any SAL_CALL SdStyleSheet::getPropertyDefault( const OUString& aPropertyName ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
1414 OGuard aGuard( Application::GetSolarMutex() );
1416 throwIfDisposed();
1418 const SfxItemPropertySimpleEntry* pEntry = getPropertyMapEntry( aPropertyName );
1419 if( pEntry == NULL )
1420 throw UnknownPropertyException();
1421 Any aRet;
1422 if( pEntry->nWID == WID_STYLE_FAMILY )
1424 aRet <<= GetFamilyString(nFamily);
1426 else if( pEntry->nWID == SDRATTR_TEXTDIRECTION )
1428 aRet <<= sal_False;
1430 else if( pEntry->nWID == OWN_ATTR_FILLBMP_MODE )
1432 aRet <<= BitmapMode_REPEAT;
1434 else
1436 SfxItemPool& rMyPool = GetPool().GetPool();
1437 SfxItemSet aSet( rMyPool, pEntry->nWID, pEntry->nWID);
1438 aSet.Put( rMyPool.GetDefaultItem( pEntry->nWID ) );
1439 aRet = GetStylePropertySet().getPropertyValue( pEntry, aSet );
1441 return aRet;
1444 // --------------------------------------------------------------------
1446 /** this is used because our property map is not sorted yet */
1447 const SfxItemPropertySimpleEntry* SdStyleSheet::getPropertyMapEntry( const OUString& rPropertyName ) const throw()
1449 return GetStylePropertySet().getPropertyMapEntry(rPropertyName);