LCOV - code coverage report
Current view: top level - toolkit/source/controls - formattedcontrol.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 172 208 82.7 %
Date: 2012-08-25 Functions: 25 26 96.2 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 136 322 42.2 %

           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 <toolkit/controls/formattedcontrol.hxx>
      30                 :            : #include <toolkit/helper/unopropertyarrayhelper.hxx>
      31                 :            : #include <toolkit/helper/property.hxx>
      32                 :            : 
      33                 :            : #include <com/sun/star/awt/XVclWindowPeer.hpp>
      34                 :            : #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
      35                 :            : 
      36                 :            : #include <tools/diagnose_ex.h>
      37                 :            : #include <comphelper/processfactory.hxx>
      38                 :            : #include <osl/diagnose.h>
      39                 :            : 
      40                 :            : //........................................................................
      41                 :            : namespace toolkit
      42                 :            : {
      43                 :            : //........................................................................
      44                 :            : 
      45                 :            :     using namespace ::com::sun::star::uno;
      46                 :            :     using namespace ::com::sun::star::awt;
      47                 :            :     using namespace ::com::sun::star::lang;
      48                 :            :     using namespace ::com::sun::star::beans;
      49                 :            :     using namespace ::com::sun::star::util;
      50                 :            : 
      51                 :            :     // -------------------------------------------------------------------
      52                 :            :     namespace
      53                 :            :     {
      54                 :            :         // ...............................................................
      55                 :         32 :         ::osl::Mutex& getDefaultFormatsMutex()
      56                 :            :         {
      57 [ +  + ][ +  - ]:         32 :             static ::osl::Mutex s_aDefaultFormatsMutex;
         [ +  - ][ #  # ]
      58                 :         32 :             return s_aDefaultFormatsMutex;
      59                 :            :         }
      60                 :            : 
      61                 :            :         // ...............................................................
      62                 :          6 :         Reference< XNumberFormatsSupplier >& lcl_getDefaultFormatsAccess_nothrow()
      63                 :            :         {
      64 [ +  - ][ +  - ]:          6 :             static Reference< XNumberFormatsSupplier > s_xDefaultFormats;
      65                 :          6 :             return s_xDefaultFormats;
      66                 :            :         }
      67                 :            : 
      68                 :            :         // ...............................................................
      69                 :          6 :         bool& lcl_getTriedCreation()
      70                 :            :         {
      71                 :            :             static bool s_bTriedCreation = false;
      72                 :          6 :             return s_bTriedCreation;
      73                 :            :         }
      74                 :            : 
      75                 :            :         // ...............................................................
      76                 :          0 :         const Reference< XNumberFormatsSupplier >& lcl_getDefaultFormats_throw()
      77                 :            :         {
      78 [ #  # ][ #  # ]:          0 :             ::osl::MutexGuard aGuard( getDefaultFormatsMutex() );
      79                 :            : 
      80                 :          0 :             bool& rbTriedCreation = lcl_getTriedCreation();
      81         [ #  # ]:          0 :             Reference< XNumberFormatsSupplier >& rDefaultFormats( lcl_getDefaultFormatsAccess_nothrow() );
      82 [ #  # ][ #  # ]:          0 :             if ( !rDefaultFormats.is() && !rbTriedCreation )
                 [ #  # ]
      83                 :            :             {
      84                 :          0 :                 rbTriedCreation = true;
      85                 :            :                 rDefaultFormats = Reference< XNumberFormatsSupplier >(
      86                 :            :                     ::comphelper::createProcessComponent(
      87                 :            :                         ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.NumberFormatsSupplier" ) ) ),
      88                 :            :                     UNO_QUERY_THROW
      89 [ #  # ][ #  # ]:          0 :                 );
         [ #  # ][ #  # ]
      90                 :            :             }
      91         [ #  # ]:          0 :             if ( !rDefaultFormats.is() )
      92         [ #  # ]:          0 :                 throw RuntimeException();
      93                 :            : 
      94         [ #  # ]:          0 :             return rDefaultFormats;
      95                 :            :         }
      96                 :            : 
      97                 :            :         // ...............................................................
      98                 :            :         static oslInterlockedCount  s_refCount(0);
      99                 :            : 
     100                 :            :         // ...............................................................
     101                 :         38 :         void    lcl_registerDefaultFormatsClient()
     102                 :            :         {
     103                 :         38 :             osl_incrementInterlockedCount( &s_refCount );
     104                 :         38 :         }
     105                 :            : 
     106                 :            :         // ...............................................................
     107                 :         32 :         void    lcl_revokeDefaultFormatsClient()
     108                 :            :         {
     109 [ +  - ][ +  - ]:         32 :             ::osl::ClearableMutexGuard aGuard( getDefaultFormatsMutex() );
     110 [ +  - ][ +  + ]:         32 :             if ( 0 == osl_decrementInterlockedCount( &s_refCount ) )
     111                 :            :             {
     112         [ +  - ]:          6 :                 Reference< XNumberFormatsSupplier >& rDefaultFormats( lcl_getDefaultFormatsAccess_nothrow() );
     113                 :          6 :                 Reference< XNumberFormatsSupplier > xReleasePotentialLastReference( rDefaultFormats );
     114                 :          6 :                 rDefaultFormats.clear();
     115                 :          6 :                 lcl_getTriedCreation() = false;
     116                 :            : 
     117         [ +  - ]:          6 :                 aGuard.clear();
     118                 :          6 :                 xReleasePotentialLastReference.clear();
     119         [ +  - ]:         32 :             }
     120                 :         32 :         }
     121                 :            :     }
     122                 :            : 
     123                 :            :     // ===================================================================
     124                 :            :     // = UnoControlFormattedFieldModel
     125                 :            :     // ===================================================================
     126                 :            :     // -------------------------------------------------------------------
     127                 :         38 :     UnoControlFormattedFieldModel::UnoControlFormattedFieldModel( const Reference< XMultiServiceFactory >& i_factory )
     128                 :            :         :UnoControlModel( i_factory )
     129                 :            :         ,m_bRevokedAsClient( false )
     130                 :         38 :         ,m_bSettingValueAndText( false )
     131                 :            :     {
     132         [ +  - ]:         38 :         ImplRegisterProperty( BASEPROPERTY_ALIGN );
     133         [ +  - ]:         38 :         ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
     134         [ +  - ]:         38 :         ImplRegisterProperty( BASEPROPERTY_BORDER );
     135         [ +  - ]:         38 :         ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR );
     136         [ +  - ]:         38 :         ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
     137         [ +  - ]:         38 :         ImplRegisterProperty( BASEPROPERTY_EFFECTIVE_DEFAULT );
     138         [ +  - ]:         38 :         ImplRegisterProperty( BASEPROPERTY_EFFECTIVE_VALUE );
     139         [ +  - ]:         38 :         ImplRegisterProperty( BASEPROPERTY_EFFECTIVE_MAX );
     140         [ +  - ]:         38 :         ImplRegisterProperty( BASEPROPERTY_EFFECTIVE_MIN );
     141         [ +  - ]:         38 :         ImplRegisterProperty( BASEPROPERTY_ENABLED );
     142         [ +  - ]:         38 :         ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
     143         [ +  - ]:         38 :         ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR );
     144         [ +  - ]:         38 :         ImplRegisterProperty( BASEPROPERTY_FORMATKEY );
     145         [ +  - ]:         38 :         ImplRegisterProperty( BASEPROPERTY_FORMATSSUPPLIER );
     146         [ +  - ]:         38 :         ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
     147         [ +  - ]:         38 :         ImplRegisterProperty( BASEPROPERTY_HELPURL );
     148         [ +  - ]:         38 :         ImplRegisterProperty( BASEPROPERTY_MAXTEXTLEN );
     149         [ +  - ]:         38 :         ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
     150         [ +  - ]:         38 :         ImplRegisterProperty( BASEPROPERTY_REPEAT );
     151         [ +  - ]:         38 :         ImplRegisterProperty( BASEPROPERTY_REPEAT_DELAY );
     152         [ +  - ]:         38 :         ImplRegisterProperty( BASEPROPERTY_READONLY );
     153         [ +  - ]:         38 :         ImplRegisterProperty( BASEPROPERTY_SPIN );
     154         [ +  - ]:         38 :         ImplRegisterProperty( BASEPROPERTY_STRICTFORMAT );
     155         [ +  - ]:         38 :         ImplRegisterProperty( BASEPROPERTY_TABSTOP );
     156         [ +  - ]:         38 :         ImplRegisterProperty( BASEPROPERTY_TEXT );
     157         [ +  - ]:         38 :         ImplRegisterProperty( BASEPROPERTY_TEXTCOLOR );
     158         [ +  - ]:         38 :         ImplRegisterProperty( BASEPROPERTY_HIDEINACTIVESELECTION );
     159         [ +  - ]:         38 :         ImplRegisterProperty( BASEPROPERTY_ENFORCE_FORMAT );
     160         [ +  - ]:         38 :         ImplRegisterProperty( BASEPROPERTY_VERTICALALIGN );
     161         [ +  - ]:         38 :         ImplRegisterProperty( BASEPROPERTY_WRITING_MODE );
     162         [ +  - ]:         38 :         ImplRegisterProperty( BASEPROPERTY_CONTEXT_WRITING_MODE );
     163         [ +  - ]:         38 :         ImplRegisterProperty( BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR );
     164                 :            : 
     165                 :         38 :         Any aTreatAsNumber;
     166         [ +  - ]:         38 :         aTreatAsNumber <<= (sal_Bool) sal_True;
     167         [ +  - ]:         38 :         ImplRegisterProperty( BASEPROPERTY_TREATASNUMBER, aTreatAsNumber );
     168                 :            : 
     169         [ +  - ]:         38 :         lcl_registerDefaultFormatsClient();
     170                 :         38 :     }
     171                 :            : 
     172                 :            :     // -------------------------------------------------------------------
     173                 :         40 :     UnoControlFormattedFieldModel::~UnoControlFormattedFieldModel()
     174                 :            :     {
     175         [ -  + ]:         80 :     }
     176                 :            : 
     177                 :            :     // -------------------------------------------------------------------
     178                 :          2 :     ::rtl::OUString UnoControlFormattedFieldModel::getServiceName() throw(RuntimeException)
     179                 :            :     {
     180                 :          2 :         return ::rtl::OUString::createFromAscii( szServiceName_UnoControlFormattedFieldModel );
     181                 :            :     }
     182                 :            : 
     183                 :            :     // -------------------------------------------------------------------
     184                 :        654 :     void SAL_CALL UnoControlFormattedFieldModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw (Exception)
     185                 :            :     {
     186                 :        654 :         UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle, rValue );
     187                 :            : 
     188   [ +  +  +  + ]:        654 :         switch ( nHandle )
     189                 :            :         {
     190                 :            :         case BASEPROPERTY_EFFECTIVE_VALUE:
     191         [ +  + ]:         16 :             if ( !m_bSettingValueAndText )
     192                 :         10 :                 impl_updateTextFromValue_nothrow();
     193                 :         16 :             break;
     194                 :            :         case BASEPROPERTY_FORMATSSUPPLIER:
     195                 :         58 :             impl_updateCachedFormatter_nothrow();
     196                 :         58 :             impl_updateTextFromValue_nothrow();
     197                 :         58 :             break;
     198                 :            :         case BASEPROPERTY_FORMATKEY:
     199                 :         28 :             impl_updateCachedFormatKey_nothrow();
     200                 :         28 :             impl_updateTextFromValue_nothrow();
     201                 :         28 :             break;
     202                 :            :         }
     203                 :        654 :     }
     204                 :            : 
     205                 :            :     // -------------------------------------------------------------------
     206                 :         96 :     void UnoControlFormattedFieldModel::impl_updateTextFromValue_nothrow()
     207                 :            :     {
     208         [ -  + ]:         96 :         if ( !m_xCachedFormatter.is() )
     209                 :          0 :             impl_updateCachedFormatter_nothrow();
     210         [ -  + ]:         96 :         if ( !m_xCachedFormatter.is() )
     211                 :         96 :             return;
     212                 :            : 
     213                 :            :         try
     214                 :            :         {
     215                 :         96 :             Any aEffectiveValue;
     216         [ +  - ]:         96 :             getFastPropertyValue( aEffectiveValue, BASEPROPERTY_EFFECTIVE_VALUE );
     217                 :            : 
     218                 :         96 :             ::rtl::OUString sStringValue;
     219         [ +  + ]:         96 :             if ( !( aEffectiveValue >>= sStringValue ) )
     220                 :            :             {
     221                 :         86 :                 double nDoubleValue(0);
     222         [ -  + ]:         86 :                 if ( aEffectiveValue >>= nDoubleValue )
     223                 :            :                 {
     224                 :          0 :                     sal_Int32 nFormatKey( 0 );
     225         [ #  # ]:          0 :                     if ( m_aCachedFormat.hasValue() )
     226                 :          0 :                         m_aCachedFormat >>= nFormatKey;
     227 [ #  # ][ #  # ]:         86 :                     sStringValue = m_xCachedFormatter->convertNumberToString( nFormatKey, nDoubleValue );
     228                 :            :                 }
     229                 :            :             }
     230                 :            : 
     231 [ +  - ][ +  - ]:         96 :             Reference< XPropertySet > xThis( *this, UNO_QUERY );
     232 [ +  - ][ +  - ]:         96 :             xThis->setPropertyValue( GetPropertyName( BASEPROPERTY_TEXT ), makeAny( sStringValue ) );
         [ +  - ][ #  # ]
                 [ +  - ]
     233                 :            :         }
     234                 :          0 :         catch( const Exception& )
     235                 :            :         {
     236                 :            :             DBG_UNHANDLED_EXCEPTION();
     237                 :            :         }
     238                 :            :     }
     239                 :            : 
     240                 :            :     // -------------------------------------------------------------------
     241                 :         58 :     void UnoControlFormattedFieldModel::impl_updateCachedFormatter_nothrow()
     242                 :            :     {
     243                 :         58 :         Any aFormatsSupplier;
     244         [ +  - ]:         58 :         getFastPropertyValue( aFormatsSupplier, BASEPROPERTY_FORMATSSUPPLIER );
     245                 :            :         try
     246                 :            :         {
     247         [ +  - ]:         58 :             Reference< XNumberFormatsSupplier > xSupplier( aFormatsSupplier, UNO_QUERY );
     248         [ -  + ]:         58 :             if ( !xSupplier.is() )
     249 [ #  # ][ #  # ]:          0 :                 xSupplier = lcl_getDefaultFormats_throw();
     250                 :            : 
     251         [ +  + ]:         58 :             if ( !m_xCachedFormatter.is() )
     252                 :            :             {
     253                 :            :                 m_xCachedFormatter = Reference< XNumberFormatter >(
     254                 :            :                     ::comphelper::createProcessComponent( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.NumberFormatter" ) ) ),
     255                 :            :                     UNO_QUERY_THROW
     256 [ +  - ][ +  - ]:         30 :                 );
         [ +  - ][ +  - ]
     257                 :            :             }
     258 [ +  - ][ +  - ]:         58 :             m_xCachedFormatter->attachNumberFormatsSupplier( xSupplier );
                 [ #  # ]
     259                 :            :         }
     260         [ #  # ]:          0 :         catch( const Exception& )
     261                 :            :         {
     262                 :            :             DBG_UNHANDLED_EXCEPTION();
     263                 :         58 :         }
     264                 :         58 :     }
     265                 :            : 
     266                 :            :     // -------------------------------------------------------------------
     267                 :         28 :     void UnoControlFormattedFieldModel::impl_updateCachedFormatKey_nothrow()
     268                 :            :     {
     269                 :         28 :         Any aFormatKey;
     270         [ +  - ]:         28 :         getFastPropertyValue( aFormatKey, BASEPROPERTY_FORMATKEY );
     271                 :         28 :         m_aCachedFormat = aFormatKey;
     272                 :         28 :     }
     273                 :            : 
     274                 :            :     // -------------------------------------------------------------------
     275                 :         32 :     void UnoControlFormattedFieldModel::dispose(  ) throw(RuntimeException)
     276                 :            :     {
     277         [ +  - ]:         32 :         UnoControlModel::dispose();
     278                 :            : 
     279         [ +  - ]:         32 :         ::osl::MutexGuard aGuard( GetMutex() );
     280         [ +  - ]:         32 :         if ( !m_bRevokedAsClient )
     281                 :            :         {
     282         [ +  - ]:         32 :             lcl_revokeDefaultFormatsClient();
     283                 :         32 :             m_bRevokedAsClient = true;
     284         [ +  - ]:         32 :         }
     285                 :         32 :     }
     286                 :            : 
     287                 :            :     // -------------------------------------------------------------------
     288                 :         90 :     void UnoControlFormattedFieldModel::ImplNormalizePropertySequence( const sal_Int32 _nCount, sal_Int32* _pHandles,
     289                 :            :         Any* _pValues, sal_Int32* _pValidHandles ) const SAL_THROW(())
     290                 :            :     {
     291                 :         90 :         ImplEnsureHandleOrder( _nCount, _pHandles, _pValues, BASEPROPERTY_EFFECTIVE_VALUE, BASEPROPERTY_TEXT );
     292                 :            : 
     293                 :         90 :         UnoControlModel::ImplNormalizePropertySequence( _nCount, _pHandles, _pValues, _pValidHandles );
     294                 :         90 :     }
     295                 :            : 
     296                 :            :     // -------------------------------------------------------------------
     297                 :            :     namespace
     298                 :            :     {
     299                 :            :         class ResetFlagOnExit
     300                 :            :         {
     301                 :            :         private:
     302                 :            :             bool&   m_rFlag;
     303                 :            : 
     304                 :            :         public:
     305                 :         92 :             ResetFlagOnExit( bool& _rFlag )
     306                 :         92 :                 :m_rFlag( _rFlag )
     307                 :            :             {
     308                 :         92 :             }
     309                 :         92 :             ~ResetFlagOnExit()
     310                 :            :             {
     311                 :         92 :                 m_rFlag = false;
     312                 :         92 :             }
     313                 :            :         };
     314                 :            :     }
     315                 :            : 
     316                 :            :     // -------------------------------------------------------------------
     317                 :         92 :     void SAL_CALL UnoControlFormattedFieldModel::setPropertyValues( const Sequence< ::rtl::OUString >& _rPropertyNames, const Sequence< Any >& _rValues ) throw(PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
     318                 :            :     {
     319                 :         92 :         bool bSettingValue = false;
     320                 :         92 :         bool bSettingText = false;
     321         [ +  + ]:       6160 :         for (   const ::rtl::OUString* pPropertyNames = _rPropertyNames.getConstArray();
     322                 :       3080 :                 pPropertyNames != _rPropertyNames.getConstArray() + _rPropertyNames.getLength();
     323                 :            :                 ++pPropertyNames
     324                 :            :             )
     325                 :            :         {
     326 [ +  - ][ +  + ]:       2988 :             if ( BASEPROPERTY_EFFECTIVE_VALUE == GetPropertyId( *pPropertyNames ) )
     327                 :         12 :                 bSettingValue = true;
     328                 :            : 
     329 [ +  - ][ +  + ]:       2988 :             if ( BASEPROPERTY_TEXT == GetPropertyId( *pPropertyNames ) )
     330                 :         90 :                 bSettingText = true;
     331                 :            :         }
     332                 :            : 
     333 [ +  + ][ +  - ]:         92 :         m_bSettingValueAndText = ( bSettingValue && bSettingText );
     334                 :         92 :         ResetFlagOnExit aResetFlag( m_bSettingValueAndText );
     335         [ +  - ]:         92 :         UnoControlModel::setPropertyValues( _rPropertyNames, _rValues );
     336                 :         92 :     }
     337                 :            : 
     338                 :            :     // -------------------------------------------------------------------
     339                 :       2366 :     sal_Bool UnoControlFormattedFieldModel::convertFastPropertyValue(
     340                 :            :                 Any& rConvertedValue, Any& rOldValue, sal_Int32 nPropId,
     341                 :            :                 const Any& rValue ) throw (IllegalArgumentException)
     342                 :            :     {
     343 [ -  + ][ #  # ]:       2366 :         if ( BASEPROPERTY_EFFECTIVE_DEFAULT == nPropId && rValue.hasValue() )
                 [ -  + ]
     344                 :            :         {
     345                 :          0 :             double dVal = 0;
     346                 :          0 :             ::rtl::OUString sVal;
     347                 :          0 :             sal_Bool bStreamed = (rValue >>= dVal);
     348         [ #  # ]:          0 :             if ( bStreamed )
     349                 :            :             {
     350         [ #  # ]:          0 :                 rConvertedValue <<= dVal;
     351                 :            :             }
     352                 :            :             else
     353                 :            :             {
     354                 :          0 :                 sal_Int32  nVal = 0;
     355                 :          0 :                 bStreamed = (rValue >>= nVal);
     356         [ #  # ]:          0 :                 if ( bStreamed )
     357                 :            :                 {
     358         [ #  # ]:          0 :                     rConvertedValue <<= static_cast<double>(nVal);
     359                 :            :                 }
     360                 :            :                 else
     361                 :            :                 {
     362                 :          0 :                     bStreamed = (rValue >>= sVal);
     363         [ #  # ]:          0 :                     if ( bStreamed )
     364                 :            :                     {
     365         [ #  # ]:          0 :                         rConvertedValue <<= sVal;
     366                 :            :                     }
     367                 :            :                 }
     368                 :            :             }
     369                 :            : 
     370         [ #  # ]:          0 :             if ( bStreamed )
     371                 :            :             {
     372         [ #  # ]:          0 :                 getFastPropertyValue( rOldValue, nPropId );
     373         [ #  # ]:          0 :                 return !CompareProperties( rConvertedValue, rOldValue );
     374                 :            :             }
     375                 :            : 
     376                 :            :             throw IllegalArgumentException(
     377                 :            :                         ( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Unable to convert the given value for the property "))
     378 [ #  # ][ #  # ]:          0 :                     +=  GetPropertyName((sal_uInt16)nPropId) )
     379         [ #  # ]:          0 :                     +=  ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" (double, integer, or string expected).")),
     380                 :            :                 static_cast< XPropertySet* >(this),
     381   [ #  #  #  # ]:          0 :                 1);
     382                 :            :         }
     383                 :            : 
     384                 :       2366 :         return UnoControlModel::convertFastPropertyValue( rConvertedValue, rOldValue, nPropId, rValue );
     385                 :            :     }
     386                 :            : 
     387                 :            :     // -------------------------------------------------------------------
     388                 :       1432 :     Any UnoControlFormattedFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
     389                 :            :     {
     390                 :       1432 :         Any aReturn;
     391   [ +  -  +  + ]:       1432 :         switch (nPropId)
     392                 :            :         {
     393         [ +  - ]:         40 :             case BASEPROPERTY_DEFAULTCONTROL: aReturn <<= ::rtl::OUString( ::rtl::OUString::createFromAscii( szServiceName_UnoControlFormattedField ) ); break;
     394                 :            : 
     395         [ #  # ]:          0 :             case BASEPROPERTY_TREATASNUMBER: aReturn <<= (sal_Bool)sal_True; break;
     396                 :            : 
     397                 :            :             case BASEPROPERTY_EFFECTIVE_DEFAULT:
     398                 :            :             case BASEPROPERTY_EFFECTIVE_VALUE:
     399                 :            :             case BASEPROPERTY_EFFECTIVE_MAX:
     400                 :            :             case BASEPROPERTY_EFFECTIVE_MIN:
     401                 :            :             case BASEPROPERTY_FORMATKEY:
     402                 :            :             case BASEPROPERTY_FORMATSSUPPLIER:
     403                 :            :                 // (void)
     404                 :        236 :                 break;
     405                 :            : 
     406         [ +  - ]:       1156 :             default : aReturn = UnoControlModel::ImplGetDefaultValue( nPropId ); break;
     407                 :            :         }
     408                 :            : 
     409                 :       1432 :         return aReturn;
     410                 :            :     }
     411                 :            : 
     412                 :            :     // -------------------------------------------------------------------
     413                 :       4424 :     ::cppu::IPropertyArrayHelper& UnoControlFormattedFieldModel::getInfoHelper()
     414                 :            :     {
     415                 :            :         static UnoPropertyArrayHelper* pHelper = NULL;
     416         [ +  + ]:       4424 :         if ( !pHelper )
     417                 :            :         {
     418         [ +  - ]:          6 :             Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
     419 [ +  - ][ +  - ]:          6 :             pHelper = new UnoPropertyArrayHelper( aIDs );
     420                 :            :         }
     421                 :       4424 :         return *pHelper;
     422                 :            :     }
     423                 :            : 
     424                 :            :     // beans::XMultiPropertySet
     425                 :            :     // -------------------------------------------------------------------
     426                 :        182 :     Reference< XPropertySetInfo > UnoControlFormattedFieldModel::getPropertySetInfo(  ) throw(RuntimeException)
     427                 :            :     {
     428 [ +  + ][ +  - ]:        182 :         static Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
         [ +  - ][ +  - ]
                 [ #  # ]
     429                 :        182 :         return xInfo;
     430                 :            :     }
     431                 :            : 
     432                 :            :     // ===================================================================
     433                 :            :     // = UnoFormattedFieldControl
     434                 :            :     // ===================================================================
     435                 :            :     // -------------------------------------------------------------------
     436                 :          2 :     UnoFormattedFieldControl::UnoFormattedFieldControl( const Reference< XMultiServiceFactory >& i_factory )
     437                 :          2 :         :UnoSpinFieldControl( i_factory )
     438                 :            :     {
     439                 :          2 :     }
     440                 :            : 
     441                 :            :     // -------------------------------------------------------------------
     442                 :          2 :     ::rtl::OUString UnoFormattedFieldControl::GetComponentServiceName()
     443                 :            :     {
     444                 :          2 :         return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FormattedField"));
     445                 :            :     }
     446                 :            : 
     447                 :            :     // -------------------------------------------------------------------
     448                 :         12 :     void UnoFormattedFieldControl::textChanged(const TextEvent& e) throw(RuntimeException)
     449                 :            :     {
     450 [ +  - ][ +  - ]:         12 :         Reference< XVclWindowPeer >  xPeer(getPeer(), UNO_QUERY);
     451                 :            :         OSL_ENSURE(xPeer.is(), "UnoFormattedFieldControl::textChanged : what kind of peer do I have ?");
     452                 :            : 
     453         [ +  - ]:         12 :         Sequence< ::rtl::OUString > aNames( 2 );
     454 [ +  - ][ +  - ]:         12 :         aNames[0] = GetPropertyName( BASEPROPERTY_EFFECTIVE_VALUE );
     455 [ +  - ][ +  - ]:         12 :         aNames[1] = GetPropertyName( BASEPROPERTY_TEXT );
     456                 :            : 
     457         [ +  - ]:         12 :         Sequence< Any > aValues( 2 );
     458 [ +  - ][ +  - ]:         12 :         aValues[0] = xPeer->getProperty( aNames[0] );
         [ +  - ][ +  - ]
     459 [ +  - ][ +  - ]:         12 :         aValues[1] = xPeer->getProperty( aNames[1] );
         [ +  - ][ +  - ]
     460                 :            : 
     461         [ +  - ]:         12 :         ImplSetPropertyValues( aNames, aValues, sal_False );
     462                 :            : 
     463 [ +  - ][ +  - ]:         12 :         if ( GetTextListeners().getLength() )
     464 [ +  - ][ +  - ]:         12 :             GetTextListeners().textChanged( e );
                 [ +  - ]
     465                 :         12 :     }
     466                 :            : 
     467                 :            : //........................................................................
     468                 :            : }   // namespace toolkit
     469                 :            : //........................................................................
     470                 :            : 
     471                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10