1*cde9e8dcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*cde9e8dcSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*cde9e8dcSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*cde9e8dcSAndrew Rist * distributed with this work for additional information
6*cde9e8dcSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*cde9e8dcSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*cde9e8dcSAndrew Rist * "License"); you may not use this file except in compliance
9*cde9e8dcSAndrew Rist * with the License. You may obtain a copy of the License at
10*cde9e8dcSAndrew Rist *
11*cde9e8dcSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*cde9e8dcSAndrew Rist *
13*cde9e8dcSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*cde9e8dcSAndrew Rist * software distributed under the License is distributed on an
15*cde9e8dcSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*cde9e8dcSAndrew Rist * KIND, either express or implied. See the License for the
17*cde9e8dcSAndrew Rist * specific language governing permissions and limitations
18*cde9e8dcSAndrew Rist * under the License.
19*cde9e8dcSAndrew Rist *
20*cde9e8dcSAndrew Rist *************************************************************/
21*cde9e8dcSAndrew Rist
22*cde9e8dcSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_chart2.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "WrappedPropertySet.hxx"
28cdf0e10cSrcweir #include "macros.hxx"
29cdf0e10cSrcweir
30cdf0e10cSrcweir // header for define DELETEZ
31cdf0e10cSrcweir #include <tools/solar.h>
32cdf0e10cSrcweir
33cdf0e10cSrcweir #include <tools/debug.hxx>
34cdf0e10cSrcweir
35cdf0e10cSrcweir //.............................................................................
36cdf0e10cSrcweir namespace chart
37cdf0e10cSrcweir {
38cdf0e10cSrcweir //.............................................................................
39cdf0e10cSrcweir
40cdf0e10cSrcweir using namespace ::com::sun::star;
41cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
42cdf0e10cSrcweir using ::com::sun::star::uno::Sequence;
43cdf0e10cSrcweir using ::com::sun::star::uno::Any;
44cdf0e10cSrcweir using ::rtl::OUString;
45cdf0e10cSrcweir
WrappedPropertySet()46cdf0e10cSrcweir WrappedPropertySet::WrappedPropertySet()
47cdf0e10cSrcweir : MutexContainer()
48cdf0e10cSrcweir , m_xInfo(0)
49cdf0e10cSrcweir , m_pPropertyArrayHelper(0)
50cdf0e10cSrcweir , m_pWrappedPropertyMap(0)
51cdf0e10cSrcweir {
52cdf0e10cSrcweir }
~WrappedPropertySet()53cdf0e10cSrcweir WrappedPropertySet::~WrappedPropertySet()
54cdf0e10cSrcweir {
55cdf0e10cSrcweir clearWrappedPropertySet();
56cdf0e10cSrcweir }
57cdf0e10cSrcweir
getInnerPropertyState()58cdf0e10cSrcweir Reference< beans::XPropertyState > WrappedPropertySet::getInnerPropertyState()
59cdf0e10cSrcweir {
60cdf0e10cSrcweir return Reference< beans::XPropertyState >( getInnerPropertySet(), uno::UNO_QUERY );
61cdf0e10cSrcweir }
62cdf0e10cSrcweir
clearWrappedPropertySet()63cdf0e10cSrcweir void WrappedPropertySet::clearWrappedPropertySet()
64cdf0e10cSrcweir {
65cdf0e10cSrcweir ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );//do not use different mutex than is already used for static property sequence
66cdf0e10cSrcweir
67cdf0e10cSrcweir //delete all wrapped properties
68cdf0e10cSrcweir if(m_pWrappedPropertyMap)
69cdf0e10cSrcweir {
70cdf0e10cSrcweir for( tWrappedPropertyMap::iterator aIt = m_pWrappedPropertyMap->begin()
71cdf0e10cSrcweir ; aIt!= m_pWrappedPropertyMap->end(); aIt++ )
72cdf0e10cSrcweir {
73cdf0e10cSrcweir const WrappedProperty* pWrappedProperty = (*aIt).second;
74cdf0e10cSrcweir DELETEZ(pWrappedProperty);
75cdf0e10cSrcweir }
76cdf0e10cSrcweir }
77cdf0e10cSrcweir
78cdf0e10cSrcweir DELETEZ(m_pPropertyArrayHelper);
79cdf0e10cSrcweir DELETEZ(m_pWrappedPropertyMap);
80cdf0e10cSrcweir
81cdf0e10cSrcweir m_xInfo = NULL;
82cdf0e10cSrcweir }
83cdf0e10cSrcweir
84cdf0e10cSrcweir //XPropertySet
getPropertySetInfo()85cdf0e10cSrcweir Reference< beans::XPropertySetInfo > SAL_CALL WrappedPropertySet::getPropertySetInfo( )
86cdf0e10cSrcweir throw (uno::RuntimeException)
87cdf0e10cSrcweir {
88cdf0e10cSrcweir Reference< beans::XPropertySetInfo > xInfo = m_xInfo;
89cdf0e10cSrcweir if( !xInfo.is() )
90cdf0e10cSrcweir {
91cdf0e10cSrcweir ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );//do not use different mutex than is already used for static property sequence
92cdf0e10cSrcweir xInfo = m_xInfo;
93cdf0e10cSrcweir if( !xInfo.is() )
94cdf0e10cSrcweir {
95cdf0e10cSrcweir xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( getInfoHelper() );
96cdf0e10cSrcweir OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
97cdf0e10cSrcweir m_xInfo = xInfo;
98cdf0e10cSrcweir }
99cdf0e10cSrcweir }
100cdf0e10cSrcweir else
101cdf0e10cSrcweir {
102cdf0e10cSrcweir OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
103cdf0e10cSrcweir }
104cdf0e10cSrcweir return m_xInfo;
105cdf0e10cSrcweir }
106cdf0e10cSrcweir
setPropertyValue(const OUString & rPropertyName,const Any & rValue)107cdf0e10cSrcweir void SAL_CALL WrappedPropertySet::setPropertyValue( const OUString& rPropertyName, const Any& rValue )
108cdf0e10cSrcweir throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
109cdf0e10cSrcweir {
110cdf0e10cSrcweir try
111cdf0e10cSrcweir {
112cdf0e10cSrcweir sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName );
113cdf0e10cSrcweir const WrappedProperty* pWrappedProperty = getWrappedProperty( nHandle );
114cdf0e10cSrcweir Reference< beans::XPropertySet > xInnerPropertySet( this->getInnerPropertySet() );
115cdf0e10cSrcweir if( pWrappedProperty )
116cdf0e10cSrcweir pWrappedProperty->setPropertyValue( rValue, xInnerPropertySet );
117cdf0e10cSrcweir else if( xInnerPropertySet.is() )
118cdf0e10cSrcweir xInnerPropertySet->setPropertyValue( rPropertyName, rValue );
119cdf0e10cSrcweir else
120cdf0e10cSrcweir {
121cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
122cdf0e10cSrcweir DBG_ERROR("found no inner property set to map to");
123cdf0e10cSrcweir #endif
124cdf0e10cSrcweir }
125cdf0e10cSrcweir }
126cdf0e10cSrcweir catch( beans::UnknownPropertyException& ex )
127cdf0e10cSrcweir {
128cdf0e10cSrcweir throw ex;
129cdf0e10cSrcweir }
130cdf0e10cSrcweir catch( beans::PropertyVetoException& ex )
131cdf0e10cSrcweir {
132cdf0e10cSrcweir throw ex;
133cdf0e10cSrcweir }
134cdf0e10cSrcweir catch( lang::IllegalArgumentException& ex )
135cdf0e10cSrcweir {
136cdf0e10cSrcweir throw ex;
137cdf0e10cSrcweir }
138cdf0e10cSrcweir catch( lang::WrappedTargetException& ex )
139cdf0e10cSrcweir {
140cdf0e10cSrcweir throw ex;
141cdf0e10cSrcweir }
142cdf0e10cSrcweir catch( uno::RuntimeException& ex )
143cdf0e10cSrcweir {
144cdf0e10cSrcweir throw ex;
145cdf0e10cSrcweir }
146cdf0e10cSrcweir catch( uno::Exception& ex )
147cdf0e10cSrcweir {
148cdf0e10cSrcweir OSL_ENSURE(false,"invalid exception caught in WrappedPropertySet::setPropertyValue");
149cdf0e10cSrcweir lang::WrappedTargetException aWrappedException;
150cdf0e10cSrcweir aWrappedException.TargetException = uno::makeAny( ex );
151cdf0e10cSrcweir throw aWrappedException;
152cdf0e10cSrcweir }
153cdf0e10cSrcweir }
getPropertyValue(const OUString & rPropertyName)154cdf0e10cSrcweir Any SAL_CALL WrappedPropertySet::getPropertyValue( const OUString& rPropertyName )
155cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
156cdf0e10cSrcweir {
157cdf0e10cSrcweir Any aRet;
158cdf0e10cSrcweir
159cdf0e10cSrcweir try
160cdf0e10cSrcweir {
161cdf0e10cSrcweir sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName );
162cdf0e10cSrcweir const WrappedProperty* pWrappedProperty = getWrappedProperty( nHandle );
163cdf0e10cSrcweir Reference< beans::XPropertySet > xInnerPropertySet( this->getInnerPropertySet() );
164cdf0e10cSrcweir if( pWrappedProperty )
165cdf0e10cSrcweir aRet = pWrappedProperty->getPropertyValue( xInnerPropertySet );
166cdf0e10cSrcweir else if( xInnerPropertySet.is() )
167cdf0e10cSrcweir aRet = xInnerPropertySet->getPropertyValue( rPropertyName );
168cdf0e10cSrcweir else
169cdf0e10cSrcweir {
170cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
171cdf0e10cSrcweir DBG_ERROR("found no inner property set to map to");
172cdf0e10cSrcweir #endif
173cdf0e10cSrcweir }
174cdf0e10cSrcweir }
175cdf0e10cSrcweir catch( beans::UnknownPropertyException& ex )
176cdf0e10cSrcweir {
177cdf0e10cSrcweir throw ex;
178cdf0e10cSrcweir }
179cdf0e10cSrcweir catch( lang::WrappedTargetException& ex )
180cdf0e10cSrcweir {
181cdf0e10cSrcweir throw ex;
182cdf0e10cSrcweir }
183cdf0e10cSrcweir catch( uno::RuntimeException& ex )
184cdf0e10cSrcweir {
185cdf0e10cSrcweir throw ex;
186cdf0e10cSrcweir }
187cdf0e10cSrcweir catch( uno::Exception& ex )
188cdf0e10cSrcweir {
189cdf0e10cSrcweir OSL_ENSURE(false,"invalid exception caught in WrappedPropertySet::setPropertyValue");
190cdf0e10cSrcweir lang::WrappedTargetException aWrappedException;
191cdf0e10cSrcweir aWrappedException.TargetException = uno::makeAny( ex );
192cdf0e10cSrcweir throw aWrappedException;
193cdf0e10cSrcweir }
194cdf0e10cSrcweir
195cdf0e10cSrcweir return aRet;
196cdf0e10cSrcweir }
197cdf0e10cSrcweir
addPropertyChangeListener(const OUString & rPropertyName,const Reference<beans::XPropertyChangeListener> & xListener)198cdf0e10cSrcweir void SAL_CALL WrappedPropertySet::addPropertyChangeListener( const OUString& rPropertyName, const Reference< beans::XPropertyChangeListener >& xListener )
199cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
200cdf0e10cSrcweir {
201cdf0e10cSrcweir Reference< beans::XPropertySet > xInnerPropertySet( this->getInnerPropertySet() );
202cdf0e10cSrcweir if( xInnerPropertySet.is() )
203cdf0e10cSrcweir {
204cdf0e10cSrcweir const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName );
205cdf0e10cSrcweir if( pWrappedProperty )
206cdf0e10cSrcweir xInnerPropertySet->addPropertyChangeListener( pWrappedProperty->getInnerName(), xListener );
207cdf0e10cSrcweir else
208cdf0e10cSrcweir xInnerPropertySet->addPropertyChangeListener( rPropertyName, xListener );
209cdf0e10cSrcweir }
210cdf0e10cSrcweir // m_aBoundListenerContainer.addInterface( (sal_Int32)nHandle, xListener );
211cdf0e10cSrcweir }
removePropertyChangeListener(const OUString & rPropertyName,const Reference<beans::XPropertyChangeListener> & aListener)212cdf0e10cSrcweir void SAL_CALL WrappedPropertySet::removePropertyChangeListener( const OUString& rPropertyName, const Reference< beans::XPropertyChangeListener >& aListener )
213cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
214cdf0e10cSrcweir {
215cdf0e10cSrcweir Reference< beans::XPropertySet > xInnerPropertySet( this->getInnerPropertySet() );
216cdf0e10cSrcweir if( xInnerPropertySet.is() )
217cdf0e10cSrcweir {
218cdf0e10cSrcweir const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName );
219cdf0e10cSrcweir if( pWrappedProperty )
220cdf0e10cSrcweir xInnerPropertySet->removePropertyChangeListener( pWrappedProperty->getInnerName(), aListener );
221cdf0e10cSrcweir else
222cdf0e10cSrcweir xInnerPropertySet->removePropertyChangeListener( rPropertyName, aListener );
223cdf0e10cSrcweir }
224cdf0e10cSrcweir }
addVetoableChangeListener(const OUString & rPropertyName,const Reference<beans::XVetoableChangeListener> & aListener)225cdf0e10cSrcweir void SAL_CALL WrappedPropertySet::addVetoableChangeListener( const OUString& rPropertyName, const Reference< beans::XVetoableChangeListener >& aListener )
226cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
227cdf0e10cSrcweir {
228cdf0e10cSrcweir Reference< beans::XPropertySet > xInnerPropertySet( this->getInnerPropertySet() );
229cdf0e10cSrcweir if( xInnerPropertySet.is() )
230cdf0e10cSrcweir {
231cdf0e10cSrcweir const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName );
232cdf0e10cSrcweir if( pWrappedProperty )
233cdf0e10cSrcweir xInnerPropertySet->addVetoableChangeListener( pWrappedProperty->getInnerName(), aListener );
234cdf0e10cSrcweir else
235cdf0e10cSrcweir xInnerPropertySet->addVetoableChangeListener( rPropertyName, aListener );
236cdf0e10cSrcweir }
237cdf0e10cSrcweir }
removeVetoableChangeListener(const OUString & rPropertyName,const Reference<beans::XVetoableChangeListener> & aListener)238cdf0e10cSrcweir void SAL_CALL WrappedPropertySet::removeVetoableChangeListener( const OUString& rPropertyName, const Reference< beans::XVetoableChangeListener >& aListener )
239cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
240cdf0e10cSrcweir {
241cdf0e10cSrcweir Reference< beans::XPropertySet > xInnerPropertySet( this->getInnerPropertySet() );
242cdf0e10cSrcweir if( xInnerPropertySet.is() )
243cdf0e10cSrcweir {
244cdf0e10cSrcweir const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName );
245cdf0e10cSrcweir if( pWrappedProperty )
246cdf0e10cSrcweir xInnerPropertySet->removeVetoableChangeListener( pWrappedProperty->getInnerName(), aListener );
247cdf0e10cSrcweir else
248cdf0e10cSrcweir xInnerPropertySet->removeVetoableChangeListener( rPropertyName, aListener );
249cdf0e10cSrcweir }
250cdf0e10cSrcweir }
251cdf0e10cSrcweir
252cdf0e10cSrcweir //XMultiPropertySet
setPropertyValues(const Sequence<OUString> & rNameSeq,const Sequence<Any> & rValueSeq)253cdf0e10cSrcweir void SAL_CALL WrappedPropertySet::setPropertyValues( const Sequence< OUString >& rNameSeq, const Sequence< Any >& rValueSeq )
254cdf0e10cSrcweir throw (beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
255cdf0e10cSrcweir {
256cdf0e10cSrcweir bool bUnknownProperty = false;
257cdf0e10cSrcweir sal_Int32 nMinCount = std::min( rValueSeq.getLength(), rNameSeq.getLength() );
258cdf0e10cSrcweir for(sal_Int32 nN=0; nN<nMinCount; nN++)
259cdf0e10cSrcweir {
260cdf0e10cSrcweir ::rtl::OUString aPropertyName( rNameSeq[nN] );
261cdf0e10cSrcweir try
262cdf0e10cSrcweir {
263cdf0e10cSrcweir this->setPropertyValue( aPropertyName, rValueSeq[nN] );
264cdf0e10cSrcweir }
265cdf0e10cSrcweir catch( beans::UnknownPropertyException& ex )
266cdf0e10cSrcweir {
267cdf0e10cSrcweir ASSERT_EXCEPTION( ex );
268cdf0e10cSrcweir bUnknownProperty = true;
269cdf0e10cSrcweir }
270cdf0e10cSrcweir }
271cdf0e10cSrcweir //todo: store unknown properties elsewhere
272cdf0e10cSrcweir // if( bUnknownProperty )
273cdf0e10cSrcweir // throw beans::UnknownPropertyException();
274cdf0e10cSrcweir }
getPropertyValues(const Sequence<OUString> & rNameSeq)275cdf0e10cSrcweir Sequence< Any > SAL_CALL WrappedPropertySet::getPropertyValues( const Sequence< OUString >& rNameSeq )
276cdf0e10cSrcweir throw (uno::RuntimeException)
277cdf0e10cSrcweir {
278cdf0e10cSrcweir Sequence< Any > aRetSeq;
279cdf0e10cSrcweir if( rNameSeq.getLength() )
280cdf0e10cSrcweir {
281cdf0e10cSrcweir aRetSeq.realloc( rNameSeq.getLength() );
282cdf0e10cSrcweir for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++)
283cdf0e10cSrcweir {
284cdf0e10cSrcweir try
285cdf0e10cSrcweir {
286cdf0e10cSrcweir ::rtl::OUString aPropertyName( rNameSeq[nN] );
287cdf0e10cSrcweir aRetSeq[nN] = this->getPropertyValue( aPropertyName );
288cdf0e10cSrcweir }
289cdf0e10cSrcweir catch( beans::UnknownPropertyException& ex )
290cdf0e10cSrcweir {
291cdf0e10cSrcweir ASSERT_EXCEPTION( ex );
292cdf0e10cSrcweir }
293cdf0e10cSrcweir catch( lang::WrappedTargetException& ex )
294cdf0e10cSrcweir {
295cdf0e10cSrcweir ASSERT_EXCEPTION( ex );
296cdf0e10cSrcweir }
297cdf0e10cSrcweir }
298cdf0e10cSrcweir }
299cdf0e10cSrcweir return aRetSeq;
300cdf0e10cSrcweir }
addPropertiesChangeListener(const Sequence<OUString> &,const Reference<beans::XPropertiesChangeListener> &)301cdf0e10cSrcweir void SAL_CALL WrappedPropertySet::addPropertiesChangeListener( const Sequence< OUString >& /* rNameSeq */, const Reference< beans::XPropertiesChangeListener >& /* xListener */ )
302cdf0e10cSrcweir throw (uno::RuntimeException)
303cdf0e10cSrcweir {
304cdf0e10cSrcweir OSL_ENSURE(false,"not implemented yet");
305cdf0e10cSrcweir //todo
306cdf0e10cSrcweir }
removePropertiesChangeListener(const Reference<beans::XPropertiesChangeListener> &)307cdf0e10cSrcweir void SAL_CALL WrappedPropertySet::removePropertiesChangeListener( const Reference< beans::XPropertiesChangeListener >& /* xListener */ )
308cdf0e10cSrcweir throw (uno::RuntimeException)
309cdf0e10cSrcweir {
310cdf0e10cSrcweir OSL_ENSURE(false,"not implemented yet");
311cdf0e10cSrcweir //todo
312cdf0e10cSrcweir }
firePropertiesChangeEvent(const Sequence<OUString> &,const Reference<beans::XPropertiesChangeListener> &)313cdf0e10cSrcweir void SAL_CALL WrappedPropertySet::firePropertiesChangeEvent( const Sequence< OUString >& /* rNameSeq */, const Reference< beans::XPropertiesChangeListener >& /* xListener */ )
314cdf0e10cSrcweir throw (uno::RuntimeException)
315cdf0e10cSrcweir {
316cdf0e10cSrcweir OSL_ENSURE(false,"not implemented yet");
317cdf0e10cSrcweir //todo
318cdf0e10cSrcweir }
319cdf0e10cSrcweir
320cdf0e10cSrcweir //XPropertyState
getPropertyState(const OUString & rPropertyName)321cdf0e10cSrcweir beans::PropertyState SAL_CALL WrappedPropertySet::getPropertyState( const OUString& rPropertyName )
322cdf0e10cSrcweir throw (beans::UnknownPropertyException, uno::RuntimeException)
323cdf0e10cSrcweir {
324cdf0e10cSrcweir beans::PropertyState aState( beans::PropertyState_DIRECT_VALUE );
325cdf0e10cSrcweir
326cdf0e10cSrcweir Reference< beans::XPropertyState > xInnerPropertyState( this->getInnerPropertyState() );
327cdf0e10cSrcweir if( xInnerPropertyState.is() )
328cdf0e10cSrcweir {
329cdf0e10cSrcweir const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName );
330cdf0e10cSrcweir if( pWrappedProperty )
331cdf0e10cSrcweir aState = pWrappedProperty->getPropertyState( xInnerPropertyState );
332cdf0e10cSrcweir else
333cdf0e10cSrcweir aState = xInnerPropertyState->getPropertyState( rPropertyName );
334cdf0e10cSrcweir }
335cdf0e10cSrcweir return aState;
336cdf0e10cSrcweir }
337cdf0e10cSrcweir
getWrappedProperty(const::rtl::OUString & rOuterName)338cdf0e10cSrcweir const WrappedProperty* WrappedPropertySet::getWrappedProperty( const ::rtl::OUString& rOuterName )
339cdf0e10cSrcweir {
340cdf0e10cSrcweir sal_Int32 nHandle = getInfoHelper().getHandleByName( rOuterName );
341cdf0e10cSrcweir return getWrappedProperty( nHandle );
342cdf0e10cSrcweir }
343cdf0e10cSrcweir
getWrappedProperty(sal_Int32 nHandle)344cdf0e10cSrcweir const WrappedProperty* WrappedPropertySet::getWrappedProperty( sal_Int32 nHandle )
345cdf0e10cSrcweir {
346cdf0e10cSrcweir tWrappedPropertyMap::const_iterator aFound( getWrappedPropertyMap().find( nHandle ) );
347cdf0e10cSrcweir if( aFound != getWrappedPropertyMap().end() )
348cdf0e10cSrcweir return (*aFound).second;
349cdf0e10cSrcweir return 0;
350cdf0e10cSrcweir }
351cdf0e10cSrcweir
getPropertyStates(const Sequence<OUString> & rNameSeq)352cdf0e10cSrcweir Sequence< beans::PropertyState > SAL_CALL WrappedPropertySet::getPropertyStates( const Sequence< OUString >& rNameSeq )
353cdf0e10cSrcweir throw (beans::UnknownPropertyException, uno::RuntimeException)
354cdf0e10cSrcweir {
355cdf0e10cSrcweir Sequence< beans::PropertyState > aRetSeq;
356cdf0e10cSrcweir if( rNameSeq.getLength() )
357cdf0e10cSrcweir {
358cdf0e10cSrcweir aRetSeq.realloc( rNameSeq.getLength() );
359cdf0e10cSrcweir for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++)
360cdf0e10cSrcweir {
361cdf0e10cSrcweir ::rtl::OUString aPropertyName( rNameSeq[nN] );
362cdf0e10cSrcweir aRetSeq[nN] = this->getPropertyState( aPropertyName );
363cdf0e10cSrcweir }
364cdf0e10cSrcweir }
365cdf0e10cSrcweir return aRetSeq;
366cdf0e10cSrcweir }
367cdf0e10cSrcweir
setPropertyToDefault(const OUString & rPropertyName)368cdf0e10cSrcweir void SAL_CALL WrappedPropertySet::setPropertyToDefault( const OUString& rPropertyName )
369cdf0e10cSrcweir throw (beans::UnknownPropertyException, uno::RuntimeException)
370cdf0e10cSrcweir {
371cdf0e10cSrcweir Reference< beans::XPropertyState > xInnerPropertyState( this->getInnerPropertyState() );
372cdf0e10cSrcweir if( xInnerPropertyState.is() )
373cdf0e10cSrcweir {
374cdf0e10cSrcweir const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName );
375cdf0e10cSrcweir if( pWrappedProperty )
376cdf0e10cSrcweir pWrappedProperty->setPropertyToDefault( xInnerPropertyState );
377cdf0e10cSrcweir else
378cdf0e10cSrcweir xInnerPropertyState->setPropertyToDefault( rPropertyName );
379cdf0e10cSrcweir }
380cdf0e10cSrcweir }
getPropertyDefault(const OUString & rPropertyName)381cdf0e10cSrcweir Any SAL_CALL WrappedPropertySet::getPropertyDefault( const OUString& rPropertyName )
382cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
383cdf0e10cSrcweir {
384cdf0e10cSrcweir Any aRet;
385cdf0e10cSrcweir Reference< beans::XPropertyState > xInnerPropertyState( this->getInnerPropertyState() );
386cdf0e10cSrcweir if( xInnerPropertyState.is() )
387cdf0e10cSrcweir {
388cdf0e10cSrcweir const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName );
389cdf0e10cSrcweir if( pWrappedProperty )
390cdf0e10cSrcweir aRet = pWrappedProperty->getPropertyDefault(xInnerPropertyState);
391cdf0e10cSrcweir else
392cdf0e10cSrcweir aRet = xInnerPropertyState->getPropertyDefault( rPropertyName );
393cdf0e10cSrcweir }
394cdf0e10cSrcweir return aRet;
395cdf0e10cSrcweir }
396cdf0e10cSrcweir
397cdf0e10cSrcweir //XMultiPropertyStates
setAllPropertiesToDefault()398cdf0e10cSrcweir void SAL_CALL WrappedPropertySet::setAllPropertiesToDefault( )
399cdf0e10cSrcweir throw (uno::RuntimeException)
400cdf0e10cSrcweir {
401cdf0e10cSrcweir const Sequence< beans::Property >& rPropSeq = getPropertySequence();
402cdf0e10cSrcweir for(sal_Int32 nN=0; nN<rPropSeq.getLength(); nN++)
403cdf0e10cSrcweir {
404cdf0e10cSrcweir ::rtl::OUString aPropertyName( rPropSeq[nN].Name );
405cdf0e10cSrcweir this->setPropertyToDefault( aPropertyName );
406cdf0e10cSrcweir }
407cdf0e10cSrcweir }
setPropertiesToDefault(const Sequence<OUString> & rNameSeq)408cdf0e10cSrcweir void SAL_CALL WrappedPropertySet::setPropertiesToDefault( const Sequence< OUString >& rNameSeq )
409cdf0e10cSrcweir throw (beans::UnknownPropertyException, uno::RuntimeException)
410cdf0e10cSrcweir {
411cdf0e10cSrcweir for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++)
412cdf0e10cSrcweir {
413cdf0e10cSrcweir ::rtl::OUString aPropertyName( rNameSeq[nN] );
414cdf0e10cSrcweir this->setPropertyToDefault( aPropertyName );
415cdf0e10cSrcweir }
416cdf0e10cSrcweir }
getPropertyDefaults(const Sequence<OUString> & rNameSeq)417cdf0e10cSrcweir Sequence< Any > SAL_CALL WrappedPropertySet::getPropertyDefaults( const Sequence< OUString >& rNameSeq )
418cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
419cdf0e10cSrcweir {
420cdf0e10cSrcweir Sequence< Any > aRetSeq;
421cdf0e10cSrcweir if( rNameSeq.getLength() )
422cdf0e10cSrcweir {
423cdf0e10cSrcweir aRetSeq.realloc( rNameSeq.getLength() );
424cdf0e10cSrcweir for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++)
425cdf0e10cSrcweir {
426cdf0e10cSrcweir ::rtl::OUString aPropertyName( rNameSeq[nN] );
427cdf0e10cSrcweir aRetSeq[nN] = this->getPropertyDefault( aPropertyName );
428cdf0e10cSrcweir }
429cdf0e10cSrcweir }
430cdf0e10cSrcweir return aRetSeq;
431cdf0e10cSrcweir }
432cdf0e10cSrcweir
433cdf0e10cSrcweir //-----------------------------------------------------------------------------
434cdf0e10cSrcweir //-----------------------------------------------------------------------------
435cdf0e10cSrcweir
getInfoHelper()436cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& WrappedPropertySet::getInfoHelper()
437cdf0e10cSrcweir {
438cdf0e10cSrcweir ::cppu::OPropertyArrayHelper* p = m_pPropertyArrayHelper;
439cdf0e10cSrcweir if(!p)
440cdf0e10cSrcweir {
441cdf0e10cSrcweir ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );//do not use different mutex than is already used for static property sequence
442cdf0e10cSrcweir p = m_pPropertyArrayHelper;
443cdf0e10cSrcweir if(!p)
444cdf0e10cSrcweir {
445cdf0e10cSrcweir p = new ::cppu::OPropertyArrayHelper( getPropertySequence(), sal_True );
446cdf0e10cSrcweir OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
447cdf0e10cSrcweir m_pPropertyArrayHelper = p;
448cdf0e10cSrcweir }
449cdf0e10cSrcweir }
450cdf0e10cSrcweir else
451cdf0e10cSrcweir {
452cdf0e10cSrcweir OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
453cdf0e10cSrcweir }
454cdf0e10cSrcweir return *m_pPropertyArrayHelper;
455cdf0e10cSrcweir }
456cdf0e10cSrcweir
457cdf0e10cSrcweir //-----------------------------------------------------------------------------
458cdf0e10cSrcweir
getWrappedPropertyMap()459cdf0e10cSrcweir tWrappedPropertyMap& WrappedPropertySet::getWrappedPropertyMap()
460cdf0e10cSrcweir {
461cdf0e10cSrcweir tWrappedPropertyMap* p = m_pWrappedPropertyMap;
462cdf0e10cSrcweir if(!p)
463cdf0e10cSrcweir {
464cdf0e10cSrcweir ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );//do not use different mutex than is already used for static property sequence
465cdf0e10cSrcweir p = m_pWrappedPropertyMap;
466cdf0e10cSrcweir if(!p)
467cdf0e10cSrcweir {
468cdf0e10cSrcweir std::vector< WrappedProperty* > aPropList( createWrappedProperties() );
469cdf0e10cSrcweir p = new tWrappedPropertyMap();
470cdf0e10cSrcweir
471cdf0e10cSrcweir for( std::vector< WrappedProperty* >::const_iterator aIt = aPropList.begin(); aIt!=aPropList.end(); ++aIt )
472cdf0e10cSrcweir {
473cdf0e10cSrcweir WrappedProperty* pProperty = *aIt;
474cdf0e10cSrcweir if(pProperty)
475cdf0e10cSrcweir {
476cdf0e10cSrcweir sal_Int32 nHandle = getInfoHelper().getHandleByName( pProperty->getOuterName() );
477cdf0e10cSrcweir
478cdf0e10cSrcweir if( nHandle == -1 )
479cdf0e10cSrcweir {
480cdf0e10cSrcweir OSL_ENSURE( false, "missing property in property list" );
481cdf0e10cSrcweir delete pProperty;//we are owner or the created WrappedProperties
482cdf0e10cSrcweir }
483cdf0e10cSrcweir else if( p->find( nHandle ) != p->end() )
484cdf0e10cSrcweir {
485cdf0e10cSrcweir //duplicate Wrapped property
486cdf0e10cSrcweir OSL_ENSURE( false, "duplicate Wrapped property" );
487cdf0e10cSrcweir delete pProperty;//we are owner or the created WrappedProperties
488cdf0e10cSrcweir }
489cdf0e10cSrcweir else
490cdf0e10cSrcweir (*p)[ nHandle ] = pProperty;
491cdf0e10cSrcweir }
492cdf0e10cSrcweir }
493cdf0e10cSrcweir
494cdf0e10cSrcweir OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
495cdf0e10cSrcweir m_pWrappedPropertyMap = p;
496cdf0e10cSrcweir }
497cdf0e10cSrcweir }
498cdf0e10cSrcweir else
499cdf0e10cSrcweir {
500cdf0e10cSrcweir OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
501cdf0e10cSrcweir }
502cdf0e10cSrcweir return *m_pWrappedPropertyMap;
503cdf0e10cSrcweir }
504cdf0e10cSrcweir
505cdf0e10cSrcweir //.............................................................................
506cdf0e10cSrcweir } //namespace chart
507cdf0e10cSrcweir //.............................................................................
508