LCOV - code coverage report
Current view: top level - libreoffice/forms/source/component - spinbutton.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 4 87 4.6 %
Date: 2012-12-27 Functions: 3 26 11.5 %
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 "spinbutton.hxx"
      21             : #include <comphelper/streamsection.hxx>
      22             : #include <comphelper/basicio.hxx>
      23             : 
      24             : //--------------------------------------------------------------------------
      25           3 : extern "C" void SAL_CALL createRegistryInfo_OSpinButtonModel()
      26             : {
      27           3 :     static ::frm::OMultiInstanceAutoRegistration< ::frm::OSpinButtonModel >   aRegisterModel;
      28           3 : }
      29             : 
      30             : //........................................................................
      31             : namespace frm
      32             : {
      33             : //........................................................................
      34             : 
      35             :     using namespace ::com::sun::star::uno;
      36             :     using namespace ::com::sun::star::beans;
      37             :     using namespace ::com::sun::star::form;
      38             :     using namespace ::com::sun::star::awt;
      39             :     using namespace ::com::sun::star::lang;
      40             :     using namespace ::com::sun::star::util;
      41             :     using namespace ::com::sun::star::io;
      42             :     using namespace ::com::sun::star::form::binding;
      43             : 
      44             :     //====================================================================
      45             :     //= OSpinButtonModel
      46             :     //====================================================================
      47             :     // implemented elsewhere
      48             :     Any translateExternalDoubleToControlIntValue(
      49             :         const Any& _rExternalValue, const Reference< XPropertySet >& _rxProperties,
      50             :         const ::rtl::OUString& _rMinValueName, const ::rtl::OUString& _rMaxValueName );
      51             :     Any translateControlIntToExternalDoubleValue( const Any& _rControlIntValue );
      52             : 
      53             :     //====================================================================
      54             :     //= OSpinButtonModel
      55             :     //====================================================================
      56             :     //--------------------------------------------------------------------
      57             :     DBG_NAME( OSpinButtonModel )
      58             :     //--------------------------------------------------------------------
      59           0 :     OSpinButtonModel::OSpinButtonModel( const Reference<XMultiServiceFactory>& _rxFactory )
      60             :         :OBoundControlModel( _rxFactory, VCL_CONTROLMODEL_SPINBUTTON, VCL_CONTROL_SPINBUTTON, sal_True, sal_True, sal_False )
      61           0 :         ,m_nDefaultSpinValue( 0 )
      62             :     {
      63             :         DBG_CTOR( OSpinButtonModel, NULL );
      64             : 
      65           0 :         m_nClassId = FormComponentType::SPINBUTTON;
      66           0 :         initValueProperty( PROPERTY_SPIN_VALUE, PROPERTY_ID_SPIN_VALUE );
      67           0 :     }
      68             : 
      69             :     //--------------------------------------------------------------------
      70           0 :     OSpinButtonModel::OSpinButtonModel( const OSpinButtonModel* _pOriginal, const Reference< XMultiServiceFactory >& _rxFactory )
      71           0 :         :OBoundControlModel( _pOriginal, _rxFactory )
      72             :     {
      73             :         DBG_CTOR( OSpinButtonModel, NULL );
      74           0 :         m_nDefaultSpinValue = _pOriginal->m_nDefaultSpinValue;
      75           0 :     }
      76             : 
      77             :     //--------------------------------------------------------------------
      78           0 :     OSpinButtonModel::~OSpinButtonModel( )
      79             :     {
      80             :         DBG_DTOR( OSpinButtonModel, NULL );
      81           0 :     }
      82             : 
      83             :     //--------------------------------------------------------------------
      84           9 :     IMPLEMENT_SERVICE_REGISTRATION_2( OSpinButtonModel, OControlModel, FRM_SUN_COMPONENT_SPINBUTTON, BINDABLE_INTEGER_VALUE_RANGE )
      85             :         // note that we're passing OControlModel as "base class". This is because
      86             :         // OBoundControlModel, our real base class, claims to support the DataAwareControlModel
      87             :         // service, which isn't really true for us. We only derive from this class
      88             :         // to benefit from the functionality for binding to spreadsheet cells
      89             : 
      90             :     //------------------------------------------------------------------------------
      91           0 :     IMPLEMENT_DEFAULT_CLONING( OSpinButtonModel )
      92             : 
      93             :     //------------------------------------------------------------------------------
      94           0 :     void SAL_CALL OSpinButtonModel::disposing()
      95             :     {
      96           0 :         OBoundControlModel::disposing();
      97           0 :     }
      98             : 
      99             :     //--------------------------------------------------------------------
     100           0 :     void OSpinButtonModel::describeFixedProperties( Sequence< Property >& _rProps ) const
     101             :     {
     102           0 :         BEGIN_DESCRIBE_PROPERTIES( 3, OControlModel )
     103           0 :             DECL_PROP1( DEFAULT_SPIN_VALUE,   sal_Int32,       BOUND );
     104           0 :             DECL_PROP1( TABINDEX,             sal_Int16,       BOUND );
     105           0 :             DECL_PROP2( CONTROLSOURCEPROPERTY,::rtl::OUString, READONLY, TRANSIENT );
     106             :         END_DESCRIBE_PROPERTIES();
     107           0 :     }
     108             : 
     109             :     //------------------------------------------------------------------------------
     110           0 :     void OSpinButtonModel::getFastPropertyValue( Any& _rValue, sal_Int32 _nHandle ) const
     111             :     {
     112           0 :         switch ( _nHandle )
     113             :         {
     114             :             case PROPERTY_ID_DEFAULT_SPIN_VALUE:
     115           0 :                 _rValue <<= m_nDefaultSpinValue;
     116           0 :                 break;
     117             : 
     118             :             default:
     119           0 :                 OBoundControlModel::getFastPropertyValue( _rValue, _nHandle );
     120             :         }
     121           0 :     }
     122             : 
     123             :     //------------------------------------------------------------------------------
     124           0 :     void OSpinButtonModel::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle, const Any& _rValue ) throw ( Exception )
     125             :     {
     126           0 :         switch ( _nHandle )
     127             :         {
     128             :             case PROPERTY_ID_DEFAULT_SPIN_VALUE:
     129           0 :                 OSL_VERIFY( _rValue >>= m_nDefaultSpinValue );
     130           0 :                 resetNoBroadcast();
     131           0 :                 break;
     132             : 
     133             :             default:
     134           0 :                 OBoundControlModel::setFastPropertyValue_NoBroadcast( _nHandle, _rValue );
     135             :         }
     136           0 :     }
     137             : 
     138             :     //------------------------------------------------------------------------------
     139           0 :     sal_Bool OSpinButtonModel::convertFastPropertyValue(
     140             :                 Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue )
     141             :                 throw ( IllegalArgumentException )
     142             :     {
     143           0 :         sal_Bool bModified( sal_False );
     144           0 :         switch ( _nHandle )
     145             :         {
     146             :             case PROPERTY_ID_DEFAULT_SPIN_VALUE:
     147           0 :                 bModified = tryPropertyValue( _rConvertedValue, _rOldValue, _rValue, m_nDefaultSpinValue );
     148           0 :                 break;
     149             : 
     150             :             default:
     151           0 :                 bModified = OBoundControlModel::convertFastPropertyValue( _rConvertedValue, _rOldValue, _nHandle, _rValue );
     152           0 :                 break;
     153             :         }
     154           0 :         return bModified;
     155             :     }
     156             : 
     157             :     //--------------------------------------------------------------------
     158           0 :     Any OSpinButtonModel::getPropertyDefaultByHandle( sal_Int32 _nHandle ) const
     159             :     {
     160           0 :         Any aReturn;
     161             : 
     162           0 :         switch ( _nHandle )
     163             :         {
     164             :         case PROPERTY_ID_DEFAULT_SPIN_VALUE:
     165           0 :             aReturn <<= (sal_Int32)0;
     166           0 :             break;
     167             : 
     168             :         default:
     169           0 :             aReturn = OBoundControlModel::getPropertyDefaultByHandle( _nHandle );
     170           0 :             break;
     171             :         }
     172             : 
     173           0 :         return aReturn;
     174             :     }
     175             : 
     176             :     //------------------------------------------------------------------------------
     177           0 :     Any OSpinButtonModel::translateDbColumnToControlValue( )
     178             :     {
     179             :         OSL_FAIL( "OSpinButtonModel::commitControlValueToDbColumn: never to be called (we're not bound)!" );
     180           0 :         return Any();
     181             :     }
     182             : 
     183             :     //------------------------------------------------------------------------------
     184           0 :     sal_Bool OSpinButtonModel::commitControlValueToDbColumn( bool /*_bPostReset*/ )
     185             :     {
     186             :         OSL_FAIL( "OSpinButtonModel::commitControlValueToDbColumn: never to be called (we're not bound)!" );
     187           0 :         return sal_True;
     188             :     }
     189             : 
     190             :     //------------------------------------------------------------------------------
     191           0 :     Any OSpinButtonModel::getDefaultForReset() const
     192             :     {
     193           0 :         return makeAny( (sal_Int32)m_nDefaultSpinValue );
     194             :     }
     195             : 
     196             :     //--------------------------------------------------------------------
     197           0 :     ::rtl::OUString SAL_CALL OSpinButtonModel::getServiceName() throw( RuntimeException )
     198             :     {
     199           0 :         return FRM_SUN_COMPONENT_SPINBUTTON;
     200             :     }
     201             : 
     202             :     //--------------------------------------------------------------------
     203           0 :     void SAL_CALL OSpinButtonModel::write( const Reference< XObjectOutputStream >& _rxOutStream )
     204             :         throw( IOException, RuntimeException )
     205             :     {
     206           0 :         OBoundControlModel::write( _rxOutStream );
     207           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     208             : 
     209           0 :         OStreamSection aSection( Reference< XDataOutputStream >( _rxOutStream, UNO_QUERY ) );
     210             : 
     211             :         // version
     212           0 :         _rxOutStream->writeShort( 0x0001 );
     213             : 
     214             :         // properties
     215           0 :         _rxOutStream << m_nDefaultSpinValue;
     216           0 :         writeHelpTextCompatibly( _rxOutStream );
     217           0 :     }
     218             : 
     219             :     //--------------------------------------------------------------------
     220           0 :     void SAL_CALL OSpinButtonModel::read( const Reference< XObjectInputStream>& _rxInStream ) throw( IOException, RuntimeException )
     221             :     {
     222           0 :         OBoundControlModel::read( _rxInStream );
     223           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     224             : 
     225             :         // version
     226             :         {
     227           0 :             OStreamSection aSection( Reference< XDataInputStream >( _rxInStream, UNO_QUERY ) );
     228             : 
     229           0 :             sal_uInt16 nVersion = _rxInStream->readShort();
     230           0 :             if ( nVersion == 0x0001 )
     231             :             {
     232           0 :                 _rxInStream >> m_nDefaultSpinValue;
     233           0 :                 readHelpTextCompatibly( _rxInStream );
     234             :             }
     235             :             else
     236           0 :                 defaultCommonProperties();
     237             : 
     238             :             // here, everything in the stream section which is left will be skipped
     239           0 :         }
     240           0 :     }
     241             : 
     242             :     //--------------------------------------------------------------------
     243           0 :     Any OSpinButtonModel::translateExternalValueToControlValue( const Any& _rExternalValue ) const
     244             :     {
     245             :         return translateExternalDoubleToControlIntValue( _rExternalValue, m_xAggregateSet,
     246             :             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SpinValueMin" ) ),
     247           0 :             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SpinValueMax" ) ) );
     248             :     }
     249             : 
     250             :     //--------------------------------------------------------------------
     251           0 :     Any OSpinButtonModel::translateControlValueToExternalValue( ) const
     252             :     {
     253             :         // by definition, the base class simply obtains the property value
     254           0 :         return translateControlIntToExternalDoubleValue( OBoundControlModel::translateControlValueToExternalValue() );
     255             :     }
     256             : 
     257             :     //--------------------------------------------------------------------
     258           0 :     Sequence< Type > OSpinButtonModel::getSupportedBindingTypes()
     259             :     {
     260           0 :         return Sequence< Type >( &::getCppuType( static_cast< double* >( NULL ) ), 1 );
     261             :     }
     262             : 
     263             : //........................................................................
     264             : }   // namespace frm
     265             : //........................................................................
     266             : 
     267             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10