LCOV - code coverage report
Current view: top level - framework/source/fwe/classes - actiontriggerseparatorpropertyset.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 94 0.0 %
Date: 2014-04-11 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             : #include <classes/actiontriggerseparatorpropertyset.hxx>
      21             : #include <threadhelp/lockhelper.hxx>
      22             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      23             : #include <cppuhelper/proptypehlp.hxx>
      24             : #include <cppuhelper/supportsservice.hxx>
      25             : #include <cppuhelper/typeprovider.hxx>
      26             : #include <vcl/svapp.hxx>
      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()
      49             :         :   OBroadcastHelper        ( m_aMutex )
      50             :         ,   OPropertySetHelper      ( *(static_cast< OBroadcastHelper * >(this))        )
      51             :         ,   OWeakObject             (                                                   )
      52           0 :         ,   m_nSeparatorType( 0 )
      53             : {
      54           0 : }
      55             : 
      56           0 : ActionTriggerSeparatorPropertySet::~ActionTriggerSeparatorPropertySet()
      57             : {
      58           0 : }
      59             : 
      60             : // XInterface
      61           0 : Any SAL_CALL ActionTriggerSeparatorPropertySet::queryInterface( const Type& aType )
      62             : throw ( RuntimeException, std::exception )
      63             : {
      64             :     Any a = ::cppu::queryInterface(
      65             :                 aType,
      66             :                 (static_cast< XServiceInfo* >(this)),
      67           0 :                 (static_cast< XTypeProvider* >(this)));
      68             : 
      69           0 :     if( a.hasValue() )
      70           0 :         return a;
      71             :     else
      72             :     {
      73           0 :         a = OPropertySetHelper::queryInterface( aType );
      74             : 
      75           0 :         if( a.hasValue() )
      76           0 :             return a;
      77             :     }
      78             : 
      79           0 :     return OWeakObject::queryInterface( aType );
      80             : }
      81             : 
      82           0 : void ActionTriggerSeparatorPropertySet::acquire() throw()
      83             : {
      84           0 :     OWeakObject::acquire();
      85           0 : }
      86             : 
      87           0 : void ActionTriggerSeparatorPropertySet::release() throw()
      88             : {
      89           0 :     OWeakObject::release();
      90           0 : }
      91             : 
      92             : // XServiceInfo
      93           0 : OUString SAL_CALL ActionTriggerSeparatorPropertySet::getImplementationName()
      94             : throw ( RuntimeException, std::exception )
      95             : {
      96           0 :     return OUString( IMPLEMENTATIONNAME_ACTIONTRIGGERSEPARATOR );
      97             : }
      98             : 
      99           0 : sal_Bool SAL_CALL ActionTriggerSeparatorPropertySet::supportsService( const OUString& ServiceName )
     100             : throw ( RuntimeException, std::exception )
     101             : {
     102           0 :     return cppu::supportsService(this, ServiceName);
     103             : }
     104             : 
     105           0 : Sequence< OUString > SAL_CALL ActionTriggerSeparatorPropertySet::getSupportedServiceNames()
     106             : throw ( RuntimeException, std::exception )
     107             : {
     108           0 :     Sequence< OUString > seqServiceNames( 1 );
     109           0 :     seqServiceNames[0] = OUString( SERVICENAME_ACTIONTRIGGERSEPARATOR );
     110           0 :     return seqServiceNames;
     111             : }
     112             : 
     113             : // XTypeProvider
     114           0 : Sequence< Type > SAL_CALL ActionTriggerSeparatorPropertySet::getTypes() throw ( RuntimeException, std::exception )
     115             : {
     116             :     // Optimize this method !
     117             :     // We initialize a static variable only one time. And we don't must use a mutex at every call!
     118             :     // For the first call; pTypeCollection is NULL - for the second call pTypeCollection is different from NULL!
     119             :     static ::cppu::OTypeCollection* pTypeCollection = NULL;
     120             : 
     121           0 :     if ( pTypeCollection == NULL )
     122             :     {
     123             :         // Ready for multithreading; get global mutex for first call of this method only! see before
     124           0 :         osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() );
     125             : 
     126             :         // Control these pointer again ... it can be, that another instance will be faster then these!
     127           0 :         if ( pTypeCollection == NULL )
     128             :         {
     129             :             // Create a static typecollection ...
     130             :             static ::cppu::OTypeCollection aTypeCollection(
     131           0 :                         ::getCppuType(( const Reference< XPropertySet           >*)NULL ) ,
     132           0 :                         ::getCppuType(( const Reference< XFastPropertySet       >*)NULL ) ,
     133           0 :                         ::getCppuType(( const Reference< XMultiPropertySet      >*)NULL ) ,
     134           0 :                         ::getCppuType(( const Reference< XServiceInfo           >*)NULL ) ,
     135           0 :                         ::getCppuType(( const Reference< XTypeProvider          >*)NULL ) );
     136             : 
     137             :             // ... and set his address to static pointer!
     138           0 :             pTypeCollection = &aTypeCollection;
     139           0 :         }
     140             :     }
     141             : 
     142           0 :     return pTypeCollection->getTypes();
     143             : }
     144             : 
     145           0 : Sequence< sal_Int8 > SAL_CALL ActionTriggerSeparatorPropertySet::getImplementationId() throw ( RuntimeException, std::exception )
     146             : {
     147           0 :     return css::uno::Sequence<sal_Int8>();
     148             : }
     149             : 
     150           0 : sal_Bool SAL_CALL ActionTriggerSeparatorPropertySet::convertFastPropertyValue(
     151             :     Any&        aConvertedValue,
     152             :     Any&        aOldValue,
     153             :     sal_Int32   nHandle,
     154             :     const Any&  aValue  )
     155             : throw( IllegalArgumentException )
     156             : {
     157             :     //  Check, if value of property will changed in method "setFastPropertyValue_NoBroadcast()".
     158             :     //  Return sal_True, if changed - else return sal_False.
     159             :     //  Attention: Method "impl_tryToChangeProperty()" can throw the IllegalArgumentException !!!
     160             :     //  Initialize return value with sal_False !!!
     161             :     //  (Handle can be invalid)
     162           0 :     bool bReturn = false;
     163             : 
     164           0 :     switch( nHandle )
     165             :     {
     166             :         case HANDLE_TYPE:
     167           0 :             bReturn = impl_tryToChangeProperty( m_nSeparatorType, aValue, aOldValue, aConvertedValue );
     168           0 :             break;
     169             :     }
     170             : 
     171             :     // Return state of operation.
     172           0 :     return bReturn;
     173             : }
     174             : 
     175           0 : void SAL_CALL ActionTriggerSeparatorPropertySet::setFastPropertyValue_NoBroadcast(
     176             :     sal_Int32 nHandle, const Any& aValue )
     177             : throw( Exception, std::exception )
     178             : {
     179           0 :     ::osl::MutexGuard aGuard( LockHelper::getGlobalLock() );
     180             : 
     181             :     // Search for right handle ... and try to set property value.
     182           0 :     switch( nHandle )
     183             :     {
     184             :         case HANDLE_TYPE:
     185           0 :             aValue >>= m_nSeparatorType;
     186           0 :             break;
     187           0 :     }
     188           0 : }
     189             : 
     190           0 : void SAL_CALL ActionTriggerSeparatorPropertySet::getFastPropertyValue(
     191             :     Any& aValue, sal_Int32 nHandle ) const
     192             : {
     193           0 :     ::osl::MutexGuard aGuard( LockHelper::getGlobalLock() );
     194             : 
     195             :     // Search for right handle ... and try to get property value.
     196           0 :     switch( nHandle )
     197             :     {
     198             :         case HANDLE_TYPE:
     199           0 :             aValue <<= m_nSeparatorType;
     200           0 :             break;
     201           0 :     }
     202           0 : }
     203             : 
     204           0 : ::cppu::IPropertyArrayHelper& SAL_CALL ActionTriggerSeparatorPropertySet::getInfoHelper()
     205             : {
     206             :     // Optimize this method !
     207             :     // We initialize a static variable only one time. And we don't must use a mutex at every call!
     208             :     // For the first call; pInfoHelper is NULL - for the second call pInfoHelper is different from NULL!
     209             :     static OPropertyArrayHelper* pInfoHelper = NULL;
     210             : 
     211           0 :     if( pInfoHelper == NULL )
     212             :     {
     213             :         // Ready for multithreading
     214           0 :         ::osl::MutexGuard aGuard( LockHelper::getGlobalLock() );
     215             :         // Control this pointer again, another instance can be faster then these!
     216           0 :         if( pInfoHelper == NULL )
     217             :         {
     218             :             // Define static member to give structure of properties to baseclass "OPropertySetHelper".
     219             :             // "impl_getStaticPropertyDescriptor" is a non exported and static funtion, who will define a static propertytable.
     220             :             // "sal_True" say: Table is sorted by name.
     221           0 :             static OPropertyArrayHelper aInfoHelper( impl_getStaticPropertyDescriptor(), sal_True );
     222           0 :             pInfoHelper = &aInfoHelper;
     223           0 :         }
     224             :     }
     225             : 
     226           0 :     return (*pInfoHelper);
     227             : }
     228             : 
     229           0 : Reference< XPropertySetInfo > SAL_CALL ActionTriggerSeparatorPropertySet::getPropertySetInfo()
     230             : throw ( RuntimeException, std::exception )
     231             : {
     232             :     // Optimize this method !
     233             :     // We initialize a static variable only one time. And we don't must use a mutex at every call!
     234             :     // For the first call; pInfo is NULL - for the second call pInfo is different from NULL!
     235             :     static Reference< XPropertySetInfo >* pInfo = NULL;
     236             : 
     237           0 :     if( pInfo == NULL )
     238             :     {
     239             :         // Ready for multithreading
     240           0 :         ::osl::MutexGuard aGuard( LockHelper::getGlobalLock() );
     241             :         // Control this pointer again, another instance can be faster then these!
     242           0 :         if( pInfo == NULL )
     243             :         {
     244             :             // Create structure of propertysetinfo for baseclass "OPropertySetHelper".
     245             :             // (Use method "getInfoHelper()".)
     246           0 :             static Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
     247           0 :             pInfo = &xInfo;
     248           0 :         }
     249             :     }
     250             : 
     251           0 :     return (*pInfo);
     252             : }
     253             : 
     254           0 : const Sequence< Property > ActionTriggerSeparatorPropertySet::impl_getStaticPropertyDescriptor()
     255             : {
     256             :     const Property pActionTriggerPropertys[] =
     257             :     {
     258           0 :         Property( OUString( "SeparatorType" ), HANDLE_TYPE, ::getCppuType((sal_Int16*)0), PropertyAttribute::TRANSIENT )
     259           0 :     };
     260             : 
     261             :     // Use it to initialize sequence!
     262           0 :     const Sequence< Property > seqActionTriggerPropertyDescriptor( pActionTriggerPropertys, PROPERTYCOUNT );
     263             : 
     264             :     // Return "PropertyDescriptor"
     265           0 :     return seqActionTriggerPropertyDescriptor;
     266             : }
     267             : 
     268           0 : bool ActionTriggerSeparatorPropertySet::impl_tryToChangeProperty(
     269             :     sal_Int16           aCurrentValue   ,
     270             :     const   Any&        aNewValue       ,
     271             :     Any&                aOldValue       ,
     272             :     Any&                aConvertedValue )
     273             : throw( IllegalArgumentException )
     274             : {
     275             :     // Set default return value if method failed.
     276           0 :     bool bReturn = false;
     277             :     // Get new value from any.
     278             :     // IllegalArgumentException() can be thrown!
     279           0 :     sal_Int16 aValue = 0;
     280           0 :     convertPropertyValue( aValue, aNewValue );
     281             : 
     282             :     // If value change ...
     283           0 :     if( aValue != aCurrentValue )
     284             :     {
     285             :         // ... set information of change.
     286           0 :         aOldValue       <<= aCurrentValue;
     287           0 :         aConvertedValue <<= aValue;
     288             :         // Return OK - "value will be change ..."
     289           0 :         bReturn = true;
     290             :     }
     291             :     else
     292             :     {
     293             :         // ... clear information of return parameter!
     294           0 :         aOldValue.clear         ();
     295           0 :         aConvertedValue.clear   ();
     296             :         // Return NOTHING - "value will not be change ..."
     297           0 :         bReturn = false;
     298             :     }
     299             : 
     300           0 :     return bReturn;
     301             : }
     302             : 
     303             : }
     304             : 
     305             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10