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_TABPAGE_CONTAINER_HXX
25 #define TOOLKIT_TABPAGE_CONTAINER_HXX
26 
27 #include <com/sun/star/awt/tab/XTabPageContainer.hpp>
28 #include <com/sun/star/awt/tab/XTabPageContainerModel.hpp>
29 #include <com/sun/star/awt/tab/XTabPageContainerListener.hpp>
30 #include <com/sun/star/awt/tab/XTabPage.hpp>
31 #include <com/sun/star/awt/tab/XTabPageModel.hpp>
32 #include <toolkit/controls/unocontrolbase.hxx>
33 #include <toolkit/controls/unocontrolmodel.hxx>
34 #include <toolkit/helper/servicenames.hxx>
35 #include <cppuhelper/implbase1.hxx>
36 #include <comphelper/sequence.hxx>
37 #include <toolkit/controls/controlmodelcontainerbase.hxx>
38 #include <toolkit/controls/unocontrolmodel.hxx>
39 #include <toolkit/helper/listenermultiplexer.hxx>
40 
41 using namespace ::com::sun::star::uno;
42 //using namespace ::com::sun::star::awt;
43 using namespace ::com::sun::star::lang;
44 using namespace ::com::sun::star::beans;
45 using namespace ::com::sun::star::container;
46 
47 //	------------------------------------------------------------------
48 //	class ::com::sun::star::awt::tab::UnoControlTabPageContainerModel
49 //	------------------------------------------------------------------
50 typedef ::cppu::AggImplInheritanceHelper1   <   UnoControlModel
51                                             ,   ::com::sun::star::awt::tab::XTabPageContainerModel
52                                             >   UnoControlTabPageContainerModel_Base;
53 class UnoControlTabPageContainerModel : public UnoControlTabPageContainerModel_Base
54 {
55 private:
56 	std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::awt::tab::XTabPageModel > > m_aTabPageVector;
57     ContainerListenerMultiplexer		maContainerListeners;
58 protected:
59 	::com::sun::star::uno::Any 		ImplGetDefaultValue( sal_uInt16 nPropId ) const;
60 	::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
61 	// ::com::sun::star::beans::XMultiPropertySet
62 	::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
63 
64 public:
65 	UnoControlTabPageContainerModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory );
UnoControlTabPageContainerModel(const UnoControlTabPageContainerModel & rModel)66 	UnoControlTabPageContainerModel( const UnoControlTabPageContainerModel& rModel ) : UnoControlTabPageContainerModel_Base( rModel ),maContainerListeners( *this ) {;}
67 
Clone() const68 	UnoControlModel*	Clone() const { return new UnoControlTabPageContainerModel( *this ); }
69 
70 	// ::com::sun::star::io::XPersistObject
71     ::rtl::OUString SAL_CALL getServiceName() throw(::com::sun::star::uno::RuntimeException);
72 
73 	// ::com::sun::star::lang::XServiceInfo
74 	DECLIMPL_SERVICEINFO_DERIVED( UnoControlTabPageContainerModel, UnoControlModel, szServiceName_UnoControlTabPageContainerModel )
75 
76     // XTabPageContainerModel
77     virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::tab::XTabPageModel > SAL_CALL createTabPage( ::sal_Int16 TabPageID ) throw (::com::sun::star::uno::RuntimeException);
78     virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::tab::XTabPageModel > SAL_CALL loadTabPage( ::sal_Int16 TabPageID, const ::rtl::OUString& ResourceURL ) throw (::com::sun::star::uno::RuntimeException);
79 
80 	// XIndexContainer
81 	virtual void SAL_CALL insertByIndex( sal_Int32 Index, const ::com::sun::star::uno::Any& Element )
82  			throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
83 	virtual void SAL_CALL removeByIndex( sal_Int32 Index )
84  			throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
85 
86     // XIndexReplace
87  	virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const ::com::sun::star::uno::Any& Element )
88  			throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
89 
90  	// XIndexAccess
91  	virtual sal_Int32 SAL_CALL getCount() 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() throw (::com::sun::star::uno::RuntimeException);
98 	virtual sal_Bool SAL_CALL hasElements() throw (::com::sun::star::uno::RuntimeException);
99 
100 	// ::com::sun::star::container::XContainer
101     void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
102     void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
103 };
104 // ===================================================================
105 // = UnoControlTabPageContainer
106 // ===================================================================
107 typedef ::cppu::AggImplInheritanceHelper1   <   ControlContainerBase
108                                             ,   ::com::sun::star::awt::tab::XTabPageContainer
109                                             >   UnoControlTabPageContainer_Base;
110 class UnoControlTabPageContainer : public UnoControlTabPageContainer_Base
111 {
112 public:
113 	UnoControlTabPageContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory );
114 	::rtl::OUString				GetComponentServiceName();
115 
116 	// ::com::sun::star::lang::XComponent
117     void SAL_CALL dispose(  ) throw(::com::sun::star::uno::RuntimeException);
118 
119 	// ::com::sun::star::awt::XControl
120     void SAL_CALL createPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit >& Toolkit, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& Parent ) throw(::com::sun::star::uno::RuntimeException);
121 
122 	// ::com::sun::star::awt::tab::XTabPageContainer
123     virtual ::sal_Int16 SAL_CALL getActiveTabPageID() throw (::com::sun::star::uno::RuntimeException);
124     virtual void SAL_CALL setActiveTabPageID( ::sal_Int16 _activetabpageid ) throw (::com::sun::star::uno::RuntimeException);
125     virtual ::sal_Int16 SAL_CALL getTabPageCount(  ) throw (::com::sun::star::uno::RuntimeException);
126     virtual ::sal_Bool SAL_CALL isTabPageActive( ::sal_Int16 tabPageIndex ) throw (::com::sun::star::uno::RuntimeException);
127     virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::tab::XTabPage > SAL_CALL getTabPage( ::sal_Int16 tabPageIndex ) throw (::com::sun::star::uno::RuntimeException);
128     virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::tab::XTabPage > SAL_CALL getTabPageByID( ::sal_Int16 tabPageID ) throw (::com::sun::star::uno::RuntimeException);
129     virtual void SAL_CALL addTabPageContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tab::XTabPageContainerListener >& listener ) throw (::com::sun::star::uno::RuntimeException);
130     virtual void SAL_CALL removeTabPageContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tab::XTabPageContainerListener >& listener ) throw (::com::sun::star::uno::RuntimeException);
131 
132     virtual void SAL_CALL addControl( const ::rtl::OUString& Name, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& Control ) throw (::com::sun::star::uno::RuntimeException);
133 	// ::com::sun::star::lang::XServiceInfo
134 	DECLIMPL_SERVICEINFO_DERIVED( UnoControlTabPageContainer, UnoControlBase, szServiceName_UnoControlTabPageContainer )
135 
136 //	using UnoControl::getPeer;
137 protected:
138     virtual void        updateFromModel();
139 private:
140 	TabPageListenerMultiplexer 	m_aTabPageListeners;
141 	sal_Int16 m_nActiveTabPageId;
142 };
143 
144 #endif // _TOOLKIT_TABPAGE_CONTAINER_HXX
145