LCOV - code coverage report
Current view: top level - forms/source/component - Numeric.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 49 73 67.1 %
Date: 2012-08-25 Functions: 14 18 77.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 24 82 29.3 %

           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 "Numeric.hxx"
      30                 :            : #include <tools/debug.hxx>
      31                 :            : 
      32                 :            : //.........................................................................
      33                 :            : namespace frm
      34                 :            : {
      35                 :            : //.........................................................................
      36                 :            : using namespace ::com::sun::star::uno;
      37                 :            : using namespace ::com::sun::star::sdb;
      38                 :            : using namespace ::com::sun::star::sdbc;
      39                 :            : using namespace ::com::sun::star::sdbcx;
      40                 :            : using namespace ::com::sun::star::beans;
      41                 :            : using namespace ::com::sun::star::container;
      42                 :            : using namespace ::com::sun::star::form;
      43                 :            : using namespace ::com::sun::star::awt;
      44                 :            : using namespace ::com::sun::star::io;
      45                 :            : using namespace ::com::sun::star::lang;
      46                 :            : using namespace ::com::sun::star::util;
      47                 :            : using namespace ::com::sun::star::form::binding;
      48                 :            : 
      49                 :            : //==================================================================
      50                 :            : // ONumericControl
      51                 :            : //==================================================================
      52                 :            : 
      53                 :            : //------------------------------------------------------------------
      54                 :         12 : ONumericControl::ONumericControl(const Reference<XMultiServiceFactory>& _rxFactory)
      55         [ +  - ]:         12 :     :OBoundControl(_rxFactory, VCL_CONTROL_NUMERICFIELD)
      56                 :            : {
      57                 :         12 : }
      58                 :            : 
      59                 :            : //------------------------------------------------------------------------------
      60                 :          0 : StringSequence ONumericControl::getSupportedServiceNames() throw()
      61                 :            : {
      62                 :          0 :     StringSequence aSupported = OBoundControl::getSupportedServiceNames();
      63         [ #  # ]:          0 :     aSupported.realloc(aSupported.getLength() + 1);
      64                 :            : 
      65         [ #  # ]:          0 :     ::rtl::OUString*pArray = aSupported.getArray();
      66         [ #  # ]:          0 :     pArray[aSupported.getLength()-1] = FRM_SUN_CONTROL_NUMERICFIELD;
      67                 :          0 :     return aSupported;
      68                 :            : }
      69                 :            : 
      70                 :            : 
      71                 :            : //------------------------------------------------------------------
      72                 :         12 : InterfaceRef SAL_CALL ONumericControl_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory)
      73                 :            : {
      74         [ +  - ]:         12 :     return *(new ONumericControl(_rxFactory));
      75                 :            : }
      76                 :            : 
      77                 :            : //------------------------------------------------------------------------------
      78                 :          0 : Sequence<Type> ONumericControl::_getTypes()
      79                 :            : {
      80                 :          0 :     return OBoundControl::_getTypes();
      81                 :            : }
      82                 :            : 
      83                 :            : //==================================================================
      84                 :            : // ONumericModel
      85                 :            : //==================================================================
      86                 :            : //------------------------------------------------------------------
      87                 :         17 : InterfaceRef SAL_CALL ONumericModel_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory)
      88                 :            : {
      89         [ +  - ]:         17 :     return *(new ONumericModel(_rxFactory));
      90                 :            : }
      91                 :            : 
      92                 :            : //------------------------------------------------------------------------------
      93                 :          4 : Sequence<Type> ONumericModel::_getTypes()
      94                 :            : {
      95                 :          4 :     return OEditBaseModel::_getTypes();
      96                 :            : }
      97                 :            : 
      98                 :            : //------------------------------------------------------------------
      99                 :            : DBG_NAME( ONumericModel )
     100                 :            : //------------------------------------------------------------------
     101                 :         17 : ONumericModel::ONumericModel(const Reference<XMultiServiceFactory>& _rxFactory)
     102 [ +  - ][ +  - ]:         17 :                 :OEditBaseModel( _rxFactory, VCL_CONTROLMODEL_NUMERICFIELD, FRM_SUN_CONTROL_NUMERICFIELD, sal_True, sal_True )
     103                 :            :                                     // use the old control name for compytibility reasons
     104                 :            : {
     105                 :            :     DBG_CTOR( ONumericModel, NULL );
     106                 :            : 
     107                 :         17 :     m_nClassId = FormComponentType::NUMERICFIELD;
     108 [ +  - ][ +  - ]:         17 :     initValueProperty( PROPERTY_VALUE, PROPERTY_ID_VALUE );
     109                 :         17 : }
     110                 :            : 
     111                 :            : //------------------------------------------------------------------
     112                 :          2 : ONumericModel::ONumericModel( const ONumericModel* _pOriginal, const Reference<XMultiServiceFactory>& _rxFactory )
     113                 :          2 :     :OEditBaseModel( _pOriginal, _rxFactory )
     114                 :            : {
     115                 :            :     DBG_CTOR( ONumericModel, NULL );
     116                 :          2 : }
     117                 :            : 
     118                 :            : //------------------------------------------------------------------
     119                 :         19 : ONumericModel::~ONumericModel()
     120                 :            : {
     121                 :            :     DBG_DTOR( ONumericModel, NULL );
     122         [ -  + ]:         38 : }
     123                 :            : 
     124                 :            : // XCloneable
     125                 :            : //------------------------------------------------------------------------------
     126 [ +  - ][ +  - ]:          2 : IMPLEMENT_DEFAULT_CLONING( ONumericModel )
     127                 :            : 
     128                 :            : // XServiceInfo
     129                 :            : //------------------------------------------------------------------------------
     130                 :         14 : StringSequence ONumericModel::getSupportedServiceNames() throw()
     131                 :            : {
     132                 :         14 :     StringSequence aSupported = OBoundControlModel::getSupportedServiceNames();
     133                 :            : 
     134                 :         14 :     sal_Int32 nOldLen = aSupported.getLength();
     135         [ +  - ]:         14 :     aSupported.realloc( nOldLen + 8 );
     136         [ +  - ]:         14 :     ::rtl::OUString* pStoreTo = aSupported.getArray() + nOldLen;
     137                 :            : 
     138         [ +  - ]:         14 :     *pStoreTo++ = BINDABLE_CONTROL_MODEL;
     139         [ +  - ]:         14 :     *pStoreTo++ = DATA_AWARE_CONTROL_MODEL;
     140         [ +  - ]:         14 :     *pStoreTo++ = VALIDATABLE_CONTROL_MODEL;
     141                 :            : 
     142         [ +  - ]:         14 :     *pStoreTo++ = BINDABLE_DATA_AWARE_CONTROL_MODEL;
     143         [ +  - ]:         14 :     *pStoreTo++ = VALIDATABLE_BINDABLE_CONTROL_MODEL;
     144                 :            : 
     145         [ +  - ]:         14 :     *pStoreTo++ = FRM_SUN_COMPONENT_NUMERICFIELD;
     146         [ +  - ]:         14 :     *pStoreTo++ = FRM_SUN_COMPONENT_DATABASE_NUMERICFIELD;
     147         [ +  - ]:         14 :     *pStoreTo++ = BINDABLE_DATABASE_NUMERIC_FIELD;
     148                 :            : 
     149                 :         14 :     return aSupported;
     150                 :            : }
     151                 :            : 
     152                 :            : //------------------------------------------------------------------------------
     153                 :         21 : void ONumericModel::describeFixedProperties( Sequence< Property >& _rProps ) const
     154                 :            : {
     155                 :         21 :     BEGIN_DESCRIBE_PROPERTIES( 2, OEditBaseModel )
     156 [ +  - ][ +  - ]:         21 :         DECL_PROP3(DEFAULT_VALUE,   double,             BOUND, MAYBEDEFAULT, MAYBEVOID);
     157         [ +  - ]:         21 :         DECL_PROP1(TABINDEX,        sal_Int16,          BOUND);
     158                 :            :     END_DESCRIBE_PROPERTIES();
     159                 :         21 : }
     160                 :            : 
     161                 :            : //------------------------------------------------------------------------------
     162                 :          2 : ::rtl::OUString SAL_CALL ONumericModel::getServiceName() throw ( ::com::sun::star::uno::RuntimeException)
     163                 :            : {
     164                 :          2 :     return FRM_COMPONENT_NUMERICFIELD;  // old (non-sun) name for compatibility !
     165                 :            : }
     166                 :            : 
     167                 :            : //------------------------------------------------------------------------------
     168                 :          0 : sal_Bool ONumericModel::commitControlValueToDbColumn( bool /*_bPostReset*/ )
     169                 :            : {
     170 [ #  # ][ #  # ]:          0 :     Any aControlValue( m_xAggregateFastSet->getFastPropertyValue( getValuePropertyAggHandle() ) );
     171 [ #  # ][ #  # ]:          0 :     if ( !compare( aControlValue, m_aSaveValue ) )
     172                 :            :     {
     173         [ #  # ]:          0 :         if ( !aControlValue.hasValue() )
     174 [ #  # ][ #  # ]:          0 :             m_xColumnUpdate->updateNull();
     175                 :            :         else
     176                 :            :         {
     177                 :            :             try
     178                 :            :             {
     179 [ #  # ][ #  # ]:          0 :                 m_xColumnUpdate->updateDouble( getDouble( aControlValue ) );
                 [ #  # ]
     180                 :            :             }
     181         [ #  # ]:          0 :             catch(const Exception&)
     182                 :            :             {
     183                 :          0 :                 return sal_False;
     184                 :            :             }
     185                 :            :         }
     186                 :          0 :         m_aSaveValue = aControlValue;
     187                 :            :     }
     188         [ #  # ]:          0 :     return sal_True;
     189                 :            : }
     190                 :            : 
     191                 :            : //------------------------------------------------------------------------------
     192                 :          0 : Any ONumericModel::translateDbColumnToControlValue()
     193                 :            : {
     194         [ #  # ]:          0 :     m_aSaveValue <<= (double)m_xColumn->getDouble();
     195         [ #  # ]:          0 :     if ( m_xColumn->wasNull() )
     196                 :          0 :         m_aSaveValue.clear();
     197                 :            : 
     198                 :          0 :     return m_aSaveValue;
     199                 :            : }
     200                 :            : 
     201                 :            : //------------------------------------------------------------------------------
     202                 :          6 : Any ONumericModel::getDefaultForReset() const
     203                 :            : {
     204                 :          6 :     Any aValue;
     205         [ -  + ]:          6 :     if (m_aDefault.getValueType().getTypeClass() == TypeClass_DOUBLE)
     206                 :          0 :         aValue = m_aDefault;
     207                 :            : 
     208                 :          6 :     return aValue;
     209                 :            : }
     210                 :            : 
     211                 :            : //------------------------------------------------------------------------------
     212                 :          6 : void ONumericModel::resetNoBroadcast()
     213                 :            : {
     214                 :          6 :     OEditBaseModel::resetNoBroadcast();
     215                 :          6 :     m_aSaveValue.clear();
     216                 :          6 : }
     217                 :            : 
     218                 :            : //.........................................................................
     219                 :            : }   // namespace frm
     220                 :            : //.........................................................................
     221                 :            : 
     222                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10