1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef __FRAMEWORK_UIELEMENT_ITEMCONTAINER_HXX_
29 #define __FRAMEWORK_UIELEMENT_ITEMCONTAINER_HXX_
30 
31 //_________________________________________________________________________________________________________________
32 //	my own includes
33 //_________________________________________________________________________________________________________________
34 
35 #include <threadhelp/threadhelpbase.hxx>
36 #include <macros/generic.hxx>
37 #include <macros/xinterface.hxx>
38 #include <macros/xtypeprovider.hxx>
39 #include <helper/shareablemutex.hxx>
40 
41 //_________________________________________________________________________________________________________________
42 //	interface includes
43 //_________________________________________________________________________________________________________________
44 #include <com/sun/star/container/XIndexContainer.hpp>
45 #include <com/sun/star/beans/PropertyValue.hpp>
46 #include <com/sun/star/lang/XUnoTunnel.hpp>
47 
48 //_________________________________________________________________________________________________________________
49 //	other includes
50 //_________________________________________________________________________________________________________________
51 #include <rtl/ustring.hxx>
52 #include <cppuhelper/implbase1.hxx>
53 
54 #include <vector>
55 #include <fwidllapi.h>
56 
57 namespace framework
58 {
59 class ConstItemContainer;
60 class FWI_DLLPUBLIC ItemContainer :   public ::cppu::WeakImplHelper1< ::com::sun::star::container::XIndexContainer>
61 {
62     friend class ConstItemContainer;
63 
64     public:
65         ItemContainer( const ShareableMutex& );
66         ItemContainer( const ConstItemContainer& rConstItemContainer, const ShareableMutex& rMutex );
67         ItemContainer( const com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess >& rItemAccessContainer, const ShareableMutex& rMutex );
68         virtual ~ItemContainer();
69 
70         //---------------------------------------------------------------------------------------------------------
71         //	XInterface, XTypeProvider
72         //---------------------------------------------------------------------------------------------------------
73 	    // XUnoTunnel
74 	    static const ::com::sun::star::uno::Sequence< sal_Int8 >&	GetUnoTunnelId() throw();
75 	    static ItemContainer*								        GetImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxIFace ) throw();
76 	    sal_Int64													SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier ) throw(::com::sun::star::uno::RuntimeException);
77 
78         // XIndexContainer
79 		virtual void SAL_CALL insertByIndex( sal_Int32 Index, const ::com::sun::star::uno::Any& Element )
80 			throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
81 
82 		virtual void SAL_CALL removeByIndex( sal_Int32 Index )
83 			throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
84 
85 		// XIndexReplace
86 		virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const ::com::sun::star::uno::Any& Element )
87 			throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
88 
89 		// XIndexAccess
90 		virtual sal_Int32 SAL_CALL getCount()
91 			throw (::com::sun::star::uno::RuntimeException);
92 
93 		virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index )
94 			throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
95 
96 		// XElementAccess
97 		virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
98 			throw (::com::sun::star::uno::RuntimeException)
99 		{
100 			return ::getCppuType((com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >*)0);
101 		}
102 
103 		virtual sal_Bool SAL_CALL hasElements()
104 			throw (::com::sun::star::uno::RuntimeException);
105 
106     private:
107         ItemContainer();
108         void copyItemContainer( const std::vector< com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > >& rSourceVector, const ShareableMutex& rMutex );
109         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 );
110 
111         mutable ShareableMutex                                                               m_aShareMutex;
112         std::vector< com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > > m_aItemVector;
113 };
114 
115 }
116 
117 #endif // #ifndef __FRAMEWORK_UIELEMENT_ITEMCONTAINER_HXX_
118