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

Generated by: LCOV version 1.10