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