LCOV - code coverage report
Current view: top level - framework/source/fwe/classes - actiontriggerseparatorpropertyset.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 104 0.0 %
Date: 2012-08-25 Functions: 0 18 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 168 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                 :            : 
      30                 :            : #include <classes/actiontriggerseparatorpropertyset.hxx>
      31                 :            : #include <com/sun/star/beans/PropertyAttribute.hpp>
      32                 :            : #include <cppuhelper/proptypehlp.hxx>
      33                 :            : #include <cppuhelper/typeprovider.hxx>
      34                 :            : #include <vcl/svapp.hxx>
      35                 :            : 
      36                 :            : 
      37                 :            : using namespace cppu;
      38                 :            : using namespace com::sun::star::uno;
      39                 :            : using namespace com::sun::star::beans;
      40                 :            : using namespace com::sun::star::lang;
      41                 :            : using namespace com::sun::star::awt;
      42                 :            : 
      43                 :            : // Handles for properties
      44                 :            : // (PLEASE SORT THIS FIELD, IF YOU ADD NEW PROPERTIES!)
      45                 :            : // We use an enum to define these handles, to use all numbers from 0 to nn and
      46                 :            : // if you add someone, you don't must control this!
      47                 :            : // But don't forget to change values of follow defines, if you do something with this enum!
      48                 :            : enum EPROPERTIES
      49                 :            : {
      50                 :            :     HANDLE_TYPE,
      51                 :            :     PROPERTYCOUNT
      52                 :            : };
      53                 :            : 
      54                 :            : namespace framework
      55                 :            : {
      56                 :            : 
      57                 :          0 : ActionTriggerSeparatorPropertySet::ActionTriggerSeparatorPropertySet( const Reference< XMultiServiceFactory >& /*ServiceManager*/ )
      58                 :          0 :         :   ThreadHelpBase          ( &Application::GetSolarMutex()                     )
      59         [ #  # ]:          0 :         ,   OBroadcastHelper        ( m_aLock.getShareableOslMutex()                    )
      60                 :            :         ,   OPropertySetHelper      ( *(static_cast< OBroadcastHelper * >(this))      )
      61                 :            :         ,   OWeakObject             (                                                   )
      62 [ #  # ][ #  # ]:          0 :         ,   m_nSeparatorType( 0 )
      63                 :            : {
      64                 :          0 : }
      65                 :            : 
      66 [ #  # ][ #  # ]:          0 : ActionTriggerSeparatorPropertySet::~ActionTriggerSeparatorPropertySet()
                 [ #  # ]
      67                 :            : {
      68         [ #  # ]:          0 : }
      69                 :            : 
      70                 :            : // XInterface
      71                 :          0 : Any SAL_CALL ActionTriggerSeparatorPropertySet::queryInterface( const Type& aType )
      72                 :            : throw ( RuntimeException )
      73                 :            : {
      74                 :            :     Any a = ::cppu::queryInterface(
      75                 :            :                 aType ,
      76         [ #  # ]:          0 :                 (static_cast< XServiceInfo* >(this)));
      77                 :            : 
      78         [ #  # ]:          0 :     if( a.hasValue() )
      79                 :          0 :         return a;
      80                 :            :     else
      81                 :            :     {
      82         [ #  # ]:          0 :         a = OPropertySetHelper::queryInterface( aType );
      83                 :            : 
      84         [ #  # ]:          0 :         if( a.hasValue() )
      85                 :          0 :             return a;
      86                 :            :     }
      87                 :            : 
      88         [ #  # ]:          0 :     return OWeakObject::queryInterface( aType );
      89                 :            : }
      90                 :            : 
      91                 :          0 : void ActionTriggerSeparatorPropertySet::acquire() throw()
      92                 :            : {
      93                 :          0 :     OWeakObject::acquire();
      94                 :          0 : }
      95                 :            : 
      96                 :          0 : void ActionTriggerSeparatorPropertySet::release() throw()
      97                 :            : {
      98                 :          0 :     OWeakObject::release();
      99                 :          0 : }
     100                 :            : 
     101                 :            : // XServiceInfo
     102                 :          0 : ::rtl::OUString SAL_CALL ActionTriggerSeparatorPropertySet::getImplementationName()
     103                 :            : throw ( RuntimeException )
     104                 :            : {
     105                 :          0 :     return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATIONNAME_ACTIONTRIGGERSEPARATOR ));
     106                 :            : }
     107                 :            : 
     108                 :          0 : sal_Bool SAL_CALL ActionTriggerSeparatorPropertySet::supportsService( const ::rtl::OUString& ServiceName )
     109                 :            : throw ( RuntimeException )
     110                 :            : {
     111         [ #  # ]:          0 :     if ( ServiceName.equalsAscii( SERVICENAME_ACTIONTRIGGERSEPARATOR ))
     112                 :          0 :         return sal_True;
     113                 :            : 
     114                 :          0 :     return sal_False;
     115                 :            : }
     116                 :            : 
     117                 :          0 : Sequence< ::rtl::OUString > SAL_CALL ActionTriggerSeparatorPropertySet::getSupportedServiceNames()
     118                 :            : throw ( RuntimeException )
     119                 :            : {
     120                 :          0 :     Sequence< ::rtl::OUString > seqServiceNames( 1 );
     121 [ #  # ][ #  # ]:          0 :     seqServiceNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICENAME_ACTIONTRIGGERSEPARATOR ));
     122                 :          0 :     return seqServiceNames;
     123                 :            : }
     124                 :            : 
     125                 :            : // XTypeProvider
     126                 :          0 : Sequence< Type > SAL_CALL ActionTriggerSeparatorPropertySet::getTypes() throw ( RuntimeException )
     127                 :            : {
     128                 :            :     // Optimize this method !
     129                 :            :     // We initialize a static variable only one time. And we don't must use a mutex at every call!
     130                 :            :     // For the first call; pTypeCollection is NULL - for the second call pTypeCollection is different from NULL!
     131                 :            :     static ::cppu::OTypeCollection* pTypeCollection = NULL ;
     132                 :            : 
     133         [ #  # ]:          0 :     if ( pTypeCollection == NULL )
     134                 :            :     {
     135                 :            :         // Ready for multithreading; get global mutex for first call of this method only! see before
     136 [ #  # ][ #  # ]:          0 :         osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
     137                 :            : 
     138                 :            :         // Control these pointer again ... it can be, that another instance will be faster then these!
     139         [ #  # ]:          0 :         if ( pTypeCollection == NULL )
     140                 :            :         {
     141                 :            :             // Create a static typecollection ...
     142                 :            :             static ::cppu::OTypeCollection aTypeCollection(
     143         [ #  # ]:          0 :                         ::getCppuType(( const Reference< XPropertySet           >*)NULL ) ,
     144         [ #  # ]:          0 :                         ::getCppuType(( const Reference< XFastPropertySet       >*)NULL ) ,
     145         [ #  # ]:          0 :                         ::getCppuType(( const Reference< XMultiPropertySet      >*)NULL ) ,
     146         [ #  # ]:          0 :                         ::getCppuType(( const Reference< XServiceInfo           >*)NULL ) ,
     147 [ #  # ][ #  # ]:          0 :                         ::getCppuType(( const Reference< XTypeProvider          >*)NULL ) ) ;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     148                 :            : 
     149                 :            :             // ... and set his address to static pointer!
     150                 :          0 :             pTypeCollection = &aTypeCollection ;
     151         [ #  # ]:          0 :         }
     152                 :            :     }
     153                 :            : 
     154                 :          0 :     return pTypeCollection->getTypes() ;
     155                 :            : }
     156                 :            : 
     157                 :          0 : Sequence< sal_Int8 > SAL_CALL ActionTriggerSeparatorPropertySet::getImplementationId() throw ( RuntimeException )
     158                 :            : {
     159                 :            :     // Create one Id for all instances of this class.
     160                 :            :     // Use ethernet address to do this! (sal_True)
     161                 :            : 
     162                 :            :     // Optimize this method
     163                 :            :     // We initialize a static variable only one time. And we don't must use a mutex at every call!
     164                 :            :     // For the first call; pID is NULL - for the second call pID is different from NULL!
     165                 :            :     static ::cppu::OImplementationId* pID = NULL ;
     166                 :            : 
     167         [ #  # ]:          0 :     if ( pID == NULL )
     168                 :            :     {
     169                 :            :         // Ready for multithreading; get global mutex for first call of this method only! see before
     170 [ #  # ][ #  # ]:          0 :         osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
     171                 :            : 
     172                 :            :         // Control these pointer again ... it can be, that another instance will be faster then these!
     173         [ #  # ]:          0 :         if ( pID == NULL )
     174                 :            :         {
     175                 :            :             // Create a new static ID ...
     176 [ #  # ][ #  # ]:          0 :             static ::cppu::OImplementationId aID( sal_False ) ;
     177                 :            :             // ... and set his address to static pointer!
     178                 :          0 :             pID = &aID ;
     179         [ #  # ]:          0 :         }
     180                 :            :     }
     181                 :            : 
     182                 :          0 :     return pID->getImplementationId() ;
     183                 :            : }
     184                 :            : 
     185                 :            : //---------------------------------------------------------------------------------------------------------
     186                 :            : //  OPropertySetHelper implementation
     187                 :            : //---------------------------------------------------------------------------------------------------------
     188                 :            : 
     189                 :          0 : sal_Bool SAL_CALL ActionTriggerSeparatorPropertySet::convertFastPropertyValue(
     190                 :            :     Any&        aConvertedValue,
     191                 :            :     Any&        aOldValue,
     192                 :            :     sal_Int32   nHandle,
     193                 :            :     const Any&  aValue  )
     194                 :            : throw( IllegalArgumentException )
     195                 :            : {
     196                 :            :     //  Check, if value of property will changed in method "setFastPropertyValue_NoBroadcast()".
     197                 :            :     //  Return sal_True, if changed - else return sal_False.
     198                 :            :     //  Attention: Method "impl_tryToChangeProperty()" can throw the IllegalArgumentException !!!
     199                 :            :     //  Initialize return value with sal_False !!!
     200                 :            :     //  (Handle can be invalid)
     201                 :          0 :     sal_Bool bReturn = sal_False;
     202                 :            : 
     203         [ #  # ]:          0 :     switch( nHandle )
     204                 :            :     {
     205                 :            :         case HANDLE_TYPE:
     206                 :          0 :             bReturn = impl_tryToChangeProperty( m_nSeparatorType, aValue, aOldValue, aConvertedValue );
     207                 :          0 :             break;
     208                 :            :     }
     209                 :            : 
     210                 :            :     // Return state of operation.
     211                 :          0 :     return bReturn;
     212                 :            : }
     213                 :            : 
     214                 :            : 
     215                 :          0 : void SAL_CALL ActionTriggerSeparatorPropertySet::setFastPropertyValue_NoBroadcast(
     216                 :            :     sal_Int32 nHandle, const Any& aValue )
     217                 :            : throw( Exception )
     218                 :            : {
     219 [ #  # ][ #  # ]:          0 :     ::osl::MutexGuard aGuard( LockHelper::getGlobalLock().getShareableOslMutex() );
                 [ #  # ]
     220                 :            : 
     221                 :            :     // Search for right handle ... and try to set property value.
     222         [ #  # ]:          0 :     switch( nHandle )
     223                 :            :     {
     224                 :            :         case HANDLE_TYPE:
     225                 :          0 :             aValue >>= m_nSeparatorType;
     226                 :          0 :             break;
     227         [ #  # ]:          0 :     }
     228                 :          0 : }
     229                 :            : 
     230                 :          0 : void SAL_CALL ActionTriggerSeparatorPropertySet::getFastPropertyValue(
     231                 :            :     Any& aValue, sal_Int32 nHandle ) const
     232                 :            : {
     233 [ #  # ][ #  # ]:          0 :     ::osl::MutexGuard aGuard( LockHelper::getGlobalLock().getShareableOslMutex() );
                 [ #  # ]
     234                 :            : 
     235                 :            :     // Search for right handle ... and try to get property value.
     236         [ #  # ]:          0 :     switch( nHandle )
     237                 :            :     {
     238                 :            :         case HANDLE_TYPE:
     239         [ #  # ]:          0 :             aValue <<= m_nSeparatorType;
     240                 :          0 :             break;
     241         [ #  # ]:          0 :     }
     242                 :          0 : }
     243                 :            : 
     244                 :          0 : ::cppu::IPropertyArrayHelper& SAL_CALL ActionTriggerSeparatorPropertySet::getInfoHelper()
     245                 :            : {
     246                 :            :     // Optimize this method !
     247                 :            :     // We initialize a static variable only one time. And we don't must use a mutex at every call!
     248                 :            :     // For the first call; pInfoHelper is NULL - for the second call pInfoHelper is different from NULL!
     249                 :            :     static OPropertyArrayHelper* pInfoHelper = NULL;
     250                 :            : 
     251         [ #  # ]:          0 :     if( pInfoHelper == NULL )
     252                 :            :     {
     253                 :            :         // Ready for multithreading
     254 [ #  # ][ #  # ]:          0 :         ::osl::MutexGuard aGuard( LockHelper::getGlobalLock().getShareableOslMutex() );
                 [ #  # ]
     255                 :            :         // Control this pointer again, another instance can be faster then these!
     256         [ #  # ]:          0 :         if( pInfoHelper == NULL )
     257                 :            :         {
     258                 :            :             // Define static member to give structure of properties to baseclass "OPropertySetHelper".
     259                 :            :             // "impl_getStaticPropertyDescriptor" is a non exported and static funtion, who will define a static propertytable.
     260                 :            :             // "sal_True" say: Table is sorted by name.
     261 [ #  # ][ #  # ]:          0 :             static OPropertyArrayHelper aInfoHelper( impl_getStaticPropertyDescriptor(), sal_True );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     262                 :          0 :             pInfoHelper = &aInfoHelper;
     263         [ #  # ]:          0 :         }
     264                 :            :     }
     265                 :            : 
     266                 :          0 :     return (*pInfoHelper);
     267                 :            : }
     268                 :            : 
     269                 :          0 : Reference< XPropertySetInfo > SAL_CALL ActionTriggerSeparatorPropertySet::getPropertySetInfo()
     270                 :            : throw ( RuntimeException )
     271                 :            : {
     272                 :            :     // Optimize this method !
     273                 :            :     // We initialize a static variable only one time. And we don't must use a mutex at every call!
     274                 :            :     // For the first call; pInfo is NULL - for the second call pInfo is different from NULL!
     275                 :            :     static Reference< XPropertySetInfo >* pInfo = NULL ;
     276                 :            : 
     277         [ #  # ]:          0 :     if( pInfo == NULL )
     278                 :            :     {
     279                 :            :         // Ready for multithreading
     280 [ #  # ][ #  # ]:          0 :         ::osl::MutexGuard aGuard( LockHelper::getGlobalLock().getShareableOslMutex() );
                 [ #  # ]
     281                 :            :         // Control this pointer again, another instance can be faster then these!
     282         [ #  # ]:          0 :         if( pInfo == NULL )
     283                 :            :         {
     284                 :            :             // Create structure of propertysetinfo for baseclass "OPropertySetHelper".
     285                 :            :             // (Use method "getInfoHelper()".)
     286 [ #  # ][ #  # ]:          0 :             static Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     287                 :          0 :             pInfo = &xInfo;
     288         [ #  # ]:          0 :         }
     289                 :            :     }
     290                 :            : 
     291                 :          0 :     return (*pInfo);
     292                 :            : }
     293                 :            : 
     294                 :          0 : const Sequence< Property > ActionTriggerSeparatorPropertySet::impl_getStaticPropertyDescriptor()
     295                 :            : {
     296                 :            :     const Property pActionTriggerPropertys[] =
     297                 :            :     {
     298         [ #  # ]:          0 :         Property( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SeparatorType" )), HANDLE_TYPE, ::getCppuType((sal_Int16*)0), PropertyAttribute::TRANSIENT )
     299         [ #  # ]:          0 :     };
           [ #  #  #  # ]
     300                 :            : 
     301                 :            :     // Use it to initialize sequence!
     302         [ #  # ]:          0 :     const Sequence< Property > seqActionTriggerPropertyDescriptor( pActionTriggerPropertys, PROPERTYCOUNT );
     303                 :            : 
     304                 :            :     // Return "PropertyDescriptor"
     305 [ #  # ][ #  # ]:          0 :     return seqActionTriggerPropertyDescriptor ;
     306                 :            : }
     307                 :            : 
     308                 :            : 
     309                 :            : //******************************************************************************************************************************
     310                 :            : //  private method
     311                 :            : //******************************************************************************************************************************
     312                 :          0 : sal_Bool ActionTriggerSeparatorPropertySet::impl_tryToChangeProperty(
     313                 :            :     sal_Int16           aCurrentValue   ,
     314                 :            :     const   Any&        aNewValue       ,
     315                 :            :     Any&                aOldValue       ,
     316                 :            :     Any&                aConvertedValue )
     317                 :            : throw( IllegalArgumentException )
     318                 :            : {
     319                 :            :     // Set default return value if method failed.
     320                 :          0 :     sal_Bool bReturn = sal_False;
     321                 :            :     // Get new value from any.
     322                 :            :     // IllegalArgumentException() can be thrown!
     323                 :          0 :     sal_Int16 aValue = 0;
     324         [ #  # ]:          0 :     convertPropertyValue( aValue, aNewValue );
     325                 :            : 
     326                 :            :     // If value change ...
     327         [ #  # ]:          0 :     if( aValue != aCurrentValue )
     328                 :            :     {
     329                 :            :         // ... set information of change.
     330         [ #  # ]:          0 :         aOldValue       <<= aCurrentValue   ;
     331         [ #  # ]:          0 :         aConvertedValue <<= aValue          ;
     332                 :            :         // Return OK - "value will be change ..."
     333                 :          0 :         bReturn = sal_True;
     334                 :            :     }
     335                 :            :     else
     336                 :            :     {
     337                 :            :         // ... clear information of return parameter!
     338                 :          0 :         aOldValue.clear         () ;
     339                 :          0 :         aConvertedValue.clear   () ;
     340                 :            :         // Return NOTHING - "value will not be change ..."
     341                 :          0 :         bReturn = sal_False;
     342                 :            :     }
     343                 :            : 
     344                 :          0 :     return bReturn;
     345                 :            : }
     346                 :            : 
     347                 :            : }
     348                 :            : 
     349                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10