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