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

Generated by: LCOV version 1.11