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