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

Generated by: LCOV version 1.10