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 #include <com/sun/star/beans/XPropertySet.hpp> 31*cdf0e10cSrcweir #include <com/sun/star/awt/XVclContainerPeer.hpp> 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include <toolkit/controls/stdtabcontroller.hxx> 34*cdf0e10cSrcweir #include <toolkit/controls/stdtabcontrollermodel.hxx> 35*cdf0e10cSrcweir #include <toolkit/awt/vclxwindow.hxx> 36*cdf0e10cSrcweir #include <toolkit/helper/macros.hxx> 37*cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx> 38*cdf0e10cSrcweir #include <rtl/memory.h> 39*cdf0e10cSrcweir #include <rtl/uuid.h> 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir #include <tools/debug.hxx> 42*cdf0e10cSrcweir #include <vcl/window.hxx> 43*cdf0e10cSrcweir #include <comphelper/sequence.hxx> 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir using namespace ::com::sun::star; 46*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 47*cdf0e10cSrcweir using namespace ::com::sun::star::awt; 48*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 49*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir // ---------------------------------------------------- 52*cdf0e10cSrcweir // class StdTabController 53*cdf0e10cSrcweir // ---------------------------------------------------- 54*cdf0e10cSrcweir StdTabController::StdTabController() 55*cdf0e10cSrcweir { 56*cdf0e10cSrcweir } 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir StdTabController::~StdTabController() 59*cdf0e10cSrcweir { 60*cdf0e10cSrcweir } 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir sal_Bool StdTabController::ImplCreateComponentSequence( 63*cdf0e10cSrcweir Sequence< Reference< XControl > >& rControls, 64*cdf0e10cSrcweir const Sequence< Reference< XControlModel > >& rModels, 65*cdf0e10cSrcweir Sequence< Reference< XWindow > >& rComponents, 66*cdf0e10cSrcweir Sequence< Any>* pTabStops, 67*cdf0e10cSrcweir sal_Bool bPeerComponent ) const 68*cdf0e10cSrcweir { 69*cdf0e10cSrcweir sal_Bool bOK = sal_True; 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir // nur die wirklich geforderten Controls 72*cdf0e10cSrcweir sal_Int32 nModels = rModels.getLength(); 73*cdf0e10cSrcweir if (nModels != rControls.getLength()) 74*cdf0e10cSrcweir { 75*cdf0e10cSrcweir Sequence< Reference< XControl > > aSeq( nModels ); 76*cdf0e10cSrcweir const Reference< XControlModel >* pModels = rModels.getConstArray(); 77*cdf0e10cSrcweir Reference< XControl > xCurrentControl; 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir sal_Int32 nRealControls = 0; 80*cdf0e10cSrcweir for (sal_Int32 n = 0; n < nModels; ++n, ++pModels) 81*cdf0e10cSrcweir { 82*cdf0e10cSrcweir xCurrentControl = FindControl(rControls, *pModels); 83*cdf0e10cSrcweir if (xCurrentControl.is()) 84*cdf0e10cSrcweir aSeq.getArray()[nRealControls++] = xCurrentControl; 85*cdf0e10cSrcweir } 86*cdf0e10cSrcweir aSeq.realloc(nRealControls); 87*cdf0e10cSrcweir rControls = aSeq; 88*cdf0e10cSrcweir } 89*cdf0e10cSrcweir #ifdef DBG_UTIL 90*cdf0e10cSrcweir DBG_ASSERT( rControls.getLength() <= rModels.getLength(), "StdTabController:ImplCreateComponentSequence: inconsistence!" ); 91*cdf0e10cSrcweir // there may be less controls than models, but never more controls than models 92*cdf0e10cSrcweir #endif 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir const Reference< XControl > * pControls = rControls.getConstArray(); 96*cdf0e10cSrcweir sal_uInt32 nCtrls = rControls.getLength(); 97*cdf0e10cSrcweir rComponents.realloc( nCtrls ); 98*cdf0e10cSrcweir Reference< XWindow > * pComps = rComponents.getArray(); 99*cdf0e10cSrcweir Any* pTabs = NULL; 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir if ( pTabStops ) 103*cdf0e10cSrcweir { 104*cdf0e10cSrcweir *pTabStops = Sequence< Any>( nCtrls ); 105*cdf0e10cSrcweir pTabs = pTabStops->getArray(); 106*cdf0e10cSrcweir } 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir for ( sal_uInt32 n = 0; bOK && ( n < nCtrls ); n++ ) 109*cdf0e10cSrcweir { 110*cdf0e10cSrcweir // Zum Model passendes Control suchen 111*cdf0e10cSrcweir Reference< XControl > xCtrl(pControls[n]); 112*cdf0e10cSrcweir if ( xCtrl.is() ) 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir if (bPeerComponent) 115*cdf0e10cSrcweir pComps[n] = Reference< XWindow > (xCtrl->getPeer(), UNO_QUERY); 116*cdf0e10cSrcweir else 117*cdf0e10cSrcweir pComps[n] = Reference< XWindow > (xCtrl, UNO_QUERY); 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir // TabStop-Property 120*cdf0e10cSrcweir if ( pTabs ) 121*cdf0e10cSrcweir { 122*cdf0e10cSrcweir // opt: String fuer TabStop als Konstante 123*cdf0e10cSrcweir static const ::rtl::OUString aTabStopName( ::rtl::OUString::createFromAscii( "Tabstop" ) ); 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir Reference< XPropertySet > xPSet( xCtrl->getModel(), UNO_QUERY ); 126*cdf0e10cSrcweir Reference< XPropertySetInfo > xInfo = xPSet->getPropertySetInfo(); 127*cdf0e10cSrcweir if( xInfo->hasPropertyByName( aTabStopName ) ) 128*cdf0e10cSrcweir *pTabs++ = xPSet->getPropertyValue( aTabStopName ); 129*cdf0e10cSrcweir else 130*cdf0e10cSrcweir ++pTabs; 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir } 133*cdf0e10cSrcweir else 134*cdf0e10cSrcweir { 135*cdf0e10cSrcweir DBG_TRACE( "ImplCreateComponentSequence: Control not found" ); 136*cdf0e10cSrcweir bOK = sal_False; 137*cdf0e10cSrcweir } 138*cdf0e10cSrcweir } 139*cdf0e10cSrcweir return bOK; 140*cdf0e10cSrcweir } 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir void StdTabController::ImplActivateControl( sal_Bool bFirst ) const 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir // HACK wegen #53688#, muss auf ein Interface abgebildet werden, wenn Controls Remote liegen koennen. 145*cdf0e10cSrcweir Reference< XTabController > xTabController(const_cast< ::cppu::OWeakObject* >(static_cast< const ::cppu::OWeakObject* >(this)), UNO_QUERY); 146*cdf0e10cSrcweir Sequence< Reference< XControl > > aCtrls = xTabController->getControls(); 147*cdf0e10cSrcweir const Reference< XControl > * pControls = aCtrls.getConstArray(); 148*cdf0e10cSrcweir sal_uInt32 nCount = aCtrls.getLength(); 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir for ( sal_uInt32 n = bFirst ? 0 : nCount; bFirst ? ( n < nCount ) : n; ) 151*cdf0e10cSrcweir { 152*cdf0e10cSrcweir sal_uInt32 nCtrl = bFirst ? n++ : --n; 153*cdf0e10cSrcweir DBG_ASSERT( pControls[nCtrl].is(), "Control nicht im Container!" ); 154*cdf0e10cSrcweir if ( pControls[nCtrl].is() ) 155*cdf0e10cSrcweir { 156*cdf0e10cSrcweir Reference< XWindowPeer > xCP = pControls[nCtrl]->getPeer(); 157*cdf0e10cSrcweir if ( xCP.is() ) 158*cdf0e10cSrcweir { 159*cdf0e10cSrcweir VCLXWindow* pC = VCLXWindow::GetImplementation( xCP ); 160*cdf0e10cSrcweir if ( pC && pC->GetWindow() && ( pC->GetWindow()->GetStyle() & WB_TABSTOP ) ) 161*cdf0e10cSrcweir { 162*cdf0e10cSrcweir pC->GetWindow()->GrabFocus(); 163*cdf0e10cSrcweir break; 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir } 166*cdf0e10cSrcweir } 167*cdf0e10cSrcweir } 168*cdf0e10cSrcweir } 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir // XInterface 171*cdf0e10cSrcweir Any StdTabController::queryAggregation( const Type & rType ) throw(RuntimeException) 172*cdf0e10cSrcweir { 173*cdf0e10cSrcweir Any aRet = ::cppu::queryInterface( rType, 174*cdf0e10cSrcweir SAL_STATIC_CAST( XTabController*, this ), 175*cdf0e10cSrcweir SAL_STATIC_CAST( XServiceInfo*, this ), 176*cdf0e10cSrcweir SAL_STATIC_CAST( XTypeProvider*, this ) ); 177*cdf0e10cSrcweir return (aRet.hasValue() ? aRet : OWeakAggObject::queryAggregation( rType )); 178*cdf0e10cSrcweir } 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir // XTypeProvider 181*cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( StdTabController ) 182*cdf0e10cSrcweir getCppuType( ( Reference< XTabController>* ) NULL ), 183*cdf0e10cSrcweir getCppuType( ( Reference< XServiceInfo>* ) NULL ) 184*cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir void StdTabController::setModel( const Reference< XTabControllerModel >& Model ) throw(RuntimeException) 187*cdf0e10cSrcweir { 188*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir mxModel = Model; 191*cdf0e10cSrcweir } 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir Reference< XTabControllerModel > StdTabController::getModel( ) throw(RuntimeException) 194*cdf0e10cSrcweir { 195*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir return mxModel; 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir void StdTabController::setContainer( const Reference< XControlContainer >& Container ) throw(RuntimeException) 201*cdf0e10cSrcweir { 202*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir mxControlContainer = Container; 205*cdf0e10cSrcweir } 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir Reference< XControlContainer > StdTabController::getContainer( ) throw(RuntimeException) 208*cdf0e10cSrcweir { 209*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir return mxControlContainer; 212*cdf0e10cSrcweir } 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir Sequence< Reference< XControl > > StdTabController::getControls( ) throw(RuntimeException) 215*cdf0e10cSrcweir { 216*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir Sequence< Reference< XControl > > aSeq; 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir if ( mxControlContainer.is() ) 221*cdf0e10cSrcweir { 222*cdf0e10cSrcweir Sequence< Reference< XControlModel > > aModels = mxModel->getControlModels(); 223*cdf0e10cSrcweir const Reference< XControlModel > * pModels = aModels.getConstArray(); 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir Sequence< Reference< XControl > > xCtrls = mxControlContainer->getControls(); 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir sal_uInt32 nCtrls = aModels.getLength(); 228*cdf0e10cSrcweir aSeq = Sequence< Reference< XControl > >( nCtrls ); 229*cdf0e10cSrcweir for ( sal_uInt32 n = 0; n < nCtrls; n++ ) 230*cdf0e10cSrcweir { 231*cdf0e10cSrcweir Reference< XControlModel > xCtrlModel = pModels[n]; 232*cdf0e10cSrcweir // Zum Model passendes Control suchen 233*cdf0e10cSrcweir Reference< XControl > xCtrl = FindControl( xCtrls, xCtrlModel ); 234*cdf0e10cSrcweir aSeq.getArray()[n] = xCtrl; 235*cdf0e10cSrcweir } 236*cdf0e10cSrcweir } 237*cdf0e10cSrcweir return aSeq; 238*cdf0e10cSrcweir } 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir void StdTabController::autoTabOrder( ) throw(RuntimeException) 241*cdf0e10cSrcweir { 242*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir DBG_ASSERT( mxControlContainer.is(), "autoTabOrder: No ControlContainer!" ); 245*cdf0e10cSrcweir if ( !mxControlContainer.is() ) 246*cdf0e10cSrcweir return; 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir Sequence< Reference< XControlModel > > aSeq = mxModel->getControlModels(); 249*cdf0e10cSrcweir Sequence< Reference< XWindow > > aCompSeq; 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir // vieleicht erhalte ich hier einen TabController, 252*cdf0e10cSrcweir // der schneller die Liste meiner Controls ermittelt 253*cdf0e10cSrcweir Reference< XTabController > xTabController(static_cast< ::cppu::OWeakObject* >(this), UNO_QUERY); 254*cdf0e10cSrcweir Sequence< Reference< XControl > > aControls = xTabController->getControls(); 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir // #58317# Es sind ggf. noch nicht alle Controls fuer die Models im Container, 257*cdf0e10cSrcweir // dann kommt spaeter nochmal ein autoTabOrder... 258*cdf0e10cSrcweir if( !ImplCreateComponentSequence( aControls, aSeq, aCompSeq, NULL, sal_False ) ) 259*cdf0e10cSrcweir return; 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir sal_uInt32 nCtrls = aCompSeq.getLength(); 262*cdf0e10cSrcweir Reference< XWindow > * pComponents = aCompSeq.getArray(); 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir ComponentEntryList aCtrls; 265*cdf0e10cSrcweir sal_uInt32 n; 266*cdf0e10cSrcweir for ( n = 0; n < nCtrls; n++ ) 267*cdf0e10cSrcweir { 268*cdf0e10cSrcweir XWindow* pC = (XWindow*)pComponents[n].get(); 269*cdf0e10cSrcweir ComponentEntry* pE = new ComponentEntry; 270*cdf0e10cSrcweir pE->pComponent = pC; 271*cdf0e10cSrcweir awt::Rectangle aPosSize = pC->getPosSize(); 272*cdf0e10cSrcweir pE->aPos.X() = aPosSize.X; 273*cdf0e10cSrcweir pE->aPos.Y() = aPosSize.Y; 274*cdf0e10cSrcweir 275*cdf0e10cSrcweir sal_uInt16 nPos; 276*cdf0e10cSrcweir for ( nPos = 0; nPos < aCtrls.Count(); nPos++ ) 277*cdf0e10cSrcweir { 278*cdf0e10cSrcweir ComponentEntry* pEntry = aCtrls.GetObject( nPos ); 279*cdf0e10cSrcweir if ( pEntry->aPos.Y() >= pE->aPos.Y() ) 280*cdf0e10cSrcweir { 281*cdf0e10cSrcweir while ( pEntry && ( pEntry->aPos.Y() == pE->aPos.Y() ) 282*cdf0e10cSrcweir && ( pEntry->aPos.X() < pE->aPos.X() ) ) 283*cdf0e10cSrcweir { 284*cdf0e10cSrcweir pEntry = aCtrls.GetObject( ++nPos ); 285*cdf0e10cSrcweir } 286*cdf0e10cSrcweir break; 287*cdf0e10cSrcweir } 288*cdf0e10cSrcweir } 289*cdf0e10cSrcweir aCtrls.Insert( pE, nPos ); 290*cdf0e10cSrcweir } 291*cdf0e10cSrcweir 292*cdf0e10cSrcweir Sequence< Reference< XControlModel > > aNewSeq( nCtrls ); 293*cdf0e10cSrcweir for ( n = 0; n < nCtrls; n++ ) 294*cdf0e10cSrcweir { 295*cdf0e10cSrcweir ComponentEntry* pE = aCtrls.GetObject( n ); 296*cdf0e10cSrcweir Reference< XControl > xUC( pE->pComponent, UNO_QUERY ); 297*cdf0e10cSrcweir aNewSeq.getArray()[n] = xUC->getModel(); 298*cdf0e10cSrcweir delete pE; 299*cdf0e10cSrcweir } 300*cdf0e10cSrcweir aCtrls.Clear(); 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir mxModel->setControlModels( aNewSeq ); 303*cdf0e10cSrcweir } 304*cdf0e10cSrcweir 305*cdf0e10cSrcweir void StdTabController::activateTabOrder( ) throw(RuntimeException) 306*cdf0e10cSrcweir { 307*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 308*cdf0e10cSrcweir 309*cdf0e10cSrcweir // Am Container die Tab-Reihenfolge aktivieren... 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir Reference< XControl > xC( mxControlContainer, UNO_QUERY ); 312*cdf0e10cSrcweir Reference< XVclContainerPeer > xVclContainerPeer; 313*cdf0e10cSrcweir if ( xC.is() ) 314*cdf0e10cSrcweir xVclContainerPeer = xVclContainerPeer.query( xC->getPeer() ); 315*cdf0e10cSrcweir if ( !xC.is() || !xVclContainerPeer.is() ) 316*cdf0e10cSrcweir return; 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir // vieleicht erhalte ich hier einen TabController, 319*cdf0e10cSrcweir // der schneller die Liste meiner Controls ermittelt 320*cdf0e10cSrcweir Reference< XTabController > xTabController(static_cast< ::cppu::OWeakObject* >(this), UNO_QUERY); 321*cdf0e10cSrcweir 322*cdf0e10cSrcweir // Flache Liste besorgen... 323*cdf0e10cSrcweir Sequence< Reference< XControlModel > > aModels = mxModel->getControlModels(); 324*cdf0e10cSrcweir Sequence< Reference< XWindow > > aCompSeq; 325*cdf0e10cSrcweir Sequence< Any> aTabSeq; 326*cdf0e10cSrcweir 327*cdf0e10cSrcweir // DG: Aus Optimierungsgruenden werden die Controls mittels getControls() geholt, 328*cdf0e10cSrcweir // dieses hoert sich zwar wiedersinning an, fuehrt aber im konkreten Fall (Forms) zu sichtbaren 329*cdf0e10cSrcweir // Geschwindigkeitsvorteilen 330*cdf0e10cSrcweir Sequence< Reference< XControl > > aControls = xTabController->getControls(); 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir // #58317# Es sind ggf. noch nicht alle Controls fuer die Models im Container, 333*cdf0e10cSrcweir // dann kommt spaeter nochmal ein activateTabOrder... 334*cdf0e10cSrcweir if( !ImplCreateComponentSequence( aControls, aModels, aCompSeq, &aTabSeq, sal_True ) ) 335*cdf0e10cSrcweir return; 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir xVclContainerPeer->setTabOrder( aCompSeq, aTabSeq, mxModel->getGroupControl() ); 338*cdf0e10cSrcweir 339*cdf0e10cSrcweir ::rtl::OUString aName; 340*cdf0e10cSrcweir Sequence< Reference< XControlModel > > aThisGroupModels; 341*cdf0e10cSrcweir Sequence< Reference< XWindow > > aControlComponents; 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir sal_uInt32 nGroups = mxModel->getGroupCount(); 344*cdf0e10cSrcweir for ( sal_uInt32 nG = 0; nG < nGroups; nG++ ) 345*cdf0e10cSrcweir { 346*cdf0e10cSrcweir mxModel->getGroup( nG, aThisGroupModels, aName ); 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir aControls = xTabController->getControls(); 349*cdf0e10cSrcweir // ImplCreateComponentSequence has a really strange semantics regarding it's first parameter: 350*cdf0e10cSrcweir // upon method entry, it expects a super set of the controls which it returns 351*cdf0e10cSrcweir // this means we need to completely fill this sequence with all available controls before 352*cdf0e10cSrcweir // calling into ImplCreateComponentSequence 353*cdf0e10cSrcweir 354*cdf0e10cSrcweir aControlComponents.realloc( 0 ); 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir ImplCreateComponentSequence( aControls, aThisGroupModels, aControlComponents, NULL, sal_True ); 357*cdf0e10cSrcweir xVclContainerPeer->setGroup( aControlComponents ); 358*cdf0e10cSrcweir } 359*cdf0e10cSrcweir } 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir void StdTabController::activateFirst( ) throw(RuntimeException) 362*cdf0e10cSrcweir { 363*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir ImplActivateControl( sal_True ); 366*cdf0e10cSrcweir } 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir void StdTabController::activateLast( ) throw(RuntimeException) 369*cdf0e10cSrcweir { 370*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 371*cdf0e10cSrcweir 372*cdf0e10cSrcweir ImplActivateControl( sal_False ); 373*cdf0e10cSrcweir } 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir 376*cdf0e10cSrcweir Reference< XControl > StdTabController::FindControl( Sequence< Reference< XControl > >& rCtrls, 377*cdf0e10cSrcweir const Reference< XControlModel > & rxCtrlModel ) 378*cdf0e10cSrcweir { 379*cdf0e10cSrcweir 380*cdf0e10cSrcweir /* 381*cdf0e10cSrcweir // MT: Funktioniert nicht mehr, weil ich nicht mehr bei mir angemeldet bin, 382*cdf0e10cSrcweir // weil DG das abfaengt. 383*cdf0e10cSrcweir 384*cdf0e10cSrcweir // #54677# Beim Laden eines HTML-Dokuments wird nach jedem Control ein 385*cdf0e10cSrcweir // activateTabOrder gerufen und jede Menge Zeit in dieser Methode verbraten. 386*cdf0e10cSrcweir // Die Anzahl dieser Schleifendurchlaufe steigt quadratisch, also versuchen 387*cdf0e10cSrcweir // das Control direkt vom Model zu erhalten. 388*cdf0e10cSrcweir // => Wenn genau ein Control als PropertyChangeListener angemeldet ist, 389*cdf0e10cSrcweir // dann muss das auch das richtige sein. 390*cdf0e10cSrcweir 391*cdf0e10cSrcweir UnoControlModel* pUnoCtrlModel = UnoControlModel::GetImplementation( rxCtrlModel ); 392*cdf0e10cSrcweir 393*cdf0e10cSrcweir 394*cdf0e10cSrcweir if ( pUnoCtrlModel ) 395*cdf0e10cSrcweir { 396*cdf0e10cSrcweir ListenerIterator aIt( pUnoCtrlModel->maPropertiesListeners ); 397*cdf0e10cSrcweir while( aIt.hasMoreElements() ) 398*cdf0e10cSrcweir { 399*cdf0e10cSrcweir XEventListener* pL = aIt.next(); 400*cdf0e10cSrcweir Reference< XControl > xC( pL, UNO_QUERY ); 401*cdf0e10cSrcweir if ( xC.is() ) 402*cdf0e10cSrcweir { 403*cdf0e10cSrcweir if( xC->getContext() == mxControlContainer ) 404*cdf0e10cSrcweir { 405*cdf0e10cSrcweir xCtrl = xC; 406*cdf0e10cSrcweir break; 407*cdf0e10cSrcweir } 408*cdf0e10cSrcweir } 409*cdf0e10cSrcweir } 410*cdf0e10cSrcweir } 411*cdf0e10cSrcweir if ( !xCtrl.is() && rxCtrlModel.is()) 412*cdf0e10cSrcweir */ 413*cdf0e10cSrcweir DBG_ASSERT( rxCtrlModel.is(), "ImplFindControl - welches ?!" ); 414*cdf0e10cSrcweir 415*cdf0e10cSrcweir const Reference< XControl > * pCtrls = rCtrls.getConstArray(); 416*cdf0e10cSrcweir sal_Int32 nCtrls = rCtrls.getLength(); 417*cdf0e10cSrcweir for ( sal_Int32 n = 0; n < nCtrls; n++ ) 418*cdf0e10cSrcweir { 419*cdf0e10cSrcweir Reference< XControlModel > xModel(pCtrls[n].is() ? pCtrls[n]->getModel() : Reference< XControlModel > ()); 420*cdf0e10cSrcweir if ( (XControlModel*)xModel.get() == (XControlModel*)rxCtrlModel.get() ) 421*cdf0e10cSrcweir { 422*cdf0e10cSrcweir Reference< XControl > xCtrl( pCtrls[n] ); 423*cdf0e10cSrcweir ::comphelper::removeElementAt( rCtrls, n ); 424*cdf0e10cSrcweir return xCtrl; 425*cdf0e10cSrcweir } 426*cdf0e10cSrcweir } 427*cdf0e10cSrcweir return Reference< XControl > (); 428*cdf0e10cSrcweir } 429