LCOV - code coverage report
Current view: top level - UnoControls/source/base - basecontainercontrol.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 205 0.0 %
Date: 2012-08-25 Functions: 0 27 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

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

Generated by: LCOV version 1.10