fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / chart2 / source / model / template / ChartTypeManager.cxx
blob1425813c0f5490eae7ea71c30de7faea9c2cc086
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 "macros.hxx"
22 #include "StackMode.hxx"
23 #include "ContainerHelper.hxx"
25 #include "CartesianCoordinateSystem.hxx"
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 "GL3DBarChartTypeTemplate.hxx"
37 #include <cppuhelper/component_context.hxx>
38 #include <cppuhelper/supportsservice.hxx>
39 #include <comphelper/InlineContainer.hxx>
40 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
41 #include <com/sun/star/lang/XServiceName.hpp>
42 #include <com/sun/star/chart/ChartSolidType.hpp>
43 #include <com/sun/star/chart2/CurveStyle.hpp>
45 #include <algorithm>
46 #include <iterator>
47 #include <functional>
48 #include <o3tl/compat_functional.hxx>
50 using namespace ::com::sun::star;
52 using ::com::sun::star::uno::Sequence;
53 using ::com::sun::star::uno::Reference;
54 using ::com::sun::star::uno::Any;
55 using ::osl::MutexGuard;
57 namespace
60 enum TemplateId
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_GL3DBAR,
127 TEMPLATE_GL3DBAR_ROUNDED_RECTANGLE,
128 // TEMPLATE_SURFACE,
129 // TEMPLATE_ADDIN,
130 TEMPLATE_NOT_FOUND = 0xffff
133 typedef ::std::map< OUString, TemplateId > tTemplateMapType;
135 const tTemplateMapType & lcl_DefaultChartTypeMap()
137 static const tTemplateMapType aMap = tTemplateMapType(
138 ::comphelper::MakeMap< tTemplateMapType::key_type, tTemplateMapType::mapped_type >
139 ( "com.sun.star.chart2.template.Symbol", TEMPLATE_SYMBOL )
140 ( "com.sun.star.chart2.template.StackedSymbol", TEMPLATE_STACKEDSYMBOL )
141 ( "com.sun.star.chart2.template.PercentStackedSymbol", TEMPLATE_PERCENTSTACKEDSYMBOL )
142 ( "com.sun.star.chart2.template.Line", TEMPLATE_LINE )
143 ( "com.sun.star.chart2.template.StackedLine", TEMPLATE_STACKEDLINE )
144 ( "com.sun.star.chart2.template.PercentStackedLine", TEMPLATE_PERCENTSTACKEDLINE )
145 ( "com.sun.star.chart2.template.LineSymbol", TEMPLATE_LINESYMBOL )
146 ( "com.sun.star.chart2.template.StackedLineSymbol", TEMPLATE_STACKEDLINESYMBOL )
147 ( "com.sun.star.chart2.template.PercentStackedLineSymbol", TEMPLATE_PERCENTSTACKEDLINESYMBOL )
148 ( "com.sun.star.chart2.template.ThreeDLine", TEMPLATE_THREEDLINE )
149 ( "com.sun.star.chart2.template.StackedThreeDLine", TEMPLATE_STACKEDTHREEDLINE )
150 ( "com.sun.star.chart2.template.PercentStackedThreeDLine", TEMPLATE_PERCENTSTACKEDTHREEDLINE )
151 ( "com.sun.star.chart2.template.ThreeDLineDeep", TEMPLATE_THREEDLINEDEEP )
152 ( "com.sun.star.chart2.template.Column", TEMPLATE_COLUMN )
153 ( "com.sun.star.chart2.template.StackedColumn", TEMPLATE_STACKEDCOLUMN )
154 ( "com.sun.star.chart2.template.PercentStackedColumn", TEMPLATE_PERCENTSTACKEDCOLUMN )
155 ( "com.sun.star.chart2.template.Bar", TEMPLATE_BAR )
156 ( "com.sun.star.chart2.template.StackedBar", TEMPLATE_STACKEDBAR )
157 ( "com.sun.star.chart2.template.PercentStackedBar", TEMPLATE_PERCENTSTACKEDBAR )
158 ( "com.sun.star.chart2.template.ThreeDColumnDeep", TEMPLATE_THREEDCOLUMNDEEP )
159 ( "com.sun.star.chart2.template.ThreeDColumnFlat", TEMPLATE_THREEDCOLUMNFLAT )
160 ( "com.sun.star.chart2.template.StackedThreeDColumnFlat", TEMPLATE_STACKEDTHREEDCOLUMNFLAT )
161 ( "com.sun.star.chart2.template.PercentStackedThreeDColumnFlat", TEMPLATE_PERCENTSTACKEDTHREEDCOLUMNFLAT )
162 ( "com.sun.star.chart2.template.ThreeDBarDeep", TEMPLATE_THREEDBARDEEP )
163 ( "com.sun.star.chart2.template.ThreeDBarFlat", TEMPLATE_THREEDBARFLAT )
164 ( "com.sun.star.chart2.template.StackedThreeDBarFlat", TEMPLATE_STACKEDTHREEDBARFLAT )
165 ( "com.sun.star.chart2.template.PercentStackedThreeDBarFlat", TEMPLATE_PERCENTSTACKEDTHREEDBARFLAT )
166 ( "com.sun.star.chart2.template.ColumnWithLine", TEMPLATE_COLUMNWITHLINE )
167 ( "com.sun.star.chart2.template.StackedColumnWithLine", TEMPLATE_STACKEDCOLUMNWITHLINE )
168 ( "com.sun.star.chart2.template.Area", TEMPLATE_AREA )
169 ( "com.sun.star.chart2.template.StackedArea", TEMPLATE_STACKEDAREA )
170 ( "com.sun.star.chart2.template.PercentStackedArea", TEMPLATE_PERCENTSTACKEDAREA )
171 ( "com.sun.star.chart2.template.ThreeDArea", TEMPLATE_THREEDAREA )
172 ( "com.sun.star.chart2.template.StackedThreeDArea", TEMPLATE_STACKEDTHREEDAREA )
173 ( "com.sun.star.chart2.template.PercentStackedThreeDArea", TEMPLATE_PERCENTSTACKEDTHREEDAREA )
174 ( "com.sun.star.chart2.template.Pie", TEMPLATE_PIE )
175 ( "com.sun.star.chart2.template.PieAllExploded", TEMPLATE_PIEALLEXPLODED )
176 ( "com.sun.star.chart2.template.Donut", TEMPLATE_DONUT )
177 ( "com.sun.star.chart2.template.DonutAllExploded", TEMPLATE_DONUTALLEXPLODED )
178 ( "com.sun.star.chart2.template.ThreeDPie", TEMPLATE_THREEDPIE )
179 ( "com.sun.star.chart2.template.ThreeDPieAllExploded", TEMPLATE_THREEDPIEALLEXPLODED )
180 ( "com.sun.star.chart2.template.ThreeDDonut", TEMPLATE_THREEDDONUT )
181 ( "com.sun.star.chart2.template.ThreeDDonutAllExploded", TEMPLATE_THREEDDONUTALLEXPLODED )
182 ( "com.sun.star.chart2.template.ScatterLineSymbol", TEMPLATE_SCATTERLINESYMBOL )
183 ( "com.sun.star.chart2.template.ScatterLine", TEMPLATE_SCATTERLINE )
184 ( "com.sun.star.chart2.template.ScatterSymbol", TEMPLATE_SCATTERSYMBOL )
185 ( "com.sun.star.chart2.template.ThreeDScatter", TEMPLATE_THREEDSCATTER )
186 ( "com.sun.star.chart2.template.Net", TEMPLATE_NET )
187 ( "com.sun.star.chart2.template.NetSymbol", TEMPLATE_NETSYMBOL )
188 ( "com.sun.star.chart2.template.NetLine", TEMPLATE_NETLINE )
189 ( "com.sun.star.chart2.template.StackedNet", TEMPLATE_STACKEDNET )
190 ( "com.sun.star.chart2.template.StackedNetSymbol", TEMPLATE_STACKEDNETSYMBOL )
191 ( "com.sun.star.chart2.template.StackedNetLine", TEMPLATE_STACKEDNETLINE )
192 ( "com.sun.star.chart2.template.PercentStackedNet", TEMPLATE_PERCENTSTACKEDNET )
193 ( "com.sun.star.chart2.template.PercentStackedNetSymbol", TEMPLATE_PERCENTSTACKEDNETSYMBOL )
194 ( "com.sun.star.chart2.template.PercentStackedNetLine", TEMPLATE_PERCENTSTACKEDNETLINE )
195 ( "com.sun.star.chart2.template.FilledNet", TEMPLATE_FILLEDNET )
196 ( "com.sun.star.chart2.template.StackedFilledNet", TEMPLATE_STACKEDFILLEDNET )
197 ( "com.sun.star.chart2.template.PercentStackedFilledNet", TEMPLATE_PERCENTSTACKEDFILLEDNET )
198 ( "com.sun.star.chart2.template.StockLowHighClose", TEMPLATE_STOCKLOWHIGHCLOSE )
199 ( "com.sun.star.chart2.template.StockOpenLowHighClose", TEMPLATE_STOCKOPENLOWHIGHCLOSE )
200 ( "com.sun.star.chart2.template.StockVolumeLowHighClose", TEMPLATE_STOCKVOLUMELOWHIGHCLOSE )
201 ( "com.sun.star.chart2.template.StockVolumeOpenLowHighClose", TEMPLATE_STOCKVOLUMEOPENLOWHIGHCLOSE )
202 ( "com.sun.star.chart2.template.Bubble", TEMPLATE_BUBBLE )
203 ( "com.sun.star.chart2.template.GL3DBar", TEMPLATE_GL3DBAR )
204 ( "com.sun.star.chart2.template.GL3DBarRoundedRectangle", TEMPLATE_GL3DBAR_ROUNDED_RECTANGLE )
205 // ( "com.sun.star.chart2.template.Surface", TEMPLATE_SURFACE )
206 // ( "com.sun.star.chart2.template.Addin", TEMPLATE_ADDIN )
209 return aMap;
212 TemplateId lcl_GetTemplateIdForService( const OUString & rServiceName )
214 TemplateId eResult = TEMPLATE_NOT_FOUND;
215 const tTemplateMapType & rMap = lcl_DefaultChartTypeMap();
216 tTemplateMapType::const_iterator aIt( rMap.find( rServiceName ));
218 if( aIt != rMap.end())
219 eResult = (*aIt).second;
221 return eResult;
224 } // anonymous namespace
226 namespace chart
229 ChartTypeManager::ChartTypeManager(
230 uno::Reference<
231 uno::XComponentContext > const & xContext ) :
232 m_xContext( xContext )
235 ChartTypeManager::~ChartTypeManager()
238 // ____ XMultiServiceFactory ____
239 uno::Reference< uno::XInterface > SAL_CALL ChartTypeManager::createInstance(
240 const OUString& aServiceSpecifier )
241 throw (uno::Exception,
242 uno::RuntimeException, std::exception)
244 uno::Reference< uno::XInterface > xResult;
245 TemplateId nId = lcl_GetTemplateIdForService( aServiceSpecifier );
247 if( nId == TEMPLATE_NOT_FOUND )
251 xResult = m_xContext->getServiceManager()->createInstanceWithContext(
252 aServiceSpecifier, m_xContext );
254 // catch( registry::InvalidValueException & ex )
255 catch( const uno::Exception & ex )
257 // couldn't create service via factory
259 // As XMultiServiceFactory does not specify, what to do in case
260 // createInstance is called with an unknown service-name, this
261 // function will just return an empty XInterface.
262 ASSERT_EXCEPTION( ex );
263 SAL_WARN("chart2", "Couldn't instantiate service: "<< aServiceSpecifier );
264 xResult.set( 0 );
267 else
269 uno::Reference< chart2::XChartTypeTemplate > xTemplate;
270 switch( nId )
272 // Point (category x axis)
273 case TEMPLATE_SYMBOL:
274 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
275 StackMode_NONE, true, false ));
276 break;
277 case TEMPLATE_STACKEDSYMBOL:
278 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
279 StackMode_Y_STACKED, true, false ));
280 break;
281 case TEMPLATE_PERCENTSTACKEDSYMBOL:
282 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
283 StackMode_Y_STACKED_PERCENT, true, false ));
284 break;
285 // Line (category x axis)
286 case TEMPLATE_LINE:
287 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
288 StackMode_NONE, false ));
289 break;
290 case TEMPLATE_STACKEDLINE:
291 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
292 StackMode_Y_STACKED, false ));
293 break;
294 case TEMPLATE_PERCENTSTACKEDLINE:
295 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
296 StackMode_Y_STACKED_PERCENT, false ));
297 break;
298 case TEMPLATE_LINESYMBOL:
299 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
300 StackMode_NONE, true ));
301 break;
302 case TEMPLATE_STACKEDLINESYMBOL:
303 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
304 StackMode_Y_STACKED, true ));
305 break;
306 case TEMPLATE_PERCENTSTACKEDLINESYMBOL:
307 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
308 StackMode_Y_STACKED_PERCENT, true ));
309 break;
310 case TEMPLATE_THREEDLINE:
311 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
312 StackMode_NONE, false, true, 3 ));
313 break;
314 case TEMPLATE_STACKEDTHREEDLINE:
315 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
316 StackMode_Y_STACKED, false, true, 3 ));
317 break;
318 case TEMPLATE_PERCENTSTACKEDTHREEDLINE:
319 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
320 StackMode_Y_STACKED_PERCENT, false, true, 3 ));
321 break;
322 case TEMPLATE_THREEDLINEDEEP:
323 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
324 StackMode_Z_STACKED, false, true, 3 ));
325 break;
327 // Bar/Column
328 case TEMPLATE_COLUMN:
329 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
330 StackMode_NONE, BarChartTypeTemplate::VERTICAL ));
331 break;
332 case TEMPLATE_STACKEDCOLUMN:
333 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
334 StackMode_Y_STACKED, BarChartTypeTemplate::VERTICAL ));
335 break;
336 case TEMPLATE_PERCENTSTACKEDCOLUMN:
337 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
338 StackMode_Y_STACKED_PERCENT, BarChartTypeTemplate::VERTICAL ));
339 break;
340 case TEMPLATE_BAR:
341 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
342 StackMode_NONE, BarChartTypeTemplate::HORIZONTAL ));
343 break;
344 case TEMPLATE_STACKEDBAR:
345 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
346 StackMode_Y_STACKED, BarChartTypeTemplate::HORIZONTAL ));
347 break;
348 case TEMPLATE_PERCENTSTACKEDBAR:
349 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
350 StackMode_Y_STACKED_PERCENT, BarChartTypeTemplate::HORIZONTAL ));
351 break;
352 case TEMPLATE_THREEDCOLUMNDEEP:
353 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
354 StackMode_Z_STACKED, BarChartTypeTemplate::VERTICAL, 3 ));
355 break;
356 case TEMPLATE_THREEDCOLUMNFLAT:
357 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
358 StackMode_NONE, BarChartTypeTemplate::VERTICAL, 3 ));
359 break;
360 case TEMPLATE_STACKEDTHREEDCOLUMNFLAT:
361 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
362 StackMode_Y_STACKED, BarChartTypeTemplate::VERTICAL, 3 ));
363 break;
364 case TEMPLATE_PERCENTSTACKEDTHREEDCOLUMNFLAT:
365 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
366 StackMode_Y_STACKED_PERCENT, BarChartTypeTemplate::VERTICAL, 3 ));
367 break;
368 case TEMPLATE_THREEDBARDEEP:
369 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
370 StackMode_Z_STACKED, BarChartTypeTemplate::HORIZONTAL, 3 ));
371 break;
372 case TEMPLATE_THREEDBARFLAT:
373 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
374 StackMode_NONE, BarChartTypeTemplate::HORIZONTAL, 3 ));
375 break;
376 case TEMPLATE_STACKEDTHREEDBARFLAT:
377 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
378 StackMode_Y_STACKED, BarChartTypeTemplate::HORIZONTAL, 3 ));
379 break;
380 case TEMPLATE_PERCENTSTACKEDTHREEDBARFLAT:
381 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
382 StackMode_Y_STACKED_PERCENT, BarChartTypeTemplate::HORIZONTAL, 3 ));
383 break;
385 // Combi-Chart Line/Column
386 case TEMPLATE_COLUMNWITHLINE:
387 case TEMPLATE_STACKEDCOLUMNWITHLINE:
389 StackMode eMode = ( nId == TEMPLATE_COLUMNWITHLINE )
390 ? StackMode_NONE
391 : StackMode_Y_STACKED;
393 xTemplate.set( new ColumnLineChartTypeTemplate( m_xContext, aServiceSpecifier, eMode, 1 ));
395 break;
397 // Area
398 case TEMPLATE_AREA:
399 xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode_NONE ));
400 break;
401 case TEMPLATE_STACKEDAREA:
402 xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode_Y_STACKED ));
403 break;
404 case TEMPLATE_PERCENTSTACKEDAREA:
405 xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode_Y_STACKED_PERCENT ));
406 break;
407 case TEMPLATE_THREEDAREA:
408 xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode_Z_STACKED, 3 ));
409 break;
410 case TEMPLATE_STACKEDTHREEDAREA:
411 xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode_Y_STACKED, 3 ));
412 break;
413 case TEMPLATE_PERCENTSTACKEDTHREEDAREA:
414 xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode_Y_STACKED_PERCENT, 3 ));
415 break;
417 case TEMPLATE_PIE:
418 xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
419 chart2::PieChartOffsetMode_NONE, false ));
420 break;
421 case TEMPLATE_PIEALLEXPLODED:
422 xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
423 chart2::PieChartOffsetMode_ALL_EXPLODED, false ));
424 break;
425 case TEMPLATE_DONUT:
426 xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
427 chart2::PieChartOffsetMode_NONE, true ));
428 break;
429 case TEMPLATE_DONUTALLEXPLODED:
430 xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
431 chart2::PieChartOffsetMode_ALL_EXPLODED, true ));
432 break;
433 case TEMPLATE_THREEDPIE:
434 xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
435 chart2::PieChartOffsetMode_NONE, false, 3 ));
436 break;
437 case TEMPLATE_THREEDPIEALLEXPLODED:
438 xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
439 chart2::PieChartOffsetMode_ALL_EXPLODED, false, 3 ));
440 break;
441 case TEMPLATE_THREEDDONUT:
442 xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
443 chart2::PieChartOffsetMode_NONE, true, 3 ));
444 break;
445 case TEMPLATE_THREEDDONUTALLEXPLODED:
446 xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
447 chart2::PieChartOffsetMode_ALL_EXPLODED, true, 3 ));
448 break;
450 case TEMPLATE_SCATTERLINESYMBOL:
451 xTemplate.set( new ScatterChartTypeTemplate( m_xContext, aServiceSpecifier, /* bSymbols */ true ));
452 break;
453 case TEMPLATE_SCATTERLINE:
454 xTemplate.set( new ScatterChartTypeTemplate( m_xContext, aServiceSpecifier, /* bSymbols */ false ));
455 break;
456 case TEMPLATE_SCATTERSYMBOL:
457 xTemplate.set( new ScatterChartTypeTemplate( m_xContext, aServiceSpecifier, /* bSymbols */ true, /* bHasLines */ false ));
458 break;
459 case TEMPLATE_THREEDSCATTER:
460 xTemplate.set( new ScatterChartTypeTemplate( m_xContext, aServiceSpecifier, /* bSymbols */ false, /* bHasLines */ true, 3 ));
461 break;
463 // NetChart
464 case TEMPLATE_NET:
465 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
466 StackMode_NONE, true ));
467 break;
468 case TEMPLATE_NETSYMBOL:
469 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
470 StackMode_NONE, true, false ));
471 break;
472 case TEMPLATE_NETLINE:
473 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
474 StackMode_NONE, false ));
475 break;
477 case TEMPLATE_STACKEDNET:
478 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
479 StackMode_Y_STACKED, true ));
480 break;
481 case TEMPLATE_STACKEDNETSYMBOL:
482 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
483 StackMode_Y_STACKED, true, false ));
484 break;
485 case TEMPLATE_STACKEDNETLINE:
486 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
487 StackMode_Y_STACKED, false, true ));
488 break;
490 case TEMPLATE_PERCENTSTACKEDNET:
491 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
492 StackMode_Y_STACKED_PERCENT, true ));
493 break;
494 case TEMPLATE_PERCENTSTACKEDNETSYMBOL:
495 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
496 StackMode_Y_STACKED_PERCENT, true, false ));
497 break;
498 case TEMPLATE_PERCENTSTACKEDNETLINE:
499 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
500 StackMode_Y_STACKED_PERCENT, false, true ));
501 break;
503 case TEMPLATE_FILLEDNET:
504 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
505 StackMode_NONE, false, false, true ));
506 break;
507 case TEMPLATE_STACKEDFILLEDNET:
508 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
509 StackMode_Y_STACKED, false, false, true ));
510 break;
511 case TEMPLATE_PERCENTSTACKEDFILLEDNET:
512 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
513 StackMode_Y_STACKED_PERCENT, false, false, true ));
514 break;
516 case TEMPLATE_STOCKLOWHIGHCLOSE:
517 xTemplate.set( new StockChartTypeTemplate( m_xContext, aServiceSpecifier,
518 StockChartTypeTemplate::LOW_HI_CLOSE, false ));
519 break;
520 case TEMPLATE_STOCKOPENLOWHIGHCLOSE:
521 xTemplate.set( new StockChartTypeTemplate( m_xContext, aServiceSpecifier,
522 StockChartTypeTemplate::OPEN_LOW_HI_CLOSE, true ));
523 break;
524 case TEMPLATE_STOCKVOLUMELOWHIGHCLOSE:
525 xTemplate.set( new StockChartTypeTemplate( m_xContext, aServiceSpecifier,
526 StockChartTypeTemplate::VOL_LOW_HI_CLOSE, false ));
527 break;
528 case TEMPLATE_STOCKVOLUMEOPENLOWHIGHCLOSE:
529 xTemplate.set( new StockChartTypeTemplate( m_xContext, aServiceSpecifier,
530 StockChartTypeTemplate::VOL_OPEN_LOW_HI_CLOSE, true ));
531 break;
533 //BubbleChart
534 case TEMPLATE_BUBBLE:
535 xTemplate.set( new BubbleChartTypeTemplate( m_xContext, aServiceSpecifier ));
536 break;
538 case TEMPLATE_GL3DBAR:
539 xTemplate.set(new GL3DBarChartTypeTemplate(m_xContext, aServiceSpecifier));
540 break;
541 case TEMPLATE_GL3DBAR_ROUNDED_RECTANGLE:
542 xTemplate.set(new GL3DBarChartTypeTemplate(m_xContext, aServiceSpecifier));
543 break;
545 // case TEMPLATE_SURFACE:
546 // case TEMPLATE_ADDIN:
547 // break;
549 case TEMPLATE_NOT_FOUND:
550 OSL_ASSERT( false );
551 break;
553 xResult.set( xTemplate, uno::UNO_QUERY );
556 return xResult;
559 uno::Reference< uno::XInterface > SAL_CALL ChartTypeManager::createInstanceWithArguments(
560 const OUString& ServiceSpecifier,
561 const uno::Sequence< uno::Any >& /* Arguments */ )
562 throw (uno::Exception,
563 uno::RuntimeException, std::exception)
565 OSL_FAIL( "createInstanceWithArguments: No arguments supported" );
566 return createInstance( ServiceSpecifier );
569 uno::Sequence< OUString > SAL_CALL ChartTypeManager::getAvailableServiceNames()
570 throw (uno::RuntimeException, std::exception)
572 ::std::vector< OUString > aServices;
573 const tTemplateMapType & rMap = lcl_DefaultChartTypeMap();
574 aServices.reserve( rMap.size());
576 // get own default templates
577 ::std::transform( rMap.begin(), rMap.end(), ::std::back_inserter( aServices ),
578 ::o3tl::select1st< tTemplateMapType::value_type >());
580 // add components that were registered in the context's factory
581 uno::Reference< container::XContentEnumerationAccess > xEnumAcc(
582 m_xContext->getServiceManager(), uno::UNO_QUERY );
583 if( xEnumAcc.is())
585 uno::Reference< container::XEnumeration > xEnum(
586 xEnumAcc->createContentEnumeration( "com.sun.star.chart2.ChartTypeTemplate" ));
587 if( xEnum.is())
589 uno::Reference< uno::XInterface > xFactIntf;
591 while( xEnum->hasMoreElements())
593 if( xEnum->nextElement() >>= xFactIntf )
595 uno::Reference< lang::XServiceName > xServiceName( xFactIntf, uno::UNO_QUERY );
596 if( xServiceName.is())
597 aServices.push_back( xServiceName->getServiceName());
603 return ContainerHelper::ContainerToSequence( aServices );
606 // ____ XServiceInfo ____
607 Sequence< OUString > ChartTypeManager::getSupportedServiceNames_Static()
609 Sequence< OUString > aServices( 2 );
610 aServices[ 0 ] = "com.sun.star.chart2.ChartTypeManager";
611 aServices[ 1 ] = "com.sun.star.lang.MultiServiceFactory";
612 return aServices;
615 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
616 OUString SAL_CALL ChartTypeManager::getImplementationName()
617 throw( css::uno::RuntimeException, std::exception )
619 return getImplementationName_Static();
622 OUString ChartTypeManager::getImplementationName_Static()
624 return OUString("com.sun.star.comp.chart.ChartTypeManager");
627 sal_Bool SAL_CALL ChartTypeManager::supportsService( const OUString& rServiceName )
628 throw( css::uno::RuntimeException, std::exception )
630 return cppu::supportsService(this, rServiceName);
633 css::uno::Sequence< OUString > SAL_CALL ChartTypeManager::getSupportedServiceNames()
634 throw( css::uno::RuntimeException, std::exception )
636 return getSupportedServiceNames_Static();
639 } // namespace chart
641 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
642 com_sun_star_comp_chart_ChartTypeManager_get_implementation(css::uno::XComponentContext *context,
643 css::uno::Sequence<css::uno::Any> const &)
645 return cppu::acquire(new ::chart::ChartTypeManager(context));
648 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */