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