xref: /AOO41X/main/svl/source/items/itemprop.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_svl.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <svl/itemprop.hxx>
32*cdf0e10cSrcweir #include <svl/itempool.hxx>
33*cdf0e10cSrcweir #include <svl/itemset.hxx>
34*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
35*cdf0e10cSrcweir #include <hash_map>
36*cdf0e10cSrcweir /*************************************************************************
37*cdf0e10cSrcweir 	UNO III Implementation
38*cdf0e10cSrcweir *************************************************************************/
39*cdf0e10cSrcweir using namespace com::sun::star;
40*cdf0e10cSrcweir using namespace com::sun::star::beans;
41*cdf0e10cSrcweir using namespace com::sun::star::lang;
42*cdf0e10cSrcweir using namespace com::sun::star::uno;
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir /*-- 16.02.2009 10:03:55---------------------------------------------------
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir struct equalOUString
49*cdf0e10cSrcweir {
50*cdf0e10cSrcweir   bool operator()(const ::rtl::OUString& r1, const ::rtl::OUString&  r2) const
51*cdf0e10cSrcweir   {
52*cdf0e10cSrcweir     return r1.equals( r2 );
53*cdf0e10cSrcweir   }
54*cdf0e10cSrcweir };
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir typedef ::std::hash_map< ::rtl::OUString,
57*cdf0e10cSrcweir                                  SfxItemPropertySimpleEntry,
58*cdf0e10cSrcweir                                  ::rtl::OUStringHash,
59*cdf0e10cSrcweir                                  equalOUString > SfxItemPropertyHashMap_t;
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir class SfxItemPropertyMap_Impl : public SfxItemPropertyHashMap_t
62*cdf0e10cSrcweir {
63*cdf0e10cSrcweir public:
64*cdf0e10cSrcweir     mutable uno::Sequence< beans::Property > m_aPropSeq;
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir     SfxItemPropertyMap_Impl(){}
67*cdf0e10cSrcweir     SfxItemPropertyMap_Impl( const SfxItemPropertyMap_Impl* pSource );
68*cdf0e10cSrcweir };
69*cdf0e10cSrcweir SfxItemPropertyMap_Impl::SfxItemPropertyMap_Impl( const SfxItemPropertyMap_Impl* pSource )
70*cdf0e10cSrcweir {
71*cdf0e10cSrcweir     this->SfxItemPropertyHashMap_t::operator=( *pSource );
72*cdf0e10cSrcweir     m_aPropSeq = pSource->m_aPropSeq;
73*cdf0e10cSrcweir }
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir /*-- 16.02.2009 10:03:51---------------------------------------------------
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
78*cdf0e10cSrcweir SfxItemPropertyMap::SfxItemPropertyMap( const SfxItemPropertyMapEntry* pEntries ) :
79*cdf0e10cSrcweir     m_pImpl( new SfxItemPropertyMap_Impl )
80*cdf0e10cSrcweir {
81*cdf0e10cSrcweir     while( pEntries->pName )
82*cdf0e10cSrcweir     {
83*cdf0e10cSrcweir         ::rtl::OUString sEntry(pEntries->pName, pEntries->nNameLen, RTL_TEXTENCODING_ASCII_US );
84*cdf0e10cSrcweir         (*m_pImpl) [ sEntry ] = pEntries;
85*cdf0e10cSrcweir         ++pEntries;
86*cdf0e10cSrcweir     }
87*cdf0e10cSrcweir }
88*cdf0e10cSrcweir /*-- 16.02.2009 12:46:41---------------------------------------------------
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
91*cdf0e10cSrcweir SfxItemPropertyMap::SfxItemPropertyMap( const SfxItemPropertyMap* pSource ) :
92*cdf0e10cSrcweir     m_pImpl( new SfxItemPropertyMap_Impl( pSource->m_pImpl ) )
93*cdf0e10cSrcweir {
94*cdf0e10cSrcweir }
95*cdf0e10cSrcweir /*-- 16.02.2009 10:03:51---------------------------------------------------
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
98*cdf0e10cSrcweir SfxItemPropertyMap::~SfxItemPropertyMap()
99*cdf0e10cSrcweir {
100*cdf0e10cSrcweir     delete m_pImpl;
101*cdf0e10cSrcweir }
102*cdf0e10cSrcweir /*-- 16.02.2009 10:03:51---------------------------------------------------
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
105*cdf0e10cSrcweir const SfxItemPropertySimpleEntry* SfxItemPropertyMap::getByName( const ::rtl::OUString &rName ) const
106*cdf0e10cSrcweir {
107*cdf0e10cSrcweir     SfxItemPropertyHashMap_t::const_iterator aIter = m_pImpl->find(rName);
108*cdf0e10cSrcweir     if( aIter == m_pImpl->end() )
109*cdf0e10cSrcweir         return 0;
110*cdf0e10cSrcweir     return &aIter->second;
111*cdf0e10cSrcweir }
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir /*-- 16.02.2009 10:44:24---------------------------------------------------
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
116*cdf0e10cSrcweir uno::Sequence<beans::Property> SfxItemPropertyMap::getProperties() const
117*cdf0e10cSrcweir {
118*cdf0e10cSrcweir     if( !m_pImpl->m_aPropSeq.getLength() )
119*cdf0e10cSrcweir     {
120*cdf0e10cSrcweir         m_pImpl->m_aPropSeq.realloc( m_pImpl->size() );
121*cdf0e10cSrcweir         beans::Property* pPropArray = m_pImpl->m_aPropSeq.getArray();
122*cdf0e10cSrcweir         sal_uInt32 n = 0;
123*cdf0e10cSrcweir         SfxItemPropertyHashMap_t::const_iterator aIt = m_pImpl->begin();
124*cdf0e10cSrcweir         while( aIt != m_pImpl->end() )
125*cdf0e10cSrcweir         //for ( const SfxItemPropertyMap *pMap = _pMap; pMap->pName; ++pMap )
126*cdf0e10cSrcweir         {
127*cdf0e10cSrcweir             const SfxItemPropertySimpleEntry* pEntry = &(*aIt).second;
128*cdf0e10cSrcweir             pPropArray[n].Name = (*aIt).first;
129*cdf0e10cSrcweir             pPropArray[n].Handle = pEntry->nWID;
130*cdf0e10cSrcweir             if(pEntry->pType)
131*cdf0e10cSrcweir                 pPropArray[n].Type = *pEntry->pType;
132*cdf0e10cSrcweir             pPropArray[n].Attributes =
133*cdf0e10cSrcweir                 sal::static_int_cast< sal_Int16 >(pEntry->nFlags);
134*cdf0e10cSrcweir             n++;
135*cdf0e10cSrcweir             ++aIt;
136*cdf0e10cSrcweir         }
137*cdf0e10cSrcweir     }
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir     return m_pImpl->m_aPropSeq;
140*cdf0e10cSrcweir }
141*cdf0e10cSrcweir /*-- 16.02.2009 11:04:31---------------------------------------------------
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
144*cdf0e10cSrcweir beans::Property SfxItemPropertyMap::getPropertyByName( const ::rtl::OUString rName ) const
145*cdf0e10cSrcweir     throw( beans::UnknownPropertyException )
146*cdf0e10cSrcweir {
147*cdf0e10cSrcweir     SfxItemPropertyHashMap_t::const_iterator aIter = m_pImpl->find(rName);
148*cdf0e10cSrcweir     if( aIter == m_pImpl->end() )
149*cdf0e10cSrcweir         throw UnknownPropertyException();
150*cdf0e10cSrcweir     const SfxItemPropertySimpleEntry* pEntry = &aIter->second;
151*cdf0e10cSrcweir     beans::Property aProp;
152*cdf0e10cSrcweir     aProp.Name = rName;
153*cdf0e10cSrcweir     aProp.Handle = pEntry->nWID;
154*cdf0e10cSrcweir     if(pEntry->pType)
155*cdf0e10cSrcweir         aProp.Type = *pEntry->pType;
156*cdf0e10cSrcweir     aProp.Attributes = sal::static_int_cast< sal_Int16 >(pEntry->nFlags);
157*cdf0e10cSrcweir     return aProp;
158*cdf0e10cSrcweir }
159*cdf0e10cSrcweir /*-- 16.02.2009 11:09:16---------------------------------------------------
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
162*cdf0e10cSrcweir sal_Bool SfxItemPropertyMap::hasPropertyByName( const ::rtl::OUString& rName ) const
163*cdf0e10cSrcweir {
164*cdf0e10cSrcweir     SfxItemPropertyHashMap_t::const_iterator aIter = m_pImpl->find(rName);
165*cdf0e10cSrcweir     return aIter != m_pImpl->end();
166*cdf0e10cSrcweir }
167*cdf0e10cSrcweir /*-- 16.02.2009 11:25:14---------------------------------------------------
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
170*cdf0e10cSrcweir void SfxItemPropertyMap::mergeProperties( const uno::Sequence< beans::Property >& rPropSeq )
171*cdf0e10cSrcweir {
172*cdf0e10cSrcweir     const beans::Property* pPropArray = rPropSeq.getConstArray();
173*cdf0e10cSrcweir     sal_uInt32 nElements = rPropSeq.getLength();
174*cdf0e10cSrcweir     for( sal_uInt32 nElement = 0; nElement < nElements; ++nElement )
175*cdf0e10cSrcweir     {
176*cdf0e10cSrcweir         SfxItemPropertySimpleEntry aTemp(
177*cdf0e10cSrcweir             sal::static_int_cast< sal_Int16 >( pPropArray[nElement].Handle ), //nWID
178*cdf0e10cSrcweir             &pPropArray[nElement].Type, //pType
179*cdf0e10cSrcweir             pPropArray[nElement].Attributes, //nFlags
180*cdf0e10cSrcweir             0 ); //nMemberId
181*cdf0e10cSrcweir         (*m_pImpl)[pPropArray[nElement].Name] = aTemp;
182*cdf0e10cSrcweir     }
183*cdf0e10cSrcweir }
184*cdf0e10cSrcweir /*-- 18.02.2009 12:04:42---------------------------------------------------
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
187*cdf0e10cSrcweir PropertyEntryVector_t SfxItemPropertyMap::getPropertyEntries() const
188*cdf0e10cSrcweir {
189*cdf0e10cSrcweir     PropertyEntryVector_t aRet;
190*cdf0e10cSrcweir     aRet.reserve(m_pImpl->size());
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir     SfxItemPropertyHashMap_t::const_iterator aIt = m_pImpl->begin();
193*cdf0e10cSrcweir     while( aIt != m_pImpl->end() )
194*cdf0e10cSrcweir     {
195*cdf0e10cSrcweir         const SfxItemPropertySimpleEntry* pEntry = &(*aIt).second;
196*cdf0e10cSrcweir         aRet.push_back( SfxItemPropertyNamedEntry( (*aIt).first, * pEntry ) );
197*cdf0e10cSrcweir         ++aIt;
198*cdf0e10cSrcweir     }
199*cdf0e10cSrcweir     return aRet;
200*cdf0e10cSrcweir }
201*cdf0e10cSrcweir /*-- 18.02.2009 15:11:06---------------------------------------------------
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
204*cdf0e10cSrcweir sal_uInt32 SfxItemPropertyMap::getSize() const
205*cdf0e10cSrcweir {
206*cdf0e10cSrcweir     return m_pImpl->size();
207*cdf0e10cSrcweir }
208*cdf0e10cSrcweir /*-- 16.02.2009 13:44:54---------------------------------------------------
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
211*cdf0e10cSrcweir SfxItemPropertySet::~SfxItemPropertySet()
212*cdf0e10cSrcweir {
213*cdf0e10cSrcweir }
214*cdf0e10cSrcweir /* -----------------------------21.02.00 11:26--------------------------------
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
217*cdf0e10cSrcweir sal_Bool SfxItemPropertySet::FillItem(SfxItemSet&, sal_uInt16, sal_Bool) const
218*cdf0e10cSrcweir {
219*cdf0e10cSrcweir 	return sal_False;
220*cdf0e10cSrcweir }
221*cdf0e10cSrcweir /* -----------------------------06.06.01 12:32--------------------------------
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
224*cdf0e10cSrcweir void SfxItemPropertySet::getPropertyValue( const SfxItemPropertySimpleEntry& rEntry,
225*cdf0e10cSrcweir 			const SfxItemSet& rSet, Any& rAny ) const
226*cdf0e10cSrcweir 						throw(RuntimeException)
227*cdf0e10cSrcweir {
228*cdf0e10cSrcweir     // get the SfxPoolItem
229*cdf0e10cSrcweir     const SfxPoolItem* pItem = 0;
230*cdf0e10cSrcweir     SfxItemState eState = rSet.GetItemState( rEntry.nWID, sal_True, &pItem );
231*cdf0e10cSrcweir     if(SFX_ITEM_SET != eState && SFX_WHICH_MAX > rEntry.nWID )
232*cdf0e10cSrcweir         pItem = &rSet.GetPool()->GetDefaultItem(rEntry.nWID);
233*cdf0e10cSrcweir     // return item values as uno::Any
234*cdf0e10cSrcweir     if(eState >= SFX_ITEM_DEFAULT && pItem)
235*cdf0e10cSrcweir     {
236*cdf0e10cSrcweir         pItem->QueryValue( rAny, rEntry.nMemberId );
237*cdf0e10cSrcweir     }
238*cdf0e10cSrcweir     else
239*cdf0e10cSrcweir     {
240*cdf0e10cSrcweir         SfxItemSet aSet(*rSet.GetPool(), rEntry.nWID, rEntry.nWID);
241*cdf0e10cSrcweir         if(FillItem(aSet, rEntry.nWID, sal_True))
242*cdf0e10cSrcweir         {
243*cdf0e10cSrcweir             const SfxPoolItem& rItem = aSet.Get(rEntry.nWID);
244*cdf0e10cSrcweir             rItem.QueryValue( rAny, rEntry.nMemberId );
245*cdf0e10cSrcweir         }
246*cdf0e10cSrcweir         else if(0 == (rEntry.nFlags & PropertyAttribute::MAYBEVOID))
247*cdf0e10cSrcweir             throw RuntimeException();
248*cdf0e10cSrcweir     }
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir 
251*cdf0e10cSrcweir     // convert general SfxEnumItem values to specific values
252*cdf0e10cSrcweir     if( rEntry.pType && TypeClass_ENUM == rEntry.pType->getTypeClass() &&
253*cdf0e10cSrcweir          rAny.getValueTypeClass() == TypeClass_LONG )
254*cdf0e10cSrcweir     {
255*cdf0e10cSrcweir         sal_Int32 nTmp = *(sal_Int32*)rAny.getValue();
256*cdf0e10cSrcweir         rAny.setValue( &nTmp, *rEntry.pType );
257*cdf0e10cSrcweir     }
258*cdf0e10cSrcweir }
259*cdf0e10cSrcweir /* -----------------------------06.06.01 12:32--------------------------------
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
262*cdf0e10cSrcweir void SfxItemPropertySet::getPropertyValue( const rtl::OUString &rName,
263*cdf0e10cSrcweir 			const SfxItemSet& rSet, Any& rAny ) const
264*cdf0e10cSrcweir 						throw(RuntimeException, UnknownPropertyException)
265*cdf0e10cSrcweir {
266*cdf0e10cSrcweir     // detect which-id
267*cdf0e10cSrcweir     const SfxItemPropertySimpleEntry* pEntry = m_aMap.getByName( rName );
268*cdf0e10cSrcweir     if ( !pEntry )
269*cdf0e10cSrcweir 		throw UnknownPropertyException();
270*cdf0e10cSrcweir     getPropertyValue( *pEntry,rSet, rAny );
271*cdf0e10cSrcweir }
272*cdf0e10cSrcweir /* -----------------------------21.02.00 11:26--------------------------------
273*cdf0e10cSrcweir 
274*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
275*cdf0e10cSrcweir Any SfxItemPropertySet::getPropertyValue( const rtl::OUString &rName,
276*cdf0e10cSrcweir 			const SfxItemSet& rSet ) const
277*cdf0e10cSrcweir 						throw(RuntimeException, UnknownPropertyException)
278*cdf0e10cSrcweir {
279*cdf0e10cSrcweir 	Any aVal;
280*cdf0e10cSrcweir 	getPropertyValue( rName,rSet, aVal );
281*cdf0e10cSrcweir 	return aVal;
282*cdf0e10cSrcweir }
283*cdf0e10cSrcweir /* -----------------------------15.11.00 14:46--------------------------------
284*cdf0e10cSrcweir 
285*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
286*cdf0e10cSrcweir void SfxItemPropertySet::setPropertyValue( const SfxItemPropertySimpleEntry& rEntry,
287*cdf0e10cSrcweir 											const Any& aVal,
288*cdf0e10cSrcweir 											SfxItemSet& rSet ) const
289*cdf0e10cSrcweir 											throw(RuntimeException,
290*cdf0e10cSrcweir 													IllegalArgumentException)
291*cdf0e10cSrcweir {
292*cdf0e10cSrcweir     // get the SfxPoolItem
293*cdf0e10cSrcweir     const SfxPoolItem* pItem = 0;
294*cdf0e10cSrcweir     SfxPoolItem *pNewItem = 0;
295*cdf0e10cSrcweir     SfxItemState eState = rSet.GetItemState( rEntry.nWID, sal_True, &pItem );
296*cdf0e10cSrcweir     if(SFX_ITEM_SET != eState && SFX_WHICH_MAX > rEntry.nWID )
297*cdf0e10cSrcweir         pItem = &rSet.GetPool()->GetDefaultItem(rEntry.nWID);
298*cdf0e10cSrcweir     //maybe there's another way to find an Item
299*cdf0e10cSrcweir     if(eState < SFX_ITEM_DEFAULT)
300*cdf0e10cSrcweir     {
301*cdf0e10cSrcweir         SfxItemSet aSet(*rSet.GetPool(), rEntry.nWID, rEntry.nWID);
302*cdf0e10cSrcweir         if(FillItem(aSet, rEntry.nWID, sal_False))
303*cdf0e10cSrcweir         {
304*cdf0e10cSrcweir             const SfxPoolItem &rItem = aSet.Get(rEntry.nWID);
305*cdf0e10cSrcweir             pNewItem = rItem.Clone();
306*cdf0e10cSrcweir         }
307*cdf0e10cSrcweir     }
308*cdf0e10cSrcweir     if(!pNewItem && pItem)
309*cdf0e10cSrcweir     {
310*cdf0e10cSrcweir         pNewItem = pItem->Clone();
311*cdf0e10cSrcweir     }
312*cdf0e10cSrcweir     if(pNewItem)
313*cdf0e10cSrcweir     {
314*cdf0e10cSrcweir         if( !pNewItem->PutValue( aVal, rEntry.nMemberId ) )
315*cdf0e10cSrcweir         {
316*cdf0e10cSrcweir             DELETEZ(pNewItem);
317*cdf0e10cSrcweir             throw IllegalArgumentException();
318*cdf0e10cSrcweir         }
319*cdf0e10cSrcweir         // apply new item
320*cdf0e10cSrcweir         rSet.Put( *pNewItem, rEntry.nWID );
321*cdf0e10cSrcweir         delete pNewItem;
322*cdf0e10cSrcweir     }
323*cdf0e10cSrcweir }
324*cdf0e10cSrcweir /* -----------------------------21.02.00 11:26--------------------------------
325*cdf0e10cSrcweir 
326*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
327*cdf0e10cSrcweir void SfxItemPropertySet::setPropertyValue( const rtl::OUString &rName,
328*cdf0e10cSrcweir 											const Any& aVal,
329*cdf0e10cSrcweir 											SfxItemSet& rSet ) const
330*cdf0e10cSrcweir 											throw(RuntimeException,
331*cdf0e10cSrcweir 													IllegalArgumentException,
332*cdf0e10cSrcweir 													UnknownPropertyException)
333*cdf0e10cSrcweir {
334*cdf0e10cSrcweir     const SfxItemPropertySimpleEntry* pEntry = m_aMap.getByName( rName );
335*cdf0e10cSrcweir     if ( !pEntry )
336*cdf0e10cSrcweir 	{
337*cdf0e10cSrcweir 		throw UnknownPropertyException();
338*cdf0e10cSrcweir 	}
339*cdf0e10cSrcweir     setPropertyValue(*pEntry, aVal, rSet);
340*cdf0e10cSrcweir }
341*cdf0e10cSrcweir /* -----------------------------21.02.00 11:26--------------------------------
342*cdf0e10cSrcweir 
343*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
344*cdf0e10cSrcweir PropertyState SfxItemPropertySet::getPropertyState(const SfxItemPropertySimpleEntry& rEntry, const SfxItemSet& rSet) const
345*cdf0e10cSrcweir                                     throw()
346*cdf0e10cSrcweir {
347*cdf0e10cSrcweir 	PropertyState eRet = PropertyState_DIRECT_VALUE;
348*cdf0e10cSrcweir     sal_uInt16 nWhich = rEntry.nWID;
349*cdf0e10cSrcweir 
350*cdf0e10cSrcweir 	// item state holen
351*cdf0e10cSrcweir 	SfxItemState eState = rSet.GetItemState( nWhich, sal_False );
352*cdf0e10cSrcweir 	// item-Wert als UnoAny zurueckgeben
353*cdf0e10cSrcweir 	if(eState == SFX_ITEM_DEFAULT)
354*cdf0e10cSrcweir 		eRet = PropertyState_DEFAULT_VALUE;
355*cdf0e10cSrcweir 	else if(eState < SFX_ITEM_DEFAULT)
356*cdf0e10cSrcweir 		eRet = PropertyState_AMBIGUOUS_VALUE;
357*cdf0e10cSrcweir 	return eRet;
358*cdf0e10cSrcweir }
359*cdf0e10cSrcweir PropertyState   SfxItemPropertySet::getPropertyState(
360*cdf0e10cSrcweir 	const rtl::OUString& rName, const SfxItemSet& rSet) const
361*cdf0e10cSrcweir                                     throw(UnknownPropertyException)
362*cdf0e10cSrcweir {
363*cdf0e10cSrcweir 	PropertyState eRet = PropertyState_DIRECT_VALUE;
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir 	// which-id ermitteln
366*cdf0e10cSrcweir     const SfxItemPropertySimpleEntry* pEntry = m_aMap.getByName( rName );
367*cdf0e10cSrcweir     if( !pEntry || !pEntry->nWID )
368*cdf0e10cSrcweir 	{
369*cdf0e10cSrcweir 		throw UnknownPropertyException();
370*cdf0e10cSrcweir 	}
371*cdf0e10cSrcweir     sal_uInt16 nWhich = pEntry->nWID;
372*cdf0e10cSrcweir 
373*cdf0e10cSrcweir 	// item holen
374*cdf0e10cSrcweir 	const SfxPoolItem* pItem = 0;
375*cdf0e10cSrcweir 	SfxItemState eState = rSet.GetItemState( nWhich, sal_False, &pItem );
376*cdf0e10cSrcweir 	if(!pItem && nWhich != rSet.GetPool()->GetSlotId(nWhich))
377*cdf0e10cSrcweir 		pItem = &rSet.GetPool()->GetDefaultItem(nWhich);
378*cdf0e10cSrcweir 	// item-Wert als UnoAny zurueckgeben
379*cdf0e10cSrcweir 	if(eState == SFX_ITEM_DEFAULT)
380*cdf0e10cSrcweir 		eRet = PropertyState_DEFAULT_VALUE;
381*cdf0e10cSrcweir 	else if(eState < SFX_ITEM_DEFAULT)
382*cdf0e10cSrcweir 		eRet = PropertyState_AMBIGUOUS_VALUE;
383*cdf0e10cSrcweir 	return eRet;
384*cdf0e10cSrcweir }
385*cdf0e10cSrcweir /* -----------------------------21.02.00 11:26--------------------------------
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
388*cdf0e10cSrcweir Reference<XPropertySetInfo>
389*cdf0e10cSrcweir     SfxItemPropertySet::getPropertySetInfo() const
390*cdf0e10cSrcweir {
391*cdf0e10cSrcweir     if( !m_xInfo.is() )
392*cdf0e10cSrcweir         m_xInfo = new SfxItemPropertySetInfo( &m_aMap );
393*cdf0e10cSrcweir     return m_xInfo;
394*cdf0e10cSrcweir }
395*cdf0e10cSrcweir /*-- 16.02.2009 13:49:25---------------------------------------------------
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
398*cdf0e10cSrcweir struct SfxItemPropertySetInfo_Impl
399*cdf0e10cSrcweir {
400*cdf0e10cSrcweir     SfxItemPropertyMap*         m_pOwnMap;
401*cdf0e10cSrcweir };
402*cdf0e10cSrcweir /*-- 16.02.2009 13:49:24---------------------------------------------------
403*cdf0e10cSrcweir 
404*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
405*cdf0e10cSrcweir SfxItemPropertySetInfo::SfxItemPropertySetInfo(const SfxItemPropertyMap *pMap ) :
406*cdf0e10cSrcweir     m_pImpl( new SfxItemPropertySetInfo_Impl )
407*cdf0e10cSrcweir {
408*cdf0e10cSrcweir     m_pImpl->m_pOwnMap = new SfxItemPropertyMap( pMap );
409*cdf0e10cSrcweir }
410*cdf0e10cSrcweir /*-- 16.02.2009 13:49:25---------------------------------------------------
411*cdf0e10cSrcweir 
412*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
413*cdf0e10cSrcweir SfxItemPropertySetInfo::SfxItemPropertySetInfo(const SfxItemPropertyMapEntry *pEntries ) :
414*cdf0e10cSrcweir     m_pImpl( new SfxItemPropertySetInfo_Impl )
415*cdf0e10cSrcweir {
416*cdf0e10cSrcweir     m_pImpl->m_pOwnMap = new SfxItemPropertyMap( pEntries );
417*cdf0e10cSrcweir }
418*cdf0e10cSrcweir /* -----------------------------21.02.00 11:09--------------------------------
419*cdf0e10cSrcweir 
420*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
421*cdf0e10cSrcweir Sequence< Property > SAL_CALL
422*cdf0e10cSrcweir         SfxItemPropertySetInfo::getProperties(  )
423*cdf0e10cSrcweir             throw(RuntimeException)
424*cdf0e10cSrcweir {
425*cdf0e10cSrcweir     return m_pImpl->m_pOwnMap->getProperties();
426*cdf0e10cSrcweir }
427*cdf0e10cSrcweir /*-- 16.02.2009 13:49:27---------------------------------------------------
428*cdf0e10cSrcweir 
429*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
430*cdf0e10cSrcweir const SfxItemPropertyMap* SfxItemPropertySetInfo::getMap() const
431*cdf0e10cSrcweir {
432*cdf0e10cSrcweir     return m_pImpl->m_pOwnMap;
433*cdf0e10cSrcweir }
434*cdf0e10cSrcweir 
435*cdf0e10cSrcweir /*-- 16.02.2009 12:43:36---------------------------------------------------
436*cdf0e10cSrcweir 
437*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
438*cdf0e10cSrcweir SfxItemPropertySetInfo::~SfxItemPropertySetInfo()
439*cdf0e10cSrcweir {
440*cdf0e10cSrcweir     delete m_pImpl->m_pOwnMap;
441*cdf0e10cSrcweir     delete m_pImpl;
442*cdf0e10cSrcweir }
443*cdf0e10cSrcweir /* -----------------------------21.02.00 11:27--------------------------------
444*cdf0e10cSrcweir 
445*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
446*cdf0e10cSrcweir Property SAL_CALL
447*cdf0e10cSrcweir 		SfxItemPropertySetInfo::getPropertyByName( const ::rtl::OUString& rName )
448*cdf0e10cSrcweir 			throw(UnknownPropertyException, RuntimeException)
449*cdf0e10cSrcweir {
450*cdf0e10cSrcweir     return m_pImpl->m_pOwnMap->getPropertyByName( rName );
451*cdf0e10cSrcweir }
452*cdf0e10cSrcweir /* -----------------------------21.02.00 11:28--------------------------------
453*cdf0e10cSrcweir 
454*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
455*cdf0e10cSrcweir sal_Bool SAL_CALL
456*cdf0e10cSrcweir 		SfxItemPropertySetInfo::hasPropertyByName( const ::rtl::OUString& rName )
457*cdf0e10cSrcweir 			throw(RuntimeException)
458*cdf0e10cSrcweir {
459*cdf0e10cSrcweir     return m_pImpl->m_pOwnMap->hasPropertyByName( rName );
460*cdf0e10cSrcweir }
461*cdf0e10cSrcweir /* -----------------------------21.02.00 12:03--------------------------------
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
464*cdf0e10cSrcweir SfxExtItemPropertySetInfo::SfxExtItemPropertySetInfo(
465*cdf0e10cSrcweir                                 const SfxItemPropertyMapEntry *pMap,
466*cdf0e10cSrcweir 								const Sequence<Property>& rPropSeq ) :
467*cdf0e10cSrcweir                 aExtMap( pMap )
468*cdf0e10cSrcweir {
469*cdf0e10cSrcweir     aExtMap.mergeProperties( rPropSeq );
470*cdf0e10cSrcweir }
471*cdf0e10cSrcweir /*-- 16.02.2009 12:06:49---------------------------------------------------
472*cdf0e10cSrcweir 
473*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
474*cdf0e10cSrcweir SfxExtItemPropertySetInfo::~SfxExtItemPropertySetInfo()
475*cdf0e10cSrcweir {
476*cdf0e10cSrcweir }
477*cdf0e10cSrcweir /* -----------------------------21.02.00 12:03--------------------------------
478*cdf0e10cSrcweir 
479*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
480*cdf0e10cSrcweir Sequence< Property > SAL_CALL
481*cdf0e10cSrcweir 		SfxExtItemPropertySetInfo::getProperties(  ) throw(RuntimeException)
482*cdf0e10cSrcweir {
483*cdf0e10cSrcweir     return aExtMap.getProperties();
484*cdf0e10cSrcweir }
485*cdf0e10cSrcweir /* -----------------------------21.02.00 12:03--------------------------------
486*cdf0e10cSrcweir 
487*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
488*cdf0e10cSrcweir Property SAL_CALL
489*cdf0e10cSrcweir SfxExtItemPropertySetInfo::getPropertyByName( const rtl::OUString& rPropertyName )
490*cdf0e10cSrcweir 			throw(UnknownPropertyException, RuntimeException)
491*cdf0e10cSrcweir {
492*cdf0e10cSrcweir     return aExtMap.getPropertyByName( rPropertyName );
493*cdf0e10cSrcweir }
494*cdf0e10cSrcweir /* -----------------------------21.02.00 12:03--------------------------------
495*cdf0e10cSrcweir 
496*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
497*cdf0e10cSrcweir sal_Bool SAL_CALL
498*cdf0e10cSrcweir SfxExtItemPropertySetInfo::hasPropertyByName( const rtl::OUString& rPropertyName )
499*cdf0e10cSrcweir 			throw(RuntimeException)
500*cdf0e10cSrcweir {
501*cdf0e10cSrcweir     return aExtMap.hasPropertyByName( rPropertyName );
502*cdf0e10cSrcweir }
503*cdf0e10cSrcweir 
504