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

Generated by: LCOV version 1.10