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