Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "ChartTypeManager.hxx"
21 : #include "macros.hxx"
22 : #include "StackMode.hxx"
23 : #include "ContainerHelper.hxx"
24 :
25 : #include "CartesianCoordinateSystem.hxx"
26 :
27 : #include "LineChartTypeTemplate.hxx"
28 : #include "BarChartTypeTemplate.hxx"
29 : #include "ColumnLineChartTypeTemplate.hxx"
30 : #include "AreaChartTypeTemplate.hxx"
31 : #include "PieChartTypeTemplate.hxx"
32 : #include "ScatterChartTypeTemplate.hxx"
33 : #include "StockChartTypeTemplate.hxx"
34 : #include "NetChartTypeTemplate.hxx"
35 : #include "BubbleChartTypeTemplate.hxx"
36 : #include <cppuhelper/component_context.hxx>
37 : #include <comphelper/InlineContainer.hxx>
38 : #include <com/sun/star/container/XContentEnumerationAccess.hpp>
39 : #include <com/sun/star/lang/XServiceName.hpp>
40 : #include <com/sun/star/chart/ChartSolidType.hpp>
41 : #include <com/sun/star/chart2/CurveStyle.hpp>
42 :
43 : #include <algorithm>
44 : #include <iterator>
45 : #include <functional>
46 : #include <o3tl/compat_functional.hxx>
47 :
48 : using namespace ::com::sun::star;
49 :
50 : using ::com::sun::star::uno::Sequence;
51 : using ::com::sun::star::uno::Reference;
52 : using ::com::sun::star::uno::Any;
53 : using ::osl::MutexGuard;
54 :
55 : // ======================================================================
56 :
57 : namespace
58 : {
59 :
60 : enum TemplateId
61 : {
62 : TEMPLATE_SYMBOL,
63 : TEMPLATE_STACKEDSYMBOL,
64 : TEMPLATE_PERCENTSTACKEDSYMBOL,
65 : TEMPLATE_LINE,
66 : TEMPLATE_STACKEDLINE,
67 : TEMPLATE_PERCENTSTACKEDLINE,
68 : TEMPLATE_LINESYMBOL,
69 : TEMPLATE_STACKEDLINESYMBOL,
70 : TEMPLATE_PERCENTSTACKEDLINESYMBOL,
71 : TEMPLATE_THREEDLINE,
72 : TEMPLATE_STACKEDTHREEDLINE,
73 : TEMPLATE_PERCENTSTACKEDTHREEDLINE,
74 : TEMPLATE_THREEDLINEDEEP,
75 : TEMPLATE_COLUMN,
76 : TEMPLATE_STACKEDCOLUMN,
77 : TEMPLATE_PERCENTSTACKEDCOLUMN,
78 : TEMPLATE_BAR,
79 : TEMPLATE_STACKEDBAR,
80 : TEMPLATE_PERCENTSTACKEDBAR,
81 : TEMPLATE_THREEDCOLUMNDEEP,
82 : TEMPLATE_THREEDCOLUMNFLAT,
83 : TEMPLATE_STACKEDTHREEDCOLUMNFLAT,
84 : TEMPLATE_PERCENTSTACKEDTHREEDCOLUMNFLAT,
85 : TEMPLATE_THREEDBARDEEP,
86 : TEMPLATE_THREEDBARFLAT,
87 : TEMPLATE_STACKEDTHREEDBARFLAT,
88 : TEMPLATE_PERCENTSTACKEDTHREEDBARFLAT,
89 : TEMPLATE_COLUMNWITHLINE,
90 : TEMPLATE_STACKEDCOLUMNWITHLINE,
91 : TEMPLATE_AREA,
92 : TEMPLATE_STACKEDAREA,
93 : TEMPLATE_PERCENTSTACKEDAREA,
94 : TEMPLATE_THREEDAREA,
95 : TEMPLATE_STACKEDTHREEDAREA,
96 : TEMPLATE_PERCENTSTACKEDTHREEDAREA,
97 : TEMPLATE_PIE,
98 : TEMPLATE_PIEALLEXPLODED,
99 : TEMPLATE_DONUT,
100 : TEMPLATE_DONUTALLEXPLODED,
101 : TEMPLATE_THREEDPIE,
102 : TEMPLATE_THREEDPIEALLEXPLODED,
103 : TEMPLATE_THREEDDONUT,
104 : TEMPLATE_THREEDDONUTALLEXPLODED,
105 : TEMPLATE_SCATTERLINESYMBOL,
106 : TEMPLATE_SCATTERLINE,
107 : TEMPLATE_SCATTERSYMBOL,
108 : TEMPLATE_THREEDSCATTER,
109 : TEMPLATE_NET,
110 : TEMPLATE_NETSYMBOL,
111 : TEMPLATE_NETLINE,
112 : TEMPLATE_STACKEDNET,
113 : TEMPLATE_STACKEDNETSYMBOL,
114 : TEMPLATE_STACKEDNETLINE,
115 : TEMPLATE_PERCENTSTACKEDNET,
116 : TEMPLATE_PERCENTSTACKEDNETSYMBOL,
117 : TEMPLATE_PERCENTSTACKEDNETLINE,
118 : TEMPLATE_FILLEDNET,
119 : TEMPLATE_STACKEDFILLEDNET,
120 : TEMPLATE_PERCENTSTACKEDFILLEDNET,
121 : TEMPLATE_STOCKLOWHIGHCLOSE,
122 : TEMPLATE_STOCKOPENLOWHIGHCLOSE,
123 : TEMPLATE_STOCKVOLUMELOWHIGHCLOSE,
124 : TEMPLATE_STOCKVOLUMEOPENLOWHIGHCLOSE,
125 : TEMPLATE_BUBBLE,
126 : // TEMPLATE_SURFACE,
127 : // TEMPLATE_ADDIN,
128 : TEMPLATE_NOT_FOUND = 0xffff
129 : };
130 :
131 : typedef ::std::map< OUString, TemplateId > tTemplateMapType;
132 :
133 1340 : const tTemplateMapType & lcl_DefaultChartTypeMap()
134 : {
135 : static const tTemplateMapType aMap = tTemplateMapType(
136 : ::comphelper::MakeMap< tTemplateMapType::key_type, tTemplateMapType::mapped_type >
137 : ( "com.sun.star.chart2.template.Symbol", TEMPLATE_SYMBOL )
138 20 : ( "com.sun.star.chart2.template.StackedSymbol", TEMPLATE_STACKEDSYMBOL )
139 30 : ( "com.sun.star.chart2.template.PercentStackedSymbol", TEMPLATE_PERCENTSTACKEDSYMBOL )
140 30 : ( "com.sun.star.chart2.template.Line", TEMPLATE_LINE )
141 30 : ( "com.sun.star.chart2.template.StackedLine", TEMPLATE_STACKEDLINE )
142 30 : ( "com.sun.star.chart2.template.PercentStackedLine", TEMPLATE_PERCENTSTACKEDLINE )
143 30 : ( "com.sun.star.chart2.template.LineSymbol", TEMPLATE_LINESYMBOL )
144 30 : ( "com.sun.star.chart2.template.StackedLineSymbol", TEMPLATE_STACKEDLINESYMBOL )
145 30 : ( "com.sun.star.chart2.template.PercentStackedLineSymbol", TEMPLATE_PERCENTSTACKEDLINESYMBOL )
146 30 : ( "com.sun.star.chart2.template.ThreeDLine", TEMPLATE_THREEDLINE )
147 30 : ( "com.sun.star.chart2.template.StackedThreeDLine", TEMPLATE_STACKEDTHREEDLINE )
148 30 : ( "com.sun.star.chart2.template.PercentStackedThreeDLine", TEMPLATE_PERCENTSTACKEDTHREEDLINE )
149 30 : ( "com.sun.star.chart2.template.ThreeDLineDeep", TEMPLATE_THREEDLINEDEEP )
150 30 : ( "com.sun.star.chart2.template.Column", TEMPLATE_COLUMN )
151 30 : ( "com.sun.star.chart2.template.StackedColumn", TEMPLATE_STACKEDCOLUMN )
152 30 : ( "com.sun.star.chart2.template.PercentStackedColumn", TEMPLATE_PERCENTSTACKEDCOLUMN )
153 30 : ( "com.sun.star.chart2.template.Bar", TEMPLATE_BAR )
154 30 : ( "com.sun.star.chart2.template.StackedBar", TEMPLATE_STACKEDBAR )
155 30 : ( "com.sun.star.chart2.template.PercentStackedBar", TEMPLATE_PERCENTSTACKEDBAR )
156 30 : ( "com.sun.star.chart2.template.ThreeDColumnDeep", TEMPLATE_THREEDCOLUMNDEEP )
157 30 : ( "com.sun.star.chart2.template.ThreeDColumnFlat", TEMPLATE_THREEDCOLUMNFLAT )
158 30 : ( "com.sun.star.chart2.template.StackedThreeDColumnFlat", TEMPLATE_STACKEDTHREEDCOLUMNFLAT )
159 30 : ( "com.sun.star.chart2.template.PercentStackedThreeDColumnFlat", TEMPLATE_PERCENTSTACKEDTHREEDCOLUMNFLAT )
160 30 : ( "com.sun.star.chart2.template.ThreeDBarDeep", TEMPLATE_THREEDBARDEEP )
161 30 : ( "com.sun.star.chart2.template.ThreeDBarFlat", TEMPLATE_THREEDBARFLAT )
162 30 : ( "com.sun.star.chart2.template.StackedThreeDBarFlat", TEMPLATE_STACKEDTHREEDBARFLAT )
163 30 : ( "com.sun.star.chart2.template.PercentStackedThreeDBarFlat", TEMPLATE_PERCENTSTACKEDTHREEDBARFLAT )
164 30 : ( "com.sun.star.chart2.template.ColumnWithLine", TEMPLATE_COLUMNWITHLINE )
165 30 : ( "com.sun.star.chart2.template.StackedColumnWithLine", TEMPLATE_STACKEDCOLUMNWITHLINE )
166 30 : ( "com.sun.star.chart2.template.Area", TEMPLATE_AREA )
167 30 : ( "com.sun.star.chart2.template.StackedArea", TEMPLATE_STACKEDAREA )
168 30 : ( "com.sun.star.chart2.template.PercentStackedArea", TEMPLATE_PERCENTSTACKEDAREA )
169 30 : ( "com.sun.star.chart2.template.ThreeDArea", TEMPLATE_THREEDAREA )
170 30 : ( "com.sun.star.chart2.template.StackedThreeDArea", TEMPLATE_STACKEDTHREEDAREA )
171 30 : ( "com.sun.star.chart2.template.PercentStackedThreeDArea", TEMPLATE_PERCENTSTACKEDTHREEDAREA )
172 30 : ( "com.sun.star.chart2.template.Pie", TEMPLATE_PIE )
173 30 : ( "com.sun.star.chart2.template.PieAllExploded", TEMPLATE_PIEALLEXPLODED )
174 30 : ( "com.sun.star.chart2.template.Donut", TEMPLATE_DONUT )
175 30 : ( "com.sun.star.chart2.template.DonutAllExploded", TEMPLATE_DONUTALLEXPLODED )
176 30 : ( "com.sun.star.chart2.template.ThreeDPie", TEMPLATE_THREEDPIE )
177 30 : ( "com.sun.star.chart2.template.ThreeDPieAllExploded", TEMPLATE_THREEDPIEALLEXPLODED )
178 30 : ( "com.sun.star.chart2.template.ThreeDDonut", TEMPLATE_THREEDDONUT )
179 30 : ( "com.sun.star.chart2.template.ThreeDDonutAllExploded", TEMPLATE_THREEDDONUTALLEXPLODED )
180 30 : ( "com.sun.star.chart2.template.ScatterLineSymbol", TEMPLATE_SCATTERLINESYMBOL )
181 30 : ( "com.sun.star.chart2.template.ScatterLine", TEMPLATE_SCATTERLINE )
182 30 : ( "com.sun.star.chart2.template.ScatterSymbol", TEMPLATE_SCATTERSYMBOL )
183 30 : ( "com.sun.star.chart2.template.ThreeDScatter", TEMPLATE_THREEDSCATTER )
184 30 : ( "com.sun.star.chart2.template.Net", TEMPLATE_NET )
185 30 : ( "com.sun.star.chart2.template.NetSymbol", TEMPLATE_NETSYMBOL )
186 30 : ( "com.sun.star.chart2.template.NetLine", TEMPLATE_NETLINE )
187 30 : ( "com.sun.star.chart2.template.StackedNet", TEMPLATE_STACKEDNET )
188 30 : ( "com.sun.star.chart2.template.StackedNetSymbol", TEMPLATE_STACKEDNETSYMBOL )
189 30 : ( "com.sun.star.chart2.template.StackedNetLine", TEMPLATE_STACKEDNETLINE )
190 30 : ( "com.sun.star.chart2.template.PercentStackedNet", TEMPLATE_PERCENTSTACKEDNET )
191 30 : ( "com.sun.star.chart2.template.PercentStackedNetSymbol", TEMPLATE_PERCENTSTACKEDNETSYMBOL )
192 30 : ( "com.sun.star.chart2.template.PercentStackedNetLine", TEMPLATE_PERCENTSTACKEDNETLINE )
193 30 : ( "com.sun.star.chart2.template.FilledNet", TEMPLATE_FILLEDNET )
194 30 : ( "com.sun.star.chart2.template.StackedFilledNet", TEMPLATE_STACKEDFILLEDNET )
195 30 : ( "com.sun.star.chart2.template.PercentStackedFilledNet", TEMPLATE_PERCENTSTACKEDFILLEDNET )
196 30 : ( "com.sun.star.chart2.template.StockLowHighClose", TEMPLATE_STOCKLOWHIGHCLOSE )
197 30 : ( "com.sun.star.chart2.template.StockOpenLowHighClose", TEMPLATE_STOCKOPENLOWHIGHCLOSE )
198 30 : ( "com.sun.star.chart2.template.StockVolumeLowHighClose", TEMPLATE_STOCKVOLUMELOWHIGHCLOSE )
199 30 : ( "com.sun.star.chart2.template.StockVolumeOpenLowHighClose", TEMPLATE_STOCKVOLUMEOPENLOWHIGHCLOSE )
200 30 : ( "com.sun.star.chart2.template.Bubble", TEMPLATE_BUBBLE )
201 : // ( "com.sun.star.chart2.template.Surface", TEMPLATE_SURFACE )
202 : // ( "com.sun.star.chart2.template.Addin", TEMPLATE_ADDIN )
203 1350 : );
204 :
205 1340 : return aMap;
206 : }
207 :
208 1221 : TemplateId lcl_GetTemplateIdForService( const OUString & rServiceName )
209 : {
210 1221 : TemplateId eResult = TEMPLATE_NOT_FOUND;
211 1221 : const tTemplateMapType & rMap = lcl_DefaultChartTypeMap();
212 1221 : tTemplateMapType::const_iterator aIt( rMap.find( rServiceName ));
213 :
214 1221 : if( aIt != rMap.end())
215 1221 : eResult = (*aIt).second;
216 :
217 1221 : return eResult;
218 : }
219 :
220 : } // anonymous namespace
221 :
222 : namespace chart
223 : {
224 :
225 113 : ChartTypeManager::ChartTypeManager(
226 : uno::Reference<
227 : uno::XComponentContext > const & xContext ) :
228 113 : m_xContext( xContext )
229 113 : {}
230 :
231 226 : ChartTypeManager::~ChartTypeManager()
232 226 : {}
233 :
234 : // ____ XMultiServiceFactory ____
235 1221 : uno::Reference< uno::XInterface > SAL_CALL ChartTypeManager::createInstance(
236 : const OUString& aServiceSpecifier )
237 : throw (uno::Exception,
238 : uno::RuntimeException)
239 : {
240 1221 : uno::Reference< uno::XInterface > xResult;
241 1221 : TemplateId nId = lcl_GetTemplateIdForService( aServiceSpecifier );
242 :
243 1221 : if( nId == TEMPLATE_NOT_FOUND )
244 : {
245 : try
246 : {
247 0 : xResult = m_xContext->getServiceManager()->createInstanceWithContext(
248 0 : aServiceSpecifier, m_xContext );
249 : }
250 : // catch( registry::InvalidValueException & ex )
251 0 : catch( const uno::Exception & ex )
252 : {
253 : // couldn't create service via factory
254 :
255 : // As XMultiServiceFactory does not specify, what to do in case
256 : // createInstance is called with an unknown service-name, this
257 : // function will just return an empty XInterface.
258 : ASSERT_EXCEPTION( ex );
259 : SAL_WARN("chart2", "Couldn't instantiate service: "<< aServiceSpecifier );
260 0 : xResult.set( 0 );
261 : }
262 : }
263 : else
264 : {
265 1221 : uno::Reference< chart2::XChartTypeTemplate > xTemplate;
266 1221 : switch( nId )
267 : {
268 : // Point (category x axis)
269 : case TEMPLATE_SYMBOL:
270 : xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
271 0 : StackMode_NONE, true, false ));
272 0 : break;
273 : case TEMPLATE_STACKEDSYMBOL:
274 : xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
275 2 : StackMode_Y_STACKED, true, false ));
276 2 : break;
277 : case TEMPLATE_PERCENTSTACKEDSYMBOL:
278 : xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
279 21 : StackMode_Y_STACKED_PERCENT, true, false ));
280 21 : break;
281 : // Line (category x axis)
282 : case TEMPLATE_LINE:
283 : xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
284 43 : StackMode_NONE, false ));
285 43 : break;
286 : case TEMPLATE_STACKEDLINE:
287 : xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
288 2 : StackMode_Y_STACKED, false ));
289 2 : break;
290 : case TEMPLATE_PERCENTSTACKEDLINE:
291 : xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
292 21 : StackMode_Y_STACKED_PERCENT, false ));
293 21 : break;
294 : case TEMPLATE_LINESYMBOL:
295 : xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
296 21 : StackMode_NONE, true ));
297 21 : break;
298 : case TEMPLATE_STACKEDLINESYMBOL:
299 : xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
300 2 : StackMode_Y_STACKED, true ));
301 2 : break;
302 : case TEMPLATE_PERCENTSTACKEDLINESYMBOL:
303 : xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
304 21 : StackMode_Y_STACKED_PERCENT, true ));
305 21 : break;
306 : case TEMPLATE_THREEDLINE:
307 : xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
308 0 : StackMode_NONE, false, true, 3 ));
309 0 : break;
310 : case TEMPLATE_STACKEDTHREEDLINE:
311 : xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
312 2 : StackMode_Y_STACKED, false, true, 3 ));
313 2 : break;
314 : case TEMPLATE_PERCENTSTACKEDTHREEDLINE:
315 : xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
316 21 : StackMode_Y_STACKED_PERCENT, false, true, 3 ));
317 21 : break;
318 : case TEMPLATE_THREEDLINEDEEP:
319 : xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
320 0 : StackMode_Z_STACKED, false, true, 3 ));
321 0 : break;
322 :
323 : // Bar/Column
324 : case TEMPLATE_COLUMN:
325 : xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
326 193 : StackMode_NONE, BarChartTypeTemplate::VERTICAL ));
327 193 : break;
328 : case TEMPLATE_STACKEDCOLUMN:
329 : xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
330 2 : StackMode_Y_STACKED, BarChartTypeTemplate::VERTICAL ));
331 2 : break;
332 : case TEMPLATE_PERCENTSTACKEDCOLUMN:
333 : xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
334 21 : StackMode_Y_STACKED_PERCENT, BarChartTypeTemplate::VERTICAL ));
335 21 : break;
336 : case TEMPLATE_BAR:
337 : xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
338 119 : StackMode_NONE, BarChartTypeTemplate::HORIZONTAL ));
339 119 : break;
340 : case TEMPLATE_STACKEDBAR:
341 : xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
342 2 : StackMode_Y_STACKED, BarChartTypeTemplate::HORIZONTAL ));
343 2 : break;
344 : case TEMPLATE_PERCENTSTACKEDBAR:
345 : xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
346 21 : StackMode_Y_STACKED_PERCENT, BarChartTypeTemplate::HORIZONTAL ));
347 21 : break;
348 : case TEMPLATE_THREEDCOLUMNDEEP:
349 : xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
350 0 : StackMode_Z_STACKED, BarChartTypeTemplate::VERTICAL, 3 ));
351 0 : break;
352 : case TEMPLATE_THREEDCOLUMNFLAT:
353 : xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
354 0 : StackMode_NONE, BarChartTypeTemplate::VERTICAL, 3 ));
355 0 : break;
356 : case TEMPLATE_STACKEDTHREEDCOLUMNFLAT:
357 : xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
358 2 : StackMode_Y_STACKED, BarChartTypeTemplate::VERTICAL, 3 ));
359 2 : break;
360 : case TEMPLATE_PERCENTSTACKEDTHREEDCOLUMNFLAT:
361 : xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
362 21 : StackMode_Y_STACKED_PERCENT, BarChartTypeTemplate::VERTICAL, 3 ));
363 21 : break;
364 : case TEMPLATE_THREEDBARDEEP:
365 : xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
366 0 : StackMode_Z_STACKED, BarChartTypeTemplate::HORIZONTAL, 3 ));
367 0 : break;
368 : case TEMPLATE_THREEDBARFLAT:
369 : xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
370 0 : StackMode_NONE, BarChartTypeTemplate::HORIZONTAL, 3 ));
371 0 : break;
372 : case TEMPLATE_STACKEDTHREEDBARFLAT:
373 : xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
374 2 : StackMode_Y_STACKED, BarChartTypeTemplate::HORIZONTAL, 3 ));
375 2 : break;
376 : case TEMPLATE_PERCENTSTACKEDTHREEDBARFLAT:
377 : xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
378 21 : StackMode_Y_STACKED_PERCENT, BarChartTypeTemplate::HORIZONTAL, 3 ));
379 21 : break;
380 :
381 : // Combi-Chart Line/Column
382 : case TEMPLATE_COLUMNWITHLINE:
383 : case TEMPLATE_STACKEDCOLUMNWITHLINE:
384 : {
385 : StackMode eMode = ( nId == TEMPLATE_COLUMNWITHLINE )
386 : ? StackMode_NONE
387 35 : : StackMode_Y_STACKED;
388 :
389 35 : xTemplate.set( new ColumnLineChartTypeTemplate( m_xContext, aServiceSpecifier, eMode, 1 ));
390 : }
391 35 : break;
392 :
393 : // Area
394 : case TEMPLATE_AREA:
395 119 : xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode_NONE ));
396 119 : break;
397 : case TEMPLATE_STACKEDAREA:
398 2 : xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode_Y_STACKED ));
399 2 : break;
400 : case TEMPLATE_PERCENTSTACKEDAREA:
401 21 : xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode_Y_STACKED_PERCENT ));
402 21 : break;
403 : case TEMPLATE_THREEDAREA:
404 0 : xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode_Z_STACKED, 3 ));
405 0 : break;
406 : case TEMPLATE_STACKEDTHREEDAREA:
407 2 : xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode_Y_STACKED, 3 ));
408 2 : break;
409 : case TEMPLATE_PERCENTSTACKEDTHREEDAREA:
410 21 : xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode_Y_STACKED_PERCENT, 3 ));
411 21 : break;
412 :
413 : case TEMPLATE_PIE:
414 : xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
415 23 : chart2::PieChartOffsetMode_NONE, false ));
416 23 : break;
417 : case TEMPLATE_PIEALLEXPLODED:
418 : xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
419 18 : chart2::PieChartOffsetMode_ALL_EXPLODED, false ));
420 18 : break;
421 : case TEMPLATE_DONUT:
422 : xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
423 33 : chart2::PieChartOffsetMode_NONE, true ));
424 33 : break;
425 : case TEMPLATE_DONUTALLEXPLODED:
426 : xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
427 33 : chart2::PieChartOffsetMode_ALL_EXPLODED, true ));
428 33 : break;
429 : case TEMPLATE_THREEDPIE:
430 : xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
431 0 : chart2::PieChartOffsetMode_NONE, false, 3 ));
432 0 : break;
433 : case TEMPLATE_THREEDPIEALLEXPLODED:
434 : xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
435 0 : chart2::PieChartOffsetMode_ALL_EXPLODED, false, 3 ));
436 0 : break;
437 : case TEMPLATE_THREEDDONUT:
438 : xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
439 0 : chart2::PieChartOffsetMode_NONE, true, 3 ));
440 0 : break;
441 : case TEMPLATE_THREEDDONUTALLEXPLODED:
442 : xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
443 0 : chart2::PieChartOffsetMode_ALL_EXPLODED, true, 3 ));
444 0 : break;
445 :
446 : case TEMPLATE_SCATTERLINESYMBOL:
447 21 : xTemplate.set( new ScatterChartTypeTemplate( m_xContext, aServiceSpecifier, /* bSymbols */ true ));
448 21 : break;
449 : case TEMPLATE_SCATTERLINE:
450 18 : xTemplate.set( new ScatterChartTypeTemplate( m_xContext, aServiceSpecifier, /* bSymbols */ false ));
451 18 : break;
452 : case TEMPLATE_SCATTERSYMBOL:
453 4 : xTemplate.set( new ScatterChartTypeTemplate( m_xContext, aServiceSpecifier, /* bSymbols */ true, /* bHasLines */ false ));
454 4 : break;
455 : case TEMPLATE_THREEDSCATTER:
456 0 : xTemplate.set( new ScatterChartTypeTemplate( m_xContext, aServiceSpecifier, /* bSymbols */ false, /* bHasLines */ true, 3 ));
457 0 : break;
458 :
459 : // NetChart
460 : case TEMPLATE_NET:
461 : xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
462 21 : StackMode_NONE, true ));
463 21 : break;
464 : case TEMPLATE_NETSYMBOL:
465 : xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
466 21 : StackMode_NONE, true, false ));
467 21 : break;
468 : case TEMPLATE_NETLINE:
469 : xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
470 21 : StackMode_NONE, false ));
471 21 : break;
472 :
473 : case TEMPLATE_STACKEDNET:
474 : xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
475 2 : StackMode_Y_STACKED, true ));
476 2 : break;
477 : case TEMPLATE_STACKEDNETSYMBOL:
478 : xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
479 2 : StackMode_Y_STACKED, true, false ));
480 2 : break;
481 : case TEMPLATE_STACKEDNETLINE:
482 : xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
483 2 : StackMode_Y_STACKED, false, true ));
484 2 : break;
485 :
486 : case TEMPLATE_PERCENTSTACKEDNET:
487 : xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
488 21 : StackMode_Y_STACKED_PERCENT, true ));
489 21 : break;
490 : case TEMPLATE_PERCENTSTACKEDNETSYMBOL:
491 : xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
492 21 : StackMode_Y_STACKED_PERCENT, true, false ));
493 21 : break;
494 : case TEMPLATE_PERCENTSTACKEDNETLINE:
495 : xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
496 21 : StackMode_Y_STACKED_PERCENT, false, true ));
497 21 : break;
498 :
499 : case TEMPLATE_FILLEDNET:
500 : xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
501 33 : StackMode_NONE, false, false, true ));
502 33 : break;
503 : case TEMPLATE_STACKEDFILLEDNET:
504 : xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
505 2 : StackMode_Y_STACKED, false, false, true ));
506 2 : break;
507 : case TEMPLATE_PERCENTSTACKEDFILLEDNET:
508 : xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
509 21 : StackMode_Y_STACKED_PERCENT, false, false, true ));
510 21 : break;
511 :
512 : case TEMPLATE_STOCKLOWHIGHCLOSE:
513 : xTemplate.set( new StockChartTypeTemplate( m_xContext, aServiceSpecifier,
514 4 : StockChartTypeTemplate::LOW_HI_CLOSE, false ));
515 4 : break;
516 : case TEMPLATE_STOCKOPENLOWHIGHCLOSE:
517 : xTemplate.set( new StockChartTypeTemplate( m_xContext, aServiceSpecifier,
518 0 : StockChartTypeTemplate::OPEN_LOW_HI_CLOSE, true ));
519 0 : break;
520 : case TEMPLATE_STOCKVOLUMELOWHIGHCLOSE:
521 : xTemplate.set( new StockChartTypeTemplate( m_xContext, aServiceSpecifier,
522 0 : StockChartTypeTemplate::VOL_LOW_HI_CLOSE, false ));
523 0 : break;
524 : case TEMPLATE_STOCKVOLUMEOPENLOWHIGHCLOSE:
525 : xTemplate.set( new StockChartTypeTemplate( m_xContext, aServiceSpecifier,
526 0 : StockChartTypeTemplate::VOL_OPEN_LOW_HI_CLOSE, true ));
527 0 : break;
528 :
529 : //BubbleChart
530 : case TEMPLATE_BUBBLE:
531 119 : xTemplate.set( new BubbleChartTypeTemplate( m_xContext, aServiceSpecifier ));
532 119 : break;
533 :
534 : // case TEMPLATE_SURFACE:
535 : // case TEMPLATE_ADDIN:
536 : // break;
537 :
538 : case TEMPLATE_NOT_FOUND:
539 : OSL_ASSERT( false );
540 0 : break;
541 : }
542 1221 : xResult.set( xTemplate, uno::UNO_QUERY );
543 : }
544 :
545 1221 : return xResult;
546 : }
547 :
548 0 : uno::Reference< uno::XInterface > SAL_CALL ChartTypeManager::createInstanceWithArguments(
549 : const OUString& ServiceSpecifier,
550 : const uno::Sequence< uno::Any >& /* Arguments */ )
551 : throw (uno::Exception,
552 : uno::RuntimeException)
553 : {
554 : OSL_FAIL( "createInstanceWithArguments: No arguments supported" );
555 0 : return createInstance( ServiceSpecifier );
556 : }
557 :
558 119 : uno::Sequence< OUString > SAL_CALL ChartTypeManager::getAvailableServiceNames()
559 : throw (uno::RuntimeException)
560 : {
561 119 : ::std::vector< OUString > aServices;
562 119 : const tTemplateMapType & rMap = lcl_DefaultChartTypeMap();
563 119 : aServices.reserve( rMap.size());
564 :
565 : // get own default templates
566 : ::std::transform( rMap.begin(), rMap.end(), ::std::back_inserter( aServices ),
567 119 : ::o3tl::select1st< tTemplateMapType::value_type >());
568 :
569 : // add components that were registered in the context's factory
570 : uno::Reference< container::XContentEnumerationAccess > xEnumAcc(
571 238 : m_xContext->getServiceManager(), uno::UNO_QUERY );
572 119 : if( xEnumAcc.is())
573 : {
574 : uno::Reference< container::XEnumeration > xEnum(
575 119 : xEnumAcc->createContentEnumeration( "com.sun.star.chart2.ChartTypeTemplate" ));
576 119 : if( xEnum.is())
577 : {
578 119 : uno::Reference< uno::XInterface > xFactIntf;
579 :
580 238 : while( xEnum->hasMoreElements())
581 : {
582 0 : if( xEnum->nextElement() >>= xFactIntf )
583 : {
584 0 : uno::Reference< lang::XServiceName > xServiceName( xFactIntf, uno::UNO_QUERY );
585 0 : if( xServiceName.is())
586 0 : aServices.push_back( xServiceName->getServiceName());
587 : }
588 119 : }
589 119 : }
590 : }
591 :
592 238 : return ContainerHelper::ContainerToSequence( aServices );
593 : }
594 :
595 : // ____ XServiceInfo ____
596 10 : Sequence< OUString > ChartTypeManager::getSupportedServiceNames_Static()
597 : {
598 10 : Sequence< OUString > aServices( 2 );
599 10 : aServices[ 0 ] = "com.sun.star.chart2.ChartTypeManager";
600 10 : aServices[ 1 ] = "com.sun.star.lang.MultiServiceFactory";
601 10 : return aServices;
602 : }
603 :
604 : // ================================================================================
605 :
606 : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
607 139 : APPHELPER_XSERVICEINFO_IMPL( ChartTypeManager,
608 : OUString("com.sun.star.comp.chart.ChartTypeManager") );
609 : } // namespace chart
610 :
611 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|