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 TOOLKIT_ROADMAP_CONTROL_HXX
25 #define TOOLKIT_ROADMAP_CONTROL_HXX
26 
27 
28 #include <toolkit/controls/unocontrols.hxx>
29 #include <toolkit/controls/unocontrolmodel.hxx>
30 #include <toolkit/helper/servicenames.hxx>
31 #include <toolkit/controls/roadmapentry.hxx>
32 #include <com/sun/star/container/XContainer.hpp>
33 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
34 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
35 #include <com/sun/star/container/XIndexContainer.hpp>
36 #include <com/sun/star/container/XContainerListener.hpp>
37 #include <com/sun/star/awt/XItemListener.hpp>
38 #include <com/sun/star/awt/XItemEventBroadcaster.hpp>
39 #include <cppuhelper/implbase2.hxx>
40 #include <cppuhelper/implbase3.hxx>
41 #include <cppuhelper/implbase4.hxx>
42 
43 
44 #include <comphelper/uno3.hxx>
45 
46 //........................................................................
47 namespace toolkit
48 {
49 //........................................................................
50 
51     typedef GraphicControlModel	UnoControlRoadmapModel_Base;
52 
53 
54     typedef ::cppu::ImplHelper3	<	::com::sun::star::lang::XSingleServiceFactory
55 							    ,	::com::sun::star::container::XContainer
56 							    ,	::com::sun::star::container::XIndexContainer
57 							    >	UnoControlRoadmapModel_IBase;
58 
59 
60 
61     typedef UnoControlBase	UnoControlRoadmap_Base;
62     typedef ::cppu::ImplHelper4	<   ::com::sun::star::awt::XItemEventBroadcaster
63 							    ,   ::com::sun::star::container::XContainerListener
64 							    ,	::com::sun::star::awt::XItemListener
65                                 ,   ::com::sun::star::beans::XPropertyChangeListener
66 							    >	UnoControlRoadmap_IBase;
67 
68 
69 
70 
71     typedef ::cppu::ImplHelper2< ::com::sun::star::container::XContainerListener,
72                                  ::com::sun::star::awt::XItemEventBroadcaster>    SVTXRoadmap_Base;
73 
74 
75 	using namespace ::com::sun::star::uno;
76 	using namespace ::com::sun::star::awt;
77 	using namespace ::com::sun::star::lang;
78 	using namespace ::com::sun::star::beans;
79     using namespace ::com::sun::star::container;
80 
81 
82 	// ===================================================================
83 	// = UnoControlRoadmapModel
84 	// ===================================================================
85 	class UnoControlRoadmapModel : public UnoControlRoadmapModel_Base,
86                                    public UnoControlRoadmapModel_IBase
87 
88 	{
89     private:
90 //        PropertyChangeListenerMultiplexer 	            maPropertyListeners;
91 
92         typedef ::std::vector< Reference< XInterface > >	RoadmapItemHolderList;
93 
94         ContainerListenerMultiplexer		maContainerListeners;
95         RoadmapItemHolderList			    maRoadmapItems;
96 
97         void                                MakeRMItemValidation( sal_Int32 Index, Reference< XInterface > xRoadmapItem );
98         ContainerEvent                      GetContainerEvent(sal_Int32 Index, Reference< XInterface > );
99         void                                SetRMItemDefaultProperties( const sal_Int32 _Index, Reference< XInterface > );
100         sal_Int16                           GetCurrentItemID( Reference< XPropertySet > xPropertySet );
101         sal_Int32                           GetUniqueID();
102 
103 
104 	protected:
105 		::com::sun::star::uno::Any 		ImplGetDefaultValue( sal_uInt16 nPropId ) const;
106 		::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
107 
108 	public:
109 		UnoControlRoadmapModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory );
UnoControlRoadmapModel(const UnoControlRoadmapModel & rModel)110 		UnoControlRoadmapModel( const UnoControlRoadmapModel& rModel ) :
111             UnoControlRoadmapModel_Base( rModel ),
112             UnoControlRoadmapModel_IBase( rModel ),
113             maContainerListeners( *this ) {}
Clone() const114 		UnoControlModel*	Clone() const { return new UnoControlRoadmapModel( *this ); }
115 
116 
117 	// XTypeProvider
118 	DECLARE_XTYPEPROVIDER( )
119 
120 
121     // ::com::sun::star::io::XPersistObject
122 	::rtl::OUString SAL_CALL getServiceName() throw(::com::sun::star::uno::RuntimeException);
123 
124 	// ::com::sun::star::lang::XServiceInfo
125 	DECLIMPL_SERVICEINFO_DERIVED( UnoControlRoadmapModel, UnoControlRoadmapModel_Base, szServiceName2_UnoControlRoadmapModel )
126 
127 	sal_Int32 SAL_CALL getCount() throw (RuntimeException);
128     virtual Any SAL_CALL getByIndex( sal_Int32 Index ) throw (IndexOutOfBoundsException, WrappedTargetException, RuntimeException );
129 
130     virtual void SAL_CALL insertByIndex( sal_Int32 Index, const Any & _Element) throw	 (IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException );
131     virtual void SAL_CALL removeByIndex( sal_Int32 Index ) throw (IndexOutOfBoundsException, WrappedTargetException, RuntimeException );
132     virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const Any & _Element) throw (IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException );
133 
134     virtual void SAL_CALL addContainerListener( const Reference< XContainerListener >& xListener ) throw (RuntimeException);
135     virtual void SAL_CALL removeContainerListener( const Reference< XContainerListener >& xListener ) throw (RuntimeException);
136 
queryInterface(const::com::sun::star::uno::Type & rType)137 	::com::sun::star::uno::Any	SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) { return UnoControlRoadmapModel_Base::queryInterface(rType); }
138     ::com::sun::star::uno::Any	SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
acquire()139 	void						SAL_CALL acquire() throw()	{ UnoControlRoadmapModel_Base::acquire(); }
release()140 	void						SAL_CALL release() throw()	{ UnoControlRoadmapModel_Base::release(); }
141 
142 
143     // ::com::sun::star::beans::XPropertySet
144     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw (::com::sun::star::uno::RuntimeException);
145 
146 
147     virtual Reference< XInterface > SAL_CALL createInstance(  ) throw (Exception, RuntimeException);
148     virtual Reference< XInterface > SAL_CALL createInstanceWithArguments( const Sequence< Any >& aArguments ) throw (Exception, RuntimeException);
149 
150 	virtual Type SAL_CALL getElementType() throw (RuntimeException);
151 
152 	virtual sal_Bool SAL_CALL hasElements() throw (RuntimeException);
153 
154 	};
155 
156 
157 	// ===================================================================
158 	// = UnoRoadmapControl
159 	// ===================================================================
160 	class UnoRoadmapControl : public UnoControlRoadmap_Base,
161                               public UnoControlRoadmap_IBase
162     {
163     private:
164         ItemListenerMultiplexer 	            maItemListeners;
165 	public:
166 							UnoRoadmapControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory );
167 		::rtl::OUString		GetComponentServiceName();
168 
disposing(const::com::sun::star::lang::EventObject & Source)169     void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException) { UnoControlBase::disposing( Source ); }
170 
171     void SAL_CALL   dispose(  ) throw(::com::sun::star::uno::RuntimeException);
172 
173 
174     sal_Bool SAL_CALL setModel(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& Model) throw ( ::com::sun::star::uno::RuntimeException );
175 
176     void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& rEvent )throw(::com::sun::star::uno::RuntimeException);
177     void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& rEvent )throw(::com::sun::star::uno::RuntimeException);
178     void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& rEvent )throw(::com::sun::star::uno::RuntimeException);
179 
180     virtual void SAL_CALL addItemListener( const Reference< XItemListener >& l ) throw (RuntimeException);
181     virtual void SAL_CALL removeItemListener( const Reference< XItemListener >& l ) throw (RuntimeException);
182 
183 
184     virtual void SAL_CALL itemStateChanged( const ItemEvent& rEvent ) throw (RuntimeException);
185 
186     virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (::com::sun::star::uno::RuntimeException);
187 
188 	// XTypeProvider
189 	DECLARE_XTYPEPROVIDER( )
190     DECLARE_XINTERFACE()
191 
192 	// ::com::sun::star::lang::XServiceInfo
193 	DECLIMPL_SERVICEINFO_DERIVED( UnoRoadmapControl, UnoControlBase, szServiceName2_UnoControlRoadmap )
194 	};
195 
196 //........................................................................
197 } // toolkit
198 //........................................................................
199 
200 
201 
202 #endif // _TOOLKIT_ROADMAP_CONTROL_HXX
203