LCOV - code coverage report
Current view: top level - forms/source/component - Numeric.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 73 0.0 %
Date: 2014-04-14 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             : #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           0 : ONumericControl::ONumericControl(const Reference<XComponentContext>& _rxFactory)
      47           0 :     :OBoundControl(_rxFactory, VCL_CONTROL_NUMERICFIELD)
      48             : {
      49           0 : }
      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           0 : InterfaceRef SAL_CALL ONumericControl_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory)
      65             : {
      66           0 :     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           0 : InterfaceRef SAL_CALL ONumericModel_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory)
      80             : {
      81           0 :     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           0 : ONumericModel::ONumericModel(const Reference<XComponentContext>& _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             : 
      97           0 :     m_nClassId = FormComponentType::NUMERICFIELD;
      98           0 :     initValueProperty( PROPERTY_VALUE, PROPERTY_ID_VALUE );
      99           0 : }
     100             : 
     101             : 
     102           0 : ONumericModel::ONumericModel( const ONumericModel* _pOriginal, const Reference<XComponentContext>& _rxFactory )
     103           0 :     :OEditBaseModel( _pOriginal, _rxFactory )
     104             : {
     105           0 : }
     106             : 
     107             : 
     108           0 : ONumericModel::~ONumericModel()
     109             : {
     110           0 : }
     111             : 
     112             : // XCloneable
     113             : 
     114           0 : IMPLEMENT_DEFAULT_CLONING( ONumericModel )
     115             : 
     116             : // XServiceInfo
     117             : 
     118           0 : StringSequence ONumericModel::getSupportedServiceNames() throw(std::exception)
     119             : {
     120           0 :     StringSequence aSupported = OBoundControlModel::getSupportedServiceNames();
     121             : 
     122           0 :     sal_Int32 nOldLen = aSupported.getLength();
     123           0 :     aSupported.realloc( nOldLen + 8 );
     124           0 :     OUString* pStoreTo = aSupported.getArray() + nOldLen;
     125             : 
     126           0 :     *pStoreTo++ = BINDABLE_CONTROL_MODEL;
     127           0 :     *pStoreTo++ = DATA_AWARE_CONTROL_MODEL;
     128           0 :     *pStoreTo++ = VALIDATABLE_CONTROL_MODEL;
     129             : 
     130           0 :     *pStoreTo++ = BINDABLE_DATA_AWARE_CONTROL_MODEL;
     131           0 :     *pStoreTo++ = VALIDATABLE_BINDABLE_CONTROL_MODEL;
     132             : 
     133           0 :     *pStoreTo++ = FRM_SUN_COMPONENT_NUMERICFIELD;
     134           0 :     *pStoreTo++ = FRM_SUN_COMPONENT_DATABASE_NUMERICFIELD;
     135           0 :     *pStoreTo++ = BINDABLE_DATABASE_NUMERIC_FIELD;
     136             : 
     137           0 :     return aSupported;
     138             : }
     139             : 
     140             : 
     141           0 : void ONumericModel::describeFixedProperties( Sequence< Property >& _rProps ) const
     142             : {
     143           0 :     BEGIN_DESCRIBE_PROPERTIES( 2, OEditBaseModel )
     144           0 :         DECL_PROP3(DEFAULT_VALUE,   double,             BOUND, MAYBEDEFAULT, MAYBEVOID);
     145           0 :         DECL_PROP1(TABINDEX,        sal_Int16,          BOUND);
     146             :     END_DESCRIBE_PROPERTIES();
     147           0 : }
     148             : 
     149             : 
     150           0 : OUString SAL_CALL ONumericModel::getServiceName() throw ( ::com::sun::star::uno::RuntimeException, std::exception)
     151             : {
     152           0 :     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           0 : Any ONumericModel::getDefaultForReset() const
     191             : {
     192           0 :     Any aValue;
     193           0 :     if (m_aDefault.getValueType().getTypeClass() == TypeClass_DOUBLE)
     194           0 :         aValue = m_aDefault;
     195             : 
     196           0 :     return aValue;
     197             : }
     198             : 
     199             : 
     200           0 : void ONumericModel::resetNoBroadcast()
     201             : {
     202           0 :     OEditBaseModel::resetNoBroadcast();
     203           0 :     m_aSaveValue.clear();
     204           0 : }
     205             : 
     206             : 
     207             : }   // namespace frm
     208             : 
     209             : 
     210             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10