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