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