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