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