Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / chart2 / source / inc / PropertyHelper.hxx
blobddf941a6d3e59a3c6d27491b6260b580f5354e61
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_CHART2_SOURCE_INC_PROPERTYHELPER_HXX
20 #define INCLUDED_CHART2_SOURCE_INC_PROPERTYHELPER_HXX
22 #include <com/sun/star/beans/Property.hpp>
23 #include <com/sun/star/uno/Any.hxx>
24 #include "charttoolsdllapi.hxx"
26 #include <unordered_map>
28 namespace com { namespace sun { namespace star { namespace lang { class XMultiServiceFactory; } } } }
30 namespace chart
33 typedef int tPropertyValueMapKey;
35 typedef std::unordered_map<tPropertyValueMapKey, css::uno::Any> tPropertyValueMap;
37 namespace PropertyHelper
40 /** adds a line dash with a unique name to the gradient obtained by the given
41 factory.
43 @return The name used for storing this element in the table
45 OOO_DLLPUBLIC_CHARTTOOLS OUString addLineDashUniqueNameToTable(
46 const css::uno::Any & rValue,
47 const css::uno::Reference< css::lang::XMultiServiceFactory > & xFact,
48 const OUString & rPreferredName );
50 /** adds a gradient with a unique name to the gradient obtained by the given
51 factory.
53 @return The name used for storing this element in the table
55 OOO_DLLPUBLIC_CHARTTOOLS OUString addGradientUniqueNameToTable(
56 const css::uno::Any & rValue,
57 const css::uno::Reference< css::lang::XMultiServiceFactory > & xFact,
58 const OUString & rPreferredName );
60 /** adds a transparency gradient with a unique name to the gradient obtained
61 by the given factory.
63 @return The name used for storing this element in the table
65 OOO_DLLPUBLIC_CHARTTOOLS
66 OUString addTransparencyGradientUniqueNameToTable(
67 const css::uno::Any & rValue,
68 const css::uno::Reference< css::lang::XMultiServiceFactory > & xFact,
69 const OUString & rPreferredName );
71 /** adds a hatch with a unique name to the gradient obtained by the given
72 factory.
74 @return The name used for storing this element in the table
76 OOO_DLLPUBLIC_CHARTTOOLS OUString addHatchUniqueNameToTable(
77 const css::uno::Any & rValue,
78 const css::uno::Reference< css::lang::XMultiServiceFactory > & xFact,
79 const OUString & rPreferredName );
81 /** adds a bitmap with a unique name to the gradient obtained by the given
82 factory.
84 @return The name used for storing this element in the table
86 OOO_DLLPUBLIC_CHARTTOOLS OUString addBitmapUniqueNameToTable(
87 const css::uno::Any & rValue,
88 const css::uno::Reference< css::lang::XMultiServiceFactory > & xFact,
89 const OUString & rPreferredName );
91 /** Set a property to a certain value in the given map. This works for
92 properties that are already set, and those which are not yet in the map.
94 @param any is the value encapsulated in the variant type Any
96 OOO_DLLPUBLIC_CHARTTOOLS
97 void setPropertyValueAny( tPropertyValueMap & rOutMap, tPropertyValueMapKey key,
98 const css::uno::Any & rAny );
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.
103 @param value is the value of type Value that will be put into a variant type
104 Any before set in the property map.
106 template< typename Value >
107 void setPropertyValue( tPropertyValueMap & rOutMap, tPropertyValueMapKey key, const Value & value )
109 setPropertyValueAny( rOutMap, key, css::uno::Any( value ));
112 template<>
113 void setPropertyValue< css::uno::Any >( tPropertyValueMap & rOutMap, tPropertyValueMapKey key, const css::uno::Any & rAny );
115 OOO_DLLPUBLIC_CHARTTOOLS void setPropertyValueDefaultAny( tPropertyValueMap & rOutMap, tPropertyValueMapKey key, const css::uno::Any & rAny );
117 /** Calls setPropertyValue() but asserts that the given property hasn't been set
118 before.
120 template< typename Value >
121 void setPropertyValueDefault( tPropertyValueMap & rOutMap, tPropertyValueMapKey key, const Value & value )
123 setPropertyValueDefaultAny( rOutMap, key, css::uno::Any( value ));
126 /** Calls setPropertyValue() but asserts that the given property hasn't been set
127 before.
129 template<>
130 void setPropertyValueDefault< css::uno::Any >( tPropertyValueMap & rOutMap, tPropertyValueMapKey key, const css::uno::Any & rAny );
132 /** Calls setPropertyValueDefault() with an empty Any as value
134 OOO_DLLPUBLIC_CHARTTOOLS void setEmptyPropertyValueDefault( tPropertyValueMap & rOutMap, tPropertyValueMapKey key );
136 } // namespace PropertyHelper
138 struct OOO_DLLPUBLIC_CHARTTOOLS PropertyNameLess
140 bool operator() ( const css::beans::Property & first,
141 const css::beans::Property & second )
143 return ( first.Name.compareTo( second.Name ) < 0 );
147 } // namespace chart
149 // INCLUDED_CHART2_SOURCE_INC_PROPERTYHELPER_HXX
150 #endif
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */