1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_chart2.hxx"
26 #include "FillProperties.hxx"
27 #include "macros.hxx"
28 #include <com/sun/star/beans/PropertyAttribute.hpp>
29 #include <com/sun/star/drawing/BitmapMode.hpp>
30 #include <com/sun/star/drawing/FillStyle.hpp>
31 #include <com/sun/star/drawing/RectanglePoint.hpp>
32 
33 using namespace ::com::sun::star;
34 
35 using ::com::sun::star::beans::Property;
36 
37 namespace chart
38 {
39 
40 namespace
41 {
42 
lcl_AddPropertiesToVector_without_BitmapProperties(::std::vector<::com::sun::star::beans::Property> & rOutProperties)43 void lcl_AddPropertiesToVector_without_BitmapProperties( ::std::vector< ::com::sun::star::beans::Property > & rOutProperties )
44 {
45     rOutProperties.push_back(
46         Property( C2U( "FillStyle" ),
47                   FillProperties::PROP_FILL_STYLE,
48                   ::getCppuType( reinterpret_cast< const drawing::FillStyle * >(0)),
49                   beans::PropertyAttribute::BOUND
50                   | beans::PropertyAttribute::MAYBEDEFAULT ));
51 
52     rOutProperties.push_back(
53         Property( C2U( "FillColor" ),
54                   FillProperties::PROP_FILL_COLOR,
55                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
56                   beans::PropertyAttribute::BOUND
57                   | beans::PropertyAttribute::MAYBEVOID         // "maybe auto"
58                   | beans::PropertyAttribute::MAYBEDEFAULT ));
59 
60     rOutProperties.push_back(
61         Property( C2U( "FillTransparence" ),
62                   FillProperties::PROP_FILL_TRANSPARENCE,
63                   ::getCppuType( reinterpret_cast< const sal_Int16 * >(0)),
64                   beans::PropertyAttribute::BOUND
65                   | beans::PropertyAttribute::MAYBEDEFAULT ));
66 
67     rOutProperties.push_back(
68         Property( C2U( "FillTransparenceGradientName" ),
69                   FillProperties::PROP_FILL_TRANSPARENCE_GRADIENT_NAME,
70                   ::getCppuType( reinterpret_cast< const ::rtl::OUString * >(0)),
71                   beans::PropertyAttribute::BOUND
72                   | beans::PropertyAttribute::MAYBEVOID
73                   | beans::PropertyAttribute::MAYBEDEFAULT ));
74 
75     //optional
76 //    rOutProperties.push_back(
77 //        Property( C2U( "FillTransparenceGradient" ),
78 //                  FillProperties::PROP_FILL_TRANSPARENCE_GRADIENT,
79 //                  ::getCppuType( reinterpret_cast< const awt::Gradient * >(0)),
80 //                  beans::PropertyAttribute::BOUND
81 //                  | beans::PropertyAttribute::MAYBEDEFAULT
82 //                  | beans::PropertyAttribute::MAYBEVOID ));
83 
84     rOutProperties.push_back(
85         Property( C2U( "FillGradientName" ),
86                   FillProperties::PROP_FILL_GRADIENT_NAME,
87                   ::getCppuType( reinterpret_cast< const ::rtl::OUString * >(0)),
88                   beans::PropertyAttribute::BOUND
89                   | beans::PropertyAttribute::MAYBEVOID
90                   | beans::PropertyAttribute::MAYBEDEFAULT ));
91 
92     rOutProperties.push_back(
93         beans::Property( C2U( "FillGradientStepCount" ),
94                   FillProperties::PROP_FILL_GRADIENT_STEPCOUNT,
95                   ::getCppuType( reinterpret_cast< const sal_Int16 * >(0)),
96                   beans::PropertyAttribute::BOUND
97                   | beans::PropertyAttribute::MAYBEVOID ));
98 
99     //optional
100 //    rOutProperties.push_back(
101 //        Property( C2U( "FillGradient" ),
102 //                  FillProperties::PROP_FILL_GRADIENT,
103 //                  ::getCppuType( reinterpret_cast< const awt::Gradient * >(0)),
104 //                  beans::PropertyAttribute::BOUND
105 //                  | beans::PropertyAttribute::MAYBEDEFAULT
106 //                  | beans::PropertyAttribute::MAYBEVOID ));
107 
108     rOutProperties.push_back(
109         Property( C2U( "FillHatchName" ),
110                   FillProperties::PROP_FILL_HATCH_NAME,
111                   ::getCppuType( reinterpret_cast< const ::rtl::OUString * >(0)),
112                   beans::PropertyAttribute::BOUND
113                   | beans::PropertyAttribute::MAYBEVOID
114                   | beans::PropertyAttribute::MAYBEDEFAULT ));
115 
116     //optional
117 //    rOutProperties.push_back(
118 //        Property( C2U( "FillHatch" ),
119 //                  FillProperties::PROP_FILL_HATCH,
120 //                  ::getCppuType( reinterpret_cast< const drawing::Hatch * >(0)),
121 //                  beans::PropertyAttribute::BOUND
122 //                  | beans::PropertyAttribute::MAYBEDEFAULT
123 //                  | beans::PropertyAttribute::MAYBEVOID ));
124 
125     //bitmap properties see lcl_AddPropertiesToVector_only_BitmapProperties()
126 
127     rOutProperties.push_back(
128         Property( C2U( "FillBackground" ),
129                   FillProperties::PROP_FILL_BACKGROUND,
130                   ::getCppuType( reinterpret_cast< const sal_Bool * >(0)),
131                   beans::PropertyAttribute::BOUND
132                   | beans::PropertyAttribute::MAYBEDEFAULT ));
133 }
134 
lcl_AddPropertiesToVector_only_BitmapProperties(::std::vector<::com::sun::star::beans::Property> & rOutProperties)135 void lcl_AddPropertiesToVector_only_BitmapProperties( ::std::vector< ::com::sun::star::beans::Property > & rOutProperties )
136 {
137     rOutProperties.push_back(
138         Property( C2U( "FillBitmapName" ),
139                   FillProperties::PROP_FILL_BITMAP_NAME,
140                   ::getCppuType( reinterpret_cast< const ::rtl::OUString * >(0)),
141                   beans::PropertyAttribute::BOUND
142                   | beans::PropertyAttribute::MAYBEVOID
143                   | beans::PropertyAttribute::MAYBEDEFAULT ));
144 
145     //optional
146 //    rOutProperties.push_back(
147 //        Property( C2U( "FillBitmap" ),
148 //                  FillProperties::PROP_FILL_BITMAP,
149 //                  ::getCppuType( reinterpret_cast< const uno::Reference< awt::XBitmap > * >(0)),
150 //                  beans::PropertyAttribute::BOUND
151 //                  | beans::PropertyAttribute::MAYBEDEFAULT ));
152 
153     //optional
154 //    rOutProperties.push_back(
155 //        Property( C2U( "FillBitmapURL" ),
156 //                  FillProperties::PROP_FILL_BITMAP_URL,
157 //                  ::getCppuType( reinterpret_cast< const ::rtl::OUString * >(0)),
158 //                  beans::PropertyAttribute::BOUND
159 //                  | beans::PropertyAttribute::MAYBEDEFAULT ));
160 
161     rOutProperties.push_back(
162         Property( C2U( "FillBitmapOffsetX" ),
163                   FillProperties::PROP_FILL_BITMAP_OFFSETX,
164                   ::getCppuType( reinterpret_cast< const sal_Int16 * >(0)),
165                   beans::PropertyAttribute::BOUND
166                   | beans::PropertyAttribute::MAYBEDEFAULT ));
167 
168     rOutProperties.push_back(
169         Property( C2U( "FillBitmapOffsetY" ),
170                   FillProperties::PROP_FILL_BITMAP_OFFSETY,
171                   ::getCppuType( reinterpret_cast< const sal_Int16 * >(0)),
172                   beans::PropertyAttribute::BOUND
173                   | beans::PropertyAttribute::MAYBEDEFAULT ));
174 
175     rOutProperties.push_back(
176         Property( C2U( "FillBitmapPositionOffsetX" ),
177                   FillProperties::PROP_FILL_BITMAP_POSITION_OFFSETX,
178                   ::getCppuType( reinterpret_cast< const sal_Int16 * >(0)),
179                   beans::PropertyAttribute::BOUND
180                   | beans::PropertyAttribute::MAYBEDEFAULT ));
181 
182     rOutProperties.push_back(
183         Property( C2U( "FillBitmapPositionOffsetY" ),
184                   FillProperties::PROP_FILL_BITMAP_POSITION_OFFSETY,
185                   ::getCppuType( reinterpret_cast< const sal_Int16 * >(0)),
186                   beans::PropertyAttribute::BOUND
187                   | beans::PropertyAttribute::MAYBEDEFAULT ));
188 
189 
190     rOutProperties.push_back(
191         Property( C2U( "FillBitmapRectanglePoint" ),
192                   FillProperties::PROP_FILL_BITMAP_RECTANGLEPOINT,
193                   ::getCppuType( reinterpret_cast< const drawing::RectanglePoint * >(0)),
194                   beans::PropertyAttribute::BOUND
195                   | beans::PropertyAttribute::MAYBEDEFAULT ));
196 
197     rOutProperties.push_back(
198         Property( C2U( "FillBitmapLogicalSize" ),
199                   FillProperties::PROP_FILL_BITMAP_LOGICALSIZE,
200                   ::getCppuType( reinterpret_cast< const sal_Bool * >(0)),
201                   beans::PropertyAttribute::BOUND
202                   | beans::PropertyAttribute::MAYBEDEFAULT ));
203 
204     rOutProperties.push_back(
205         Property( C2U( "FillBitmapSizeX" ),
206                   FillProperties::PROP_FILL_BITMAP_SIZEX,
207                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
208                   beans::PropertyAttribute::BOUND
209                   | beans::PropertyAttribute::MAYBEDEFAULT ));
210 
211     rOutProperties.push_back(
212         Property( C2U( "FillBitmapSizeY" ),
213                   FillProperties::PROP_FILL_BITMAP_SIZEY,
214                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
215                   beans::PropertyAttribute::BOUND
216                   | beans::PropertyAttribute::MAYBEDEFAULT ));
217 
218     rOutProperties.push_back(
219         Property( C2U( "FillBitmapMode" ),
220                   FillProperties::PROP_FILL_BITMAP_MODE,
221                   ::getCppuType( reinterpret_cast< const drawing::BitmapMode * >(0)),
222                   beans::PropertyAttribute::BOUND
223                   | beans::PropertyAttribute::MAYBEDEFAULT ));
224 }
225 
226 
lcl_AddDefaultsToMap_without_BitmapProperties(::chart::tPropertyValueMap & rOutMap)227 void lcl_AddDefaultsToMap_without_BitmapProperties(
228     ::chart::tPropertyValueMap & rOutMap )
229 {
230     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_STYLE, drawing::FillStyle_SOLID );
231     ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, FillProperties::PROP_FILL_COLOR, 0xd9d9d9 ); // gray85
232     ::chart::PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, FillProperties::PROP_FILL_TRANSPARENCE, 0 );
233     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BACKGROUND, false );
234 }
235 
lcl_AddDefaultsToMap_only_BitmapProperties(::chart::tPropertyValueMap & rOutMap)236 void lcl_AddDefaultsToMap_only_BitmapProperties(
237     ::chart::tPropertyValueMap & rOutMap )
238 {
239     uno::Any aSalInt16Zero = uno::makeAny( sal_Int16( 0 ));
240     uno::Any aSalInt32SizeDefault = uno::makeAny( sal_Int32( 0 ));
241 
242     ::chart::PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, FillProperties::PROP_FILL_BITMAP_OFFSETX, 0 );
243     ::chart::PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, FillProperties::PROP_FILL_BITMAP_OFFSETY, 0 );
244     ::chart::PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, FillProperties::PROP_FILL_BITMAP_POSITION_OFFSETX, 0 );
245     ::chart::PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, FillProperties::PROP_FILL_BITMAP_POSITION_OFFSETY, 0 );
246 
247     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_RECTANGLEPOINT, drawing::RectanglePoint_MIDDLE_MIDDLE );
248     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_LOGICALSIZE, true );
249     ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, FillProperties::PROP_FILL_BITMAP_SIZEX, 0 );
250     ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, FillProperties::PROP_FILL_BITMAP_SIZEY, 0 );
251     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_MODE, drawing::BitmapMode_REPEAT );
252 }
253 
254 }//end anonymous namespace
255 
AddPropertiesToVector(::std::vector<Property> & rOutProperties)256 void FillProperties::AddPropertiesToVector(
257     ::std::vector< Property > & rOutProperties )
258 {
259     // Fill Properties see service drawing::FillProperties
260     // ---------------
261     lcl_AddPropertiesToVector_without_BitmapProperties( rOutProperties );
262     lcl_AddPropertiesToVector_only_BitmapProperties( rOutProperties );
263 }
264 
AddDefaultsToMap(::chart::tPropertyValueMap & rOutMap)265 void FillProperties::AddDefaultsToMap(
266     ::chart::tPropertyValueMap & rOutMap )
267 {
268     lcl_AddDefaultsToMap_without_BitmapProperties( rOutMap );
269     lcl_AddDefaultsToMap_only_BitmapProperties( rOutMap );
270 }
271 
272 } //  namespace chart
273