xref: /aoo42x/main/framework/inc/tabwin/tabwindow.hxx (revision 30acf5e8)
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_TABWIN_TABWINDOW_HXX_
25 #define __FRAMEWORK_TABWIN_TABWINDOW_HXX_
26 
27 //_________________________________________________________________________________________________________________
28 //	my own includes
29 //_________________________________________________________________________________________________________________
30 
31 #include <stdtypes.h>
32 #include <threadhelp/threadhelpbase.hxx>
33 #include <macros/generic.hxx>
34 #include <macros/xinterface.hxx>
35 #include <macros/xtypeprovider.hxx>
36 #include <macros/xserviceinfo.hxx>
37 #include <services.h>
38 
39 //_________________________________________________________________________________________________________________
40 //	interface includes
41 //_________________________________________________________________________________________________________________
42 #include <com/sun/star/lang/XServiceInfo.hpp>
43 #include <com/sun/star/lang/XTypeProvider.hpp>
44 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
45 #include <com/sun/star/lang/XInitialization.hpp>
46 #include <com/sun/star/beans/PropertyValue.hpp>
47 #ifndef _COM_SUN_STAR_LANG_XWINDOW_HPP_
48 #include <com/sun/star/awt/XWindow.hpp>
49 #endif
50 #ifndef _COM_SUN_STAR_LANG_XTOPWINDOW_HPP_
51 #include <com/sun/star/awt/XTopWindow.hpp>
52 #endif
53 #include <com/sun/star/lang/XComponent.hpp>
54 #include <com/sun/star/awt/XSimpleTabController.hpp>
55 #include <com/sun/star/awt/XTabListener.hpp>
56 
57 //_________________________________________________________________________________________________________________
58 //	includes of other projects
59 //_________________________________________________________________________________________________________________
60 #include <cppuhelper/propshlp.hxx>
61 #include <cppuhelper/interfacecontainer.hxx>
62 #include <cppuhelper/weak.hxx>
63 #include <rtl/ustring.hxx>
64 #include <vcl/tabctrl.hxx>
65 
66 namespace framework
67 {
68 
69 class TabWindow :  public ::com::sun::star::lang::XTypeProvider		        ,
70                    public ::com::sun::star::lang::XServiceInfo		        ,
71 				   public ::com::sun::star::lang::XInitialization			,
72                    public ::com::sun::star::lang::XComponent                ,
73 				   public ::com::sun::star::awt::XWindowListener            ,
74                    public ::com::sun::star::awt::XTopWindowListener         ,
75                    public ::com::sun::star::awt::XSimpleTabController       ,
76                    protected ThreadHelpBase							        ,	// Struct for right initialization of mutex member! Must be first of baseclasses.
77                    public ::cppu::OBroadcastHelper							,
78                    public ::cppu::OPropertySetHelper						,   // => XPropertySet / XFastPropertySet / XMultiPropertySet
79                    public ::cppu::OWeakObject
80 {
81 	public:
82         TabWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager );
83 		virtual ~TabWindow();
84 
85         //  XInterface, XTypeProvider, XServiceInfo
86 		FWK_DECLARE_XINTERFACE
87 		DECLARE_XSERVICEINFO
88 		FWK_DECLARE_XTYPEPROVIDER
89 
90 	    using ::cppu::OPropertySetHelper::disposing;
91 	    using ::cppu::OPropertySetHelper::getFastPropertyValue;
92 
93 		//---------------------------------------------------------------------------------------------------------
94 	    //	XInitialization
95 	    //---------------------------------------------------------------------------------------------------------
96 		virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
97 
98         //---------------------------------------------------------------------------------------------------------
99 	    //	XComponent
100 	    //---------------------------------------------------------------------------------------------------------
101         virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);
102         virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
103         virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
104 
105         //---------------------------------------------------------------------------------------------------------
106 	    //	XSimpleTabController
107 	    //---------------------------------------------------------------------------------------------------------
108         virtual ::sal_Int32 SAL_CALL insertTab() throw (::com::sun::star::uno::RuntimeException);
109         virtual void SAL_CALL removeTab( ::sal_Int32 ID ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
110         virtual void SAL_CALL setTabProps( ::sal_Int32 ID, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& Properties ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
111         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > SAL_CALL getTabProps( ::sal_Int32 ID ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
112         virtual void SAL_CALL activateTab( ::sal_Int32 ID ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
113         virtual ::sal_Int32 SAL_CALL getActiveTabID(  ) throw (::com::sun::star::uno::RuntimeException);
114         virtual void SAL_CALL addTabListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
115         virtual void SAL_CALL removeTabListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
116 
117         //---------------------------------------------------------------------------------------------------------
118         //  XEventListener
119 		//---------------------------------------------------------------------------------------------------------
120 	    virtual void SAL_CALL disposing( const css::lang::EventObject& aEvent ) throw( css::uno::RuntimeException );
121 
122 		//---------------------------------------------------------------------------------------------------------
123 	    //	XTopWindowListener
124 	    //---------------------------------------------------------------------------------------------------------
125         virtual void SAL_CALL windowOpened( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
126         virtual void SAL_CALL windowClosing( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
127         virtual void SAL_CALL windowClosed( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
128         virtual void SAL_CALL windowMinimized( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
129         virtual void SAL_CALL windowNormalized( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
130         virtual void SAL_CALL windowActivated( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
131         virtual void SAL_CALL windowDeactivated( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
132 
133         //---------------------------------------------------------------------------------------------------------
134 	    //	XWindowListener
135 	    //---------------------------------------------------------------------------------------------------------
136     	virtual void SAL_CALL windowResized( const css::awt::WindowEvent& aEvent ) throw( css::uno::RuntimeException );
137     	virtual void SAL_CALL windowMoved( const css::awt::WindowEvent& aEvent ) throw( css::uno::RuntimeException );
138         virtual void SAL_CALL windowShown( const css::lang::EventObject& aEvent ) throw( css::uno::RuntimeException );
139         virtual void SAL_CALL windowHidden( const css::lang::EventObject& aEvent ) throw( css::uno::RuntimeException );
140 
141     protected:
142         DECL_LINK( Activate, TabControl* );
143         DECL_LINK( Deactivate, TabControl* );
144 
145     private:
146 		//---------------------------------------------------------------------------------------------------------
147 		//	OPropertySetHelper
148 		//---------------------------------------------------------------------------------------------------------
149         virtual sal_Bool                                            SAL_CALL convertFastPropertyValue( com::sun::star::uno::Any&        aConvertedValue ,
150                                                                                                        com::sun::star::uno::Any&        aOldValue       ,
151                                                                                                        sal_Int32                        nHandle         ,
152                                                                                                        const com::sun::star::uno::Any&  aValue          ) throw( com::sun::star::lang::IllegalArgumentException );
153         virtual void                                                SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32                        nHandle         ,
154                                                                                                                const com::sun::star::uno::Any&  aValue          ) throw( com::sun::star::uno::Exception                 );
155         virtual void                                                SAL_CALL getFastPropertyValue( com::sun::star::uno::Any&    aValue          ,
156                                                                                                    sal_Int32                    nHandle         ) const;
157         virtual ::cppu::IPropertyArrayHelper&                       SAL_CALL getInfoHelper();
158         virtual ::com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() throw (::com::sun::star::uno::RuntimeException);
159 
160         static const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > impl_getStaticPropertyDescriptor();
161 
162 	private:
163         enum Notification
164         {
165             NOTIFY_INSERTED,
166             NOTIFY_REMOVED,
167             NOTIFY_CHANGED,
168             NOTIFY_ACTIVATED,
169             NOTIFY_DEACTIVATED
170         };
171 
172         sal_Int32   impl_GetPageIdFromIndex( ::sal_Int32 nIndex ) const;
173         sal_Bool    impl_CheckIndex( ::sal_Int32 nIndex ) const;
174         void        implts_LayoutWindows() const;
175         void        impl_SetTitle( const ::rtl::OUString& rTitle );
176         TabControl* impl_GetTabControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& xTabControlWindow ) const;
177         void        implts_SendNotification( Notification eNotify, sal_Int32 ID ) const;
178         void        implts_SendNotification( Notification eNotify, sal_Int32 ID, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& rSeq ) const;
179 
180         typedef std::vector< sal_uInt16 > PageIdVector;
181 
182         sal_Bool																		 m_bInitialized : 1,
183                                                                                          m_bDisposed : 1;
184         sal_Int32                                                                        m_nNextTabID;
185         ::rtl::OUString                                                                  m_aTitlePropName;
186         ::rtl::OUString                                                                  m_aPosPropName;
187 		::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager;
188         ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTopWindow >            m_xTopWindow;
189 		::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >				 m_xContainerWindow;
190 		::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >				 m_xTabControlWindow;
191         ::cppu::OMultiTypeInterfaceContainerHelper                                       m_aListenerContainer; // container for ALL Listener
192 };
193 
194 }
195 
196 #endif // __FRAMEWORK_TABWIN_TABWINDOW_HXX_
197