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

Generated by: LCOV version 1.10