LCOV - code coverage report
Current view: top level - chart2/source/inc - PropertyHelper.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 8 8 100.0 %
Date: 2012-08-25 Functions: 39 39 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 13 32 40.6 %

           Branch data     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                 :            : #ifndef CHART_PROPERTYHELPER_HXX
      20                 :            : #define CHART_PROPERTYHELPER_HXX
      21                 :            : 
      22                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      23                 :            : #include <com/sun/star/beans/Property.hpp>
      24                 :            : #include <com/sun/star/beans/PropertyValue.hpp>
      25                 :            : #include <com/sun/star/uno/Any.hxx>
      26                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      27                 :            : #include <comphelper/property.hxx>
      28                 :            : #include <map>
      29                 :            : #include "charttoolsdllapi.hxx"
      30                 :            : 
      31                 :            : namespace chart
      32                 :            : {
      33                 :            : 
      34                 :            : typedef int tPropertyValueMapKey;
      35                 :            : 
      36                 :            : typedef ::std::map< tPropertyValueMapKey, ::com::sun::star::uno::Any >
      37                 :            :     tPropertyValueMap;
      38                 :            : 
      39                 :            : namespace PropertyHelper
      40                 :            : {
      41                 :            : 
      42                 :            : /** adds a line dash with a unique name to the gradient obtained by the given
      43                 :            :     factory.
      44                 :            : 
      45                 :            :     @return The name used for storing this element in the table
      46                 :            : */
      47                 :            : OOO_DLLPUBLIC_CHARTTOOLS ::rtl::OUString addLineDashUniqueNameToTable(
      48                 :            :     const ::com::sun::star::uno::Any & rValue,
      49                 :            :     const ::com::sun::star::uno::Reference<
      50                 :            :         ::com::sun::star::lang::XMultiServiceFactory > & xFact,
      51                 :            :     const ::rtl::OUString & rPreferredName );
      52                 :            : 
      53                 :            : /** adds a gradient with a unique name to the gradient obtained by the given
      54                 :            :     factory.
      55                 :            : 
      56                 :            :     @return The name used for storing this element in the table
      57                 :            : */
      58                 :            : OOO_DLLPUBLIC_CHARTTOOLS ::rtl::OUString addGradientUniqueNameToTable(
      59                 :            :     const ::com::sun::star::uno::Any & rValue,
      60                 :            :     const ::com::sun::star::uno::Reference<
      61                 :            :         ::com::sun::star::lang::XMultiServiceFactory > & xFact,
      62                 :            :     const ::rtl::OUString & rPreferredName );
      63                 :            : 
      64                 :            : /** adds a transparency gradient with a unique name to the gradient obtained
      65                 :            :     by the given factory.
      66                 :            : 
      67                 :            :     @return The name used for storing this element in the table
      68                 :            : */
      69                 :            : OOO_DLLPUBLIC_CHARTTOOLS
      70                 :            : ::rtl::OUString addTransparencyGradientUniqueNameToTable(
      71                 :            :     const ::com::sun::star::uno::Any & rValue,
      72                 :            :     const ::com::sun::star::uno::Reference<
      73                 :            :         ::com::sun::star::lang::XMultiServiceFactory > & xFact,
      74                 :            :     const ::rtl::OUString & rPreferredName );
      75                 :            : 
      76                 :            : /** adds a hatch with a unique name to the gradient obtained by the given
      77                 :            :     factory.
      78                 :            : 
      79                 :            :     @return The name used for storing this element in the table
      80                 :            : */
      81                 :            : OOO_DLLPUBLIC_CHARTTOOLS ::rtl::OUString addHatchUniqueNameToTable(
      82                 :            :     const ::com::sun::star::uno::Any & rValue,
      83                 :            :     const ::com::sun::star::uno::Reference<
      84                 :            :         ::com::sun::star::lang::XMultiServiceFactory > & xFact,
      85                 :            :     const ::rtl::OUString & rPreferredName );
      86                 :            : 
      87                 :            : /** adds a bitmap with a unique name to the gradient obtained by the given
      88                 :            :     factory.
      89                 :            : 
      90                 :            :     @return The name used for storing this element in the table
      91                 :            : */
      92                 :            : OOO_DLLPUBLIC_CHARTTOOLS ::rtl::OUString addBitmapUniqueNameToTable(
      93                 :            :     const ::com::sun::star::uno::Any & rValue,
      94                 :            :     const ::com::sun::star::uno::Reference<
      95                 :            :         ::com::sun::star::lang::XMultiServiceFactory > & xFact,
      96                 :            :     const ::rtl::OUString & rPreferredName );
      97                 :            : 
      98                 :            : // --------------------------------------------------------------------------------
      99                 :            : 
     100                 :            : /** Set a property to a certain value in the given map.  This works for
     101                 :            :     properties that are already set, and those which are not yet in the map.
     102                 :            : 
     103                 :            :     @param any is the value encapsulated in the variant type Any
     104                 :            :  */
     105                 :            : OOO_DLLPUBLIC_CHARTTOOLS
     106                 :            : void setPropertyValueAny( tPropertyValueMap & rOutMap, tPropertyValueMapKey key,
     107                 :            :                           const ::com::sun::star::uno::Any & rAny );
     108                 :            : 
     109                 :            : /** Set a property to a certain value in the given map.  This works for
     110                 :            :     properties that are already set, and those which are not yet in the map.
     111                 :            : 
     112                 :            :     @param value is the value of type Value that will be put into a variant type
     113                 :            :         Any before set in the property map.
     114                 :            :  */
     115                 :            : template< typename Value >
     116                 :        200 :     void setPropertyValue( tPropertyValueMap & rOutMap, tPropertyValueMapKey key, const Value & value )
     117                 :            : {
     118 [ +  - ][ +  - ]:        200 :     setPropertyValueAny( rOutMap, key, ::com::sun::star::uno::makeAny( value ));
                 [ #  # ]
     119                 :        200 : }
     120                 :            : 
     121                 :            : template<>
     122                 :            :     void setPropertyValue< ::com::sun::star::uno::Any >( tPropertyValueMap & rOutMap, tPropertyValueMapKey key, const ::com::sun::star::uno::Any & rAny );
     123                 :            : 
     124                 :            : OOO_DLLPUBLIC_CHARTTOOLS void setPropertyValueDefaultAny( tPropertyValueMap & rOutMap, tPropertyValueMapKey key, const ::com::sun::star::uno::Any & rAny );
     125                 :            : 
     126                 :            : /** Calls setPropertyValue() but asserts that the given property hasn't been set
     127                 :            :     before.
     128                 :            :  */
     129                 :            : template< typename Value >
     130                 :       4667 :     void setPropertyValueDefault( tPropertyValueMap & rOutMap, tPropertyValueMapKey key, const Value & value )
     131                 :            : {
     132 [ +  - ][ +  - ]:       4667 :     setPropertyValueDefaultAny( rOutMap, key, ::com::sun::star::uno::makeAny( value ));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ #  # ]
         [ +  - ][ +  - ]
                 [ #  # ]
     133                 :       4667 : }
     134                 :            : 
     135                 :            : /** Calls setPropertyValue() but asserts that the given property hasn't been set
     136                 :            :     before.
     137                 :            :  */
     138                 :            : template<>
     139                 :            :     void setPropertyValueDefault< ::com::sun::star::uno::Any >( tPropertyValueMap & rOutMap, tPropertyValueMapKey key, const ::com::sun::star::uno::Any & rAny );
     140                 :            : 
     141                 :            : /** Calls setPropertyValueDefault() with an empty Any as value
     142                 :            :  */
     143                 :            : OOO_DLLPUBLIC_CHARTTOOLS void setEmptyPropertyValueDefault( tPropertyValueMap & rOutMap, tPropertyValueMapKey key );
     144                 :            : 
     145                 :            : 
     146                 :            : } // namespace PropertyHelper
     147                 :            : 
     148                 :            : // ================================================================================
     149                 :            : 
     150                 :            : struct OOO_DLLPUBLIC_CHARTTOOLS PropertyNameLess
     151                 :            : {
     152                 :      81195 :     inline bool operator() ( const ::com::sun::star::beans::Property & first,
     153                 :            :                              const ::com::sun::star::beans::Property & second )
     154                 :            :     {
     155                 :      81195 :         return ( first.Name.compareTo( second.Name ) < 0 );
     156                 :            :     }
     157                 :            : };
     158                 :            : 
     159                 :            : struct OOO_DLLPUBLIC_CHARTTOOLS PropertyLess : public ::std::binary_function<
     160                 :            :         ::com::sun::star::beans::Property,
     161                 :            :         ::com::sun::star::beans::Property,
     162                 :            :         bool >
     163                 :            : {
     164                 :            :     bool operator() ( const ::com::sun::star::beans::Property & rFirst,
     165                 :            :                       const ::com::sun::star::beans::Property & rSecond )
     166                 :            :     {
     167                 :            :         return ( rFirst.Name.compareTo( rSecond.Name ) < 0 );
     168                 :            :     }
     169                 :            : };
     170                 :            : 
     171                 :            : struct OOO_DLLPUBLIC_CHARTTOOLS PropertyValueNameEquals : public ::std::unary_function< ::com::sun::star::beans::PropertyValue, bool >
     172                 :            : {
     173                 :            :     explicit PropertyValueNameEquals( const ::rtl::OUString & rName ) :
     174                 :            :             m_aName( rName )
     175                 :            :     {}
     176                 :            : 
     177                 :            :     bool operator() ( const ::com::sun::star::beans::PropertyValue & rPropValue )
     178                 :            :     {
     179                 :            :         return rPropValue.Name.equals( m_aName );
     180                 :            :     }
     181                 :            : 
     182                 :            : private:
     183                 :            :     ::rtl::OUString m_aName;
     184                 :            : };
     185                 :            : 
     186                 :            : } //  namespace chart
     187                 :            : 
     188                 :            : // CHART_PROPERTYHELPER_HXX
     189                 :            : #endif
     190                 :            : 
     191                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10