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 //____________________________________________________________________________________________________________ 29*cdf0e10cSrcweir // my own includes 30*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir #include "basecontainercontrol.hxx" 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 35*cdf0e10cSrcweir // includes of other projects 36*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 37*cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx> 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 40*cdf0e10cSrcweir // includes of my own project 41*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 44*cdf0e10cSrcweir // namespaces 45*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir using namespace ::cppu ; 48*cdf0e10cSrcweir using namespace ::osl ; 49*cdf0e10cSrcweir using namespace ::rtl ; 50*cdf0e10cSrcweir using namespace ::com::sun::star::uno ; 51*cdf0e10cSrcweir using namespace ::com::sun::star::lang ; 52*cdf0e10cSrcweir using namespace ::com::sun::star::awt ; 53*cdf0e10cSrcweir using namespace ::com::sun::star::container ; 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir namespace unocontrols{ 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 58*cdf0e10cSrcweir // construct/destruct 59*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir BaseContainerControl::BaseContainerControl( const Reference< XMultiServiceFactory >& xFactory ) 62*cdf0e10cSrcweir : BaseControl ( xFactory ) 63*cdf0e10cSrcweir , m_aListeners ( m_aMutex ) 64*cdf0e10cSrcweir { 65*cdf0e10cSrcweir // initialize info list for controls 66*cdf0e10cSrcweir m_pControlInfoList = new IMPL_ControlInfoList ; 67*cdf0e10cSrcweir } 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir BaseContainerControl::~BaseContainerControl() 70*cdf0e10cSrcweir { 71*cdf0e10cSrcweir impl_cleanMemory(); 72*cdf0e10cSrcweir } 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 75*cdf0e10cSrcweir // XInterface 76*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir Any SAL_CALL BaseContainerControl::queryInterface( const Type& rType ) throw( RuntimeException ) 79*cdf0e10cSrcweir { 80*cdf0e10cSrcweir // Attention: 81*cdf0e10cSrcweir // Don't use mutex or guard in this method!!! Is a method of XInterface. 82*cdf0e10cSrcweir Any aReturn ; 83*cdf0e10cSrcweir Reference< XInterface > xDel = BaseControl::impl_getDelegator(); 84*cdf0e10cSrcweir if ( xDel.is() == sal_True ) 85*cdf0e10cSrcweir { 86*cdf0e10cSrcweir // If an delegator exist, forward question to his queryInterface. 87*cdf0e10cSrcweir // Delegator will ask his own queryAggregation! 88*cdf0e10cSrcweir aReturn = xDel->queryInterface( rType ); 89*cdf0e10cSrcweir } 90*cdf0e10cSrcweir else 91*cdf0e10cSrcweir { 92*cdf0e10cSrcweir // If an delegator unknown, forward question to own queryAggregation. 93*cdf0e10cSrcweir aReturn = queryAggregation( rType ); 94*cdf0e10cSrcweir } 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir return aReturn ; 97*cdf0e10cSrcweir } 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 100*cdf0e10cSrcweir // XTypeProvider 101*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir Sequence< Type > SAL_CALL BaseContainerControl::getTypes() throw( RuntimeException ) 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir // Optimize this method ! 106*cdf0e10cSrcweir // We initialize a static variable only one time. And we don't must use a mutex at every call! 107*cdf0e10cSrcweir // For the first call; pTypeCollection is NULL - for the second call pTypeCollection is different from NULL! 108*cdf0e10cSrcweir static OTypeCollection* pTypeCollection = NULL ; 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir if ( pTypeCollection == NULL ) 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir // Ready for multithreading; get global mutex for first call of this method only! see before 113*cdf0e10cSrcweir MutexGuard aGuard( Mutex::getGlobalMutex() ); 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir // Control these pointer again ... it can be, that another instance will be faster then these! 116*cdf0e10cSrcweir if ( pTypeCollection == NULL ) 117*cdf0e10cSrcweir { 118*cdf0e10cSrcweir // Create a static typecollection ... 119*cdf0e10cSrcweir static OTypeCollection aTypeCollection ( ::getCppuType(( const Reference< XControlModel >*)NULL ) , 120*cdf0e10cSrcweir ::getCppuType(( const Reference< XControlContainer >*)NULL ) , 121*cdf0e10cSrcweir BaseControl::getTypes() 122*cdf0e10cSrcweir ); 123*cdf0e10cSrcweir // ... and set his address to static pointer! 124*cdf0e10cSrcweir pTypeCollection = &aTypeCollection ; 125*cdf0e10cSrcweir } 126*cdf0e10cSrcweir } 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir return pTypeCollection->getTypes(); 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 132*cdf0e10cSrcweir // XAggregation 133*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir Any SAL_CALL BaseContainerControl::queryAggregation( const Type& aType ) throw( RuntimeException ) 136*cdf0e10cSrcweir { 137*cdf0e10cSrcweir // Ask for my own supported interfaces ... 138*cdf0e10cSrcweir // Attention: XTypeProvider and XInterface are supported by OComponentHelper! 139*cdf0e10cSrcweir Any aReturn ( ::cppu::queryInterface( aType , 140*cdf0e10cSrcweir static_cast< XControlModel* > ( this ) , 141*cdf0e10cSrcweir static_cast< XControlContainer* > ( this ) 142*cdf0e10cSrcweir ) 143*cdf0e10cSrcweir ); 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir // If searched interface supported by this class ... 146*cdf0e10cSrcweir if ( aReturn.hasValue() == sal_True ) 147*cdf0e10cSrcweir { 148*cdf0e10cSrcweir // ... return this information. 149*cdf0e10cSrcweir return aReturn ; 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir else 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir // Else; ... ask baseclass for interfaces! 154*cdf0e10cSrcweir return BaseControl::queryAggregation( aType ); 155*cdf0e10cSrcweir } 156*cdf0e10cSrcweir } 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 159*cdf0e10cSrcweir // XControl 160*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir void SAL_CALL BaseContainerControl::createPeer( const Reference< XToolkit >& xToolkit , 163*cdf0e10cSrcweir const Reference< XWindowPeer >& xParent ) throw( RuntimeException ) 164*cdf0e10cSrcweir { 165*cdf0e10cSrcweir if ( getPeer().is() == sal_False ) 166*cdf0e10cSrcweir { 167*cdf0e10cSrcweir // create own peer 168*cdf0e10cSrcweir BaseControl::createPeer( xToolkit, xParent ); 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir // create peers at all childs 171*cdf0e10cSrcweir Sequence< Reference< XControl > > seqControlList = getControls(); 172*cdf0e10cSrcweir sal_uInt32 nControls = seqControlList.getLength(); 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir for ( sal_uInt32 n=0; n<nControls; n++ ) 175*cdf0e10cSrcweir { 176*cdf0e10cSrcweir seqControlList.getArray()[n]->createPeer( xToolkit, getPeer() ); 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir // activate new tab order 180*cdf0e10cSrcweir impl_activateTabControllers(); 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir /* 183*cdf0e10cSrcweir Reference< XVclContainerPeer > xC; 184*cdf0e10cSrcweir mxPeer->queryInterface( ::getCppuType((const Reference< XVclContainerPeer >*)0), xC ); 185*cdf0e10cSrcweir xC->enableDialogControl( sal_True ); 186*cdf0e10cSrcweir */ 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir } 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 192*cdf0e10cSrcweir // XControl 193*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir sal_Bool SAL_CALL BaseContainerControl::setModel( const Reference< XControlModel >& ) throw( RuntimeException ) 196*cdf0e10cSrcweir { 197*cdf0e10cSrcweir // This object has NO model. 198*cdf0e10cSrcweir return sal_False ; 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 202*cdf0e10cSrcweir // XControl 203*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir Reference< XControlModel > SAL_CALL BaseContainerControl::getModel() throw( RuntimeException ) 206*cdf0e10cSrcweir { 207*cdf0e10cSrcweir // This object has NO model. 208*cdf0e10cSrcweir // return (XControlModel*)this ; 209*cdf0e10cSrcweir return Reference< XControlModel >(); 210*cdf0e10cSrcweir } 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 213*cdf0e10cSrcweir // XComponent 214*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir void SAL_CALL BaseContainerControl::dispose() throw( RuntimeException ) 217*cdf0e10cSrcweir { 218*cdf0e10cSrcweir // Zuerst der Welt mitteilen, da� der Container wegfliegt. Dieses ist um einiges 219*cdf0e10cSrcweir // schneller wenn die Welt sowohl an den Controls als auch am Container horcht 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir // Ready for multithreading 222*cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir // remove listeners 225*cdf0e10cSrcweir EventObject aObject ; 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir aObject.Source = Reference< XComponent > ( (XControlContainer*)this, UNO_QUERY ); 228*cdf0e10cSrcweir m_aListeners.disposeAndClear( aObject ); 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir // remove controls 231*cdf0e10cSrcweir Sequence< Reference< XControl > > seqCtrls = getControls(); 232*cdf0e10cSrcweir Reference< XControl > * pCtrls = seqCtrls.getArray(); 233*cdf0e10cSrcweir sal_uInt32 nCtrls = seqCtrls.getLength(); 234*cdf0e10cSrcweir sal_uInt32 nMaxCount = m_pControlInfoList->Count(); 235*cdf0e10cSrcweir sal_uInt32 nCount = 0; 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir for ( nCount = 0; nCount < nMaxCount; ++nCount ) 238*cdf0e10cSrcweir { 239*cdf0e10cSrcweir delete m_pControlInfoList->GetObject( 0 ); 240*cdf0e10cSrcweir } 241*cdf0e10cSrcweir m_pControlInfoList->Clear(); 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir for ( nCount = 0; nCount < nCtrls; ++nCount ) 245*cdf0e10cSrcweir { 246*cdf0e10cSrcweir pCtrls [ nCount ] -> removeEventListener ( static_cast< XEventListener* >( static_cast< XWindowListener* >( this ) ) ) ; 247*cdf0e10cSrcweir pCtrls [ nCount ] -> dispose ( ) ; 248*cdf0e10cSrcweir } 249*cdf0e10cSrcweir 250*cdf0e10cSrcweir // call baseclass 251*cdf0e10cSrcweir BaseControl::dispose(); 252*cdf0e10cSrcweir } 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 255*cdf0e10cSrcweir // XEventListener 256*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir void SAL_CALL BaseContainerControl::disposing( const EventObject& rEvent ) throw( RuntimeException ) 259*cdf0e10cSrcweir { 260*cdf0e10cSrcweir Reference< XControl > xControl( rEvent.Source, UNO_QUERY ); 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir // "removeControl" remove only, when control is an active control 263*cdf0e10cSrcweir removeControl( xControl ); 264*cdf0e10cSrcweir } 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 267*cdf0e10cSrcweir // XControlContainer 268*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir void SAL_CALL BaseContainerControl::addControl ( const OUString& rName, const Reference< XControl > & rControl ) throw( RuntimeException ) 271*cdf0e10cSrcweir { 272*cdf0e10cSrcweir if ( !rControl.is () ) 273*cdf0e10cSrcweir return; 274*cdf0e10cSrcweir 275*cdf0e10cSrcweir // take memory for new item 276*cdf0e10cSrcweir IMPL_ControlInfo* pNewControl = new IMPL_ControlInfo ; 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir if (pNewControl!=(IMPL_ControlInfo*)0) 279*cdf0e10cSrcweir { 280*cdf0e10cSrcweir // Ready for multithreading 281*cdf0e10cSrcweir MutexGuard aGuard (m_aMutex) ; 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir // set control 284*cdf0e10cSrcweir pNewControl->sName = rName ; 285*cdf0e10cSrcweir pNewControl->xControl = rControl ; 286*cdf0e10cSrcweir 287*cdf0e10cSrcweir // and insert in list 288*cdf0e10cSrcweir m_pControlInfoList->Insert ( pNewControl, LIST_APPEND ) ; 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir // initialize new control 291*cdf0e10cSrcweir pNewControl->xControl->setContext ( (OWeakObject*)this ) ; 292*cdf0e10cSrcweir pNewControl->xControl->addEventListener ( static_cast< XEventListener* >( static_cast< XWindowListener* >( this ) ) ) ; 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir // when container has a peer ... 295*cdf0e10cSrcweir if (getPeer().is()) 296*cdf0e10cSrcweir { 297*cdf0e10cSrcweir // .. then create a peer on child 298*cdf0e10cSrcweir pNewControl->xControl->createPeer ( getPeer()->getToolkit(), getPeer() ) ; 299*cdf0e10cSrcweir impl_activateTabControllers () ; 300*cdf0e10cSrcweir } 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir // Send message to all listener 303*cdf0e10cSrcweir OInterfaceContainerHelper* pInterfaceContainer = m_aListeners.getContainer( ::getCppuType((const Reference< XContainerListener >*)0) ) ; 304*cdf0e10cSrcweir 305*cdf0e10cSrcweir if (pInterfaceContainer) 306*cdf0e10cSrcweir { 307*cdf0e10cSrcweir // Build event 308*cdf0e10cSrcweir ContainerEvent aEvent ; 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir aEvent.Source = *this ; 311*cdf0e10cSrcweir aEvent.Element <<= rControl ; 312*cdf0e10cSrcweir 313*cdf0e10cSrcweir // Get all listener 314*cdf0e10cSrcweir OInterfaceIteratorHelper aIterator (*pInterfaceContainer) ; 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir // Send event 317*cdf0e10cSrcweir while ( aIterator.hasMoreElements() ) 318*cdf0e10cSrcweir { 319*cdf0e10cSrcweir ((XContainerListener*)aIterator.next())->elementInserted (aEvent) ; 320*cdf0e10cSrcweir } 321*cdf0e10cSrcweir } 322*cdf0e10cSrcweir } 323*cdf0e10cSrcweir } 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 326*cdf0e10cSrcweir // XControlContainer 327*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir void SAL_CALL BaseContainerControl::addContainerListener ( const Reference< XContainerListener > & rListener ) throw( RuntimeException ) 330*cdf0e10cSrcweir { 331*cdf0e10cSrcweir // Ready for multithreading 332*cdf0e10cSrcweir MutexGuard aGuard ( m_aMutex ) ; 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir m_aListeners.addInterface ( ::getCppuType((const Reference< XContainerListener >*)0), rListener ) ; 335*cdf0e10cSrcweir } 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 338*cdf0e10cSrcweir // XControlContainer 339*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 340*cdf0e10cSrcweir 341*cdf0e10cSrcweir void SAL_CALL BaseContainerControl::removeControl ( const Reference< XControl > & rControl ) throw( RuntimeException ) 342*cdf0e10cSrcweir { 343*cdf0e10cSrcweir if ( rControl.is() ) 344*cdf0e10cSrcweir { 345*cdf0e10cSrcweir // Ready for multithreading 346*cdf0e10cSrcweir MutexGuard aGuard (m_aMutex) ; 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir sal_uInt32 nControls = m_pControlInfoList->Count () ; 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir for ( sal_uInt32 n=0; n<nControls; n++ ) 351*cdf0e10cSrcweir { 352*cdf0e10cSrcweir // Search for right control 353*cdf0e10cSrcweir IMPL_ControlInfo* pControl = m_pControlInfoList->GetObject (n) ; 354*cdf0e10cSrcweir if ( rControl == pControl->xControl ) 355*cdf0e10cSrcweir { 356*cdf0e10cSrcweir //.is it found ... remove listener from control 357*cdf0e10cSrcweir pControl->xControl->removeEventListener (static_cast< XEventListener* >( static_cast< XWindowListener* >( this ) )) ; 358*cdf0e10cSrcweir pControl->xControl->setContext ( Reference< XInterface > () ) ; 359*cdf0e10cSrcweir 360*cdf0e10cSrcweir // ... free memory 361*cdf0e10cSrcweir delete pControl ; 362*cdf0e10cSrcweir m_pControlInfoList->Remove (n) ; 363*cdf0e10cSrcweir 364*cdf0e10cSrcweir // Send message to all other listener 365*cdf0e10cSrcweir OInterfaceContainerHelper * pInterfaceContainer = m_aListeners.getContainer( ::getCppuType((const Reference< XContainerListener >*)0) ) ; 366*cdf0e10cSrcweir 367*cdf0e10cSrcweir if (pInterfaceContainer) 368*cdf0e10cSrcweir { 369*cdf0e10cSrcweir ContainerEvent aEvent ; 370*cdf0e10cSrcweir 371*cdf0e10cSrcweir aEvent.Source = *this ; 372*cdf0e10cSrcweir aEvent.Element <<= rControl ; 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir OInterfaceIteratorHelper aIterator (*pInterfaceContainer) ; 375*cdf0e10cSrcweir 376*cdf0e10cSrcweir while ( aIterator.hasMoreElements() ) 377*cdf0e10cSrcweir { 378*cdf0e10cSrcweir ((XContainerListener*)aIterator.next())->elementRemoved (aEvent) ; 379*cdf0e10cSrcweir } 380*cdf0e10cSrcweir } 381*cdf0e10cSrcweir // Break "for" ! 382*cdf0e10cSrcweir break ; 383*cdf0e10cSrcweir } 384*cdf0e10cSrcweir } 385*cdf0e10cSrcweir } 386*cdf0e10cSrcweir } 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 389*cdf0e10cSrcweir // XControlContainer 390*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 391*cdf0e10cSrcweir 392*cdf0e10cSrcweir void SAL_CALL BaseContainerControl::removeContainerListener ( const Reference< XContainerListener > & rListener ) throw( RuntimeException ) 393*cdf0e10cSrcweir { 394*cdf0e10cSrcweir // Ready for multithreading 395*cdf0e10cSrcweir MutexGuard aGuard ( m_aMutex ) ; 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir m_aListeners.removeInterface ( ::getCppuType((const Reference< XContainerListener >*)0), rListener ) ; 398*cdf0e10cSrcweir } 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 401*cdf0e10cSrcweir // XControlContainer 402*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 403*cdf0e10cSrcweir 404*cdf0e10cSrcweir void SAL_CALL BaseContainerControl::setStatusText ( const OUString& rStatusText ) throw( RuntimeException ) 405*cdf0e10cSrcweir { 406*cdf0e10cSrcweir // go down to each parent 407*cdf0e10cSrcweir Reference< XControlContainer > xContainer ( getContext(), UNO_QUERY ) ; 408*cdf0e10cSrcweir 409*cdf0e10cSrcweir if ( xContainer.is () ) 410*cdf0e10cSrcweir { 411*cdf0e10cSrcweir xContainer->setStatusText ( rStatusText ) ; 412*cdf0e10cSrcweir } 413*cdf0e10cSrcweir } 414*cdf0e10cSrcweir 415*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 416*cdf0e10cSrcweir // XControlContainer 417*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 418*cdf0e10cSrcweir 419*cdf0e10cSrcweir Reference< XControl > SAL_CALL BaseContainerControl::getControl ( const OUString& rName ) throw( RuntimeException ) 420*cdf0e10cSrcweir { 421*cdf0e10cSrcweir // Ready for multithreading 422*cdf0e10cSrcweir MutexGuard aGuard ( Mutex::getGlobalMutex() ) ; 423*cdf0e10cSrcweir 424*cdf0e10cSrcweir Reference< XControl > xRetControl = Reference< XControl > () ; 425*cdf0e10cSrcweir sal_uInt32 nControls = m_pControlInfoList->Count () ; 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir // Search for right control 428*cdf0e10cSrcweir for( sal_uInt32 nCount = 0; nCount < nControls; ++nCount ) 429*cdf0e10cSrcweir { 430*cdf0e10cSrcweir IMPL_ControlInfo* pSearchControl = m_pControlInfoList->GetObject ( nCount ) ; 431*cdf0e10cSrcweir 432*cdf0e10cSrcweir if ( pSearchControl->sName == rName ) 433*cdf0e10cSrcweir { 434*cdf0e10cSrcweir // We have found it ... 435*cdf0e10cSrcweir // Break operation and return. 436*cdf0e10cSrcweir return pSearchControl->xControl ; 437*cdf0e10cSrcweir } 438*cdf0e10cSrcweir } 439*cdf0e10cSrcweir 440*cdf0e10cSrcweir // We have not found it ... return NULL. 441*cdf0e10cSrcweir return Reference< XControl > () ; 442*cdf0e10cSrcweir } 443*cdf0e10cSrcweir 444*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 445*cdf0e10cSrcweir // XControlContainer 446*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 447*cdf0e10cSrcweir 448*cdf0e10cSrcweir Sequence< Reference< XControl > > SAL_CALL BaseContainerControl::getControls () throw( RuntimeException ) 449*cdf0e10cSrcweir { 450*cdf0e10cSrcweir // Ready for multithreading 451*cdf0e10cSrcweir MutexGuard aGuard ( Mutex::getGlobalMutex() ) ; 452*cdf0e10cSrcweir 453*cdf0e10cSrcweir sal_uInt32 nControls = m_pControlInfoList->Count () ; 454*cdf0e10cSrcweir Sequence< Reference< XControl > > aDescriptor ( nControls ) ; 455*cdf0e10cSrcweir Reference< XControl > * pDestination = aDescriptor.getArray () ; 456*cdf0e10cSrcweir sal_uInt32 nCount = 0 ; 457*cdf0e10cSrcweir 458*cdf0e10cSrcweir // Copy controls to sequence 459*cdf0e10cSrcweir for( nCount = 0; nCount < nControls; ++nCount ) 460*cdf0e10cSrcweir { 461*cdf0e10cSrcweir IMPL_ControlInfo* pCopyControl = m_pControlInfoList->GetObject ( nCount ) ; 462*cdf0e10cSrcweir pDestination [ nCount ] = pCopyControl->xControl ; 463*cdf0e10cSrcweir } 464*cdf0e10cSrcweir 465*cdf0e10cSrcweir // Return sequence 466*cdf0e10cSrcweir return aDescriptor ; 467*cdf0e10cSrcweir } 468*cdf0e10cSrcweir 469*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 470*cdf0e10cSrcweir // XUnoControlContainer 471*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 472*cdf0e10cSrcweir 473*cdf0e10cSrcweir void SAL_CALL BaseContainerControl::addTabController ( const Reference< XTabController > & rTabController ) throw( RuntimeException ) 474*cdf0e10cSrcweir { 475*cdf0e10cSrcweir // Ready for multithreading 476*cdf0e10cSrcweir MutexGuard aGuard (m_aMutex) ; 477*cdf0e10cSrcweir 478*cdf0e10cSrcweir sal_uInt32 nOldCount = m_xTabControllerList.getLength () ; 479*cdf0e10cSrcweir Sequence< Reference< XTabController > > aNewList ( nOldCount + 1 ) ; 480*cdf0e10cSrcweir sal_uInt32 nCount = 0 ; 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir // Copy old elements of sequence to new list. 483*cdf0e10cSrcweir for ( nCount = 0; nCount < nOldCount; ++nCount ) 484*cdf0e10cSrcweir { 485*cdf0e10cSrcweir aNewList.getArray () [nCount] = m_xTabControllerList.getConstArray () [nCount] ; 486*cdf0e10cSrcweir } 487*cdf0e10cSrcweir 488*cdf0e10cSrcweir // Add new controller 489*cdf0e10cSrcweir aNewList.getArray () [nOldCount] = rTabController ; 490*cdf0e10cSrcweir 491*cdf0e10cSrcweir // change old and new list 492*cdf0e10cSrcweir m_xTabControllerList = aNewList ; 493*cdf0e10cSrcweir } 494*cdf0e10cSrcweir 495*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 496*cdf0e10cSrcweir // XUnoControlContainer 497*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 498*cdf0e10cSrcweir 499*cdf0e10cSrcweir void SAL_CALL BaseContainerControl::removeTabController ( const Reference< XTabController > & rTabController ) throw( RuntimeException ) 500*cdf0e10cSrcweir { 501*cdf0e10cSrcweir // Ready for multithreading 502*cdf0e10cSrcweir MutexGuard aGuard (m_aMutex) ; 503*cdf0e10cSrcweir 504*cdf0e10cSrcweir sal_uInt32 nMaxCount = m_xTabControllerList.getLength () ; 505*cdf0e10cSrcweir sal_uInt32 nCount = 0 ; 506*cdf0e10cSrcweir 507*cdf0e10cSrcweir // Search right tabcontroller ... 508*cdf0e10cSrcweir for ( nCount = 0; nCount < nMaxCount; ++nCount ) 509*cdf0e10cSrcweir { 510*cdf0e10cSrcweir if ( m_xTabControllerList.getConstArray () [nCount] == rTabController ) 511*cdf0e10cSrcweir { 512*cdf0e10cSrcweir // ... if is it found ... remove it from list. 513*cdf0e10cSrcweir m_xTabControllerList.getArray()[ nCount ] = Reference< XTabController >() ; 514*cdf0e10cSrcweir break ; 515*cdf0e10cSrcweir } 516*cdf0e10cSrcweir } 517*cdf0e10cSrcweir } 518*cdf0e10cSrcweir 519*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 520*cdf0e10cSrcweir // XUnoControlContainer 521*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 522*cdf0e10cSrcweir 523*cdf0e10cSrcweir void SAL_CALL BaseContainerControl::setTabControllers ( const Sequence< Reference< XTabController > >& rTabControllers ) throw( RuntimeException ) 524*cdf0e10cSrcweir { 525*cdf0e10cSrcweir // Ready for multithreading 526*cdf0e10cSrcweir MutexGuard aGuard (m_aMutex) ; 527*cdf0e10cSrcweir 528*cdf0e10cSrcweir m_xTabControllerList = rTabControllers ; 529*cdf0e10cSrcweir } 530*cdf0e10cSrcweir 531*cdf0e10cSrcweir Sequence<Reference< XTabController > > SAL_CALL BaseContainerControl::getTabControllers () throw( RuntimeException ) 532*cdf0e10cSrcweir { 533*cdf0e10cSrcweir // Ready for multithreading 534*cdf0e10cSrcweir MutexGuard aGuard (m_aMutex) ; 535*cdf0e10cSrcweir 536*cdf0e10cSrcweir return m_xTabControllerList ; 537*cdf0e10cSrcweir } 538*cdf0e10cSrcweir 539*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 540*cdf0e10cSrcweir // XWindow 541*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 542*cdf0e10cSrcweir 543*cdf0e10cSrcweir void SAL_CALL BaseContainerControl::setVisible ( sal_Bool bVisible ) throw( RuntimeException ) 544*cdf0e10cSrcweir { 545*cdf0e10cSrcweir // override baseclass definition 546*cdf0e10cSrcweir BaseControl::setVisible ( bVisible ) ; 547*cdf0e10cSrcweir 548*cdf0e10cSrcweir // is it a top window ? 549*cdf0e10cSrcweir if ( !getContext().is() && bVisible ) 550*cdf0e10cSrcweir { 551*cdf0e10cSrcweir // then show it automaticly 552*cdf0e10cSrcweir createPeer ( Reference< XToolkit > (), Reference< XWindowPeer > () ) ; 553*cdf0e10cSrcweir } 554*cdf0e10cSrcweir } 555*cdf0e10cSrcweir 556*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 557*cdf0e10cSrcweir // protected method 558*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 559*cdf0e10cSrcweir 560*cdf0e10cSrcweir WindowDescriptor* BaseContainerControl::impl_getWindowDescriptor ( const Reference< XWindowPeer > & rParentPeer ) 561*cdf0e10cSrcweir { 562*cdf0e10cSrcweir // - used from "createPeer()" to set the values of an WindowDescriptor !!! 563*cdf0e10cSrcweir // - if you will change the descriptor-values, you must override thid virtuell function 564*cdf0e10cSrcweir // - the caller must release the memory for this dynamical descriptor !!! 565*cdf0e10cSrcweir 566*cdf0e10cSrcweir WindowDescriptor * aDescriptor = new WindowDescriptor ; 567*cdf0e10cSrcweir 568*cdf0e10cSrcweir aDescriptor->Type = WindowClass_CONTAINER ; 569*cdf0e10cSrcweir aDescriptor->WindowServiceName = OUString(RTL_CONSTASCII_USTRINGPARAM("window")) ; 570*cdf0e10cSrcweir aDescriptor->ParentIndex = -1 ; 571*cdf0e10cSrcweir aDescriptor->Parent = rParentPeer ; 572*cdf0e10cSrcweir aDescriptor->Bounds = getPosSize () ; 573*cdf0e10cSrcweir aDescriptor->WindowAttributes = 0 ; 574*cdf0e10cSrcweir 575*cdf0e10cSrcweir return aDescriptor ; 576*cdf0e10cSrcweir } 577*cdf0e10cSrcweir 578*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 579*cdf0e10cSrcweir // protected method 580*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 581*cdf0e10cSrcweir 582*cdf0e10cSrcweir void BaseContainerControl::impl_paint ( sal_Int32 /*nX*/, sal_Int32 /*nY*/, const Reference< XGraphics > & /*rGraphics*/ ) 583*cdf0e10cSrcweir { 584*cdf0e10cSrcweir /* 585*cdf0e10cSrcweir if (rGraphics.is()) 586*cdf0e10cSrcweir { 587*cdf0e10cSrcweir for ( sal_uInt32 n=m_pControlInfoList->Count(); n; ) 588*cdf0e10cSrcweir { 589*cdf0e10cSrcweir ControlInfo* pSearchControl = m_pControlInfoList->GetObject (--n) ; 590*cdf0e10cSrcweir 591*cdf0e10cSrcweir pSearchControl->xControl->paint ( nX, nY, rGraphics ) ; 592*cdf0e10cSrcweir } 593*cdf0e10cSrcweir } 594*cdf0e10cSrcweir */ 595*cdf0e10cSrcweir } 596*cdf0e10cSrcweir 597*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 598*cdf0e10cSrcweir // private method 599*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 600*cdf0e10cSrcweir 601*cdf0e10cSrcweir void BaseContainerControl::impl_activateTabControllers () 602*cdf0e10cSrcweir { 603*cdf0e10cSrcweir // Ready for multithreading 604*cdf0e10cSrcweir MutexGuard aGuard (m_aMutex) ; 605*cdf0e10cSrcweir 606*cdf0e10cSrcweir sal_uInt32 nMaxCount = m_xTabControllerList.getLength () ; 607*cdf0e10cSrcweir sal_uInt32 nCount = 0 ; 608*cdf0e10cSrcweir 609*cdf0e10cSrcweir for ( nCount = 0; nCount < nMaxCount; ++nCount ) 610*cdf0e10cSrcweir { 611*cdf0e10cSrcweir m_xTabControllerList.getArray () [nCount]->setContainer ( this ) ; 612*cdf0e10cSrcweir m_xTabControllerList.getArray () [nCount]->activateTabOrder ( ) ; 613*cdf0e10cSrcweir } 614*cdf0e10cSrcweir } 615*cdf0e10cSrcweir 616*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 617*cdf0e10cSrcweir // private method 618*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 619*cdf0e10cSrcweir 620*cdf0e10cSrcweir void BaseContainerControl::impl_cleanMemory () 621*cdf0e10cSrcweir { 622*cdf0e10cSrcweir // Get count of listitems. 623*cdf0e10cSrcweir sal_uInt32 nMaxCount = m_pControlInfoList->Count () ; 624*cdf0e10cSrcweir sal_uInt32 nCount = 0 ; 625*cdf0e10cSrcweir 626*cdf0e10cSrcweir // Delete all items. 627*cdf0e10cSrcweir for ( nCount = 0; nCount < nMaxCount; ++nCount ) 628*cdf0e10cSrcweir { 629*cdf0e10cSrcweir // Delete everytime first element of list! 630*cdf0e10cSrcweir // We count from 0 to MAX, where "MAX=count of items" BEFORE we delete some elements! 631*cdf0e10cSrcweir // If we use "GetObject ( nCount )" ... it can be, that we have an index greater then count of current elements! 632*cdf0e10cSrcweir 633*cdf0e10cSrcweir IMPL_ControlInfo* pSearchControl = m_pControlInfoList->GetObject ( 0 ) ; 634*cdf0e10cSrcweir delete pSearchControl ; 635*cdf0e10cSrcweir } 636*cdf0e10cSrcweir 637*cdf0e10cSrcweir // Delete list himself. 638*cdf0e10cSrcweir m_pControlInfoList->Clear () ; 639*cdf0e10cSrcweir delete m_pControlInfoList ; 640*cdf0e10cSrcweir } 641*cdf0e10cSrcweir 642*cdf0e10cSrcweir } // namespace unocontrols 643