1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef __FRAMEWORK_UIELEMENT_ITEMCONTAINER_HXX_
25 #define __FRAMEWORK_UIELEMENT_ITEMCONTAINER_HXX_
26 
27 //_________________________________________________________________________________________________________________
28 //	my own includes
29 //_________________________________________________________________________________________________________________
30 
31 #include <threadhelp/threadhelpbase.hxx>
32 #include <macros/generic.hxx>
33 #include <macros/xinterface.hxx>
34 #include <macros/xtypeprovider.hxx>
35 #include <helper/shareablemutex.hxx>
36 
37 //_________________________________________________________________________________________________________________
38 //	interface includes
39 //_________________________________________________________________________________________________________________
40 #include <com/sun/star/container/XIndexContainer.hpp>
41 #include <com/sun/star/beans/PropertyValue.hpp>
42 #include <com/sun/star/lang/XUnoTunnel.hpp>
43 
44 //_________________________________________________________________________________________________________________
45 //	other includes
46 //_________________________________________________________________________________________________________________
47 #include <rtl/ustring.hxx>
48 #include <cppuhelper/implbase1.hxx>
49 
50 #include <vector>
51 #include <fwidllapi.h>
52 
53 namespace framework
54 {
55 class ConstItemContainer;
56 class FWI_DLLPUBLIC ItemContainer :   public ::cppu::WeakImplHelper1< ::com::sun::star::container::XIndexContainer>
57 {
58     friend class ConstItemContainer;
59 
60     public:
61         ItemContainer( const ShareableMutex& );
62         ItemContainer( const ConstItemContainer& rConstItemContainer, const ShareableMutex& rMutex );
63         ItemContainer( const com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess >& rItemAccessContainer, const ShareableMutex& rMutex );
64         virtual ~ItemContainer();
65 
66         //---------------------------------------------------------------------------------------------------------
67         //	XInterface, XTypeProvider
68         //---------------------------------------------------------------------------------------------------------
69 	    // XUnoTunnel
70 	    static const ::com::sun::star::uno::Sequence< sal_Int8 >&	GetUnoTunnelId() throw();
71 	    static ItemContainer*								        GetImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxIFace ) throw();
72 	    sal_Int64													SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier ) throw(::com::sun::star::uno::RuntimeException);
73 
74         // XIndexContainer
75 		virtual void SAL_CALL insertByIndex( sal_Int32 Index, const ::com::sun::star::uno::Any& Element )
76 			throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
77 
78 		virtual void SAL_CALL removeByIndex( sal_Int32 Index )
79 			throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
80 
81 		// XIndexReplace
82 		virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const ::com::sun::star::uno::Any& Element )
83 			throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
84 
85 		// XIndexAccess
86 		virtual sal_Int32 SAL_CALL getCount()
87 			throw (::com::sun::star::uno::RuntimeException);
88 
89 		virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index )
90 			throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
91 
92 		// XElementAccess
getElementType()93 		virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
94 			throw (::com::sun::star::uno::RuntimeException)
95 		{
96 			return ::getCppuType((com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >*)0);
97 		}
98 
99 		virtual sal_Bool SAL_CALL hasElements()
100 			throw (::com::sun::star::uno::RuntimeException);
101 
102     private:
103         ItemContainer();
104         void copyItemContainer( const std::vector< com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > >& rSourceVector, const ShareableMutex& rMutex );
105         com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess > deepCopyContainer( const com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess >& rSubContainer, const ShareableMutex& rMutex );
106 
107         mutable ShareableMutex                                                               m_aShareMutex;
108         std::vector< com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > > m_aItemVector;
109 };
110 
111 }
112 
113 #endif // #ifndef __FRAMEWORK_UIELEMENT_ITEMCONTAINER_HXX_
114