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 // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_framework.hxx" 30*cdf0e10cSrcweir #include <tabwin/tabwindow.hxx> 31*cdf0e10cSrcweir #include <properties.h> 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 34*cdf0e10cSrcweir // my own includes 35*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 36*cdf0e10cSrcweir #include <threadhelp/resetableguard.hxx> 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 39*cdf0e10cSrcweir // interface includes 40*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 41*cdf0e10cSrcweir #include <com/sun/star/util/XURLTransformer.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp> 43*cdf0e10cSrcweir #include <com/sun/star/awt/WindowDescriptor.hpp> 44*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp> 45*cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp> 46*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 47*cdf0e10cSrcweir // includes of other projects 48*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 49*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 50*cdf0e10cSrcweir #include <tools/urlobj.hxx> 51*cdf0e10cSrcweir #include <vcl/svapp.hxx> 52*cdf0e10cSrcweir #include <vcl/window.hxx> 53*cdf0e10cSrcweir #include <vcl/wrkwin.hxx> 54*cdf0e10cSrcweir #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ 55*cdf0e10cSrcweir #include <toolkit/unohlp.hxx> 56*cdf0e10cSrcweir #endif 57*cdf0e10cSrcweir #include <comphelper/sequenceashashmap.hxx> 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 60*cdf0e10cSrcweir // Defines 61*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 62*cdf0e10cSrcweir // 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir using namespace rtl; 65*cdf0e10cSrcweir using namespace com::sun::star; 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir namespace framework 68*cdf0e10cSrcweir { 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir //***************************************************************************************************************** 71*cdf0e10cSrcweir // XInterface, XTypeProvider, XServiceInfo 72*cdf0e10cSrcweir //***************************************************************************************************************** 73*cdf0e10cSrcweir DEFINE_XINTERFACE_11 ( TabWindow , 74*cdf0e10cSrcweir ::cppu::OWeakObject , 75*cdf0e10cSrcweir DIRECT_INTERFACE( css::lang::XTypeProvider ), 76*cdf0e10cSrcweir DIRECT_INTERFACE( css::lang::XServiceInfo ), 77*cdf0e10cSrcweir DIRECT_INTERFACE( css::lang::XInitialization ), 78*cdf0e10cSrcweir DIRECT_INTERFACE( css::lang::XComponent ), 79*cdf0e10cSrcweir DIRECT_INTERFACE( css::awt::XWindowListener ), 80*cdf0e10cSrcweir DIRECT_INTERFACE( css::awt::XTopWindowListener ), 81*cdf0e10cSrcweir DIRECT_INTERFACE( css::awt::XSimpleTabController ), 82*cdf0e10cSrcweir DERIVED_INTERFACE( css::lang::XEventListener, css::awt::XWindowListener ), 83*cdf0e10cSrcweir DIRECT_INTERFACE( css::beans::XMultiPropertySet ), 84*cdf0e10cSrcweir DIRECT_INTERFACE( css::beans::XFastPropertySet ), 85*cdf0e10cSrcweir DIRECT_INTERFACE( css::beans::XPropertySet ) 86*cdf0e10cSrcweir ) 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir DEFINE_XTYPEPROVIDER_11 ( TabWindow , 89*cdf0e10cSrcweir css::lang::XTypeProvider , 90*cdf0e10cSrcweir css::lang::XServiceInfo , 91*cdf0e10cSrcweir css::lang::XInitialization , 92*cdf0e10cSrcweir css::lang::XComponent , 93*cdf0e10cSrcweir css::awt::XWindowListener , 94*cdf0e10cSrcweir css::awt::XTopWindowListener , 95*cdf0e10cSrcweir css::awt::XSimpleTabController , 96*cdf0e10cSrcweir css::lang::XEventListener , 97*cdf0e10cSrcweir css::beans::XMultiPropertySet , 98*cdf0e10cSrcweir css::beans::XFastPropertySet , 99*cdf0e10cSrcweir css::beans::XPropertySet 100*cdf0e10cSrcweir ) 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir DEFINE_XSERVICEINFO_MULTISERVICE ( TabWindow , 103*cdf0e10cSrcweir ::cppu::OWeakObject , 104*cdf0e10cSrcweir SERVICENAME_TABWINDOW , 105*cdf0e10cSrcweir IMPLEMENTATIONNAME_TABWINDOW 106*cdf0e10cSrcweir ) 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir DEFINE_INIT_SERVICE ( TabWindow, {} ) 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir TabWindow::TabWindow( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ) : 111*cdf0e10cSrcweir ThreadHelpBase( &Application::GetSolarMutex() ) 112*cdf0e10cSrcweir , ::cppu::OBroadcastHelperVar< ::cppu::OMultiTypeInterfaceContainerHelper, ::cppu::OMultiTypeInterfaceContainerHelper::keyType >( m_aLock.getShareableOslMutex() ) 113*cdf0e10cSrcweir , ::cppu::OPropertySetHelper ( *(static_cast< ::cppu::OBroadcastHelper* >(this)) ) 114*cdf0e10cSrcweir , m_bInitialized( sal_False ) 115*cdf0e10cSrcweir , m_bDisposed( sal_False ) 116*cdf0e10cSrcweir , m_nNextTabID( 1 ) 117*cdf0e10cSrcweir , m_aTitlePropName( RTL_CONSTASCII_USTRINGPARAM( "Title" )) 118*cdf0e10cSrcweir , m_aPosPropName( RTL_CONSTASCII_USTRINGPARAM( "Position" )) 119*cdf0e10cSrcweir , m_xServiceManager( xServiceManager ) 120*cdf0e10cSrcweir , m_aListenerContainer( m_aLock.getShareableOslMutex() ) 121*cdf0e10cSrcweir { 122*cdf0e10cSrcweir } 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir TabWindow::~TabWindow() 125*cdf0e10cSrcweir { 126*cdf0e10cSrcweir } 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 129*cdf0e10cSrcweir // Helper 130*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir void TabWindow::implts_LayoutWindows() const 133*cdf0e10cSrcweir { 134*cdf0e10cSrcweir const sal_Int32 nTabControlHeight = 30; 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 137*cdf0e10cSrcweir ResetableGuard aLock( m_aLock ); 138*cdf0e10cSrcweir css::uno::Reference< css::awt::XDevice > xDevice( m_xTopWindow, css::uno::UNO_QUERY ); 139*cdf0e10cSrcweir css::uno::Reference< css::awt::XWindow > xWindow( m_xTopWindow, css::uno::UNO_QUERY ); 140*cdf0e10cSrcweir css::uno::Reference< css::awt::XWindow > xTabControlWindow( m_xTabControlWindow ); 141*cdf0e10cSrcweir css::uno::Reference< css::awt::XWindow > xContainerWindow( m_xContainerWindow ); 142*cdf0e10cSrcweir aLock.unlock(); 143*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir // Convert relativ size to output size. 146*cdf0e10cSrcweir if ( xWindow.is() && xDevice.is() ) 147*cdf0e10cSrcweir { 148*cdf0e10cSrcweir css::awt::Rectangle aRectangle = xWindow->getPosSize(); 149*cdf0e10cSrcweir css::awt::DeviceInfo aInfo = xDevice->getInfo(); 150*cdf0e10cSrcweir css::awt::Size aSize ( aRectangle.Width - aInfo.LeftInset - aInfo.RightInset , 151*cdf0e10cSrcweir aRectangle.Height - aInfo.TopInset - aInfo.BottomInset ); 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir css::awt::Size aContainerWindowSize; 154*cdf0e10cSrcweir css::awt::Size aTabControlSize; 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir aContainerWindowSize.Width = aSize.Width; 157*cdf0e10cSrcweir aTabControlSize.Width = aSize.Width; 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir aContainerWindowSize.Height = std::max( sal_Int32( 0 ), aSize.Height - nTabControlHeight ); 160*cdf0e10cSrcweir aTabControlSize.Height = nTabControlHeight; 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir xContainerWindow->setPosSize( 0, 0, 163*cdf0e10cSrcweir aContainerWindowSize.Width, aContainerWindowSize.Height, 164*cdf0e10cSrcweir css::awt::PosSize::POSSIZE ); 165*cdf0e10cSrcweir xTabControlWindow->setPosSize( 0, std::max( nTabControlHeight, sal_Int32( aSize.Height - nTabControlHeight)), 166*cdf0e10cSrcweir aTabControlSize.Width, aTabControlSize.Height, 167*cdf0e10cSrcweir css::awt::PosSize::POSSIZE ); 168*cdf0e10cSrcweir } 169*cdf0e10cSrcweir } 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir TabControl* TabWindow::impl_GetTabControl( const css::uno::Reference< css::awt::XWindow >& rTabControlWindow ) const 172*cdf0e10cSrcweir { 173*cdf0e10cSrcweir Window* pWindow = VCLUnoHelper::GetWindow( rTabControlWindow ); 174*cdf0e10cSrcweir if ( pWindow ) 175*cdf0e10cSrcweir return (TabControl *)pWindow; 176*cdf0e10cSrcweir else 177*cdf0e10cSrcweir return NULL; 178*cdf0e10cSrcweir } 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir void TabWindow::impl_SetTitle( const ::rtl::OUString& rTitle ) 181*cdf0e10cSrcweir { 182*cdf0e10cSrcweir if ( m_xTopWindow.is() ) 183*cdf0e10cSrcweir { 184*cdf0e10cSrcweir Window* pWindow = VCLUnoHelper::GetWindow( 185*cdf0e10cSrcweir css::uno::Reference< css::awt::XWindow >( 186*cdf0e10cSrcweir m_xTopWindow, css::uno::UNO_QUERY )); 187*cdf0e10cSrcweir if ( pWindow ) 188*cdf0e10cSrcweir pWindow->SetText( rTitle ); 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir } 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir void TabWindow::implts_SendNotification( Notification eNotify, sal_Int32 ID ) const 193*cdf0e10cSrcweir { 194*cdf0e10cSrcweir ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer( 195*cdf0e10cSrcweir ::getCppuType( ( const css::uno::Reference< css::awt::XTabListener >*) NULL ) ); 196*cdf0e10cSrcweir if (pContainer!=NULL) 197*cdf0e10cSrcweir { 198*cdf0e10cSrcweir ::cppu::OInterfaceIteratorHelper pIterator(*pContainer); 199*cdf0e10cSrcweir while (pIterator.hasMoreElements()) 200*cdf0e10cSrcweir { 201*cdf0e10cSrcweir try 202*cdf0e10cSrcweir { 203*cdf0e10cSrcweir switch ( eNotify ) 204*cdf0e10cSrcweir { 205*cdf0e10cSrcweir case NOTIFY_INSERTED: 206*cdf0e10cSrcweir ((css::awt::XTabListener*)pIterator.next())->inserted( ID ); 207*cdf0e10cSrcweir break; 208*cdf0e10cSrcweir case NOTIFY_REMOVED: 209*cdf0e10cSrcweir ((css::awt::XTabListener*)pIterator.next())->removed( ID ); 210*cdf0e10cSrcweir break; 211*cdf0e10cSrcweir case NOTIFY_ACTIVATED: 212*cdf0e10cSrcweir ((css::awt::XTabListener*)pIterator.next())->activated( ID ); 213*cdf0e10cSrcweir break; 214*cdf0e10cSrcweir case NOTIFY_DEACTIVATED: 215*cdf0e10cSrcweir ((css::awt::XTabListener*)pIterator.next())->deactivated( ID ); 216*cdf0e10cSrcweir break; 217*cdf0e10cSrcweir default: 218*cdf0e10cSrcweir break; 219*cdf0e10cSrcweir } 220*cdf0e10cSrcweir } 221*cdf0e10cSrcweir catch( css::uno::RuntimeException& ) 222*cdf0e10cSrcweir { 223*cdf0e10cSrcweir pIterator.remove(); 224*cdf0e10cSrcweir } 225*cdf0e10cSrcweir } 226*cdf0e10cSrcweir } 227*cdf0e10cSrcweir } 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir void TabWindow::implts_SendNotification( Notification eNotify, sal_Int32 ID, const css::uno::Sequence< css::beans::NamedValue >& rSeq ) const 230*cdf0e10cSrcweir { 231*cdf0e10cSrcweir ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer( 232*cdf0e10cSrcweir ::getCppuType( ( const css::uno::Reference< css::awt::XTabListener >*) NULL ) ); 233*cdf0e10cSrcweir if (pContainer!=NULL) 234*cdf0e10cSrcweir { 235*cdf0e10cSrcweir ::cppu::OInterfaceIteratorHelper pIterator(*pContainer); 236*cdf0e10cSrcweir while (pIterator.hasMoreElements()) 237*cdf0e10cSrcweir { 238*cdf0e10cSrcweir try 239*cdf0e10cSrcweir { 240*cdf0e10cSrcweir switch ( eNotify ) 241*cdf0e10cSrcweir { 242*cdf0e10cSrcweir case NOTIFY_CHANGED: 243*cdf0e10cSrcweir ((css::awt::XTabListener*)pIterator.next())->changed( ID, rSeq ); 244*cdf0e10cSrcweir break; 245*cdf0e10cSrcweir default: 246*cdf0e10cSrcweir break; 247*cdf0e10cSrcweir } 248*cdf0e10cSrcweir } 249*cdf0e10cSrcweir catch( css::uno::RuntimeException& ) 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir pIterator.remove(); 252*cdf0e10cSrcweir } 253*cdf0e10cSrcweir } 254*cdf0e10cSrcweir } 255*cdf0e10cSrcweir } 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 258*cdf0e10cSrcweir // Links 259*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir IMPL_LINK( TabWindow, Activate, TabControl*, pTabControl ) 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 264*cdf0e10cSrcweir ResetableGuard aLock( m_aLock ); 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir sal_Int32 nPageId = pTabControl->GetCurPageId(); 267*cdf0e10cSrcweir 268*cdf0e10cSrcweir rtl::OUString aTitle = pTabControl->GetPageText( sal_uInt16( nPageId )); 269*cdf0e10cSrcweir impl_SetTitle( aTitle ); 270*cdf0e10cSrcweir aLock.unlock(); 271*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir implts_SendNotification( NOTIFY_ACTIVATED, nPageId ); 274*cdf0e10cSrcweir 275*cdf0e10cSrcweir return 1; 276*cdf0e10cSrcweir } 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir IMPL_LINK( TabWindow, Deactivate, TabControl*, pTabControl ) 279*cdf0e10cSrcweir { 280*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 281*cdf0e10cSrcweir ResetableGuard aLock( m_aLock ); 282*cdf0e10cSrcweir sal_Int32 nPageId = pTabControl->GetCurPageId(); 283*cdf0e10cSrcweir aLock.unlock(); 284*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir implts_SendNotification( NOTIFY_DEACTIVATED, nPageId ); 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir return 1; 289*cdf0e10cSrcweir } 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 292*cdf0e10cSrcweir // XInitilization 293*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir void SAL_CALL TabWindow::initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) 296*cdf0e10cSrcweir throw (css::uno::Exception, css::uno::RuntimeException) 297*cdf0e10cSrcweir { 298*cdf0e10cSrcweir const rtl::OUString aTopWindowArgName( RTL_CONSTASCII_USTRINGPARAM( "TopWindow" )); 299*cdf0e10cSrcweir const rtl::OUString aSizeArgName( RTL_CONSTASCII_USTRINGPARAM( "Size" )); 300*cdf0e10cSrcweir 301*cdf0e10cSrcweir css::awt::Size aDefaultSize( 500, 500 ); 302*cdf0e10cSrcweir css::awt::Size aSize( aDefaultSize ); 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 305*cdf0e10cSrcweir ResetableGuard aLock( m_aLock ); 306*cdf0e10cSrcweir sal_Bool bInitalized( m_bInitialized ); 307*cdf0e10cSrcweir css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR( m_xServiceManager ); 308*cdf0e10cSrcweir aLock.unlock(); 309*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir if ( !bInitalized ) 312*cdf0e10cSrcweir { 313*cdf0e10cSrcweir css::beans::PropertyValue aPropValue; 314*cdf0e10cSrcweir css::uno::Reference< css::awt::XTopWindow > xTopWindow; 315*cdf0e10cSrcweir css::uno::Reference< css::awt::XToolkit > xToolkit; 316*cdf0e10cSrcweir css::awt::WindowDescriptor aDescriptor; 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir if ( xSMGR.is() ) 319*cdf0e10cSrcweir { 320*cdf0e10cSrcweir try 321*cdf0e10cSrcweir { 322*cdf0e10cSrcweir xToolkit = css::uno::Reference< css::awt::XToolkit >( 323*cdf0e10cSrcweir xSMGR->createInstance( SERVICENAME_VCLTOOLKIT ), css::uno::UNO_QUERY ); 324*cdf0e10cSrcweir } 325*cdf0e10cSrcweir catch ( css::uno::RuntimeException& ) 326*cdf0e10cSrcweir { 327*cdf0e10cSrcweir throw; 328*cdf0e10cSrcweir } 329*cdf0e10cSrcweir catch ( css::uno::Exception& ) 330*cdf0e10cSrcweir { 331*cdf0e10cSrcweir } 332*cdf0e10cSrcweir } 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir for ( int i = 0; i < aArguments.getLength(); i++ ) 335*cdf0e10cSrcweir { 336*cdf0e10cSrcweir if ( aArguments[i] >>= aPropValue ) 337*cdf0e10cSrcweir { 338*cdf0e10cSrcweir if ( aPropValue.Name == aTopWindowArgName ) 339*cdf0e10cSrcweir aPropValue.Value >>= xTopWindow; 340*cdf0e10cSrcweir else if ( aPropValue.Name == aSizeArgName ) 341*cdf0e10cSrcweir { 342*cdf0e10cSrcweir aPropValue.Value >>= aSize; 343*cdf0e10cSrcweir if ( aSize.Width <= 0 ) 344*cdf0e10cSrcweir aSize.Width = aDefaultSize.Width; 345*cdf0e10cSrcweir if ( aSize.Height <= 0 ) 346*cdf0e10cSrcweir aSize.Height = aDefaultSize.Height; 347*cdf0e10cSrcweir } 348*cdf0e10cSrcweir } 349*cdf0e10cSrcweir } 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir if ( xToolkit.is() ) 352*cdf0e10cSrcweir { 353*cdf0e10cSrcweir if ( !xTopWindow.is() ) 354*cdf0e10cSrcweir { 355*cdf0e10cSrcweir // describe top window properties. 356*cdf0e10cSrcweir aDescriptor.Type = css::awt::WindowClass_TOP; 357*cdf0e10cSrcweir aDescriptor.ParentIndex = -1; 358*cdf0e10cSrcweir aDescriptor.Parent = css::uno::Reference< css::awt::XWindowPeer >(); 359*cdf0e10cSrcweir aDescriptor.Bounds = css::awt::Rectangle( 0, 0, aSize.Width, aSize.Height ); 360*cdf0e10cSrcweir aDescriptor.WindowAttributes = 0; 361*cdf0e10cSrcweir 362*cdf0e10cSrcweir try 363*cdf0e10cSrcweir { 364*cdf0e10cSrcweir xTopWindow = css::uno::Reference< css::awt::XTopWindow >( xToolkit->createWindow( aDescriptor ), css::uno::UNO_QUERY ); 365*cdf0e10cSrcweir } 366*cdf0e10cSrcweir catch ( css::uno::RuntimeException& ) 367*cdf0e10cSrcweir { 368*cdf0e10cSrcweir throw; 369*cdf0e10cSrcweir } 370*cdf0e10cSrcweir catch ( css::uno::Exception& ) 371*cdf0e10cSrcweir { 372*cdf0e10cSrcweir } 373*cdf0e10cSrcweir } 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir if ( xTopWindow.is() ) 376*cdf0e10cSrcweir { 377*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 378*cdf0e10cSrcweir aLock.lock(); 379*cdf0e10cSrcweir m_bInitialized = sal_True; 380*cdf0e10cSrcweir aLock.unlock(); 381*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 382*cdf0e10cSrcweir 383*cdf0e10cSrcweir css::uno::Reference< css::awt::XWindow > xWindow( xTopWindow, css::uno::UNO_QUERY ); 384*cdf0e10cSrcweir xWindow->addWindowListener( css::uno::Reference< css::awt::XWindowListener >( 385*cdf0e10cSrcweir static_cast< ::cppu::OWeakObject* >( this ), css::uno::UNO_QUERY_THROW )); 386*cdf0e10cSrcweir 387*cdf0e10cSrcweir xTopWindow->addTopWindowListener( css::uno::Reference< css::awt::XTopWindowListener >( 388*cdf0e10cSrcweir static_cast< ::cppu::OWeakObject* >( this ), css::uno::UNO_QUERY_THROW )); 389*cdf0e10cSrcweir 390*cdf0e10cSrcweir css::uno::Reference< css::awt::XWindow > xContainerWindow; 391*cdf0e10cSrcweir css::uno::Reference< css::awt::XWindow > xTabControl; 392*cdf0e10cSrcweir 393*cdf0e10cSrcweir // describe container window properties. 394*cdf0e10cSrcweir aDescriptor.Type = css::awt::WindowClass_SIMPLE; 395*cdf0e10cSrcweir aDescriptor.ParentIndex = -1; 396*cdf0e10cSrcweir aDescriptor.Parent = css::uno::Reference< css::awt::XWindowPeer >( xTopWindow, css::uno::UNO_QUERY ); 397*cdf0e10cSrcweir aDescriptor.Bounds = css::awt::Rectangle(0,0,0,0); 398*cdf0e10cSrcweir aDescriptor.WindowAttributes = 0; 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir xContainerWindow = css::uno::Reference< css::awt::XWindow >( xToolkit->createWindow( aDescriptor ), css::uno::UNO_QUERY ); 401*cdf0e10cSrcweir 402*cdf0e10cSrcweir // create a tab control window properties 403*cdf0e10cSrcweir aDescriptor.Type = css::awt::WindowClass_SIMPLE; 404*cdf0e10cSrcweir aDescriptor.WindowServiceName = DECLARE_ASCII("tabcontrol"); 405*cdf0e10cSrcweir aDescriptor.ParentIndex = -1; 406*cdf0e10cSrcweir aDescriptor.Parent = css::uno::Reference< css::awt::XWindowPeer >( xTopWindow, css::uno::UNO_QUERY ); 407*cdf0e10cSrcweir aDescriptor.Bounds = css::awt::Rectangle( 0,0,0,0 ); 408*cdf0e10cSrcweir aDescriptor.WindowAttributes = 0; 409*cdf0e10cSrcweir 410*cdf0e10cSrcweir xTabControl = css::uno::Reference< css::awt::XWindow >( xToolkit->createWindow( aDescriptor ), css::uno::UNO_QUERY ); 411*cdf0e10cSrcweir 412*cdf0e10cSrcweir if ( xContainerWindow.is() && xTabControl.is() ) 413*cdf0e10cSrcweir { 414*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 415*cdf0e10cSrcweir aLock.lock(); 416*cdf0e10cSrcweir m_xTopWindow = xTopWindow; 417*cdf0e10cSrcweir m_xContainerWindow = xContainerWindow; 418*cdf0e10cSrcweir m_xTabControlWindow = xTabControl; 419*cdf0e10cSrcweir aLock.unlock(); 420*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir xWindow->setPosSize( 0, 0, aSize.Width, aSize.Height, css::awt::PosSize::POSSIZE ); 423*cdf0e10cSrcweir 424*cdf0e10cSrcweir vos::OGuard aGuard( Application::GetSolarMutex() ); 425*cdf0e10cSrcweir Window* pWindow = VCLUnoHelper::GetWindow( xWindow ); 426*cdf0e10cSrcweir if( pWindow ) 427*cdf0e10cSrcweir pWindow->Show( sal_True ); 428*cdf0e10cSrcweir 429*cdf0e10cSrcweir pWindow = VCLUnoHelper::GetWindow( xContainerWindow ); 430*cdf0e10cSrcweir if ( pWindow ) 431*cdf0e10cSrcweir pWindow->Show( sal_True, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE ); 432*cdf0e10cSrcweir 433*cdf0e10cSrcweir pWindow = VCLUnoHelper::GetWindow( xTabControl ); 434*cdf0e10cSrcweir if ( pWindow ) 435*cdf0e10cSrcweir { 436*cdf0e10cSrcweir pWindow->Show( sal_True, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE ); 437*cdf0e10cSrcweir TabControl* pTabControl = (TabControl *)pWindow; 438*cdf0e10cSrcweir pTabControl->SetActivatePageHdl( LINK( this, TabWindow, Activate )); 439*cdf0e10cSrcweir pTabControl->SetDeactivatePageHdl( LINK( this, TabWindow, Deactivate )); 440*cdf0e10cSrcweir } 441*cdf0e10cSrcweir 442*cdf0e10cSrcweir implts_LayoutWindows(); 443*cdf0e10cSrcweir } 444*cdf0e10cSrcweir } 445*cdf0e10cSrcweir } 446*cdf0e10cSrcweir } 447*cdf0e10cSrcweir } 448*cdf0e10cSrcweir 449*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 450*cdf0e10cSrcweir // XComponent 451*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 452*cdf0e10cSrcweir void SAL_CALL TabWindow::dispose() throw (css::uno::RuntimeException) 453*cdf0e10cSrcweir { 454*cdf0e10cSrcweir // Send message to all listener and forget her references. 455*cdf0e10cSrcweir css::uno::Reference< css::lang::XComponent > xThis( 456*cdf0e10cSrcweir static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY ); 457*cdf0e10cSrcweir css::lang::EventObject aEvent( xThis ); 458*cdf0e10cSrcweir 459*cdf0e10cSrcweir m_aListenerContainer.disposeAndClear( aEvent ); 460*cdf0e10cSrcweir 461*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 462*cdf0e10cSrcweir ResetableGuard aLock( m_aLock ); 463*cdf0e10cSrcweir css::uno::Reference< css::awt::XWindow > xTabControlWindow( m_xTabControlWindow ); 464*cdf0e10cSrcweir css::uno::Reference< css::awt::XWindow > xContainerWindow( m_xContainerWindow ); 465*cdf0e10cSrcweir css::uno::Reference< css::awt::XTopWindow > xTopWindow( m_xTopWindow ); 466*cdf0e10cSrcweir m_xTabControlWindow.clear(); 467*cdf0e10cSrcweir m_xContainerWindow.clear(); 468*cdf0e10cSrcweir m_xTopWindow.clear(); 469*cdf0e10cSrcweir aLock.unlock(); 470*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 471*cdf0e10cSrcweir 472*cdf0e10cSrcweir css::uno::Reference< css::lang::XComponent > xComponent( xTabControlWindow, css::uno::UNO_QUERY ); 473*cdf0e10cSrcweir if ( xComponent.is() ) 474*cdf0e10cSrcweir xComponent->dispose(); 475*cdf0e10cSrcweir 476*cdf0e10cSrcweir xComponent = css::uno::Reference< css::lang::XComponent >( xContainerWindow, css::uno::UNO_QUERY ); 477*cdf0e10cSrcweir if ( xComponent.is() ) 478*cdf0e10cSrcweir xComponent->dispose(); 479*cdf0e10cSrcweir 480*cdf0e10cSrcweir xComponent = css::uno::Reference< css::lang::XComponent >( xTopWindow, css::uno::UNO_QUERY ); 481*cdf0e10cSrcweir if ( xComponent.is() ) 482*cdf0e10cSrcweir xComponent->dispose(); 483*cdf0e10cSrcweir 484*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 485*cdf0e10cSrcweir aLock.lock(); 486*cdf0e10cSrcweir m_bDisposed = sal_True; 487*cdf0e10cSrcweir aLock.unlock(); 488*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 489*cdf0e10cSrcweir } 490*cdf0e10cSrcweir 491*cdf0e10cSrcweir void SAL_CALL TabWindow::addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) 492*cdf0e10cSrcweir throw (css::uno::RuntimeException) 493*cdf0e10cSrcweir { 494*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 495*cdf0e10cSrcweir ResetableGuard aLock( m_aLock ); 496*cdf0e10cSrcweir if ( m_bDisposed ) 497*cdf0e10cSrcweir return; 498*cdf0e10cSrcweir aLock.unlock(); 499*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 500*cdf0e10cSrcweir 501*cdf0e10cSrcweir m_aListenerContainer.addInterface( ::getCppuType( ( const css::uno::Reference< css::lang::XEventListener >* ) NULL ), xListener ); 502*cdf0e10cSrcweir } 503*cdf0e10cSrcweir 504*cdf0e10cSrcweir void SAL_CALL TabWindow::removeEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) 505*cdf0e10cSrcweir throw (css::uno::RuntimeException) 506*cdf0e10cSrcweir { 507*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 508*cdf0e10cSrcweir ResetableGuard aLock( m_aLock ); 509*cdf0e10cSrcweir if ( m_bDisposed ) 510*cdf0e10cSrcweir return; 511*cdf0e10cSrcweir aLock.unlock(); 512*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 513*cdf0e10cSrcweir 514*cdf0e10cSrcweir m_aListenerContainer.removeInterface( ::getCppuType( ( const css::uno::Reference< css::lang::XEventListener >* ) NULL ), xListener ); 515*cdf0e10cSrcweir } 516*cdf0e10cSrcweir 517*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 518*cdf0e10cSrcweir // XEventListener 519*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 520*cdf0e10cSrcweir void SAL_CALL TabWindow::disposing( const css::lang::EventObject& ) 521*cdf0e10cSrcweir throw( css::uno::RuntimeException ) 522*cdf0e10cSrcweir { 523*cdf0e10cSrcweir } 524*cdf0e10cSrcweir 525*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 526*cdf0e10cSrcweir // XWindowListener 527*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 528*cdf0e10cSrcweir void SAL_CALL TabWindow::windowResized( const css::awt::WindowEvent& ) 529*cdf0e10cSrcweir throw( css::uno::RuntimeException ) 530*cdf0e10cSrcweir { 531*cdf0e10cSrcweir implts_LayoutWindows(); 532*cdf0e10cSrcweir } 533*cdf0e10cSrcweir 534*cdf0e10cSrcweir void SAL_CALL TabWindow::windowMoved( const css::awt::WindowEvent& ) 535*cdf0e10cSrcweir throw( css::uno::RuntimeException ) 536*cdf0e10cSrcweir { 537*cdf0e10cSrcweir } 538*cdf0e10cSrcweir 539*cdf0e10cSrcweir void SAL_CALL TabWindow::windowShown( const css::lang::EventObject& ) 540*cdf0e10cSrcweir throw( css::uno::RuntimeException ) 541*cdf0e10cSrcweir { 542*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 543*cdf0e10cSrcweir ResetableGuard aLock( m_aLock ); 544*cdf0e10cSrcweir 545*cdf0e10cSrcweir TabControl* pTabControl = impl_GetTabControl( m_xTabControlWindow ); 546*cdf0e10cSrcweir if ( pTabControl ) 547*cdf0e10cSrcweir pTabControl->Show(); 548*cdf0e10cSrcweir 549*cdf0e10cSrcweir if ( m_xContainerWindow.is() ) 550*cdf0e10cSrcweir { 551*cdf0e10cSrcweir Window* pWindow = VCLUnoHelper::GetWindow( m_xContainerWindow ); 552*cdf0e10cSrcweir if ( pWindow ) 553*cdf0e10cSrcweir pWindow->Show(); 554*cdf0e10cSrcweir } 555*cdf0e10cSrcweir } 556*cdf0e10cSrcweir 557*cdf0e10cSrcweir void SAL_CALL TabWindow::windowHidden( const css::lang::EventObject& ) 558*cdf0e10cSrcweir throw( css::uno::RuntimeException ) 559*cdf0e10cSrcweir { 560*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 561*cdf0e10cSrcweir ResetableGuard aLock( m_aLock ); 562*cdf0e10cSrcweir if ( m_xContainerWindow.is() ) 563*cdf0e10cSrcweir { 564*cdf0e10cSrcweir Window* pWindow = VCLUnoHelper::GetWindow( m_xContainerWindow ); 565*cdf0e10cSrcweir if ( pWindow ) 566*cdf0e10cSrcweir pWindow->Hide(); 567*cdf0e10cSrcweir } 568*cdf0e10cSrcweir 569*cdf0e10cSrcweir TabControl* pTabControl = impl_GetTabControl( m_xTabControlWindow ); 570*cdf0e10cSrcweir if ( pTabControl ) 571*cdf0e10cSrcweir pTabControl->Hide(); 572*cdf0e10cSrcweir } 573*cdf0e10cSrcweir 574*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 575*cdf0e10cSrcweir // XTopWindowListener 576*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 577*cdf0e10cSrcweir void SAL_CALL TabWindow::windowOpened( const css::lang::EventObject& ) 578*cdf0e10cSrcweir throw (css::uno::RuntimeException) 579*cdf0e10cSrcweir { 580*cdf0e10cSrcweir } 581*cdf0e10cSrcweir 582*cdf0e10cSrcweir void SAL_CALL TabWindow::windowClosing( const css::lang::EventObject& ) 583*cdf0e10cSrcweir throw (css::uno::RuntimeException) 584*cdf0e10cSrcweir { 585*cdf0e10cSrcweir css::uno::Reference< css::lang::XComponent > xComponent( (OWeakObject *)this, css::uno::UNO_QUERY ); 586*cdf0e10cSrcweir if ( xComponent.is() ) 587*cdf0e10cSrcweir xComponent->dispose(); 588*cdf0e10cSrcweir } 589*cdf0e10cSrcweir 590*cdf0e10cSrcweir void SAL_CALL TabWindow::windowClosed( const css::lang::EventObject& ) 591*cdf0e10cSrcweir throw (css::uno::RuntimeException) 592*cdf0e10cSrcweir { 593*cdf0e10cSrcweir } 594*cdf0e10cSrcweir 595*cdf0e10cSrcweir void SAL_CALL TabWindow::windowMinimized( const css::lang::EventObject& ) 596*cdf0e10cSrcweir throw (css::uno::RuntimeException) 597*cdf0e10cSrcweir { 598*cdf0e10cSrcweir } 599*cdf0e10cSrcweir 600*cdf0e10cSrcweir void SAL_CALL TabWindow::windowNormalized( const css::lang::EventObject& ) 601*cdf0e10cSrcweir throw (css::uno::RuntimeException) 602*cdf0e10cSrcweir { 603*cdf0e10cSrcweir } 604*cdf0e10cSrcweir 605*cdf0e10cSrcweir void SAL_CALL TabWindow::windowActivated( const css::lang::EventObject& ) 606*cdf0e10cSrcweir throw (css::uno::RuntimeException) 607*cdf0e10cSrcweir { 608*cdf0e10cSrcweir } 609*cdf0e10cSrcweir 610*cdf0e10cSrcweir void SAL_CALL TabWindow::windowDeactivated( const css::lang::EventObject& ) 611*cdf0e10cSrcweir throw (css::uno::RuntimeException) 612*cdf0e10cSrcweir { 613*cdf0e10cSrcweir } 614*cdf0e10cSrcweir 615*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 616*cdf0e10cSrcweir // XSimpleTabController 617*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 618*cdf0e10cSrcweir 619*cdf0e10cSrcweir ::sal_Int32 SAL_CALL TabWindow::insertTab() 620*cdf0e10cSrcweir throw (css::uno::RuntimeException) 621*cdf0e10cSrcweir { 622*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 623*cdf0e10cSrcweir ResetableGuard aLock( m_aLock ); 624*cdf0e10cSrcweir 625*cdf0e10cSrcweir if ( m_bDisposed ) 626*cdf0e10cSrcweir throw css::lang::DisposedException(); 627*cdf0e10cSrcweir 628*cdf0e10cSrcweir sal_Int32 nNextTabID( m_nNextTabID++ ); 629*cdf0e10cSrcweir 630*cdf0e10cSrcweir rtl::OUString aTitle; 631*cdf0e10cSrcweir TabControl* pTabControl = impl_GetTabControl( m_xTabControlWindow ); 632*cdf0e10cSrcweir if ( pTabControl ) 633*cdf0e10cSrcweir pTabControl->InsertPage( sal_uInt16( nNextTabID ), aTitle ); 634*cdf0e10cSrcweir aLock.unlock(); 635*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 636*cdf0e10cSrcweir 637*cdf0e10cSrcweir implts_SendNotification( NOTIFY_INSERTED, nNextTabID ); 638*cdf0e10cSrcweir 639*cdf0e10cSrcweir return nNextTabID; 640*cdf0e10cSrcweir } 641*cdf0e10cSrcweir 642*cdf0e10cSrcweir void SAL_CALL TabWindow::removeTab( ::sal_Int32 ID ) 643*cdf0e10cSrcweir throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException) 644*cdf0e10cSrcweir { 645*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 646*cdf0e10cSrcweir ResetableGuard aLock( m_aLock ); 647*cdf0e10cSrcweir 648*cdf0e10cSrcweir if ( m_bDisposed ) 649*cdf0e10cSrcweir throw css::lang::DisposedException(); 650*cdf0e10cSrcweir 651*cdf0e10cSrcweir TabControl* pTabControl = impl_GetTabControl( m_xTabControlWindow ); 652*cdf0e10cSrcweir if ( pTabControl ) 653*cdf0e10cSrcweir { 654*cdf0e10cSrcweir sal_uInt16 nCurTabId = pTabControl->GetCurPageId(); 655*cdf0e10cSrcweir sal_uInt16 nPos = pTabControl->GetPagePos( sal_uInt16( ID )); 656*cdf0e10cSrcweir if ( nPos == TAB_PAGE_NOTFOUND ) 657*cdf0e10cSrcweir throw css::lang::IndexOutOfBoundsException(); 658*cdf0e10cSrcweir else 659*cdf0e10cSrcweir { 660*cdf0e10cSrcweir pTabControl->RemovePage( sal_uInt16( ID )); 661*cdf0e10cSrcweir nCurTabId = pTabControl->GetCurPageId(); 662*cdf0e10cSrcweir } 663*cdf0e10cSrcweir aLock.unlock(); 664*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 665*cdf0e10cSrcweir 666*cdf0e10cSrcweir implts_SendNotification( NOTIFY_REMOVED, ID ); 667*cdf0e10cSrcweir 668*cdf0e10cSrcweir // activate new tab if old tab was active! 669*cdf0e10cSrcweir nPos = pTabControl->GetPagePos( sal_uInt16( nCurTabId )); 670*cdf0e10cSrcweir if ( nPos != TAB_PAGE_NOTFOUND && nCurTabId != ID ) 671*cdf0e10cSrcweir activateTab( nCurTabId ); 672*cdf0e10cSrcweir } 673*cdf0e10cSrcweir } 674*cdf0e10cSrcweir 675*cdf0e10cSrcweir void SAL_CALL TabWindow::setTabProps( ::sal_Int32 ID, const css::uno::Sequence< css::beans::NamedValue >& Properties ) 676*cdf0e10cSrcweir throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException) 677*cdf0e10cSrcweir { 678*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 679*cdf0e10cSrcweir ResetableGuard aLock( m_aLock ); 680*cdf0e10cSrcweir 681*cdf0e10cSrcweir if ( m_bDisposed ) 682*cdf0e10cSrcweir throw css::lang::DisposedException(); 683*cdf0e10cSrcweir 684*cdf0e10cSrcweir TabControl* pTabControl = impl_GetTabControl( m_xTabControlWindow ); 685*cdf0e10cSrcweir if ( pTabControl ) 686*cdf0e10cSrcweir { 687*cdf0e10cSrcweir sal_uInt16 nPos = pTabControl->GetPagePos( sal_uInt16( ID )); 688*cdf0e10cSrcweir if ( nPos == TAB_PAGE_NOTFOUND ) 689*cdf0e10cSrcweir throw css::lang::IndexOutOfBoundsException(); 690*cdf0e10cSrcweir else 691*cdf0e10cSrcweir { 692*cdf0e10cSrcweir comphelper::SequenceAsHashMap aSeqHashMap( Properties ); 693*cdf0e10cSrcweir 694*cdf0e10cSrcweir ::rtl::OUString aTitle = pTabControl->GetPageText( sal_uInt16( ID )); 695*cdf0e10cSrcweir sal_Int32 nNewPos = nPos; 696*cdf0e10cSrcweir 697*cdf0e10cSrcweir aTitle = aSeqHashMap.getUnpackedValueOrDefault< ::rtl::OUString >( 698*cdf0e10cSrcweir m_aTitlePropName, aTitle ); 699*cdf0e10cSrcweir pTabControl->SetPageText( sal_uInt16( ID ), aTitle ); 700*cdf0e10cSrcweir nNewPos = aSeqHashMap.getUnpackedValueOrDefault< sal_Int32 >( 701*cdf0e10cSrcweir m_aPosPropName, nNewPos ); 702*cdf0e10cSrcweir if ( nNewPos != sal_Int32( nPos )) 703*cdf0e10cSrcweir { 704*cdf0e10cSrcweir nPos = sal_uInt16( nNewPos ); 705*cdf0e10cSrcweir if ( nPos >= pTabControl->GetPageCount() ) 706*cdf0e10cSrcweir nPos = TAB_APPEND; 707*cdf0e10cSrcweir 708*cdf0e10cSrcweir pTabControl->RemovePage( sal_uInt16( ID )); 709*cdf0e10cSrcweir pTabControl->InsertPage( sal_uInt16( ID ), aTitle, nPos ); 710*cdf0e10cSrcweir } 711*cdf0e10cSrcweir 712*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 713*cdf0e10cSrcweir aLock.unlock(); 714*cdf0e10cSrcweir 715*cdf0e10cSrcweir css::uno::Sequence< css::beans::NamedValue > aNamedValueSeq = getTabProps( ID ); 716*cdf0e10cSrcweir implts_SendNotification( NOTIFY_CHANGED, ID, aNamedValueSeq ); 717*cdf0e10cSrcweir } 718*cdf0e10cSrcweir } 719*cdf0e10cSrcweir } 720*cdf0e10cSrcweir 721*cdf0e10cSrcweir css::uno::Sequence< css::beans::NamedValue > SAL_CALL TabWindow::getTabProps( ::sal_Int32 ID ) 722*cdf0e10cSrcweir throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException) 723*cdf0e10cSrcweir { 724*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 725*cdf0e10cSrcweir ResetableGuard aLock( m_aLock ); 726*cdf0e10cSrcweir 727*cdf0e10cSrcweir if ( m_bDisposed ) 728*cdf0e10cSrcweir throw css::lang::DisposedException(); 729*cdf0e10cSrcweir 730*cdf0e10cSrcweir css::uno::Sequence< css::beans::NamedValue > aNamedValueSeq; 731*cdf0e10cSrcweir 732*cdf0e10cSrcweir TabControl* pTabControl = impl_GetTabControl( m_xTabControlWindow ); 733*cdf0e10cSrcweir if ( pTabControl ) 734*cdf0e10cSrcweir { 735*cdf0e10cSrcweir sal_uInt16 nPos = pTabControl->GetPagePos( sal_uInt16( ID )); 736*cdf0e10cSrcweir if ( nPos == TAB_PAGE_NOTFOUND ) 737*cdf0e10cSrcweir throw css::lang::IndexOutOfBoundsException(); 738*cdf0e10cSrcweir else 739*cdf0e10cSrcweir { 740*cdf0e10cSrcweir rtl::OUString aTitle = pTabControl->GetPageText( sal_uInt16( ID )); 741*cdf0e10cSrcweir nPos = pTabControl->GetPagePos( sal_uInt16( ID )); 742*cdf0e10cSrcweir 743*cdf0e10cSrcweir css::uno::Sequence< css::beans::NamedValue > aSeq( 2 ); 744*cdf0e10cSrcweir aSeq[0].Name = m_aTitlePropName; 745*cdf0e10cSrcweir aSeq[0].Value = css::uno::makeAny( aTitle ); 746*cdf0e10cSrcweir aSeq[1].Name = m_aPosPropName; 747*cdf0e10cSrcweir aSeq[1].Value = css::uno::makeAny( sal_Int32( nPos )); 748*cdf0e10cSrcweir return aSeq; 749*cdf0e10cSrcweir } 750*cdf0e10cSrcweir } 751*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 752*cdf0e10cSrcweir 753*cdf0e10cSrcweir return aNamedValueSeq; 754*cdf0e10cSrcweir } 755*cdf0e10cSrcweir 756*cdf0e10cSrcweir void SAL_CALL TabWindow::activateTab( ::sal_Int32 ID ) 757*cdf0e10cSrcweir throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException) 758*cdf0e10cSrcweir { 759*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 760*cdf0e10cSrcweir ResetableGuard aLock( m_aLock ); 761*cdf0e10cSrcweir 762*cdf0e10cSrcweir if ( m_bDisposed ) 763*cdf0e10cSrcweir throw css::lang::DisposedException(); 764*cdf0e10cSrcweir 765*cdf0e10cSrcweir TabControl* pTabControl = impl_GetTabControl( m_xTabControlWindow ); 766*cdf0e10cSrcweir if ( pTabControl ) 767*cdf0e10cSrcweir { 768*cdf0e10cSrcweir sal_uInt16 nPos = pTabControl->GetPagePos( sal_uInt16( ID )); 769*cdf0e10cSrcweir if ( nPos == TAB_PAGE_NOTFOUND ) 770*cdf0e10cSrcweir throw css::lang::IndexOutOfBoundsException(); 771*cdf0e10cSrcweir else 772*cdf0e10cSrcweir { 773*cdf0e10cSrcweir sal_Int32 nOldID = pTabControl->GetCurPageId(); 774*cdf0e10cSrcweir rtl::OUString aTitle = pTabControl->GetPageText( sal_uInt16( ID )); 775*cdf0e10cSrcweir pTabControl->SetCurPageId( sal_uInt16( ID )); 776*cdf0e10cSrcweir pTabControl->SelectTabPage( sal_uInt16( ID )); 777*cdf0e10cSrcweir impl_SetTitle( aTitle ); 778*cdf0e10cSrcweir 779*cdf0e10cSrcweir aLock.unlock(); 780*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 781*cdf0e10cSrcweir 782*cdf0e10cSrcweir if ( nOldID != TAB_PAGE_NOTFOUND ) 783*cdf0e10cSrcweir implts_SendNotification( NOTIFY_DEACTIVATED, nOldID ); 784*cdf0e10cSrcweir implts_SendNotification( NOTIFY_ACTIVATED, ID ); 785*cdf0e10cSrcweir } 786*cdf0e10cSrcweir } 787*cdf0e10cSrcweir } 788*cdf0e10cSrcweir 789*cdf0e10cSrcweir ::sal_Int32 SAL_CALL TabWindow::getActiveTabID() 790*cdf0e10cSrcweir throw (css::uno::RuntimeException) 791*cdf0e10cSrcweir { 792*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 793*cdf0e10cSrcweir ResetableGuard aLock( m_aLock ); 794*cdf0e10cSrcweir 795*cdf0e10cSrcweir if ( m_bDisposed ) 796*cdf0e10cSrcweir throw css::lang::DisposedException(); 797*cdf0e10cSrcweir 798*cdf0e10cSrcweir TabControl* pTabControl = impl_GetTabControl( m_xTabControlWindow ); 799*cdf0e10cSrcweir if ( pTabControl ) 800*cdf0e10cSrcweir { 801*cdf0e10cSrcweir sal_uInt16 nID = pTabControl->GetCurPageId(); 802*cdf0e10cSrcweir if ( nID == TAB_PAGE_NOTFOUND ) 803*cdf0e10cSrcweir return -1; 804*cdf0e10cSrcweir else 805*cdf0e10cSrcweir return sal_Int32( nID ); 806*cdf0e10cSrcweir } 807*cdf0e10cSrcweir 808*cdf0e10cSrcweir return -1; 809*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 810*cdf0e10cSrcweir } 811*cdf0e10cSrcweir 812*cdf0e10cSrcweir void SAL_CALL TabWindow::addTabListener( 813*cdf0e10cSrcweir const css::uno::Reference< css::awt::XTabListener >& xListener ) 814*cdf0e10cSrcweir throw (css::uno::RuntimeException) 815*cdf0e10cSrcweir { 816*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 817*cdf0e10cSrcweir ResetableGuard aLock( m_aLock ); 818*cdf0e10cSrcweir if ( m_bDisposed ) 819*cdf0e10cSrcweir return; 820*cdf0e10cSrcweir aLock.unlock(); 821*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 822*cdf0e10cSrcweir 823*cdf0e10cSrcweir m_aListenerContainer.addInterface( 824*cdf0e10cSrcweir ::getCppuType( ( const css::uno::Reference< css::awt::XTabListener >* ) NULL ), xListener ); 825*cdf0e10cSrcweir } 826*cdf0e10cSrcweir 827*cdf0e10cSrcweir void SAL_CALL TabWindow::removeTabListener( const css::uno::Reference< css::awt::XTabListener >& xListener ) 828*cdf0e10cSrcweir throw (css::uno::RuntimeException) 829*cdf0e10cSrcweir { 830*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 831*cdf0e10cSrcweir ResetableGuard aLock( m_aLock ); 832*cdf0e10cSrcweir if ( m_bDisposed ) 833*cdf0e10cSrcweir return; 834*cdf0e10cSrcweir aLock.unlock(); 835*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 836*cdf0e10cSrcweir 837*cdf0e10cSrcweir m_aListenerContainer.removeInterface( 838*cdf0e10cSrcweir ::getCppuType( ( const css::uno::Reference< css::awt::XTabListener >* ) NULL ), xListener ); 839*cdf0e10cSrcweir } 840*cdf0e10cSrcweir 841*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 842*cdf0e10cSrcweir // OPropertySetHelper 843*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 844*cdf0e10cSrcweir 845*cdf0e10cSrcweir // XPropertySet helper 846*cdf0e10cSrcweir sal_Bool SAL_CALL TabWindow::convertFastPropertyValue( css::uno::Any& aConvertedValue , 847*cdf0e10cSrcweir css::uno::Any& aOldValue , 848*cdf0e10cSrcweir sal_Int32 nHandle , 849*cdf0e10cSrcweir const css::uno::Any& aValue ) 850*cdf0e10cSrcweir throw( css::lang::IllegalArgumentException ) 851*cdf0e10cSrcweir { 852*cdf0e10cSrcweir // Initialize state with sal_False !!! 853*cdf0e10cSrcweir // (Handle can be invalid) 854*cdf0e10cSrcweir sal_Bool bReturn = sal_False; 855*cdf0e10cSrcweir 856*cdf0e10cSrcweir switch( nHandle ) 857*cdf0e10cSrcweir { 858*cdf0e10cSrcweir case TABWINDOW_PROPHANDLE_PARENTWINDOW : 859*cdf0e10cSrcweir bReturn = PropHelper::willPropertyBeChanged( 860*cdf0e10cSrcweir com::sun::star::uno::makeAny( m_xContainerWindow ), 861*cdf0e10cSrcweir aValue, 862*cdf0e10cSrcweir aOldValue, 863*cdf0e10cSrcweir aConvertedValue); 864*cdf0e10cSrcweir break; 865*cdf0e10cSrcweir 866*cdf0e10cSrcweir case TABWINDOW_PROPHANDLE_TOPWINDOW : 867*cdf0e10cSrcweir bReturn = PropHelper::willPropertyBeChanged( 868*cdf0e10cSrcweir com::sun::star::uno::makeAny( m_xTopWindow ), 869*cdf0e10cSrcweir aValue, 870*cdf0e10cSrcweir aOldValue, 871*cdf0e10cSrcweir aConvertedValue); 872*cdf0e10cSrcweir break; 873*cdf0e10cSrcweir } 874*cdf0e10cSrcweir 875*cdf0e10cSrcweir // Return state of operation. 876*cdf0e10cSrcweir return bReturn ; 877*cdf0e10cSrcweir } 878*cdf0e10cSrcweir 879*cdf0e10cSrcweir void SAL_CALL TabWindow::setFastPropertyValue_NoBroadcast( sal_Int32, 880*cdf0e10cSrcweir const css::uno::Any&) 881*cdf0e10cSrcweir throw( css::uno::Exception ) 882*cdf0e10cSrcweir { 883*cdf0e10cSrcweir } 884*cdf0e10cSrcweir 885*cdf0e10cSrcweir void SAL_CALL TabWindow::getFastPropertyValue( css::uno::Any& aValue , 886*cdf0e10cSrcweir sal_Int32 nHandle ) const 887*cdf0e10cSrcweir { 888*cdf0e10cSrcweir switch( nHandle ) 889*cdf0e10cSrcweir { 890*cdf0e10cSrcweir case TABWINDOW_PROPHANDLE_PARENTWINDOW: 891*cdf0e10cSrcweir aValue <<= m_xContainerWindow; 892*cdf0e10cSrcweir break; 893*cdf0e10cSrcweir case TABWINDOW_PROPHANDLE_TOPWINDOW: 894*cdf0e10cSrcweir aValue <<= m_xTopWindow; 895*cdf0e10cSrcweir break; 896*cdf0e10cSrcweir } 897*cdf0e10cSrcweir } 898*cdf0e10cSrcweir 899*cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& SAL_CALL TabWindow::getInfoHelper() 900*cdf0e10cSrcweir { 901*cdf0e10cSrcweir // Optimize this method ! 902*cdf0e10cSrcweir // We initialize a static variable only one time. And we don't must use a mutex at every call! 903*cdf0e10cSrcweir // For the first call; pInfoHelper is NULL - for the second call pInfoHelper is different from NULL! 904*cdf0e10cSrcweir static ::cppu::OPropertyArrayHelper* pInfoHelper = NULL; 905*cdf0e10cSrcweir 906*cdf0e10cSrcweir if( pInfoHelper == NULL ) 907*cdf0e10cSrcweir { 908*cdf0e10cSrcweir // Ready for multithreading 909*cdf0e10cSrcweir osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ; 910*cdf0e10cSrcweir 911*cdf0e10cSrcweir // Control this pointer again, another instance can be faster then these! 912*cdf0e10cSrcweir if( pInfoHelper == NULL ) 913*cdf0e10cSrcweir { 914*cdf0e10cSrcweir // Define static member to give structure of properties to baseclass "OPropertySetHelper". 915*cdf0e10cSrcweir // "impl_getStaticPropertyDescriptor" is a non exported and static funtion, who will define a static propertytable. 916*cdf0e10cSrcweir // "sal_True" say: Table is sorted by name. 917*cdf0e10cSrcweir static ::cppu::OPropertyArrayHelper aInfoHelper( impl_getStaticPropertyDescriptor(), sal_True ); 918*cdf0e10cSrcweir pInfoHelper = &aInfoHelper; 919*cdf0e10cSrcweir } 920*cdf0e10cSrcweir } 921*cdf0e10cSrcweir 922*cdf0e10cSrcweir return(*pInfoHelper); 923*cdf0e10cSrcweir } 924*cdf0e10cSrcweir 925*cdf0e10cSrcweir css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL TabWindow::getPropertySetInfo() 926*cdf0e10cSrcweir throw ( css::uno::RuntimeException ) 927*cdf0e10cSrcweir { 928*cdf0e10cSrcweir // Optimize this method ! 929*cdf0e10cSrcweir // We initialize a static variable only one time. And we don't must use a mutex at every call! 930*cdf0e10cSrcweir // For the first call; pInfo is NULL - for the second call pInfo is different from NULL! 931*cdf0e10cSrcweir static css::uno::Reference< css::beans::XPropertySetInfo >* pInfo = NULL; 932*cdf0e10cSrcweir 933*cdf0e10cSrcweir if( pInfo == NULL ) 934*cdf0e10cSrcweir { 935*cdf0e10cSrcweir // Ready for multithreading 936*cdf0e10cSrcweir osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ; 937*cdf0e10cSrcweir // Control this pointer again, another instance can be faster then these! 938*cdf0e10cSrcweir if( pInfo == NULL ) 939*cdf0e10cSrcweir { 940*cdf0e10cSrcweir // Create structure of propertysetinfo for baseclass "OPropertySetHelper". 941*cdf0e10cSrcweir // (Use method "getInfoHelper()".) 942*cdf0e10cSrcweir static css::uno::Reference< css::beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); 943*cdf0e10cSrcweir pInfo = &xInfo; 944*cdf0e10cSrcweir } 945*cdf0e10cSrcweir } 946*cdf0e10cSrcweir 947*cdf0e10cSrcweir return (*pInfo); 948*cdf0e10cSrcweir } 949*cdf0e10cSrcweir 950*cdf0e10cSrcweir const css::uno::Sequence< css::beans::Property > TabWindow::impl_getStaticPropertyDescriptor() 951*cdf0e10cSrcweir { 952*cdf0e10cSrcweir // Create a new static property array to initialize sequence! 953*cdf0e10cSrcweir // Table of all predefined properties of this class. Its used from OPropertySetHelper-class! 954*cdf0e10cSrcweir // Don't forget to change the defines (see begin of this file), if you add, change or delete a property in this list!!! 955*cdf0e10cSrcweir // It's necessary for methods of OPropertySetHelper. 956*cdf0e10cSrcweir // ATTENTION: 957*cdf0e10cSrcweir // YOU MUST SORT FOLLOW TABLE BY NAME ALPHABETICAL !!! 958*cdf0e10cSrcweir 959*cdf0e10cSrcweir static const com::sun::star::beans::Property pProperties[] = 960*cdf0e10cSrcweir { 961*cdf0e10cSrcweir com::sun::star::beans::Property( TABWINDOW_PROPNAME_PARENTWINDOW, 962*cdf0e10cSrcweir TABWINDOW_PROPHANDLE_PARENTWINDOW, 963*cdf0e10cSrcweir ::getCppuType((const css::uno::Reference< css::awt::XWindow >*)NULL), 964*cdf0e10cSrcweir com::sun::star::beans::PropertyAttribute::READONLY ), 965*cdf0e10cSrcweir com::sun::star::beans::Property( TABWINDOW_PROPNAME_TOPWINDOW, 966*cdf0e10cSrcweir TABWINDOW_PROPHANDLE_TOPWINDOW, 967*cdf0e10cSrcweir ::getCppuType((const css::uno::Reference< css::awt::XWindow >*)NULL), 968*cdf0e10cSrcweir com::sun::star::beans::PropertyAttribute::READONLY ) 969*cdf0e10cSrcweir }; // Use it to initialize sequence! 970*cdf0e10cSrcweir static const com::sun::star::uno::Sequence< com::sun::star::beans::Property > lPropertyDescriptor( pProperties, TABWINDOW_PROPCOUNT ); 971*cdf0e10cSrcweir 972*cdf0e10cSrcweir // Return static "PropertyDescriptor" 973*cdf0e10cSrcweir return lPropertyDescriptor; 974*cdf0e10cSrcweir } 975*cdf0e10cSrcweir 976*cdf0e10cSrcweir } 977