1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
27 #ifndef CHART_PROPERTYHELPER_HXX
28 #define CHART_PROPERTYHELPER_HXX
30 #include <com/sun/star/beans/XPropertySet.hpp>
31 #include <com/sun/star/beans/Property.hpp>
32 #include <com/sun/star/beans/PropertyValue.hpp>
33 #include <com/sun/star/uno/Any.hxx>
34 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
35 #include <comphelper/property.hxx>
37 #include "charttoolsdllapi.hxx"
42 typedef int tPropertyValueMapKey
;
44 typedef ::std::map
< tPropertyValueMapKey
, ::com::sun::star::uno::Any
>
47 namespace PropertyHelper
50 /** adds a line dash with a unique name to the gradient obtained by the given
53 @return The name used for storing this element in the table
55 OOO_DLLPUBLIC_CHARTTOOLS ::rtl::OUString
addLineDashUniqueNameToTable(
56 const ::com::sun::star::uno::Any
& rValue
,
57 const ::com::sun::star::uno::Reference
<
58 ::com::sun::star::lang::XMultiServiceFactory
> & xFact
,
59 const ::rtl::OUString
& rPreferredName
);
61 /** adds a gradient with a unique name to the gradient obtained by the given
64 @return The name used for storing this element in the table
66 OOO_DLLPUBLIC_CHARTTOOLS ::rtl::OUString
addGradientUniqueNameToTable(
67 const ::com::sun::star::uno::Any
& rValue
,
68 const ::com::sun::star::uno::Reference
<
69 ::com::sun::star::lang::XMultiServiceFactory
> & xFact
,
70 const ::rtl::OUString
& rPreferredName
);
72 /** adds a transparency gradient with a unique name to the gradient obtained
75 @return The name used for storing this element in the table
77 OOO_DLLPUBLIC_CHARTTOOLS
78 ::rtl::OUString
addTransparencyGradientUniqueNameToTable(
79 const ::com::sun::star::uno::Any
& rValue
,
80 const ::com::sun::star::uno::Reference
<
81 ::com::sun::star::lang::XMultiServiceFactory
> & xFact
,
82 const ::rtl::OUString
& rPreferredName
);
84 /** adds a hatch with a unique name to the gradient obtained by the given
87 @return The name used for storing this element in the table
89 OOO_DLLPUBLIC_CHARTTOOLS ::rtl::OUString
addHatchUniqueNameToTable(
90 const ::com::sun::star::uno::Any
& rValue
,
91 const ::com::sun::star::uno::Reference
<
92 ::com::sun::star::lang::XMultiServiceFactory
> & xFact
,
93 const ::rtl::OUString
& rPreferredName
);
95 /** adds a bitmap with a unique name to the gradient obtained by the given
98 @return The name used for storing this element in the table
100 OOO_DLLPUBLIC_CHARTTOOLS ::rtl::OUString
addBitmapUniqueNameToTable(
101 const ::com::sun::star::uno::Any
& rValue
,
102 const ::com::sun::star::uno::Reference
<
103 ::com::sun::star::lang::XMultiServiceFactory
> & xFact
,
104 const ::rtl::OUString
& rPreferredName
);
106 // --------------------------------------------------------------------------------
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.
111 @param any is the value encapsulated in the variant type Any
113 OOO_DLLPUBLIC_CHARTTOOLS
114 void setPropertyValueAny( tPropertyValueMap
& rOutMap
, tPropertyValueMapKey key
,
115 const ::com::sun::star::uno::Any
& rAny
);
117 /** Set a property to a certain value in the given map. This works for
118 properties that are already set, and those which are not yet in the map.
120 @param value is the value of type Value that will be put into a variant type
121 Any before set in the property map.
123 template< typename Value
>
124 void setPropertyValue( tPropertyValueMap
& rOutMap
, tPropertyValueMapKey key
, const Value
& value
)
126 setPropertyValueAny( rOutMap
, key
, ::com::sun::star::uno::makeAny( value
));
130 void setPropertyValue
< ::com::sun::star::uno::Any
>( tPropertyValueMap
& rOutMap
, tPropertyValueMapKey key
, const ::com::sun::star::uno::Any
& rAny
);
132 OOO_DLLPUBLIC_CHARTTOOLS
void setPropertyValueDefaultAny( tPropertyValueMap
& rOutMap
, tPropertyValueMapKey key
, const ::com::sun::star::uno::Any
& rAny
);
134 /** Calls setPropertyValue() but asserts that the given property hasn't been set
137 template< typename Value
>
138 void setPropertyValueDefault( tPropertyValueMap
& rOutMap
, tPropertyValueMapKey key
, const Value
& value
)
140 setPropertyValueDefaultAny( rOutMap
, key
, ::com::sun::star::uno::makeAny( value
));
143 /** Calls setPropertyValue() but asserts that the given property hasn't been set
147 void setPropertyValueDefault
< ::com::sun::star::uno::Any
>( tPropertyValueMap
& rOutMap
, tPropertyValueMapKey key
, const ::com::sun::star::uno::Any
& rAny
);
149 /** Calls setPropertyValueDefault() with an empty Any as value
151 OOO_DLLPUBLIC_CHARTTOOLS
void setEmptyPropertyValueDefault( tPropertyValueMap
& rOutMap
, tPropertyValueMapKey key
);
154 } // namespace PropertyHelper
156 // ================================================================================
158 struct OOO_DLLPUBLIC_CHARTTOOLS PropertyNameLess
160 inline bool operator() ( const ::com::sun::star::beans::Property
& first
,
161 const ::com::sun::star::beans::Property
& second
)
163 return ( first
.Name
.compareTo( second
.Name
) < 0 );
167 struct OOO_DLLPUBLIC_CHARTTOOLS PropertyLess
: public ::std::binary_function
<
168 ::com::sun::star::beans::Property
,
169 ::com::sun::star::beans::Property
,
172 bool operator() ( const ::com::sun::star::beans::Property
& rFirst
,
173 const ::com::sun::star::beans::Property
& rSecond
)
175 return ( rFirst
.Name
.compareTo( rSecond
.Name
) < 0 );
179 struct OOO_DLLPUBLIC_CHARTTOOLS PropertyValueNameEquals
: public ::std::unary_function
< ::com::sun::star::beans::PropertyValue
, bool >
181 explicit PropertyValueNameEquals( const ::rtl::OUString
& rName
) :
185 bool operator() ( const ::com::sun::star::beans::PropertyValue
& rPropValue
)
187 return rPropValue
.Name
.equals( m_aName
);
191 ::rtl::OUString m_aName
;
196 // CHART_PROPERTYHELPER_HXX