1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
21 #include <com/sun/star/beans/Property.hpp>
22 #include <com/sun/star/uno/Any.hxx>
23 #include "charttoolsdllapi.hxx"
25 #include <unordered_map>
27 namespace com::sun::star::lang
{ class XMultiServiceFactory
; }
32 typedef int tPropertyValueMapKey
;
34 typedef std::unordered_map
<tPropertyValueMapKey
, css::uno::Any
> tPropertyValueMap
;
36 namespace PropertyHelper
39 /** adds a line dash with a unique name to the gradient obtained by the given
42 @return The name used for storing this element in the table
44 OOO_DLLPUBLIC_CHARTTOOLS OUString
addLineDashUniqueNameToTable(
45 const css::uno::Any
& rValue
,
46 const css::uno::Reference
< css::lang::XMultiServiceFactory
> & xFact
,
47 const OUString
& rPreferredName
);
49 /** adds a gradient with a unique name to the gradient obtained by the given
52 @return The name used for storing this element in the table
54 OOO_DLLPUBLIC_CHARTTOOLS OUString
addGradientUniqueNameToTable(
55 const css::uno::Any
& rValue
,
56 const css::uno::Reference
< css::lang::XMultiServiceFactory
> & xFact
,
57 const OUString
& rPreferredName
);
59 /** adds a transparency gradient with a unique name to the gradient obtained
62 @return The name used for storing this element in the table
64 OOO_DLLPUBLIC_CHARTTOOLS
65 OUString
addTransparencyGradientUniqueNameToTable(
66 const css::uno::Any
& rValue
,
67 const css::uno::Reference
< css::lang::XMultiServiceFactory
> & xFact
,
68 const OUString
& rPreferredName
);
70 /** adds a hatch with a unique name to the gradient obtained by the given
73 @return The name used for storing this element in the table
75 OOO_DLLPUBLIC_CHARTTOOLS OUString
addHatchUniqueNameToTable(
76 const css::uno::Any
& rValue
,
77 const css::uno::Reference
< css::lang::XMultiServiceFactory
> & xFact
,
78 const OUString
& rPreferredName
);
80 /** adds a bitmap with a unique name to the gradient obtained by the given
83 @return The name used for storing this element in the table
85 OOO_DLLPUBLIC_CHARTTOOLS OUString
addBitmapUniqueNameToTable(
86 const css::uno::Any
& rValue
,
87 const css::uno::Reference
< css::lang::XMultiServiceFactory
> & xFact
,
88 const OUString
& rPreferredName
);
90 /** Set a property to a certain value in the given map. This works for
91 properties that are already set, and those which are not yet in the map.
93 @param any is the value encapsulated in the variant type Any
95 OOO_DLLPUBLIC_CHARTTOOLS
96 void setPropertyValueAny( tPropertyValueMap
& rOutMap
, tPropertyValueMapKey key
,
97 const css::uno::Any
& rAny
);
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.
102 @param value is the value of type Value that will be put into a variant type
103 Any before set in the property map.
105 template< typename Value
>
106 void setPropertyValue( tPropertyValueMap
& rOutMap
, tPropertyValueMapKey key
, const Value
& value
)
108 setPropertyValueAny( rOutMap
, key
, css::uno::Any( value
));
112 void setPropertyValue
< css::uno::Any
>( tPropertyValueMap
& rOutMap
, tPropertyValueMapKey key
, const css::uno::Any
& rAny
);
114 OOO_DLLPUBLIC_CHARTTOOLS
void setPropertyValueDefaultAny( tPropertyValueMap
& rOutMap
, tPropertyValueMapKey key
, const css::uno::Any
& rAny
);
116 /** Calls setPropertyValue() but asserts that the given property hasn't been set
119 template< typename Value
>
120 void setPropertyValueDefault( tPropertyValueMap
& rOutMap
, tPropertyValueMapKey key
, const Value
& value
)
122 setPropertyValueDefaultAny( rOutMap
, key
, css::uno::Any( value
));
125 /** Calls setPropertyValue() but asserts that the given property hasn't been set
129 void setPropertyValueDefault
< css::uno::Any
>( tPropertyValueMap
& rOutMap
, tPropertyValueMapKey key
, const css::uno::Any
& rAny
);
131 /** Calls setPropertyValueDefault() with an empty Any as value
133 OOO_DLLPUBLIC_CHARTTOOLS
void setEmptyPropertyValueDefault( tPropertyValueMap
& rOutMap
, tPropertyValueMapKey key
);
135 } // namespace PropertyHelper
137 struct OOO_DLLPUBLIC_CHARTTOOLS PropertyNameLess
139 bool operator() ( const css::beans::Property
& first
,
140 const css::beans::Property
& second
)
142 return ( first
.Name
.compareTo( second
.Name
) < 0 );
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */