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

Generated by: LCOV version 1.10