LCOV - code coverage report
Current view: top level - forms/source/inc - propertybaghelper.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 6 17 35.3 %
Date: 2015-06-13 12:38:46 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 INCLUDED_FORMS_SOURCE_INC_PROPERTYBAGHELPER_HXX
      21             : #define INCLUDED_FORMS_SOURCE_INC_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         807 :     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         772 :         ~IPropertyBagHelperContext() {}
      53             :     };
      54             : 
      55             :     class PropertyBagHelper : public ::boost::noncopyable
      56             :     {
      57             :     private:
      58             :         IPropertyBagHelperContext&                      m_rContext;
      59             :         ::comphelper::OPropertyArrayAggregationHelper*  m_pPropertyArrayHelper;
      60             :         ::comphelper::PropertyBag                       m_aDynamicProperties;
      61             :         bool                                            m_bDisposed;
      62             : 
      63             :     public:
      64             :         PropertyBagHelper( IPropertyBagHelperContext& _rContext );
      65             :         ~PropertyBagHelper();
      66             : 
      67             :         // XComponent equivalent
      68             :         void    dispose();
      69             : 
      70             :         // OPropertySetHelper equivalent
      71             :         inline ::comphelper::OPropertyArrayAggregationHelper& getInfoHelper() const;
      72             : 
      73             :         // XPropertyContainer equivalent
      74             :         void addProperty( const OUString& _rName, ::sal_Int16 _nAttributes, const ::com::sun::star::uno::Any& _rInitialValue );
      75             :         void removeProperty( const OUString& _rName );
      76             : 
      77             :         // XPropertyAccess equivalent
      78             :         ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getPropertyValues();
      79             :         void setPropertyValues( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rProps );
      80             : 
      81             :         // forwards to m_aDynamicProperties
      82             :         inline void getDynamicFastPropertyValue( sal_Int32 _nHandle, ::com::sun::star::uno::Any& _out_rValue ) const;
      83             :         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;
      84             :         inline void setDynamicFastPropertyValue( sal_Int32 _nHandle, const ::com::sun::star::uno::Any& _rValue );
      85             :         inline void getDynamicPropertyDefaultByHandle( sal_Int32 _nHandle, ::com::sun::star::uno::Any& _out_rValue ) const;
      86             :         inline bool hasDynamicPropertyByName( const OUString& _rName ) const;
      87             :         inline bool hasDynamicPropertyByHandle( sal_Int32 _nHandle ) const;
      88             : 
      89             :     private:
      90             :         void    impl_nts_checkDisposed_throw() const;
      91             : 
      92             :         /** invalidates our property set info, so subsequent calls to impl_ts_getArrayHelper and thus
      93             :             getInfoHelper will return a newly created instance
      94             :         */
      95             :         void    impl_nts_invalidatePropertySetInfo();
      96             : 
      97             :         /** returns the IPropertyArrayHelper instance used by |this|
      98             :         */
      99             :         ::comphelper::OPropertyArrayAggregationHelper& impl_ts_getArrayHelper() const;
     100             : 
     101             :         /** finds a free property handle
     102             :             @param _rPropertyName
     103             :                 the name of the property to find a handle for. If possible, the handle as determined by
     104             :                 our ConcreteInfoService instance will be used
     105             :         */
     106             :         sal_Int32   impl_findFreeHandle( const OUString& _rPropertyName );
     107             :     };
     108             : 
     109             : 
     110      184945 :     inline ::comphelper::OPropertyArrayAggregationHelper& PropertyBagHelper::getInfoHelper() const
     111             :     {
     112      184945 :         return impl_ts_getArrayHelper();
     113             :     }
     114             : 
     115             : 
     116           0 :     inline void PropertyBagHelper::getDynamicFastPropertyValue( sal_Int32 _nHandle, ::com::sun::star::uno::Any& _out_rValue ) const
     117             :     {
     118           0 :         m_aDynamicProperties.getFastPropertyValue( _nHandle, _out_rValue );
     119           0 :     }
     120             : 
     121             : 
     122           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
     123             :     {
     124           0 :         return m_aDynamicProperties.convertFastPropertyValue( _nHandle, _rNewValue, _out_rConvertedValue, _out_rCurrentValue );
     125             :     }
     126             : 
     127             : 
     128           0 :     inline void PropertyBagHelper::setDynamicFastPropertyValue( sal_Int32 _nHandle, const ::com::sun::star::uno::Any& _rValue )
     129             :     {
     130           0 :         m_aDynamicProperties.setFastPropertyValue( _nHandle, _rValue );
     131           0 :     }
     132             : 
     133             : 
     134           0 :     inline void PropertyBagHelper::getDynamicPropertyDefaultByHandle( sal_Int32 _nHandle, ::com::sun::star::uno::Any& _out_rValue ) const
     135             :     {
     136           0 :         m_aDynamicProperties.getPropertyDefaultByHandle( _nHandle, _out_rValue );
     137           0 :     }
     138             : 
     139             : 
     140             :     inline bool PropertyBagHelper::hasDynamicPropertyByName( const OUString& _rName ) const
     141             :     {
     142             :         return m_aDynamicProperties.hasPropertyByName( _rName );
     143             :     }
     144             : 
     145             : 
     146       42515 :     inline bool PropertyBagHelper::hasDynamicPropertyByHandle( sal_Int32 _nHandle ) const
     147             :     {
     148       42515 :         return m_aDynamicProperties.hasPropertyByHandle( _nHandle );
     149             :     }
     150             : 
     151             : 
     152             : } // namespace frm
     153             : 
     154             : 
     155             : #endif // INCLUDED_FORMS_SOURCE_INC_PROPERTYBAGHELPER_HXX
     156             : 
     157             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11