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_ROOTITEMCONTAINER_HXX_
29 #define __FRAMEWORK_UIELEMENT_ROOTITEMCONTAINER_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/container/XIndexAccess.hpp>
46 #include <com/sun/star/lang/XSingleComponentFactory.hpp>
47 #include <com/sun/star/beans/PropertyValue.hpp>
48 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
49 #include <com/sun/star/lang/XUnoTunnel.hpp>
50 
51 //_________________________________________________________________________________________________________________
52 //	other includes
53 //_________________________________________________________________________________________________________________
54 #include <rtl/ustring.hxx>
55 #include <cppuhelper/weak.hxx>
56 #include <cppuhelper/propshlp.hxx>
57 #include <cppuhelper/interfacecontainer.hxx>
58 
59 #include <vector>
60 #include <fwidllapi.h>
61 
62 namespace framework
63 {
64 class ConstItemContainer;
65 class RootItemContainer : public ::com::sun::star::lang::XTypeProvider            ,
66                             public ::com::sun::star::container::XIndexContainer	    ,
67                             public ::com::sun::star::lang::XSingleComponentFactory  ,
68                             public ::com::sun::star::lang::XUnoTunnel               ,
69                             protected ThreadHelpBase                                ,
70                             public ::cppu::OBroadcastHelper                         ,
71                             public ::cppu::OPropertySetHelper                       ,
72                             public ::cppu::OWeakObject
73 {
74     friend class ConstItemContainer;
75 
76     public:
77         FWI_DLLPUBLIC RootItemContainer();
78         FWI_DLLPUBLIC RootItemContainer( const ConstItemContainer& rConstItemContainer );
79         FWI_DLLPUBLIC RootItemContainer( const com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess >& rItemAccessContainer );
80         virtual FWI_DLLPUBLIC ~RootItemContainer();
81 
82 		//---------------------------------------------------------------------------------------------------------
83 		//	XInterface, XTypeProvider
84 		//---------------------------------------------------------------------------------------------------------
85         FWK_DECLARE_XINTERFACE
86         FWK_DECLARE_XTYPEPROVIDER
87 
88 	    // XUnoTunnel
89         static FWI_DLLPUBLIC const ::com::sun::star::uno::Sequence< sal_Int8 >&   GetUnoTunnelId() throw();
90         static FWI_DLLPUBLIC RootItemContainer*                                   GetImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxIFace ) throw();
91 	    sal_Int64													SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier ) throw(::com::sun::star::uno::RuntimeException);
92 
93         // XIndexContainer
94 		virtual void SAL_CALL insertByIndex( sal_Int32 Index, const ::com::sun::star::uno::Any& Element )
95 			throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
96 
97 		virtual void SAL_CALL removeByIndex( sal_Int32 Index )
98 			throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
99 
100 		// XIndexReplace
101 		virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const ::com::sun::star::uno::Any& Element )
102 			throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
103 
104 		// XIndexAccess
105 		virtual sal_Int32 SAL_CALL getCount()
106 			throw (::com::sun::star::uno::RuntimeException);
107 
108 		virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index )
109 			throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
110 
111 		// XElementAccess
112 		virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
113 			throw (::com::sun::star::uno::RuntimeException)
114 		{
115 			return ::getCppuType((com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >*)0);
116 		}
117 
118 		virtual sal_Bool SAL_CALL hasElements()
119 			throw (::com::sun::star::uno::RuntimeException);
120 
121         // XSingleComponentFactory
122         virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithContext( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& Context ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
123         virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArgumentsAndContext( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Arguments, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& Context ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
124 
125     protected:
126 		//	OPropertySetHelper
127         virtual sal_Bool                                            SAL_CALL convertFastPropertyValue        ( com::sun::star::uno::Any&        aConvertedValue ,
128                                                                                                                com::sun::star::uno::Any&        aOldValue       ,
129                                                                                                                sal_Int32                        nHandle         ,
130                                                                                                                const com::sun::star::uno::Any&  aValue          ) throw( com::sun::star::lang::IllegalArgumentException );
131         virtual void                                                SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32                        nHandle         ,
132                                                                                                                const com::sun::star::uno::Any&  aValue          ) throw( com::sun::star::uno::Exception                 );
133         using cppu::OPropertySetHelper::getFastPropertyValue;
134         virtual void                                                SAL_CALL getFastPropertyValue( com::sun::star::uno::Any&    aValue          ,
135                                                                                                    sal_Int32                    nHandle         ) const;
136         virtual ::cppu::IPropertyArrayHelper&                       SAL_CALL getInfoHelper();
137         virtual ::com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() throw (::com::sun::star::uno::RuntimeException);
138 
139         static const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > impl_getStaticPropertyDescriptor();
140 
141     private:
142         RootItemContainer& operator=( const RootItemContainer& );
143         RootItemContainer( const RootItemContainer& );
144 
145         void copyItemContainer( const std::vector< com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > >& rSourceVector );
146         com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess > deepCopyContainer( const com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess >& rSubContainer );
147 
148         mutable ShareableMutex                                                                  m_aShareMutex;
149         std::vector< com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > >    m_aItemVector;
150         rtl::OUString                                                                           m_aUIName;
151 };
152 
153 }
154 
155 #endif // #ifndef __FRAMEWORK_UIELEMENT_ROOTITEMCONTAINER_HXX_
156