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_SERVICES_TABWINDOWSERVICE_HXX_
25 #define __FRAMEWORK_SERVICES_TABWINDOWSERVICE_HXX_
26 
27 /** Attention: stl headers must(!) be included at first. Otherwise it can make trouble
28                with solaris headers ...
29 */
30 #include <vector>
31 
32 //_________________________________________________________________________________________________________________
33 //	my own includes
34 //_________________________________________________________________________________________________________________
35 
36 #include <classes/fwktabwindow.hxx>
37 #include <classes/propertysethelper.hxx>
38 #include <threadhelp/threadhelpbase.hxx>
39 #include <macros/generic.hxx>
40 #include <macros/debug.hxx>
41 #include <macros/xinterface.hxx>
42 #include <macros/xtypeprovider.hxx>
43 #include <macros/xserviceinfo.hxx>
44 #include <general.h>
45 #include <stdtypes.h>
46 
47 //_________________________________________________________________________________________________________________
48 //	interface includes
49 //_________________________________________________________________________________________________________________
50 
51 #include <com/sun/star/awt/XSimpleTabController.hpp>
52 #include <com/sun/star/awt/XWindow.hpp>
53 #include <com/sun/star/beans/XPropertySet.hpp>
54 
55 //_________________________________________________________________________________________________________________
56 //	other includes
57 //_________________________________________________________________________________________________________________
58 
59 #include <cppuhelper/weak.hxx>
60 #include <vcl/window.hxx>
61 
62 //_________________________________________________________________________________________________________________
63 //	namespace
64 //_________________________________________________________________________________________________________________
65 
66 namespace framework{
67 
68 //_________________________________________________________________________________________________________________
69 //	exported const
70 //_________________________________________________________________________________________________________________
71 
72 //_________________________________________________________________________________________________________________
73 //	exported definitions
74 //_________________________________________________________________________________________________________________
75 
76 struct TTabPageInfo
77 {
78     public:
79 
TTabPageInfoframework::TTabPageInfo80         TTabPageInfo()
81             : m_nIndex      ( -1      )
82             , m_bCreated    (sal_False)
83             , m_pPage       ( NULL    )
84             , m_lProperties (         )
85         {}
86 
TTabPageInfoframework::TTabPageInfo87         TTabPageInfo(::sal_Int32 nID)
88             : m_nIndex      ( nID     )
89             , m_bCreated    (sal_False)
90             , m_pPage       ( NULL    )
91             , m_lProperties (         )
92         {}
93 
94     public:
95 
96         ::sal_Int32                                   m_nIndex;
97         ::sal_Bool                                    m_bCreated;
98         FwkTabPage*                                   m_pPage;
99         css::uno::Sequence< css::beans::NamedValue >  m_lProperties;
100 };
101 
102 typedef ::std::hash_map< ::sal_Int32                    ,
103                          TTabPageInfo                   ,
104                          Int32HashCode                  ,
105                          ::std::equal_to< ::sal_Int32 > > TTabPageInfoHash;
106 
107 /*-************************************************************************************************************//**
108 	@short  implements a helper service providing a dockable tab control window
109 *//*-*************************************************************************************************************/
110 
111 class TabWindowService :  public css::lang::XTypeProvider
112                          ,  public css::lang::XServiceInfo
113                          ,  public css::awt::XSimpleTabController
114                          ,  public css::lang::XComponent
115                          ,  public ThreadHelpBase
116                          ,  public TransactionBase
117                          ,  public PropertySetHelper
118 						 ,  public ::cppu::OWeakObject
119 {
120 	//-------------------------------------------------------------------------------------------------------------
121 	//	public methods
122 	//-------------------------------------------------------------------------------------------------------------
123 
124 	public:
125 
126 		//---------------------------------------------------------------------------------------------------------
127 		//	constructor / destructor
128 		//---------------------------------------------------------------------------------------------------------
129 
130         TabWindowService( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory );
131         virtual ~TabWindowService();
132 
133 		//---------------------------------------------------------------------------------------------------------
134 		//	XInterface, XTypeProvider, XServiceInfo
135 		//---------------------------------------------------------------------------------------------------------
136 
137 		FWK_DECLARE_XINTERFACE
138 		FWK_DECLARE_XTYPEPROVIDER
139 		DECLARE_XSERVICEINFO
140 
141 		//---------------------------------------------------------------------------------------------------------
142         //  XSimpleTabController
143 		//---------------------------------------------------------------------------------------------------------
144 
145         virtual sal_Int32 SAL_CALL insertTab() throw ( css::uno::RuntimeException );
146         virtual void SAL_CALL removeTab( sal_Int32 nID ) throw ( css::lang::IndexOutOfBoundsException, css::uno::RuntimeException );
147         virtual void SAL_CALL setTabProps( sal_Int32 nID, const css::uno::Sequence< css::beans::NamedValue >& aProperties ) throw ( css::lang::IndexOutOfBoundsException, css::uno::RuntimeException );
148         virtual css::uno::Sequence< css::beans::NamedValue > SAL_CALL getTabProps( sal_Int32 nID ) throw ( css::lang::IndexOutOfBoundsException, css::uno::RuntimeException );
149         virtual void SAL_CALL activateTab( sal_Int32 nID ) throw ( css::lang::IndexOutOfBoundsException, css::uno::RuntimeException );
150         virtual sal_Int32 SAL_CALL getActiveTabID() throw ( css::uno::RuntimeException );
151         virtual void SAL_CALL addTabListener( const css::uno::Reference< css::awt::XTabListener >& Listener ) throw ( css::uno::RuntimeException );
152         virtual void SAL_CALL removeTabListener( const css::uno::Reference< css::awt::XTabListener >& Listener ) throw ( css::uno::RuntimeException );
153 
154         //---------------------------------------------------------------------------------------------------------
155         //  XComponent
156         //---------------------------------------------------------------------------------------------------------
157 
158         virtual void SAL_CALL dispose() throw ( css::uno::RuntimeException );
159         virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) throw ( css::uno::RuntimeException );
160         virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) throw ( css::uno::RuntimeException );
161 
162     //-------------------------------------------------------------------------------------------------------------
163 	//	protected methods
164 	//-------------------------------------------------------------------------------------------------------------
165 
166 	protected:
167 
168 	//-------------------------------------------------------------------------------------------------------------
169 	//	private methods
170 	//-------------------------------------------------------------------------------------------------------------
171 
172 	private:
173 
174         void impl_initializePropInfo();
175         virtual void SAL_CALL impl_setPropertyValue(const ::rtl::OUString& sProperty,
176                                                           sal_Int32        nHandle  ,
177                                                     const css::uno::Any&   aValue   );
178         virtual css::uno::Any SAL_CALL impl_getPropertyValue(const ::rtl::OUString& sProperty,
179                                                                    sal_Int32        nHandle  );
180 
181         DECL_DLLPRIVATE_LINK( EventListener, VclSimpleEvent * );
182 
183         void impl_checkTabIndex (::sal_Int32 nID) throw (css::lang::IndexOutOfBoundsException);
184         TTabPageInfoHash::iterator impl_getTabPageInfo(::sal_Int32 nID) throw (css::lang::IndexOutOfBoundsException);
185         FwkTabWindow* mem_TabWin ();
186 /*
187         ::cppu::IPropertyArrayHelper& SAL_CALL              getInfoHelper();
188         const css::uno::Sequence< css::beans::Property >    impl_getStaticPropertyDescriptor();
189         static css::uno::Reference < css::beans::XPropertySetInfo > SAL_CALL
190                                                             createPropertySetInfo( ::cppu::IPropertyArrayHelper& rProperties ) SAL_THROW( () );
191 */
192 	//-------------------------------------------------------------------------------------------------------------
193 	//	variables
194 	//	(should be private everyway!)
195 	//-------------------------------------------------------------------------------------------------------------
196 
197 	private:
198 
199         /// reference to factory, which has created this instance
200         css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory;
201 
202         /// the tab window as XWindow ( to hold window* alive !)
203         css::uno::Reference< css::awt::XWindow > m_xTabWin;
204 
205         /// the VCL tab window
206         FwkTabWindow* m_pTabWin;
207 
208         /// container of inserted tab pages
209         TTabPageInfoHash m_lTabPageInfos;
210 
211         /// container of the added TabListener
212         ::cppu::OMultiTypeInterfaceContainerHelper m_lListener;
213 
214         /// counter of the tabpage indexes
215         ::sal_Int32 m_nPageIndexCounter;
216 
217         /// index of the current active page
218         ::sal_Int32 m_nCurrentPageIndex;
219 
220         /// title of the tabcontrolled window
221         ::rtl::OUString m_sTitle;
222 
223 };      //  class TabWindowService
224 
225 }		//	namespace framework
226 
227 #endif  //  #ifndef __FRAMEWORK_SERVICES_TABWINDOWSERVICE_HXX_
228 
229