LCOV - code coverage report
Current view: top level - forms/source/inc - property.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 8 8 100.0 %
Date: 2015-06-13 12:38:46 Functions: 6 7 85.7 %
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_PROPERTY_HXX
      21             : #define INCLUDED_FORMS_SOURCE_INC_PROPERTY_HXX
      22             : 
      23             : #include <sal/config.h>
      24             : 
      25             : #include <vector>
      26             : 
      27             : #include <com/sun/star/uno/XAggregation.hpp>
      28             : #include <com/sun/star/beans/XPropertyState.hpp>
      29             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      30             : #include <cppuhelper/propshlp.hxx>
      31             : #include <cppuhelper/proptypehlp.hxx>
      32             : #include <comphelper/property.hxx>
      33             : #include <comphelper/propagg.hxx>
      34             : #include <tools/debug.hxx>
      35             : 
      36             : using namespace comphelper;
      37             : 
      38             : //= property helper classes
      39             : 
      40             : namespace frm
      41             : {
      42             : 
      43             : //= assigment property handle <-> property name
      44             : //= used by the PropertySetAggregationHelper
      45             : 
      46             : 
      47             : class PropertyInfoService
      48             : {
      49             : 
      50       89207 :     struct PropertyAssignment
      51             :     {
      52             :         OUString     sName;
      53             :         sal_Int32           nHandle;
      54             : 
      55             :         PropertyAssignment() { nHandle = -1; }
      56       14848 :         PropertyAssignment(const PropertyAssignment& _rSource)
      57       14848 :             :sName(_rSource.sName), nHandle(_rSource.nHandle) { }
      58       44919 :         PropertyAssignment(const OUString& _rName, sal_Int32 _nHandle)
      59       44919 :             :sName(_rName), nHandle(_nHandle) { }
      60             : 
      61             :     };
      62             : 
      63             :     typedef std::vector<PropertyAssignment> PropertyMap;
      64             :     static PropertyMap      s_AllKnownProperties;
      65             : 
      66             : 
      67             :     // comparing two PropertyAssignment's
      68             : public:
      69             :     typedef PropertyAssignment PUBLIC_SOLARIS_COMPILER_HACK;
      70             :         // did not get the following compiled under with SUNPRO 5 without this
      71             :         // public typedef
      72             : private:
      73             :     friend struct PropertyAssignmentNameCompareLess;
      74             :     typedef ::std::binary_function< PUBLIC_SOLARIS_COMPILER_HACK, PUBLIC_SOLARIS_COMPILER_HACK, sal_Bool > PropertyAssignmentNameCompareLess_Base;
      75             :     struct PropertyAssignmentNameCompareLess : public PropertyAssignmentNameCompareLess_Base
      76             :     {
      77      509266 :         inline bool operator() (const PUBLIC_SOLARIS_COMPILER_HACK& _rL, const PUBLIC_SOLARIS_COMPILER_HACK& _rR) const
      78             :         {
      79      509266 :             return (_rL.sName.compareTo(_rR.sName) < 0);
      80             :         }
      81             :     };
      82             : 
      83             : public:
      84             :     PropertyInfoService() { }
      85             : 
      86             : public:
      87             :     static sal_Int32            getPropertyId(const OUString& _rName);
      88             :     static OUString      getPropertyName(sal_Int32 _nHandle);
      89             : 
      90             : private:
      91             :     static void initialize();
      92             : };
      93             : 
      94             : 
      95             : // a class implementing the comphelper::IPropertyInfoService
      96             : class ConcreteInfoService : public ::comphelper::IPropertyInfoService
      97             : {
      98             : public:
      99          32 :     virtual ~ConcreteInfoService() {}
     100             : 
     101             :     virtual sal_Int32 getPreferredPropertyId(const OUString& _rName) SAL_OVERRIDE;
     102             : };
     103             : 
     104             : 
     105             : #define DECL_PROP_IMPL(varname, type) \
     106             :     *pProperties++ = com::sun::star::beans::Property(PROPERTY_##varname, PROPERTY_ID_##varname, cppu::UnoType<type>::get(),
     107             : 
     108             : 
     109             : #define DECL_BOOL_PROP_IMPL(varname) \
     110             :     *pProperties++ = com::sun::star::beans::Property(PROPERTY_##varname, PROPERTY_ID_##varname, cppu::UnoType<bool>::get(),
     111             : 
     112             : 
     113             : #define DECL_IFACE_PROP_IMPL(varname, type) \
     114             :     *pProperties++ = com::sun::star::beans::Property(PROPERTY_##varname, PROPERTY_ID_##varname, cppu::UnoType<type>::get(),
     115             : 
     116             : 
     117             : #define BEGIN_DESCRIBE_PROPERTIES( count, baseclass )   \
     118             :     baseclass::describeFixedProperties( _rProps ); \
     119             :     sal_Int32 nOldCount = _rProps.getLength(); \
     120             :     _rProps.realloc( nOldCount + ( count ) );   \
     121             :     ::com::sun::star::beans::Property* pProperties = _rProps.getArray() + nOldCount;       \
     122             : 
     123             : 
     124             : #define BEGIN_DESCRIBE_BASE_PROPERTIES( count ) \
     125             :     _rProps.realloc( count );   \
     126             :     ::com::sun::star::beans::Property* pProperties = _rProps.getArray();       \
     127             : 
     128             : 
     129             : #define BEGIN_DESCRIBE_AGGREGATION_PROPERTIES( count, aggregate )   \
     130             :     _rProps.realloc( count );   \
     131             :     ::com::sun::star::beans::Property* pProperties = _rProps.getArray();       \
     132             :     \
     133             :     if (aggregate.is()) \
     134             :         _rAggregateProps = aggregate->getPropertySetInfo()->getProperties();    \
     135             : 
     136             : 
     137             : 
     138             : #define DECL_PROP0(varname, type)   \
     139             :     DECL_PROP_IMPL(varname, type) 0)
     140             : 
     141             : 
     142             : #define DECL_PROP1(varname, type, attrib1)  \
     143             :         DECL_PROP_IMPL(varname, type) com::sun::star::beans::PropertyAttribute::attrib1)
     144             : 
     145             : 
     146             : #define DECL_PROP2(varname, type, attrib1, attrib2) \
     147             :         DECL_PROP_IMPL(varname, type) com::sun::star::beans::PropertyAttribute::attrib1 | com::sun::star::beans::PropertyAttribute::attrib2)
     148             : 
     149             : 
     150             : #define DECL_PROP3(varname, type, attrib1, attrib2, attrib3)    \
     151             :         DECL_PROP_IMPL(varname, type) com::sun::star::beans::PropertyAttribute::attrib1 | com::sun::star::beans::PropertyAttribute::attrib2 | com::sun::star::beans::PropertyAttribute::attrib3)
     152             : 
     153             : 
     154             : #define DECL_PROP4(varname, type, attrib1, attrib2, attrib3, attrib4)   \
     155             :         DECL_PROP_IMPL(varname, type) com::sun::star::beans::PropertyAttribute::attrib1 | com::sun::star::beans::PropertyAttribute::attrib2 | com::sun::star::beans::PropertyAttribute::attrib3 | com::sun::star::beans::PropertyAttribute::attrib4)
     156             : 
     157             : // === some property types require special handling
     158             : // === such as interfaces
     159             : 
     160             : #define DECL_IFACE_PROP0(varname, type) \
     161             :     DECL_IFACE_PROP_IMPL(varname, type) 0)
     162             : 
     163             : 
     164             : #define DECL_IFACE_PROP1(varname, type, attrib1)    \
     165             :     DECL_IFACE_PROP_IMPL(varname, type) css::beans::PropertyAttribute::attrib1)
     166             : 
     167             : 
     168             : #define DECL_IFACE_PROP2(varname, type, attrib1, attrib2)   \
     169             :         DECL_IFACE_PROP_IMPL(varname, type) com::sun::star::beans::PropertyAttribute::attrib1 | com::sun::star::beans::PropertyAttribute::attrib2)
     170             : 
     171             : 
     172             : #define DECL_IFACE_PROP3(varname, type, attrib1, attrib2, attrib3)  \
     173             :     DECL_IFACE_PROP_IMPL(varname, type) css::beans::PropertyAttribute::attrib1 | css::beans::PropertyAttribute::attrib2 | css::beans::PropertyAttribute::attrib3)
     174             : 
     175             : 
     176             : #define DECL_IFACE_PROP4(varname, type, attrib1, attrib2, attrib3, attrib4) \
     177             :     DECL_IFACE_PROP_IMPL(varname, type) css::beans::PropertyAttribute::attrib1 | css::beans::PropertyAttribute::attrib2 | css::beans::PropertyAttribute::attrib3 | PropertyAttribute::attrib4)
     178             : 
     179             : // === or Boolean properties
     180             : 
     181             : #define DECL_BOOL_PROP0(varname)    \
     182             :     DECL_BOOL_PROP_IMPL(varname) 0)
     183             : 
     184             : 
     185             : #define DECL_BOOL_PROP1(varname, attrib1)   \
     186             :         DECL_BOOL_PROP_IMPL(varname) com::sun::star::beans::PropertyAttribute::attrib1)
     187             : 
     188             : 
     189             : #define DECL_BOOL_PROP2(varname, attrib1, attrib2)  \
     190             :         DECL_BOOL_PROP_IMPL(varname) com::sun::star::beans::PropertyAttribute::attrib1 | com::sun::star::beans::PropertyAttribute::attrib2)
     191             : 
     192             : 
     193             : #define DECL_BOOL_PROP3( varname, attrib1, attrib2, attrib3 )   \
     194             :         DECL_BOOL_PROP_IMPL(varname) com::sun::star::beans::PropertyAttribute::attrib1 | com::sun::star::beans::PropertyAttribute::attrib2 | com::sun::star::beans::PropertyAttribute::attrib3 )
     195             : 
     196             : 
     197             : 
     198             : #define END_DESCRIBE_PROPERTIES()   \
     199             :     DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(), "<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?"); \
     200             : 
     201             : 
     202             : 
     203             : #define REGISTER_PROP_1( prop, member, attrib1 ) \
     204             :     registerProperty( PROPERTY_##prop, PROPERTY_ID_##prop, PropertyAttribute::attrib1, \
     205             :         &member, cppu::UnoType<decltype(member)>::get() );
     206             : 
     207             : #define REGISTER_PROP_2( prop, member, attrib1, attrib2 ) \
     208             :     registerProperty( PROPERTY_##prop, PROPERTY_ID_##prop, PropertyAttribute::attrib1 | PropertyAttribute::attrib2, \
     209             :         &member, cppu::UnoType<decltype(member)>::get() );
     210             : 
     211             : #define REGISTER_PROP_3( prop, member, attrib1, attrib2, attrib3 ) \
     212             :     registerProperty( PROPERTY_##prop, PROPERTY_ID_##prop, PropertyAttribute::attrib1 | PropertyAttribute::attrib2 | PropertyAttribute::attrib3, \
     213             :         &member, cppu::UnoType<decltype(member)>::get() );
     214             : 
     215             : 
     216             : #define REGISTER_VOID_PROP_1( prop, memberAny, type, attrib1 ) \
     217             :     registerMayBeVoidProperty( PROPERTY_##prop, PROPERTY_ID_##prop, PropertyAttribute::MAYBEVOID | PropertyAttribute::attrib1, \
     218             :         &memberAny, cppu::UnoType<type>::get() );
     219             : 
     220             : #define REGISTER_VOID_PROP_2( prop, memberAny, type, attrib1, attrib2 ) \
     221             :     registerMayBeVoidProperty( PROPERTY_##prop, PROPERTY_ID_##prop, PropertyAttribute::MAYBEVOID | PropertyAttribute::attrib1 | PropertyAttribute::attrib2, \
     222             :         &memberAny, cppu::UnoType<type>::get() );
     223             : 
     224             : 
     225             : }
     226             : //... namespace frm .......................................................
     227             : 
     228             : #endif // INCLUDED_FORMS_SOURCE_INC_PROPERTY_HXX
     229             : 
     230             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11