Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef __FRAMEWORK_SERVICES_TABWINDOWSERVICE_HXX_
30 : : #define __FRAMEWORK_SERVICES_TABWINDOWSERVICE_HXX_
31 : :
32 : : /** Attention: stl headers must(!) be included at first. Otherwhise it can make trouble
33 : : with solaris headers ...
34 : : */
35 : : #include <vector>
36 : :
37 : : #include <classes/fwktabwindow.hxx>
38 : : #include <classes/propertysethelper.hxx>
39 : : #include <threadhelp/threadhelpbase.hxx>
40 : : #include <macros/generic.hxx>
41 : : #include <macros/debug.hxx>
42 : : #include <macros/xinterface.hxx>
43 : : #include <macros/xtypeprovider.hxx>
44 : : #include <macros/xserviceinfo.hxx>
45 : : #include <general.h>
46 : : #include <stdtypes.h>
47 : :
48 : : #include <com/sun/star/awt/XSimpleTabController.hpp>
49 : : #include <com/sun/star/awt/XWindow.hpp>
50 : : #include <com/sun/star/beans/XPropertySet.hpp>
51 : :
52 : : #include <cppuhelper/weak.hxx>
53 : : #include <vcl/window.hxx>
54 : :
55 : : namespace framework{
56 : :
57 : 0 : struct TTabPageInfo
58 : : {
59 : : public:
60 : :
61 : 0 : TTabPageInfo()
62 : : : m_nIndex ( -1 )
63 : : , m_bCreated (sal_False)
64 : : , m_pPage ( NULL )
65 : 0 : , m_lProperties ( )
66 : 0 : {}
67 : :
68 : 0 : TTabPageInfo(::sal_Int32 nID)
69 : : : m_nIndex ( nID )
70 : : , m_bCreated (sal_False)
71 : : , m_pPage ( NULL )
72 : 0 : , m_lProperties ( )
73 : 0 : {}
74 : :
75 : : public:
76 : :
77 : : ::sal_Int32 m_nIndex;
78 : : ::sal_Bool m_bCreated;
79 : : FwkTabPage* m_pPage;
80 : : css::uno::Sequence< css::beans::NamedValue > m_lProperties;
81 : : };
82 : :
83 : : typedef ::boost::unordered_map< ::sal_Int32 ,
84 : : TTabPageInfo ,
85 : : Int32HashCode ,
86 : : ::std::equal_to< ::sal_Int32 > > TTabPageInfoHash;
87 : :
88 : : /*-************************************************************************************************************//**
89 : : @short implements a helper service providing a dockable tab control window
90 : : *//*-*************************************************************************************************************/
91 : :
92 : : class TabWindowService : public css::lang::XTypeProvider
93 : : , public css::lang::XServiceInfo
94 : : , public css::awt::XSimpleTabController
95 : : , public css::lang::XComponent
96 : : , public ThreadHelpBase
97 : : , public TransactionBase
98 : : , public PropertySetHelper
99 : : , public ::cppu::OWeakObject
100 : : {
101 : : //-------------------------------------------------------------------------------------------------------------
102 : : // public methods
103 : : //-------------------------------------------------------------------------------------------------------------
104 : :
105 : : public:
106 : :
107 : : //---------------------------------------------------------------------------------------------------------
108 : : // constructor / destructor
109 : : //---------------------------------------------------------------------------------------------------------
110 : :
111 : : TabWindowService( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory );
112 : : virtual ~TabWindowService();
113 : :
114 : : //---------------------------------------------------------------------------------------------------------
115 : : // XInterface, XTypeProvider, XServiceInfo
116 : : //---------------------------------------------------------------------------------------------------------
117 : :
118 : : FWK_DECLARE_XINTERFACE
119 : : FWK_DECLARE_XTYPEPROVIDER
120 : : DECLARE_XSERVICEINFO
121 : :
122 : : //---------------------------------------------------------------------------------------------------------
123 : : // XSimpleTabController
124 : : //---------------------------------------------------------------------------------------------------------
125 : :
126 : : virtual sal_Int32 SAL_CALL insertTab() throw ( css::uno::RuntimeException );
127 : : virtual void SAL_CALL removeTab( sal_Int32 nID ) throw ( css::lang::IndexOutOfBoundsException, css::uno::RuntimeException );
128 : : virtual void SAL_CALL setTabProps( sal_Int32 nID, const css::uno::Sequence< css::beans::NamedValue >& aProperties ) throw ( css::lang::IndexOutOfBoundsException, css::uno::RuntimeException );
129 : : virtual css::uno::Sequence< css::beans::NamedValue > SAL_CALL getTabProps( sal_Int32 nID ) throw ( css::lang::IndexOutOfBoundsException, css::uno::RuntimeException );
130 : : virtual void SAL_CALL activateTab( sal_Int32 nID ) throw ( css::lang::IndexOutOfBoundsException, css::uno::RuntimeException );
131 : : virtual sal_Int32 SAL_CALL getActiveTabID() throw ( css::uno::RuntimeException );
132 : : virtual void SAL_CALL addTabListener( const css::uno::Reference< css::awt::XTabListener >& Listener ) throw ( css::uno::RuntimeException );
133 : : virtual void SAL_CALL removeTabListener( const css::uno::Reference< css::awt::XTabListener >& Listener ) throw ( css::uno::RuntimeException );
134 : :
135 : : //---------------------------------------------------------------------------------------------------------
136 : : // XComponent
137 : : //---------------------------------------------------------------------------------------------------------
138 : :
139 : : virtual void SAL_CALL dispose() throw ( css::uno::RuntimeException );
140 : : virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) throw ( css::uno::RuntimeException );
141 : : virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) throw ( css::uno::RuntimeException );
142 : :
143 : : //-------------------------------------------------------------------------------------------------------------
144 : : // protected methods
145 : : //-------------------------------------------------------------------------------------------------------------
146 : :
147 : : protected:
148 : :
149 : : //-------------------------------------------------------------------------------------------------------------
150 : : // private methods
151 : : //-------------------------------------------------------------------------------------------------------------
152 : :
153 : : private:
154 : :
155 : : void impl_initializePropInfo();
156 : : virtual void SAL_CALL impl_setPropertyValue(const ::rtl::OUString& sProperty,
157 : : sal_Int32 nHandle ,
158 : : const css::uno::Any& aValue );
159 : : virtual css::uno::Any SAL_CALL impl_getPropertyValue(const ::rtl::OUString& sProperty,
160 : : sal_Int32 nHandle );
161 : :
162 : : DECL_DLLPRIVATE_LINK( EventListener, VclSimpleEvent * );
163 : :
164 : : void impl_checkTabIndex (::sal_Int32 nID) throw (css::lang::IndexOutOfBoundsException);
165 : : TTabPageInfoHash::iterator impl_getTabPageInfo(::sal_Int32 nID) throw (css::lang::IndexOutOfBoundsException);
166 : : FwkTabWindow* mem_TabWin ();
167 : : //-------------------------------------------------------------------------------------------------------------
168 : : // variables
169 : : // (should be private everyway!)
170 : : //-------------------------------------------------------------------------------------------------------------
171 : :
172 : : private:
173 : :
174 : : /// reference to factory, which has created this instance
175 : : css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory;
176 : :
177 : : /// the tab window as XWindow ( to hold window* alive !)
178 : : css::uno::Reference< css::awt::XWindow > m_xTabWin;
179 : :
180 : : /// the VCL tab window
181 : : FwkTabWindow* m_pTabWin;
182 : :
183 : : /// container of inserted tab pages
184 : : TTabPageInfoHash m_lTabPageInfos;
185 : :
186 : : /// container of the added TabListener
187 : : ::cppu::OMultiTypeInterfaceContainerHelper m_lListener;
188 : :
189 : : /// counter of the tabpage indexes
190 : : ::sal_Int32 m_nPageIndexCounter;
191 : :
192 : : /// index of the current active page
193 : : ::sal_Int32 m_nCurrentPageIndex;
194 : :
195 : : /// title of the tabcontrolled window
196 : : ::rtl::OUString m_sTitle;
197 : :
198 : : }; // class TabWindowService
199 : :
200 : : } // namespace framework
201 : :
202 : : #endif // #ifndef __FRAMEWORK_SERVICES_TABWINDOWSERVICE_HXX_
203 : :
204 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|