LCOV - code coverage report
Current view: top level - libreoffice/forms/source/inc - propertybaghelper.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 6 17 35.3 %
Date: 2012-12-27 Functions: 4 8 50.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 FORMS_PROPERTYBAGHELPER_HXX
      21             : #define FORMS_PROPERTYBAGHELPER_HXX
      22             : 
      23             : #include <com/sun/star/beans/PropertyValue.hpp>
      24             : 
      25             : #include <comphelper/propertybag.hxx>
      26             : #include <comphelper/propagg.hxx>
      27             : 
      28             : #include <boost/noncopyable.hpp>
      29             : 
      30             : //........................................................................
      31             : namespace frm
      32             : {
      33             : //........................................................................
      34             : 
      35             :     //====================================================================
      36             :     //= class IPropertyBagHelperContext
      37             :     //====================================================================
      38          17 :     class SAL_NO_VTABLE IPropertyBagHelperContext
      39             :     {
      40             :     public:
      41             :         virtual ::osl::Mutex&   getMutex() = 0;
      42             : 
      43             :         virtual void            describeFixedAndAggregateProperties(
      44             :             ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& _out_rFixedProperties,
      45             :             ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& _out_rAggregateProperties
      46             :         ) const = 0;
      47             : 
      48             :         virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XMultiPropertySet >
      49             :                                 getPropertiesInterface() = 0;
      50             : 
      51             :     protected:
      52           9 :         ~IPropertyBagHelperContext() {}
      53             :     };
      54             : 
      55             :     //====================================================================
      56             :     //= class PropertyBagHelper
      57             :     //====================================================================
      58             :     class PropertyBagHelper : public ::boost::noncopyable
      59             :     {
      60             :     private:
      61             :         IPropertyBagHelperContext&                      m_rContext;
      62             :         ::comphelper::OPropertyArrayAggregationHelper*  m_pPropertyArrayHelper;
      63             :         ::comphelper::PropertyBag                       m_aDynamicProperties;
      64             :         bool                                            m_bDisposed;
      65             : 
      66             :     public:
      67             :         PropertyBagHelper( IPropertyBagHelperContext& _rContext );
      68             :         ~PropertyBagHelper();
      69             : 
      70             :         // XComponent equivalent
      71             :         void    dispose();
      72             : 
      73             :         // OPropertySetHelper equivalent
      74             :         inline ::comphelper::OPropertyArrayAggregationHelper& getInfoHelper() const;
      75             : 
      76             :         // XPropertyContainer equivalent
      77             :         void addProperty( const ::rtl::OUString& _rName, ::sal_Int16 _nAttributes, const ::com::sun::star::uno::Any& _rInitialValue );
      78             :         void removeProperty( const ::rtl::OUString& _rName );
      79             : 
      80             :         // XPropertyAccess equivalent
      81             :         ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getPropertyValues();
      82             :         void setPropertyValues( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rProps );
      83             : 
      84             :         // forwards to m_aDynamicProperties
      85             :         inline void getDynamicFastPropertyValue( sal_Int32 _nHandle, ::com::sun::star::uno::Any& _out_rValue ) const;
      86             :         inline bool convertDynamicFastPropertyValue( sal_Int32 _nHandle, const ::com::sun::star::uno::Any& _rNewValue, ::com::sun::star::uno::Any& _out_rConvertedValue, ::com::sun::star::uno::Any& _out_rCurrentValue ) const;
      87             :         inline void setDynamicFastPropertyValue( sal_Int32 _nHandle, const ::com::sun::star::uno::Any& _rValue );
      88             :         inline void getDynamicPropertyDefaultByHandle( sal_Int32 _nHandle, ::com::sun::star::uno::Any& _out_rValue ) const;
      89             :         inline bool hasDynamicPropertyByName( const ::rtl::OUString& _rName ) const;
      90             :         inline bool hasDynamicPropertyByHandle( sal_Int32 _nHandle ) const;
      91             : 
      92             :     private:
      93             :         void    impl_nts_checkDisposed_throw() const;
      94             : 
      95             :         /** invalidates our property set info, so subsequent calls to impl_ts_getArrayHelper and thus
      96             :             getInfoHelper will return a newly created instance
      97             :         */
      98             :         void    impl_nts_invalidatePropertySetInfo();
      99             : 
     100             :         /** returns the IPropertyArrayHelper instance used by |this|
     101             :         */
     102             :         ::comphelper::OPropertyArrayAggregationHelper& impl_ts_getArrayHelper() const;
     103             : 
     104             :         /** finds a free property handle
     105             :             @param _rPropertyName
     106             :                 the name of the property to find a handle for. If possible, the handle as determined by
     107             :                 our ConcreteInfoService instance will be used
     108             :         */
     109             :         sal_Int32   impl_findFreeHandle( const ::rtl::OUString& _rPropertyName );
     110             :     };
     111             : 
     112             :     //--------------------------------------------------------------------
     113        2297 :     inline ::comphelper::OPropertyArrayAggregationHelper& PropertyBagHelper::getInfoHelper() const
     114             :     {
     115        2297 :         return impl_ts_getArrayHelper();
     116             :     }
     117             : 
     118             :     //--------------------------------------------------------------------
     119           0 :     inline void PropertyBagHelper::getDynamicFastPropertyValue( sal_Int32 _nHandle, ::com::sun::star::uno::Any& _out_rValue ) const
     120             :     {
     121           0 :         m_aDynamicProperties.getFastPropertyValue( _nHandle, _out_rValue );
     122           0 :     }
     123             : 
     124             :     //--------------------------------------------------------------------
     125           0 :     inline bool PropertyBagHelper::convertDynamicFastPropertyValue( sal_Int32 _nHandle, const ::com::sun::star::uno::Any& _rNewValue, ::com::sun::star::uno::Any& _out_rConvertedValue, ::com::sun::star::uno::Any& _out_rCurrentValue ) const
     126             :     {
     127           0 :         return m_aDynamicProperties.convertFastPropertyValue( _nHandle, _rNewValue, _out_rConvertedValue, _out_rCurrentValue );
     128             :     }
     129             : 
     130             :     //--------------------------------------------------------------------
     131           0 :     inline void PropertyBagHelper::setDynamicFastPropertyValue( sal_Int32 _nHandle, const ::com::sun::star::uno::Any& _rValue )
     132             :     {
     133           0 :         m_aDynamicProperties.setFastPropertyValue( _nHandle, _rValue );
     134           0 :     }
     135             : 
     136             :     //--------------------------------------------------------------------
     137           0 :     inline void PropertyBagHelper::getDynamicPropertyDefaultByHandle( sal_Int32 _nHandle, ::com::sun::star::uno::Any& _out_rValue ) const
     138             :     {
     139           0 :         m_aDynamicProperties.getPropertyDefaultByHandle( _nHandle, _out_rValue );
     140           0 :     }
     141             : 
     142             :     //--------------------------------------------------------------------
     143             :     inline bool PropertyBagHelper::hasDynamicPropertyByName( const ::rtl::OUString& _rName ) const
     144             :     {
     145             :         return m_aDynamicProperties.hasPropertyByName( _rName );
     146             :     }
     147             : 
     148             :     //--------------------------------------------------------------------
     149         342 :     inline bool PropertyBagHelper::hasDynamicPropertyByHandle( sal_Int32 _nHandle ) const
     150             :     {
     151         342 :         return m_aDynamicProperties.hasPropertyByHandle( _nHandle );
     152             :     }
     153             : 
     154             : //........................................................................
     155             : } // namespace frm
     156             : //........................................................................
     157             : 
     158             : #endif // FORMS_PROPERTYBAGHELPER_HXX
     159             : 
     160             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10