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