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 :
20 : #include "oox/drawingml/chart/objectformatter.hxx"
21 :
22 : #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
23 : #include <com/sun/star/util/XNumberFormatTypes.hpp>
24 : #include <osl/thread.h>
25 : #include <rtl/strbuf.hxx>
26 : #include "oox/core/xmlfilterbase.hxx"
27 : #include "oox/drawingml/fillproperties.hxx"
28 : #include "oox/drawingml/lineproperties.hxx"
29 : #include "oox/drawingml/shapepropertymap.hxx"
30 : #include "oox/drawingml/textbody.hxx"
31 : #include "oox/drawingml/textparagraph.hxx"
32 : #include "oox/drawingml/theme.hxx"
33 : #include "oox/drawingml/chart/chartspacemodel.hxx"
34 : #include "oox/helper/modelobjecthelper.hxx"
35 :
36 : namespace oox {
37 : namespace drawingml {
38 : namespace chart {
39 :
40 : // ============================================================================
41 :
42 : using namespace ::com::sun::star::chart2;
43 : using namespace ::com::sun::star::frame;
44 : using namespace ::com::sun::star::graphic;
45 : using namespace ::com::sun::star::lang;
46 : using namespace ::com::sun::star::uno;
47 : using namespace ::com::sun::star::util;
48 :
49 : using ::oox::core::XmlFilterBase;
50 :
51 : // ============================================================================
52 :
53 : namespace {
54 :
55 : struct AutoFormatPatternEntry
56 : {
57 : sal_Int32 mnColorToken; /// Theme color token.
58 : sal_Int32 mnModToken; /// Color modification token.
59 : sal_Int32 mnModValue; /// Color modification value.
60 : };
61 :
62 : #define AUTOFORMAT_PATTERN_COLOR( color_token ) \
63 : { color_token, XML_TOKEN_INVALID, 0 }
64 :
65 : #define AUTOFORMAT_PATTERN_COLORMOD( color_token, mod_token, mod_value ) \
66 : { color_token, mod_token, mod_value }
67 :
68 : #define AUTOFORMAT_PATTERN_END() \
69 : AUTOFORMAT_PATTERN_COLOR( XML_TOKEN_INVALID )
70 :
71 : static const AutoFormatPatternEntry spAutoFormatPattern1[] =
72 : {
73 : AUTOFORMAT_PATTERN_COLORMOD( XML_dk1, XML_tint, 88500 ),
74 : AUTOFORMAT_PATTERN_COLORMOD( XML_dk1, XML_tint, 55000 ),
75 : AUTOFORMAT_PATTERN_COLORMOD( XML_dk1, XML_tint, 78000 ),
76 : AUTOFORMAT_PATTERN_COLORMOD( XML_dk1, XML_tint, 92500 ),
77 : AUTOFORMAT_PATTERN_COLORMOD( XML_dk1, XML_tint, 70000 ),
78 : AUTOFORMAT_PATTERN_COLORMOD( XML_dk1, XML_tint, 30000 ),
79 : AUTOFORMAT_PATTERN_END()
80 : };
81 :
82 : static const AutoFormatPatternEntry spAutoFormatPattern2[] =
83 : {
84 : AUTOFORMAT_PATTERN_COLOR( XML_accent1 ),
85 : AUTOFORMAT_PATTERN_COLOR( XML_accent2 ),
86 : AUTOFORMAT_PATTERN_COLOR( XML_accent3 ),
87 : AUTOFORMAT_PATTERN_COLOR( XML_accent4 ),
88 : AUTOFORMAT_PATTERN_COLOR( XML_accent5 ),
89 : AUTOFORMAT_PATTERN_COLOR( XML_accent6 ),
90 : AUTOFORMAT_PATTERN_END()
91 : };
92 :
93 : static const AutoFormatPatternEntry spAutoFormatPattern3[] =
94 : {
95 : AUTOFORMAT_PATTERN_COLORMOD( XML_accent1, XML_shade, 50000 ),
96 : AUTOFORMAT_PATTERN_COLORMOD( XML_accent2, XML_shade, 50000 ),
97 : AUTOFORMAT_PATTERN_COLORMOD( XML_accent3, XML_shade, 50000 ),
98 : AUTOFORMAT_PATTERN_COLORMOD( XML_accent4, XML_shade, 50000 ),
99 : AUTOFORMAT_PATTERN_COLORMOD( XML_accent5, XML_shade, 50000 ),
100 : AUTOFORMAT_PATTERN_COLORMOD( XML_accent6, XML_shade, 50000 ),
101 : AUTOFORMAT_PATTERN_END()
102 : };
103 :
104 : static const AutoFormatPatternEntry spAutoFormatPattern4[] =
105 : {
106 : AUTOFORMAT_PATTERN_COLORMOD( XML_dk1, XML_tint, 5000 ),
107 : AUTOFORMAT_PATTERN_COLORMOD( XML_dk1, XML_tint, 55000 ),
108 : AUTOFORMAT_PATTERN_COLORMOD( XML_dk1, XML_tint, 78000 ),
109 : AUTOFORMAT_PATTERN_COLORMOD( XML_dk1, XML_tint, 15000 ),
110 : AUTOFORMAT_PATTERN_COLORMOD( XML_dk1, XML_tint, 70000 ),
111 : AUTOFORMAT_PATTERN_COLORMOD( XML_dk1, XML_tint, 30000 ),
112 : AUTOFORMAT_PATTERN_END()
113 : };
114 :
115 : #undef AUTOFORMAT_PATTERN_COLOR
116 : #undef AUTOFORMAT_PATTERN_COLORMOD
117 : #undef AUTOFORMAT_PATTERN_END
118 :
119 : // ----------------------------------------------------------------------------
120 :
121 : struct AutoFormatEntry
122 : {
123 : sal_Int32 mnFirstStyleIdx; /// First chart style index.
124 : sal_Int32 mnLastStyleIdx; /// Last chart style index.
125 : sal_Int32 mnThemedIdx; /// Themed style index.
126 : sal_Int32 mnColorToken; /// Theme color token.
127 : sal_Int32 mnModToken; /// Color modification token.
128 : sal_Int32 mnModValue; /// Color modification value.
129 : sal_Int32 mnRelLineWidth; /// Relative line width (percent).
130 : const AutoFormatPatternEntry* mpPattern;/// Color cycling pattern for data series.
131 : bool mbFadedColor; /// True = Faded color for data series.
132 : };
133 :
134 : #define AUTOFORMAT_COLOR( first, last, themed_style, color_token ) \
135 : { first, last, themed_style, color_token, XML_TOKEN_INVALID, 0, 100, 0, false }
136 :
137 : #define AUTOFORMAT_ACCENTS( first, themed_style ) \
138 : AUTOFORMAT_COLOR( first, first, themed_style, XML_accent1 ), \
139 : AUTOFORMAT_COLOR( first + 1, first + 1, themed_style, XML_accent2 ), \
140 : AUTOFORMAT_COLOR( first + 2, first + 2, themed_style, XML_accent3 ), \
141 : AUTOFORMAT_COLOR( first + 3, first + 3, themed_style, XML_accent4 ), \
142 : AUTOFORMAT_COLOR( first + 4, first + 4, themed_style, XML_accent5 ), \
143 : AUTOFORMAT_COLOR( first + 5, first + 5, themed_style, XML_accent6 )
144 :
145 : #define AUTOFORMAT_COLORMOD( first, last, themed_style, color_token, mod_token, mod_value ) \
146 : { first, last, themed_style, color_token, mod_token, mod_value, 100, 0, false }
147 :
148 : #define AUTOFORMAT_ACCENTSMOD( first, themed_style, mod_token, mod_value ) \
149 : AUTOFORMAT_COLORMOD( first, first, themed_style, XML_accent1, mod_token, mod_value ), \
150 : AUTOFORMAT_COLORMOD( first + 1, first + 1, themed_style, XML_accent2, mod_token, mod_value ), \
151 : AUTOFORMAT_COLORMOD( first + 2, first + 2, themed_style, XML_accent3, mod_token, mod_value ), \
152 : AUTOFORMAT_COLORMOD( first + 3, first + 3, themed_style, XML_accent4, mod_token, mod_value ), \
153 : AUTOFORMAT_COLORMOD( first + 4, first + 4, themed_style, XML_accent5, mod_token, mod_value ), \
154 : AUTOFORMAT_COLORMOD( first + 5, first + 5, themed_style, XML_accent6, mod_token, mod_value )
155 :
156 : #define AUTOFORMAT_PATTERN( first, last, themed_style, line_width, pattern ) \
157 : { first, last, themed_style, XML_TOKEN_INVALID, XML_TOKEN_INVALID, 0, line_width, pattern, false }
158 :
159 : #define AUTOFORMAT_FADED( first, last, themed_style, color_token, line_width ) \
160 : { first, last, themed_style, color_token, XML_TOKEN_INVALID, 0, line_width, 0, true }
161 :
162 : #define AUTOFORMAT_FADEDACCENTS( first, themed_style, line_width ) \
163 : AUTOFORMAT_FADED( first, first, themed_style, XML_accent1, line_width ), \
164 : AUTOFORMAT_FADED( first + 1, first + 1, themed_style, XML_accent2, line_width ), \
165 : AUTOFORMAT_FADED( first + 2, first + 2, themed_style, XML_accent3, line_width ), \
166 : AUTOFORMAT_FADED( first + 3, first + 3, themed_style, XML_accent4, line_width ), \
167 : AUTOFORMAT_FADED( first + 4, first + 4, themed_style, XML_accent5, line_width ), \
168 : AUTOFORMAT_FADED( first + 5, first + 5, themed_style, XML_accent6, line_width )
169 :
170 : #define AUTOFORMAT_INVISIBLE( first, last ) \
171 : AUTOFORMAT_COLOR( first, last, -1, XML_TOKEN_INVALID )
172 :
173 : #define AUTOFORMAT_END() \
174 : AUTOFORMAT_INVISIBLE( -1, -1 )
175 :
176 : static const AutoFormatEntry spNoFormats[] =
177 : {
178 : AUTOFORMAT_INVISIBLE( 1, 48 ),
179 : AUTOFORMAT_END()
180 : };
181 :
182 : static const AutoFormatEntry spDataTableLines[] =
183 : {
184 : AUTOFORMAT_COLORMOD( 1, 32, THEMED_STYLE_SUBTLE, XML_tx1, XML_tint, 75000 ),
185 : AUTOFORMAT_COLORMOD( 33, 40, THEMED_STYLE_SUBTLE, XML_dk1, XML_tint, 75000 ),
186 : // 41...48: no line, same as Chart2
187 : AUTOFORMAT_END()
188 : };
189 :
190 : static const AutoFormatEntry spPlotArea2dFills[] =
191 : {
192 : AUTOFORMAT_COLOR( 1, 32, THEMED_STYLE_SUBTLE, XML_bg1 ),
193 : AUTOFORMAT_COLORMOD( 33, 34, THEMED_STYLE_SUBTLE, XML_dk1, XML_tint, 20000 ),
194 : AUTOFORMAT_ACCENTSMOD( 35, THEMED_STYLE_SUBTLE, XML_tint, 20000 ), // tint not documented!?
195 : AUTOFORMAT_COLORMOD( 41, 48, THEMED_STYLE_SUBTLE, XML_dk1, XML_tint, 95000 ),
196 : AUTOFORMAT_END()
197 : };
198 :
199 : static const AutoFormatEntry spWallFloorLines[] =
200 : {
201 : AUTOFORMAT_COLORMOD( 1, 32, THEMED_STYLE_SUBTLE, XML_tx1, XML_tint, 75000 ),
202 : AUTOFORMAT_COLORMOD( 33, 40, THEMED_STYLE_SUBTLE, XML_dk1, XML_tint, 75000 ),
203 : // 41...48: no line, same as Chart2
204 : AUTOFORMAT_END()
205 : };
206 :
207 : static const AutoFormatEntry spWallFloorFills[] =
208 : {
209 : AUTOFORMAT_INVISIBLE( 1, 32 ),
210 : AUTOFORMAT_COLORMOD( 33, 34, THEMED_STYLE_SUBTLE, XML_dk1, XML_tint, 20000 ),
211 : AUTOFORMAT_ACCENTSMOD( 35, THEMED_STYLE_SUBTLE, XML_tint, 20000 ), // tint not documented!?
212 : AUTOFORMAT_COLORMOD( 41, 48, THEMED_STYLE_SUBTLE, XML_dk1, XML_tint, 95000 ),
213 : AUTOFORMAT_END()
214 : };
215 :
216 : static const AutoFormatEntry spAxisLines[] =
217 : {
218 : AUTOFORMAT_COLORMOD( 1, 32, THEMED_STYLE_SUBTLE, XML_tx1, XML_tint, 75000 ), // tint not documented!?
219 : AUTOFORMAT_COLORMOD( 33, 48, THEMED_STYLE_SUBTLE, XML_dk1, XML_tint, 75000 ), // tint not documented!?
220 : AUTOFORMAT_END()
221 : };
222 :
223 : static const AutoFormatEntry spMajorGridLines[] =
224 : {
225 : AUTOFORMAT_COLORMOD( 1, 32, THEMED_STYLE_SUBTLE, XML_tx1, XML_tint, 75000 ), // tint not documented!?
226 : AUTOFORMAT_COLORMOD( 33, 48, THEMED_STYLE_SUBTLE, XML_dk1, XML_tint, 75000 ), // tint not documented!?
227 : AUTOFORMAT_END()
228 : };
229 :
230 : static const AutoFormatEntry spMinorGridLines[] =
231 : {
232 : AUTOFORMAT_COLORMOD( 1, 40, THEMED_STYLE_SUBTLE, XML_tx1, XML_tint, 50000 ),
233 : AUTOFORMAT_COLORMOD( 41, 48, THEMED_STYLE_SUBTLE, XML_tx1, XML_tint, 90000 ),
234 : AUTOFORMAT_END()
235 : };
236 :
237 : static const AutoFormatEntry spOtherLines[] =
238 : {
239 : AUTOFORMAT_COLOR( 1, 32, THEMED_STYLE_SUBTLE, XML_tx1 ),
240 : AUTOFORMAT_COLOR( 33, 34, THEMED_STYLE_SUBTLE, XML_dk1 ),
241 : AUTOFORMAT_COLORMOD( 35, 40, THEMED_STYLE_SUBTLE, XML_dk1, XML_shade, 25000 ),
242 : AUTOFORMAT_COLOR( 41, 48, THEMED_STYLE_SUBTLE, XML_lt1 ),
243 : AUTOFORMAT_END()
244 : };
245 :
246 : static const AutoFormatEntry spLinearSeriesLines[] =
247 : {
248 : AUTOFORMAT_PATTERN( 1, 1, THEMED_STYLE_SUBTLE, 300, spAutoFormatPattern1 ),
249 : AUTOFORMAT_PATTERN( 2, 2, THEMED_STYLE_SUBTLE, 300, spAutoFormatPattern2 ),
250 : AUTOFORMAT_FADEDACCENTS( 3, THEMED_STYLE_SUBTLE, 300 ),
251 : AUTOFORMAT_PATTERN( 9, 9, THEMED_STYLE_SUBTLE, 500, spAutoFormatPattern1 ),
252 : AUTOFORMAT_PATTERN( 10, 10, THEMED_STYLE_SUBTLE, 500, spAutoFormatPattern2 ),
253 : AUTOFORMAT_FADEDACCENTS( 11, THEMED_STYLE_SUBTLE, 500 ),
254 : AUTOFORMAT_PATTERN( 17, 17, THEMED_STYLE_SUBTLE, 500, spAutoFormatPattern1 ),
255 : AUTOFORMAT_PATTERN( 18, 18, THEMED_STYLE_SUBTLE, 500, spAutoFormatPattern2 ),
256 : AUTOFORMAT_FADEDACCENTS( 19, THEMED_STYLE_SUBTLE, 500 ),
257 : AUTOFORMAT_PATTERN( 25, 25, THEMED_STYLE_SUBTLE, 700, spAutoFormatPattern1 ),
258 : AUTOFORMAT_PATTERN( 26, 26, THEMED_STYLE_SUBTLE, 700, spAutoFormatPattern2 ),
259 : AUTOFORMAT_FADEDACCENTS( 27, THEMED_STYLE_SUBTLE, 700 ),
260 : AUTOFORMAT_PATTERN( 33, 33, THEMED_STYLE_SUBTLE, 500, spAutoFormatPattern1 ),
261 : AUTOFORMAT_PATTERN( 34, 34, THEMED_STYLE_SUBTLE, 500, spAutoFormatPattern2 ),
262 : AUTOFORMAT_FADEDACCENTS( 35, THEMED_STYLE_SUBTLE, 500 ),
263 : AUTOFORMAT_PATTERN( 41, 42, THEMED_STYLE_SUBTLE, 500, spAutoFormatPattern4 ),
264 : AUTOFORMAT_PATTERN( 42, 42, THEMED_STYLE_SUBTLE, 500, spAutoFormatPattern2 ),
265 : AUTOFORMAT_FADEDACCENTS( 43, THEMED_STYLE_SUBTLE, 500 ),
266 : AUTOFORMAT_END()
267 : };
268 :
269 : static const AutoFormatEntry spFilledSeriesLines[] =
270 : {
271 : AUTOFORMAT_INVISIBLE( 1, 8 ),
272 : AUTOFORMAT_COLOR( 9, 16, THEMED_STYLE_SUBTLE, XML_lt1 ),
273 : AUTOFORMAT_INVISIBLE( 17, 32 ),
274 : AUTOFORMAT_COLORMOD( 33, 33, THEMED_STYLE_SUBTLE, XML_dk1, XML_shade, 50000 ),
275 : AUTOFORMAT_PATTERN( 34, 34, THEMED_STYLE_SUBTLE, 100, spAutoFormatPattern3 ),
276 : AUTOFORMAT_ACCENTSMOD( 35, THEMED_STYLE_SUBTLE, XML_shade, 50000 ),
277 : AUTOFORMAT_INVISIBLE( 41, 48 ),
278 : AUTOFORMAT_END()
279 : };
280 :
281 : static const AutoFormatEntry spFilledSeries2dFills[] =
282 : {
283 : AUTOFORMAT_PATTERN( 1, 1, THEMED_STYLE_SUBTLE, 100, spAutoFormatPattern1 ),
284 : AUTOFORMAT_PATTERN( 2, 2, THEMED_STYLE_SUBTLE, 100, spAutoFormatPattern2 ),
285 : AUTOFORMAT_FADEDACCENTS( 3, THEMED_STYLE_SUBTLE, 100 ),
286 : AUTOFORMAT_PATTERN( 9, 9, THEMED_STYLE_SUBTLE, 100, spAutoFormatPattern1 ),
287 : AUTOFORMAT_PATTERN( 10, 10, THEMED_STYLE_SUBTLE, 100, spAutoFormatPattern2 ),
288 : AUTOFORMAT_FADEDACCENTS( 11, THEMED_STYLE_SUBTLE, 100 ),
289 : AUTOFORMAT_PATTERN( 17, 17, THEMED_STYLE_INTENSE, 100, spAutoFormatPattern1 ),
290 : AUTOFORMAT_PATTERN( 18, 18, THEMED_STYLE_INTENSE, 100, spAutoFormatPattern2 ),
291 : AUTOFORMAT_FADEDACCENTS( 19, THEMED_STYLE_INTENSE, 100 ),
292 : AUTOFORMAT_PATTERN( 25, 25, THEMED_STYLE_INTENSE, 100, spAutoFormatPattern1 ),
293 : AUTOFORMAT_PATTERN( 26, 26, THEMED_STYLE_INTENSE, 100, spAutoFormatPattern2 ),
294 : AUTOFORMAT_FADEDACCENTS( 27, THEMED_STYLE_INTENSE, 100 ),
295 : AUTOFORMAT_PATTERN( 33, 33, THEMED_STYLE_SUBTLE, 100, spAutoFormatPattern1 ),
296 : AUTOFORMAT_PATTERN( 34, 34, THEMED_STYLE_SUBTLE, 100, spAutoFormatPattern2 ),
297 : AUTOFORMAT_FADEDACCENTS( 35, THEMED_STYLE_SUBTLE, 100 ),
298 : AUTOFORMAT_PATTERN( 41, 42, THEMED_STYLE_INTENSE, 100, spAutoFormatPattern4 ),
299 : AUTOFORMAT_PATTERN( 42, 42, THEMED_STYLE_INTENSE, 100, spAutoFormatPattern2 ),
300 : AUTOFORMAT_FADEDACCENTS( 43, THEMED_STYLE_INTENSE, 100 ),
301 : AUTOFORMAT_END()
302 : };
303 :
304 : static const AutoFormatEntry spFilledSeries3dFills[] =
305 : {
306 : AUTOFORMAT_PATTERN( 1, 1, THEMED_STYLE_SUBTLE, 100, spAutoFormatPattern1 ),
307 : AUTOFORMAT_PATTERN( 2, 2, THEMED_STYLE_SUBTLE, 100, spAutoFormatPattern2 ),
308 : AUTOFORMAT_FADEDACCENTS( 3, THEMED_STYLE_SUBTLE, 100 ),
309 : AUTOFORMAT_PATTERN( 9, 9, THEMED_STYLE_SUBTLE, 100, spAutoFormatPattern1 ),
310 : AUTOFORMAT_PATTERN( 10, 10, THEMED_STYLE_SUBTLE, 100, spAutoFormatPattern2 ),
311 : AUTOFORMAT_FADEDACCENTS( 11, THEMED_STYLE_SUBTLE, 100 ),
312 : AUTOFORMAT_PATTERN( 17, 17, THEMED_STYLE_SUBTLE, 100, spAutoFormatPattern1 ),
313 : AUTOFORMAT_PATTERN( 18, 18, THEMED_STYLE_INTENSE, 100, spAutoFormatPattern2 ),
314 : AUTOFORMAT_FADEDACCENTS( 19, THEMED_STYLE_SUBTLE, 100 ),
315 : AUTOFORMAT_PATTERN( 25, 25, THEMED_STYLE_SUBTLE, 100, spAutoFormatPattern1 ),
316 : AUTOFORMAT_PATTERN( 26, 26, THEMED_STYLE_INTENSE, 100, spAutoFormatPattern2 ),
317 : AUTOFORMAT_FADEDACCENTS( 27, THEMED_STYLE_SUBTLE, 100 ),
318 : AUTOFORMAT_PATTERN( 33, 33, THEMED_STYLE_SUBTLE, 100, spAutoFormatPattern1 ),
319 : AUTOFORMAT_PATTERN( 34, 34, THEMED_STYLE_SUBTLE, 100, spAutoFormatPattern2 ),
320 : AUTOFORMAT_FADEDACCENTS( 35, THEMED_STYLE_SUBTLE, 100 ),
321 : AUTOFORMAT_PATTERN( 41, 42, THEMED_STYLE_SUBTLE, 100, spAutoFormatPattern4 ),
322 : AUTOFORMAT_PATTERN( 42, 42, THEMED_STYLE_INTENSE, 100, spAutoFormatPattern2 ),
323 : AUTOFORMAT_FADEDACCENTS( 43, THEMED_STYLE_SUBTLE, 100 ),
324 : AUTOFORMAT_END()
325 : };
326 :
327 : static const AutoFormatEntry spFilledSeriesEffects[] =
328 : {
329 : // 1...8: no effect, same as Chart2
330 : AUTOFORMAT_COLOR( 9, 16, THEMED_STYLE_SUBTLE, XML_dk1 ),
331 : AUTOFORMAT_COLOR( 17, 24, THEMED_STYLE_MODERATE, XML_dk1 ),
332 : AUTOFORMAT_COLOR( 25, 32, THEMED_STYLE_INTENSE, XML_dk1 ),
333 : // 33...40: no effect, same as Chart2
334 : AUTOFORMAT_COLOR( 41, 48, THEMED_STYLE_INTENSE, XML_dk1 ),
335 : AUTOFORMAT_END()
336 : };
337 :
338 : static const AutoFormatEntry spUpDownBarLines[] =
339 : {
340 : AUTOFORMAT_COLOR( 1, 16, THEMED_STYLE_SUBTLE, XML_tx1 ),
341 : AUTOFORMAT_INVISIBLE( 17, 32 ),
342 : AUTOFORMAT_COLOR( 33, 34, THEMED_STYLE_SUBTLE, XML_dk1 ),
343 : AUTOFORMAT_ACCENTSMOD( 35, THEMED_STYLE_SUBTLE, XML_shade, 25000 ),
344 : AUTOFORMAT_INVISIBLE( 41, 48 ),
345 : AUTOFORMAT_END()
346 : };
347 :
348 : static const AutoFormatEntry spUpBarFills[] =
349 : {
350 : AUTOFORMAT_COLORMOD( 1, 1, THEMED_STYLE_SUBTLE, XML_dk1, XML_tint, 25000 ),
351 : AUTOFORMAT_COLORMOD( 2, 2, THEMED_STYLE_SUBTLE, XML_dk1, XML_tint, 5000 ),
352 : AUTOFORMAT_ACCENTSMOD( 3, THEMED_STYLE_SUBTLE, XML_tint, 25000 ),
353 : AUTOFORMAT_COLORMOD( 9, 9, THEMED_STYLE_SUBTLE, XML_dk1, XML_tint, 25000 ),
354 : AUTOFORMAT_COLORMOD( 10, 10, THEMED_STYLE_SUBTLE, XML_dk1, XML_tint, 5000 ),
355 : AUTOFORMAT_ACCENTSMOD( 11, THEMED_STYLE_SUBTLE, XML_tint, 25000 ),
356 : AUTOFORMAT_COLORMOD( 17, 17, THEMED_STYLE_INTENSE, XML_dk1, XML_tint, 25000 ),
357 : AUTOFORMAT_COLORMOD( 18, 18, THEMED_STYLE_INTENSE, XML_dk1, XML_tint, 5000 ),
358 : AUTOFORMAT_ACCENTSMOD( 19, THEMED_STYLE_INTENSE, XML_tint, 25000 ),
359 : AUTOFORMAT_COLORMOD( 25, 25, THEMED_STYLE_INTENSE, XML_dk1, XML_tint, 25000 ),
360 : AUTOFORMAT_COLORMOD( 26, 26, THEMED_STYLE_INTENSE, XML_dk1, XML_tint, 5000 ),
361 : AUTOFORMAT_ACCENTSMOD( 27, THEMED_STYLE_INTENSE, XML_tint, 25000 ),
362 : AUTOFORMAT_COLOR( 33, 40, THEMED_STYLE_SUBTLE, XML_lt1 ),
363 : AUTOFORMAT_COLORMOD( 41, 41, THEMED_STYLE_INTENSE, XML_dk1, XML_tint, 25000 ),
364 : AUTOFORMAT_COLOR( 42, 42, THEMED_STYLE_INTENSE, XML_lt1 ),
365 : AUTOFORMAT_ACCENTSMOD( 43, THEMED_STYLE_INTENSE, XML_tint, 25000 ),
366 : AUTOFORMAT_END()
367 : };
368 :
369 : static const AutoFormatEntry spDownBarFills[] =
370 : {
371 : AUTOFORMAT_COLORMOD( 1, 1, THEMED_STYLE_SUBTLE, XML_dk1, XML_tint, 85000 ),
372 : AUTOFORMAT_COLORMOD( 2, 2, THEMED_STYLE_SUBTLE, XML_dk1, XML_tint, 95000 ),
373 : AUTOFORMAT_ACCENTSMOD( 3, THEMED_STYLE_SUBTLE, XML_shade, 25000 ),
374 : AUTOFORMAT_COLORMOD( 9, 9, THEMED_STYLE_SUBTLE, XML_dk1, XML_tint, 85000 ),
375 : AUTOFORMAT_COLORMOD( 10, 10, THEMED_STYLE_SUBTLE, XML_dk1, XML_tint, 95000 ),
376 : AUTOFORMAT_ACCENTSMOD( 11, THEMED_STYLE_SUBTLE, XML_shade, 25000 ),
377 : AUTOFORMAT_COLORMOD( 17, 17, THEMED_STYLE_INTENSE, XML_dk1, XML_tint, 85000 ),
378 : AUTOFORMAT_COLORMOD( 18, 18, THEMED_STYLE_INTENSE, XML_dk1, XML_tint, 95000 ),
379 : AUTOFORMAT_ACCENTSMOD( 19, THEMED_STYLE_INTENSE, XML_shade, 25000 ),
380 : AUTOFORMAT_COLORMOD( 25, 25, THEMED_STYLE_INTENSE, XML_dk1, XML_tint, 85000 ),
381 : AUTOFORMAT_COLORMOD( 26, 26, THEMED_STYLE_INTENSE, XML_dk1, XML_tint, 95000 ),
382 : AUTOFORMAT_ACCENTSMOD( 27, THEMED_STYLE_INTENSE, XML_shade, 25000 ),
383 : AUTOFORMAT_COLORMOD( 33, 33, THEMED_STYLE_SUBTLE, XML_dk1, XML_tint, 85000 ),
384 : AUTOFORMAT_COLORMOD( 34, 34, THEMED_STYLE_SUBTLE, XML_dk1, XML_tint, 95000 ),
385 : AUTOFORMAT_ACCENTSMOD( 27, THEMED_STYLE_SUBTLE, XML_shade, 25000 ),
386 : AUTOFORMAT_COLORMOD( 41, 41, THEMED_STYLE_INTENSE, XML_dk1, XML_tint, 85000 ),
387 : AUTOFORMAT_COLOR( 42, 42, THEMED_STYLE_INTENSE, XML_dk1 ),
388 : AUTOFORMAT_ACCENTSMOD( 43, THEMED_STYLE_INTENSE, XML_shade, 25000 ),
389 : AUTOFORMAT_END()
390 : };
391 :
392 : static const AutoFormatEntry spUpDownBarEffects[] =
393 : {
394 : // 1...8: no effect, same as Chart2
395 : AUTOFORMAT_COLOR( 9, 16, THEMED_STYLE_SUBTLE, XML_dk1 ),
396 : AUTOFORMAT_COLOR( 17, 24, THEMED_STYLE_MODERATE, XML_dk1 ),
397 : AUTOFORMAT_COLOR( 25, 32, THEMED_STYLE_INTENSE, XML_dk1 ),
398 : // 33...40: no effect, same as Chart2
399 : AUTOFORMAT_COLOR( 41, 48, THEMED_STYLE_INTENSE, XML_dk1 ),
400 : AUTOFORMAT_END()
401 : };
402 :
403 : #undef AUTOFORMAT_COLOR
404 : #undef AUTOFORMAT_ACCENTS
405 : #undef AUTOFORMAT_COLORMOD
406 : #undef AUTOFORMAT_ACCENTSMOD
407 : #undef AUTOFORMAT_PATTERN
408 : #undef AUTOFORMAT_FADED
409 : #undef AUTOFORMAT_FADEDACCENTS
410 : #undef AUTOFORMAT_INVISIBLE
411 : #undef AUTOFORMAT_END
412 :
413 0 : const AutoFormatEntry* lclGetAutoFormatEntry( const AutoFormatEntry* pEntries, sal_Int32 nStyle )
414 : {
415 0 : for( ; pEntries && (pEntries->mnFirstStyleIdx >= 0); ++pEntries )
416 0 : if( (pEntries->mnFirstStyleIdx <= nStyle) && (nStyle <= pEntries->mnLastStyleIdx) )
417 0 : return pEntries;
418 0 : return 0;
419 : }
420 :
421 : // ----------------------------------------------------------------------------
422 :
423 : struct AutoTextEntry
424 : {
425 : sal_Int32 mnFirstStyleIdx; /// First chart style index.
426 : sal_Int32 mnLastStyleIdx; /// Last chart style index.
427 : sal_Int32 mnThemedFont; /// Themed font (minor/major).
428 : sal_Int32 mnColorToken; /// Theme color token.
429 : sal_Int32 mnDefFontSize; /// Default font size (1/100 points).
430 : sal_Int32 mnRelFontSize; /// Font size relative to chart global font (percent).
431 : bool mbBold; /// True = bold font.
432 : };
433 :
434 : #define AUTOTEXT_COLOR( first, last, themed_font, color_token, def_font_size, rel_font_size, bold ) \
435 : { first, last, themed_font, color_token, def_font_size, rel_font_size, bold }
436 :
437 : #define AUTOTEXT_END() \
438 : AUTOTEXT_COLOR( -1, -1, XML_none, XML_TOKEN_INVALID, 1000, 100, false )
439 :
440 : static const AutoTextEntry spChartTitleTexts[] =
441 : {
442 : AUTOTEXT_COLOR( 1, 40, XML_minor, XML_tx1, 1800, 120, true ),
443 : AUTOTEXT_COLOR( 41, 48, XML_minor, XML_lt1, 1800, 120, true ),
444 : AUTOTEXT_END()
445 : };
446 :
447 : static const AutoTextEntry spAxisTitleTexts[] =
448 : {
449 : AUTOTEXT_COLOR( 1, 40, XML_minor, XML_tx1, 1000, 100, true ),
450 : AUTOTEXT_COLOR( 41, 48, XML_minor, XML_lt1, 1000, 100, true ),
451 : AUTOTEXT_END()
452 : };
453 :
454 : static const AutoTextEntry spOtherTexts[] =
455 : {
456 : AUTOTEXT_COLOR( 1, 40, XML_minor, XML_tx1, 1000, 100, false ),
457 : AUTOTEXT_COLOR( 41, 48, XML_minor, XML_lt1, 1000, 100, false ),
458 : AUTOTEXT_END()
459 : };
460 :
461 : #undef AUTOTEXT_COLOR
462 : #undef AUTOTEXT_END
463 :
464 0 : const AutoTextEntry* lclGetAutoTextEntry( const AutoTextEntry* pEntries, sal_Int32 nStyle )
465 : {
466 0 : for( ; pEntries && (pEntries->mnFirstStyleIdx >= 0); ++pEntries )
467 0 : if( (pEntries->mnFirstStyleIdx <= nStyle) && (nStyle <= pEntries->mnLastStyleIdx) )
468 0 : return pEntries;
469 0 : return 0;
470 : }
471 :
472 : // ----------------------------------------------------------------------------
473 :
474 : /** Property identifiers for common chart objects, to be used in ShapePropertyInfo. */
475 : static const sal_Int32 spnCommonPropIds[] =
476 : {
477 : PROP_LineStyle, PROP_LineWidth, PROP_LineColor, PROP_LineTransparence, PROP_LineDashName,
478 : PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID,
479 : PROP_FillStyle, PROP_FillColor, PROP_FillTransparence, PROP_FillGradientName,
480 : PROP_FillBitmapName, PROP_FillBitmapMode, PROP_FillBitmapSizeX, PROP_FillBitmapSizeY,
481 : PROP_FillBitmapPositionOffsetX, PROP_FillBitmapPositionOffsetY, PROP_FillBitmapRectanglePoint
482 : };
483 :
484 : /** Property identifiers for linear data series, to be used in ShapePropertyInfo. */
485 : static const sal_Int32 spnLinearPropIds[] =
486 : {
487 : PROP_LineStyle, PROP_LineWidth, PROP_Color, PROP_Transparency, PROP_LineDashName,
488 : PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID,
489 : PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID,
490 : PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID,
491 : PROP_INVALID, PROP_INVALID, PROP_INVALID
492 : };
493 :
494 : /** Property identifiers for filled data series, to be used in ShapePropertyInfo. */
495 : static const sal_Int32 spnFilledPropIds[] =
496 : {
497 : PROP_BorderStyle, PROP_BorderWidth, PROP_BorderColor, PROP_BorderTransparency, PROP_BorderDashName,
498 : PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID,
499 : PROP_FillStyle, PROP_Color, PROP_Transparency, PROP_GradientName,
500 : PROP_FillBitmapName, PROP_FillBitmapMode, PROP_FillBitmapSizeX, PROP_FillBitmapSizeY,
501 : PROP_FillBitmapPositionOffsetX, PROP_FillBitmapPositionOffsetY, PROP_FillBitmapRectanglePoint
502 : };
503 :
504 : /** Property info for common chart objects, to be used in ShapePropertyMap. */
505 17 : static const ShapePropertyInfo saCommonPropInfo( spnCommonPropIds, false, true, true, true );
506 : /** Property info for linear data series, to be used in ShapePropertyMap. */
507 17 : static const ShapePropertyInfo saLinearPropInfo( spnLinearPropIds, false, true, true, true );
508 : /** Property info for filled data series, to be used in ShapePropertyMap. */
509 17 : static const ShapePropertyInfo saFilledPropInfo( spnFilledPropIds, false, true, true, true );
510 :
511 : // ----------------------------------------------------------------------------
512 :
513 : /** Contains information about formatting of a specific chart object type. */
514 : struct ObjectTypeFormatEntry
515 : {
516 : ObjectType meObjType; /// Object type for automatic format.
517 : const ShapePropertyInfo* mpPropInfo; /// Property info for the ShapePropertyMap class.
518 : const AutoFormatEntry* mpAutoLines; /// Automatic line formatting for all chart styles.
519 : const AutoFormatEntry* mpAutoFills; /// Automatic fill formatting for all chart styles.
520 : const AutoFormatEntry* mpAutoEffects; /// Automatic effect formatting for all chart styles.
521 : const AutoTextEntry* mpAutoTexts; /// Automatic text attributes for all chart styles.
522 : bool mbIsFrame; /// True = object is a frame, false = object is a line.
523 : };
524 :
525 : #define TYPEFORMAT_FRAME( obj_type, prop_type, auto_texts, auto_lines, auto_fills, auto_effects ) \
526 : { obj_type, prop_type, auto_lines, auto_fills, auto_effects, auto_texts, true }
527 :
528 : #define TYPEFORMAT_LINE( obj_type, prop_type, auto_texts, auto_lines ) \
529 : { obj_type, prop_type, auto_lines, 0, 0, auto_texts, false }
530 :
531 : static const ObjectTypeFormatEntry spObjTypeFormatEntries[] =
532 : {
533 : // object type property info auto text auto line auto fill auto effect
534 : TYPEFORMAT_FRAME( OBJECTTYPE_CHARTSPACE, &saCommonPropInfo, 0, spNoFormats, spNoFormats, 0 /* eq to Ch2 */ ),
535 : TYPEFORMAT_FRAME( OBJECTTYPE_CHARTTITLE, &saCommonPropInfo, spChartTitleTexts, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */ ),
536 : TYPEFORMAT_FRAME( OBJECTTYPE_LEGEND, &saCommonPropInfo, spOtherTexts, spNoFormats, spNoFormats, 0 /* eq to Ch2 */ ),
537 : TYPEFORMAT_FRAME( OBJECTTYPE_PLOTAREA2D, &saCommonPropInfo, 0, 0 /* eq to Ch2 */, spPlotArea2dFills, 0 /* eq to Ch2 */ ),
538 : TYPEFORMAT_FRAME( OBJECTTYPE_PLOTAREA3D, &saCommonPropInfo, 0, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */ ),
539 : TYPEFORMAT_FRAME( OBJECTTYPE_WALL, &saCommonPropInfo, 0, spWallFloorLines, spWallFloorFills, 0 /* eq to Ch2 */ ),
540 : TYPEFORMAT_FRAME( OBJECTTYPE_FLOOR, &saCommonPropInfo, 0, spWallFloorLines, spWallFloorFills, 0 /* eq to Ch2 */ ),
541 : TYPEFORMAT_LINE( OBJECTTYPE_AXIS, &saCommonPropInfo, spOtherTexts, spAxisLines ),
542 : TYPEFORMAT_FRAME( OBJECTTYPE_AXISTITLE, &saCommonPropInfo, spAxisTitleTexts, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */ ),
543 : TYPEFORMAT_FRAME( OBJECTTYPE_AXISUNIT, &saCommonPropInfo, spAxisTitleTexts, 0 /* eq in Ch2 */, 0 /* eq in Ch2 */, 0 /* eq in Ch2 */ ),
544 : TYPEFORMAT_LINE( OBJECTTYPE_MAJORGRIDLINE, &saCommonPropInfo, 0, spMajorGridLines ),
545 : TYPEFORMAT_LINE( OBJECTTYPE_MINORGRIDLINE, &saCommonPropInfo, 0, spMinorGridLines ),
546 : TYPEFORMAT_LINE( OBJECTTYPE_LINEARSERIES2D, &saLinearPropInfo, 0, spLinearSeriesLines ),
547 : TYPEFORMAT_FRAME( OBJECTTYPE_FILLEDSERIES2D, &saFilledPropInfo, 0, spFilledSeriesLines, spFilledSeries2dFills, spFilledSeriesEffects ),
548 : TYPEFORMAT_FRAME( OBJECTTYPE_FILLEDSERIES3D, &saFilledPropInfo, 0, spFilledSeriesLines, spFilledSeries3dFills, spFilledSeriesEffects ),
549 : TYPEFORMAT_FRAME( OBJECTTYPE_DATALABEL, &saCommonPropInfo, spOtherTexts, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */ ),
550 : TYPEFORMAT_LINE( OBJECTTYPE_TRENDLINE, &saCommonPropInfo, 0, spOtherLines ),
551 : TYPEFORMAT_FRAME( OBJECTTYPE_TRENDLINELABEL, &saCommonPropInfo, spOtherTexts, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */ ),
552 : TYPEFORMAT_LINE( OBJECTTYPE_ERRORBAR, &saCommonPropInfo, 0, spOtherLines ),
553 : TYPEFORMAT_LINE( OBJECTTYPE_SERLINE, &saCommonPropInfo, 0, spOtherLines ),
554 : TYPEFORMAT_LINE( OBJECTTYPE_LEADERLINE, &saCommonPropInfo, 0, spOtherLines ),
555 : TYPEFORMAT_LINE( OBJECTTYPE_DROPLINE, &saCommonPropInfo, 0, spOtherLines ),
556 : TYPEFORMAT_LINE( OBJECTTYPE_HILOLINE, &saLinearPropInfo, 0, spOtherLines ),
557 : TYPEFORMAT_FRAME( OBJECTTYPE_UPBAR, &saCommonPropInfo, 0, spUpDownBarLines, spUpBarFills, spUpDownBarEffects ),
558 : TYPEFORMAT_FRAME( OBJECTTYPE_DOWNBAR, &saCommonPropInfo, 0, spUpDownBarLines, spDownBarFills, spUpDownBarEffects ),
559 : TYPEFORMAT_LINE( OBJECTTYPE_DATATABLE, &saCommonPropInfo, spOtherTexts, spDataTableLines )
560 : };
561 :
562 : #undef TYPEFORMAT_FRAME
563 : #undef TYPEFORMAT_LINE
564 :
565 : // ----------------------------------------------------------------------------
566 :
567 0 : void lclConvertPictureOptions( FillProperties& orFillProps, const PictureOptionsModel& rPicOptions )
568 : {
569 0 : bool bStacked = (rPicOptions.mnPictureFormat == XML_stack) || (rPicOptions.mnPictureFormat == XML_stackScale);
570 0 : orFillProps.maBlipProps.moBitmapMode = bStacked ? XML_tile : XML_stretch;
571 0 : }
572 :
573 : } // namespace
574 :
575 : // ============================================================================
576 :
577 : struct ObjectFormatterData;
578 :
579 : // ----------------------------------------------------------------------------
580 :
581 0 : class DetailFormatterBase
582 : {
583 : public:
584 : explicit DetailFormatterBase(
585 : ObjectFormatterData& rData,
586 : const AutoFormatEntry* pAutoFormatEntry );
587 : explicit DetailFormatterBase(
588 : ObjectFormatterData& rData,
589 : const AutoTextEntry* pAutoTextEntry );
590 :
591 : protected:
592 : /** Returns the placeholder color which may depend on the passed series index. */
593 : sal_Int32 getPhColor( sal_Int32 nSeriesIdx ) const;
594 :
595 : private:
596 : /** Resolves and returns the scheme color with the passed transformation. */
597 : sal_Int32 getSchemeColor( sal_Int32 nColorToken, sal_Int32 nModToken, sal_Int32 nModValue ) const;
598 :
599 : protected:
600 : typedef ::std::vector< sal_Int32 > ColorPatternVec;
601 :
602 : ObjectFormatterData& mrData; /// Shared formatter data.
603 : sal_Int32 mnPhClr; /// RGB placeholder color for themed style.
604 : ColorPatternVec maColorPattern; /// Different cycling colors for data series.
605 : };
606 :
607 : // ----------------------------------------------------------------------------
608 :
609 0 : class LineFormatter : public DetailFormatterBase
610 : {
611 : public:
612 : explicit LineFormatter(
613 : ObjectFormatterData& rData,
614 : const AutoFormatEntry* pAutoFormatEntry );
615 :
616 : /** Converts line formatting to the passed property set. */
617 : void convertFormatting(
618 : ShapePropertyMap& rPropMap,
619 : const ModelRef< Shape >& rxShapeProp,
620 : sal_Int32 nSeriesIdx );
621 :
622 : private:
623 : LinePropertiesPtr mxAutoLine; /// Automatic line properties.
624 : };
625 :
626 : // ----------------------------------------------------------------------------
627 :
628 0 : class FillFormatter : public DetailFormatterBase
629 : {
630 : public:
631 : explicit FillFormatter(
632 : ObjectFormatterData& rData,
633 : const AutoFormatEntry* pAutoFormatEntry );
634 :
635 : /** Converts area formatting to the passed property set. */
636 : void convertFormatting(
637 : ShapePropertyMap& rPropMap,
638 : const ModelRef< Shape >& rxShapeProp,
639 : const PictureOptionsModel* pPicOptions,
640 : sal_Int32 nSeriesIdx );
641 :
642 : private:
643 : FillPropertiesPtr mxAutoFill; /// Automatic fill properties.
644 : };
645 :
646 : // ----------------------------------------------------------------------------
647 :
648 0 : class EffectFormatter : public DetailFormatterBase
649 : {
650 : public:
651 : explicit EffectFormatter(
652 : ObjectFormatterData& rData,
653 : const AutoFormatEntry* pAutoFormatEntry );
654 :
655 : /** Converts effect formatting to the passed property set. */
656 : void convertFormatting(
657 : ShapePropertyMap& rPropMap,
658 : const ModelRef< Shape >& rxShapeProp,
659 : sal_Int32 nSeriesIdx ) const;
660 : };
661 :
662 : // ----------------------------------------------------------------------------
663 :
664 0 : class TextFormatter : public DetailFormatterBase
665 : {
666 : public:
667 : explicit TextFormatter(
668 : ObjectFormatterData& rData,
669 : const AutoTextEntry* pAutoTextEntry,
670 : const ModelRef< TextBody >& rxGlobalTextProp );
671 :
672 : /** Converts text formatting to the passed property set. */
673 : void convertFormatting(
674 : PropertySet& rPropSet,
675 : const TextCharacterProperties* pTextProps );
676 : /** Converts text formatting to the passed property set. */
677 : void convertFormatting(
678 : PropertySet& rPropSet,
679 : const ModelRef< TextBody >& rxTextProp );
680 :
681 : private:
682 : TextCharacterPropertiesPtr mxAutoText; /// Automatic text properties.
683 : };
684 :
685 : // ----------------------------------------------------------------------------
686 :
687 : /** Formatter for a specific object type. */
688 0 : class ObjectTypeFormatter
689 : {
690 : public:
691 : explicit ObjectTypeFormatter(
692 : ObjectFormatterData& rData,
693 : const ObjectTypeFormatEntry& rEntry,
694 : const ChartSpaceModel& rChartSpace );
695 :
696 : /** Sets frame formatting properties to the passed property set. */
697 : void convertFrameFormatting(
698 : PropertySet& rPropSet,
699 : const ModelRef< Shape >& rxShapeProp,
700 : const PictureOptionsModel* pPicOptions,
701 : sal_Int32 nSeriesIdx );
702 :
703 : /** Sets text formatting properties to the passed property set. */
704 : void convertTextFormatting(
705 : PropertySet& rPropSet,
706 : const ModelRef< TextBody >& rxTextProp );
707 :
708 : /** Sets frame/text formatting properties to the passed property set. */
709 : void convertFormatting(
710 : PropertySet& rPropSet,
711 : const ModelRef< Shape >& rxShapeProp,
712 : const ModelRef< TextBody >& rxTextProp );
713 :
714 : /** Sets text formatting properties to the passed property set. */
715 : void convertTextFormatting(
716 : PropertySet& rPropSet,
717 : const TextCharacterProperties& rTextProps );
718 :
719 : /** Sets automatic fill properties to the passed property set. */
720 : void convertAutomaticFill(
721 : PropertySet& rPropSet,
722 : sal_Int32 nSeriesIdx );
723 :
724 : private:
725 : LineFormatter maLineFormatter; /// Converter for line formatting.
726 : FillFormatter maFillFormatter; /// Converter for fill formatting.
727 : EffectFormatter maEffectFormatter; /// Converter for effect formatting.
728 : TextFormatter maTextFormatter; /// Converter for text formatting.
729 : ModelObjectHelper& mrModelObjHelper; /// Helper for named drawing formatting.
730 : const ObjectTypeFormatEntry& mrEntry; /// Additional settings.
731 : };
732 :
733 : // ----------------------------------------------------------------------------
734 :
735 0 : struct ObjectFormatterData
736 : {
737 : typedef RefMap< ObjectType, ObjectTypeFormatter > ObjectTypeFormatterMap;
738 :
739 : const XmlFilterBase& mrFilter; /// Base filter object.
740 : ObjectTypeFormatterMap maTypeFormatters; /// Formatters for all types of objects in a chart.
741 : ModelObjectHelper maModelObjHelper; /// Helper for named drawing formatting (dashes, gradients, bitmaps).
742 : Reference< XNumberFormats > mxNumFmts; /// Number formats collection of container document.
743 : Reference< XNumberFormatTypes > mxNumTypes; /// Number format types collection of container document.
744 : Locale maEnUsLocale; /// Locale struct containing en-US.
745 : Locale maFromLocale; /// Empty locale struct.
746 : sal_Int32 mnMaxSeriesIdx; /// Maximum series index used for color cycling/fading.
747 :
748 : explicit ObjectFormatterData(
749 : const XmlFilterBase& rFilter,
750 : const Reference< XChartDocument >& rxChartDoc,
751 : const ChartSpaceModel& rChartSpace );
752 :
753 : ObjectTypeFormatter* getTypeFormatter( ObjectType eObjType );
754 : };
755 :
756 : // ============================================================================
757 :
758 0 : DetailFormatterBase::DetailFormatterBase( ObjectFormatterData& rData, const AutoFormatEntry* pAutoFormatEntry ) :
759 : mrData( rData ),
760 0 : mnPhClr( -1 )
761 : {
762 0 : if( pAutoFormatEntry )
763 : {
764 0 : if( pAutoFormatEntry->mpPattern )
765 : {
766 : // prepare multi-color pattern
767 0 : for( const AutoFormatPatternEntry* pPatternEntry = pAutoFormatEntry->mpPattern; pPatternEntry->mnColorToken != XML_TOKEN_INVALID; ++pPatternEntry )
768 0 : maColorPattern.push_back( getSchemeColor( pPatternEntry->mnColorToken, pPatternEntry->mnModToken, pPatternEntry->mnModValue ) );
769 : }
770 0 : else if( pAutoFormatEntry->mnColorToken != XML_TOKEN_INVALID )
771 : {
772 : // prepare color or single-color pattern (color fading)
773 0 : mnPhClr = getSchemeColor( pAutoFormatEntry->mnColorToken, pAutoFormatEntry->mnModToken, pAutoFormatEntry->mnModValue );
774 0 : if( pAutoFormatEntry->mbFadedColor )
775 0 : maColorPattern.push_back( mnPhClr );
776 : }
777 : }
778 0 : }
779 :
780 0 : DetailFormatterBase::DetailFormatterBase( ObjectFormatterData& rData, const AutoTextEntry* pAutoTextEntry ) :
781 : mrData( rData ),
782 0 : mnPhClr( -1 )
783 : {
784 0 : if( pAutoTextEntry && (pAutoTextEntry->mnColorToken != XML_TOKEN_INVALID) )
785 0 : mnPhClr = getSchemeColor( pAutoTextEntry->mnColorToken, XML_TOKEN_INVALID, 0 );
786 0 : }
787 :
788 0 : sal_Int32 DetailFormatterBase::getPhColor( sal_Int32 nSeriesIdx ) const
789 : {
790 0 : if( maColorPattern.empty() || (mrData.mnMaxSeriesIdx < 0) || (nSeriesIdx < 0) )
791 0 : return mnPhClr;
792 :
793 : /* Apply tint/shade depending on the cycle index. The colors of leading
794 : series are darkened (color shade), the colors of trailing series are
795 : lightened (color tint). Shade/tint is applied in an exclusive range of
796 : -70% to 70%.
797 :
798 : Example 1: 3 data series using single-color shading with accent color 1
799 : (e.g. automatic chart style #3). Shade/tint is applied per series.
800 : Shade/tint changes in steps of 140%/(<series_count+1) = 140%/4 = 35%,
801 : starting at -70%:
802 : Step 1: -70% -> Not used.
803 : Step 2: -35% -> Series 1 has 35% shade of accent color 1.
804 : Step 3: 0% -> Series 2 has pure accent color 1.
805 : Step 4: 35% -> Series 3 has 35% tint of accent color 1.
806 : Step 5: 70% -> Not used.
807 :
808 : Example 2: 20 data series using accent color pattern (e.g. automatic
809 : chart style #2). Each color cycle has a size of 6 series (accent colors
810 : 1 to 6). Shade/tint is applied per color cycle.
811 : Cycle #1: Series 1...6 are based on accent colors 1 to 6.
812 : Cycle #2: Series 7...12 are based on accent colors 1 to 6.
813 : Cycle #3: Series 13...18 are based on accent colors 1 to 6.
814 : Cycle #4: Series 19...20 are based on accent colors 1 to 2.
815 : Shade/tint changes in steps of 140%/(cycle_count+1) = 140%/5 = 28%,
816 : starting at -70%:
817 : Step 1: -70% -> Not used.
818 : Step 2: -42% -> Cycle #1 has 42% shade of accent colors 1...6
819 : step 3: -14% -> Cycle #2 has 14% shade of accent colors 1...6
820 : step 4: 14% -> Cycle #3 has 14% tint of accent colors 1...6
821 : step 5: 42% -> Cycle #4 has 42% tint of accent colors 1...6
822 : step 6: 70% -> Not used.
823 : */
824 0 : sal_Int32 nPhClr = maColorPattern[ static_cast< size_t >( nSeriesIdx % maColorPattern.size() ) ];
825 0 : size_t nCycleIdx = static_cast< size_t >( nSeriesIdx / maColorPattern.size() );
826 0 : size_t nMaxCycleIdx = static_cast< size_t >( mrData.mnMaxSeriesIdx / maColorPattern.size() );
827 0 : double fShadeTint = static_cast< double >( nCycleIdx + 1 ) / (nMaxCycleIdx + 2) * 1.4 - 0.7;
828 0 : if( fShadeTint != 0.0 )
829 : {
830 0 : Color aColor;
831 0 : aColor.setSrgbClr( nPhClr );
832 0 : aColor.addChartTintTransformation( fShadeTint );
833 0 : nPhClr = aColor.getColor( mrData.mrFilter.getGraphicHelper() );
834 : }
835 :
836 0 : return nPhClr;
837 : }
838 :
839 0 : sal_Int32 DetailFormatterBase::getSchemeColor( sal_Int32 nColorToken, sal_Int32 nModToken, sal_Int32 nModValue ) const
840 : {
841 0 : Color aColor;
842 0 : aColor.setSchemeClr( nColorToken );
843 0 : if( nModToken != XML_TOKEN_INVALID )
844 0 : aColor.addTransformation( nModToken, nModValue );
845 0 : return aColor.getColor( mrData.mrFilter.getGraphicHelper() );
846 : }
847 :
848 : // ============================================================================
849 :
850 0 : LineFormatter::LineFormatter( ObjectFormatterData& rData, const AutoFormatEntry* pAutoFormatEntry ) :
851 0 : DetailFormatterBase( rData, pAutoFormatEntry )
852 : {
853 0 : if( pAutoFormatEntry )
854 : {
855 0 : mxAutoLine.reset( new LineProperties );
856 0 : mxAutoLine->maLineFill.moFillType = XML_noFill;
857 0 : if( const Theme* pTheme = mrData.mrFilter.getCurrentTheme() )
858 0 : if( const LineProperties* pLineProps = pTheme->getLineStyle( pAutoFormatEntry->mnThemedIdx ) )
859 0 : *mxAutoLine = *pLineProps;
860 : // change line width according to chart auto style
861 0 : if( mxAutoLine->moLineWidth.has() )
862 0 : mxAutoLine->moLineWidth = mxAutoLine->moLineWidth.get() * pAutoFormatEntry->mnRelLineWidth / 100;
863 : }
864 0 : }
865 :
866 0 : void LineFormatter::convertFormatting( ShapePropertyMap& rPropMap, const ModelRef< Shape >& rxShapeProp, sal_Int32 nSeriesIdx )
867 : {
868 0 : LineProperties aLineProps;
869 0 : if( mxAutoLine.get() )
870 0 : aLineProps.assignUsed( *mxAutoLine );
871 0 : if( rxShapeProp.is() )
872 0 : aLineProps.assignUsed( rxShapeProp->getLineProperties() );
873 0 : aLineProps.pushToPropMap( rPropMap, mrData.mrFilter.getGraphicHelper(), getPhColor( nSeriesIdx ) );
874 0 : }
875 :
876 : // ============================================================================
877 :
878 0 : FillFormatter::FillFormatter( ObjectFormatterData& rData, const AutoFormatEntry* pAutoFormatEntry ) :
879 0 : DetailFormatterBase( rData, pAutoFormatEntry )
880 : {
881 0 : if( pAutoFormatEntry )
882 : {
883 0 : mxAutoFill.reset( new FillProperties );
884 0 : mxAutoFill->moFillType = XML_noFill;
885 0 : if( const Theme* pTheme = mrData.mrFilter.getCurrentTheme() )
886 0 : if( const FillProperties* pFillProps = pTheme->getFillStyle( pAutoFormatEntry->mnThemedIdx ) )
887 0 : *mxAutoFill = *pFillProps;
888 : }
889 0 : }
890 :
891 0 : void FillFormatter::convertFormatting( ShapePropertyMap& rPropMap, const ModelRef< Shape >& rxShapeProp, const PictureOptionsModel* pPicOptions, sal_Int32 nSeriesIdx )
892 : {
893 0 : FillProperties aFillProps;
894 0 : if( mxAutoFill.get() )
895 0 : aFillProps.assignUsed( *mxAutoFill );
896 0 : if( rxShapeProp.is() )
897 0 : aFillProps.assignUsed( rxShapeProp->getFillProperties() );
898 0 : if( pPicOptions )
899 0 : lclConvertPictureOptions( aFillProps, *pPicOptions );
900 0 : aFillProps.pushToPropMap( rPropMap, mrData.mrFilter.getGraphicHelper(), 0, getPhColor( nSeriesIdx ) );
901 0 : }
902 :
903 : // ============================================================================
904 :
905 0 : EffectFormatter::EffectFormatter( ObjectFormatterData& rData, const AutoFormatEntry* pAutoFormatEntry ) :
906 0 : DetailFormatterBase( rData, pAutoFormatEntry )
907 : {
908 0 : }
909 : //TODO :
910 0 : void EffectFormatter::convertFormatting( ShapePropertyMap& /*rPropMap*/, const ModelRef< Shape >& /*rxShapeProp*/, sal_Int32 /*nSeriesIdx*/ ) const
911 : {
912 0 : }
913 :
914 : // ============================================================================
915 :
916 : namespace {
917 :
918 0 : const TextCharacterProperties* lclGetTextProperties( const ModelRef< TextBody >& rxTextProp )
919 : {
920 0 : return (rxTextProp.is() && !rxTextProp->getParagraphs().empty()) ?
921 0 : &rxTextProp->getParagraphs().front()->getProperties().getTextCharacterProperties() : 0;
922 : }
923 :
924 : } // namespace
925 :
926 0 : TextFormatter::TextFormatter( ObjectFormatterData& rData, const AutoTextEntry* pAutoTextEntry, const ModelRef< TextBody >& rxGlobalTextProp ) :
927 0 : DetailFormatterBase( rData, pAutoTextEntry )
928 : {
929 0 : if( pAutoTextEntry )
930 : {
931 0 : mxAutoText.reset( new TextCharacterProperties );
932 0 : if( const Theme* pTheme = mrData.mrFilter.getCurrentTheme() )
933 0 : if( const TextCharacterProperties* pTextProps = pTheme->getFontStyle( pAutoTextEntry->mnThemedFont ) )
934 0 : *mxAutoText = *pTextProps;
935 0 : sal_Int32 nTextColor = getPhColor( -1 );
936 0 : if( nTextColor >= 0 )
937 0 : mxAutoText->maCharColor.setSrgbClr( nTextColor );
938 0 : mxAutoText->moHeight = pAutoTextEntry->mnDefFontSize;
939 0 : mxAutoText->moBold = pAutoTextEntry->mbBold;
940 :
941 0 : if( const TextCharacterProperties* pTextProps = lclGetTextProperties( rxGlobalTextProp ) )
942 : {
943 0 : mxAutoText->assignUsed( *pTextProps );
944 0 : if( pTextProps->moHeight.has() )
945 0 : mxAutoText->moHeight = pTextProps->moHeight.get() * pAutoTextEntry->mnRelFontSize / 100;
946 : }
947 : }
948 0 : }
949 :
950 0 : void TextFormatter::convertFormatting( PropertySet& rPropSet, const TextCharacterProperties* pTextProps )
951 : {
952 0 : TextCharacterProperties aTextProps;
953 0 : if( mxAutoText.get() )
954 0 : aTextProps.assignUsed( *mxAutoText );
955 0 : if( pTextProps )
956 0 : aTextProps.assignUsed( *pTextProps );
957 0 : aTextProps.pushToPropSet( rPropSet, mrData.mrFilter );
958 0 : }
959 :
960 0 : void TextFormatter::convertFormatting( PropertySet& rPropSet, const ModelRef< TextBody >& rxTextProp )
961 : {
962 0 : convertFormatting( rPropSet, lclGetTextProperties( rxTextProp ) );
963 0 : }
964 :
965 : // ============================================================================
966 :
967 0 : ObjectTypeFormatter::ObjectTypeFormatter( ObjectFormatterData& rData, const ObjectTypeFormatEntry& rEntry, const ChartSpaceModel& rChartSpace ) :
968 : maLineFormatter( rData, lclGetAutoFormatEntry( rEntry.mpAutoLines, rChartSpace.mnStyle ) ),
969 : maFillFormatter( rData, lclGetAutoFormatEntry( rEntry.mpAutoFills, rChartSpace.mnStyle ) ),
970 : maEffectFormatter( rData, lclGetAutoFormatEntry( rEntry.mpAutoEffects, rChartSpace.mnStyle ) ),
971 : maTextFormatter( rData, lclGetAutoTextEntry( rEntry.mpAutoTexts, rChartSpace.mnStyle ), rChartSpace.mxTextProp ),
972 : mrModelObjHelper( rData.maModelObjHelper ),
973 0 : mrEntry( rEntry )
974 : {
975 0 : }
976 :
977 0 : void ObjectTypeFormatter::convertFrameFormatting( PropertySet& rPropSet, const ModelRef< Shape >& rxShapeProp, const PictureOptionsModel* pPicOptions, sal_Int32 nSeriesIdx )
978 : {
979 0 : ShapePropertyMap aPropMap( mrModelObjHelper, *mrEntry.mpPropInfo );
980 0 : maLineFormatter.convertFormatting( aPropMap, rxShapeProp, nSeriesIdx );
981 0 : if( mrEntry.mbIsFrame )
982 0 : maFillFormatter.convertFormatting( aPropMap, rxShapeProp, pPicOptions, nSeriesIdx );
983 0 : maEffectFormatter.convertFormatting( aPropMap, rxShapeProp, nSeriesIdx );
984 0 : rPropSet.setProperties( aPropMap );
985 0 : }
986 :
987 0 : void ObjectTypeFormatter::convertTextFormatting( PropertySet& rPropSet, const ModelRef< TextBody >& rxTextProp )
988 : {
989 0 : maTextFormatter.convertFormatting( rPropSet, rxTextProp );
990 0 : }
991 :
992 0 : void ObjectTypeFormatter::convertFormatting( PropertySet& rPropSet, const ModelRef< Shape >& rxShapeProp, const ModelRef< TextBody >& rxTextProp )
993 : {
994 0 : convertFrameFormatting( rPropSet, rxShapeProp, 0, -1 );
995 0 : convertTextFormatting( rPropSet, rxTextProp );
996 0 : }
997 :
998 0 : void ObjectTypeFormatter::convertTextFormatting( PropertySet& rPropSet, const TextCharacterProperties& rTextProps )
999 : {
1000 0 : maTextFormatter.convertFormatting( rPropSet, &rTextProps );
1001 0 : }
1002 :
1003 0 : void ObjectTypeFormatter::convertAutomaticFill( PropertySet& rPropSet, sal_Int32 nSeriesIdx )
1004 : {
1005 0 : ShapePropertyMap aPropMap( mrModelObjHelper, *mrEntry.mpPropInfo );
1006 0 : ModelRef< Shape > xShapeProp;
1007 0 : maFillFormatter.convertFormatting( aPropMap, xShapeProp, 0, nSeriesIdx );
1008 0 : maEffectFormatter.convertFormatting( aPropMap, xShapeProp, nSeriesIdx );
1009 0 : rPropSet.setProperties( aPropMap );
1010 0 : }
1011 :
1012 : // ============================================================================
1013 :
1014 0 : ObjectFormatterData::ObjectFormatterData( const XmlFilterBase& rFilter, const Reference< XChartDocument >& rxChartDoc, const ChartSpaceModel& rChartSpace ) :
1015 : mrFilter( rFilter ),
1016 : maModelObjHelper( Reference< XMultiServiceFactory >( rxChartDoc, UNO_QUERY ) ),
1017 : maEnUsLocale( CREATE_OUSTRING( "en" ), CREATE_OUSTRING( "US" ), OUString() ),
1018 0 : mnMaxSeriesIdx( -1 )
1019 : {
1020 0 : const ObjectTypeFormatEntry* pEntryEnd = STATIC_ARRAY_END( spObjTypeFormatEntries );
1021 0 : for( const ObjectTypeFormatEntry* pEntry = spObjTypeFormatEntries; pEntry != pEntryEnd; ++pEntry )
1022 0 : maTypeFormatters[ pEntry->meObjType ].reset( new ObjectTypeFormatter( *this, *pEntry, rChartSpace ) );
1023 :
1024 : try
1025 : {
1026 0 : Reference< XNumberFormatsSupplier > xNumFmtsSupp( rxChartDoc, UNO_QUERY_THROW );
1027 0 : mxNumFmts = xNumFmtsSupp->getNumberFormats();
1028 0 : mxNumTypes.set( mxNumFmts, UNO_QUERY );
1029 : }
1030 0 : catch( Exception& )
1031 : {
1032 : }
1033 : OSL_ENSURE( mxNumFmts.is() && mxNumTypes.is(), "ObjectFormatterData::ObjectFormatterData - cannot get number formats" );
1034 0 : }
1035 :
1036 0 : ObjectTypeFormatter* ObjectFormatterData::getTypeFormatter( ObjectType eObjType )
1037 : {
1038 : OSL_ENSURE( maTypeFormatters.has( eObjType ), "ObjectFormatterData::getTypeFormatter - unknown object type" );
1039 0 : return maTypeFormatters.get( eObjType ).get();
1040 : }
1041 :
1042 : // ============================================================================
1043 :
1044 0 : ObjectFormatter::ObjectFormatter( const XmlFilterBase& rFilter, const Reference< XChartDocument >& rxChartDoc, const ChartSpaceModel& rChartSpace ) :
1045 0 : mxData( new ObjectFormatterData( rFilter, rxChartDoc, rChartSpace ) )
1046 : {
1047 0 : }
1048 :
1049 0 : ObjectFormatter::~ObjectFormatter()
1050 : {
1051 0 : }
1052 :
1053 0 : void ObjectFormatter::setMaxSeriesIndex( sal_Int32 nMaxSeriesIdx )
1054 : {
1055 0 : mxData->mnMaxSeriesIdx = nMaxSeriesIdx;
1056 0 : }
1057 :
1058 0 : sal_Int32 ObjectFormatter::getMaxSeriesIndex() const
1059 : {
1060 0 : return mxData->mnMaxSeriesIdx;
1061 : }
1062 :
1063 0 : void ObjectFormatter::convertFrameFormatting( PropertySet& rPropSet, const ModelRef< Shape >& rxShapeProp, ObjectType eObjType, sal_Int32 nSeriesIdx )
1064 : {
1065 0 : if( ObjectTypeFormatter* pFormat = mxData->getTypeFormatter( eObjType ) )
1066 0 : pFormat->convertFrameFormatting( rPropSet, rxShapeProp, 0, nSeriesIdx );
1067 0 : }
1068 :
1069 0 : void ObjectFormatter::convertFrameFormatting( PropertySet& rPropSet, const ModelRef< Shape >& rxShapeProp, const PictureOptionsModel& rPicOptions, ObjectType eObjType, sal_Int32 nSeriesIdx )
1070 : {
1071 0 : if( ObjectTypeFormatter* pFormat = mxData->getTypeFormatter( eObjType ) )
1072 0 : pFormat->convertFrameFormatting( rPropSet, rxShapeProp, &rPicOptions, nSeriesIdx );
1073 0 : }
1074 :
1075 0 : void ObjectFormatter::convertTextFormatting( PropertySet& rPropSet, const ModelRef< TextBody >& rxTextProp, ObjectType eObjType )
1076 : {
1077 0 : if( ObjectTypeFormatter* pFormat = mxData->getTypeFormatter( eObjType ) )
1078 0 : pFormat->convertTextFormatting( rPropSet, rxTextProp );
1079 0 : }
1080 :
1081 0 : void ObjectFormatter::convertFormatting( PropertySet& rPropSet, const ModelRef< Shape >& rxShapeProp, const ModelRef< TextBody >& rxTextProp, ObjectType eObjType )
1082 : {
1083 0 : if( ObjectTypeFormatter* pFormat = mxData->getTypeFormatter( eObjType ) )
1084 0 : pFormat->convertFormatting( rPropSet, rxShapeProp, rxTextProp );
1085 0 : }
1086 :
1087 0 : void ObjectFormatter::convertTextFormatting( PropertySet& rPropSet, const TextCharacterProperties& rTextProps, ObjectType eObjType )
1088 : {
1089 0 : if( ObjectTypeFormatter* pFormat = mxData->getTypeFormatter( eObjType ) )
1090 0 : pFormat->convertTextFormatting( rPropSet, rTextProps );
1091 0 : }
1092 :
1093 0 : void ObjectFormatter::convertTextRotation( PropertySet& rPropSet, const ModelRef< TextBody >& rxTextProp, bool bSupportsStacked )
1094 : {
1095 0 : if( rxTextProp.is() )
1096 : {
1097 0 : bool bStacked = false;
1098 0 : if( bSupportsStacked )
1099 : {
1100 0 : sal_Int32 nVert = rxTextProp->getTextProperties().moVert.get( XML_horz );
1101 0 : bStacked = (nVert == XML_wordArtVert) || (nVert == XML_wordArtVertRtl);
1102 0 : rPropSet.setProperty( PROP_StackCharacters, bStacked );
1103 : }
1104 :
1105 : /* Chart2 expects rotation angle as double value in range of [0,360).
1106 : OOXML counts clockwise, Chart2 counts counterclockwise. */
1107 0 : double fAngle = static_cast< double >( bStacked ? 0 : rxTextProp->getTextProperties().moRotation.get( 0 ) );
1108 0 : fAngle = getDoubleIntervalValue< double >( -fAngle / 60000.0, 0.0, 360.0 );
1109 0 : rPropSet.setProperty( PROP_TextRotation, fAngle );
1110 : }
1111 0 : }
1112 :
1113 0 : void ObjectFormatter::convertNumberFormat( PropertySet& rPropSet, const NumberFormat& rNumberFormat, bool bPercentFormat )
1114 : {
1115 0 : if( mxData->mxNumFmts.is() )
1116 : {
1117 0 : sal_Int32 nPropId = bPercentFormat ? PROP_PercentageNumberFormat : PROP_NumberFormat;
1118 0 : if( rNumberFormat.mbSourceLinked || rNumberFormat.maFormatCode.isEmpty() )
1119 : {
1120 0 : rPropSet.setAnyProperty( nPropId, Any() );
1121 : }
1122 : else try
1123 : {
1124 0 : sal_Int32 nIndex = rNumberFormat.maFormatCode.equalsIgnoreAsciiCase("general") ?
1125 0 : mxData->mxNumTypes->getStandardIndex( mxData->maFromLocale ) :
1126 0 : mxData->mxNumFmts->addNewConverted( rNumberFormat.maFormatCode, mxData->maEnUsLocale, mxData->maFromLocale );
1127 0 : if( nIndex >= 0 )
1128 0 : rPropSet.setProperty( nPropId, nIndex );
1129 : }
1130 0 : catch( Exception& )
1131 : {
1132 : OSL_FAIL( OStringBuffer( "ObjectFormatter::convertNumberFormat - cannot create number format '" ).
1133 : append( OUStringToOString( rNumberFormat.maFormatCode, osl_getThreadTextEncoding() ) ).append( '\'' ).getStr() );
1134 : }
1135 : }
1136 0 : }
1137 :
1138 0 : void ObjectFormatter::convertAutomaticFill( PropertySet& rPropSet, ObjectType eObjType, sal_Int32 nSeriesIdx )
1139 : {
1140 0 : if( ObjectTypeFormatter* pFormat = mxData->getTypeFormatter( eObjType ) )
1141 0 : pFormat->convertAutomaticFill( rPropSet, nSeriesIdx );
1142 0 : }
1143 :
1144 0 : /*static*/ bool ObjectFormatter::isAutomaticFill( const ModelRef< Shape >& rxShapeProp )
1145 : {
1146 0 : return !rxShapeProp || !rxShapeProp->getFillProperties().moFillType.has();
1147 : }
1148 :
1149 : // ============================================================================
1150 :
1151 : } // namespace chart
1152 : } // namespace drawingml
1153 51 : } // namespace oox
1154 :
1155 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|