LCOV - code coverage report
Current view: top level - libreoffice/framework/source/fwe/classes - actiontriggerseparatorpropertyset.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 104 0.0 %
Date: 2012-12-27 Functions: 0 18 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10