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_toolkit.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <toolkit/controls/geometrycontrolmodel.hxx> 32*cdf0e10cSrcweir #include <toolkit/controls/tabpagecontainer.hxx> 33*cdf0e10cSrcweir #include <toolkit/controls/tabpagemodel.hxx> 34*cdf0e10cSrcweir #include <toolkit/helper/property.hxx> 35*cdf0e10cSrcweir #include <toolkit/helper/unopropertyarrayhelper.hxx> 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #include <com/sun/star/awt/XControlModel.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/awt/XVclWindowPeer.hpp> 39*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 42*cdf0e10cSrcweir #include <osl/diagnose.h> 43*cdf0e10cSrcweir #include <tools/diagnose_ex.h> 44*cdf0e10cSrcweir #include <vcl/svapp.hxx> 45*cdf0e10cSrcweir #include <vos/mutex.hxx> 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir using ::rtl::OUString; 48*cdf0e10cSrcweir using namespace ::com::sun::star; 49*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 50*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 51*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 52*cdf0e10cSrcweir using namespace ::com::sun::star::container; 53*cdf0e10cSrcweir using namespace ::com::sun::star::view; 54*cdf0e10cSrcweir using ::com::sun::star::awt::tab::XTabPageModel; 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir #define WRONG_TYPE_EXCEPTION "Type must be ::com::sun::star::awt::tab::XTabPageModel!" 57*cdf0e10cSrcweir // ---------------------------------------------------- 58*cdf0e10cSrcweir // class UnoControlTabPageContainerModel 59*cdf0e10cSrcweir // ---------------------------------------------------- 60*cdf0e10cSrcweir UnoControlTabPageContainerModel::UnoControlTabPageContainerModel( const Reference< XMultiServiceFactory >& i_factory ) 61*cdf0e10cSrcweir :UnoControlTabPageContainerModel_Base( i_factory ) 62*cdf0e10cSrcweir ,maContainerListeners( *this ) 63*cdf0e10cSrcweir { 64*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR ); 65*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_BORDER ); 66*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR ); 67*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL ); 68*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_ENABLED ); 69*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_HELPTEXT ); 70*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_HELPURL ); 71*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_PRINTABLE ); 72*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_TEXT ); 73*cdf0e10cSrcweir } 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir ::rtl::OUString UnoControlTabPageContainerModel::getServiceName() throw(RuntimeException) 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( szServiceName_UnoControlTabPageContainerModel ); 78*cdf0e10cSrcweir } 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir uno::Any UnoControlTabPageContainerModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const 81*cdf0e10cSrcweir { 82*cdf0e10cSrcweir switch(nPropId) 83*cdf0e10cSrcweir { 84*cdf0e10cSrcweir case BASEPROPERTY_DEFAULTCONTROL: 85*cdf0e10cSrcweir return uno::makeAny( ::rtl::OUString::createFromAscii( szServiceName_UnoControlTabPageContainer ) ); 86*cdf0e10cSrcweir case BASEPROPERTY_BORDER: 87*cdf0e10cSrcweir return uno::makeAny((sal_Int16) 0); // No Border 88*cdf0e10cSrcweir default: 89*cdf0e10cSrcweir return UnoControlModel::ImplGetDefaultValue( nPropId ); 90*cdf0e10cSrcweir } 91*cdf0e10cSrcweir } 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& UnoControlTabPageContainerModel::getInfoHelper() 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir static UnoPropertyArrayHelper* pHelper = NULL; 96*cdf0e10cSrcweir if ( !pHelper ) 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir com::sun::star::uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds(); 99*cdf0e10cSrcweir pHelper = new UnoPropertyArrayHelper( aIDs ); 100*cdf0e10cSrcweir } 101*cdf0e10cSrcweir return *pHelper; 102*cdf0e10cSrcweir } 103*cdf0e10cSrcweir Reference< ::com::sun::star::beans::XPropertySetInfo > UnoControlTabPageContainerModel::getPropertySetInfo( ) throw(RuntimeException) 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir static Reference< ::com::sun::star::beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); 106*cdf0e10cSrcweir return xInfo; 107*cdf0e10cSrcweir } 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir namespace 110*cdf0e10cSrcweir { 111*cdf0e10cSrcweir Reference< XTabPageModel > lcl_createTabPageModel( ::comphelper::ComponentContext const & i_context, 112*cdf0e10cSrcweir Sequence< Any > const & i_initArguments, Reference< XPropertySet > const & i_parentModel ) 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir try 115*cdf0e10cSrcweir { 116*cdf0e10cSrcweir Reference< XPropertySet > const xParentDelegator( i_parentModel, UNO_QUERY_THROW ); 117*cdf0e10cSrcweir Reference< XPropertySetInfo > const xPSI( xParentDelegator->getPropertySetInfo() ); 118*cdf0e10cSrcweir bool const isGeometryControlModel = xPSI.is() && xPSI->hasPropertyByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PositionX" ) ) ); 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir Reference< XInterface > xInstance; 121*cdf0e10cSrcweir if ( isGeometryControlModel ) 122*cdf0e10cSrcweir xInstance = *( new OGeometryControlModel< UnoControlTabPageModel >( i_context.getLegacyServiceFactory() ) ); 123*cdf0e10cSrcweir else 124*cdf0e10cSrcweir xInstance = *( new UnoControlTabPageModel( i_context.getLegacyServiceFactory() ) ); 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir Reference< XTabPageModel > const xTabPageModel( xInstance, UNO_QUERY_THROW ); 127*cdf0e10cSrcweir Reference< XInitialization > const xInit( xTabPageModel, UNO_QUERY_THROW ); 128*cdf0e10cSrcweir xInit->initialize( i_initArguments ); 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir return xTabPageModel; 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir catch( const RuntimeException& ) 133*cdf0e10cSrcweir { 134*cdf0e10cSrcweir throw; 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir catch( const Exception& ) 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir return NULL; 141*cdf0e10cSrcweir } 142*cdf0e10cSrcweir } 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir Reference< XTabPageModel > SAL_CALL UnoControlTabPageContainerModel::createTabPage( ::sal_Int16 i_tabPageID ) throw (RuntimeException) 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir Sequence< Any > aInitArgs(1); 147*cdf0e10cSrcweir aInitArgs[0] <<= i_tabPageID; 148*cdf0e10cSrcweir return lcl_createTabPageModel( maContext, aInitArgs, this ); 149*cdf0e10cSrcweir } 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir Reference< XTabPageModel > SAL_CALL UnoControlTabPageContainerModel::loadTabPage( ::sal_Int16 i_tabPageID, const ::rtl::OUString& i_resourceURL ) throw (RuntimeException) 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir Sequence< Any > aInitArgs(2); 154*cdf0e10cSrcweir aInitArgs[0] <<= i_tabPageID; 155*cdf0e10cSrcweir aInitArgs[1] <<= i_resourceURL; 156*cdf0e10cSrcweir return lcl_createTabPageModel( maContext, aInitArgs, this ); 157*cdf0e10cSrcweir } 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir void SAL_CALL UnoControlTabPageContainerModel::insertByIndex( ::sal_Int32 nIndex, const com::sun::star::uno::Any& aElement) throw (IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, uno::RuntimeException) 160*cdf0e10cSrcweir { 161*cdf0e10cSrcweir vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 162*cdf0e10cSrcweir uno::Reference < XTabPageModel > xTabPageModel; 163*cdf0e10cSrcweir if(aElement >>= xTabPageModel) 164*cdf0e10cSrcweir { 165*cdf0e10cSrcweir if ( sal_Int32( m_aTabPageVector.size()) ==nIndex ) 166*cdf0e10cSrcweir m_aTabPageVector.push_back( xTabPageModel ); 167*cdf0e10cSrcweir else if ( sal_Int32( m_aTabPageVector.size()) > nIndex ) 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir std::vector< uno::Reference< XTabPageModel > >::iterator aIter = m_aTabPageVector.begin(); 170*cdf0e10cSrcweir aIter += nIndex; 171*cdf0e10cSrcweir m_aTabPageVector.insert( aIter, xTabPageModel ); 172*cdf0e10cSrcweir } 173*cdf0e10cSrcweir else 174*cdf0e10cSrcweir throw IndexOutOfBoundsException( ::rtl::OUString(), (OWeakObject *)this ); 175*cdf0e10cSrcweir ContainerEvent aEvent; 176*cdf0e10cSrcweir aEvent.Source = *this; 177*cdf0e10cSrcweir aEvent.Element <<= aElement; 178*cdf0e10cSrcweir aEvent.Accessor <<= ::rtl::OUString::valueOf(nIndex); 179*cdf0e10cSrcweir maContainerListeners.elementInserted( aEvent ); 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir else 182*cdf0e10cSrcweir throw IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( WRONG_TYPE_EXCEPTION )), 183*cdf0e10cSrcweir (OWeakObject *)this, 2 ); 184*cdf0e10cSrcweir } 185*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 186*cdf0e10cSrcweir void SAL_CALL UnoControlTabPageContainerModel::removeByIndex( ::sal_Int32 /*Index*/ ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) 187*cdf0e10cSrcweir { 188*cdf0e10cSrcweir } 189*cdf0e10cSrcweir // XIndexReplace 190*cdf0e10cSrcweir void SAL_CALL UnoControlTabPageContainerModel::replaceByIndex( ::sal_Int32 /*Index*/, const uno::Any& /*Element*/ ) throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) 191*cdf0e10cSrcweir { 192*cdf0e10cSrcweir } 193*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 194*cdf0e10cSrcweir // XIndexAccess 195*cdf0e10cSrcweir ::sal_Int32 SAL_CALL UnoControlTabPageContainerModel::getCount( ) throw (uno::RuntimeException) 196*cdf0e10cSrcweir { 197*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 198*cdf0e10cSrcweir return sal_Int32( m_aTabPageVector.size()); 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 201*cdf0e10cSrcweir uno::Any SAL_CALL UnoControlTabPageContainerModel::getByIndex( ::sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) 202*cdf0e10cSrcweir { 203*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 204*cdf0e10cSrcweir if ( nIndex < 0 || nIndex > sal_Int32(m_aTabPageVector.size()) ) 205*cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 206*cdf0e10cSrcweir return uno::makeAny(m_aTabPageVector[nIndex]); 207*cdf0e10cSrcweir } 208*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 209*cdf0e10cSrcweir // XElementAccess 210*cdf0e10cSrcweir uno::Type SAL_CALL UnoControlTabPageContainerModel::getElementType( ) throw (uno::RuntimeException) 211*cdf0e10cSrcweir { 212*cdf0e10cSrcweir return ::getCppuType(static_cast< Reference< com::sun::star::awt::XControlModel>* >(NULL)); 213*cdf0e10cSrcweir } 214*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 215*cdf0e10cSrcweir ::sal_Bool SAL_CALL UnoControlTabPageContainerModel::hasElements( ) throw (uno::RuntimeException) 216*cdf0e10cSrcweir { 217*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 218*cdf0e10cSrcweir return !m_aTabPageVector.empty(); 219*cdf0e10cSrcweir } 220*cdf0e10cSrcweir // XContainer 221*cdf0e10cSrcweir void UnoControlTabPageContainerModel::addContainerListener( const Reference< XContainerListener >& l ) throw(RuntimeException) 222*cdf0e10cSrcweir { 223*cdf0e10cSrcweir maContainerListeners.addInterface( l ); 224*cdf0e10cSrcweir } 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir void UnoControlTabPageContainerModel::removeContainerListener( const Reference< XContainerListener >& l ) throw(RuntimeException) 227*cdf0e10cSrcweir { 228*cdf0e10cSrcweir maContainerListeners.removeInterface( l ); 229*cdf0e10cSrcweir } 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir // ---------------------------------------------------- 232*cdf0e10cSrcweir // class UnoControlTabPageContainer 233*cdf0e10cSrcweir // ---------------------------------------------------- 234*cdf0e10cSrcweir UnoControlTabPageContainer::UnoControlTabPageContainer( const Reference< XMultiServiceFactory >& i_factory ) 235*cdf0e10cSrcweir :UnoControlTabPageContainer_Base( i_factory ) 236*cdf0e10cSrcweir ,m_aTabPageListeners( *this ) 237*cdf0e10cSrcweir { 238*cdf0e10cSrcweir } 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir OUString UnoControlTabPageContainer::GetComponentServiceName() 241*cdf0e10cSrcweir { 242*cdf0e10cSrcweir return OUString::createFromAscii( "TabPageContainer" ); 243*cdf0e10cSrcweir } 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir void SAL_CALL UnoControlTabPageContainer::dispose( ) throw(RuntimeException) 246*cdf0e10cSrcweir { 247*cdf0e10cSrcweir lang::EventObject aEvt; 248*cdf0e10cSrcweir aEvt.Source = (::cppu::OWeakObject*)this; 249*cdf0e10cSrcweir m_aTabPageListeners.disposeAndClear( aEvt ); 250*cdf0e10cSrcweir UnoControl::dispose(); 251*cdf0e10cSrcweir } 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir void UnoControlTabPageContainer::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException) 254*cdf0e10cSrcweir { 255*cdf0e10cSrcweir UnoControlBase::createPeer( rxToolkit, rParentPeer ); 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir Reference< XTabPageContainer > xTPContainer( getPeer(), UNO_QUERY_THROW ); 258*cdf0e10cSrcweir if ( m_aTabPageListeners.getLength() ) 259*cdf0e10cSrcweir xTPContainer->addTabPageContainerListener(&m_aTabPageListeners); 260*cdf0e10cSrcweir } 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir // ------------------------------------------------------------------- 263*cdf0e10cSrcweir // XTabPageContainer 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir ::sal_Int16 SAL_CALL UnoControlTabPageContainer::getActiveTabPageID() throw (RuntimeException) 266*cdf0e10cSrcweir { 267*cdf0e10cSrcweir vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 268*cdf0e10cSrcweir Reference< XTabPageContainer > xTPContainer( getPeer(), UNO_QUERY_THROW ); 269*cdf0e10cSrcweir return xTPContainer->getActiveTabPageID(); 270*cdf0e10cSrcweir } 271*cdf0e10cSrcweir void SAL_CALL UnoControlTabPageContainer::setActiveTabPageID( ::sal_Int16 _activetabpageid ) throw (RuntimeException) 272*cdf0e10cSrcweir { 273*cdf0e10cSrcweir vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 274*cdf0e10cSrcweir Reference< XTabPageContainer > xTPContainer( getPeer(), UNO_QUERY_THROW ); 275*cdf0e10cSrcweir xTPContainer->setActiveTabPageID(_activetabpageid); 276*cdf0e10cSrcweir } 277*cdf0e10cSrcweir ::sal_Int16 SAL_CALL UnoControlTabPageContainer::getTabPageCount( ) throw (RuntimeException) 278*cdf0e10cSrcweir { 279*cdf0e10cSrcweir vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 280*cdf0e10cSrcweir Reference< XTabPageContainer > xTPContainer( getPeer(), UNO_QUERY_THROW ); 281*cdf0e10cSrcweir return xTPContainer->getTabPageCount(); 282*cdf0e10cSrcweir } 283*cdf0e10cSrcweir ::sal_Bool SAL_CALL UnoControlTabPageContainer::isTabPageActive( ::sal_Int16 tabPageIndex ) throw (RuntimeException) 284*cdf0e10cSrcweir { 285*cdf0e10cSrcweir vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 286*cdf0e10cSrcweir Reference< XTabPageContainer > xTPContainer( getPeer(), UNO_QUERY_THROW ); 287*cdf0e10cSrcweir return xTPContainer->isTabPageActive(tabPageIndex); 288*cdf0e10cSrcweir } 289*cdf0e10cSrcweir Reference< ::com::sun::star::awt::tab::XTabPage > SAL_CALL UnoControlTabPageContainer::getTabPage( ::sal_Int16 tabPageIndex ) throw (RuntimeException) 290*cdf0e10cSrcweir { 291*cdf0e10cSrcweir vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 292*cdf0e10cSrcweir Reference< XTabPageContainer > xTPContainer( getPeer(), UNO_QUERY_THROW ); 293*cdf0e10cSrcweir return xTPContainer->getTabPage(tabPageIndex); 294*cdf0e10cSrcweir } 295*cdf0e10cSrcweir Reference< ::com::sun::star::awt::tab::XTabPage > SAL_CALL UnoControlTabPageContainer::getTabPageByID( ::sal_Int16 tabPageID ) throw (RuntimeException) 296*cdf0e10cSrcweir { 297*cdf0e10cSrcweir vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 298*cdf0e10cSrcweir Reference< XTabPageContainer > xTPContainer( getPeer(), UNO_QUERY_THROW ); 299*cdf0e10cSrcweir return xTPContainer->getTabPageByID(tabPageID); 300*cdf0e10cSrcweir } 301*cdf0e10cSrcweir void SAL_CALL UnoControlTabPageContainer::addTabPageContainerListener( const Reference< ::com::sun::star::awt::tab::XTabPageContainerListener >& listener ) throw (RuntimeException) 302*cdf0e10cSrcweir { 303*cdf0e10cSrcweir m_aTabPageListeners.addInterface( listener ); 304*cdf0e10cSrcweir if( getPeer().is() && m_aTabPageListeners.getLength() == 1 ) 305*cdf0e10cSrcweir { 306*cdf0e10cSrcweir uno::Reference < awt::tab::XTabPageContainer > xTabPageContainer( getPeer(), uno::UNO_QUERY ); 307*cdf0e10cSrcweir xTabPageContainer->addTabPageContainerListener( &m_aTabPageListeners ); 308*cdf0e10cSrcweir } 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir void SAL_CALL UnoControlTabPageContainer::removeTabPageContainerListener( const Reference< ::com::sun::star::awt::tab::XTabPageContainerListener >& listener ) throw (RuntimeException) 311*cdf0e10cSrcweir { 312*cdf0e10cSrcweir if( getPeer().is() && m_aTabPageListeners.getLength() == 1 ) 313*cdf0e10cSrcweir { 314*cdf0e10cSrcweir uno::Reference < awt::tab::XTabPageContainer > xTabPageContainer( getPeer(), uno::UNO_QUERY ); 315*cdf0e10cSrcweir xTabPageContainer->addTabPageContainerListener( &m_aTabPageListeners ); 316*cdf0e10cSrcweir } 317*cdf0e10cSrcweir m_aTabPageListeners.removeInterface( listener ); 318*cdf0e10cSrcweir } 319*cdf0e10cSrcweir 320*cdf0e10cSrcweir void UnoControlTabPageContainer::updateFromModel() 321*cdf0e10cSrcweir { 322*cdf0e10cSrcweir UnoControlTabPageContainer_Base::updateFromModel(); 323*cdf0e10cSrcweir Reference< XContainerListener > xContainerListener( getPeer(), UNO_QUERY ); 324*cdf0e10cSrcweir ENSURE_OR_RETURN_VOID( xContainerListener.is(), "UnoListBoxControl::updateFromModel: a peer which is no ItemListListener?!" ); 325*cdf0e10cSrcweir 326*cdf0e10cSrcweir ContainerEvent aEvent; 327*cdf0e10cSrcweir aEvent.Source = getModel(); 328*cdf0e10cSrcweir Sequence< Reference< XControl > > aControls = getControls(); 329*cdf0e10cSrcweir const Reference< XControl >* pCtrls = aControls.getConstArray(); 330*cdf0e10cSrcweir const Reference< XControl >* pCtrlsEnd = pCtrls + aControls.getLength(); 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir for ( ; pCtrls < pCtrlsEnd; ++pCtrls ) 333*cdf0e10cSrcweir { 334*cdf0e10cSrcweir aEvent.Element <<= *pCtrls; 335*cdf0e10cSrcweir xContainerListener->elementInserted( aEvent ); 336*cdf0e10cSrcweir } 337*cdf0e10cSrcweir } 338*cdf0e10cSrcweir void SAL_CALL UnoControlTabPageContainer::addControl( const ::rtl::OUString& Name, const Reference< ::com::sun::star::awt::XControl >& Control ) throw (RuntimeException) 339*cdf0e10cSrcweir { 340*cdf0e10cSrcweir vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 341*cdf0e10cSrcweir ControlContainerBase::addControl(Name,Control); 342*cdf0e10cSrcweir Reference< XContainerListener > xContainerListener( getPeer(), UNO_QUERY ); 343*cdf0e10cSrcweir ContainerEvent aEvent; 344*cdf0e10cSrcweir aEvent.Source = getModel(); 345*cdf0e10cSrcweir aEvent.Element <<= Control; 346*cdf0e10cSrcweir xContainerListener->elementInserted( aEvent ); 347*cdf0e10cSrcweir } 348*cdf0e10cSrcweir 349