LCOV - code coverage report
Current view: top level - extensions/source/propctrlr - propertycomposer.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 195 0.0 %
Date: 2012-08-25 Functions: 0 34 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                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "propertycomposer.hxx"
      30                 :            : 
      31                 :            : #include <com/sun/star/lang/NullPointerException.hpp>
      32                 :            : #include <com/sun/star/lang/IllegalArgumentException.hpp>
      33                 :            : #include <osl/diagnose.h>
      34                 :            : #include <tools/diagnose_ex.h>
      35                 :            : 
      36                 :            : #include <functional>
      37                 :            : #include <algorithm>
      38                 :            : #include <map>
      39                 :            : 
      40                 :            : //........................................................................
      41                 :            : namespace pcr
      42                 :            : {
      43                 :            : //........................................................................
      44                 :            : 
      45                 :            :     using namespace ::com::sun::star::uno;
      46                 :            :     using namespace ::com::sun::star::beans;
      47                 :            :     using namespace ::com::sun::star::lang;
      48                 :            :     using namespace ::com::sun::star::inspection;
      49                 :            : 
      50                 :            :     //====================================================================
      51                 :            :     //= helper
      52                 :            :     //====================================================================
      53                 :            :     namespace
      54                 :            :     {
      55                 :            :         //----------------------------------------------------------------
      56                 :          0 :         struct SetPropertyValue : public ::std::unary_function< Reference< XPropertyHandler >, void >
      57                 :            :         {
      58                 :            :             ::rtl::OUString sPropertyName;
      59                 :            :             const Any&      rValue;
      60                 :          0 :             SetPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) : sPropertyName( _rPropertyName ), rValue( _rValue ) { }
      61                 :          0 :             void operator()( const Reference< XPropertyHandler >& _rHandler )
      62                 :            :             {
      63                 :          0 :                 _rHandler->setPropertyValue( sPropertyName, rValue );
      64                 :          0 :             }
      65                 :            :         };
      66                 :            : 
      67                 :            :         //----------------------------------------------------------------
      68                 :            :         template < class BagType >
      69                 :          0 :         void putIntoBag( const Sequence< typename BagType::value_type >& _rArray, BagType& /* [out] */ _rBag )
      70                 :            :         {
      71                 :          0 :             ::std::copy( _rArray.getConstArray(), _rArray.getConstArray() + _rArray.getLength(),
      72                 :            :                 ::std::insert_iterator< BagType >( _rBag, _rBag.begin() ) );
      73                 :          0 :         }
      74                 :            : 
      75                 :            :         //----------------------------------------------------------------
      76                 :            :         template < class BagType >
      77                 :          0 :         void copyBagToArray( const BagType& /* [out] */ _rBag, Sequence< typename BagType::value_type >& _rArray )
      78                 :            :         {
      79                 :          0 :             _rArray.realloc( _rBag.size() );
      80                 :          0 :             ::std::copy( _rBag.begin(), _rBag.end(), _rArray.getArray() );
      81                 :          0 :         }
      82                 :            :     }
      83                 :            : 
      84                 :            :     //====================================================================
      85                 :            :     //= PropertyComposer
      86                 :            :     //====================================================================
      87                 :            : 
      88                 :            :     // TODO: there are various places where we determine the first handler in our array which
      89                 :            :     // supports a given property id. This is, at the moment, done with searching all handlers,
      90                 :            :     // which is O( n * k ) at worst (n being the number of handlers, k being the maximum number
      91                 :            :     // of supported properties per handler). Shouldn't we cache this? So that it is O( log k )?
      92                 :            : 
      93                 :            :     //--------------------------------------------------------------------
      94                 :          0 :     PropertyComposer::PropertyComposer( const ::std::vector< Reference< XPropertyHandler > >& _rSlaveHandlers )
      95                 :            :         :PropertyComposer_Base          ( m_aMutex          )
      96                 :            :         ,m_aSlaveHandlers               ( _rSlaveHandlers   )
      97                 :            :         ,m_aPropertyListeners           ( m_aMutex          )
      98                 :          0 :         ,m_bSupportedPropertiesAreKnown ( false             )
      99                 :            :     {
     100                 :          0 :         if ( m_aSlaveHandlers.empty() )
     101                 :          0 :             throw IllegalArgumentException();
     102                 :            : 
     103                 :          0 :         osl_incrementInterlockedCount( &m_refCount );
     104                 :            :         {
     105                 :          0 :             Reference< XPropertyChangeListener > xMeMyselfAndI( this );
     106                 :          0 :             for (   HandlerArray::const_iterator loop = m_aSlaveHandlers.begin();
     107                 :          0 :                     loop != m_aSlaveHandlers.end();
     108                 :            :                     ++loop
     109                 :            :                 )
     110                 :            :             {
     111                 :          0 :                 if ( !loop->is() )
     112                 :          0 :                     throw NullPointerException();
     113                 :          0 :                 (*loop)->addPropertyChangeListener( xMeMyselfAndI );
     114                 :          0 :             }
     115                 :            :         }
     116                 :          0 :         osl_decrementInterlockedCount( &m_refCount );
     117                 :          0 :     }
     118                 :            : 
     119                 :            :     //--------------------------------------------------------------------
     120                 :          0 :     void SAL_CALL PropertyComposer::inspect( const Reference< XInterface >& _rxIntrospectee ) throw (RuntimeException, NullPointerException)
     121                 :            :     {
     122                 :          0 :         MethodGuard aGuard( *this );
     123                 :            : 
     124                 :          0 :         for ( HandlerArray::const_iterator loop = m_aSlaveHandlers.begin();
     125                 :          0 :               loop != m_aSlaveHandlers.end();
     126                 :            :               ++loop
     127                 :            :             )
     128                 :            :         {
     129                 :          0 :             (*loop)->inspect( _rxIntrospectee );
     130                 :          0 :         }
     131                 :          0 :     }
     132                 :            : 
     133                 :            :     //--------------------------------------------------------------------
     134                 :          0 :     Any SAL_CALL PropertyComposer::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
     135                 :            :     {
     136                 :          0 :         MethodGuard aGuard( *this );
     137                 :          0 :         return m_aSlaveHandlers[0]->getPropertyValue( _rPropertyName );
     138                 :            :     }
     139                 :            : 
     140                 :            :     //--------------------------------------------------------------------
     141                 :          0 :     void SAL_CALL PropertyComposer::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException)
     142                 :            :     {
     143                 :          0 :         MethodGuard aGuard( *this );
     144                 :          0 :         ::std::for_each( m_aSlaveHandlers.begin(), m_aSlaveHandlers.end(), SetPropertyValue( _rPropertyName, _rValue ) );
     145                 :          0 :     }
     146                 :            : 
     147                 :            :     //--------------------------------------------------------------------
     148                 :          0 :     Any SAL_CALL PropertyComposer::convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rControlValue ) throw (UnknownPropertyException, RuntimeException)
     149                 :            :     {
     150                 :          0 :         MethodGuard aGuard( *this );
     151                 :          0 :         return m_aSlaveHandlers[0]->convertToPropertyValue( _rPropertyName, _rControlValue );
     152                 :            :     }
     153                 :            : 
     154                 :            :     //--------------------------------------------------------------------
     155                 :          0 :     Any SAL_CALL PropertyComposer::convertToControlValue( const ::rtl::OUString& _rPropertyName, const Any& _rPropertyValue, const Type& _rControlValueType ) throw (UnknownPropertyException, RuntimeException)
     156                 :            :     {
     157                 :          0 :         MethodGuard aGuard( *this );
     158                 :          0 :         return m_aSlaveHandlers[0]->convertToControlValue( _rPropertyName, _rPropertyValue, _rControlValueType );
     159                 :            :     }
     160                 :            : 
     161                 :            :     //--------------------------------------------------------------------
     162                 :          0 :     PropertyState SAL_CALL PropertyComposer::getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
     163                 :            :     {
     164                 :          0 :         MethodGuard aGuard( *this );
     165                 :            : 
     166                 :            :         // assume DIRECT for the moment. This will stay this way if *all* slaves
     167                 :            :         // tell the property has DIRECT state, and if *all* values equal
     168                 :          0 :         PropertyState eState = PropertyState_DIRECT_VALUE;
     169                 :            : 
     170                 :            :         // check the master state
     171                 :          0 :         Reference< XPropertyHandler > xPrimary( *m_aSlaveHandlers.begin() );
     172                 :          0 :         Any aPrimaryValue = xPrimary->getPropertyValue( _rPropertyName );
     173                 :          0 :         eState = xPrimary->getPropertyState( _rPropertyName );
     174                 :            : 
     175                 :            :         // loop through the secondary sets
     176                 :          0 :         PropertyState eSecondaryState = PropertyState_DIRECT_VALUE;
     177                 :          0 :         for ( HandlerArray::const_iterator loop = ( m_aSlaveHandlers.begin() + 1 );
     178                 :          0 :               loop != m_aSlaveHandlers.end();
     179                 :            :               ++loop
     180                 :            :             )
     181                 :            :         {
     182                 :            :             // the secondary state
     183                 :          0 :             eSecondaryState = (*loop)->getPropertyState( _rPropertyName );
     184                 :            : 
     185                 :            :             // the secondary value
     186                 :          0 :             Any aSecondaryValue( (*loop)->getPropertyValue( _rPropertyName ) );
     187                 :            : 
     188                 :          0 :             if  (   ( PropertyState_AMBIGUOUS_VALUE == eSecondaryState )    // secondary is ambiguous
     189                 :          0 :                 ||  ( aPrimaryValue != aSecondaryValue )                    // unequal values
     190                 :            :                 )
     191                 :            :             {
     192                 :          0 :                 eState = PropertyState_AMBIGUOUS_VALUE;
     193                 :            :                 break;
     194                 :            :             }
     195                 :          0 :         }
     196                 :            : 
     197                 :          0 :         return eState;
     198                 :            :     }
     199                 :            : 
     200                 :            :     //--------------------------------------------------------------------
     201                 :          0 :     void SAL_CALL PropertyComposer::addPropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
     202                 :            :     {
     203                 :          0 :         MethodGuard aGuard( *this );
     204                 :          0 :         m_aPropertyListeners.addListener( _rxListener );
     205                 :          0 :     }
     206                 :            : 
     207                 :            :     //--------------------------------------------------------------------
     208                 :          0 :     void SAL_CALL PropertyComposer::removePropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
     209                 :            :     {
     210                 :          0 :         MethodGuard aGuard( *this );
     211                 :          0 :         m_aPropertyListeners.removeListener( _rxListener );
     212                 :          0 :     }
     213                 :            : 
     214                 :            :     //--------------------------------------------------------------------
     215                 :          0 :     Sequence< Property > SAL_CALL PropertyComposer::getSupportedProperties() throw (RuntimeException)
     216                 :            :     {
     217                 :          0 :         MethodGuard aGuard( *this );
     218                 :            : 
     219                 :          0 :         if ( !m_bSupportedPropertiesAreKnown )
     220                 :            :         {
     221                 :            :             // we support a property if and only if all of our slaves support it
     222                 :            : 
     223                 :            :             // initially, use all the properties of an arbitrary handler (we take the first one)
     224                 :          0 :             putIntoBag( (*m_aSlaveHandlers.begin())->getSupportedProperties(), m_aSupportedProperties );
     225                 :            : 
     226                 :            :             // now intersect with the properties of *all* other handlers
     227                 :          0 :             for ( HandlerArray::const_iterator loop = ( m_aSlaveHandlers.begin() + 1 );
     228                 :          0 :                 loop != m_aSlaveHandlers.end();
     229                 :            :                 ++loop
     230                 :            :                 )
     231                 :            :             {
     232                 :            :                 // the properties supported by the current handler
     233                 :          0 :                 PropertyBag aThisRound;
     234                 :          0 :                 putIntoBag( (*loop)->getSupportedProperties(), aThisRound );
     235                 :            : 
     236                 :            :                 // the intersection of those properties with all we already have
     237                 :          0 :                 PropertyBag aIntersection;
     238                 :            :                 ::std::set_intersection( aThisRound.begin(), aThisRound.end(), m_aSupportedProperties.begin(), m_aSupportedProperties.end(),
     239                 :          0 :                     ::std::insert_iterator< PropertyBag >( aIntersection, aIntersection.begin() ), PropertyLessByName() );
     240                 :            : 
     241                 :          0 :                 m_aSupportedProperties.swap( aIntersection );
     242                 :          0 :                 if ( m_aSupportedProperties.empty() )
     243                 :            :                     break;
     244                 :          0 :             }
     245                 :            : 
     246                 :            :             // remove those properties which are not composable
     247                 :          0 :             for (   PropertyBag::iterator check = m_aSupportedProperties.begin();
     248                 :          0 :                     check != m_aSupportedProperties.end();
     249                 :            :                 )
     250                 :            :             {
     251                 :          0 :                 sal_Bool bIsComposable = isComposable( check->Name );
     252                 :          0 :                 if ( !bIsComposable )
     253                 :            :                 {
     254                 :          0 :                     PropertyBag::iterator next = check; ++next;
     255                 :          0 :                     m_aSupportedProperties.erase( check );
     256                 :          0 :                     check = next;
     257                 :            :                 }
     258                 :            :                 else
     259                 :          0 :                     ++check;
     260                 :            :             }
     261                 :            : 
     262                 :          0 :             m_bSupportedPropertiesAreKnown = true;
     263                 :            :         }
     264                 :            : 
     265                 :          0 :         Sequence< Property > aSurvived;
     266                 :          0 :         copyBagToArray( m_aSupportedProperties, aSurvived );
     267                 :          0 :         return aSurvived;
     268                 :            :     }
     269                 :            : 
     270                 :            :     //--------------------------------------------------------------------
     271                 :          0 :     void uniteStringArrays( const PropertyComposer::HandlerArray& _rHandlers, Sequence< ::rtl::OUString > (SAL_CALL XPropertyHandler::*pGetter)( void ),
     272                 :            :         Sequence< ::rtl::OUString >& /* [out] */ _rUnion )
     273                 :            :     {
     274                 :          0 :         ::std::set< ::rtl::OUString > aUnitedBag;
     275                 :            : 
     276                 :          0 :         Sequence< ::rtl::OUString > aThisRound;
     277                 :          0 :         for ( PropertyComposer::HandlerArray::const_iterator loop = _rHandlers.begin();
     278                 :          0 :               loop != _rHandlers.end();
     279                 :            :               ++loop
     280                 :            :             )
     281                 :            :         {
     282                 :          0 :             aThisRound = (loop->get()->*pGetter)();
     283                 :          0 :             putIntoBag( aThisRound, aUnitedBag );
     284                 :            :         }
     285                 :            : 
     286                 :          0 :         copyBagToArray( aUnitedBag, _rUnion );
     287                 :          0 :     }
     288                 :            : 
     289                 :            :     //--------------------------------------------------------------------
     290                 :          0 :     Sequence< ::rtl::OUString > SAL_CALL PropertyComposer::getSupersededProperties( ) throw (RuntimeException)
     291                 :            :     {
     292                 :          0 :         MethodGuard aGuard( *this );
     293                 :            : 
     294                 :            :         // we supersede those properties which are superseded by at least one of our slaves
     295                 :          0 :         Sequence< ::rtl::OUString > aSuperseded;
     296                 :          0 :         uniteStringArrays( m_aSlaveHandlers, &XPropertyHandler::getSupersededProperties, aSuperseded );
     297                 :          0 :         return aSuperseded;
     298                 :            :     }
     299                 :            : 
     300                 :            :     //--------------------------------------------------------------------
     301                 :          0 :     Sequence< ::rtl::OUString > SAL_CALL PropertyComposer::getActuatingProperties( ) throw (RuntimeException)
     302                 :            :     {
     303                 :          0 :         MethodGuard aGuard( *this );
     304                 :            : 
     305                 :            :         // we're interested in those properties which at least one handler wants to have
     306                 :          0 :         Sequence< ::rtl::OUString > aActuating;
     307                 :          0 :         uniteStringArrays( m_aSlaveHandlers, &XPropertyHandler::getActuatingProperties, aActuating );
     308                 :          0 :         return aActuating;
     309                 :            :     }
     310                 :            : 
     311                 :            :     //--------------------------------------------------------------------
     312                 :          0 :     LineDescriptor SAL_CALL PropertyComposer::describePropertyLine( const ::rtl::OUString& _rPropertyName,
     313                 :            :         const Reference< XPropertyControlFactory >& _rxControlFactory )
     314                 :            :         throw (UnknownPropertyException, NullPointerException, RuntimeException)
     315                 :            :     {
     316                 :          0 :         MethodGuard aGuard( *this );
     317                 :          0 :         return m_aSlaveHandlers[0]->describePropertyLine( _rPropertyName, _rxControlFactory );
     318                 :            :     }
     319                 :            : 
     320                 :            :     //--------------------------------------------------------------------
     321                 :          0 :     ::sal_Bool SAL_CALL PropertyComposer::isComposable( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
     322                 :            :     {
     323                 :          0 :         MethodGuard aGuard( *this );
     324                 :          0 :         return m_aSlaveHandlers[0]->isComposable( _rPropertyName );
     325                 :            :     }
     326                 :            : 
     327                 :            :     //--------------------------------------------------------------------
     328                 :          0 :     InteractiveSelectionResult SAL_CALL PropertyComposer::onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool _bPrimary, Any& _rData, const Reference< XObjectInspectorUI >& _rxInspectorUI ) throw (UnknownPropertyException, NullPointerException, RuntimeException)
     329                 :            :     {
     330                 :          0 :         if ( !_rxInspectorUI.is() )
     331                 :          0 :             throw NullPointerException();
     332                 :            : 
     333                 :          0 :         MethodGuard aGuard( *this );
     334                 :            : 
     335                 :          0 :         impl_ensureUIRequestComposer( _rxInspectorUI );
     336                 :          0 :         ComposedUIAutoFireGuard aAutoFireGuard( *m_pUIRequestComposer );
     337                 :            : 
     338                 :            :         // ask the first of the handlers
     339                 :          0 :         InteractiveSelectionResult eResult = (*m_aSlaveHandlers.begin())->onInteractivePropertySelection(
     340                 :            :                 _rPropertyName,
     341                 :            :                 _bPrimary,
     342                 :            :                 _rData,
     343                 :          0 :                 m_pUIRequestComposer->getUIForPropertyHandler( *m_aSlaveHandlers.begin() )
     344                 :          0 :             );
     345                 :            : 
     346                 :          0 :         switch ( eResult )
     347                 :            :         {
     348                 :            :         case InteractiveSelectionResult_Cancelled:
     349                 :            :             // fine
     350                 :          0 :             break;
     351                 :            : 
     352                 :            :         case InteractiveSelectionResult_Success:
     353                 :            :         case InteractiveSelectionResult_Pending:
     354                 :            :             OSL_FAIL( "PropertyComposer::onInteractivePropertySelection: no chance to forward the new value to the other handlers!" );
     355                 :            :             // This means that we cannot know the new property value, which either has already been set
     356                 :            :             // at the first component ("Success"), or will be set later on once the asynchronous input
     357                 :            :             // is finished ("Pending"). So, we also cannot forward this new property value to the other
     358                 :            :             // handlers.
     359                 :            :             // We would need to be a listener at the property at the first component, but even this wouldn't
     360                 :            :             // be sufficient, since the property handler is free to change *any* property during a dedicated
     361                 :            :             // property UI.
     362                 :          0 :             eResult = InteractiveSelectionResult_Cancelled;
     363                 :          0 :             break;
     364                 :            : 
     365                 :            :         case InteractiveSelectionResult_ObtainedValue:
     366                 :            :             // OK. Our own caller will pass this as setPropertyValue, and we will then pass it to
     367                 :            :             // all slave handlers
     368                 :          0 :             break;
     369                 :            : 
     370                 :            :         default:
     371                 :            :             OSL_FAIL( "OPropertyBrowserController::onInteractivePropertySelection: unknown result value!" );
     372                 :          0 :             break;
     373                 :            :         }
     374                 :            : 
     375                 :          0 :         return eResult;
     376                 :            :     }
     377                 :            : 
     378                 :            :     //--------------------------------------------------------------------
     379                 :          0 :     void PropertyComposer::impl_ensureUIRequestComposer( const Reference< XObjectInspectorUI >& _rxInspectorUI )
     380                 :            :     {
     381                 :            :         OSL_ENSURE( !m_pUIRequestComposer.get() || m_pUIRequestComposer->getDelegatorUI().get() == _rxInspectorUI.get(),
     382                 :            :             "PropertyComposer::impl_ensureUIRequestComposer: somebody's changing the horse in the mid of the race!" );
     383                 :            : 
     384                 :          0 :         if ( !m_pUIRequestComposer.get() )
     385                 :          0 :             m_pUIRequestComposer.reset( new ComposedPropertyUIUpdate( _rxInspectorUI, this ) );
     386                 :          0 :     }
     387                 :            : 
     388                 :            :     //--------------------------------------------------------------------
     389                 :          0 :     void SAL_CALL PropertyComposer::actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const Any& _rNewValue, const Any& _rOldValue, const Reference< XObjectInspectorUI >& _rxInspectorUI, sal_Bool _bFirstTimeInit ) throw (NullPointerException, RuntimeException)
     390                 :            :     {
     391                 :          0 :         if ( !_rxInspectorUI.is() )
     392                 :          0 :             throw NullPointerException();
     393                 :            : 
     394                 :          0 :         MethodGuard aGuard( *this );
     395                 :            : 
     396                 :          0 :         impl_ensureUIRequestComposer( _rxInspectorUI );
     397                 :          0 :         ComposedUIAutoFireGuard aAutoFireGuard( *m_pUIRequestComposer );
     398                 :            : 
     399                 :            :         // ask all handlers which expressed interest in this particular property, and "compose" their
     400                 :            :         // commands for the UIUpdater
     401                 :          0 :         for (   HandlerArray::const_iterator loop = m_aSlaveHandlers.begin();
     402                 :          0 :                 loop != m_aSlaveHandlers.end();
     403                 :            :                 ++loop
     404                 :            :             )
     405                 :            :         {
     406                 :            :             // TODO: make this cheaper (cache it?)
     407                 :          0 :             const StlSyntaxSequence< ::rtl::OUString > aThisHandlersActuatingProps = (*loop)->getActuatingProperties();
     408                 :          0 :             for (   StlSyntaxSequence< ::rtl::OUString >::const_iterator loopProps = aThisHandlersActuatingProps.begin();
     409                 :          0 :                     loopProps != aThisHandlersActuatingProps.end();
     410                 :            :                     ++loopProps
     411                 :            :                 )
     412                 :            :             {
     413                 :          0 :                 if ( *loopProps == _rActuatingPropertyName )
     414                 :            :                 {
     415                 :          0 :                     (*loop)->actuatingPropertyChanged( _rActuatingPropertyName, _rNewValue, _rOldValue,
     416                 :          0 :                         m_pUIRequestComposer->getUIForPropertyHandler( *loop ),
     417                 :          0 :                         _bFirstTimeInit );
     418                 :          0 :                     break;
     419                 :            :                 }
     420                 :            :             }
     421                 :          0 :         }
     422                 :          0 :     }
     423                 :            : 
     424                 :            :     //--------------------------------------------------------------------
     425                 :          0 :     IMPLEMENT_FORWARD_XCOMPONENT( PropertyComposer, PropertyComposer_Base )
     426                 :            : 
     427                 :            :     //--------------------------------------------------------------------
     428                 :          0 :     void SAL_CALL PropertyComposer::disposing()
     429                 :            :     {
     430                 :          0 :         MethodGuard aGuard( *this );
     431                 :            : 
     432                 :            :         // dispose our slave handlers
     433                 :          0 :         for ( PropertyComposer::HandlerArray::const_iterator loop = m_aSlaveHandlers.begin();
     434                 :          0 :               loop != m_aSlaveHandlers.end();
     435                 :            :               ++loop
     436                 :            :             )
     437                 :            :         {
     438                 :          0 :             (*loop)->removePropertyChangeListener( this );
     439                 :          0 :             (*loop)->dispose();
     440                 :            :         }
     441                 :            : 
     442                 :          0 :         clearContainer( m_aSlaveHandlers );
     443                 :            : 
     444                 :          0 :         if ( m_pUIRequestComposer.get() )
     445                 :          0 :             m_pUIRequestComposer->dispose();
     446                 :          0 :         m_pUIRequestComposer.reset( NULL );
     447                 :          0 :     }
     448                 :            : 
     449                 :            :     //--------------------------------------------------------------------
     450                 :          0 :     void SAL_CALL PropertyComposer::propertyChange( const PropertyChangeEvent& evt ) throw (RuntimeException)
     451                 :            :     {
     452                 :          0 :         if ( !impl_isSupportedProperty_nothrow( evt.PropertyName ) )
     453                 :            :             // A slave handler might fire events for more properties than we support. Ignore those.
     454                 :          0 :             return;
     455                 :            : 
     456                 :          0 :         PropertyChangeEvent aTranslatedEvent( evt );
     457                 :            :         try
     458                 :            :         {
     459                 :          0 :             aTranslatedEvent.NewValue = getPropertyValue( evt.PropertyName );
     460                 :            :         }
     461                 :          0 :         catch( const Exception& )
     462                 :            :         {
     463                 :            :             DBG_UNHANDLED_EXCEPTION();
     464                 :            :         }
     465                 :          0 :         m_aPropertyListeners.notify( aTranslatedEvent, &XPropertyChangeListener::propertyChange );
     466                 :            :     }
     467                 :            : 
     468                 :            :     //--------------------------------------------------------------------
     469                 :          0 :     void SAL_CALL PropertyComposer::disposing( const EventObject& Source ) throw (RuntimeException)
     470                 :            :     {
     471                 :          0 :         MethodGuard aGuard( *this );
     472                 :          0 :         m_aPropertyListeners.disposing( Source );
     473                 :          0 :     }
     474                 :            : 
     475                 :            :     //--------------------------------------------------------------------
     476                 :          0 :     sal_Bool SAL_CALL PropertyComposer::suspend( sal_Bool _bSuspend ) throw (RuntimeException)
     477                 :            :     {
     478                 :          0 :         MethodGuard aGuard( *this );
     479                 :          0 :         for ( PropertyComposer::HandlerArray::const_iterator loop = m_aSlaveHandlers.begin();
     480                 :          0 :               loop != m_aSlaveHandlers.end();
     481                 :            :               ++loop
     482                 :            :             )
     483                 :            :         {
     484                 :          0 :             if ( !(*loop)->suspend( _bSuspend ) )
     485                 :            :             {
     486                 :          0 :                 if ( _bSuspend && ( loop != m_aSlaveHandlers.begin() ) )
     487                 :            :                 {
     488                 :            :                     // if we tried to suspend, but one of the slave handlers vetoed,
     489                 :            :                     // re-activate the handlers which actually did *not* veto
     490                 :            :                     // the suspension
     491                 :          0 :                     do
     492                 :            :                     {
     493                 :          0 :                         --loop;
     494                 :          0 :                         (*loop)->suspend( sal_False );
     495                 :            :                     }
     496                 :          0 :                     while ( loop != m_aSlaveHandlers.begin() );
     497                 :            :                 }
     498                 :          0 :                 return false;
     499                 :            :             }
     500                 :            :         }
     501                 :          0 :         return true;
     502                 :            :     }
     503                 :            : 
     504                 :            :     //--------------------------------------------------------------------
     505                 :          0 :     sal_Bool SAL_CALL PropertyComposer::hasPropertyByName( const ::rtl::OUString& _rName ) throw (RuntimeException)
     506                 :            :     {
     507                 :          0 :         return impl_isSupportedProperty_nothrow( _rName );
     508                 :            :     }
     509                 :            : 
     510                 :            : //........................................................................
     511                 :            : } // namespace pcr
     512                 :            : //........................................................................
     513                 :            : 
     514                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10