LCOV - code coverage report
Current view: top level - libreoffice/forms/source/component - Pattern.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 85 0.0 %
Date: 2012-12-27 Functions: 0 20 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 "Pattern.hxx"
      21             : 
      22             : //.........................................................................
      23             : namespace frm
      24             : {
      25             : //.........................................................................
      26             : 
      27             :     /** === begin UNO using === **/
      28             :     using ::com::sun::star::uno::Reference;
      29             :     using ::com::sun::star::lang::XMultiServiceFactory;
      30             :     using ::com::sun::star::uno::Sequence;
      31             :     using ::com::sun::star::uno::Type;
      32             :     using ::com::sun::star::beans::Property;
      33             :     using ::com::sun::star::uno::Exception;
      34             :     using ::com::sun::star::uno::XInterface;
      35             :     using ::com::sun::star::uno::Any;
      36             :     using ::com::sun::star::uno::makeAny;
      37             :     using ::com::sun::star::sdbc::XRowSet;
      38             :     using ::com::sun::star::uno::UNO_QUERY;
      39             :     /** === end UNO using === **/
      40             :     namespace FormComponentType = ::com::sun::star::form::FormComponentType;
      41             : 
      42             : //==================================================================
      43             : // OPatternControl
      44             : //==================================================================
      45             : //------------------------------------------------------------------
      46           0 : OPatternControl::OPatternControl(const Reference<XMultiServiceFactory>& _rxFactory)
      47           0 :     :OBoundControl(_rxFactory, VCL_CONTROL_PATTERNFIELD)
      48             : {
      49           0 : }
      50             : 
      51             : //------------------------------------------------------------------
      52           0 : InterfaceRef SAL_CALL OPatternControl_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory)
      53             : {
      54           0 :     return *(new OPatternControl(_rxFactory));
      55             : }
      56             : 
      57             : //------------------------------------------------------------------------------
      58           0 : Sequence<Type> OPatternControl::_getTypes()
      59             : {
      60           0 :     return OBoundControl::_getTypes();
      61             : }
      62             : 
      63             : //------------------------------------------------------------------------------
      64           0 : StringSequence OPatternControl::getSupportedServiceNames() throw()
      65             : {
      66           0 :     StringSequence aSupported = OBoundControl::getSupportedServiceNames();
      67           0 :     aSupported.realloc(aSupported.getLength() + 1);
      68             : 
      69           0 :     ::rtl::OUString*pArray = aSupported.getArray();
      70           0 :     pArray[aSupported.getLength()-1] = FRM_SUN_CONTROL_PATTERNFIELD;
      71           0 :     return aSupported;
      72             : }
      73             : 
      74             : //==================================================================
      75             : // OPatternModel
      76             : //==================================================================
      77             : //------------------------------------------------------------------
      78           0 : InterfaceRef SAL_CALL OPatternModel_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory)
      79             : {
      80           0 :     return *(new OPatternModel(_rxFactory));
      81             : }
      82             : 
      83             : //------------------------------------------------------------------------------
      84           0 : Sequence<Type> OPatternModel::_getTypes()
      85             : {
      86           0 :     return OEditBaseModel::_getTypes();
      87             : }
      88             : 
      89             : //------------------------------------------------------------------
      90             : DBG_NAME( OPatternModel )
      91             : //------------------------------------------------------------------
      92           0 : OPatternModel::OPatternModel(const Reference<XMultiServiceFactory>& _rxFactory)
      93           0 :     :OEditBaseModel( _rxFactory, VCL_CONTROLMODEL_PATTERNFIELD, FRM_SUN_CONTROL_PATTERNFIELD, sal_False, sal_False )
      94             :                                     // use the old control name for compytibility reasons
      95             : {
      96             :     DBG_CTOR( OPatternModel, NULL );
      97             : 
      98           0 :     m_nClassId = FormComponentType::PATTERNFIELD;
      99           0 :     initValueProperty( PROPERTY_TEXT, PROPERTY_ID_TEXT );
     100           0 : }
     101             : 
     102             : //------------------------------------------------------------------
     103           0 : OPatternModel::OPatternModel( const OPatternModel* _pOriginal, const Reference<XMultiServiceFactory>& _rxFactory )
     104           0 :     :OEditBaseModel( _pOriginal, _rxFactory )
     105             : {
     106             :     DBG_CTOR( OPatternModel, NULL );
     107           0 : }
     108             : 
     109             : //------------------------------------------------------------------
     110           0 : OPatternModel::~OPatternModel()
     111             : {
     112             :     DBG_DTOR( OPatternModel, NULL );
     113           0 : }
     114             : 
     115             : // XCloneable
     116             : //------------------------------------------------------------------------------
     117           0 : IMPLEMENT_DEFAULT_CLONING( OPatternModel )
     118             : 
     119             : // XServiceInfo
     120             : //------------------------------------------------------------------------------
     121           0 : StringSequence SAL_CALL OPatternModel::getSupportedServiceNames() throw()
     122             : {
     123           0 :     StringSequence aSupported = OBoundControlModel::getSupportedServiceNames();
     124           0 :     aSupported.realloc(aSupported.getLength() + 2);
     125             : 
     126           0 :     ::rtl::OUString*pArray = aSupported.getArray();
     127           0 :     pArray[aSupported.getLength()-2] = FRM_SUN_COMPONENT_DATABASE_PATTERNFIELD;
     128           0 :     pArray[aSupported.getLength()-1] = FRM_SUN_COMPONENT_PATTERNFIELD;
     129           0 :     return aSupported;
     130             : }
     131             : 
     132             : 
     133             : //------------------------------------------------------------------------------
     134           0 : void OPatternModel::describeFixedProperties( Sequence< Property >& _rProps ) const
     135             : {
     136           0 :     BEGIN_DESCRIBE_PROPERTIES( 4, OEditBaseModel )
     137           0 :         DECL_PROP2(DEFAULT_TEXT,    ::rtl::OUString,    BOUND, MAYBEDEFAULT);
     138           0 :         DECL_BOOL_PROP1(EMPTY_IS_NULL,                  BOUND);
     139           0 :         DECL_PROP1(TABINDEX,        sal_Int16,          BOUND);
     140           0 :         DECL_PROP2(FILTERPROPOSAL,  sal_Bool,           BOUND, MAYBEDEFAULT);
     141             :     END_DESCRIBE_PROPERTIES();
     142           0 : }
     143             : 
     144             : //------------------------------------------------------------------------------
     145           0 : ::rtl::OUString SAL_CALL OPatternModel::getServiceName() throw ( ::com::sun::star::uno::RuntimeException)
     146             : {
     147           0 :     return FRM_COMPONENT_PATTERNFIELD;  // old (non-sun) name for compatibility !
     148             : }
     149             : 
     150             : //------------------------------------------------------------------------------
     151           0 : sal_Bool OPatternModel::commitControlValueToDbColumn( bool /*_bPostReset*/ )
     152             : {
     153           0 :     Any aNewValue( m_xAggregateFastSet->getFastPropertyValue( getValuePropertyAggHandle() ) );
     154             : 
     155           0 :     if ( aNewValue != m_aLastKnownValue )
     156             :     {
     157           0 :         ::rtl::OUString sNewValue;
     158           0 :         aNewValue >>= sNewValue;
     159             : 
     160           0 :         if  (   !aNewValue.hasValue()
     161           0 :             ||  (   sNewValue.isEmpty()         // an empty string
     162             :                 &&  m_bEmptyIsNull              // which should be interpreted as NULL
     163             :                 )
     164             :             )
     165             :         {
     166           0 :             m_xColumnUpdate->updateNull();
     167             :         }
     168             :         else
     169             :         {
     170             :             OSL_ENSURE( m_pFormattedValue.get(), "OPatternModel::commitControlValueToDbColumn: no value helper!" );
     171           0 :             if ( !m_pFormattedValue.get() )
     172           0 :                 return sal_False;
     173             : 
     174           0 :             if ( !m_pFormattedValue->setFormattedValue( sNewValue ) )
     175           0 :                 return sal_False;
     176             :         }
     177             : 
     178           0 :         m_aLastKnownValue = aNewValue;
     179             :     }
     180             : 
     181           0 :     return sal_True;
     182             : }
     183             : 
     184             : //------------------------------------------------------------------------------
     185           0 : void OPatternModel::onConnectedDbColumn( const Reference< XInterface >& _rxForm )
     186             : {
     187           0 :     OEditBaseModel::onConnectedDbColumn( _rxForm );
     188             : 
     189           0 :     Reference< XPropertySet > xField( getField() );
     190           0 :     if ( !xField.is() )
     191           0 :         return;
     192             : 
     193           0 :     m_pFormattedValue.reset( new ::dbtools::FormattedColumnValue( getContext(), Reference< XRowSet >( _rxForm, UNO_QUERY ), xField ) );
     194             : }
     195             : 
     196             : //------------------------------------------------------------------------------
     197           0 : void OPatternModel::onDisconnectedDbColumn()
     198             : {
     199           0 :     OEditBaseModel::onDisconnectedDbColumn();
     200           0 :     m_pFormattedValue.reset();
     201           0 : }
     202             : 
     203             : // XPropertyChangeListener
     204             : //------------------------------------------------------------------------------
     205           0 : Any OPatternModel::translateDbColumnToControlValue()
     206             : {
     207             :     OSL_PRECOND( m_pFormattedValue.get(), "OPatternModel::translateDbColumnToControlValue: no value helper!" );
     208             : 
     209           0 :     if ( m_pFormattedValue.get() )
     210             :     {
     211           0 :         ::rtl::OUString sValue( m_pFormattedValue->getFormattedValue() );
     212           0 :         if  (   sValue.isEmpty()
     213           0 :             &&  m_pFormattedValue->getColumn().is()
     214           0 :             &&  m_pFormattedValue->getColumn()->wasNull()
     215             :             )
     216             :         {
     217           0 :             m_aLastKnownValue.clear();
     218             :         }
     219             :         else
     220             :         {
     221           0 :             m_aLastKnownValue <<= sValue;
     222           0 :         }
     223             :     }
     224             :     else
     225           0 :         m_aLastKnownValue.clear();
     226             : 
     227           0 :     return m_aLastKnownValue.hasValue() ? m_aLastKnownValue : makeAny( ::rtl::OUString() );
     228             :         // (m_aLastKnownValue is alllowed to be VOID, the control value isn't)
     229             : }
     230             : 
     231             : // XReset
     232             : //------------------------------------------------------------------------------
     233           0 : Any OPatternModel::getDefaultForReset() const
     234             : {
     235           0 :     return makeAny( m_aDefaultText );
     236             : }
     237             : 
     238             : //------------------------------------------------------------------------------
     239           0 : void OPatternModel::resetNoBroadcast()
     240             : {
     241           0 :     OEditBaseModel::resetNoBroadcast();
     242           0 :     m_aLastKnownValue.clear();
     243           0 : }
     244             : 
     245             : //.........................................................................
     246             : }   // namespace frm
     247             : //.........................................................................
     248             : 
     249             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10