LCOV - code coverage report
Current view: top level - forms/source/component - FormattedField.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 2 4 50.0 %
Date: 2014-04-11 Functions: 6 8 75.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             : #ifndef INCLUDED_FORMS_SOURCE_COMPONENT_FORMATTEDFIELD_HXX
      21             : #define INCLUDED_FORMS_SOURCE_COMPONENT_FORMATTEDFIELD_HXX
      22             : 
      23             : #include "EditBase.hxx"
      24             : #include <tools/link.hxx>
      25             : #include <comphelper/propmultiplex.hxx>
      26             : #include <cppuhelper/implbase1.hxx>
      27             : #include "errorbroadcaster.hxx"
      28             : 
      29             : namespace frm
      30             : {
      31             : class OFormattedModel
      32             :                     :public OEditBaseModel
      33             :                     ,public OErrorBroadcaster
      34             :     {
      35             :         // the original, in case I faked the format properties of my aggregated model,
      36             :         // i.e. I just passed on the attributes of the field to which I am bound
      37             :         // (only valid if loaded)
      38             : 
      39             :         ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier>   m_xOriginalFormatter;
      40             :         ::com::sun::star::util::Date        m_aNullDate;
      41             :         ::com::sun::star::uno::Any          m_aSaveValue;
      42             : 
      43             :         sal_Int32                           m_nFieldType;
      44             :         sal_Int16                           m_nKeyType;
      45             :         sal_Bool                            m_bOriginalNumeric      : 1,
      46             :                                             m_bNumeric              : 1;    // analogous for the TreatAsNumeric-property
      47             : 
      48             :     protected:
      49             :         ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier>  calcDefaultFormatsSupplier() const;
      50             :         ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier>  calcFormFormatsSupplier() const;
      51             :         ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier>  calcFormatsSupplier() const;
      52             : 
      53             :         DECLARE_DEFAULT_LEAF_XTOR( OFormattedModel );
      54             : 
      55             :         friend class OFormattedFieldWrapper;
      56             : 
      57             :     protected:
      58             :         // XInterface
      59       13034 :         DECLARE_UNO3_AGG_DEFAULTS( OFormattedModel, OEditBaseModel )
      60             : 
      61             :         // XTypeProvider
      62             :         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes() SAL_OVERRIDE;
      63             : 
      64             :         // XAggregation
      65             :         virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation(const ::com::sun::star::uno::Type& _rType) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      66             : 
      67             :         // OComponentHelper
      68             :         virtual void SAL_CALL disposing() SAL_OVERRIDE;
      69             : 
      70             :         // XServiceInfo
      71           0 :         IMPLEMENTATION_NAME(OFormattedModel);
      72             :         virtual StringSequence SAL_CALL getSupportedServiceNames() throw(std::exception) SAL_OVERRIDE;
      73             : 
      74             :         // XPersistObject
      75             :         virtual void SAL_CALL write(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOutStream) throw ( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      76             :         virtual void SAL_CALL read(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxInStream) throw ( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      77             :         virtual OUString SAL_CALL getServiceName() throw ( ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      78             : 
      79             :         // XPropertySet
      80             :         virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const SAL_OVERRIDE;
      81             :         virtual sal_Bool SAL_CALL convertFastPropertyValue(::com::sun::star::uno::Any& rConvertedValue, ::com::sun::star::uno::Any& rOldValue,
      82             :                                               sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue )
      83             :                                             throw(::com::sun::star::lang::IllegalArgumentException) SAL_OVERRIDE;
      84             :         virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue) throw ( ::com::sun::star::uno::Exception, std::exception) SAL_OVERRIDE;
      85             : 
      86             :         // XLoadListener
      87             :         virtual void SAL_CALL loaded(const ::com::sun::star::lang::EventObject& rEvent) throw ( ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      88             : 
      89             :         // XPropertyState
      90             :         void setPropertyToDefaultByHandle(sal_Int32 nHandle) SAL_OVERRIDE;
      91             :         ::com::sun::star::uno::Any getPropertyDefaultByHandle(sal_Int32 nHandle) const SAL_OVERRIDE;
      92             : 
      93             :         void SAL_CALL setPropertyToDefault(const OUString& aPropertyName) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      94             :         ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      95             : 
      96             :         // OControlModel's property handling
      97             :         virtual void describeFixedProperties(
      98             :             ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps
      99             :         ) const SAL_OVERRIDE;
     100             :         virtual void describeAggregateProperties(
     101             :             ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps
     102             :         ) const SAL_OVERRIDE;
     103             : 
     104             :         // XPropertyChangeListener
     105             :         virtual void _propertyChanged(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException) SAL_OVERRIDE;
     106             : 
     107             :         // prevent method hiding
     108             :         using OEditBaseModel::disposing;
     109             :         using OEditBaseModel::getFastPropertyValue;
     110             : 
     111             :     protected:
     112             :         virtual sal_uInt16 getPersistenceFlags() const SAL_OVERRIDE;
     113             :         // as we have an own version handling for persistence
     114             : 
     115             :         // OBoundControlModel overridables
     116             :         virtual ::com::sun::star::uno::Any
     117             :                             translateDbColumnToControlValue( ) SAL_OVERRIDE;
     118             :         virtual sal_Bool    commitControlValueToDbColumn( bool _bPostReset ) SAL_OVERRIDE;
     119             : 
     120             :         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >
     121             :                             getSupportedBindingTypes() SAL_OVERRIDE;
     122             :         virtual ::com::sun::star::uno::Any
     123             :                             translateExternalValueToControlValue( const ::com::sun::star::uno::Any& _rExternalValue ) const SAL_OVERRIDE;
     124             :         virtual ::com::sun::star::uno::Any
     125             :                             translateControlValueToExternalValue( ) const SAL_OVERRIDE;
     126             :         virtual void onConnectedExternalValue( ) SAL_OVERRIDE;
     127             : 
     128             :         virtual ::com::sun::star::uno::Any
     129             :                             getDefaultForReset() const SAL_OVERRIDE;
     130             :         virtual void        resetNoBroadcast() SAL_OVERRIDE;
     131             : 
     132             :         virtual void        onConnectedDbColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxForm ) SAL_OVERRIDE;
     133             :         virtual void        onDisconnectedDbColumn() SAL_OVERRIDE;
     134             : 
     135             :     private:
     136             :         DECLARE_XCLONEABLE();
     137             : 
     138             :         void implConstruct();
     139             : 
     140             :         void    updateFormatterNullDate();
     141             :     };
     142             : 
     143             :     // OFormattedControl
     144             :     typedef ::cppu::ImplHelper1< ::com::sun::star::awt::XKeyListener> OFormattedControl_BASE;
     145             :     class OFormattedControl :    public OBoundControl
     146             :                                 ,public OFormattedControl_BASE
     147             :     {
     148             :         sal_uInt32              m_nKeyEvent;
     149             : 
     150             :     public:
     151             :         OFormattedControl(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext);
     152             :         virtual ~OFormattedControl();
     153             : 
     154        3758 :         DECLARE_UNO3_AGG_DEFAULTS(OFormattedControl, OBoundControl)
     155             :         virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation(const ::com::sun::star::uno::Type& _rType) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     156             : 
     157             :         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes() SAL_OVERRIDE;
     158             : 
     159             :         // ::com::sun::star::lang::XServiceInfo
     160           0 :         IMPLEMENTATION_NAME(OFormattedControl);
     161             :         virtual StringSequence SAL_CALL getSupportedServiceNames() throw(std::exception) SAL_OVERRIDE;
     162             : 
     163             :         // ::com::sun::star::lang::XEventListener
     164             :         virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& _rSource) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     165             : 
     166             :         // ::com::sun::star::awt::XKeyListener
     167             :         virtual void SAL_CALL keyPressed(const ::com::sun::star::awt::KeyEvent& e) throw ( ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     168             :         virtual void SAL_CALL keyReleased(const ::com::sun::star::awt::KeyEvent& e) throw ( ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     169             : 
     170             :         // ::com::sun::star::awt::XControl
     171             :         virtual void SAL_CALL setDesignMode(sal_Bool bOn) throw ( ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     172             : 
     173             :         // disambiguation
     174             :         using OBoundControl::disposing;
     175             : 
     176             :     private:
     177             :         DECL_LINK( OnKeyPressed, void* );
     178             :     };
     179             : }
     180             : #endif // INCLUDED_FORMS_SOURCE_COMPONENT_FORMATTEDFIELD_HXX
     181             : 
     182             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10