LCOV - code coverage report
Current view: top level - forms/source/inc - propertybaghelper.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 6 17 35.3 %
Date: 2012-08-25 Functions: 4 8 50.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef FORMS_PROPERTYBAGHELPER_HXX
      30                 :            : #define FORMS_PROPERTYBAGHELPER_HXX
      31                 :            : 
      32                 :            : #include <com/sun/star/beans/PropertyValue.hpp>
      33                 :            : 
      34                 :            : #include <comphelper/propertybag.hxx>
      35                 :            : #include <comphelper/propagg.hxx>
      36                 :            : 
      37                 :            : #include <boost/noncopyable.hpp>
      38                 :            : 
      39                 :            : //........................................................................
      40                 :            : namespace frm
      41                 :            : {
      42                 :            : //........................................................................
      43                 :            : 
      44                 :            :     //====================================================================
      45                 :            :     //= class IPropertyBagHelperContext
      46                 :            :     //====================================================================
      47                 :       1275 :     class SAL_NO_VTABLE IPropertyBagHelperContext
      48                 :            :     {
      49                 :            :     public:
      50                 :            :         virtual ::osl::Mutex&   getMutex() = 0;
      51                 :            : 
      52                 :            :         virtual void            describeFixedAndAggregateProperties(
      53                 :            :             ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& _out_rFixedProperties,
      54                 :            :             ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& _out_rAggregateProperties
      55                 :            :         ) const = 0;
      56                 :            : 
      57                 :            :         virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XMultiPropertySet >
      58                 :            :                                 getPropertiesInterface() = 0;
      59                 :            : 
      60                 :            :     protected:
      61                 :       1200 :         ~IPropertyBagHelperContext() {}
      62                 :            :     };
      63                 :            : 
      64                 :            :     //====================================================================
      65                 :            :     //= class PropertyBagHelper
      66                 :            :     //====================================================================
      67                 :            :     class PropertyBagHelper : public ::boost::noncopyable
      68                 :            :     {
      69                 :            :     private:
      70                 :            :         IPropertyBagHelperContext&                      m_rContext;
      71                 :            :         ::comphelper::OPropertyArrayAggregationHelper*  m_pPropertyArrayHelper;
      72                 :            :         ::comphelper::PropertyBag                       m_aDynamicProperties;
      73                 :            :         bool                                            m_bDisposed;
      74                 :            : 
      75                 :            :     public:
      76                 :            :         PropertyBagHelper( IPropertyBagHelperContext& _rContext );
      77                 :            :         ~PropertyBagHelper();
      78                 :            : 
      79                 :            :         // XComponent equivalent
      80                 :            :         void    dispose();
      81                 :            : 
      82                 :            :         // OPropertySetHelper equivalent
      83                 :            :         inline ::comphelper::OPropertyArrayAggregationHelper& getInfoHelper() const;
      84                 :            : 
      85                 :            :         // XPropertyContainer equivalent
      86                 :            :         void addProperty( const ::rtl::OUString& _rName, ::sal_Int16 _nAttributes, const ::com::sun::star::uno::Any& _rInitialValue );
      87                 :            :         void removeProperty( const ::rtl::OUString& _rName );
      88                 :            : 
      89                 :            :         // XPropertyAccess equivalent
      90                 :            :         ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getPropertyValues();
      91                 :            :         void setPropertyValues( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rProps );
      92                 :            : 
      93                 :            :         // forwards to m_aDynamicProperties
      94                 :            :         inline void getDynamicFastPropertyValue( sal_Int32 _nHandle, ::com::sun::star::uno::Any& _out_rValue ) const;
      95                 :            :         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;
      96                 :            :         inline void setDynamicFastPropertyValue( sal_Int32 _nHandle, const ::com::sun::star::uno::Any& _rValue );
      97                 :            :         inline void getDynamicPropertyDefaultByHandle( sal_Int32 _nHandle, ::com::sun::star::uno::Any& _out_rValue ) const;
      98                 :            :         inline bool hasDynamicPropertyByName( const ::rtl::OUString& _rName ) const;
      99                 :            :         inline bool hasDynamicPropertyByHandle( sal_Int32 _nHandle ) const;
     100                 :            : 
     101                 :            :     private:
     102                 :            :         void    impl_nts_checkDisposed_throw() const;
     103                 :            : 
     104                 :            :         /** invalidates our property set info, so subsequent calls to impl_ts_getArrayHelper and thus
     105                 :            :             getInfoHelper will return a newly created instance
     106                 :            :         */
     107                 :            :         void    impl_nts_invalidatePropertySetInfo();
     108                 :            : 
     109                 :            :         /** returns the IPropertyArrayHelper instance used by |this|
     110                 :            :         */
     111                 :            :         ::comphelper::OPropertyArrayAggregationHelper& impl_ts_getArrayHelper() const;
     112                 :            : 
     113                 :            :         /** finds a free property handle
     114                 :            :             @param _rPropertyName
     115                 :            :                 the name of the property to find a handle for. If possible, the handle as determined by
     116                 :            :                 our ConcreteInfoService instance will be used
     117                 :            :         */
     118                 :            :         sal_Int32   impl_findFreeHandle( const ::rtl::OUString& _rPropertyName );
     119                 :            :     };
     120                 :            : 
     121                 :            :     //--------------------------------------------------------------------
     122                 :     333965 :     inline ::comphelper::OPropertyArrayAggregationHelper& PropertyBagHelper::getInfoHelper() const
     123                 :            :     {
     124                 :     333965 :         return impl_ts_getArrayHelper();
     125                 :            :     }
     126                 :            : 
     127                 :            :     //--------------------------------------------------------------------
     128                 :          0 :     inline void PropertyBagHelper::getDynamicFastPropertyValue( sal_Int32 _nHandle, ::com::sun::star::uno::Any& _out_rValue ) const
     129                 :            :     {
     130                 :          0 :         m_aDynamicProperties.getFastPropertyValue( _nHandle, _out_rValue );
     131                 :          0 :     }
     132                 :            : 
     133                 :            :     //--------------------------------------------------------------------
     134                 :          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
     135                 :            :     {
     136                 :          0 :         return m_aDynamicProperties.convertFastPropertyValue( _nHandle, _rNewValue, _out_rConvertedValue, _out_rCurrentValue );
     137                 :            :     }
     138                 :            : 
     139                 :            :     //--------------------------------------------------------------------
     140                 :          0 :     inline void PropertyBagHelper::setDynamicFastPropertyValue( sal_Int32 _nHandle, const ::com::sun::star::uno::Any& _rValue )
     141                 :            :     {
     142                 :          0 :         m_aDynamicProperties.setFastPropertyValue( _nHandle, _rValue );
     143                 :          0 :     }
     144                 :            : 
     145                 :            :     //--------------------------------------------------------------------
     146                 :          0 :     inline void PropertyBagHelper::getDynamicPropertyDefaultByHandle( sal_Int32 _nHandle, ::com::sun::star::uno::Any& _out_rValue ) const
     147                 :            :     {
     148                 :          0 :         m_aDynamicProperties.getPropertyDefaultByHandle( _nHandle, _out_rValue );
     149                 :          0 :     }
     150                 :            : 
     151                 :            :     //--------------------------------------------------------------------
     152                 :            :     inline bool PropertyBagHelper::hasDynamicPropertyByName( const ::rtl::OUString& _rName ) const
     153                 :            :     {
     154                 :            :         return m_aDynamicProperties.hasPropertyByName( _rName );
     155                 :            :     }
     156                 :            : 
     157                 :            :     //--------------------------------------------------------------------
     158                 :      82067 :     inline bool PropertyBagHelper::hasDynamicPropertyByHandle( sal_Int32 _nHandle ) const
     159                 :            :     {
     160                 :      82067 :         return m_aDynamicProperties.hasPropertyByHandle( _nHandle );
     161                 :            :     }
     162                 :            : 
     163                 :            : //........................................................................
     164                 :            : } // namespace frm
     165                 :            : //........................................................................
     166                 :            : 
     167                 :            : #endif // FORMS_PROPERTYBAGHELPER_HXX
     168                 :            : 
     169                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10