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

Generated by: LCOV version 1.10