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

Generated by: LCOV version 1.11