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