LCOV - code coverage report
Current view: top level - chart2/source/model/template - ChartTypeManager.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 244 259 94.2 %
Date: 2015-06-13 12:38:46 Functions: 12 14 85.7 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.11