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