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
10*6d739b60SAndrew Rist *
11*6d739b60SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*6d739b60SAndrew Rist *
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.
19*6d739b60SAndrew Rist *
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/rootitemcontainer.hxx>
30cdf0e10cSrcweir
31cdf0e10cSrcweir #ifndef __FRAMEWORK_UIELEMENT_ITEMCONTAINER_HHX_
32cdf0e10cSrcweir #include <uielement/itemcontainer.hxx>
33cdf0e10cSrcweir #endif
34cdf0e10cSrcweir
35cdf0e10cSrcweir #ifndef __FRAMEWORK_UIELEMENT_CONSTITEMCONTAINER_HHX_
36cdf0e10cSrcweir #include <uielement/constitemcontainer.hxx>
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir #include <threadhelp/resetableguard.hxx>
39cdf0e10cSrcweir #include <general.h>
40cdf0e10cSrcweir #include <properties.h>
41cdf0e10cSrcweir
42cdf0e10cSrcweir //_________________________________________________________________________________________________________________
43cdf0e10cSrcweir // interface includes
44cdf0e10cSrcweir //_________________________________________________________________________________________________________________
45cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
46cdf0e10cSrcweir
47cdf0e10cSrcweir //_________________________________________________________________________________________________________________
48cdf0e10cSrcweir // other includes
49cdf0e10cSrcweir //_________________________________________________________________________________________________________________
50cdf0e10cSrcweir
51cdf0e10cSrcweir using namespace cppu;
52cdf0e10cSrcweir using namespace com::sun::star::uno;
53cdf0e10cSrcweir using namespace com::sun::star::lang;
54cdf0e10cSrcweir using namespace com::sun::star::beans;
55cdf0e10cSrcweir using namespace com::sun::star::container;
56cdf0e10cSrcweir
57cdf0e10cSrcweir const char WRONG_TYPE_EXCEPTION[] = "Type must be com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >";
58cdf0e10cSrcweir
59cdf0e10cSrcweir const int PROPHANDLE_UINAME = 1;
60cdf0e10cSrcweir const int PROPCOUNT = 1;
61cdf0e10cSrcweir const rtl::OUString PROPNAME_UINAME( RTL_CONSTASCII_USTRINGPARAM( "UIName" ));
62cdf0e10cSrcweir
63cdf0e10cSrcweir namespace framework
64cdf0e10cSrcweir {
65cdf0e10cSrcweir
66cdf0e10cSrcweir //*****************************************************************************************************************
67cdf0e10cSrcweir // XInterface, XTypeProvider
68cdf0e10cSrcweir //*****************************************************************************************************************
DEFINE_XINTERFACE_10(RootItemContainer,OWeakObject,DIRECT_INTERFACE (::com::sun::star::lang::XTypeProvider),DIRECT_INTERFACE (::com::sun::star::container::XIndexContainer),DIRECT_INTERFACE (::com::sun::star::lang::XUnoTunnel),DIRECT_INTERFACE (::com::sun::star::lang::XSingleComponentFactory),DIRECT_INTERFACE (::com::sun::star::beans::XMultiPropertySet),DIRECT_INTERFACE (::com::sun::star::beans::XFastPropertySet),DIRECT_INTERFACE (::com::sun::star::beans::XPropertySet),DERIVED_INTERFACE (::com::sun::star::container::XIndexReplace,com::sun::star::container::XIndexContainer),DERIVED_INTERFACE (::com::sun::star::container::XIndexAccess,com::sun::star::container::XIndexReplace),DERIVED_INTERFACE (::com::sun::star::container::XElementAccess,::com::sun::star::container::XIndexAccess))69cdf0e10cSrcweir DEFINE_XINTERFACE_10 ( RootItemContainer ,
70cdf0e10cSrcweir OWeakObject ,
71cdf0e10cSrcweir DIRECT_INTERFACE( ::com::sun::star::lang::XTypeProvider ),
72cdf0e10cSrcweir DIRECT_INTERFACE( ::com::sun::star::container::XIndexContainer ),
73cdf0e10cSrcweir DIRECT_INTERFACE( ::com::sun::star::lang::XUnoTunnel ),
74cdf0e10cSrcweir DIRECT_INTERFACE( ::com::sun::star::lang::XSingleComponentFactory ),
75cdf0e10cSrcweir DIRECT_INTERFACE( ::com::sun::star::beans::XMultiPropertySet ),
76cdf0e10cSrcweir DIRECT_INTERFACE( ::com::sun::star::beans::XFastPropertySet ),
77cdf0e10cSrcweir DIRECT_INTERFACE( ::com::sun::star::beans::XPropertySet ),
78cdf0e10cSrcweir DERIVED_INTERFACE( ::com::sun::star::container::XIndexReplace, com::sun::star::container::XIndexContainer ),
79cdf0e10cSrcweir DERIVED_INTERFACE( ::com::sun::star::container::XIndexAccess, com::sun::star::container::XIndexReplace ),
80cdf0e10cSrcweir DERIVED_INTERFACE( ::com::sun::star::container::XElementAccess, ::com::sun::star::container::XIndexAccess )
81cdf0e10cSrcweir )
82cdf0e10cSrcweir
83cdf0e10cSrcweir DEFINE_XTYPEPROVIDER_10 ( RootItemContainer ,
84cdf0e10cSrcweir ::com::sun::star::lang::XTypeProvider ,
85cdf0e10cSrcweir ::com::sun::star::container::XIndexContainer ,
86cdf0e10cSrcweir ::com::sun::star::container::XIndexReplace ,
87cdf0e10cSrcweir ::com::sun::star::container::XIndexAccess ,
88cdf0e10cSrcweir ::com::sun::star::container::XElementAccess ,
89cdf0e10cSrcweir ::com::sun::star::beans::XMultiPropertySet ,
90cdf0e10cSrcweir ::com::sun::star::beans::XFastPropertySet ,
91cdf0e10cSrcweir ::com::sun::star::beans::XPropertySet ,
92cdf0e10cSrcweir ::com::sun::star::lang::XUnoTunnel ,
93cdf0e10cSrcweir ::com::sun::star::lang::XSingleComponentFactory
94cdf0e10cSrcweir )
95cdf0e10cSrcweir
96cdf0e10cSrcweir RootItemContainer::RootItemContainer()
97cdf0e10cSrcweir : ThreadHelpBase ( )
98cdf0e10cSrcweir , ::cppu::OBroadcastHelperVar< ::cppu::OMultiTypeInterfaceContainerHelper, ::cppu::OMultiTypeInterfaceContainerHelper::keyType >( m_aLock.getShareableOslMutex() )
99cdf0e10cSrcweir , ::cppu::OPropertySetHelper ( *(static_cast< ::cppu::OBroadcastHelper* >(this)) )
100cdf0e10cSrcweir , ::cppu::OWeakObject()
101cdf0e10cSrcweir {
102cdf0e10cSrcweir }
103cdf0e10cSrcweir
RootItemContainer(const ConstItemContainer & rConstItemContainer)104cdf0e10cSrcweir RootItemContainer::RootItemContainer( const ConstItemContainer& rConstItemContainer )
105cdf0e10cSrcweir : ThreadHelpBase ( )
106cdf0e10cSrcweir , ::cppu::OBroadcastHelperVar< ::cppu::OMultiTypeInterfaceContainerHelper, ::cppu::OMultiTypeInterfaceContainerHelper::keyType >( m_aLock.getShareableOslMutex() )
107cdf0e10cSrcweir , ::cppu::OPropertySetHelper ( *(static_cast< ::cppu::OBroadcastHelper* >(this)) )
108cdf0e10cSrcweir , ::cppu::OWeakObject()
109cdf0e10cSrcweir {
110cdf0e10cSrcweir m_aUIName = rConstItemContainer.m_aUIName;
111cdf0e10cSrcweir copyItemContainer( rConstItemContainer.m_aItemVector );
112cdf0e10cSrcweir }
113cdf0e10cSrcweir
RootItemContainer(const Reference<XIndexAccess> & rSourceContainer)114cdf0e10cSrcweir RootItemContainer::RootItemContainer( const Reference< XIndexAccess >& rSourceContainer )
115cdf0e10cSrcweir : ThreadHelpBase ( )
116cdf0e10cSrcweir , ::cppu::OBroadcastHelperVar< ::cppu::OMultiTypeInterfaceContainerHelper, ::cppu::OMultiTypeInterfaceContainerHelper::keyType >( m_aLock.getShareableOslMutex() )
117cdf0e10cSrcweir , ::cppu::OPropertySetHelper ( *(static_cast< ::cppu::OBroadcastHelper* >(this)) )
118cdf0e10cSrcweir , ::cppu::OWeakObject()
119cdf0e10cSrcweir {
120cdf0e10cSrcweir // We also have to copy the UIName property
121cdf0e10cSrcweir try
122cdf0e10cSrcweir {
123cdf0e10cSrcweir Reference< XPropertySet > xPropSet( rSourceContainer, UNO_QUERY );
124cdf0e10cSrcweir if ( xPropSet.is() )
125cdf0e10cSrcweir {
126cdf0e10cSrcweir xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UIName" ))) >>= m_aUIName;
127cdf0e10cSrcweir }
128cdf0e10cSrcweir }
129cdf0e10cSrcweir catch ( Exception& )
130cdf0e10cSrcweir {
131cdf0e10cSrcweir }
132cdf0e10cSrcweir
133cdf0e10cSrcweir if ( rSourceContainer.is() )
134cdf0e10cSrcweir {
135cdf0e10cSrcweir sal_Int32 nCount = rSourceContainer->getCount();
136cdf0e10cSrcweir try
137cdf0e10cSrcweir {
138cdf0e10cSrcweir for ( sal_Int32 i = 0; i < nCount; i++ )
139cdf0e10cSrcweir {
140cdf0e10cSrcweir Sequence< PropertyValue > aPropSeq;
141cdf0e10cSrcweir if ( rSourceContainer->getByIndex( i ) >>= aPropSeq )
142cdf0e10cSrcweir {
143cdf0e10cSrcweir sal_Int32 nContainerIndex = -1;
144cdf0e10cSrcweir Reference< XIndexAccess > xIndexAccess;
145cdf0e10cSrcweir for ( sal_Int32 j = 0; j < aPropSeq.getLength(); j++ )
146cdf0e10cSrcweir {
147cdf0e10cSrcweir if ( aPropSeq[j].Name.equalsAscii( "ItemDescriptorContainer" ))
148cdf0e10cSrcweir {
149cdf0e10cSrcweir aPropSeq[j].Value >>= xIndexAccess;
150cdf0e10cSrcweir nContainerIndex = j;
151cdf0e10cSrcweir break;
152cdf0e10cSrcweir }
153cdf0e10cSrcweir }
154cdf0e10cSrcweir
155cdf0e10cSrcweir if ( xIndexAccess.is() && nContainerIndex >= 0 )
156cdf0e10cSrcweir aPropSeq[nContainerIndex].Value <<= deepCopyContainer( xIndexAccess );
157cdf0e10cSrcweir
158cdf0e10cSrcweir m_aItemVector.push_back( aPropSeq );
159cdf0e10cSrcweir }
160cdf0e10cSrcweir }
161cdf0e10cSrcweir }
162cdf0e10cSrcweir catch ( IndexOutOfBoundsException& )
163cdf0e10cSrcweir {
164cdf0e10cSrcweir }
165cdf0e10cSrcweir }
166cdf0e10cSrcweir }
167cdf0e10cSrcweir
~RootItemContainer()168cdf0e10cSrcweir RootItemContainer::~RootItemContainer()
169cdf0e10cSrcweir {
170cdf0e10cSrcweir }
171cdf0e10cSrcweir
172cdf0e10cSrcweir // private
copyItemContainer(const std::vector<Sequence<PropertyValue>> & rSourceVector)173cdf0e10cSrcweir void RootItemContainer::copyItemContainer( const std::vector< Sequence< PropertyValue > >& rSourceVector )
174cdf0e10cSrcweir {
175cdf0e10cSrcweir const sal_uInt32 nCount = rSourceVector.size();
176cdf0e10cSrcweir m_aItemVector.reserve(nCount);
177cdf0e10cSrcweir for ( sal_uInt32 i = 0; i < nCount; i++ )
178cdf0e10cSrcweir {
179cdf0e10cSrcweir sal_Int32 nContainerIndex = -1;
180cdf0e10cSrcweir Sequence< PropertyValue > aPropSeq( rSourceVector[i] );
181cdf0e10cSrcweir Reference< XIndexAccess > xIndexAccess;
182cdf0e10cSrcweir for ( sal_Int32 j = 0; j < aPropSeq.getLength(); j++ )
183cdf0e10cSrcweir {
184cdf0e10cSrcweir if ( aPropSeq[j].Name.equalsAscii( "ItemDescriptorContainer" ))
185cdf0e10cSrcweir {
186cdf0e10cSrcweir aPropSeq[j].Value >>= xIndexAccess;
187cdf0e10cSrcweir nContainerIndex = j;
188cdf0e10cSrcweir break;
189cdf0e10cSrcweir }
190cdf0e10cSrcweir }
191cdf0e10cSrcweir
192cdf0e10cSrcweir if ( xIndexAccess.is() && nContainerIndex >= 0 )
193cdf0e10cSrcweir aPropSeq[nContainerIndex].Value <<= deepCopyContainer( xIndexAccess );
194cdf0e10cSrcweir
195cdf0e10cSrcweir m_aItemVector.push_back( aPropSeq );
196cdf0e10cSrcweir }
197cdf0e10cSrcweir }
198cdf0e10cSrcweir
deepCopyContainer(const Reference<XIndexAccess> & rSubContainer)199cdf0e10cSrcweir Reference< XIndexAccess > RootItemContainer::deepCopyContainer( const Reference< XIndexAccess >& rSubContainer )
200cdf0e10cSrcweir {
201cdf0e10cSrcweir Reference< XIndexAccess > xReturn;
202cdf0e10cSrcweir if ( rSubContainer.is() )
203cdf0e10cSrcweir {
204cdf0e10cSrcweir ConstItemContainer* pSource = ConstItemContainer::GetImplementation( rSubContainer );
205cdf0e10cSrcweir ItemContainer* pSubContainer( 0 );
206cdf0e10cSrcweir if ( pSource )
207cdf0e10cSrcweir pSubContainer = new ItemContainer( *pSource, m_aShareMutex );
208cdf0e10cSrcweir else
209cdf0e10cSrcweir pSubContainer = new ItemContainer( rSubContainer, m_aShareMutex );
210cdf0e10cSrcweir xReturn = Reference< XIndexAccess >( static_cast< OWeakObject* >( pSubContainer ), UNO_QUERY );
211cdf0e10cSrcweir }
212cdf0e10cSrcweir
213cdf0e10cSrcweir return xReturn;
214cdf0e10cSrcweir }
215cdf0e10cSrcweir
216cdf0e10cSrcweir // XUnoTunnel
getSomething(const::com::sun::star::uno::Sequence<sal_Int8> & rIdentifier)217cdf0e10cSrcweir sal_Int64 RootItemContainer::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier ) throw(::com::sun::star::uno::RuntimeException)
218cdf0e10cSrcweir {
219cdf0e10cSrcweir if( ( rIdentifier.getLength() == 16 ) && ( 0 == rtl_compareMemory( RootItemContainer::GetUnoTunnelId().getConstArray(), rIdentifier.getConstArray(), 16 ) ) )
220cdf0e10cSrcweir return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ));
221cdf0e10cSrcweir return 0;
222cdf0e10cSrcweir }
223cdf0e10cSrcweir
GetUnoTunnelId()224cdf0e10cSrcweir const Sequence< sal_Int8 >& RootItemContainer::GetUnoTunnelId() throw()
225cdf0e10cSrcweir {
226cdf0e10cSrcweir static ::com::sun::star::uno::Sequence< sal_Int8 > * pSeq = NULL;
227cdf0e10cSrcweir if( !pSeq )
228cdf0e10cSrcweir {
229cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() );
230cdf0e10cSrcweir if( !pSeq )
231cdf0e10cSrcweir {
232cdf0e10cSrcweir static ::com::sun::star::uno::Sequence< sal_Int8 > aSeq( 16 );
233cdf0e10cSrcweir rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
234cdf0e10cSrcweir pSeq = &aSeq;
235cdf0e10cSrcweir }
236cdf0e10cSrcweir }
237cdf0e10cSrcweir return *pSeq;
238cdf0e10cSrcweir }
239cdf0e10cSrcweir
GetImplementation(const::com::sun::star::uno::Reference<::com::sun::star::uno::XInterface> & rxIFace)240cdf0e10cSrcweir RootItemContainer* RootItemContainer::GetImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxIFace ) throw()
241cdf0e10cSrcweir {
242cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > xUT( rxIFace, ::com::sun::star::uno::UNO_QUERY );
243cdf0e10cSrcweir return xUT.is() ? reinterpret_cast< RootItemContainer* >(sal::static_int_cast< sal_IntPtr >(
244cdf0e10cSrcweir xUT->getSomething( RootItemContainer::GetUnoTunnelId() ))) : NULL;
245cdf0e10cSrcweir }
246cdf0e10cSrcweir
247cdf0e10cSrcweir // XElementAccess
hasElements()248cdf0e10cSrcweir sal_Bool SAL_CALL RootItemContainer::hasElements()
249cdf0e10cSrcweir throw ( RuntimeException )
250cdf0e10cSrcweir {
251cdf0e10cSrcweir ShareGuard aLock( m_aShareMutex );
252cdf0e10cSrcweir return ( !m_aItemVector.empty() );
253cdf0e10cSrcweir }
254cdf0e10cSrcweir
255cdf0e10cSrcweir // XIndexAccess
getCount()256cdf0e10cSrcweir sal_Int32 SAL_CALL RootItemContainer::getCount()
257cdf0e10cSrcweir throw ( RuntimeException )
258cdf0e10cSrcweir {
259cdf0e10cSrcweir ShareGuard aLock( m_aShareMutex );
260cdf0e10cSrcweir return m_aItemVector.size();
261cdf0e10cSrcweir }
262cdf0e10cSrcweir
getByIndex(sal_Int32 Index)263cdf0e10cSrcweir Any SAL_CALL RootItemContainer::getByIndex( sal_Int32 Index )
264cdf0e10cSrcweir throw ( IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
265cdf0e10cSrcweir {
266cdf0e10cSrcweir ShareGuard aLock( m_aShareMutex );
267cdf0e10cSrcweir if ( sal_Int32( m_aItemVector.size()) > Index )
268cdf0e10cSrcweir return makeAny( m_aItemVector[Index] );
269cdf0e10cSrcweir else
270cdf0e10cSrcweir throw IndexOutOfBoundsException( ::rtl::OUString(), (OWeakObject *)this );
271cdf0e10cSrcweir }
272cdf0e10cSrcweir
273cdf0e10cSrcweir // XIndexContainer
insertByIndex(sal_Int32 Index,const Any & aItem)274cdf0e10cSrcweir void SAL_CALL RootItemContainer::insertByIndex( sal_Int32 Index, const Any& aItem )
275cdf0e10cSrcweir throw ( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
276cdf0e10cSrcweir {
277cdf0e10cSrcweir Sequence< PropertyValue > aSeq;
278cdf0e10cSrcweir if ( aItem >>= aSeq )
279cdf0e10cSrcweir {
280cdf0e10cSrcweir ShareGuard aLock( m_aShareMutex );
281cdf0e10cSrcweir if ( sal_Int32( m_aItemVector.size()) == Index )
282cdf0e10cSrcweir m_aItemVector.push_back( aSeq );
283cdf0e10cSrcweir else if ( sal_Int32( m_aItemVector.size()) >Index )
284cdf0e10cSrcweir {
285cdf0e10cSrcweir std::vector< Sequence< PropertyValue > >::iterator aIter = m_aItemVector.begin();
286cdf0e10cSrcweir aIter += Index;
287cdf0e10cSrcweir m_aItemVector.insert( aIter, aSeq );
288cdf0e10cSrcweir }
289cdf0e10cSrcweir else
290cdf0e10cSrcweir throw IndexOutOfBoundsException( ::rtl::OUString(), (OWeakObject *)this );
291cdf0e10cSrcweir }
292cdf0e10cSrcweir else
293cdf0e10cSrcweir throw IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( WRONG_TYPE_EXCEPTION )),
294cdf0e10cSrcweir (OWeakObject *)this, 2 );
295cdf0e10cSrcweir }
296cdf0e10cSrcweir
removeByIndex(sal_Int32 Index)297cdf0e10cSrcweir void SAL_CALL RootItemContainer::removeByIndex( sal_Int32 Index )
298cdf0e10cSrcweir throw ( IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
299cdf0e10cSrcweir {
300cdf0e10cSrcweir ShareGuard aLock( m_aShareMutex );
301cdf0e10cSrcweir if ( (sal_Int32)m_aItemVector.size() > Index )
302cdf0e10cSrcweir {
303cdf0e10cSrcweir std::vector< Sequence< PropertyValue > >::iterator aIter = m_aItemVector.begin();
304cdf0e10cSrcweir aIter += Index;
305cdf0e10cSrcweir m_aItemVector.erase( aIter );
306cdf0e10cSrcweir }
307cdf0e10cSrcweir else
308cdf0e10cSrcweir throw IndexOutOfBoundsException( ::rtl::OUString(), (OWeakObject *)this );
309cdf0e10cSrcweir }
310cdf0e10cSrcweir
replaceByIndex(sal_Int32 Index,const Any & aItem)311cdf0e10cSrcweir void SAL_CALL RootItemContainer::replaceByIndex( sal_Int32 Index, const Any& aItem )
312cdf0e10cSrcweir throw ( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
313cdf0e10cSrcweir {
314cdf0e10cSrcweir Sequence< PropertyValue > aSeq;
315cdf0e10cSrcweir if ( aItem >>= aSeq )
316cdf0e10cSrcweir {
317cdf0e10cSrcweir ShareGuard aLock( m_aShareMutex );
318cdf0e10cSrcweir if ( sal_Int32( m_aItemVector.size()) > Index )
319cdf0e10cSrcweir m_aItemVector[Index] = aSeq;
320cdf0e10cSrcweir else
321cdf0e10cSrcweir throw IndexOutOfBoundsException( ::rtl::OUString(), (OWeakObject *)this );
322cdf0e10cSrcweir }
323cdf0e10cSrcweir else
324cdf0e10cSrcweir throw IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( WRONG_TYPE_EXCEPTION )),
325cdf0e10cSrcweir (OWeakObject *)this, 2 );
326cdf0e10cSrcweir }
327cdf0e10cSrcweir
createInstanceWithContext(const Reference<XComponentContext> &)328cdf0e10cSrcweir Reference< XInterface > SAL_CALL RootItemContainer::createInstanceWithContext( const Reference< XComponentContext >& )
329cdf0e10cSrcweir throw ( Exception, RuntimeException)
330cdf0e10cSrcweir {
331cdf0e10cSrcweir return (OWeakObject *)(new ItemContainer( m_aShareMutex ));
332cdf0e10cSrcweir }
333cdf0e10cSrcweir
createInstanceWithArgumentsAndContext(const Sequence<Any> &,const Reference<XComponentContext> &)334cdf0e10cSrcweir Reference< XInterface > SAL_CALL RootItemContainer::createInstanceWithArgumentsAndContext( const Sequence< Any >&, const Reference< XComponentContext >& )
335cdf0e10cSrcweir throw (Exception, RuntimeException)
336cdf0e10cSrcweir {
337cdf0e10cSrcweir return (OWeakObject *)(new ItemContainer( m_aShareMutex ));
338cdf0e10cSrcweir }
339cdf0e10cSrcweir
340cdf0e10cSrcweir // XPropertySet helper
convertFastPropertyValue(Any & aConvertedValue,Any & aOldValue,sal_Int32 nHandle,const Any & aValue)341cdf0e10cSrcweir sal_Bool SAL_CALL RootItemContainer::convertFastPropertyValue( Any& aConvertedValue ,
342cdf0e10cSrcweir Any& aOldValue ,
343cdf0e10cSrcweir sal_Int32 nHandle ,
344cdf0e10cSrcweir const Any& aValue )
345cdf0e10cSrcweir throw( com::sun::star::lang::IllegalArgumentException )
346cdf0e10cSrcweir {
347cdf0e10cSrcweir // Initialize state with sal_False !!!
348cdf0e10cSrcweir // (Handle can be invalid)
349cdf0e10cSrcweir sal_Bool bReturn = sal_False;
350cdf0e10cSrcweir
351cdf0e10cSrcweir switch( nHandle )
352cdf0e10cSrcweir {
353cdf0e10cSrcweir case PROPHANDLE_UINAME:
354cdf0e10cSrcweir bReturn = PropHelper::willPropertyBeChanged(
355cdf0e10cSrcweir com::sun::star::uno::makeAny(m_aUIName),
356cdf0e10cSrcweir aValue,
357cdf0e10cSrcweir aOldValue,
358cdf0e10cSrcweir aConvertedValue);
359cdf0e10cSrcweir break;
360cdf0e10cSrcweir }
361cdf0e10cSrcweir
362cdf0e10cSrcweir // Return state of operation.
363cdf0e10cSrcweir return bReturn ;
364cdf0e10cSrcweir }
365cdf0e10cSrcweir
setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const com::sun::star::uno::Any & aValue)366cdf0e10cSrcweir void SAL_CALL RootItemContainer::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle ,
367cdf0e10cSrcweir const com::sun::star::uno::Any& aValue )
368cdf0e10cSrcweir throw( com::sun::star::uno::Exception )
369cdf0e10cSrcweir {
370cdf0e10cSrcweir switch( nHandle )
371cdf0e10cSrcweir {
372cdf0e10cSrcweir case PROPHANDLE_UINAME:
373cdf0e10cSrcweir aValue >>= m_aUIName;
374cdf0e10cSrcweir break;
375cdf0e10cSrcweir }
376cdf0e10cSrcweir }
377cdf0e10cSrcweir
getFastPropertyValue(com::sun::star::uno::Any & aValue,sal_Int32 nHandle) const378cdf0e10cSrcweir void SAL_CALL RootItemContainer::getFastPropertyValue( com::sun::star::uno::Any& aValue ,
379cdf0e10cSrcweir sal_Int32 nHandle ) const
380cdf0e10cSrcweir {
381cdf0e10cSrcweir switch( nHandle )
382cdf0e10cSrcweir {
383cdf0e10cSrcweir case PROPHANDLE_UINAME:
384cdf0e10cSrcweir aValue <<= m_aUIName;
385cdf0e10cSrcweir break;
386cdf0e10cSrcweir }
387cdf0e10cSrcweir }
388cdf0e10cSrcweir
getInfoHelper()389cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& SAL_CALL RootItemContainer::getInfoHelper()
390cdf0e10cSrcweir {
391cdf0e10cSrcweir // Optimize this method !
392cdf0e10cSrcweir // We initialize a static variable only one time. And we don't must use a mutex at every call!
393cdf0e10cSrcweir // For the first call; pInfoHelper is NULL - for the second call pInfoHelper is different from NULL!
394cdf0e10cSrcweir static ::cppu::OPropertyArrayHelper* pInfoHelper = NULL;
395cdf0e10cSrcweir
396cdf0e10cSrcweir if( pInfoHelper == NULL )
397cdf0e10cSrcweir {
398cdf0e10cSrcweir // Ready for multithreading
399cdf0e10cSrcweir osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
400cdf0e10cSrcweir
401cdf0e10cSrcweir // Control this pointer again, another instance can be faster then these!
402cdf0e10cSrcweir if( pInfoHelper == NULL )
403cdf0e10cSrcweir {
404cdf0e10cSrcweir // Define static member to give structure of properties to baseclass "OPropertySetHelper".
405cdf0e10cSrcweir // "impl_getStaticPropertyDescriptor" is a non exported and static funtion, who will define a static propertytable.
406cdf0e10cSrcweir // "sal_True" say: Table is sorted by name.
407cdf0e10cSrcweir static ::cppu::OPropertyArrayHelper aInfoHelper( impl_getStaticPropertyDescriptor(), sal_True );
408cdf0e10cSrcweir pInfoHelper = &aInfoHelper;
409cdf0e10cSrcweir }
410cdf0e10cSrcweir }
411cdf0e10cSrcweir
412cdf0e10cSrcweir return(*pInfoHelper);
413cdf0e10cSrcweir }
414cdf0e10cSrcweir
getPropertySetInfo()415cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo > SAL_CALL RootItemContainer::getPropertySetInfo()
416cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
417cdf0e10cSrcweir {
418cdf0e10cSrcweir // Optimize this method !
419cdf0e10cSrcweir // We initialize a static variable only one time. And we don't must use a mutex at every call!
420cdf0e10cSrcweir // For the first call; pInfo is NULL - for the second call pInfo is different from NULL!
421cdf0e10cSrcweir static com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo >* pInfo = NULL;
422cdf0e10cSrcweir
423cdf0e10cSrcweir if( pInfo == NULL )
424cdf0e10cSrcweir {
425cdf0e10cSrcweir // Ready for multithreading
426cdf0e10cSrcweir osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
427cdf0e10cSrcweir // Control this pointer again, another instance can be faster then these!
428cdf0e10cSrcweir if( pInfo == NULL )
429cdf0e10cSrcweir {
430cdf0e10cSrcweir // Create structure of propertysetinfo for baseclass "OPropertySetHelper".
431cdf0e10cSrcweir // (Use method "getInfoHelper()".)
432cdf0e10cSrcweir static com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
433cdf0e10cSrcweir pInfo = &xInfo;
434cdf0e10cSrcweir }
435cdf0e10cSrcweir }
436cdf0e10cSrcweir
437cdf0e10cSrcweir return (*pInfo);
438cdf0e10cSrcweir }
439cdf0e10cSrcweir
impl_getStaticPropertyDescriptor()440cdf0e10cSrcweir const com::sun::star::uno::Sequence< com::sun::star::beans::Property > RootItemContainer::impl_getStaticPropertyDescriptor()
441cdf0e10cSrcweir {
442cdf0e10cSrcweir // Create a new static property array to initialize sequence!
443cdf0e10cSrcweir // Table of all predefined properties of this class. Its used from OPropertySetHelper-class!
444cdf0e10cSrcweir // Don't forget to change the defines (see begin of this file), if you add, change or delete a property in this list!!!
445cdf0e10cSrcweir // It's necessary for methods of OPropertySetHelper.
446cdf0e10cSrcweir // ATTENTION:
447cdf0e10cSrcweir // YOU MUST SORT FOLLOW TABLE BY NAME ALPHABETICAL !!!
448cdf0e10cSrcweir
449cdf0e10cSrcweir static const com::sun::star::beans::Property pProperties[] =
450cdf0e10cSrcweir {
451cdf0e10cSrcweir com::sun::star::beans::Property( PROPNAME_UINAME, PROPHANDLE_UINAME ,
452cdf0e10cSrcweir ::getCppuType((const rtl::OUString*)NULL),
453cdf0e10cSrcweir com::sun::star::beans::PropertyAttribute::TRANSIENT )
454cdf0e10cSrcweir };
455cdf0e10cSrcweir // Use it to initialize sequence!
456cdf0e10cSrcweir static const com::sun::star::uno::Sequence< com::sun::star::beans::Property > lPropertyDescriptor( pProperties, PROPCOUNT );
457cdf0e10cSrcweir // Return static "PropertyDescriptor"
458cdf0e10cSrcweir return lPropertyDescriptor;
459cdf0e10cSrcweir }
460cdf0e10cSrcweir
461cdf0e10cSrcweir } // namespace framework
462cdf0e10cSrcweir
463