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

Generated by: LCOV version 1.10