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