Gtk-WARNING gtktreestore.c:1047: Invalid column number 1 added to iter
[LibreOffice.git] / chart2 / source / model / template / ChartTypeManager.cxx
blobdeb70d9aa03c8d7d5706bf78bb554125dbdbcc20
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <ChartTypeManager.hxx>
21 #include <StackMode.hxx>
23 #include "LineChartTypeTemplate.hxx"
24 #include "BarChartTypeTemplate.hxx"
25 #include "ColumnLineChartTypeTemplate.hxx"
26 #include "HistogramChartTypeTemplate.hxx"
27 #include "AreaChartTypeTemplate.hxx"
28 #include "PieChartTypeTemplate.hxx"
29 #include "ScatterChartTypeTemplate.hxx"
30 #include "StockChartTypeTemplate.hxx"
31 #include "NetChartTypeTemplate.hxx"
32 #include "BubbleChartTypeTemplate.hxx"
33 #include <cppuhelper/supportsservice.hxx>
34 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
35 #include <com/sun/star/lang/XServiceName.hpp>
36 #include <com/sun/star/uno/XComponentContext.hpp>
37 #include <sal/log.hxx>
39 #include <algorithm>
40 #include <iterator>
41 #include <o3tl/functional.hxx>
42 #include <map>
43 #include <utility>
45 using namespace ::com::sun::star;
47 using ::com::sun::star::uno::Sequence;
49 namespace
52 enum TemplateId
54 TEMPLATE_SYMBOL,
55 TEMPLATE_STACKEDSYMBOL,
56 TEMPLATE_PERCENTSTACKEDSYMBOL,
57 TEMPLATE_LINE,
58 TEMPLATE_STACKEDLINE,
59 TEMPLATE_PERCENTSTACKEDLINE,
60 TEMPLATE_LINESYMBOL,
61 TEMPLATE_STACKEDLINESYMBOL,
62 TEMPLATE_PERCENTSTACKEDLINESYMBOL,
63 TEMPLATE_THREEDLINE,
64 TEMPLATE_STACKEDTHREEDLINE,
65 TEMPLATE_PERCENTSTACKEDTHREEDLINE,
66 TEMPLATE_THREEDLINEDEEP,
67 TEMPLATE_COLUMN,
68 TEMPLATE_STACKEDCOLUMN,
69 TEMPLATE_PERCENTSTACKEDCOLUMN,
70 TEMPLATE_BAR,
71 TEMPLATE_STACKEDBAR,
72 TEMPLATE_PERCENTSTACKEDBAR,
73 TEMPLATE_THREEDCOLUMNDEEP,
74 TEMPLATE_THREEDCOLUMNFLAT,
75 TEMPLATE_STACKEDTHREEDCOLUMNFLAT,
76 TEMPLATE_PERCENTSTACKEDTHREEDCOLUMNFLAT,
77 TEMPLATE_THREEDBARDEEP,
78 TEMPLATE_THREEDBARFLAT,
79 TEMPLATE_STACKEDTHREEDBARFLAT,
80 TEMPLATE_PERCENTSTACKEDTHREEDBARFLAT,
81 TEMPLATE_COLUMNWITHLINE,
82 TEMPLATE_STACKEDCOLUMNWITHLINE,
83 TEMPLATE_HISTOGRAM,
84 TEMPLATE_AREA,
85 TEMPLATE_STACKEDAREA,
86 TEMPLATE_PERCENTSTACKEDAREA,
87 TEMPLATE_THREEDAREA,
88 TEMPLATE_STACKEDTHREEDAREA,
89 TEMPLATE_PERCENTSTACKEDTHREEDAREA,
90 TEMPLATE_PIE,
91 TEMPLATE_PIEALLEXPLODED,
92 TEMPLATE_DONUT,
93 TEMPLATE_DONUTALLEXPLODED,
94 TEMPLATE_BAROFPIE,
95 TEMPLATE_PIEOFPIE,
96 TEMPLATE_THREEDPIE,
97 TEMPLATE_THREEDPIEALLEXPLODED,
98 TEMPLATE_THREEDDONUT,
99 TEMPLATE_THREEDDONUTALLEXPLODED,
100 TEMPLATE_SCATTERLINESYMBOL,
101 TEMPLATE_SCATTERLINE,
102 TEMPLATE_SCATTERSYMBOL,
103 TEMPLATE_THREEDSCATTER,
104 TEMPLATE_NET,
105 TEMPLATE_NETSYMBOL,
106 TEMPLATE_NETLINE,
107 TEMPLATE_STACKEDNET,
108 TEMPLATE_STACKEDNETSYMBOL,
109 TEMPLATE_STACKEDNETLINE,
110 TEMPLATE_PERCENTSTACKEDNET,
111 TEMPLATE_PERCENTSTACKEDNETSYMBOL,
112 TEMPLATE_PERCENTSTACKEDNETLINE,
113 TEMPLATE_FILLEDNET,
114 TEMPLATE_STACKEDFILLEDNET,
115 TEMPLATE_PERCENTSTACKEDFILLEDNET,
116 TEMPLATE_STOCKLOWHIGHCLOSE,
117 TEMPLATE_STOCKOPENLOWHIGHCLOSE,
118 TEMPLATE_STOCKVOLUMELOWHIGHCLOSE,
119 TEMPLATE_STOCKVOLUMEOPENLOWHIGHCLOSE,
120 TEMPLATE_BUBBLE,
121 // TEMPLATE_SURFACE,
122 // TEMPLATE_ADDIN,
123 TEMPLATE_NOT_FOUND = 0xffff
126 typedef std::map< OUString, TemplateId > tTemplateMapType;
128 const tTemplateMapType & lcl_DefaultChartTypeMap()
130 static const tTemplateMapType aMap{
131 {"com.sun.star.chart2.template.Symbol", TEMPLATE_SYMBOL},
132 {"com.sun.star.chart2.template.StackedSymbol", TEMPLATE_STACKEDSYMBOL},
133 {"com.sun.star.chart2.template.PercentStackedSymbol", TEMPLATE_PERCENTSTACKEDSYMBOL},
134 {"com.sun.star.chart2.template.Line", TEMPLATE_LINE},
135 {"com.sun.star.chart2.template.StackedLine", TEMPLATE_STACKEDLINE},
136 {"com.sun.star.chart2.template.PercentStackedLine", TEMPLATE_PERCENTSTACKEDLINE},
137 {"com.sun.star.chart2.template.LineSymbol", TEMPLATE_LINESYMBOL},
138 {"com.sun.star.chart2.template.StackedLineSymbol", TEMPLATE_STACKEDLINESYMBOL},
139 {"com.sun.star.chart2.template.PercentStackedLineSymbol", TEMPLATE_PERCENTSTACKEDLINESYMBOL},
140 {"com.sun.star.chart2.template.ThreeDLine", TEMPLATE_THREEDLINE},
141 {"com.sun.star.chart2.template.StackedThreeDLine", TEMPLATE_STACKEDTHREEDLINE},
142 {"com.sun.star.chart2.template.PercentStackedThreeDLine", TEMPLATE_PERCENTSTACKEDTHREEDLINE},
143 {"com.sun.star.chart2.template.ThreeDLineDeep", TEMPLATE_THREEDLINEDEEP},
144 {"com.sun.star.chart2.template.Column", TEMPLATE_COLUMN},
145 {"com.sun.star.chart2.template.StackedColumn", TEMPLATE_STACKEDCOLUMN},
146 {"com.sun.star.chart2.template.PercentStackedColumn", TEMPLATE_PERCENTSTACKEDCOLUMN},
147 {"com.sun.star.chart2.template.Bar", TEMPLATE_BAR},
148 {"com.sun.star.chart2.template.StackedBar", TEMPLATE_STACKEDBAR},
149 {"com.sun.star.chart2.template.PercentStackedBar", TEMPLATE_PERCENTSTACKEDBAR},
150 {"com.sun.star.chart2.template.ThreeDColumnDeep", TEMPLATE_THREEDCOLUMNDEEP},
151 {"com.sun.star.chart2.template.ThreeDColumnFlat", TEMPLATE_THREEDCOLUMNFLAT},
152 {"com.sun.star.chart2.template.StackedThreeDColumnFlat", TEMPLATE_STACKEDTHREEDCOLUMNFLAT},
153 {"com.sun.star.chart2.template.PercentStackedThreeDColumnFlat", TEMPLATE_PERCENTSTACKEDTHREEDCOLUMNFLAT},
154 {"com.sun.star.chart2.template.ThreeDBarDeep", TEMPLATE_THREEDBARDEEP},
155 {"com.sun.star.chart2.template.ThreeDBarFlat", TEMPLATE_THREEDBARFLAT},
156 {"com.sun.star.chart2.template.StackedThreeDBarFlat", TEMPLATE_STACKEDTHREEDBARFLAT},
157 {"com.sun.star.chart2.template.PercentStackedThreeDBarFlat", TEMPLATE_PERCENTSTACKEDTHREEDBARFLAT},
158 {"com.sun.star.chart2.template.ColumnWithLine", TEMPLATE_COLUMNWITHLINE},
159 {"com.sun.star.chart2.template.StackedColumnWithLine", TEMPLATE_STACKEDCOLUMNWITHLINE},
160 {"com.sun.star.chart2.template.Histogram", TEMPLATE_HISTOGRAM},
161 {"com.sun.star.chart2.template.Area", TEMPLATE_AREA},
162 {"com.sun.star.chart2.template.StackedArea", TEMPLATE_STACKEDAREA},
163 {"com.sun.star.chart2.template.PercentStackedArea", TEMPLATE_PERCENTSTACKEDAREA},
164 {"com.sun.star.chart2.template.ThreeDArea", TEMPLATE_THREEDAREA},
165 {"com.sun.star.chart2.template.StackedThreeDArea", TEMPLATE_STACKEDTHREEDAREA},
166 {"com.sun.star.chart2.template.PercentStackedThreeDArea", TEMPLATE_PERCENTSTACKEDTHREEDAREA},
167 {"com.sun.star.chart2.template.Pie", TEMPLATE_PIE},
168 {"com.sun.star.chart2.template.PieAllExploded", TEMPLATE_PIEALLEXPLODED},
169 {"com.sun.star.chart2.template.Donut", TEMPLATE_DONUT},
170 {"com.sun.star.chart2.template.DonutAllExploded", TEMPLATE_DONUTALLEXPLODED},
171 {"com.sun.star.chart2.template.BarOfPie", TEMPLATE_BAROFPIE},
172 {"com.sun.star.chart2.template.PieOfPie", TEMPLATE_PIEOFPIE},
173 {"com.sun.star.chart2.template.DonutAllExploded", TEMPLATE_DONUTALLEXPLODED},
174 {"com.sun.star.chart2.template.ThreeDPie", TEMPLATE_THREEDPIE},
175 {"com.sun.star.chart2.template.ThreeDPieAllExploded", TEMPLATE_THREEDPIEALLEXPLODED},
176 {"com.sun.star.chart2.template.ThreeDDonut", TEMPLATE_THREEDDONUT},
177 {"com.sun.star.chart2.template.ThreeDDonutAllExploded", TEMPLATE_THREEDDONUTALLEXPLODED},
178 {"com.sun.star.chart2.template.ScatterLineSymbol", TEMPLATE_SCATTERLINESYMBOL},
179 {"com.sun.star.chart2.template.ScatterLine", TEMPLATE_SCATTERLINE},
180 {"com.sun.star.chart2.template.ScatterSymbol", TEMPLATE_SCATTERSYMBOL},
181 {"com.sun.star.chart2.template.ThreeDScatter", TEMPLATE_THREEDSCATTER},
182 {"com.sun.star.chart2.template.Net", TEMPLATE_NET},
183 {"com.sun.star.chart2.template.NetSymbol", TEMPLATE_NETSYMBOL},
184 {"com.sun.star.chart2.template.NetLine", TEMPLATE_NETLINE},
185 {"com.sun.star.chart2.template.StackedNet", TEMPLATE_STACKEDNET},
186 {"com.sun.star.chart2.template.StackedNetSymbol", TEMPLATE_STACKEDNETSYMBOL},
187 {"com.sun.star.chart2.template.StackedNetLine", TEMPLATE_STACKEDNETLINE},
188 {"com.sun.star.chart2.template.PercentStackedNet", TEMPLATE_PERCENTSTACKEDNET},
189 {"com.sun.star.chart2.template.PercentStackedNetSymbol", TEMPLATE_PERCENTSTACKEDNETSYMBOL},
190 {"com.sun.star.chart2.template.PercentStackedNetLine", TEMPLATE_PERCENTSTACKEDNETLINE},
191 {"com.sun.star.chart2.template.FilledNet", TEMPLATE_FILLEDNET},
192 {"com.sun.star.chart2.template.StackedFilledNet", TEMPLATE_STACKEDFILLEDNET},
193 {"com.sun.star.chart2.template.PercentStackedFilledNet", TEMPLATE_PERCENTSTACKEDFILLEDNET},
194 {"com.sun.star.chart2.template.StockLowHighClose", TEMPLATE_STOCKLOWHIGHCLOSE},
195 {"com.sun.star.chart2.template.StockOpenLowHighClose", TEMPLATE_STOCKOPENLOWHIGHCLOSE},
196 {"com.sun.star.chart2.template.StockVolumeLowHighClose", TEMPLATE_STOCKVOLUMELOWHIGHCLOSE},
197 {"com.sun.star.chart2.template.StockVolumeOpenLowHighClose", TEMPLATE_STOCKVOLUMEOPENLOWHIGHCLOSE},
198 {"com.sun.star.chart2.template.Bubble", TEMPLATE_BUBBLE},
199 // {"com.sun.star.chart2.template.Surface", TEMPLATE_SURFACE},
200 // {"com.sun.star.chart2.template.Addin", TEMPLATE_ADDIN},
202 return aMap;
205 TemplateId lcl_GetTemplateIdForService( const OUString & rServiceName )
207 TemplateId eResult = TEMPLATE_NOT_FOUND;
208 const tTemplateMapType & rMap = lcl_DefaultChartTypeMap();
209 tTemplateMapType::const_iterator aIt( rMap.find( rServiceName ));
211 if( aIt != rMap.end())
212 eResult = (*aIt).second;
214 return eResult;
217 } // anonymous namespace
219 namespace chart
222 ChartTypeManager::ChartTypeManager(
223 uno::Reference<
224 uno::XComponentContext > xContext ) :
225 m_xContext(std::move( xContext ))
228 ChartTypeManager::~ChartTypeManager()
231 // ____ XMultiServiceFactory ____
232 uno::Reference< uno::XInterface > SAL_CALL ChartTypeManager::createInstance(
233 const OUString& aServiceSpecifier )
235 return static_cast<cppu::OWeakObject*>(createTemplate(aServiceSpecifier).get());
238 rtl::Reference< ::chart::ChartTypeTemplate > ChartTypeManager::createTemplate(
239 const OUString& aServiceSpecifier )
241 TemplateId nId = lcl_GetTemplateIdForService( aServiceSpecifier );
243 rtl::Reference< ::chart::ChartTypeTemplate > xTemplate;
244 switch( nId )
246 // Point (category x axis)
247 case TEMPLATE_SYMBOL:
248 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
249 StackMode::NONE, true, false ));
250 break;
251 case TEMPLATE_STACKEDSYMBOL:
252 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
253 StackMode::YStacked, true, false ));
254 break;
255 case TEMPLATE_PERCENTSTACKEDSYMBOL:
256 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
257 StackMode::YStackedPercent, true, false ));
258 break;
259 // Line (category x axis)
260 case TEMPLATE_LINE:
261 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
262 StackMode::NONE, false ));
263 break;
264 case TEMPLATE_STACKEDLINE:
265 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
266 StackMode::YStacked, false ));
267 break;
268 case TEMPLATE_PERCENTSTACKEDLINE:
269 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
270 StackMode::YStackedPercent, false ));
271 break;
272 case TEMPLATE_LINESYMBOL:
273 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
274 StackMode::NONE, true ));
275 break;
276 case TEMPLATE_STACKEDLINESYMBOL:
277 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
278 StackMode::YStacked, true ));
279 break;
280 case TEMPLATE_PERCENTSTACKEDLINESYMBOL:
281 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
282 StackMode::YStackedPercent, true ));
283 break;
284 case TEMPLATE_THREEDLINE:
285 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
286 StackMode::NONE, false, true, 3 ));
287 break;
288 case TEMPLATE_STACKEDTHREEDLINE:
289 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
290 StackMode::YStacked, false, true, 3 ));
291 break;
292 case TEMPLATE_PERCENTSTACKEDTHREEDLINE:
293 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
294 StackMode::YStackedPercent, false, true, 3 ));
295 break;
296 case TEMPLATE_THREEDLINEDEEP:
297 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
298 StackMode::ZStacked, false, true, 3 ));
299 break;
301 // Bar/Column
302 case TEMPLATE_COLUMN:
303 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
304 StackMode::NONE, BarChartTypeTemplate::VERTICAL ));
305 break;
306 case TEMPLATE_STACKEDCOLUMN:
307 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
308 StackMode::YStacked, BarChartTypeTemplate::VERTICAL ));
309 break;
310 case TEMPLATE_PERCENTSTACKEDCOLUMN:
311 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
312 StackMode::YStackedPercent, BarChartTypeTemplate::VERTICAL ));
313 break;
314 case TEMPLATE_BAR:
315 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
316 StackMode::NONE, BarChartTypeTemplate::HORIZONTAL ));
317 break;
318 case TEMPLATE_STACKEDBAR:
319 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
320 StackMode::YStacked, BarChartTypeTemplate::HORIZONTAL ));
321 break;
322 case TEMPLATE_PERCENTSTACKEDBAR:
323 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
324 StackMode::YStackedPercent, BarChartTypeTemplate::HORIZONTAL ));
325 break;
326 case TEMPLATE_THREEDCOLUMNDEEP:
327 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
328 StackMode::ZStacked, BarChartTypeTemplate::VERTICAL, 3 ));
329 break;
330 case TEMPLATE_THREEDCOLUMNFLAT:
331 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
332 StackMode::NONE, BarChartTypeTemplate::VERTICAL, 3 ));
333 break;
334 case TEMPLATE_STACKEDTHREEDCOLUMNFLAT:
335 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
336 StackMode::YStacked, BarChartTypeTemplate::VERTICAL, 3 ));
337 break;
338 case TEMPLATE_PERCENTSTACKEDTHREEDCOLUMNFLAT:
339 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
340 StackMode::YStackedPercent, BarChartTypeTemplate::VERTICAL, 3 ));
341 break;
342 case TEMPLATE_THREEDBARDEEP:
343 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
344 StackMode::ZStacked, BarChartTypeTemplate::HORIZONTAL, 3 ));
345 break;
346 case TEMPLATE_THREEDBARFLAT:
347 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
348 StackMode::NONE, BarChartTypeTemplate::HORIZONTAL, 3 ));
349 break;
350 case TEMPLATE_STACKEDTHREEDBARFLAT:
351 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
352 StackMode::YStacked, BarChartTypeTemplate::HORIZONTAL, 3 ));
353 break;
354 case TEMPLATE_PERCENTSTACKEDTHREEDBARFLAT:
355 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
356 StackMode::YStackedPercent, BarChartTypeTemplate::HORIZONTAL, 3 ));
357 break;
359 // Combi-Chart Line/Column
360 case TEMPLATE_COLUMNWITHLINE:
361 case TEMPLATE_STACKEDCOLUMNWITHLINE:
363 StackMode eMode = ( nId == TEMPLATE_COLUMNWITHLINE )
364 ? StackMode::NONE
365 : StackMode::YStacked;
367 xTemplate.set( new ColumnLineChartTypeTemplate( m_xContext, aServiceSpecifier, eMode, 1 ));
369 break;
371 // Histogram
372 case TEMPLATE_HISTOGRAM:
373 xTemplate.set( new HistogramChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode::NONE ));
374 break;
376 // Area
377 case TEMPLATE_AREA:
378 xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode::NONE ));
379 break;
380 case TEMPLATE_STACKEDAREA:
381 xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode::YStacked ));
382 break;
383 case TEMPLATE_PERCENTSTACKEDAREA:
384 xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode::YStackedPercent ));
385 break;
386 case TEMPLATE_THREEDAREA:
387 xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode::ZStacked, 3 ));
388 break;
389 case TEMPLATE_STACKEDTHREEDAREA:
390 xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode::YStacked, 3 ));
391 break;
392 case TEMPLATE_PERCENTSTACKEDTHREEDAREA:
393 xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode::YStackedPercent, 3 ));
394 break;
396 case TEMPLATE_PIE:
397 xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
398 chart2::PieChartOffsetMode_NONE, false,
399 chart2::PieChartSubType_NONE, 3, 2));
400 break;
401 case TEMPLATE_PIEALLEXPLODED:
402 xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
403 chart2::PieChartOffsetMode_ALL_EXPLODED, false,
404 chart2::PieChartSubType_NONE, 3, 2 ));
405 break;
406 case TEMPLATE_DONUT:
407 xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
408 chart2::PieChartOffsetMode_NONE, true,
409 chart2::PieChartSubType_NONE, 3, 2 ));
410 break;
411 case TEMPLATE_DONUTALLEXPLODED:
412 xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
413 chart2::PieChartOffsetMode_ALL_EXPLODED, true,
414 chart2::PieChartSubType_NONE, 3, 2 ));
415 break;
416 case TEMPLATE_BAROFPIE:
417 xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
418 chart2::PieChartOffsetMode_NONE, false,
419 chart2::PieChartSubType_BAR, 3, 2 ));
420 break;
421 case TEMPLATE_PIEOFPIE:
422 xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
423 chart2::PieChartOffsetMode_NONE, false,
424 chart2::PieChartSubType_PIE, 3, 2 ));
425 break;
426 case TEMPLATE_THREEDPIE:
427 xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
428 chart2::PieChartOffsetMode_NONE, false,
429 chart2::PieChartSubType_NONE, 3, 3 ));
430 break;
431 case TEMPLATE_THREEDPIEALLEXPLODED:
432 xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
433 chart2::PieChartOffsetMode_ALL_EXPLODED, false,
434 chart2::PieChartSubType_NONE, 3, 3 ));
435 break;
436 case TEMPLATE_THREEDDONUT:
437 xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
438 chart2::PieChartOffsetMode_NONE, true,
439 chart2::PieChartSubType_NONE, 3, 3 ));
440 break;
441 case TEMPLATE_THREEDDONUTALLEXPLODED:
442 xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
443 chart2::PieChartOffsetMode_ALL_EXPLODED, true,
444 chart2::PieChartSubType_NONE, 3, 3 ));
445 break;
447 case TEMPLATE_SCATTERLINESYMBOL:
448 xTemplate.set( new ScatterChartTypeTemplate( m_xContext, aServiceSpecifier, /* bSymbols */ true ));
449 break;
450 case TEMPLATE_SCATTERLINE:
451 xTemplate.set( new ScatterChartTypeTemplate( m_xContext, aServiceSpecifier, /* bSymbols */ false ));
452 break;
453 case TEMPLATE_SCATTERSYMBOL:
454 xTemplate.set( new ScatterChartTypeTemplate( m_xContext, aServiceSpecifier, /* bSymbols */ true, /* bHasLines */ false ));
455 break;
456 case TEMPLATE_THREEDSCATTER:
457 xTemplate.set( new ScatterChartTypeTemplate( m_xContext, aServiceSpecifier, /* bSymbols */ false, /* bHasLines */ true, 3 ));
458 break;
460 // NetChart
461 case TEMPLATE_NET:
462 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
463 StackMode::NONE, true ));
464 break;
465 case TEMPLATE_NETSYMBOL:
466 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
467 StackMode::NONE, true, false ));
468 break;
469 case TEMPLATE_NETLINE:
470 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
471 StackMode::NONE, false ));
472 break;
474 case TEMPLATE_STACKEDNET:
475 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
476 StackMode::YStacked, true ));
477 break;
478 case TEMPLATE_STACKEDNETSYMBOL:
479 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
480 StackMode::YStacked, true, false ));
481 break;
482 case TEMPLATE_STACKEDNETLINE:
483 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
484 StackMode::YStacked, false, true ));
485 break;
487 case TEMPLATE_PERCENTSTACKEDNET:
488 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
489 StackMode::YStackedPercent, true ));
490 break;
491 case TEMPLATE_PERCENTSTACKEDNETSYMBOL:
492 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
493 StackMode::YStackedPercent, true, false ));
494 break;
495 case TEMPLATE_PERCENTSTACKEDNETLINE:
496 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
497 StackMode::YStackedPercent, false, true ));
498 break;
500 case TEMPLATE_FILLEDNET:
501 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
502 StackMode::NONE, false, false, true ));
503 break;
504 case TEMPLATE_STACKEDFILLEDNET:
505 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
506 StackMode::YStacked, false, false, true ));
507 break;
508 case TEMPLATE_PERCENTSTACKEDFILLEDNET:
509 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
510 StackMode::YStackedPercent, false, false, true ));
511 break;
513 case TEMPLATE_STOCKLOWHIGHCLOSE:
514 xTemplate.set( new StockChartTypeTemplate( m_xContext, aServiceSpecifier,
515 StockChartTypeTemplate::StockVariant::NONE, false ));
516 break;
517 case TEMPLATE_STOCKOPENLOWHIGHCLOSE:
518 xTemplate.set( new StockChartTypeTemplate( m_xContext, aServiceSpecifier,
519 StockChartTypeTemplate::StockVariant::Open, true ));
520 break;
521 case TEMPLATE_STOCKVOLUMELOWHIGHCLOSE:
522 xTemplate.set( new StockChartTypeTemplate( m_xContext, aServiceSpecifier,
523 StockChartTypeTemplate::StockVariant::Volume, false ));
524 break;
525 case TEMPLATE_STOCKVOLUMEOPENLOWHIGHCLOSE:
526 xTemplate.set( new StockChartTypeTemplate( m_xContext, aServiceSpecifier,
527 StockChartTypeTemplate::StockVariant::VolumeOpen, true ));
528 break;
530 //BubbleChart
531 case TEMPLATE_BUBBLE:
532 xTemplate.set( new BubbleChartTypeTemplate( m_xContext, aServiceSpecifier ));
533 break;
535 case TEMPLATE_NOT_FOUND:
536 SAL_WARN("chart2", "Couldn't instantiate service: "<< aServiceSpecifier );
537 assert(false);
538 break;
540 default: break;
541 // case TEMPLATE_SURFACE:
542 // case TEMPLATE_ADDIN:
543 // break;
546 return xTemplate;
549 uno::Reference< uno::XInterface > SAL_CALL ChartTypeManager::createInstanceWithArguments(
550 const OUString& ServiceSpecifier,
551 const uno::Sequence< uno::Any >& /* Arguments */ )
553 OSL_FAIL( "createInstanceWithArguments: No arguments supported" );
554 return createInstance( ServiceSpecifier );
557 uno::Sequence< OUString > SAL_CALL ChartTypeManager::getAvailableServiceNames()
559 std::vector< OUString > aServices;
560 const tTemplateMapType & rMap = lcl_DefaultChartTypeMap();
561 aServices.reserve( rMap.size());
563 // get own default templates
564 std::transform( rMap.begin(), rMap.end(), std::back_inserter( aServices ),
565 ::o3tl::select1st< tTemplateMapType::value_type >() );
567 // add components that were registered in the context's factory
568 uno::Reference< container::XContentEnumerationAccess > xEnumAcc(
569 m_xContext->getServiceManager(), uno::UNO_QUERY );
570 if( xEnumAcc.is())
572 uno::Reference< container::XEnumeration > xEnum(
573 xEnumAcc->createContentEnumeration( u"com.sun.star.chart2.ChartTypeTemplate"_ustr ));
574 if( xEnum.is())
576 uno::Reference< uno::XInterface > xFactIntf;
578 while( xEnum->hasMoreElements())
580 if( xEnum->nextElement() >>= xFactIntf )
582 uno::Reference< lang::XServiceName > xServiceName( xFactIntf, uno::UNO_QUERY );
583 if( xServiceName.is())
584 aServices.push_back( xServiceName->getServiceName());
590 return comphelper::containerToSequence( aServices );
593 // ____ XServiceInfo ____
594 OUString SAL_CALL ChartTypeManager::getImplementationName()
596 return u"com.sun.star.comp.chart.ChartTypeManager"_ustr;
599 sal_Bool SAL_CALL ChartTypeManager::supportsService( const OUString& rServiceName )
601 return cppu::supportsService(this, rServiceName);
604 css::uno::Sequence< OUString > SAL_CALL ChartTypeManager::getSupportedServiceNames()
606 return {
607 u"com.sun.star.chart2.ChartTypeManager"_ustr,
608 u"com.sun.star.lang.MultiServiceFactory"_ustr };
611 } // namespace chart
613 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
614 com_sun_star_comp_chart_ChartTypeManager_get_implementation(css::uno::XComponentContext *context,
615 css::uno::Sequence<css::uno::Any> const &)
617 return cppu::acquire(new ::chart::ChartTypeManager(context));
620 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */