Branch data 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 : 1499 : 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 [ + - ][ + - ]: 28 : ( C2U( "com.sun.star.chart2.template.StackedSymbol" ), TEMPLATE_STACKEDSYMBOL )
[ + - ][ + - ]
140 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.PercentStackedSymbol" ), TEMPLATE_PERCENTSTACKEDSYMBOL )
141 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.Line" ), TEMPLATE_LINE )
142 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.StackedLine" ), TEMPLATE_STACKEDLINE )
143 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.PercentStackedLine" ), TEMPLATE_PERCENTSTACKEDLINE )
144 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.LineSymbol" ), TEMPLATE_LINESYMBOL )
145 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.StackedLineSymbol" ), TEMPLATE_STACKEDLINESYMBOL )
146 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.PercentStackedLineSymbol" ), TEMPLATE_PERCENTSTACKEDLINESYMBOL )
147 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.ThreeDLine" ), TEMPLATE_THREEDLINE )
148 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.StackedThreeDLine" ), TEMPLATE_STACKEDTHREEDLINE )
149 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.PercentStackedThreeDLine" ), TEMPLATE_PERCENTSTACKEDTHREEDLINE )
150 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.ThreeDLineDeep" ), TEMPLATE_THREEDLINEDEEP )
151 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.Column" ), TEMPLATE_COLUMN )
152 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.StackedColumn" ), TEMPLATE_STACKEDCOLUMN )
153 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.PercentStackedColumn" ), TEMPLATE_PERCENTSTACKEDCOLUMN )
154 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.Bar" ), TEMPLATE_BAR )
155 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.StackedBar" ), TEMPLATE_STACKEDBAR )
156 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.PercentStackedBar" ), TEMPLATE_PERCENTSTACKEDBAR )
157 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.ThreeDColumnDeep" ), TEMPLATE_THREEDCOLUMNDEEP )
158 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.ThreeDColumnFlat" ), TEMPLATE_THREEDCOLUMNFLAT )
159 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.StackedThreeDColumnFlat" ), TEMPLATE_STACKEDTHREEDCOLUMNFLAT )
160 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.PercentStackedThreeDColumnFlat" ), TEMPLATE_PERCENTSTACKEDTHREEDCOLUMNFLAT )
161 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.ThreeDBarDeep" ), TEMPLATE_THREEDBARDEEP )
162 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.ThreeDBarFlat" ), TEMPLATE_THREEDBARFLAT )
163 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.StackedThreeDBarFlat" ), TEMPLATE_STACKEDTHREEDBARFLAT )
164 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.PercentStackedThreeDBarFlat" ), TEMPLATE_PERCENTSTACKEDTHREEDBARFLAT )
165 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.ColumnWithLine" ), TEMPLATE_COLUMNWITHLINE )
166 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.StackedColumnWithLine" ), TEMPLATE_STACKEDCOLUMNWITHLINE )
167 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.Area" ), TEMPLATE_AREA )
168 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.StackedArea" ), TEMPLATE_STACKEDAREA )
169 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.PercentStackedArea" ), TEMPLATE_PERCENTSTACKEDAREA )
170 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.ThreeDArea" ), TEMPLATE_THREEDAREA )
171 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.StackedThreeDArea" ), TEMPLATE_STACKEDTHREEDAREA )
172 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.PercentStackedThreeDArea" ), TEMPLATE_PERCENTSTACKEDTHREEDAREA )
173 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.Pie" ), TEMPLATE_PIE )
174 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.PieAllExploded" ), TEMPLATE_PIEALLEXPLODED )
175 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.Donut" ), TEMPLATE_DONUT )
176 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.DonutAllExploded" ), TEMPLATE_DONUTALLEXPLODED )
177 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.ThreeDPie" ), TEMPLATE_THREEDPIE )
178 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.ThreeDPieAllExploded" ), TEMPLATE_THREEDPIEALLEXPLODED )
179 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.ThreeDDonut" ), TEMPLATE_THREEDDONUT )
180 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.ThreeDDonutAllExploded" ), TEMPLATE_THREEDDONUTALLEXPLODED )
181 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.ScatterLineSymbol" ), TEMPLATE_SCATTERLINESYMBOL )
182 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.ScatterLine" ), TEMPLATE_SCATTERLINE )
183 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.ScatterSymbol" ), TEMPLATE_SCATTERSYMBOL )
184 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.ThreeDScatter" ), TEMPLATE_THREEDSCATTER )
185 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.Net" ), TEMPLATE_NET )
186 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.NetSymbol" ), TEMPLATE_NETSYMBOL )
187 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.NetLine" ), TEMPLATE_NETLINE )
188 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.StackedNet" ), TEMPLATE_STACKEDNET )
189 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.StackedNetSymbol" ), TEMPLATE_STACKEDNETSYMBOL )
190 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.StackedNetLine" ), TEMPLATE_STACKEDNETLINE )
191 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.PercentStackedNet" ), TEMPLATE_PERCENTSTACKEDNET )
192 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.PercentStackedNetSymbol" ), TEMPLATE_PERCENTSTACKEDNETSYMBOL )
193 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.PercentStackedNetLine" ), TEMPLATE_PERCENTSTACKEDNETLINE )
194 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.FilledNet" ), TEMPLATE_FILLEDNET )
195 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.StackedFilledNet" ), TEMPLATE_STACKEDFILLEDNET )
196 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.PercentStackedFilledNet" ), TEMPLATE_PERCENTSTACKEDFILLEDNET )
197 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.StockLowHighClose" ), TEMPLATE_STOCKLOWHIGHCLOSE )
198 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.StockOpenLowHighClose" ), TEMPLATE_STOCKOPENLOWHIGHCLOSE )
199 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.StockVolumeLowHighClose" ), TEMPLATE_STOCKVOLUMELOWHIGHCLOSE )
200 [ + - ][ + - ]: 42 : ( C2U( "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" ), TEMPLATE_STOCKVOLUMEOPENLOWHIGHCLOSE )
201 [ + - ][ + - ]: 42 : ( 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 [ + + ][ + - ]: 1513 : );
[ + - ][ # # ]
205 : :
206 : 1499 : return aMap;
207 : : }
208 : :
209 : 1322 : TemplateId lcl_GetTemplateIdForService( const OUString & rServiceName )
210 : : {
211 : 1322 : TemplateId eResult = TEMPLATE_NOT_FOUND;
212 [ + - ]: 1322 : const tTemplateMapType & rMap = lcl_DefaultChartTypeMap();
213 [ + - ]: 1322 : tTemplateMapType::const_iterator aIt( rMap.find( rServiceName ));
214 : :
215 [ + - ]: 1322 : if( aIt != rMap.end())
216 : 1322 : eResult = (*aIt).second;
217 : :
218 : 1322 : return eResult;
219 : : }
220 : :
221 : : } // anonymous namespace
222 : :
223 : : namespace chart
224 : : {
225 : :
226 : 94 : ChartTypeManager::ChartTypeManager(
227 : : uno::Reference<
228 : : uno::XComponentContext > const & xContext ) :
229 : 94 : m_xContext( xContext )
230 : 94 : {}
231 : :
232 : 94 : ChartTypeManager::~ChartTypeManager()
233 [ - + ]: 188 : {}
234 : :
235 : : // ____ XMultiServiceFactory ____
236 : 1322 : uno::Reference< uno::XInterface > SAL_CALL ChartTypeManager::createInstance(
237 : : const OUString& aServiceSpecifier )
238 : : throw (uno::Exception,
239 : : uno::RuntimeException)
240 : : {
241 : 1322 : uno::Reference< uno::XInterface > xResult;
242 [ + - ]: 1322 : TemplateId nId = lcl_GetTemplateIdForService( aServiceSpecifier );
243 : :
244 [ - + ]: 1322 : 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 : 1322 : uno::Reference< chart2::XChartTypeTemplate > xTemplate;
267 [ - + + + : 1322 : 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 [ + - ][ + - ]: 4 : StackMode_Y_STACKED, true, false ));
[ + - ]
277 : 4 : break;
278 : : case TEMPLATE_PERCENTSTACKEDSYMBOL:
279 : : xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
280 [ + - ][ + - ]: 16 : StackMode_Y_STACKED_PERCENT, true, false ));
[ + - ]
281 : 16 : break;
282 : : // Line (category x axis)
283 : : case TEMPLATE_LINE:
284 : : xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
285 [ + - ][ + - ]: 32 : StackMode_NONE, false ));
[ + - ]
286 : 32 : break;
287 : : case TEMPLATE_STACKEDLINE:
288 : : xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
289 [ + - ][ + - ]: 4 : StackMode_Y_STACKED, false ));
[ + - ]
290 : 4 : break;
291 : : case TEMPLATE_PERCENTSTACKEDLINE:
292 : : xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
293 [ + - ][ + - ]: 16 : StackMode_Y_STACKED_PERCENT, false ));
[ + - ]
294 : 16 : break;
295 : : case TEMPLATE_LINESYMBOL:
296 : : xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
297 [ + - ][ + - ]: 16 : StackMode_NONE, true ));
[ + - ]
298 : 16 : break;
299 : : case TEMPLATE_STACKEDLINESYMBOL:
300 : : xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
301 [ + - ][ + - ]: 4 : StackMode_Y_STACKED, true ));
[ + - ]
302 : 4 : break;
303 : : case TEMPLATE_PERCENTSTACKEDLINESYMBOL:
304 : : xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
305 [ + - ][ + - ]: 16 : StackMode_Y_STACKED_PERCENT, true ));
[ + - ]
306 : 16 : 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 [ + - ][ + - ]: 4 : StackMode_Y_STACKED, false, true, 3 ));
[ + - ]
314 : 4 : break;
315 : : case TEMPLATE_PERCENTSTACKEDTHREEDLINE:
316 : : xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
317 [ + - ][ + - ]: 16 : StackMode_Y_STACKED_PERCENT, false, true, 3 ));
[ + - ]
318 : 16 : 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 [ + - ][ + - ]: 239 : StackMode_NONE, BarChartTypeTemplate::VERTICAL ));
[ + - ]
328 : 239 : break;
329 : : case TEMPLATE_STACKEDCOLUMN:
330 : : xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
331 [ + - ][ + - ]: 4 : StackMode_Y_STACKED, BarChartTypeTemplate::VERTICAL ));
[ + - ]
332 : 4 : break;
333 : : case TEMPLATE_PERCENTSTACKEDCOLUMN:
334 : : xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
335 [ + - ][ + - ]: 16 : StackMode_Y_STACKED_PERCENT, BarChartTypeTemplate::VERTICAL ));
[ + - ]
336 : 16 : break;
337 : : case TEMPLATE_BAR:
338 : : xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
339 [ + - ][ + - ]: 177 : StackMode_NONE, BarChartTypeTemplate::HORIZONTAL ));
[ + - ]
340 : 177 : break;
341 : : case TEMPLATE_STACKEDBAR:
342 : : xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
343 [ + - ][ + - ]: 4 : StackMode_Y_STACKED, BarChartTypeTemplate::HORIZONTAL ));
[ + - ]
344 : 4 : break;
345 : : case TEMPLATE_PERCENTSTACKEDBAR:
346 : : xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
347 [ + - ][ + - ]: 16 : StackMode_Y_STACKED_PERCENT, BarChartTypeTemplate::HORIZONTAL ));
[ + - ]
348 : 16 : 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 [ + - ][ + - ]: 4 : StackMode_Y_STACKED, BarChartTypeTemplate::VERTICAL, 3 ));
[ + - ]
360 : 4 : break;
361 : : case TEMPLATE_PERCENTSTACKEDTHREEDCOLUMNFLAT:
362 : : xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
363 [ + - ][ + - ]: 16 : StackMode_Y_STACKED_PERCENT, BarChartTypeTemplate::VERTICAL, 3 ));
[ + - ]
364 : 16 : 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 [ + - ][ + - ]: 4 : StackMode_Y_STACKED, BarChartTypeTemplate::HORIZONTAL, 3 ));
[ + - ]
376 : 4 : break;
377 : : case TEMPLATE_PERCENTSTACKEDTHREEDBARFLAT:
378 : : xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
379 [ + - ][ + - ]: 16 : StackMode_Y_STACKED_PERCENT, BarChartTypeTemplate::HORIZONTAL, 3 ));
[ + - ]
380 : 16 : 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 : 30 : : StackMode_Y_STACKED;
389 : :
390 [ + - ][ + - ]: 30 : xTemplate.set( new ColumnLineChartTypeTemplate( m_xContext, aServiceSpecifier, eMode, 1 ));
[ + - ]
391 : : }
392 : 30 : break;
393 : :
394 : : // Area
395 : : case TEMPLATE_AREA:
396 [ + - ][ + - ]: 177 : xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode_NONE ));
[ + - ]
397 : 177 : break;
398 : : case TEMPLATE_STACKEDAREA:
399 [ + - ][ + - ]: 4 : xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode_Y_STACKED ));
[ + - ]
400 : 4 : break;
401 : : case TEMPLATE_PERCENTSTACKEDAREA:
402 [ + - ][ + - ]: 16 : xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode_Y_STACKED_PERCENT ));
[ + - ]
403 : 16 : 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 [ + - ][ + - ]: 4 : xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode_Y_STACKED, 3 ));
[ + - ]
409 : 4 : break;
410 : : case TEMPLATE_PERCENTSTACKEDTHREEDAREA:
411 [ + - ][ + - ]: 16 : xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode_Y_STACKED_PERCENT, 3 ));
[ + - ]
412 : 16 : break;
413 : :
414 : : case TEMPLATE_PIE:
415 : : xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
416 [ + - ][ + - ]: 20 : chart2::PieChartOffsetMode_NONE, false ));
[ + - ]
417 : 20 : break;
418 : : case TEMPLATE_PIEALLEXPLODED:
419 : : xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
420 [ + - ][ + - ]: 10 : chart2::PieChartOffsetMode_ALL_EXPLODED, false ));
[ + - ]
421 : 10 : break;
422 : : case TEMPLATE_DONUT:
423 : : xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
424 [ + - ][ + - ]: 26 : chart2::PieChartOffsetMode_NONE, true ));
[ + - ]
425 : 26 : break;
426 : : case TEMPLATE_DONUTALLEXPLODED:
427 : : xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
428 [ + - ][ + - ]: 26 : chart2::PieChartOffsetMode_ALL_EXPLODED, true ));
[ + - ]
429 : 26 : 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 [ + - ][ + - ]: 16 : xTemplate.set( new ScatterChartTypeTemplate( m_xContext, aServiceSpecifier, /* bSymbols */ true ));
[ + - ]
449 : 16 : break;
450 : : case TEMPLATE_SCATTERLINE:
451 [ + - ][ + - ]: 10 : xTemplate.set( new ScatterChartTypeTemplate( m_xContext, aServiceSpecifier, /* bSymbols */ false ));
[ + - ]
452 : 10 : break;
453 : : case TEMPLATE_SCATTERSYMBOL:
454 [ + - ][ + - ]: 4 : xTemplate.set( new ScatterChartTypeTemplate( m_xContext, aServiceSpecifier, /* bSymbols */ true, /* bHasLines */ false ));
[ + - ]
455 : 4 : 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 [ + - ][ + - ]: 16 : StackMode_NONE, true ));
[ + - ]
464 : 16 : break;
465 : : case TEMPLATE_NETSYMBOL:
466 : : xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
467 [ + - ][ + - ]: 16 : StackMode_NONE, true, false ));
[ + - ]
468 : 16 : break;
469 : : case TEMPLATE_NETLINE:
470 : : xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
471 [ + - ][ + - ]: 16 : StackMode_NONE, false ));
[ + - ]
472 : 16 : break;
473 : :
474 : : case TEMPLATE_STACKEDNET:
475 : : xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
476 [ + - ][ + - ]: 4 : StackMode_Y_STACKED, true ));
[ + - ]
477 : 4 : break;
478 : : case TEMPLATE_STACKEDNETSYMBOL:
479 : : xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
480 [ + - ][ + - ]: 4 : StackMode_Y_STACKED, true, false ));
[ + - ]
481 : 4 : break;
482 : : case TEMPLATE_STACKEDNETLINE:
483 : : xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
484 [ + - ][ + - ]: 4 : StackMode_Y_STACKED, false, true ));
[ + - ]
485 : 4 : break;
486 : :
487 : : case TEMPLATE_PERCENTSTACKEDNET:
488 : : xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
489 [ + - ][ + - ]: 16 : StackMode_Y_STACKED_PERCENT, true ));
[ + - ]
490 : 16 : break;
491 : : case TEMPLATE_PERCENTSTACKEDNETSYMBOL:
492 : : xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
493 [ + - ][ + - ]: 16 : StackMode_Y_STACKED_PERCENT, true, false ));
[ + - ]
494 : 16 : break;
495 : : case TEMPLATE_PERCENTSTACKEDNETLINE:
496 : : xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
497 [ + - ][ + - ]: 16 : StackMode_Y_STACKED_PERCENT, false, true ));
[ + - ]
498 : 16 : break;
499 : :
500 : : case TEMPLATE_FILLEDNET:
501 : : xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
502 [ + - ][ + - ]: 26 : StackMode_NONE, false, false, true ));
[ + - ]
503 : 26 : break;
504 : : case TEMPLATE_STACKEDFILLEDNET:
505 : : xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
506 [ + - ][ + - ]: 4 : StackMode_Y_STACKED, false, false, true ));
[ + - ]
507 : 4 : break;
508 : : case TEMPLATE_PERCENTSTACKEDFILLEDNET:
509 : : xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
510 [ + - ][ + - ]: 16 : StackMode_Y_STACKED_PERCENT, false, false, true ));
[ + - ]
511 : 16 : break;
512 : :
513 : : case TEMPLATE_STOCKLOWHIGHCLOSE:
514 : : xTemplate.set( new StockChartTypeTemplate( m_xContext, aServiceSpecifier,
515 [ + - ][ + - ]: 8 : StockChartTypeTemplate::LOW_HI_CLOSE, false ));
[ + - ]
516 : 8 : 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 [ + - ][ + - ]: 177 : xTemplate.set( new BubbleChartTypeTemplate( m_xContext, aServiceSpecifier ));
[ + - ]
533 : 177 : 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 [ + - ]: 1322 : xResult.set( xTemplate, uno::UNO_QUERY );
544 : : }
545 : :
546 : 1322 : 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 : 177 : uno::Sequence< OUString > SAL_CALL ChartTypeManager::getAvailableServiceNames()
560 : : throw (uno::RuntimeException)
561 : : {
562 [ + - ]: 177 : ::std::vector< OUString > aServices;
563 [ + - ]: 177 : const tTemplateMapType & rMap = lcl_DefaultChartTypeMap();
564 [ + - ]: 177 : aServices.reserve( rMap.size());
565 : :
566 : : // get own default templates
567 : : ::std::transform( rMap.begin(), rMap.end(), ::std::back_inserter( aServices ),
568 [ + - ][ + - ]: 177 : ::o3tl::select1st< tTemplateMapType::value_type >());
569 : :
570 : : // add components that were registered in the context's factory
571 : : uno::Reference< container::XContentEnumerationAccess > xEnumAcc(
572 [ + - ][ + - ]: 177 : m_xContext->getServiceManager(), uno::UNO_QUERY );
[ + - ]
573 [ + - ]: 177 : if( xEnumAcc.is())
574 : : {
575 : : uno::Reference< container::XEnumeration > xEnum(
576 [ + - ][ + - ]: 177 : xEnumAcc->createContentEnumeration( C2U( "com.sun.star.chart2.ChartTypeTemplate" ) ));
[ + - ]
577 [ + - ]: 177 : if( xEnum.is())
578 : : {
579 : 177 : uno::Reference< uno::XInterface > xFactIntf;
580 : :
581 [ + - ][ + - ]: 177 : 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 : 177 : }
590 : 177 : }
591 : : }
592 : :
593 [ + - ]: 177 : return ContainerHelper::ContainerToSequence( aServices );
594 : : }
595 : :
596 : : // ____ XServiceInfo ____
597 : 14 : Sequence< OUString > ChartTypeManager::getSupportedServiceNames_Static()
598 : : {
599 : 14 : Sequence< OUString > aServices( 2 );
600 [ + - ][ + - ]: 14 : aServices[ 0 ] = C2U( "com.sun.star.chart2.ChartTypeManager" );
601 [ + - ][ + - ]: 14 : aServices[ 1 ] = C2U( "com.sun.star.lang.MultiServiceFactory" );
602 : 14 : return aServices;
603 : : }
604 : :
605 : : // ================================================================================
606 : :
607 : : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
608 [ # # ][ # # ]: 173 : APPHELPER_XSERVICEINFO_IMPL( ChartTypeManager,
[ # # ][ # # ]
[ # # ]
609 : : C2U( "com.sun.star.comp.chart.ChartTypeManager" ));
610 : : } // namespace chart
611 : :
612 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|