xref: /aoo42x/main/svx/source/unodraw/unopool.cxx (revision 301f0c9f)
1f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f6e50924SAndrew Rist  * distributed with this work for additional information
6f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10f6e50924SAndrew Rist  *
11f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12f6e50924SAndrew Rist  *
13f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17f6e50924SAndrew Rist  * specific language governing permissions and limitations
18f6e50924SAndrew Rist  * under the License.
19f6e50924SAndrew Rist  *
20f6e50924SAndrew Rist  *************************************************************/
21f6e50924SAndrew Rist 
22f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
27cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_PROPERTYSTATE_HDL_
28cdf0e10cSrcweir #include <com/sun/star/beans/PropertyState.hpp>
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <comphelper/propertysetinfo.hxx>
32cdf0e10cSrcweir #include <rtl/uuid.h>
33cdf0e10cSrcweir #include <vos/mutex.hxx>
34cdf0e10cSrcweir #include <vcl/svapp.hxx>
35cdf0e10cSrcweir #include "svx/unopool.hxx"
36cdf0e10cSrcweir #include <svx/svdmodel.hxx>
37cdf0e10cSrcweir #include <svx/svdpool.hxx>
38cdf0e10cSrcweir #include <svx/unoprov.hxx>
39cdf0e10cSrcweir #include <svx/svdobj.hxx>
40cdf0e10cSrcweir #include <svx/unoshprp.hxx>
41cdf0e10cSrcweir #include <svx/xflbstit.hxx>
42cdf0e10cSrcweir #include <svx/xflbmtit.hxx>
43cdf0e10cSrcweir #include <svx/unopage.hxx>
44cdf0e10cSrcweir #include <svx/svdetc.hxx>
45cdf0e10cSrcweir #include <editeng/editeng.hxx>
46cdf0e10cSrcweir 
47cdf0e10cSrcweir #include "svx/unoapi.hxx"
48cdf0e10cSrcweir #include <memory>
49cdf0e10cSrcweir 
50cdf0e10cSrcweir using namespace ::com::sun::star;
51cdf0e10cSrcweir using namespace ::rtl;
52cdf0e10cSrcweir using namespace ::cppu;
53cdf0e10cSrcweir 
SvxUnoDrawPool(SdrModel * pModel,sal_Int32 nServiceId)54cdf0e10cSrcweir SvxUnoDrawPool::SvxUnoDrawPool( SdrModel* pModel, sal_Int32 nServiceId ) throw()
55cdf0e10cSrcweir : PropertySetHelper( SvxPropertySetInfoPool::getOrCreate( nServiceId ) ), mpModel( pModel )
56cdf0e10cSrcweir {
57cdf0e10cSrcweir 	init();
58cdf0e10cSrcweir }
59cdf0e10cSrcweir 
60cdf0e10cSrcweir /* deprecated */
SvxUnoDrawPool(SdrModel * pModel)61cdf0e10cSrcweir SvxUnoDrawPool::SvxUnoDrawPool( SdrModel* pModel ) throw()
62cdf0e10cSrcweir : PropertySetHelper( SvxPropertySetInfoPool::getOrCreate( SVXUNO_SERVICEID_COM_SUN_STAR_DRAWING_DEFAULTS ) ), mpModel( pModel )
63cdf0e10cSrcweir {
64cdf0e10cSrcweir 	init();
65cdf0e10cSrcweir }
66cdf0e10cSrcweir 
~SvxUnoDrawPool()67cdf0e10cSrcweir SvxUnoDrawPool::~SvxUnoDrawPool() throw()
68cdf0e10cSrcweir {
69*301f0c9fSArmin Le Grand     // memory leak #119991#: to release the secondary pool created in function SvxUnoDrawPool::init()
70*301f0c9fSArmin Le Grand     SfxItemPool* pSecondaryPool = mpDefaultsPool->GetSecondaryPool();
71e262f9e6SJian Fang Zhang 
72*301f0c9fSArmin Le Grand     // #119991# delete master pool first, this will reset the pMaster entry in pSecondaryPool as needed.
73*301f0c9fSArmin Le Grand     // This is the needed order (see SdrModel::~SdrModel for example)
74cdf0e10cSrcweir     SfxItemPool::Free(mpDefaultsPool);
75*301f0c9fSArmin Le Grand 
76*301f0c9fSArmin Le Grand     // delete pSecondaryPool if exists
77*301f0c9fSArmin Le Grand     if(pSecondaryPool)
78*301f0c9fSArmin Le Grand     {
79*301f0c9fSArmin Le Grand         SfxItemPool::Free(pSecondaryPool);
80*301f0c9fSArmin Le Grand     }
81cdf0e10cSrcweir }
82cdf0e10cSrcweir 
init()83cdf0e10cSrcweir void SvxUnoDrawPool::init()
84cdf0e10cSrcweir {
85cdf0e10cSrcweir     mpDefaultsPool = new SdrItemPool();
86cdf0e10cSrcweir 	SfxItemPool* pOutlPool=EditEngine::CreatePool();
87cdf0e10cSrcweir     mpDefaultsPool->SetSecondaryPool(pOutlPool);
88cdf0e10cSrcweir 
89cdf0e10cSrcweir     SdrModel::SetTextDefaults( mpDefaultsPool, SdrEngineDefaults::GetFontHeight() );
90cdf0e10cSrcweir     mpDefaultsPool->SetDefaultMetric((SfxMapUnit)SdrEngineDefaults::GetMapUnit());
91cdf0e10cSrcweir     mpDefaultsPool->FreezeIdRanges();
92cdf0e10cSrcweir }
93cdf0e10cSrcweir 
getModelPool(sal_Bool bReadOnly)94cdf0e10cSrcweir SfxItemPool* SvxUnoDrawPool::getModelPool( sal_Bool bReadOnly ) throw()
95cdf0e10cSrcweir {
96cdf0e10cSrcweir 	if( mpModel	)
97cdf0e10cSrcweir 	{
98cdf0e10cSrcweir 		return &mpModel->GetItemPool();
99cdf0e10cSrcweir 	}
100cdf0e10cSrcweir 	else
101cdf0e10cSrcweir 	{
102cdf0e10cSrcweir 		if( bReadOnly )
103cdf0e10cSrcweir             return mpDefaultsPool;
104cdf0e10cSrcweir 		else
105cdf0e10cSrcweir 			return NULL;
106cdf0e10cSrcweir 	}
107cdf0e10cSrcweir }
108cdf0e10cSrcweir 
getAny(SfxItemPool * pPool,const comphelper::PropertyMapEntry * pEntry,uno::Any & rValue)109cdf0e10cSrcweir void SvxUnoDrawPool::getAny( SfxItemPool* pPool, const comphelper::PropertyMapEntry* pEntry, uno::Any& rValue )
110cdf0e10cSrcweir 	throw(beans::UnknownPropertyException)
111cdf0e10cSrcweir {
112cdf0e10cSrcweir 	switch( pEntry->mnHandle )
113cdf0e10cSrcweir 	{
114cdf0e10cSrcweir 	case OWN_ATTR_FILLBMP_MODE:
115cdf0e10cSrcweir 		{
116cdf0e10cSrcweir 			XFillBmpStretchItem* pStretchItem = (XFillBmpStretchItem*)&pPool->GetDefaultItem(XATTR_FILLBMP_STRETCH);
117cdf0e10cSrcweir 			XFillBmpTileItem* pTileItem = (XFillBmpTileItem*)&pPool->GetDefaultItem(XATTR_FILLBMP_TILE);
118cdf0e10cSrcweir 			if( pTileItem && pTileItem->GetValue() )
119cdf0e10cSrcweir 			{
120cdf0e10cSrcweir 				rValue <<= drawing::BitmapMode_REPEAT;
121cdf0e10cSrcweir 			}
122cdf0e10cSrcweir 			else if( pStretchItem && pStretchItem->GetValue() )
123cdf0e10cSrcweir 			{
124cdf0e10cSrcweir 				rValue <<= drawing::BitmapMode_STRETCH;
125cdf0e10cSrcweir 			}
126cdf0e10cSrcweir 			else
127cdf0e10cSrcweir 			{
128cdf0e10cSrcweir 				rValue <<= drawing::BitmapMode_NO_REPEAT;
129cdf0e10cSrcweir 			}
130cdf0e10cSrcweir 			break;
131cdf0e10cSrcweir 		}
132cdf0e10cSrcweir     default:
133cdf0e10cSrcweir 		{
134cdf0e10cSrcweir 			const SfxMapUnit eMapUnit = pPool ? pPool->GetMetric((sal_uInt16)pEntry->mnHandle) : SFX_MAPUNIT_100TH_MM;
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 			sal_uInt8 nMemberId = pEntry->mnMemberId & (~SFX_METRIC_ITEM);
137cdf0e10cSrcweir 			if( eMapUnit == SFX_MAPUNIT_100TH_MM )
138cdf0e10cSrcweir 				nMemberId &= (~CONVERT_TWIPS);
139cdf0e10cSrcweir 
140cdf0e10cSrcweir             // DVO, OD 10.10.2003 #i18732#
141cdf0e10cSrcweir             // Assure, that ID is a Which-ID (it could be a Slot-ID.)
142cdf0e10cSrcweir             // Thus, convert handle to Which-ID.
143cdf0e10cSrcweir             pPool->GetDefaultItem( pPool->GetWhich( (sal_uInt16)pEntry->mnHandle ) ).QueryValue( rValue, nMemberId );
144cdf0e10cSrcweir 		}
145cdf0e10cSrcweir 	}
146cdf0e10cSrcweir 
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 	// check for needed metric translation
149cdf0e10cSrcweir 	const SfxMapUnit eMapUnit = pPool->GetMetric((sal_uInt16)pEntry->mnHandle);
150cdf0e10cSrcweir 	if(pEntry->mnMemberId & SFX_METRIC_ITEM && eMapUnit != SFX_MAPUNIT_100TH_MM)
151cdf0e10cSrcweir 	{
152cdf0e10cSrcweir 		SvxUnoConvertToMM( eMapUnit, rValue );
153cdf0e10cSrcweir 	}
154cdf0e10cSrcweir 	// convert int32 to correct enum type if needed
155cdf0e10cSrcweir 	else if ( pEntry->mpType->getTypeClass() == uno::TypeClass_ENUM && rValue.getValueType() == ::getCppuType((const sal_Int32*)0) )
156cdf0e10cSrcweir 	{
157cdf0e10cSrcweir 		sal_Int32 nEnum;
158cdf0e10cSrcweir 		rValue >>= nEnum;
159cdf0e10cSrcweir 
160cdf0e10cSrcweir 		rValue.setValue( &nEnum, *pEntry->mpType );
161cdf0e10cSrcweir 	}
162cdf0e10cSrcweir }
163cdf0e10cSrcweir 
putAny(SfxItemPool * pPool,const comphelper::PropertyMapEntry * pEntry,const uno::Any & rValue)164cdf0e10cSrcweir void SvxUnoDrawPool::putAny( SfxItemPool* pPool, const comphelper::PropertyMapEntry* pEntry, const uno::Any& rValue )
165cdf0e10cSrcweir 	throw(beans::UnknownPropertyException, lang::IllegalArgumentException)
166cdf0e10cSrcweir {
167cdf0e10cSrcweir 	uno::Any aValue( rValue );
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 	const SfxMapUnit eMapUnit = pPool->GetMetric((sal_uInt16)pEntry->mnHandle);
170cdf0e10cSrcweir 	if(pEntry->mnMemberId & SFX_METRIC_ITEM && eMapUnit != SFX_MAPUNIT_100TH_MM)
171cdf0e10cSrcweir 	{
172cdf0e10cSrcweir 		SvxUnoConvertFromMM( eMapUnit, aValue );
173cdf0e10cSrcweir 	}
174cdf0e10cSrcweir 
175cdf0e10cSrcweir     // DVO, OD 10.10.2003 #i18732#
176cdf0e10cSrcweir     // Assure, that ID is a Which-ID (it could be a Slot-ID.)
177cdf0e10cSrcweir     // Thus, convert handle to Which-ID.
178cdf0e10cSrcweir     const sal_uInt16 nWhich = pPool->GetWhich( (sal_uInt16)pEntry->mnHandle );
179cdf0e10cSrcweir 	switch( nWhich )
180cdf0e10cSrcweir 	{
181cdf0e10cSrcweir 		case OWN_ATTR_FILLBMP_MODE:
182cdf0e10cSrcweir 			do
183cdf0e10cSrcweir 			{
184cdf0e10cSrcweir 				drawing::BitmapMode eMode;
185cdf0e10cSrcweir 				if(!(aValue >>= eMode) )
186cdf0e10cSrcweir 				{
187cdf0e10cSrcweir 					sal_Int32 nMode = 0;
188cdf0e10cSrcweir 					if(!(aValue >>= nMode))
189cdf0e10cSrcweir 						throw lang::IllegalArgumentException();
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 					eMode = (drawing::BitmapMode)nMode;
192cdf0e10cSrcweir 				}
193cdf0e10cSrcweir 
194cdf0e10cSrcweir 				pPool->SetPoolDefaultItem( XFillBmpStretchItem( eMode == drawing::BitmapMode_STRETCH ) );
195cdf0e10cSrcweir 				pPool->SetPoolDefaultItem( XFillBmpTileItem( eMode == drawing::BitmapMode_REPEAT ) );
196cdf0e10cSrcweir 				return;
197cdf0e10cSrcweir 			}
198cdf0e10cSrcweir 			while(0);
199cdf0e10cSrcweir 
200cdf0e10cSrcweir     default:
201cdf0e10cSrcweir 		{
202cdf0e10cSrcweir 			::std::auto_ptr<SfxPoolItem> pNewItem( pPool->GetDefaultItem( nWhich ).Clone() );
203cdf0e10cSrcweir 			sal_uInt8 nMemberId = pEntry->mnMemberId & (~SFX_METRIC_ITEM);
204cdf0e10cSrcweir 			if( !pPool || (pPool->GetMetric(nWhich) == SFX_MAPUNIT_100TH_MM) )
205cdf0e10cSrcweir 				nMemberId &= (~CONVERT_TWIPS);
206cdf0e10cSrcweir 
207cdf0e10cSrcweir 			if( !pNewItem->PutValue( aValue, nMemberId ) )
208cdf0e10cSrcweir 				throw lang::IllegalArgumentException();
209cdf0e10cSrcweir 
210cdf0e10cSrcweir 			pPool->SetPoolDefaultItem( *pNewItem );
211cdf0e10cSrcweir 		}
212cdf0e10cSrcweir 	}
213cdf0e10cSrcweir }
214cdf0e10cSrcweir 
_setPropertyValues(const comphelper::PropertyMapEntry ** ppEntries,const uno::Any * pValues)215cdf0e10cSrcweir void SvxUnoDrawPool::_setPropertyValues( const comphelper::PropertyMapEntry** ppEntries, const uno::Any* pValues )
216cdf0e10cSrcweir 	throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException )
217cdf0e10cSrcweir {
218cdf0e10cSrcweir 	vos::OGuard aGuard( Application::GetSolarMutex() );
219cdf0e10cSrcweir 
220cdf0e10cSrcweir 	SfxItemPool* pPool = getModelPool( sal_False );
221cdf0e10cSrcweir 
222cdf0e10cSrcweir 	DBG_ASSERT( pPool, "I need a SfxItemPool!" );
223cdf0e10cSrcweir 	if( NULL == pPool )
224cdf0e10cSrcweir 		throw beans::UnknownPropertyException();
225cdf0e10cSrcweir 
226cdf0e10cSrcweir 	while( *ppEntries )
227cdf0e10cSrcweir 		putAny( pPool, *ppEntries++, *pValues++ );
228cdf0e10cSrcweir }
229cdf0e10cSrcweir 
_getPropertyValues(const comphelper::PropertyMapEntry ** ppEntries,uno::Any * pValue)230cdf0e10cSrcweir void SvxUnoDrawPool::_getPropertyValues( const comphelper::PropertyMapEntry** ppEntries, uno::Any* pValue )
231cdf0e10cSrcweir 	throw(beans::UnknownPropertyException, lang::WrappedTargetException )
232cdf0e10cSrcweir {
233cdf0e10cSrcweir 	vos::OGuard aGuard( Application::GetSolarMutex() );
234cdf0e10cSrcweir 
235cdf0e10cSrcweir 	SfxItemPool* pPool = getModelPool( sal_True );
236cdf0e10cSrcweir 
237cdf0e10cSrcweir 	DBG_ASSERT( pPool, "I need a SfxItemPool!" );
238cdf0e10cSrcweir 	if( NULL == pPool )
239cdf0e10cSrcweir 		throw beans::UnknownPropertyException();
240cdf0e10cSrcweir 
241cdf0e10cSrcweir 	while( *ppEntries )
242cdf0e10cSrcweir 		getAny( pPool, *ppEntries++, *pValue++ );
243cdf0e10cSrcweir }
244cdf0e10cSrcweir 
_getPropertyStates(const comphelper::PropertyMapEntry ** ppEntries,beans::PropertyState * pStates)245cdf0e10cSrcweir void SvxUnoDrawPool::_getPropertyStates( const comphelper::PropertyMapEntry** ppEntries, beans::PropertyState* pStates )
246cdf0e10cSrcweir 	throw(beans::UnknownPropertyException )
247cdf0e10cSrcweir {
248cdf0e10cSrcweir 	vos::OGuard aGuard( Application::GetSolarMutex() );
249cdf0e10cSrcweir 
250cdf0e10cSrcweir 	SfxItemPool* pPool = getModelPool( sal_True );
251cdf0e10cSrcweir 
252cdf0e10cSrcweir     if( pPool && pPool != mpDefaultsPool )
253cdf0e10cSrcweir 	{
254cdf0e10cSrcweir 		while( *ppEntries )
255cdf0e10cSrcweir 		{
256cdf0e10cSrcweir             // OD 13.10.2003 #i18732#
257cdf0e10cSrcweir             // Assure, that ID is a Which-ID (it could be a Slot-ID.)
258cdf0e10cSrcweir             // Thus, convert handle to Which-ID.
259cdf0e10cSrcweir             const sal_uInt16 nWhich = pPool->GetWhich( ((sal_uInt16)(*ppEntries)->mnHandle) );
260cdf0e10cSrcweir 
261cdf0e10cSrcweir 			switch( nWhich )
262cdf0e10cSrcweir 			{
263cdf0e10cSrcweir 			case OWN_ATTR_FILLBMP_MODE:
264cdf0e10cSrcweir 				{
265cdf0e10cSrcweir                     // use method <IsStaticDefaultItem(..)> instead of using
266cdf0e10cSrcweir                     // probably incompatible item pool <mpDefaultPool>.
267cdf0e10cSrcweir                     if ( IsStaticDefaultItem( &(pPool->GetDefaultItem( XATTR_FILLBMP_STRETCH )) ) ||
268cdf0e10cSrcweir                          IsStaticDefaultItem( &(pPool->GetDefaultItem( XATTR_FILLBMP_TILE )) ) )
269cdf0e10cSrcweir 					{
270cdf0e10cSrcweir 						*pStates = beans::PropertyState_DEFAULT_VALUE;
271cdf0e10cSrcweir 					}
272cdf0e10cSrcweir 					else
273cdf0e10cSrcweir 					{
274cdf0e10cSrcweir 						*pStates = beans::PropertyState_DIRECT_VALUE;
275cdf0e10cSrcweir 					}
276cdf0e10cSrcweir 				}
277cdf0e10cSrcweir 				break;
278cdf0e10cSrcweir 			default:
279cdf0e10cSrcweir                 // OD 13.10.2003 #i18732# - correction:
280cdf0e10cSrcweir                 // use method <IsStaticDefaultItem(..)> instead of using probably
281cdf0e10cSrcweir                 // incompatible item pool <mpDefaultPool>.
282cdf0e10cSrcweir                 const SfxPoolItem& r1 = pPool->GetDefaultItem( nWhich );
283cdf0e10cSrcweir                 //const SfxPoolItem& r2 = mpDefaultPool->GetDefaultItem( nWhich );
284cdf0e10cSrcweir 
285cdf0e10cSrcweir                 if ( IsStaticDefaultItem( &r1 ) )
286cdf0e10cSrcweir 				{
287cdf0e10cSrcweir 					*pStates = beans::PropertyState_DEFAULT_VALUE;
288cdf0e10cSrcweir 				}
289cdf0e10cSrcweir 				else
290cdf0e10cSrcweir 				{
291cdf0e10cSrcweir 					*pStates = beans::PropertyState_DIRECT_VALUE;
292cdf0e10cSrcweir 				}
293cdf0e10cSrcweir 			}
294cdf0e10cSrcweir 
295cdf0e10cSrcweir 			pStates++;
296cdf0e10cSrcweir 			ppEntries++;
297cdf0e10cSrcweir 		}
298cdf0e10cSrcweir 	}
299cdf0e10cSrcweir 	else
300cdf0e10cSrcweir 	{
301cdf0e10cSrcweir 		// as long as we have no model, all properties are default
302cdf0e10cSrcweir 		while( *ppEntries++ )
303cdf0e10cSrcweir 			*pStates++ = beans::PropertyState_DEFAULT_VALUE;
304cdf0e10cSrcweir 		return;
305cdf0e10cSrcweir 	}
306cdf0e10cSrcweir }
307cdf0e10cSrcweir 
_setPropertyToDefault(const comphelper::PropertyMapEntry * pEntry)308cdf0e10cSrcweir void SvxUnoDrawPool::_setPropertyToDefault( const comphelper::PropertyMapEntry* pEntry )
309cdf0e10cSrcweir 	throw(beans::UnknownPropertyException )
310cdf0e10cSrcweir {
311cdf0e10cSrcweir 	vos::OGuard aGuard( Application::GetSolarMutex() );
312cdf0e10cSrcweir 
313cdf0e10cSrcweir 	SfxItemPool* pPool = getModelPool( sal_True );
314cdf0e10cSrcweir 
315cdf0e10cSrcweir     // OD 10.10.2003 #i18732#
316cdf0e10cSrcweir     // Assure, that ID is a Which-ID (it could be a Slot-ID.)
317cdf0e10cSrcweir     // Thus, convert handle to Which-ID.
318cdf0e10cSrcweir     const sal_uInt16 nWhich = pPool->GetWhich( (sal_uInt16)pEntry->mnHandle );
319cdf0e10cSrcweir     if ( pPool && pPool != mpDefaultsPool )
320cdf0e10cSrcweir     {
321cdf0e10cSrcweir         // OD 13.10.2003 #i18732# - use method <ResetPoolDefaultItem(..)>
322cdf0e10cSrcweir         // instead of using probably incompatible item pool <mpDefaultsPool>.
323cdf0e10cSrcweir         pPool->ResetPoolDefaultItem( nWhich );
324cdf0e10cSrcweir     }
325cdf0e10cSrcweir }
326cdf0e10cSrcweir 
_getPropertyDefault(const comphelper::PropertyMapEntry * pEntry)327cdf0e10cSrcweir uno::Any SvxUnoDrawPool::_getPropertyDefault( const comphelper::PropertyMapEntry* pEntry )
328cdf0e10cSrcweir 	throw(beans::UnknownPropertyException, lang::WrappedTargetException )
329cdf0e10cSrcweir {
330cdf0e10cSrcweir 	vos::OGuard aGuard( Application::GetSolarMutex() );
331cdf0e10cSrcweir 
332cdf0e10cSrcweir     // OD 13.10.2003 #i18732# - use method <GetPoolDefaultItem(..)> instead of
333cdf0e10cSrcweir     // using probably incompatible item pool <mpDefaultsPool>
334cdf0e10cSrcweir     uno::Any aAny;
335cdf0e10cSrcweir     SfxItemPool* pPool = getModelPool( sal_True );
336cdf0e10cSrcweir     const sal_uInt16 nWhich = pPool->GetWhich( (sal_uInt16)pEntry->mnHandle );
337cdf0e10cSrcweir     const SfxPoolItem *pItem = pPool->GetPoolDefaultItem ( nWhich );
338cdf0e10cSrcweir     pItem->QueryValue( aAny, pEntry->mnMemberId );
339cdf0e10cSrcweir 
340cdf0e10cSrcweir     return aAny;
341cdf0e10cSrcweir }
342cdf0e10cSrcweir 
343cdf0e10cSrcweir // XInterface
344cdf0e10cSrcweir 
queryInterface(const uno::Type & rType)345cdf0e10cSrcweir uno::Any SAL_CALL SvxUnoDrawPool::queryInterface( const uno::Type & rType )
346cdf0e10cSrcweir 	throw( uno::RuntimeException )
347cdf0e10cSrcweir {
348cdf0e10cSrcweir 	return OWeakAggObject::queryInterface( rType );
349cdf0e10cSrcweir }
350cdf0e10cSrcweir 
queryAggregation(const uno::Type & rType)351cdf0e10cSrcweir uno::Any SAL_CALL SvxUnoDrawPool::queryAggregation( const uno::Type & rType )
352cdf0e10cSrcweir 	throw(uno::RuntimeException)
353cdf0e10cSrcweir {
354cdf0e10cSrcweir 	uno::Any aAny;
355cdf0e10cSrcweir 
356cdf0e10cSrcweir 	if( rType == ::getCppuType((const uno::Reference< lang::XServiceInfo >*)0) )
357cdf0e10cSrcweir 		aAny <<= uno::Reference< lang::XServiceInfo >(this);
358cdf0e10cSrcweir 	else if( rType == ::getCppuType((const uno::Reference< lang::XTypeProvider >*)0) )
359cdf0e10cSrcweir 		aAny <<= uno::Reference< lang::XTypeProvider >(this);
360cdf0e10cSrcweir 	else if( rType == ::getCppuType((const uno::Reference< beans::XPropertySet >*)0) )
361cdf0e10cSrcweir 		aAny <<= uno::Reference< beans::XPropertySet >(this);
362cdf0e10cSrcweir 	else if( rType == ::getCppuType((const uno::Reference< beans::XPropertyState >*)0) )
363cdf0e10cSrcweir 		aAny <<= uno::Reference< beans::XPropertyState >(this);
364cdf0e10cSrcweir 	else if( rType == ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0) )
365cdf0e10cSrcweir 		aAny <<= uno::Reference< beans::XMultiPropertySet >(this);
366cdf0e10cSrcweir 	else
367cdf0e10cSrcweir 		aAny <<= OWeakAggObject::queryAggregation( rType );
368cdf0e10cSrcweir 
369cdf0e10cSrcweir 	return aAny;
370cdf0e10cSrcweir }
371cdf0e10cSrcweir 
acquire()372cdf0e10cSrcweir void SAL_CALL SvxUnoDrawPool::acquire() throw ( )
373cdf0e10cSrcweir {
374cdf0e10cSrcweir 	OWeakAggObject::acquire();
375cdf0e10cSrcweir }
376cdf0e10cSrcweir 
release()377cdf0e10cSrcweir void SAL_CALL SvxUnoDrawPool::release() throw ( )
378cdf0e10cSrcweir {
379cdf0e10cSrcweir 	OWeakAggObject::release();
380cdf0e10cSrcweir }
381cdf0e10cSrcweir 
getTypes()382cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL SvxUnoDrawPool::getTypes()
383cdf0e10cSrcweir 	throw (uno::RuntimeException)
384cdf0e10cSrcweir {
385cdf0e10cSrcweir 	uno::Sequence< uno::Type > aTypes( 6 );
386cdf0e10cSrcweir 	uno::Type* pTypes = aTypes.getArray();
387cdf0e10cSrcweir 
388cdf0e10cSrcweir 	*pTypes++ = ::getCppuType((const uno::Reference< uno::XAggregation>*)0);
389cdf0e10cSrcweir 	*pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo>*)0);
390cdf0e10cSrcweir 	*pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider>*)0);
391cdf0e10cSrcweir 	*pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertySet>*)0);
392cdf0e10cSrcweir 	*pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertyState>*)0);
393cdf0e10cSrcweir 	*pTypes++ = ::getCppuType((const uno::Reference< beans::XMultiPropertySet>*)0);
394cdf0e10cSrcweir 
395cdf0e10cSrcweir 	return aTypes;
396cdf0e10cSrcweir }
397cdf0e10cSrcweir 
getImplementationId()398cdf0e10cSrcweir uno::Sequence< sal_Int8 > SAL_CALL SvxUnoDrawPool::getImplementationId()
399cdf0e10cSrcweir 	throw (uno::RuntimeException)
400cdf0e10cSrcweir {
401cdf0e10cSrcweir 	vos::OGuard aGuard( Application::GetSolarMutex() );
402cdf0e10cSrcweir 
403cdf0e10cSrcweir 	static uno::Sequence< sal_Int8 > aId;
404cdf0e10cSrcweir 	if( aId.getLength() == 0 )
405cdf0e10cSrcweir 	{
406cdf0e10cSrcweir 		aId.realloc( 16 );
407cdf0e10cSrcweir 		rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
408cdf0e10cSrcweir 	}
409cdf0e10cSrcweir 	return aId;
410cdf0e10cSrcweir }
411cdf0e10cSrcweir 
412cdf0e10cSrcweir // XServiceInfo
413cdf0e10cSrcweir 
supportsService(const OUString & ServiceName)414cdf0e10cSrcweir sal_Bool SAL_CALL SvxUnoDrawPool::supportsService( const  OUString& ServiceName ) throw(uno::RuntimeException)
415cdf0e10cSrcweir {
416cdf0e10cSrcweir     uno::Sequence< OUString > aSNL( getSupportedServiceNames() );
417cdf0e10cSrcweir     const OUString * pArray = aSNL.getConstArray();
418cdf0e10cSrcweir 
419cdf0e10cSrcweir     for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
420cdf0e10cSrcweir         if( pArray[i] == ServiceName )
421cdf0e10cSrcweir             return sal_True;
422cdf0e10cSrcweir 
423cdf0e10cSrcweir     return sal_False;
424cdf0e10cSrcweir }
425cdf0e10cSrcweir 
getImplementationName()426cdf0e10cSrcweir OUString SAL_CALL SvxUnoDrawPool::getImplementationName() throw( uno::RuntimeException )
427cdf0e10cSrcweir {
428cdf0e10cSrcweir 	return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxUnoDrawPool") );
429cdf0e10cSrcweir }
430cdf0e10cSrcweir 
getSupportedServiceNames()431cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL SvxUnoDrawPool::getSupportedServiceNames(  )
432cdf0e10cSrcweir 	throw( uno::RuntimeException )
433cdf0e10cSrcweir {
434cdf0e10cSrcweir     uno::Sequence< OUString > aSNS( 1 );
435cdf0e10cSrcweir     aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.Defaults" ));
436cdf0e10cSrcweir     return aSNS;
437cdf0e10cSrcweir }
438