xref: /AOO41X/main/framework/source/fwi/uielement/constitemcontainer.cxx (revision 6d739b60ff8f4ed2134ae1442e284f9da90334b4)
1*6d739b60SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*6d739b60SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*6d739b60SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*6d739b60SAndrew Rist  * distributed with this work for additional information
6*6d739b60SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*6d739b60SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*6d739b60SAndrew Rist  * "License"); you may not use this file except in compliance
9*6d739b60SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*6d739b60SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*6d739b60SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*6d739b60SAndrew Rist  * software distributed under the License is distributed on an
15*6d739b60SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*6d739b60SAndrew Rist  * KIND, either express or implied.  See the License for the
17*6d739b60SAndrew Rist  * specific language governing permissions and limitations
18*6d739b60SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*6d739b60SAndrew Rist  *************************************************************/
21*6d739b60SAndrew Rist 
22*6d739b60SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_framework.hxx"
26cdf0e10cSrcweir //_________________________________________________________________________________________________________________
27cdf0e10cSrcweir //	my own includes
28cdf0e10cSrcweir //_________________________________________________________________________________________________________________
29cdf0e10cSrcweir #include <uielement/constitemcontainer.hxx>
30cdf0e10cSrcweir #include <uielement/rootitemcontainer.hxx>
31cdf0e10cSrcweir #include <uielement/itemcontainer.hxx>
32cdf0e10cSrcweir #include <threadhelp/resetableguard.hxx>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir //_________________________________________________________________________________________________________________
35cdf0e10cSrcweir //	interface includes
36cdf0e10cSrcweir //_________________________________________________________________________________________________________________
37cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir //_________________________________________________________________________________________________________________
40cdf0e10cSrcweir //	other includes
41cdf0e10cSrcweir //_________________________________________________________________________________________________________________
42cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
43cdf0e10cSrcweir 
44cdf0e10cSrcweir using namespace cppu;
45cdf0e10cSrcweir using namespace com::sun::star::uno;
46cdf0e10cSrcweir using namespace com::sun::star::lang;
47cdf0e10cSrcweir using namespace com::sun::star::beans;
48cdf0e10cSrcweir using namespace com::sun::star::container;
49cdf0e10cSrcweir 
50cdf0e10cSrcweir const char WRONG_TYPE_EXCEPTION[] = "Type must be com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >";
51cdf0e10cSrcweir 
52cdf0e10cSrcweir const int PROPHANDLE_UINAME     = 1;
53cdf0e10cSrcweir const int PROPCOUNT             = 1;
54cdf0e10cSrcweir const rtl::OUString PROPNAME_UINAME( RTL_CONSTASCII_USTRINGPARAM( "UIName" ));
55cdf0e10cSrcweir 
56cdf0e10cSrcweir namespace framework
57cdf0e10cSrcweir {
58cdf0e10cSrcweir 
59cdf0e10cSrcweir /**
60cdf0e10cSrcweir  * The class which implements the PropertySetInfo interface.
61cdf0e10cSrcweir  */
62cdf0e10cSrcweir extern "C"
63cdf0e10cSrcweir {
compare_OUString_Property_Impl(const void * arg1,const void * arg2)64cdf0e10cSrcweir static int SAL_CALL compare_OUString_Property_Impl( const void *arg1, const void *arg2 ) SAL_THROW( () )
65cdf0e10cSrcweir {
66cdf0e10cSrcweir    return ((::rtl::OUString *)arg1)->compareTo( ((Property *)arg2)->Name );
67cdf0e10cSrcweir }
68cdf0e10cSrcweir }
69cdf0e10cSrcweir 
70cdf0e10cSrcweir class OPropertySetHelperInfo_Impl
71cdf0e10cSrcweir     : public WeakImplHelper1< ::com::sun::star::beans::XPropertySetInfo >
72cdf0e10cSrcweir {
73cdf0e10cSrcweir 	Sequence < Property > aInfos;
74cdf0e10cSrcweir 
75cdf0e10cSrcweir public:
76cdf0e10cSrcweir 	OPropertySetHelperInfo_Impl( IPropertyArrayHelper & rHelper_ ) SAL_THROW( () );
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 	// XPropertySetInfo-Methoden
79cdf0e10cSrcweir     virtual Sequence< Property > SAL_CALL getProperties(void) throw(::com::sun::star::uno::RuntimeException);
80cdf0e10cSrcweir     virtual Property SAL_CALL getPropertyByName(const ::rtl::OUString& PropertyName) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
81cdf0e10cSrcweir     virtual sal_Bool SAL_CALL hasPropertyByName(const ::rtl::OUString& PropertyName) throw(::com::sun::star::uno::RuntimeException);
82cdf0e10cSrcweir };
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 
85cdf0e10cSrcweir /**
86cdf0e10cSrcweir  * Create an object that implements XPropertySetInfo IPropertyArrayHelper.
87cdf0e10cSrcweir  */
OPropertySetHelperInfo_Impl(IPropertyArrayHelper & rHelper_)88cdf0e10cSrcweir OPropertySetHelperInfo_Impl::OPropertySetHelperInfo_Impl(
89cdf0e10cSrcweir 	IPropertyArrayHelper & rHelper_ )
90cdf0e10cSrcweir 	SAL_THROW( () )
91cdf0e10cSrcweir 	:aInfos( rHelper_.getProperties() )
92cdf0e10cSrcweir {
93cdf0e10cSrcweir }
94cdf0e10cSrcweir 
95cdf0e10cSrcweir /**
96cdf0e10cSrcweir  * Return the sequence of properties, which are provided throug the constructor.
97cdf0e10cSrcweir  */
getProperties(void)98cdf0e10cSrcweir Sequence< Property > OPropertySetHelperInfo_Impl::getProperties(void) throw(::com::sun::star::uno::RuntimeException)
99cdf0e10cSrcweir {
100cdf0e10cSrcweir 	return aInfos;
101cdf0e10cSrcweir }
102cdf0e10cSrcweir 
103cdf0e10cSrcweir /**
104cdf0e10cSrcweir  * Return the sequence of properties, which are provided throug the constructor.
105cdf0e10cSrcweir  */
getPropertyByName(const::rtl::OUString & PropertyName)106cdf0e10cSrcweir Property OPropertySetHelperInfo_Impl::getPropertyByName( const ::rtl::OUString & PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)
107cdf0e10cSrcweir {
108cdf0e10cSrcweir 	Property * pR;
109cdf0e10cSrcweir 	pR = (Property *)bsearch( &PropertyName, aInfos.getConstArray(), aInfos.getLength(),
110cdf0e10cSrcweir                               sizeof( Property ),
111cdf0e10cSrcweir 							  compare_OUString_Property_Impl );
112cdf0e10cSrcweir 	if( !pR ) {
113cdf0e10cSrcweir 		throw UnknownPropertyException();
114cdf0e10cSrcweir 	}
115cdf0e10cSrcweir 
116cdf0e10cSrcweir 	return *pR;
117cdf0e10cSrcweir }
118cdf0e10cSrcweir 
119cdf0e10cSrcweir /**
120cdf0e10cSrcweir  * Return the sequence of properties, which are provided throug the constructor.
121cdf0e10cSrcweir  */
hasPropertyByName(const::rtl::OUString & PropertyName)122cdf0e10cSrcweir sal_Bool OPropertySetHelperInfo_Impl::hasPropertyByName( const ::rtl::OUString & PropertyName ) throw(::com::sun::star::uno::RuntimeException)
123cdf0e10cSrcweir {
124cdf0e10cSrcweir 	Property * pR;
125cdf0e10cSrcweir 	pR = (Property *)bsearch( &PropertyName, aInfos.getConstArray(), aInfos.getLength(),
126cdf0e10cSrcweir                               sizeof( Property ),
127cdf0e10cSrcweir 							  compare_OUString_Property_Impl );
128cdf0e10cSrcweir 	return pR != NULL;
129cdf0e10cSrcweir }
130cdf0e10cSrcweir 
131cdf0e10cSrcweir //*****************************************************************************************************************
132cdf0e10cSrcweir //	XInterface, XTypeProvider
133cdf0e10cSrcweir //*****************************************************************************************************************
DEFINE_XINTERFACE_6(ConstItemContainer,OWeakObject,DIRECT_INTERFACE (::com::sun::star::lang::XTypeProvider),DIRECT_INTERFACE (::com::sun::star::container::XElementAccess),DIRECT_INTERFACE (::com::sun::star::container::XIndexAccess),DIRECT_INTERFACE (::com::sun::star::beans::XFastPropertySet),DIRECT_INTERFACE (::com::sun::star::beans::XPropertySet),DIRECT_INTERFACE (::com::sun::star::lang::XUnoTunnel))134cdf0e10cSrcweir DEFINE_XINTERFACE_6     (   ConstItemContainer                                              ,
135cdf0e10cSrcweir                             OWeakObject                                                     ,
136cdf0e10cSrcweir                             DIRECT_INTERFACE( ::com::sun::star::lang::XTypeProvider         ),
137cdf0e10cSrcweir                             DIRECT_INTERFACE( ::com::sun::star::container::XElementAccess   ),
138cdf0e10cSrcweir                             DIRECT_INTERFACE( ::com::sun::star::container::XIndexAccess     ),
139cdf0e10cSrcweir                             DIRECT_INTERFACE( ::com::sun::star::beans::XFastPropertySet		),
140cdf0e10cSrcweir                             DIRECT_INTERFACE( ::com::sun::star::beans::XPropertySet		    ),
141cdf0e10cSrcweir                             DIRECT_INTERFACE( ::com::sun::star::lang::XUnoTunnel            )
142cdf0e10cSrcweir 						)
143cdf0e10cSrcweir 
144cdf0e10cSrcweir DEFINE_XTYPEPROVIDER_6  (   ConstItemContainer                          ,
145cdf0e10cSrcweir                             ::com::sun::star::lang::XTypeProvider       ,
146cdf0e10cSrcweir                             ::com::sun::star::container::XIndexAccess   ,
147cdf0e10cSrcweir                             ::com::sun::star::container::XElementAccess ,
148cdf0e10cSrcweir                             ::com::sun::star::beans::XFastPropertySet   ,
149cdf0e10cSrcweir                             ::com::sun::star::beans::XPropertySet       ,
150cdf0e10cSrcweir                             ::com::sun::star::lang::XUnoTunnel
151cdf0e10cSrcweir 						)
152cdf0e10cSrcweir 
153cdf0e10cSrcweir ConstItemContainer::ConstItemContainer() : ::cppu::OWeakObject()
154cdf0e10cSrcweir {
155cdf0e10cSrcweir }
156cdf0e10cSrcweir 
ConstItemContainer(const RootItemContainer & rRootItemContainer,sal_Bool bFastCopy)157cdf0e10cSrcweir ConstItemContainer::ConstItemContainer( const RootItemContainer& rRootItemContainer, sal_Bool bFastCopy )
158cdf0e10cSrcweir {
159cdf0e10cSrcweir     ShareGuard( rRootItemContainer.m_aShareMutex );
160cdf0e10cSrcweir 
161cdf0e10cSrcweir     // If bFastCopy is set the onwer of the root item container will transfer ownership to us. So
162cdf0e10cSrcweir     // it is possible to copy only the root part.
163cdf0e10cSrcweir     m_aUIName = rRootItemContainer.m_aUIName;
164cdf0e10cSrcweir     if ( bFastCopy )
165cdf0e10cSrcweir         m_aItemVector = rRootItemContainer.m_aItemVector;
166cdf0e10cSrcweir     else
167cdf0e10cSrcweir         copyItemContainer( rRootItemContainer.m_aItemVector );
168cdf0e10cSrcweir }
169cdf0e10cSrcweir 
ConstItemContainer(const ItemContainer & rItemContainer)170cdf0e10cSrcweir ConstItemContainer::ConstItemContainer( const ItemContainer& rItemContainer )
171cdf0e10cSrcweir {
172cdf0e10cSrcweir     ShareGuard( rItemContainer.m_aShareMutex );
173cdf0e10cSrcweir     copyItemContainer( rItemContainer.m_aItemVector );
174cdf0e10cSrcweir }
175cdf0e10cSrcweir 
ConstItemContainer(const Reference<XIndexAccess> & rSourceContainer,sal_Bool bFastCopy)176cdf0e10cSrcweir ConstItemContainer::ConstItemContainer( const Reference< XIndexAccess >& rSourceContainer, sal_Bool bFastCopy )
177cdf0e10cSrcweir {
178cdf0e10cSrcweir     // We also have to copy the UIName property
179cdf0e10cSrcweir     try
180cdf0e10cSrcweir     {
181cdf0e10cSrcweir         Reference< XPropertySet > xPropSet( rSourceContainer, UNO_QUERY );
182cdf0e10cSrcweir         if ( xPropSet.is() )
183cdf0e10cSrcweir         {
184cdf0e10cSrcweir             rtl::OUString aUIName;
185cdf0e10cSrcweir             xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UIName" ))) >>= m_aUIName;
186cdf0e10cSrcweir         }
187cdf0e10cSrcweir     }
188cdf0e10cSrcweir     catch ( Exception& )
189cdf0e10cSrcweir     {
190cdf0e10cSrcweir     }
191cdf0e10cSrcweir 
192cdf0e10cSrcweir     if ( rSourceContainer.is() )
193cdf0e10cSrcweir     {
194cdf0e10cSrcweir         try
195cdf0e10cSrcweir         {
196cdf0e10cSrcweir             sal_Int32 nCount = rSourceContainer->getCount();
197cdf0e10cSrcweir             m_aItemVector.reserve(nCount);
198cdf0e10cSrcweir             if ( bFastCopy )
199cdf0e10cSrcweir             {
200cdf0e10cSrcweir                 for ( sal_Int32 i = 0; i < nCount; i++ )
201cdf0e10cSrcweir                 {
202cdf0e10cSrcweir                     Sequence< PropertyValue > aPropSeq;
203cdf0e10cSrcweir                     if ( rSourceContainer->getByIndex( i ) >>= aPropSeq )
204cdf0e10cSrcweir                         m_aItemVector.push_back( aPropSeq );
205cdf0e10cSrcweir                 }
206cdf0e10cSrcweir             }
207cdf0e10cSrcweir             else
208cdf0e10cSrcweir             {
209cdf0e10cSrcweir                 for ( sal_Int32 i = 0; i < nCount; i++ )
210cdf0e10cSrcweir                 {
211cdf0e10cSrcweir                     Sequence< PropertyValue > aPropSeq;
212cdf0e10cSrcweir                     if ( rSourceContainer->getByIndex( i ) >>= aPropSeq )
213cdf0e10cSrcweir                     {
214cdf0e10cSrcweir                         sal_Int32 nContainerIndex = -1;
215cdf0e10cSrcweir                         Reference< XIndexAccess > xIndexAccess;
216cdf0e10cSrcweir                         for ( sal_Int32 j = 0; j < aPropSeq.getLength(); j++ )
217cdf0e10cSrcweir                         {
218cdf0e10cSrcweir                             if ( aPropSeq[j].Name.equalsAscii( "ItemDescriptorContainer" ))
219cdf0e10cSrcweir                             {
220cdf0e10cSrcweir                                 aPropSeq[j].Value >>= xIndexAccess;
221cdf0e10cSrcweir                                 nContainerIndex = j;
222cdf0e10cSrcweir                                 break;
223cdf0e10cSrcweir                             }
224cdf0e10cSrcweir                         }
225cdf0e10cSrcweir 
226cdf0e10cSrcweir                         if ( xIndexAccess.is() && nContainerIndex >= 0 )
227cdf0e10cSrcweir                             aPropSeq[nContainerIndex].Value <<= deepCopyContainer( xIndexAccess );
228cdf0e10cSrcweir 
229cdf0e10cSrcweir                         m_aItemVector.push_back( aPropSeq );
230cdf0e10cSrcweir                     }
231cdf0e10cSrcweir                 }
232cdf0e10cSrcweir             }
233cdf0e10cSrcweir         }
234cdf0e10cSrcweir         catch ( IndexOutOfBoundsException& )
235cdf0e10cSrcweir         {
236cdf0e10cSrcweir         }
237cdf0e10cSrcweir     }
238cdf0e10cSrcweir }
239cdf0e10cSrcweir 
~ConstItemContainer()240cdf0e10cSrcweir ConstItemContainer::~ConstItemContainer()
241cdf0e10cSrcweir {
242cdf0e10cSrcweir }
243cdf0e10cSrcweir 
244cdf0e10cSrcweir // private
copyItemContainer(const std::vector<Sequence<PropertyValue>> & rSourceVector)245cdf0e10cSrcweir void ConstItemContainer::copyItemContainer( const std::vector< Sequence< PropertyValue > >& rSourceVector )
246cdf0e10cSrcweir {
247cdf0e10cSrcweir     const sal_uInt32 nCount = rSourceVector.size();
248cdf0e10cSrcweir     for ( sal_uInt32 i = 0; i < nCount; i++ )
249cdf0e10cSrcweir     {
250cdf0e10cSrcweir         sal_Int32 nContainerIndex = -1;
251cdf0e10cSrcweir         Sequence< PropertyValue > aPropSeq( rSourceVector[i] );
252cdf0e10cSrcweir         Reference< XIndexAccess > xIndexAccess;
253cdf0e10cSrcweir         for ( sal_Int32 j = 0; j < aPropSeq.getLength(); j++ )
254cdf0e10cSrcweir         {
255cdf0e10cSrcweir             if ( aPropSeq[j].Name.equalsAscii( "ItemDescriptorContainer" ))
256cdf0e10cSrcweir             {
257cdf0e10cSrcweir                 aPropSeq[j].Value >>= xIndexAccess;
258cdf0e10cSrcweir                 nContainerIndex = j;
259cdf0e10cSrcweir                 break;
260cdf0e10cSrcweir             }
261cdf0e10cSrcweir         }
262cdf0e10cSrcweir 
263cdf0e10cSrcweir         if ( xIndexAccess.is() && nContainerIndex >= 0 )
264cdf0e10cSrcweir             aPropSeq[nContainerIndex].Value <<= deepCopyContainer( xIndexAccess );
265cdf0e10cSrcweir 
266cdf0e10cSrcweir         m_aItemVector.push_back( aPropSeq );
267cdf0e10cSrcweir     }
268cdf0e10cSrcweir }
269cdf0e10cSrcweir 
deepCopyContainer(const Reference<XIndexAccess> & rSubContainer)270cdf0e10cSrcweir Reference< XIndexAccess > ConstItemContainer::deepCopyContainer( const Reference< XIndexAccess >& rSubContainer )
271cdf0e10cSrcweir {
272cdf0e10cSrcweir     Reference< XIndexAccess > xReturn;
273cdf0e10cSrcweir     if ( rSubContainer.is() )
274cdf0e10cSrcweir     {
275cdf0e10cSrcweir         ItemContainer*      pSource = ItemContainer::GetImplementation( rSubContainer );
276cdf0e10cSrcweir         ConstItemContainer* pSubContainer( 0 );
277cdf0e10cSrcweir         if ( pSource )
278cdf0e10cSrcweir             pSubContainer = new ConstItemContainer( *pSource );
279cdf0e10cSrcweir         else
280cdf0e10cSrcweir             pSubContainer = new ConstItemContainer( rSubContainer );
281cdf0e10cSrcweir         xReturn = Reference< XIndexAccess >( static_cast< OWeakObject* >( pSubContainer ), UNO_QUERY );
282cdf0e10cSrcweir     }
283cdf0e10cSrcweir 
284cdf0e10cSrcweir     return xReturn;
285cdf0e10cSrcweir }
286cdf0e10cSrcweir 
287cdf0e10cSrcweir // XUnoTunnel
getSomething(const::com::sun::star::uno::Sequence<sal_Int8> & rIdentifier)288cdf0e10cSrcweir sal_Int64 ConstItemContainer::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier ) throw(::com::sun::star::uno::RuntimeException)
289cdf0e10cSrcweir {
290cdf0e10cSrcweir     if( ( rIdentifier.getLength() == 16 ) && ( 0 == rtl_compareMemory( ConstItemContainer::GetUnoTunnelId().getConstArray(), rIdentifier.getConstArray(), 16 ) ) )
291cdf0e10cSrcweir 	{
292cdf0e10cSrcweir 		return reinterpret_cast< sal_Int64 >( this );
293cdf0e10cSrcweir 	}
294cdf0e10cSrcweir 	return 0;
295cdf0e10cSrcweir }
296cdf0e10cSrcweir 
GetUnoTunnelId()297cdf0e10cSrcweir const Sequence< sal_Int8 >& ConstItemContainer::GetUnoTunnelId() throw()
298cdf0e10cSrcweir {
299cdf0e10cSrcweir 	static ::com::sun::star::uno::Sequence< sal_Int8 > * pSeq = NULL;
300cdf0e10cSrcweir 	if( !pSeq )
301cdf0e10cSrcweir 	{
302cdf0e10cSrcweir 		::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() );
303cdf0e10cSrcweir 		if( !pSeq )
304cdf0e10cSrcweir 		{
305cdf0e10cSrcweir 			static ::com::sun::star::uno::Sequence< sal_Int8 > aSeq( 16 );
306cdf0e10cSrcweir 			rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
307cdf0e10cSrcweir 			pSeq = &aSeq;
308cdf0e10cSrcweir 		}
309cdf0e10cSrcweir 	}
310cdf0e10cSrcweir 	return *pSeq;
311cdf0e10cSrcweir }
312cdf0e10cSrcweir 
GetImplementation(const::com::sun::star::uno::Reference<::com::sun::star::uno::XInterface> & rxIFace)313cdf0e10cSrcweir ConstItemContainer* ConstItemContainer::GetImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxIFace ) throw()
314cdf0e10cSrcweir {
315cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > xUT( rxIFace, ::com::sun::star::uno::UNO_QUERY );
316cdf0e10cSrcweir 	return xUT.is() ? reinterpret_cast< ConstItemContainer* >(sal::static_int_cast< sal_IntPtr >(
317cdf0e10cSrcweir                           xUT->getSomething( ConstItemContainer::GetUnoTunnelId() ))) : NULL;
318cdf0e10cSrcweir }
319cdf0e10cSrcweir 
320cdf0e10cSrcweir // XElementAccess
hasElements()321cdf0e10cSrcweir sal_Bool SAL_CALL ConstItemContainer::hasElements()
322cdf0e10cSrcweir throw ( RuntimeException )
323cdf0e10cSrcweir {
324cdf0e10cSrcweir     return ( !m_aItemVector.empty() );
325cdf0e10cSrcweir }
326cdf0e10cSrcweir 
327cdf0e10cSrcweir // XIndexAccess
getCount()328cdf0e10cSrcweir sal_Int32 SAL_CALL ConstItemContainer::getCount()
329cdf0e10cSrcweir throw ( RuntimeException )
330cdf0e10cSrcweir {
331cdf0e10cSrcweir     return m_aItemVector.size();
332cdf0e10cSrcweir }
333cdf0e10cSrcweir 
getByIndex(sal_Int32 Index)334cdf0e10cSrcweir Any SAL_CALL ConstItemContainer::getByIndex( sal_Int32 Index )
335cdf0e10cSrcweir throw ( IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
336cdf0e10cSrcweir {
337cdf0e10cSrcweir     if ( sal_Int32( m_aItemVector.size()) > Index )
338cdf0e10cSrcweir         return makeAny( m_aItemVector[Index] );
339cdf0e10cSrcweir     else
340cdf0e10cSrcweir 		throw IndexOutOfBoundsException( ::rtl::OUString(), (OWeakObject *)this );
341cdf0e10cSrcweir }
342cdf0e10cSrcweir 
343cdf0e10cSrcweir // XPropertySet
getPropertySetInfo()344cdf0e10cSrcweir Reference< XPropertySetInfo > SAL_CALL ConstItemContainer::getPropertySetInfo()
345cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
346cdf0e10cSrcweir {
347cdf0e10cSrcweir 	// Optimize this method !
348cdf0e10cSrcweir 	// We initialize a static variable only one time. And we don't must use a mutex at every call!
349cdf0e10cSrcweir 	// For the first call; pInfo is NULL - for the second call pInfo is different from NULL!
350cdf0e10cSrcweir     static Reference< XPropertySetInfo >* pInfo = NULL;
351cdf0e10cSrcweir 
352cdf0e10cSrcweir     if( pInfo == NULL )
353cdf0e10cSrcweir 	{
354cdf0e10cSrcweir 		// Ready for multithreading
355cdf0e10cSrcweir 		osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
356cdf0e10cSrcweir 		// Control this pointer again, another instance can be faster then these!
357cdf0e10cSrcweir         if( pInfo == NULL )
358cdf0e10cSrcweir 		{
359cdf0e10cSrcweir 			// Create structure of propertysetinfo for baseclass "OPropertySetHelper".
360cdf0e10cSrcweir 			// (Use method "getInfoHelper()".)
361cdf0e10cSrcweir             static Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
362cdf0e10cSrcweir 			pInfo = &xInfo;
363cdf0e10cSrcweir 		}
364cdf0e10cSrcweir 	}
365cdf0e10cSrcweir 
366cdf0e10cSrcweir 	return (*pInfo);
367cdf0e10cSrcweir }
368cdf0e10cSrcweir 
setPropertyValue(const::rtl::OUString &,const Any &)369cdf0e10cSrcweir void SAL_CALL ConstItemContainer::setPropertyValue( const ::rtl::OUString&, const Any& )
370cdf0e10cSrcweir throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
371cdf0e10cSrcweir {
372cdf0e10cSrcweir }
373cdf0e10cSrcweir 
getPropertyValue(const::rtl::OUString & PropertyName)374cdf0e10cSrcweir Any SAL_CALL ConstItemContainer::getPropertyValue( const ::rtl::OUString& PropertyName )
375cdf0e10cSrcweir throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
376cdf0e10cSrcweir {
377cdf0e10cSrcweir     if ( PropertyName.equals( PROPNAME_UINAME ))
378cdf0e10cSrcweir         return makeAny( m_aUIName );
379cdf0e10cSrcweir 
380cdf0e10cSrcweir     throw UnknownPropertyException();
381cdf0e10cSrcweir }
382cdf0e10cSrcweir 
addPropertyChangeListener(const::rtl::OUString &,const::com::sun::star::uno::Reference<::com::sun::star::beans::XPropertyChangeListener> &)383cdf0e10cSrcweir void SAL_CALL ConstItemContainer::addPropertyChangeListener( const ::rtl::OUString&, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& )
384cdf0e10cSrcweir throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
385cdf0e10cSrcweir {
386cdf0e10cSrcweir }
387cdf0e10cSrcweir 
removePropertyChangeListener(const::rtl::OUString &,const::com::sun::star::uno::Reference<::com::sun::star::beans::XPropertyChangeListener> &)388cdf0e10cSrcweir void SAL_CALL ConstItemContainer::removePropertyChangeListener( const ::rtl::OUString&, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& )
389cdf0e10cSrcweir throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
390cdf0e10cSrcweir {
391cdf0e10cSrcweir     // Only read-only properties - do nothing
392cdf0e10cSrcweir }
393cdf0e10cSrcweir 
addVetoableChangeListener(const::rtl::OUString &,const::com::sun::star::uno::Reference<::com::sun::star::beans::XVetoableChangeListener> &)394cdf0e10cSrcweir void SAL_CALL ConstItemContainer::addVetoableChangeListener( const ::rtl::OUString&, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& )
395cdf0e10cSrcweir throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
396cdf0e10cSrcweir {
397cdf0e10cSrcweir     // Only read-only properties - do nothing
398cdf0e10cSrcweir }
399cdf0e10cSrcweir 
removeVetoableChangeListener(const::rtl::OUString &,const::com::sun::star::uno::Reference<::com::sun::star::beans::XVetoableChangeListener> &)400cdf0e10cSrcweir void SAL_CALL ConstItemContainer::removeVetoableChangeListener( const ::rtl::OUString&, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& )
401cdf0e10cSrcweir throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
402cdf0e10cSrcweir {
403cdf0e10cSrcweir     // Only read-only properties - do nothing
404cdf0e10cSrcweir }
405cdf0e10cSrcweir 
406cdf0e10cSrcweir // XFastPropertySet
setFastPropertyValue(sal_Int32,const::com::sun::star::uno::Any &)407cdf0e10cSrcweir void SAL_CALL ConstItemContainer::setFastPropertyValue( sal_Int32, const ::com::sun::star::uno::Any& )
408cdf0e10cSrcweir throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
409cdf0e10cSrcweir {
410cdf0e10cSrcweir }
411cdf0e10cSrcweir 
getFastPropertyValue(sal_Int32 nHandle)412cdf0e10cSrcweir Any SAL_CALL ConstItemContainer::getFastPropertyValue( sal_Int32 nHandle )
413cdf0e10cSrcweir throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
414cdf0e10cSrcweir {
415cdf0e10cSrcweir     if ( nHandle == PROPHANDLE_UINAME )
416cdf0e10cSrcweir         return makeAny( m_aUIName );
417cdf0e10cSrcweir 
418cdf0e10cSrcweir     throw UnknownPropertyException();
419cdf0e10cSrcweir }
420cdf0e10cSrcweir 
getInfoHelper()421cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& SAL_CALL ConstItemContainer::getInfoHelper()
422cdf0e10cSrcweir {
423cdf0e10cSrcweir 	// Optimize this method !
424cdf0e10cSrcweir 	// We initialize a static variable only one time. And we don't must use a mutex at every call!
425cdf0e10cSrcweir 	// For the first call; pInfoHelper is NULL - for the second call pInfoHelper is different from NULL!
426cdf0e10cSrcweir     static ::cppu::OPropertyArrayHelper* pInfoHelper = NULL;
427cdf0e10cSrcweir 
428cdf0e10cSrcweir     if( pInfoHelper == NULL )
429cdf0e10cSrcweir 	{
430cdf0e10cSrcweir 		// Ready for multithreading
431cdf0e10cSrcweir         osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
432cdf0e10cSrcweir 
433cdf0e10cSrcweir 		// Control this pointer again, another instance can be faster then these!
434cdf0e10cSrcweir         if( pInfoHelper == NULL )
435cdf0e10cSrcweir 		{
436cdf0e10cSrcweir 			// Define static member to give structure of properties to baseclass "OPropertySetHelper".
437cdf0e10cSrcweir 			// "impl_getStaticPropertyDescriptor" is a non exported and static funtion, who will define a static propertytable.
438cdf0e10cSrcweir 			// "sal_True" say: Table is sorted by name.
439cdf0e10cSrcweir             static ::cppu::OPropertyArrayHelper aInfoHelper( impl_getStaticPropertyDescriptor(), sal_True );
440cdf0e10cSrcweir 			pInfoHelper = &aInfoHelper;
441cdf0e10cSrcweir 		}
442cdf0e10cSrcweir 	}
443cdf0e10cSrcweir 
444cdf0e10cSrcweir     return(*pInfoHelper);
445cdf0e10cSrcweir }
446cdf0e10cSrcweir 
impl_getStaticPropertyDescriptor()447cdf0e10cSrcweir const com::sun::star::uno::Sequence< com::sun::star::beans::Property > ConstItemContainer::impl_getStaticPropertyDescriptor()
448cdf0e10cSrcweir {
449cdf0e10cSrcweir 	// Create a new static property array to initialize sequence!
450cdf0e10cSrcweir 	// Table of all predefined properties of this class. Its used from OPropertySetHelper-class!
451cdf0e10cSrcweir 	// Don't forget to change the defines (see begin of this file), if you add, change or delete a property in this list!!!
452cdf0e10cSrcweir 	// It's necessary for methods of OPropertySetHelper.
453cdf0e10cSrcweir 	// ATTENTION:
454cdf0e10cSrcweir     //      YOU MUST SORT FOLLOW TABLE BY NAME ALPHABETICAL !!!
455cdf0e10cSrcweir 
456cdf0e10cSrcweir     static const com::sun::star::beans::Property pProperties[] =
457cdf0e10cSrcweir 	{
458cdf0e10cSrcweir         com::sun::star::beans::Property( PROPNAME_UINAME, PROPHANDLE_UINAME ,
459cdf0e10cSrcweir                                          ::getCppuType((const rtl::OUString*)NULL),
460cdf0e10cSrcweir                                          com::sun::star::beans::PropertyAttribute::TRANSIENT | com::sun::star::beans::PropertyAttribute::READONLY  )
461cdf0e10cSrcweir 	};
462cdf0e10cSrcweir 	// Use it to initialize sequence!
463cdf0e10cSrcweir     static const com::sun::star::uno::Sequence< com::sun::star::beans::Property > lPropertyDescriptor( pProperties, PROPCOUNT );
464cdf0e10cSrcweir 	// Return static "PropertyDescriptor"
465cdf0e10cSrcweir     return lPropertyDescriptor;
466cdf0e10cSrcweir }
467cdf0e10cSrcweir 
createPropertySetInfo(IPropertyArrayHelper & rProperties)468cdf0e10cSrcweir Reference < XPropertySetInfo > ConstItemContainer::createPropertySetInfo(
469cdf0e10cSrcweir 	IPropertyArrayHelper & rProperties ) SAL_THROW( () )
470cdf0e10cSrcweir {
471cdf0e10cSrcweir 	return static_cast< XPropertySetInfo * >( new OPropertySetHelperInfo_Impl( rProperties ) );
472cdf0e10cSrcweir }
473cdf0e10cSrcweir 
474cdf0e10cSrcweir } // namespace framework
475cdf0e10cSrcweir 
476