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