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

Generated by: LCOV version 1.10