xref: /trunk/main/chart2/source/model/template/ChartTypeManager.cxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
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_chartmodel.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 {
244     uno::Reference< uno::XInterface > xResult;
245     TemplateId nId = lcl_GetTemplateIdForService( aServiceSpecifier );
246 
247     if( nId == TEMPLATE_NOT_FOUND )
248     {
249         try
250         {
251             xResult = m_xContext->getServiceManager()->createInstanceWithContext(
252                 aServiceSpecifier, m_xContext );
253         }
254 //         catch( registry::InvalidValueException & ex )
255         catch( uno::Exception & ex )
256         {
257             // couldn't create service via factory
258 
259             // As XMultiServiceFactory does not specify, what to do in case
260             // createInstance is called with an unknown service-name, this
261             // function will just return an empty XInterface.
262             ASSERT_EXCEPTION( ex );
263             OSL_TRACE( "Couldn't instantiate service \"%s\"", U2C( aServiceSpecifier ));
264             xResult.set( 0 );
265         }
266     }
267     else
268     {
269         uno::Reference< chart2::XChartTypeTemplate > xTemplate;
270         switch( nId )
271         {
272             // Point (category x axis)
273             case TEMPLATE_SYMBOL:
274                 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
275                     StackMode_NONE, true, false ));
276                 break;
277             case TEMPLATE_STACKEDSYMBOL:
278                 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
279                     StackMode_Y_STACKED, true, false ));
280                 break;
281             case TEMPLATE_PERCENTSTACKEDSYMBOL:
282                 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
283                     StackMode_Y_STACKED_PERCENT, true, false ));
284                 break;
285             // Line (category x axis)
286             case TEMPLATE_LINE:
287                 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
288                     StackMode_NONE, false ));
289                 break;
290             case TEMPLATE_STACKEDLINE:
291                 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
292                     StackMode_Y_STACKED, false ));
293                 break;
294             case TEMPLATE_PERCENTSTACKEDLINE:
295                 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
296                     StackMode_Y_STACKED_PERCENT, false ));
297                 break;
298             case TEMPLATE_LINESYMBOL:
299                 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
300                     StackMode_NONE, true ));
301                 break;
302             case TEMPLATE_STACKEDLINESYMBOL:
303                 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
304                     StackMode_Y_STACKED, true ));
305                 break;
306             case TEMPLATE_PERCENTSTACKEDLINESYMBOL:
307                 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
308                     StackMode_Y_STACKED_PERCENT, true ));
309                 break;
310             case TEMPLATE_THREEDLINE:
311                 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
312                     StackMode_NONE, false, true, 3 ));
313                 break;
314             case TEMPLATE_STACKEDTHREEDLINE:
315                 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
316                     StackMode_Y_STACKED, false, true, 3 ));
317                 break;
318             case TEMPLATE_PERCENTSTACKEDTHREEDLINE:
319                 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
320                     StackMode_Y_STACKED_PERCENT, false, true, 3 ));
321                 break;
322             case TEMPLATE_THREEDLINEDEEP:
323                 xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
324                     StackMode_Z_STACKED, false, true, 3 ));
325                 break;
326 
327             // Bar/Column
328             case TEMPLATE_COLUMN:
329                 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
330                     StackMode_NONE, BarChartTypeTemplate::VERTICAL ));
331                 break;
332             case TEMPLATE_STACKEDCOLUMN:
333                 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
334                     StackMode_Y_STACKED, BarChartTypeTemplate::VERTICAL ));
335                 break;
336             case TEMPLATE_PERCENTSTACKEDCOLUMN:
337                 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
338                     StackMode_Y_STACKED_PERCENT, BarChartTypeTemplate::VERTICAL ));
339                 break;
340             case TEMPLATE_BAR:
341                 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
342                     StackMode_NONE, BarChartTypeTemplate::HORIZONTAL ));
343                 break;
344             case TEMPLATE_STACKEDBAR:
345                 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
346                     StackMode_Y_STACKED, BarChartTypeTemplate::HORIZONTAL ));
347                 break;
348             case TEMPLATE_PERCENTSTACKEDBAR:
349                 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
350                     StackMode_Y_STACKED_PERCENT, BarChartTypeTemplate::HORIZONTAL ));
351                 break;
352             case TEMPLATE_THREEDCOLUMNDEEP:
353                 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
354                     StackMode_Z_STACKED, BarChartTypeTemplate::VERTICAL, 3 ));
355                 break;
356             case TEMPLATE_THREEDCOLUMNFLAT:
357                 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
358                     StackMode_NONE, BarChartTypeTemplate::VERTICAL, 3 ));
359                 break;
360             case TEMPLATE_STACKEDTHREEDCOLUMNFLAT:
361                 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
362                     StackMode_Y_STACKED, BarChartTypeTemplate::VERTICAL, 3 ));
363                 break;
364             case TEMPLATE_PERCENTSTACKEDTHREEDCOLUMNFLAT:
365                 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
366                     StackMode_Y_STACKED_PERCENT, BarChartTypeTemplate::VERTICAL, 3 ));
367                 break;
368             case TEMPLATE_THREEDBARDEEP:
369                 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
370                     StackMode_Z_STACKED, BarChartTypeTemplate::HORIZONTAL, 3 ));
371                 break;
372             case TEMPLATE_THREEDBARFLAT:
373                 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
374                     StackMode_NONE, BarChartTypeTemplate::HORIZONTAL, 3 ));
375                 break;
376             case TEMPLATE_STACKEDTHREEDBARFLAT:
377                 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
378                     StackMode_Y_STACKED, BarChartTypeTemplate::HORIZONTAL, 3 ));
379                 break;
380             case TEMPLATE_PERCENTSTACKEDTHREEDBARFLAT:
381                 xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
382                     StackMode_Y_STACKED_PERCENT, BarChartTypeTemplate::HORIZONTAL, 3 ));
383                 break;
384 
385             // Combi-Chart Line/Column
386             case TEMPLATE_COLUMNWITHLINE:
387             case TEMPLATE_STACKEDCOLUMNWITHLINE:
388             {
389                 StackMode eMode = ( nId == TEMPLATE_COLUMNWITHLINE )
390                     ? StackMode_NONE
391                     : StackMode_Y_STACKED;
392 
393                 xTemplate.set( new ColumnLineChartTypeTemplate( m_xContext, aServiceSpecifier, eMode, 1 ));
394             }
395             break;
396 
397             // Area
398             case TEMPLATE_AREA:
399                 xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode_NONE ));
400                 break;
401             case TEMPLATE_STACKEDAREA:
402                 xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode_Y_STACKED ));
403                 break;
404             case TEMPLATE_PERCENTSTACKEDAREA:
405                 xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode_Y_STACKED_PERCENT ));
406                 break;
407             case TEMPLATE_THREEDAREA:
408                 xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode_Z_STACKED, 3 ));
409                 break;
410             case TEMPLATE_STACKEDTHREEDAREA:
411                 xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode_Y_STACKED, 3 ));
412                 break;
413             case TEMPLATE_PERCENTSTACKEDTHREEDAREA:
414                 xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode_Y_STACKED_PERCENT, 3 ));
415                 break;
416 
417             case TEMPLATE_PIE:
418                 xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
419                     chart2::PieChartOffsetMode_NONE, false ));
420                 break;
421             case TEMPLATE_PIEALLEXPLODED:
422                 xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
423                     chart2::PieChartOffsetMode_ALL_EXPLODED, false ));
424                 break;
425             case TEMPLATE_DONUT:
426                 xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
427                     chart2::PieChartOffsetMode_NONE, true ));
428                 break;
429             case TEMPLATE_DONUTALLEXPLODED:
430                 xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
431                     chart2::PieChartOffsetMode_ALL_EXPLODED, true ));
432                 break;
433             case TEMPLATE_THREEDPIE:
434                 xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
435                     chart2::PieChartOffsetMode_NONE, false, 3 ));
436                 break;
437             case TEMPLATE_THREEDPIEALLEXPLODED:
438                 xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
439                     chart2::PieChartOffsetMode_ALL_EXPLODED, false, 3 ));
440                 break;
441             case TEMPLATE_THREEDDONUT:
442                 xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
443                     chart2::PieChartOffsetMode_NONE, true, 3 ));
444                 break;
445             case TEMPLATE_THREEDDONUTALLEXPLODED:
446                 xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
447                     chart2::PieChartOffsetMode_ALL_EXPLODED, true, 3 ));
448                 break;
449 
450             case TEMPLATE_SCATTERLINESYMBOL:
451                 xTemplate.set( new ScatterChartTypeTemplate( m_xContext, aServiceSpecifier, /* bSymbols */ true ));
452                 break;
453             case TEMPLATE_SCATTERLINE:
454                 xTemplate.set( new ScatterChartTypeTemplate( m_xContext, aServiceSpecifier, /* bSymbols */ false ));
455                 break;
456             case TEMPLATE_SCATTERSYMBOL:
457                 xTemplate.set( new ScatterChartTypeTemplate( m_xContext, aServiceSpecifier, /* bSymbols */ true, /* bHasLines */ false ));
458                 break;
459             case TEMPLATE_THREEDSCATTER:
460                 xTemplate.set( new ScatterChartTypeTemplate( m_xContext, aServiceSpecifier, /* bSymbols */ false, /* bHasLines */ true, 3 ));
461                 break;
462 
463             // NetChart
464             case TEMPLATE_NET:
465                 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
466                     StackMode_NONE, true ));
467                 break;
468             case TEMPLATE_NETSYMBOL:
469                 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
470                     StackMode_NONE, true, false ));
471                 break;
472             case TEMPLATE_NETLINE:
473                 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
474                     StackMode_NONE, false ));
475                 break;
476 
477             case TEMPLATE_STACKEDNET:
478                 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
479                     StackMode_Y_STACKED, true ));
480                 break;
481             case TEMPLATE_STACKEDNETSYMBOL:
482                 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
483                     StackMode_Y_STACKED, true, false ));
484                 break;
485             case TEMPLATE_STACKEDNETLINE:
486                 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
487                     StackMode_Y_STACKED, false, true ));
488                 break;
489 
490             case TEMPLATE_PERCENTSTACKEDNET:
491                 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
492                     StackMode_Y_STACKED_PERCENT, true ));
493                 break;
494             case TEMPLATE_PERCENTSTACKEDNETSYMBOL:
495                 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
496                     StackMode_Y_STACKED_PERCENT, true, false ));
497                 break;
498             case TEMPLATE_PERCENTSTACKEDNETLINE:
499                 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
500                     StackMode_Y_STACKED_PERCENT, false, true ));
501                 break;
502 
503             case TEMPLATE_FILLEDNET:
504                 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
505                     StackMode_NONE, false, false, true ));
506                 break;
507             case TEMPLATE_STACKEDFILLEDNET:
508                 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
509                     StackMode_Y_STACKED, false, false, true ));
510                 break;
511             case TEMPLATE_PERCENTSTACKEDFILLEDNET:
512                 xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
513                     StackMode_Y_STACKED_PERCENT, false, false, true ));
514                 break;
515 
516             case TEMPLATE_STOCKLOWHIGHCLOSE:
517                 xTemplate.set( new StockChartTypeTemplate( m_xContext, aServiceSpecifier,
518                     StockChartTypeTemplate::LOW_HI_CLOSE, false ));
519                 break;
520             case TEMPLATE_STOCKOPENLOWHIGHCLOSE:
521                 xTemplate.set( new StockChartTypeTemplate( m_xContext, aServiceSpecifier,
522                     StockChartTypeTemplate::OPEN_LOW_HI_CLOSE, true ));
523                 break;
524             case TEMPLATE_STOCKVOLUMELOWHIGHCLOSE:
525                 xTemplate.set( new StockChartTypeTemplate( m_xContext, aServiceSpecifier,
526                     StockChartTypeTemplate::VOL_LOW_HI_CLOSE, false ));
527                 break;
528             case TEMPLATE_STOCKVOLUMEOPENLOWHIGHCLOSE:
529                 xTemplate.set( new StockChartTypeTemplate( m_xContext, aServiceSpecifier,
530                     StockChartTypeTemplate::VOL_OPEN_LOW_HI_CLOSE, true ));
531                 break;
532 
533             //BubbleChart
534             case TEMPLATE_BUBBLE:
535                 xTemplate.set( new BubbleChartTypeTemplate( m_xContext, aServiceSpecifier ));
536                 break;
537 
538 //            case TEMPLATE_SURFACE:
539 //            case TEMPLATE_ADDIN:
540 //               break;
541 
542             case TEMPLATE_NOT_FOUND:
543                 OSL_ASSERT( false );
544                 break;
545         }
546         xResult.set( xTemplate, uno::UNO_QUERY );
547     }
548 
549     return xResult;
550 }
551 
createInstanceWithArguments(const OUString & ServiceSpecifier,const uno::Sequence<uno::Any> &)552 uno::Reference< uno::XInterface > SAL_CALL ChartTypeManager::createInstanceWithArguments(
553     const OUString& ServiceSpecifier,
554     const uno::Sequence< uno::Any >& /* Arguments */ )
555 {
556     OSL_ENSURE( false, "createInstanceWithArguments: No arguments supported" );
557     return createInstance( ServiceSpecifier );
558 }
559 
getAvailableServiceNames()560 uno::Sequence< OUString > SAL_CALL ChartTypeManager::getAvailableServiceNames()
561 {
562     ::std::vector< OUString > aServices;
563     const tTemplateMapType & rMap = lcl_DefaultChartTypeMap();
564     aServices.reserve( rMap.size());
565 
566     // get own default templates
567     ::std::transform( rMap.begin(), rMap.end(), ::std::back_inserter( aServices ),
568                       ::std::select1st< tTemplateMapType::value_type >());
569 
570     // add components that were registered in the context's factory
571     uno::Reference< container::XContentEnumerationAccess > xEnumAcc(
572         m_xContext->getServiceManager(), uno::UNO_QUERY );
573     if( xEnumAcc.is())
574     {
575         uno::Reference< container::XEnumeration > xEnum(
576             xEnumAcc->createContentEnumeration( C2U( "com.sun.star.chart2.ChartTypeTemplate" ) ));
577         if( xEnum.is())
578         {
579             uno::Reference< uno::XInterface > xFactIntf;
580 
581             while( xEnum->hasMoreElements())
582             {
583                 if( xEnum->nextElement() >>= xFactIntf )
584                 {
585                     uno::Reference< lang::XServiceName > xServiceName( xFactIntf, uno::UNO_QUERY );
586                     if( xServiceName.is())
587                         aServices.push_back( xServiceName->getServiceName());
588                 }
589             }
590         }
591     }
592 
593     return ContainerHelper::ContainerToSequence( aServices );
594 }
595 
596 // ____ XServiceInfo ____
getSupportedServiceNames_Static()597 Sequence< OUString > ChartTypeManager::getSupportedServiceNames_Static()
598 {
599     Sequence< OUString > aServices( 2 );
600     aServices[ 0 ] = C2U( "com.sun.star.chart2.ChartTypeManager" );
601     aServices[ 1 ] = C2U( "com.sun.star.lang.MultiServiceFactory" );
602     return aServices;
603 }
604 
605 // ================================================================================
606 
607 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
608 APPHELPER_XSERVICEINFO_IMPL( ChartTypeManager,
609                              C2U( "com.sun.star.comp.chart.ChartTypeManager" ));
610 } //  namespace chart
611