1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: objectformatter.cxx,v $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 #include "oox/drawingml/chart/objectformatter.hxx"
33 #include <rtl/strbuf.hxx>
34 #include <osl/thread.h>
35 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
36 #include <com/sun/star/util/XNumberFormatTypes.hpp>
37 #include "properties.hxx"
39 #include "oox/helper/modelobjecthelper.hxx"
40 #include "oox/core/xmlfilterbase.hxx"
41 #include "oox/drawingml/fillproperties.hxx"
42 #include "oox/drawingml/lineproperties.hxx"
43 #include "oox/drawingml/textbody.hxx"
44 #include "oox/drawingml/textparagraph.hxx"
45 #include "oox/drawingml/theme.hxx"
46 #include "oox/drawingml/chart/chartspacemodel.hxx"
48 using ::rtl::OStringBuffer
;
49 using ::rtl::OUString
;
50 using ::rtl::OUStringToOString
;
51 using ::com::sun::star::uno::Any
;
52 using ::com::sun::star::uno::Reference
;
53 using ::com::sun::star::uno::Exception
;
54 using ::com::sun::star::uno::UNO_QUERY
;
55 using ::com::sun::star::uno::UNO_QUERY_THROW
;
56 using ::com::sun::star::lang::Locale
;
57 using ::com::sun::star::lang::XMultiServiceFactory
;
58 using ::com::sun::star::frame::XModel
;
59 using ::com::sun::star::chart2::XChartDocument
;
60 using ::com::sun::star::graphic::XGraphic
;
61 using ::com::sun::star::util::XNumberFormats
;
62 using ::com::sun::star::util::XNumberFormatsSupplier
;
63 using ::com::sun::star::util::XNumberFormatTypes
;
64 using ::oox::core::XmlFilterBase
;
70 // ============================================================================
74 struct AutoFormatPatternEntry
76 sal_Int32 mnColorToken
; /// Theme color token.
77 sal_Int32 mnModToken
; /// Color modification token.
78 sal_Int32 mnModValue
; /// Color modification value.
81 #define AUTOFORMAT_PATTERN_COLOR( color_token ) \
82 { color_token, XML_TOKEN_INVALID, 0 }
84 #define AUTOFORMAT_PATTERN_COLORMOD( color_token, mod_token, mod_value ) \
85 { color_token, mod_token, mod_value }
87 #define AUTOFORMAT_PATTERN_END() \
88 AUTOFORMAT_PATTERN_COLOR( XML_TOKEN_INVALID )
90 static const AutoFormatPatternEntry spAutoFormatPattern1
[] =
92 AUTOFORMAT_PATTERN_COLORMOD( XML_dk1
, XML_tint
, 88500 ),
93 AUTOFORMAT_PATTERN_COLORMOD( XML_dk1
, XML_tint
, 55000 ),
94 AUTOFORMAT_PATTERN_COLORMOD( XML_dk1
, XML_tint
, 78000 ),
95 AUTOFORMAT_PATTERN_COLORMOD( XML_dk1
, XML_tint
, 92500 ),
96 AUTOFORMAT_PATTERN_COLORMOD( XML_dk1
, XML_tint
, 70000 ),
97 AUTOFORMAT_PATTERN_COLORMOD( XML_dk1
, XML_tint
, 30000 ),
98 AUTOFORMAT_PATTERN_END()
101 static const AutoFormatPatternEntry spAutoFormatPattern2
[] =
103 AUTOFORMAT_PATTERN_COLOR( XML_accent1
),
104 AUTOFORMAT_PATTERN_COLOR( XML_accent2
),
105 AUTOFORMAT_PATTERN_COLOR( XML_accent3
),
106 AUTOFORMAT_PATTERN_COLOR( XML_accent4
),
107 AUTOFORMAT_PATTERN_COLOR( XML_accent5
),
108 AUTOFORMAT_PATTERN_COLOR( XML_accent6
),
109 AUTOFORMAT_PATTERN_END()
112 static const AutoFormatPatternEntry spAutoFormatPattern3
[] =
114 AUTOFORMAT_PATTERN_COLORMOD( XML_accent1
, XML_shade
, 50000 ),
115 AUTOFORMAT_PATTERN_COLORMOD( XML_accent2
, XML_shade
, 50000 ),
116 AUTOFORMAT_PATTERN_COLORMOD( XML_accent3
, XML_shade
, 50000 ),
117 AUTOFORMAT_PATTERN_COLORMOD( XML_accent4
, XML_shade
, 50000 ),
118 AUTOFORMAT_PATTERN_COLORMOD( XML_accent5
, XML_shade
, 50000 ),
119 AUTOFORMAT_PATTERN_COLORMOD( XML_accent6
, XML_shade
, 50000 ),
120 AUTOFORMAT_PATTERN_END()
123 static const AutoFormatPatternEntry spAutoFormatPattern4
[] =
125 AUTOFORMAT_PATTERN_COLORMOD( XML_dk1
, XML_tint
, 5000 ),
126 AUTOFORMAT_PATTERN_COLORMOD( XML_dk1
, XML_tint
, 55000 ),
127 AUTOFORMAT_PATTERN_COLORMOD( XML_dk1
, XML_tint
, 78000 ),
128 AUTOFORMAT_PATTERN_COLORMOD( XML_dk1
, XML_tint
, 15000 ),
129 AUTOFORMAT_PATTERN_COLORMOD( XML_dk1
, XML_tint
, 70000 ),
130 AUTOFORMAT_PATTERN_COLORMOD( XML_dk1
, XML_tint
, 30000 ),
131 AUTOFORMAT_PATTERN_END()
134 #undef AUTOFORMAT_PATTERN_COLOR
135 #undef AUTOFORMAT_PATTERN_COLORMOD
136 #undef AUTOFORMAT_PATTERN_END
138 // ----------------------------------------------------------------------------
140 struct AutoFormatEntry
142 sal_Int32 mnFirstStyleIdx
; /// First chart style index.
143 sal_Int32 mnLastStyleIdx
; /// Last chart style index.
144 sal_Int32 mnThemedIdx
; /// Themed style index.
145 sal_Int32 mnColorToken
; /// Theme color token.
146 sal_Int32 mnModToken
; /// Color modification token.
147 sal_Int32 mnModValue
; /// Color modification value.
148 sal_Int32 mnRelLineWidth
; /// Relative line width (percent).
149 const AutoFormatPatternEntry
* mpPattern
;/// Color cycling pattern for data series.
150 bool mbFadedColor
; /// True = Faded color for data series.
153 #define AUTOFORMAT_COLOR( first, last, themed_style, color_token ) \
154 { first, last, themed_style, color_token, XML_TOKEN_INVALID, 0, 100, 0, false }
156 #define AUTOFORMAT_ACCENTS( first, themed_style ) \
157 AUTOFORMAT_COLOR( first, first, themed_style, XML_accent1 ), \
158 AUTOFORMAT_COLOR( first + 1, first + 1, themed_style, XML_accent2 ), \
159 AUTOFORMAT_COLOR( first + 2, first + 2, themed_style, XML_accent3 ), \
160 AUTOFORMAT_COLOR( first + 3, first + 3, themed_style, XML_accent4 ), \
161 AUTOFORMAT_COLOR( first + 4, first + 4, themed_style, XML_accent5 ), \
162 AUTOFORMAT_COLOR( first + 5, first + 5, themed_style, XML_accent6 )
164 #define AUTOFORMAT_COLORMOD( first, last, themed_style, color_token, mod_token, mod_value ) \
165 { first, last, themed_style, color_token, mod_token, mod_value, 100, 0, false }
167 #define AUTOFORMAT_ACCENTSMOD( first, themed_style, mod_token, mod_value ) \
168 AUTOFORMAT_COLORMOD( first, first, themed_style, XML_accent1, mod_token, mod_value ), \
169 AUTOFORMAT_COLORMOD( first + 1, first + 1, themed_style, XML_accent2, mod_token, mod_value ), \
170 AUTOFORMAT_COLORMOD( first + 2, first + 2, themed_style, XML_accent3, mod_token, mod_value ), \
171 AUTOFORMAT_COLORMOD( first + 3, first + 3, themed_style, XML_accent4, mod_token, mod_value ), \
172 AUTOFORMAT_COLORMOD( first + 4, first + 4, themed_style, XML_accent5, mod_token, mod_value ), \
173 AUTOFORMAT_COLORMOD( first + 5, first + 5, themed_style, XML_accent6, mod_token, mod_value )
175 #define AUTOFORMAT_PATTERN( first, last, themed_style, line_width, pattern ) \
176 { first, last, themed_style, XML_TOKEN_INVALID, XML_TOKEN_INVALID, 0, line_width, pattern, false }
178 #define AUTOFORMAT_FADED( first, last, themed_style, color_token, line_width ) \
179 { first, last, themed_style, color_token, XML_TOKEN_INVALID, 0, line_width, 0, true }
181 #define AUTOFORMAT_FADEDACCENTS( first, themed_style, line_width ) \
182 AUTOFORMAT_FADED( first, first, themed_style, XML_accent1, line_width ), \
183 AUTOFORMAT_FADED( first + 1, first + 1, themed_style, XML_accent2, line_width ), \
184 AUTOFORMAT_FADED( first + 2, first + 2, themed_style, XML_accent3, line_width ), \
185 AUTOFORMAT_FADED( first + 3, first + 3, themed_style, XML_accent4, line_width ), \
186 AUTOFORMAT_FADED( first + 4, first + 4, themed_style, XML_accent5, line_width ), \
187 AUTOFORMAT_FADED( first + 5, first + 5, themed_style, XML_accent6, line_width )
189 #define AUTOFORMAT_INVISIBLE( first, last ) \
190 AUTOFORMAT_COLOR( first, last, -1, XML_TOKEN_INVALID )
192 #define AUTOFORMAT_END() \
193 AUTOFORMAT_INVISIBLE( -1, -1 )
195 static const AutoFormatEntry spNoFormats
[] =
197 AUTOFORMAT_INVISIBLE( 1, 48 ),
201 static const AutoFormatEntry spChartSpaceLines
[] =
203 AUTOFORMAT_COLORMOD( 1, 32, THEMED_STYLE_SUBTLE
, XML_tx1
, XML_tint
, 75000 ),
204 AUTOFORMAT_COLORMOD( 33, 40, THEMED_STYLE_SUBTLE
, XML_dk1
, XML_tint
, 75000 ),
205 // 41...48: no line, same as Chart2
209 static const AutoFormatEntry spChartSpaceFills
[] =
211 AUTOFORMAT_COLOR( 1, 32, THEMED_STYLE_SUBTLE
, XML_bg1
),
212 AUTOFORMAT_COLOR( 33, 40, THEMED_STYLE_SUBTLE
, XML_lt1
),
213 AUTOFORMAT_COLOR( 41, 48, THEMED_STYLE_SUBTLE
, XML_dk1
),
217 static const AutoFormatEntry spPlotArea2dFills
[] =
219 AUTOFORMAT_COLOR( 1, 32, THEMED_STYLE_SUBTLE
, XML_bg1
),
220 AUTOFORMAT_COLORMOD( 33, 34, THEMED_STYLE_SUBTLE
, XML_dk1
, XML_tint
, 20000 ),
221 AUTOFORMAT_ACCENTSMOD( 35, THEMED_STYLE_SUBTLE
, XML_tint
, 20000 ), // tint not documented!?
222 AUTOFORMAT_COLORMOD( 41, 48, THEMED_STYLE_SUBTLE
, XML_dk1
, XML_tint
, 95000 ),
226 static const AutoFormatEntry spFloorLines
[] =
228 AUTOFORMAT_COLORMOD( 1, 32, THEMED_STYLE_SUBTLE
, XML_tx1
, XML_tint
, 75000 ),
229 AUTOFORMAT_COLORMOD( 33, 40, THEMED_STYLE_SUBTLE
, XML_dk1
, XML_tint
, 75000 ),
230 // 41...48: no line, same as Chart2
234 static const AutoFormatEntry spWallFloorFills
[] =
236 AUTOFORMAT_INVISIBLE( 1, 32 ),
237 AUTOFORMAT_COLORMOD( 33, 34, THEMED_STYLE_SUBTLE
, XML_dk1
, XML_tint
, 20000 ),
238 AUTOFORMAT_ACCENTSMOD( 35, THEMED_STYLE_SUBTLE
, XML_tint
, 20000 ), // tint not documented!?
239 AUTOFORMAT_COLORMOD( 41, 48, THEMED_STYLE_SUBTLE
, XML_dk1
, XML_tint
, 95000 ),
243 static const AutoFormatEntry spAxisLines
[] =
245 AUTOFORMAT_COLORMOD( 1, 32, THEMED_STYLE_SUBTLE
, XML_tx1
, XML_tint
, 75000 ), // tint not documented!?
246 AUTOFORMAT_COLORMOD( 33, 48, THEMED_STYLE_SUBTLE
, XML_dk1
, XML_tint
, 75000 ), // tint not documented!?
250 static const AutoFormatEntry spMajorGridLines
[] =
252 AUTOFORMAT_COLORMOD( 1, 32, THEMED_STYLE_SUBTLE
, XML_tx1
, XML_tint
, 75000 ), // tint not documented!?
253 AUTOFORMAT_COLORMOD( 33, 48, THEMED_STYLE_SUBTLE
, XML_dk1
, XML_tint
, 75000 ), // tint not documented!?
257 static const AutoFormatEntry spMinorGridLines
[] =
259 AUTOFORMAT_COLORMOD( 1, 40, THEMED_STYLE_SUBTLE
, XML_tx1
, XML_tint
, 50000 ),
260 AUTOFORMAT_COLORMOD( 41, 48, THEMED_STYLE_SUBTLE
, XML_tx1
, XML_tint
, 90000 ),
264 static const AutoFormatEntry spOtherLines
[] =
266 AUTOFORMAT_COLOR( 1, 32, THEMED_STYLE_SUBTLE
, XML_tx1
),
267 AUTOFORMAT_COLOR( 33, 34, THEMED_STYLE_SUBTLE
, XML_dk1
),
268 AUTOFORMAT_COLORMOD( 35, 40, THEMED_STYLE_SUBTLE
, XML_dk1
, XML_shade
, 25000 ),
269 AUTOFORMAT_COLOR( 41, 48, THEMED_STYLE_SUBTLE
, XML_lt1
),
273 static const AutoFormatEntry spLinearSeriesLines
[] =
275 AUTOFORMAT_PATTERN( 1, 1, THEMED_STYLE_SUBTLE
, 300, spAutoFormatPattern1
),
276 AUTOFORMAT_PATTERN( 2, 2, THEMED_STYLE_SUBTLE
, 300, spAutoFormatPattern2
),
277 AUTOFORMAT_FADEDACCENTS( 3, THEMED_STYLE_SUBTLE
, 300 ),
278 AUTOFORMAT_PATTERN( 9, 9, THEMED_STYLE_SUBTLE
, 500, spAutoFormatPattern1
),
279 AUTOFORMAT_PATTERN( 10, 10, THEMED_STYLE_SUBTLE
, 500, spAutoFormatPattern2
),
280 AUTOFORMAT_FADEDACCENTS( 11, THEMED_STYLE_SUBTLE
, 500 ),
281 AUTOFORMAT_PATTERN( 17, 17, THEMED_STYLE_SUBTLE
, 500, spAutoFormatPattern1
),
282 AUTOFORMAT_PATTERN( 18, 18, THEMED_STYLE_SUBTLE
, 500, spAutoFormatPattern2
),
283 AUTOFORMAT_FADEDACCENTS( 19, THEMED_STYLE_SUBTLE
, 500 ),
284 AUTOFORMAT_PATTERN( 25, 25, THEMED_STYLE_SUBTLE
, 700, spAutoFormatPattern1
),
285 AUTOFORMAT_PATTERN( 26, 26, THEMED_STYLE_SUBTLE
, 700, spAutoFormatPattern2
),
286 AUTOFORMAT_FADEDACCENTS( 27, THEMED_STYLE_SUBTLE
, 700 ),
287 AUTOFORMAT_PATTERN( 33, 33, THEMED_STYLE_SUBTLE
, 500, spAutoFormatPattern1
),
288 AUTOFORMAT_PATTERN( 34, 34, THEMED_STYLE_SUBTLE
, 500, spAutoFormatPattern2
),
289 AUTOFORMAT_FADEDACCENTS( 35, THEMED_STYLE_SUBTLE
, 500 ),
290 AUTOFORMAT_PATTERN( 41, 42, THEMED_STYLE_SUBTLE
, 500, spAutoFormatPattern4
),
291 AUTOFORMAT_PATTERN( 42, 42, THEMED_STYLE_SUBTLE
, 500, spAutoFormatPattern2
),
292 AUTOFORMAT_FADEDACCENTS( 43, THEMED_STYLE_SUBTLE
, 500 ),
296 static const AutoFormatEntry spFilledSeriesLines
[] =
298 AUTOFORMAT_INVISIBLE( 1, 8 ),
299 AUTOFORMAT_COLOR( 9, 16, THEMED_STYLE_SUBTLE
, XML_lt1
),
300 AUTOFORMAT_INVISIBLE( 17, 32 ),
301 AUTOFORMAT_COLORMOD( 33, 33, THEMED_STYLE_SUBTLE
, XML_dk1
, XML_shade
, 50000 ),
302 AUTOFORMAT_PATTERN( 34, 34, THEMED_STYLE_SUBTLE
, 100, spAutoFormatPattern3
),
303 AUTOFORMAT_ACCENTSMOD( 35, THEMED_STYLE_SUBTLE
, XML_shade
, 50000 ),
304 AUTOFORMAT_INVISIBLE( 41, 48 ),
308 static const AutoFormatEntry spFilledSeries2dFills
[] =
310 AUTOFORMAT_PATTERN( 1, 1, THEMED_STYLE_SUBTLE
, 100, spAutoFormatPattern1
),
311 AUTOFORMAT_PATTERN( 2, 2, THEMED_STYLE_SUBTLE
, 100, spAutoFormatPattern2
),
312 AUTOFORMAT_FADEDACCENTS( 3, THEMED_STYLE_SUBTLE
, 100 ),
313 AUTOFORMAT_PATTERN( 9, 9, THEMED_STYLE_SUBTLE
, 100, spAutoFormatPattern1
),
314 AUTOFORMAT_PATTERN( 10, 10, THEMED_STYLE_SUBTLE
, 100, spAutoFormatPattern2
),
315 AUTOFORMAT_FADEDACCENTS( 11, THEMED_STYLE_SUBTLE
, 100 ),
316 AUTOFORMAT_PATTERN( 17, 17, THEMED_STYLE_INTENSE
, 100, spAutoFormatPattern1
),
317 AUTOFORMAT_PATTERN( 18, 18, THEMED_STYLE_INTENSE
, 100, spAutoFormatPattern2
),
318 AUTOFORMAT_FADEDACCENTS( 19, THEMED_STYLE_INTENSE
, 100 ),
319 AUTOFORMAT_PATTERN( 25, 25, THEMED_STYLE_INTENSE
, 100, spAutoFormatPattern1
),
320 AUTOFORMAT_PATTERN( 26, 26, THEMED_STYLE_INTENSE
, 100, spAutoFormatPattern2
),
321 AUTOFORMAT_FADEDACCENTS( 27, THEMED_STYLE_INTENSE
, 100 ),
322 AUTOFORMAT_PATTERN( 33, 33, THEMED_STYLE_SUBTLE
, 100, spAutoFormatPattern1
),
323 AUTOFORMAT_PATTERN( 34, 34, THEMED_STYLE_SUBTLE
, 100, spAutoFormatPattern2
),
324 AUTOFORMAT_FADEDACCENTS( 35, THEMED_STYLE_SUBTLE
, 100 ),
325 AUTOFORMAT_PATTERN( 41, 42, THEMED_STYLE_INTENSE
, 100, spAutoFormatPattern4
),
326 AUTOFORMAT_PATTERN( 42, 42, THEMED_STYLE_INTENSE
, 100, spAutoFormatPattern2
),
327 AUTOFORMAT_FADEDACCENTS( 43, THEMED_STYLE_INTENSE
, 100 ),
331 static const AutoFormatEntry spFilledSeries3dFills
[] =
333 AUTOFORMAT_PATTERN( 1, 1, THEMED_STYLE_SUBTLE
, 100, spAutoFormatPattern1
),
334 AUTOFORMAT_PATTERN( 2, 2, THEMED_STYLE_SUBTLE
, 100, spAutoFormatPattern2
),
335 AUTOFORMAT_FADEDACCENTS( 3, THEMED_STYLE_SUBTLE
, 100 ),
336 AUTOFORMAT_PATTERN( 9, 9, THEMED_STYLE_SUBTLE
, 100, spAutoFormatPattern1
),
337 AUTOFORMAT_PATTERN( 10, 10, THEMED_STYLE_SUBTLE
, 100, spAutoFormatPattern2
),
338 AUTOFORMAT_FADEDACCENTS( 11, THEMED_STYLE_SUBTLE
, 100 ),
339 AUTOFORMAT_PATTERN( 17, 17, THEMED_STYLE_SUBTLE
, 100, spAutoFormatPattern1
),
340 AUTOFORMAT_PATTERN( 18, 18, THEMED_STYLE_INTENSE
, 100, spAutoFormatPattern2
),
341 AUTOFORMAT_FADEDACCENTS( 19, THEMED_STYLE_SUBTLE
, 100 ),
342 AUTOFORMAT_PATTERN( 25, 25, THEMED_STYLE_SUBTLE
, 100, spAutoFormatPattern1
),
343 AUTOFORMAT_PATTERN( 26, 26, THEMED_STYLE_INTENSE
, 100, spAutoFormatPattern2
),
344 AUTOFORMAT_FADEDACCENTS( 27, THEMED_STYLE_SUBTLE
, 100 ),
345 AUTOFORMAT_PATTERN( 33, 33, THEMED_STYLE_SUBTLE
, 100, spAutoFormatPattern1
),
346 AUTOFORMAT_PATTERN( 34, 34, THEMED_STYLE_SUBTLE
, 100, spAutoFormatPattern2
),
347 AUTOFORMAT_FADEDACCENTS( 35, THEMED_STYLE_SUBTLE
, 100 ),
348 AUTOFORMAT_PATTERN( 41, 42, THEMED_STYLE_SUBTLE
, 100, spAutoFormatPattern4
),
349 AUTOFORMAT_PATTERN( 42, 42, THEMED_STYLE_INTENSE
, 100, spAutoFormatPattern2
),
350 AUTOFORMAT_FADEDACCENTS( 43, THEMED_STYLE_SUBTLE
, 100 ),
354 static const AutoFormatEntry spFilledSeriesEffects
[] =
356 // 1...8: no effect, same as Chart2
357 AUTOFORMAT_COLOR( 9, 16, THEMED_STYLE_SUBTLE
, XML_dk1
),
358 AUTOFORMAT_COLOR( 17, 24, THEMED_STYLE_MODERATE
, XML_dk1
),
359 AUTOFORMAT_COLOR( 25, 32, THEMED_STYLE_INTENSE
, XML_dk1
),
360 // 33...40: no effect, same as Chart2
361 AUTOFORMAT_COLOR( 41, 48, THEMED_STYLE_INTENSE
, XML_dk1
),
365 static const AutoFormatEntry spUpDownBarLines
[] =
367 AUTOFORMAT_COLOR( 1, 16, THEMED_STYLE_SUBTLE
, XML_tx1
),
368 AUTOFORMAT_INVISIBLE( 17, 32 ),
369 AUTOFORMAT_COLOR( 33, 34, THEMED_STYLE_SUBTLE
, XML_dk1
),
370 AUTOFORMAT_ACCENTSMOD( 35, THEMED_STYLE_SUBTLE
, XML_shade
, 25000 ),
371 AUTOFORMAT_INVISIBLE( 41, 48 ),
375 static const AutoFormatEntry spUpBarFills
[] =
377 AUTOFORMAT_COLORMOD( 1, 1, THEMED_STYLE_SUBTLE
, XML_dk1
, XML_tint
, 25000 ),
378 AUTOFORMAT_COLORMOD( 2, 2, THEMED_STYLE_SUBTLE
, XML_dk1
, XML_tint
, 5000 ),
379 AUTOFORMAT_ACCENTSMOD( 3, THEMED_STYLE_SUBTLE
, XML_tint
, 25000 ),
380 AUTOFORMAT_COLORMOD( 9, 9, THEMED_STYLE_SUBTLE
, XML_dk1
, XML_tint
, 25000 ),
381 AUTOFORMAT_COLORMOD( 10, 10, THEMED_STYLE_SUBTLE
, XML_dk1
, XML_tint
, 5000 ),
382 AUTOFORMAT_ACCENTSMOD( 11, THEMED_STYLE_SUBTLE
, XML_tint
, 25000 ),
383 AUTOFORMAT_COLORMOD( 17, 17, THEMED_STYLE_INTENSE
, XML_dk1
, XML_tint
, 25000 ),
384 AUTOFORMAT_COLORMOD( 18, 18, THEMED_STYLE_INTENSE
, XML_dk1
, XML_tint
, 5000 ),
385 AUTOFORMAT_ACCENTSMOD( 19, THEMED_STYLE_INTENSE
, XML_tint
, 25000 ),
386 AUTOFORMAT_COLORMOD( 25, 25, THEMED_STYLE_INTENSE
, XML_dk1
, XML_tint
, 25000 ),
387 AUTOFORMAT_COLORMOD( 26, 26, THEMED_STYLE_INTENSE
, XML_dk1
, XML_tint
, 5000 ),
388 AUTOFORMAT_ACCENTSMOD( 27, THEMED_STYLE_INTENSE
, XML_tint
, 25000 ),
389 AUTOFORMAT_COLOR( 33, 40, THEMED_STYLE_SUBTLE
, XML_lt1
),
390 AUTOFORMAT_COLORMOD( 41, 41, THEMED_STYLE_INTENSE
, XML_dk1
, XML_tint
, 25000 ),
391 AUTOFORMAT_COLOR( 42, 42, THEMED_STYLE_INTENSE
, XML_lt1
),
392 AUTOFORMAT_ACCENTSMOD( 43, THEMED_STYLE_INTENSE
, XML_tint
, 25000 ),
396 static const AutoFormatEntry spDownBarFills
[] =
398 AUTOFORMAT_COLORMOD( 1, 1, THEMED_STYLE_SUBTLE
, XML_dk1
, XML_tint
, 85000 ),
399 AUTOFORMAT_COLORMOD( 2, 2, THEMED_STYLE_SUBTLE
, XML_dk1
, XML_tint
, 95000 ),
400 AUTOFORMAT_ACCENTSMOD( 3, THEMED_STYLE_SUBTLE
, XML_shade
, 25000 ),
401 AUTOFORMAT_COLORMOD( 9, 9, THEMED_STYLE_SUBTLE
, XML_dk1
, XML_tint
, 85000 ),
402 AUTOFORMAT_COLORMOD( 10, 10, THEMED_STYLE_SUBTLE
, XML_dk1
, XML_tint
, 95000 ),
403 AUTOFORMAT_ACCENTSMOD( 11, THEMED_STYLE_SUBTLE
, XML_shade
, 25000 ),
404 AUTOFORMAT_COLORMOD( 17, 17, THEMED_STYLE_INTENSE
, XML_dk1
, XML_tint
, 85000 ),
405 AUTOFORMAT_COLORMOD( 18, 18, THEMED_STYLE_INTENSE
, XML_dk1
, XML_tint
, 95000 ),
406 AUTOFORMAT_ACCENTSMOD( 19, THEMED_STYLE_INTENSE
, XML_shade
, 25000 ),
407 AUTOFORMAT_COLORMOD( 25, 25, THEMED_STYLE_INTENSE
, XML_dk1
, XML_tint
, 85000 ),
408 AUTOFORMAT_COLORMOD( 26, 26, THEMED_STYLE_INTENSE
, XML_dk1
, XML_tint
, 95000 ),
409 AUTOFORMAT_ACCENTSMOD( 27, THEMED_STYLE_INTENSE
, XML_shade
, 25000 ),
410 AUTOFORMAT_COLORMOD( 33, 33, THEMED_STYLE_SUBTLE
, XML_dk1
, XML_tint
, 85000 ),
411 AUTOFORMAT_COLORMOD( 34, 34, THEMED_STYLE_SUBTLE
, XML_dk1
, XML_tint
, 95000 ),
412 AUTOFORMAT_ACCENTSMOD( 27, THEMED_STYLE_SUBTLE
, XML_shade
, 25000 ),
413 AUTOFORMAT_COLORMOD( 41, 41, THEMED_STYLE_INTENSE
, XML_dk1
, XML_tint
, 85000 ),
414 AUTOFORMAT_COLOR( 42, 42, THEMED_STYLE_INTENSE
, XML_dk1
),
415 AUTOFORMAT_ACCENTSMOD( 43, THEMED_STYLE_INTENSE
, XML_shade
, 25000 ),
419 static const AutoFormatEntry spUpDownBarEffects
[] =
421 // 1...8: no effect, same as Chart2
422 AUTOFORMAT_COLOR( 9, 16, THEMED_STYLE_SUBTLE
, XML_dk1
),
423 AUTOFORMAT_COLOR( 17, 24, THEMED_STYLE_MODERATE
, XML_dk1
),
424 AUTOFORMAT_COLOR( 25, 32, THEMED_STYLE_INTENSE
, XML_dk1
),
425 // 33...40: no effect, same as Chart2
426 AUTOFORMAT_COLOR( 41, 48, THEMED_STYLE_INTENSE
, XML_dk1
),
430 #undef AUTOFORMAT_COLOR
431 #undef AUTOFORMAT_ACCENTS
432 #undef AUTOFORMAT_COLORMOD
433 #undef AUTOFORMAT_ACCENTSMOD
434 #undef AUTOFORMAT_PATTERN
435 #undef AUTOFORMAT_FADED
436 #undef AUTOFORMAT_FADEDACCENTS
437 #undef AUTOFORMAT_INVISIBLE
438 #undef AUTOFORMAT_END
440 const AutoFormatEntry
* lclGetAutoFormatEntry( const AutoFormatEntry
* pEntries
, sal_Int32 nStyle
)
442 for( ; pEntries
&& (pEntries
->mnFirstStyleIdx
>= 0); ++pEntries
)
443 if( (pEntries
->mnFirstStyleIdx
<= nStyle
) && (nStyle
<= pEntries
->mnLastStyleIdx
) )
448 // ----------------------------------------------------------------------------
452 sal_Int32 mnFirstStyleIdx
; /// First chart style index.
453 sal_Int32 mnLastStyleIdx
; /// Last chart style index.
454 sal_Int32 mnThemedFont
; /// Themed font (minor/major).
455 sal_Int32 mnColorToken
; /// Theme color token.
456 sal_Int32 mnDefFontSize
; /// Default font size (1/100 points).
457 sal_Int32 mnRelFontSize
; /// Font size relative to chart global font (percent).
458 bool mbBold
; /// True = bold font.
461 #define AUTOTEXT_COLOR( first, last, themed_font, color_token, def_font_size, rel_font_size, bold ) \
462 { first, last, themed_font, color_token, def_font_size, rel_font_size, bold }
464 #define AUTOTEXT_END() \
465 AUTOTEXT_COLOR( -1, -1, XML_none, XML_TOKEN_INVALID, 1000, 100, false )
467 static const AutoTextEntry spChartTitleTexts
[] =
469 AUTOTEXT_COLOR( 1, 40, XML_minor
, XML_tx1
, 1800, 120, true ),
470 AUTOTEXT_COLOR( 41, 48, XML_minor
, XML_lt1
, 1800, 120, true ),
474 static const AutoTextEntry spAxisTitleTexts
[] =
476 AUTOTEXT_COLOR( 1, 40, XML_minor
, XML_tx1
, 1000, 100, true ),
477 AUTOTEXT_COLOR( 41, 48, XML_minor
, XML_lt1
, 1000, 100, true ),
481 static const AutoTextEntry spOtherTexts
[] =
483 AUTOTEXT_COLOR( 1, 40, XML_minor
, XML_tx1
, 1000, 100, false ),
484 AUTOTEXT_COLOR( 41, 48, XML_minor
, XML_lt1
, 1000, 100, false ),
488 #undef AUTOTEXT_COLOR
491 const AutoTextEntry
* lclGetAutoTextEntry( const AutoTextEntry
* pEntries
, sal_Int32 nStyle
)
493 for( ; pEntries
&& (pEntries
->mnFirstStyleIdx
>= 0); ++pEntries
)
494 if( (pEntries
->mnFirstStyleIdx
<= nStyle
) && (nStyle
<= pEntries
->mnLastStyleIdx
) )
499 // ----------------------------------------------------------------------------
501 /** Enumerates different sets of property names for chart object formatting. */
504 PROPERTYTYPE_COMMON
, /// Common objects, no special handling.
505 PROPERTYTYPE_LINEARSERIES
, /// Specific to linear data series.
506 PROPERTYTYPE_FILLEDSERIES
/// Specific to filled data series.
509 /** Contains information about formatting of a specific chart object type. */
510 struct ObjectTypeFormatEntry
512 ObjectType meObjType
; /// Object type for automatic format.
513 PropertyType mePropType
; /// Property type for property names.
514 const AutoFormatEntry
* mpAutoLines
; /// Automatic line formatting for all chart styles.
515 const AutoFormatEntry
* mpAutoFills
; /// Automatic fill formatting for all chart styles.
516 const AutoFormatEntry
* mpAutoEffects
; /// Automatic effect formatting for all chart styles.
517 const AutoTextEntry
* mpAutoTexts
; /// Automatic text attributes for all chart styles.
518 bool mbIsFrame
; /// True = object is a frame, false = object is a line.
521 #define TYPEFORMAT_FRAME( obj_type, prop_type, auto_texts, auto_lines, auto_fills, auto_effects ) \
522 { obj_type, prop_type, auto_lines, auto_fills, auto_effects, auto_texts, true }
524 #define TYPEFORMAT_LINE( obj_type, prop_type, auto_texts, auto_lines ) \
525 { obj_type, prop_type, auto_lines, 0, 0, auto_texts, false }
527 static const ObjectTypeFormatEntry spObjTypeFormatEntries
[] =
529 // object type property type auto text auto line auto fill auto effect
530 TYPEFORMAT_FRAME( OBJECTTYPE_CHARTSPACE
, PROPERTYTYPE_COMMON
, 0, spChartSpaceLines
, spChartSpaceFills
, 0 /* eq to Ch2 */ ),
531 TYPEFORMAT_FRAME( OBJECTTYPE_CHARTTITLE
, PROPERTYTYPE_COMMON
, spChartTitleTexts
, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */ ),
532 TYPEFORMAT_FRAME( OBJECTTYPE_LEGEND
, PROPERTYTYPE_COMMON
, spOtherTexts
, spNoFormats
, spNoFormats
, 0 /* eq to Ch2 */ ),
533 TYPEFORMAT_FRAME( OBJECTTYPE_PLOTAREA2D
, PROPERTYTYPE_COMMON
, 0, 0 /* eq to Ch2 */, spPlotArea2dFills
, 0 /* eq to Ch2 */ ),
534 TYPEFORMAT_FRAME( OBJECTTYPE_PLOTAREA3D
, PROPERTYTYPE_COMMON
, 0, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */ ),
535 TYPEFORMAT_FRAME( OBJECTTYPE_WALL
, PROPERTYTYPE_COMMON
, 0, 0 /* eq to Ch2 */, spWallFloorFills
, 0 /* eq to Ch2 */ ),
536 TYPEFORMAT_FRAME( OBJECTTYPE_FLOOR
, PROPERTYTYPE_COMMON
, 0, spFloorLines
, spWallFloorFills
, 0 /* eq to Ch2 */ ),
537 TYPEFORMAT_LINE( OBJECTTYPE_AXIS
, PROPERTYTYPE_COMMON
, spOtherTexts
, spAxisLines
),
538 TYPEFORMAT_FRAME( OBJECTTYPE_AXISTITLE
, PROPERTYTYPE_COMMON
, spAxisTitleTexts
, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */ ),
539 TYPEFORMAT_FRAME( OBJECTTYPE_AXISUNIT
, PROPERTYTYPE_COMMON
, spAxisTitleTexts
, 0 /* eq in Ch2 */, 0 /* eq in Ch2 */, 0 /* eq in Ch2 */ ),
540 TYPEFORMAT_LINE( OBJECTTYPE_MAJORGRIDLINE
, PROPERTYTYPE_COMMON
, 0, spMajorGridLines
),
541 TYPEFORMAT_LINE( OBJECTTYPE_MINORGRIDLINE
, PROPERTYTYPE_COMMON
, 0, spMinorGridLines
),
542 TYPEFORMAT_LINE( OBJECTTYPE_LINEARSERIES2D
, PROPERTYTYPE_LINEARSERIES
, 0, spLinearSeriesLines
),
543 TYPEFORMAT_FRAME( OBJECTTYPE_FILLEDSERIES2D
, PROPERTYTYPE_FILLEDSERIES
, 0, spFilledSeriesLines
, spFilledSeries2dFills
, spFilledSeriesEffects
),
544 TYPEFORMAT_FRAME( OBJECTTYPE_FILLEDSERIES3D
, PROPERTYTYPE_FILLEDSERIES
, 0, spFilledSeriesLines
, spFilledSeries3dFills
, spFilledSeriesEffects
),
545 TYPEFORMAT_FRAME( OBJECTTYPE_DATALABEL
, PROPERTYTYPE_COMMON
, spOtherTexts
, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */ ),
546 TYPEFORMAT_LINE( OBJECTTYPE_TRENDLINE
, PROPERTYTYPE_COMMON
, 0, spOtherLines
),
547 TYPEFORMAT_FRAME( OBJECTTYPE_TRENDLINELABEL
, PROPERTYTYPE_COMMON
, spOtherTexts
, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */ ),
548 TYPEFORMAT_LINE( OBJECTTYPE_ERRORBAR
, PROPERTYTYPE_COMMON
, 0, spOtherLines
),
549 TYPEFORMAT_LINE( OBJECTTYPE_SERLINE
, PROPERTYTYPE_COMMON
, 0, spOtherLines
),
550 TYPEFORMAT_LINE( OBJECTTYPE_LEADERLINE
, PROPERTYTYPE_COMMON
, 0, spOtherLines
),
551 TYPEFORMAT_LINE( OBJECTTYPE_DROPLINE
, PROPERTYTYPE_COMMON
, 0, spOtherLines
),
552 TYPEFORMAT_LINE( OBJECTTYPE_HILOLINE
, PROPERTYTYPE_LINEARSERIES
, 0, spOtherLines
),
553 TYPEFORMAT_FRAME( OBJECTTYPE_UPBAR
, PROPERTYTYPE_COMMON
, 0, spUpDownBarLines
, spUpBarFills
, spUpDownBarEffects
),
554 TYPEFORMAT_FRAME( OBJECTTYPE_DOWNBAR
, PROPERTYTYPE_COMMON
, 0, spUpDownBarLines
, spDownBarFills
, spUpDownBarEffects
),
555 TYPEFORMAT_LINE( OBJECTTYPE_DATATABLE
, PROPERTYTYPE_COMMON
, spOtherTexts
, spChartSpaceLines
)
558 #undef TYPEFORMAT_FRAME
559 #undef TYPEFORMAT_LINE
560 // ----------------------------------------------------------------------------
562 void lclConvertPictureOptions( FillProperties
& orFillProps
, const PictureOptionsModel
& rPicOptions
)
564 bool bStacked
= (rPicOptions
.mnPictureFormat
== XML_stack
) || (rPicOptions
.mnPictureFormat
== XML_stackScale
);
565 orFillProps
.maBlipProps
.moBitmapMode
= bStacked
? XML_tile
: XML_stretch
;
568 // ----------------------------------------------------------------------------
570 const sal_Int32 spnCommonLineIds
[ LineId_END
] = { PROP_LineStyle
, PROP_LineWidth
, PROP_LineColor
, PROP_LineTransparence
, PROP_LineDashName
, PROP_INVALID
, PROP_INVALID
, PROP_INVALID
, PROP_INVALID
, PROP_INVALID
, PROP_INVALID
, PROP_INVALID
};
571 const sal_Int32 spnLinearLineIds
[ LineId_END
] = { PROP_LineStyle
, PROP_LineWidth
, PROP_Color
, PROP_Transparency
, PROP_LineDashName
, PROP_INVALID
, PROP_INVALID
, PROP_INVALID
, PROP_INVALID
, PROP_INVALID
, PROP_INVALID
, PROP_INVALID
};
572 const sal_Int32 spnFilledLineIds
[ LineId_END
] = { PROP_BorderStyle
, PROP_BorderWidth
, PROP_BorderColor
, PROP_BorderTransparency
, PROP_BorderDashName
, PROP_INVALID
, PROP_INVALID
, PROP_INVALID
, PROP_INVALID
, PROP_INVALID
, PROP_INVALID
, PROP_INVALID
};
574 const sal_Int32 spnCommonFillIds
[ FillId_END
] = { PROP_FillStyle
, PROP_FillColor
, PROP_FillTransparence
, PROP_FillGradientName
, PROP_FillBitmapName
, PROP_FillBitmapMode
, PROP_FillBitmapSizeX
, PROP_FillBitmapSizeY
, PROP_FillBitmapPositionOffsetX
, PROP_FillBitmapPositionOffsetY
, PROP_FillBitmapRectanglePoint
};
575 const sal_Int32 spnFilledFillIds
[ FillId_END
] = { PROP_FillStyle
, PROP_Color
, PROP_Transparency
, PROP_GradientName
, PROP_FillBitmapName
, PROP_FillBitmapMode
, PROP_FillBitmapSizeX
, PROP_FillBitmapSizeY
, PROP_FillBitmapPositionOffsetX
, PROP_FillBitmapPositionOffsetY
, PROP_FillBitmapRectanglePoint
};
579 // ============================================================================
581 struct ObjectFormatterData
;
583 // ----------------------------------------------------------------------------
585 class DetailFormatterBase
588 explicit DetailFormatterBase(
589 ObjectFormatterData
& rData
,
590 const AutoFormatEntry
* pAutoFormatEntry
);
591 explicit DetailFormatterBase(
592 ObjectFormatterData
& rData
,
593 const AutoTextEntry
* pAutoTextEntry
);
596 /** Returns the placeholder color which may depend on the passed series index. */
597 sal_Int32
getPhColor( sal_Int32 nSeriesIdx
) const;
600 /** Resolves and returns the scheme color with the passed transformation. */
601 sal_Int32
getSchemeColor( sal_Int32 nColorToken
, sal_Int32 nModToken
, sal_Int32 nModValue
) const;
604 typedef ::std::vector
< sal_Int32
> ColorPatternVec
;
606 ObjectFormatterData
& mrData
; /// Shared formatter data.
607 sal_Int32 mnPhClr
; /// RGB placeholder color for themed style.
608 ColorPatternVec maColorPattern
; /// Different cycling colors for data series.
611 // ----------------------------------------------------------------------------
613 class LineFormatter
: public DetailFormatterBase
616 explicit LineFormatter(
617 ObjectFormatterData
& rData
,
618 const AutoFormatEntry
* pAutoFormatEntry
,
619 PropertyType ePropType
);
621 /** Converts line formatting to the passed property set. */
622 void convertFormatting(
623 PropertySet
& rPropSet
,
624 const ModelRef
< Shape
>& rxShapeProp
,
625 sal_Int32 nSeriesIdx
);
628 LinePropertiesPtr mxAutoLine
; /// Automatic line properties.
629 LinePropertyIds
& mrLinePropIds
; /// Property identifiers for border/line formatting.
632 // ----------------------------------------------------------------------------
634 class FillFormatter
: public DetailFormatterBase
637 explicit FillFormatter(
638 ObjectFormatterData
& rData
,
639 const AutoFormatEntry
* pAutoFormatEntry
,
640 PropertyType ePropType
);
642 /** Converts area formatting to the passed property set. */
643 void convertFormatting(
644 PropertySet
& rPropSet
,
645 const ModelRef
< Shape
>& rxShapeProp
,
646 const PictureOptionsModel
* pPicOptions
,
647 sal_Int32 nSeriesIdx
);
650 FillPropertiesPtr mxAutoFill
; /// Automatic fill properties.
651 FillPropertyIds
& mrFillPropIds
; /// Property identifiers for fill formatting.
654 // ----------------------------------------------------------------------------
656 class EffectFormatter
: public DetailFormatterBase
659 explicit EffectFormatter(
660 ObjectFormatterData
& rData
,
661 const AutoFormatEntry
* pAutoFormatEntry
,
662 PropertyType ePropType
);
664 /** Converts effect formatting to the passed property set. */
665 void convertFormatting(
666 PropertySet
& rPropSet
,
667 const ModelRef
< Shape
>& rxShapeProp
,
668 sal_Int32 nSeriesIdx
);
671 // ----------------------------------------------------------------------------
673 class TextFormatter
: public DetailFormatterBase
676 explicit TextFormatter(
677 ObjectFormatterData
& rData
,
678 const AutoTextEntry
* pAutoTextEntry
,
679 const ModelRef
< TextBody
>& rxGlobalTextProp
);
681 /** Converts text formatting to the passed property set. */
682 void convertFormatting(
683 PropertySet
& rPropSet
,
684 const TextCharacterProperties
* pTextProps
);
685 /** Converts text formatting to the passed property set. */
686 void convertFormatting(
687 PropertySet
& rPropSet
,
688 const ModelRef
< TextBody
>& rxTextProp
);
691 TextCharacterPropertiesPtr mxAutoText
; /// Automatic text properties.
694 // ----------------------------------------------------------------------------
696 /** Formatter for a specific object type. */
697 class ObjectTypeFormatter
700 explicit ObjectTypeFormatter(
701 ObjectFormatterData
& rData
,
702 const ObjectTypeFormatEntry
& rEntry
,
703 const ChartSpaceModel
& rChartSpace
);
705 /** Sets frame formatting properties to the passed property set. */
706 void convertFrameFormatting(
707 PropertySet
& rPropSet
,
708 const ModelRef
< Shape
>& rxShapeProp
,
709 const PictureOptionsModel
* pPicOptions
,
710 sal_Int32 nSeriesIdx
);
712 /** Sets text formatting properties to the passed property set. */
713 void convertTextFormatting(
714 PropertySet
& rPropSet
,
715 const ModelRef
< TextBody
>& rxTextProp
);
717 /** Sets frame/text formatting properties to the passed property set. */
718 void convertFormatting(
719 PropertySet
& rPropSet
,
720 const ModelRef
< Shape
>& rxShapeProp
,
721 const ModelRef
< TextBody
>& rxTextProp
);
723 /** Sets text formatting properties to the passed property set. */
724 void convertTextFormatting(
725 PropertySet
& rPropSet
,
726 const TextCharacterProperties
& rTextProps
);
728 /** Sets automatic line properties to the passed property set. */
729 void convertAutomaticLine(
730 PropertySet
& rPropSet
,
731 sal_Int32 nSeriesIdx
);
733 /** Sets automatic fill properties to the passed property set. */
734 void convertAutomaticFill(
735 PropertySet
& rPropSet
,
736 sal_Int32 nSeriesIdx
);
739 LineFormatter maLineFormatter
; /// Converter for line formatting.
740 FillFormatter maFillFormatter
; /// Converter for fill formatting.
741 EffectFormatter maEffectFormatter
; /// Converter for effect formatting.
742 TextFormatter maTextFormatter
; /// Converter for text formatting.
743 const ObjectTypeFormatEntry
& mrEntry
; /// Additional settings.
746 // ----------------------------------------------------------------------------
748 struct ObjectFormatterData
750 typedef RefMap
< ObjectType
, ObjectTypeFormatter
> ObjectTypeFormatterMap
;
752 const XmlFilterBase
& mrFilter
; /// Base filter object.
753 ObjectTypeFormatterMap maTypeFormatters
; /// Formatters for all types of objects in a chart.
754 ModelObjectHelper maModelObjHelper
; /// Helper for named drawing formatting (dashes, gradients, bitmaps).
755 LinePropertyIds maCommonLineIds
; /// Property identifiers for common border formatting.
756 LinePropertyIds maLinearLineIds
; /// Property identifiers for line formatting of linear series.
757 LinePropertyIds maFilledLineIds
; /// Property identifiers for line formatting of filled series.
758 FillPropertyIds maCommonFillIds
; /// Property identifiers for common area fill.
759 FillPropertyIds maFilledFillIds
; /// Property identifiers for area fill of filled series.
760 Reference
< XNumberFormats
> mxNumFmts
; /// Number formats collection of container document.
761 Reference
< XNumberFormatTypes
> mxNumTypes
; /// Number format types collection of container document.
762 Locale maEnUsLocale
; /// Locale struct containing en-US.
763 Locale maFromLocale
; /// Empty locale struct.
764 sal_Int32 mnMaxSeriesIdx
; /// Maximum series index used for color cycling/fading.
766 explicit ObjectFormatterData(
767 const XmlFilterBase
& rFilter
,
768 const Reference
< XChartDocument
>& rxChartDoc
,
769 const ChartSpaceModel
& rChartSpace
);
771 ObjectTypeFormatter
* getTypeFormatter( ObjectType eObjType
);
773 LinePropertyIds
& getLinePropertyIds( PropertyType ePropType
);
774 FillPropertyIds
& getFillPropertyIds( PropertyType ePropType
);
777 // ============================================================================
779 DetailFormatterBase::DetailFormatterBase( ObjectFormatterData
& rData
, const AutoFormatEntry
* pAutoFormatEntry
) :
783 if( pAutoFormatEntry
)
785 if( pAutoFormatEntry
->mpPattern
)
787 // prepare multi-color pattern
788 for( const AutoFormatPatternEntry
* pPatternEntry
= pAutoFormatEntry
->mpPattern
; pPatternEntry
->mnColorToken
!= XML_TOKEN_INVALID
; ++pPatternEntry
)
789 maColorPattern
.push_back( getSchemeColor( pPatternEntry
->mnColorToken
, pPatternEntry
->mnModToken
, pPatternEntry
->mnModValue
) );
791 else if( pAutoFormatEntry
->mnColorToken
!= XML_TOKEN_INVALID
)
793 // prepare color or single-color pattern (color fading)
794 mnPhClr
= getSchemeColor( pAutoFormatEntry
->mnColorToken
, pAutoFormatEntry
->mnModToken
, pAutoFormatEntry
->mnModValue
);
795 if( pAutoFormatEntry
->mbFadedColor
)
796 maColorPattern
.push_back( mnPhClr
);
801 DetailFormatterBase::DetailFormatterBase( ObjectFormatterData
& rData
, const AutoTextEntry
* pAutoTextEntry
) :
805 if( pAutoTextEntry
&& (pAutoTextEntry
->mnColorToken
!= XML_TOKEN_INVALID
) )
806 mnPhClr
= getSchemeColor( pAutoTextEntry
->mnColorToken
, XML_TOKEN_INVALID
, 0 );
809 sal_Int32
DetailFormatterBase::getPhColor( sal_Int32 nSeriesIdx
) const
811 if( maColorPattern
.empty() || (mrData
.mnMaxSeriesIdx
< 0) || (nSeriesIdx
< 0) )
814 /* Apply tint/shade depending on the cycle index. The colors of leading
815 series are darkened (color shade), the colors of trailing series are
816 lightened (color tint). Shade/tint is applied in an exclusive range of
819 Example 1: 3 data series using single-color shading with accent color 1
820 (e.g. automatic chart style #3). Shade/tint is applied per series.
821 Shade/tint changes in steps of 140%/(<series_count+1) = 140%/4 = 35%,
823 Step 1: -70% -> Not used.
824 Step 2: -35% -> Series 1 has 35% shade of accent color 1.
825 Step 3: 0% -> Series 2 has pure accent color 1.
826 Step 4: 35% -> Series 3 has 35% tint of accent color 1.
827 Step 5: 70% -> Not used.
829 Example 2: 20 data series using accent color pattern (e.g. automatic
830 chart style #2). Each color cycle has a size of 6 series (accent colors
831 1 to 6). Shade/tint is applied per color cycle.
832 Cycle #1: Series 1...6 are based on accent colors 1 to 6.
833 Cycle #2: Series 7...12 are based on accent colors 1 to 6.
834 Cycle #3: Series 13...18 are based on accent colors 1 to 6.
835 Cycle #4: Series 19...20 are based on accent colors 1 to 2.
836 Shade/tint changes in steps of 140%/(cycle_count+1) = 140%/5 = 28%,
838 Step 1: -70% -> Not used.
839 Step 2: -42% -> Cycle #1 has 42% shade of accent colors 1...6
840 step 3: -14% -> Cycle #2 has 14% shade of accent colors 1...6
841 step 4: 14% -> Cycle #3 has 14% tint of accent colors 1...6
842 step 5: 42% -> Cycle #4 has 42% tint of accent colors 1...6
843 step 6: 70% -> Not used.
845 sal_Int32 nPhClr
= maColorPattern
[ static_cast< size_t >( nSeriesIdx
% maColorPattern
.size() ) ];
846 size_t nCycleIdx
= static_cast< size_t >( nSeriesIdx
/ maColorPattern
.size() );
847 size_t nMaxCycleIdx
= static_cast< size_t >( mrData
.mnMaxSeriesIdx
/ maColorPattern
.size() );
848 double fShadeTint
= static_cast< double >( nCycleIdx
+ 1 ) / (nMaxCycleIdx
+ 2) * 1.4 - 0.7;
849 if( fShadeTint
!= 0.0 )
852 aColor
.setSrgbClr( nPhClr
);
853 aColor
.addChartTintTransformation( fShadeTint
);
854 nPhClr
= aColor
.getColor( mrData
.mrFilter
);
860 sal_Int32
DetailFormatterBase::getSchemeColor( sal_Int32 nColorToken
, sal_Int32 nModToken
, sal_Int32 nModValue
) const
863 aColor
.setSchemeClr( nColorToken
);
864 if( nModToken
!= XML_TOKEN_INVALID
)
865 aColor
.addTransformation( nModToken
, nModValue
);
866 return aColor
.getColor( mrData
.mrFilter
);
869 // ============================================================================
871 LineFormatter::LineFormatter( ObjectFormatterData
& rData
, const AutoFormatEntry
* pAutoFormatEntry
, PropertyType ePropType
) :
872 DetailFormatterBase( rData
, pAutoFormatEntry
),
873 mrLinePropIds( rData
.getLinePropertyIds( ePropType
) )
875 if( pAutoFormatEntry
)
877 mxAutoLine
.reset( new LineProperties
);
878 mxAutoLine
->maLineFill
.moFillType
= XML_noFill
;
879 if( const Theme
* pTheme
= mrData
.mrFilter
.getCurrentTheme() )
880 if( const LineProperties
* pLineProps
= pTheme
->getLineStyle( pAutoFormatEntry
->mnThemedIdx
) )
881 *mxAutoLine
= *pLineProps
;
882 // change line width according to chart auto style
883 if( mxAutoLine
->moLineWidth
.has() )
884 mxAutoLine
->moLineWidth
= mxAutoLine
->moLineWidth
.get() * pAutoFormatEntry
->mnRelLineWidth
/ 100;
888 void LineFormatter::convertFormatting( PropertySet
& rPropSet
, const ModelRef
< Shape
>& rxShapeProp
, sal_Int32 nSeriesIdx
)
890 LineProperties aLineProps
;
891 if( mxAutoLine
.get() )
892 aLineProps
.assignUsed( *mxAutoLine
);
893 if( rxShapeProp
.is() )
894 aLineProps
.assignUsed( rxShapeProp
->getLineProperties() );
895 aLineProps
.pushToPropSet( rPropSet
, mrLinePropIds
, mrData
.mrFilter
, mrData
.maModelObjHelper
, getPhColor( nSeriesIdx
) );
898 // ============================================================================
900 FillFormatter::FillFormatter( ObjectFormatterData
& rData
, const AutoFormatEntry
* pAutoFormatEntry
, PropertyType ePropType
) :
901 DetailFormatterBase( rData
, pAutoFormatEntry
),
902 mrFillPropIds( rData
.getFillPropertyIds( ePropType
) )
904 if( pAutoFormatEntry
)
906 mxAutoFill
.reset( new FillProperties
);
907 mxAutoFill
->moFillType
= XML_noFill
;
908 if( const Theme
* pTheme
= mrData
.mrFilter
.getCurrentTheme() )
909 if( const FillProperties
* pFillProps
= pTheme
->getFillStyle( pAutoFormatEntry
->mnThemedIdx
) )
910 *mxAutoFill
= *pFillProps
;
914 void FillFormatter::convertFormatting( PropertySet
& rPropSet
, const ModelRef
< Shape
>& rxShapeProp
, const PictureOptionsModel
* pPicOptions
, sal_Int32 nSeriesIdx
)
916 FillProperties aFillProps
;
917 if( mxAutoFill
.get() )
918 aFillProps
.assignUsed( *mxAutoFill
);
919 if( rxShapeProp
.is() )
920 aFillProps
.assignUsed( rxShapeProp
->getFillProperties() );
922 lclConvertPictureOptions( aFillProps
, *pPicOptions
);
923 aFillProps
.pushToPropSet( rPropSet
, mrFillPropIds
, mrData
.mrFilter
, mrData
.maModelObjHelper
, 0, getPhColor( nSeriesIdx
) );
926 // ============================================================================
928 EffectFormatter::EffectFormatter( ObjectFormatterData
& rData
, const AutoFormatEntry
* pAutoFormatEntry
, PropertyType
/*ePropType*/ ) :
929 DetailFormatterBase( rData
, pAutoFormatEntry
)
933 void EffectFormatter::convertFormatting( PropertySet
& /*rPropSet*/, const ModelRef
< Shape
>& /*rxShapeProp*/, sal_Int32
/*nSeriesIdx*/ )
937 // ============================================================================
941 const TextCharacterProperties
* lclGetTextProperties( const ModelRef
< TextBody
>& rxTextProp
)
943 return (rxTextProp
.is() && !rxTextProp
->getParagraphs().empty()) ?
944 &rxTextProp
->getParagraphs().front()->getProperties().getTextCharacterProperties() : 0;
949 TextFormatter::TextFormatter( ObjectFormatterData
& rData
, const AutoTextEntry
* pAutoTextEntry
, const ModelRef
< TextBody
>& rxGlobalTextProp
) :
950 DetailFormatterBase( rData
, pAutoTextEntry
)
954 mxAutoText
.reset( new TextCharacterProperties
);
955 if( const Theme
* pTheme
= mrData
.mrFilter
.getCurrentTheme() )
956 if( const TextCharacterProperties
* pTextProps
= pTheme
->getFontStyle( pAutoTextEntry
->mnThemedFont
) )
957 *mxAutoText
= *pTextProps
;
958 sal_Int32 nTextColor
= getPhColor( -1 );
959 if( nTextColor
>= 0 )
960 mxAutoText
->maCharColor
.setSrgbClr( nTextColor
);
961 mxAutoText
->moHeight
= pAutoTextEntry
->mnDefFontSize
;
962 mxAutoText
->moBold
= pAutoTextEntry
->mbBold
;
964 if( const TextCharacterProperties
* pTextProps
= lclGetTextProperties( rxGlobalTextProp
) )
966 mxAutoText
->assignUsed( *pTextProps
);
967 if( pTextProps
->moHeight
.has() )
968 mxAutoText
->moHeight
= pTextProps
->moHeight
.get() * pAutoTextEntry
->mnRelFontSize
/ 100;
973 void TextFormatter::convertFormatting( PropertySet
& rPropSet
, const TextCharacterProperties
* pTextProps
)
975 TextCharacterProperties aTextProps
;
976 if( mxAutoText
.get() )
977 aTextProps
.assignUsed( *mxAutoText
);
979 aTextProps
.assignUsed( *pTextProps
);
980 aTextProps
.pushToPropSet( rPropSet
, mrData
.mrFilter
);
983 void TextFormatter::convertFormatting( PropertySet
& rPropSet
, const ModelRef
< TextBody
>& rxTextProp
)
985 convertFormatting( rPropSet
, lclGetTextProperties( rxTextProp
) );
988 // ============================================================================
990 ObjectTypeFormatter::ObjectTypeFormatter( ObjectFormatterData
& rData
, const ObjectTypeFormatEntry
& rEntry
, const ChartSpaceModel
& rChartSpace
) :
991 maLineFormatter( rData
, lclGetAutoFormatEntry( rEntry
.mpAutoLines
, rChartSpace
.mnStyle
), rEntry
.mePropType
),
992 maFillFormatter( rData
, lclGetAutoFormatEntry( rEntry
.mpAutoFills
, rChartSpace
.mnStyle
), rEntry
.mePropType
),
993 maEffectFormatter( rData
, lclGetAutoFormatEntry( rEntry
.mpAutoEffects
, rChartSpace
.mnStyle
), rEntry
.mePropType
),
994 maTextFormatter( rData
, lclGetAutoTextEntry( rEntry
.mpAutoTexts
, rChartSpace
.mnStyle
), rChartSpace
.mxTextProp
),
999 void ObjectTypeFormatter::convertFrameFormatting( PropertySet
& rPropSet
, const ModelRef
< Shape
>& rxShapeProp
, const PictureOptionsModel
* pPicOptions
, sal_Int32 nSeriesIdx
)
1001 maLineFormatter
.convertFormatting( rPropSet
, rxShapeProp
, nSeriesIdx
);
1002 if( mrEntry
.mbIsFrame
)
1003 maFillFormatter
.convertFormatting( rPropSet
, rxShapeProp
, pPicOptions
, nSeriesIdx
);
1004 maEffectFormatter
.convertFormatting( rPropSet
, rxShapeProp
, nSeriesIdx
);
1007 void ObjectTypeFormatter::convertTextFormatting( PropertySet
& rPropSet
, const ModelRef
< TextBody
>& rxTextProp
)
1009 maTextFormatter
.convertFormatting( rPropSet
, rxTextProp
);
1012 void ObjectTypeFormatter::convertFormatting( PropertySet
& rPropSet
, const ModelRef
< Shape
>& rxShapeProp
, const ModelRef
< TextBody
>& rxTextProp
)
1014 convertFrameFormatting( rPropSet
, rxShapeProp
, 0, -1 );
1015 convertTextFormatting( rPropSet
, rxTextProp
);
1018 void ObjectTypeFormatter::convertTextFormatting( PropertySet
& rPropSet
, const TextCharacterProperties
& rTextProps
)
1020 maTextFormatter
.convertFormatting( rPropSet
, &rTextProps
);
1023 void ObjectTypeFormatter::convertAutomaticLine( PropertySet
& rPropSet
, sal_Int32 nSeriesIdx
)
1025 ModelRef
< Shape
> xShapeProp
;
1026 maLineFormatter
.convertFormatting( rPropSet
, xShapeProp
, nSeriesIdx
);
1027 maEffectFormatter
.convertFormatting( rPropSet
, xShapeProp
, nSeriesIdx
);
1030 void ObjectTypeFormatter::convertAutomaticFill( PropertySet
& rPropSet
, sal_Int32 nSeriesIdx
)
1032 ModelRef
< Shape
> xShapeProp
;
1033 maFillFormatter
.convertFormatting( rPropSet
, xShapeProp
, 0, nSeriesIdx
);
1034 maEffectFormatter
.convertFormatting( rPropSet
, xShapeProp
, nSeriesIdx
);
1037 // ============================================================================
1039 ObjectFormatterData::ObjectFormatterData( const XmlFilterBase
& rFilter
, const Reference
< XChartDocument
>& rxChartDoc
, const ChartSpaceModel
& rChartSpace
) :
1040 mrFilter( rFilter
),
1041 maModelObjHelper( Reference
< XMultiServiceFactory
>( rxChartDoc
, UNO_QUERY
) ),
1042 maCommonLineIds( spnCommonLineIds
, true, false ),
1043 maLinearLineIds( spnLinearLineIds
, true, false ),
1044 maFilledLineIds( spnFilledLineIds
, true, false ),
1045 maCommonFillIds( spnCommonFillIds
, true, true ),
1046 maFilledFillIds( spnFilledFillIds
, true, true ),
1047 maEnUsLocale( CREATE_OUSTRING( "en" ), CREATE_OUSTRING( "US" ), OUString() ),
1048 mnMaxSeriesIdx( -1 )
1050 const ObjectTypeFormatEntry
* pEntryEnd
= STATIC_ARRAY_END( spObjTypeFormatEntries
);
1051 for( const ObjectTypeFormatEntry
* pEntry
= spObjTypeFormatEntries
; pEntry
!= pEntryEnd
; ++pEntry
)
1052 maTypeFormatters
[ pEntry
->meObjType
].reset( new ObjectTypeFormatter( *this, *pEntry
, rChartSpace
) );
1056 Reference
< XNumberFormatsSupplier
> xNumFmtsSupp( mrFilter
.getModel(), UNO_QUERY_THROW
);
1057 mxNumFmts
= xNumFmtsSupp
->getNumberFormats();
1058 mxNumTypes
.set( mxNumFmts
, UNO_QUERY
);
1063 OSL_ENSURE( mxNumFmts
.is() && mxNumTypes
.is(), "ObjectFormatterData::ObjectFormatterData - cannot get number formats" );
1066 ObjectTypeFormatter
* ObjectFormatterData::getTypeFormatter( ObjectType eObjType
)
1068 OSL_ENSURE( maTypeFormatters
.has( eObjType
), "ObjectFormatterData::getTypeFormatter - unknown object type" );
1069 return maTypeFormatters
.get( eObjType
).get();
1072 LinePropertyIds
& ObjectFormatterData::getLinePropertyIds( PropertyType ePropType
)
1076 case PROPERTYTYPE_COMMON
: return maCommonLineIds
;
1077 case PROPERTYTYPE_LINEARSERIES
: return maLinearLineIds
;
1078 case PROPERTYTYPE_FILLEDSERIES
: return maFilledLineIds
;
1080 return maCommonLineIds
;
1083 FillPropertyIds
& ObjectFormatterData::getFillPropertyIds( PropertyType ePropType
)
1087 case PROPERTYTYPE_COMMON
: return maCommonFillIds
;
1088 case PROPERTYTYPE_LINEARSERIES
: return maCommonFillIds
;
1089 case PROPERTYTYPE_FILLEDSERIES
: return maFilledFillIds
;
1091 return maCommonFillIds
;
1094 // ============================================================================
1096 ObjectFormatter::ObjectFormatter( const XmlFilterBase
& rFilter
, const Reference
< XChartDocument
>& rxChartDoc
, const ChartSpaceModel
& rChartSpace
) :
1097 mxData( new ObjectFormatterData( rFilter
, rxChartDoc
, rChartSpace
) )
1101 ObjectFormatter::~ObjectFormatter()
1105 void ObjectFormatter::setMaxSeriesIndex( sal_Int32 nMaxSeriesIdx
)
1107 mxData
->mnMaxSeriesIdx
= nMaxSeriesIdx
;
1110 sal_Int32
ObjectFormatter::getMaxSeriesIndex() const
1112 return mxData
->mnMaxSeriesIdx
;
1115 void ObjectFormatter::convertFrameFormatting( PropertySet
& rPropSet
, const ModelRef
< Shape
>& rxShapeProp
, ObjectType eObjType
, sal_Int32 nSeriesIdx
)
1117 if( ObjectTypeFormatter
* pFormat
= mxData
->getTypeFormatter( eObjType
) )
1118 pFormat
->convertFrameFormatting( rPropSet
, rxShapeProp
, 0, nSeriesIdx
);
1121 void ObjectFormatter::convertFrameFormatting( PropertySet
& rPropSet
, const ModelRef
< Shape
>& rxShapeProp
, const PictureOptionsModel
& rPicOptions
, ObjectType eObjType
, sal_Int32 nSeriesIdx
)
1123 if( ObjectTypeFormatter
* pFormat
= mxData
->getTypeFormatter( eObjType
) )
1124 pFormat
->convertFrameFormatting( rPropSet
, rxShapeProp
, &rPicOptions
, nSeriesIdx
);
1127 void ObjectFormatter::convertTextFormatting( PropertySet
& rPropSet
, const ModelRef
< TextBody
>& rxTextProp
, ObjectType eObjType
)
1129 if( ObjectTypeFormatter
* pFormat
= mxData
->getTypeFormatter( eObjType
) )
1130 pFormat
->convertTextFormatting( rPropSet
, rxTextProp
);
1133 void ObjectFormatter::convertFormatting( PropertySet
& rPropSet
, const ModelRef
< Shape
>& rxShapeProp
, const ModelRef
< TextBody
>& rxTextProp
, ObjectType eObjType
)
1135 if( ObjectTypeFormatter
* pFormat
= mxData
->getTypeFormatter( eObjType
) )
1136 pFormat
->convertFormatting( rPropSet
, rxShapeProp
, rxTextProp
);
1139 void ObjectFormatter::convertTextFormatting( PropertySet
& rPropSet
, const TextCharacterProperties
& rTextProps
, ObjectType eObjType
)
1141 if( ObjectTypeFormatter
* pFormat
= mxData
->getTypeFormatter( eObjType
) )
1142 pFormat
->convertTextFormatting( rPropSet
, rTextProps
);
1145 void ObjectFormatter::convertTextRotation( PropertySet
& rPropSet
, const ModelRef
< TextBody
>& rxTextProp
, bool bSupportsStacked
)
1147 if( rxTextProp
.is() )
1149 /* Chart2 expects rotation angle as double value in range of [0,360).
1150 OOXML counts clockwise, Chart2 counts counterclockwise. */
1151 double fAngle
= rxTextProp
->getTextProperties().moRotation
.get( 0 );
1152 fAngle
= getDoubleIntervalValue
< double >( -fAngle
/ 60000.0, 0.0, 360.0 );
1153 rPropSet
.setProperty( PROP_TextRotation
, fAngle
);
1155 if( bSupportsStacked
)
1157 sal_Int32 nVert
= rxTextProp
->getTextProperties().moVert
.get( XML_horz
);
1158 bool bStacked
= (nVert
== XML_wordArtVert
) || (nVert
== XML_wordArtVertRtl
);
1159 rPropSet
.setProperty( PROP_StackCharacters
, bStacked
);
1164 void ObjectFormatter::convertNumberFormat( PropertySet
& rPropSet
, const NumberFormat
& rNumberFormat
, bool bPercentFormat
)
1166 if( mxData
->mxNumFmts
.is() )
1168 sal_Int32 nPropId
= bPercentFormat
? PROP_PercentageNumberFormat
: PROP_NumberFormat
;
1169 if( rNumberFormat
.mbSourceLinked
|| (rNumberFormat
.maFormatCode
.getLength() == 0) )
1171 rPropSet
.setProperty( nPropId
, Any() );
1175 sal_Int32 nIndex
= rNumberFormat
.maFormatCode
.equalsIgnoreAsciiCaseAscii( "general" ) ?
1176 mxData
->mxNumTypes
->getStandardIndex( mxData
->maFromLocale
) :
1177 mxData
->mxNumFmts
->addNewConverted( rNumberFormat
.maFormatCode
, mxData
->maEnUsLocale
, mxData
->maFromLocale
);
1179 rPropSet
.setProperty( nPropId
, nIndex
);
1184 OStringBuffer( "ObjectFormatter::convertNumberFormat - cannot create number format '" ).
1185 append( OUStringToOString( rNumberFormat
.maFormatCode
, osl_getThreadTextEncoding() ) ).append( '\'' ).getStr() );
1190 void ObjectFormatter::convertAutomaticLine( PropertySet
& rPropSet
, ObjectType eObjType
, sal_Int32 nSeriesIdx
)
1192 if( ObjectTypeFormatter
* pFormat
= mxData
->getTypeFormatter( eObjType
) )
1193 pFormat
->convertAutomaticLine( rPropSet
, nSeriesIdx
);
1196 void ObjectFormatter::convertAutomaticFill( PropertySet
& rPropSet
, ObjectType eObjType
, sal_Int32 nSeriesIdx
)
1198 if( ObjectTypeFormatter
* pFormat
= mxData
->getTypeFormatter( eObjType
) )
1199 pFormat
->convertAutomaticFill( rPropSet
, nSeriesIdx
);
1202 bool ObjectFormatter::isAutomaticLine( const ModelRef
< Shape
>& rxShapeProp
)
1204 return !rxShapeProp
|| !rxShapeProp
->getLineProperties().maLineFill
.moFillType
.has();
1207 bool ObjectFormatter::isAutomaticFill( const ModelRef
< Shape
>& rxShapeProp
)
1209 return !rxShapeProp
|| !rxShapeProp
->getFillProperties().moFillType
.has();
1212 // ============================================================================
1214 } // namespace chart
1215 } // namespace drawingml