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

Generated by: LCOV version 1.10