LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/chart2/source/tools - ChartTypeHelper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 256 389 65.8 %
Date: 2013-07-09 Functions: 21 30 70.0 %
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             : 
      21             : #include "ChartTypeHelper.hxx"
      22             : #include "DiagramHelper.hxx"
      23             : #include "DataSeriesHelper.hxx"
      24             : #include "macros.hxx"
      25             : #include "servicenames_charttypes.hxx"
      26             : 
      27             : #include <com/sun/star/beans/XPropertySet.hpp>
      28             : #include <com/sun/star/chart/DataLabelPlacement.hpp>
      29             : #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
      30             : #include <com/sun/star/chart/MissingValueTreatment.hpp>
      31             : 
      32             : //.............................................................................
      33             : using namespace ::com::sun::star;
      34             : using namespace ::com::sun::star::chart2;
      35             : 
      36             : //.............................................................................
      37             : namespace chart
      38             : {
      39             : 
      40           0 : bool ChartTypeHelper::isSupportingAxisSideBySide(
      41             :     const uno::Reference< chart2::XChartType >& xChartType, sal_Int32 nDimensionCount )
      42             : {
      43           0 :     bool bResult = false;
      44             : 
      45           0 :     if( xChartType.is() &&
      46             :         nDimensionCount < 3 )
      47             :     {
      48           0 :         bool bFound=false;
      49           0 :         bool bAmbiguous=false;
      50           0 :         StackMode eStackMode = DiagramHelper::getStackModeFromChartType( xChartType, bFound, bAmbiguous, 0 );
      51           0 :         if( eStackMode == StackMode_NONE && !bAmbiguous )
      52             :         {
      53           0 :             OUString aChartTypeName = xChartType->getChartType();
      54           0 :             bResult = ( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN) ||
      55           0 :                         aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR) );
      56             :         }
      57             :     }
      58             : 
      59           0 :     return bResult;
      60             : }
      61             : 
      62           0 : sal_Bool ChartTypeHelper::isSupportingGeometryProperties( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
      63             : {
      64             :     //form tab only for 3D-bar and 3D-column charts.
      65             : 
      66             :     //@todo ask charttype itself --> need model change first
      67           0 :     if(xChartType.is())
      68             :     {
      69           0 :         if(nDimensionCount==3)
      70             :         {
      71           0 :             OUString aChartTypeName = xChartType->getChartType();
      72           0 :             if( aChartTypeName.equals(CHART2_SERVICE_NAME_CHARTTYPE_BAR) )
      73           0 :                 return sal_True;
      74           0 :             if( aChartTypeName.equals(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN) )
      75           0 :                 return sal_True;
      76             :         }
      77             :     }
      78           0 :     return sal_False;
      79             : }
      80             : 
      81        6941 : sal_Bool ChartTypeHelper::isSupportingStatisticProperties( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
      82             : {
      83             :     //3D charts, pie, net and stock do not support statistic properties
      84             : 
      85             :     //@todo ask charttype itself (and series? --> stock chart?)  --> need model change first
      86        6941 :     if(xChartType.is())
      87             :     {
      88        6923 :         if(nDimensionCount==3)
      89         135 :             return sal_False;
      90             : 
      91        6879 :         OUString aChartTypeName = xChartType->getChartType();
      92        6879 :         if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
      93          37 :             return sal_False;
      94        6842 :         if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
      95           0 :             return sal_False;
      96        6842 :         if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) )
      97           0 :             return sal_False;
      98        6842 :         if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
      99          10 :             return sal_False;
     100        6832 :         if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE) ) //todo: BubbleChart support error bars and trend lines
     101           0 :             return sal_False;
     102             :     }
     103        6850 :     return sal_True;
     104             : }
     105             : 
     106           0 : sal_Bool ChartTypeHelper::isSupportingRegressionProperties( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
     107             : {
     108             :     // note: old chart: only scatter chart
     109           0 :     return isSupportingStatisticProperties( xChartType, nDimensionCount );
     110             : }
     111             : 
     112         372 : sal_Bool ChartTypeHelper::isSupportingAreaProperties( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
     113             : {
     114             :     //2D line charts, net and stock do not support area properties
     115             : 
     116             :     //@todo ask charttype itself --> need model change first
     117         372 :     if(xChartType.is())
     118             :     {
     119         372 :          if(nDimensionCount==2)
     120             :         {
     121         372 :             OUString aChartTypeName = xChartType->getChartType();
     122         372 :             if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_LINE) )
     123          14 :                 return sal_False;
     124         358 :             if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) )
     125          30 :                 return sal_False;
     126         328 :             if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
     127           0 :                 return sal_False;
     128         328 :             if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
     129           0 :                 return sal_False;
     130             :         }
     131             :     }
     132         328 :     return sal_True;
     133             : }
     134             : 
     135          90 : sal_Bool ChartTypeHelper::isSupportingSymbolProperties( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
     136             : {
     137             :     //2D line charts, 2D scatter charts and 2D net charts do support symbols
     138             : 
     139             :     //@todo ask charttype itself --> need model change first
     140          90 :     if(xChartType.is())
     141             :     {
     142          90 :         if(nDimensionCount==3)
     143          46 :             return sal_False;
     144             : 
     145          84 :         OUString aChartTypeName = xChartType->getChartType();
     146          84 :         if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_LINE) )
     147          23 :             return sal_True;
     148          61 :         if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) )
     149          11 :             return sal_True;
     150          50 :         if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
     151           0 :             return sal_True;
     152             :     }
     153          50 :     return sal_False;
     154             : }
     155             : 
     156        5328 : sal_Bool ChartTypeHelper::isSupportingMainAxis( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount, sal_Int32 nDimensionIndex )
     157             : {
     158             :     //pie charts do not support axis at all
     159             :     //no 3rd axis for 2D charts
     160             : 
     161             :     //@todo ask charttype itself --> need model change first
     162        5328 :     if(xChartType.is())
     163             :     {
     164        5266 :         OUString aChartTypeName = xChartType->getChartType();
     165        5266 :         if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
     166         119 :             return sal_False;
     167             : 
     168        5147 :         if( nDimensionIndex == 2 )
     169         530 :             return nDimensionCount == 3;
     170             :     }
     171        4679 :     return sal_True;
     172             : }
     173             : 
     174        1085 : sal_Bool ChartTypeHelper::isSupportingSecondaryAxis( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount, sal_Int32 /*nDimensionIndex*/ )
     175             : {
     176             :     //3D, pie and net charts do not support a secondary axis at all
     177             : 
     178             :     //@todo ask charttype itself --> need model change first
     179        1085 :     if(xChartType.is())
     180             :     {
     181        1057 :          if(nDimensionCount==3)
     182          64 :             return sal_False;
     183             : 
     184        1038 :         OUString aChartTypeName = xChartType->getChartType();
     185        1038 :         if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
     186          26 :             return sal_False;
     187        1012 :         if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
     188           0 :             return sal_False;
     189        1012 :         if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) )
     190           0 :             return sal_False;
     191             :     }
     192        1040 :     return sal_True;
     193             : }
     194             : 
     195           0 : sal_Bool ChartTypeHelper::isSupportingOverlapAndGapWidthProperties(
     196             :         const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
     197             : {
     198             :     //2D bar charts do support a this special properties
     199             : 
     200             :     //@todo ask charttype itself --> need model change first
     201           0 :     if(xChartType.is())
     202             :     {
     203           0 :          if(nDimensionCount==3)
     204           0 :             return sal_False;
     205             : 
     206           0 :         OUString aChartTypeName = xChartType->getChartType();
     207           0 :         if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN) )
     208           0 :             return sal_True;
     209           0 :         if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR) )
     210           0 :             return sal_True;
     211             :     }
     212           0 :     return sal_False;
     213             : }
     214             : 
     215           0 : sal_Bool ChartTypeHelper::isSupportingBarConnectors(
     216             :     const uno::Reference< chart2::XChartType >& xChartType, sal_Int32 nDimensionCount )
     217             : {
     218             :     //2D bar charts with stacked series support this
     219             : 
     220             :     //@todo ask charttype itself --> need model change first
     221           0 :     if(xChartType.is())
     222             :     {
     223           0 :         if(nDimensionCount==3)
     224           0 :             return sal_False;
     225             : 
     226           0 :         bool bFound=false;
     227           0 :         bool bAmbiguous=false;
     228           0 :         StackMode eStackMode = DiagramHelper::getStackModeFromChartType( xChartType, bFound, bAmbiguous, 0 );
     229           0 :         if( eStackMode != StackMode_Y_STACKED || bAmbiguous )
     230           0 :             return sal_False;
     231             : 
     232           0 :         OUString aChartTypeName = xChartType->getChartType();
     233           0 :         if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN) )
     234           0 :             return sal_True;
     235           0 :         if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR) )
     236           0 :             return sal_True;  // note: old chart was false here
     237             :     }
     238           0 :     return sal_False;
     239             : }
     240             : 
     241        1373 : uno::Sequence < sal_Int32 > ChartTypeHelper::getSupportedLabelPlacements( const uno::Reference< chart2::XChartType >& xChartType
     242             :                                                                          , sal_Int32 nDimensionCount, sal_Bool bSwapXAndY
     243             :                                                                          , const uno::Reference< chart2::XDataSeries >& xSeries )
     244             : {
     245             :     (void)nDimensionCount;
     246             : 
     247        1373 :     uno::Sequence < sal_Int32 > aRet;
     248        1373 :     if( !xChartType.is() )
     249           0 :         return aRet;
     250             : 
     251        2746 :     OUString aChartTypeName = xChartType->getChartType();
     252        1373 :     if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
     253             :     {
     254           6 :         bool bDonut = false;
     255           6 :         uno::Reference< beans::XPropertySet > xChartTypeProp( xChartType, uno::UNO_QUERY_THROW );
     256           6 :         if(xChartTypeProp.is())
     257           6 :             xChartTypeProp->getPropertyValue( "UseRings") >>= bDonut;
     258             : 
     259           6 :         if(!bDonut)
     260             :         {
     261           6 :             aRet.realloc(4);
     262           6 :             sal_Int32* pSeq = aRet.getArray();
     263           6 :             *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::AVOID_OVERLAP;
     264           6 :             *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::OUTSIDE;
     265           6 :             *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::INSIDE;
     266           6 :             *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::CENTER;
     267             :         }
     268             :         else
     269             :         {
     270           0 :             aRet.realloc(1);
     271           0 :             sal_Int32* pSeq = aRet.getArray();
     272           0 :             *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::CENTER;
     273           6 :         }
     274             :     }
     275        5468 :     else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER)
     276        2676 :         || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_LINE)
     277        5968 :         || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE)
     278             :         )
     279             :     {
     280         867 :         aRet.realloc(5);
     281         867 :         sal_Int32* pSeq = aRet.getArray();
     282         867 :         *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::TOP;
     283         867 :         *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::BOTTOM;
     284         867 :         *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::LEFT;
     285         867 :         *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::RIGHT;
     286         867 :         *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::CENTER;
     287             :     }
     288        2000 :     else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN)
     289        2000 :         || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR) )
     290             :     {
     291             : 
     292         480 :         bool bStacked = false;
     293             :         {
     294         480 :             uno::Reference< beans::XPropertySet > xSeriesProp( xSeries, uno::UNO_QUERY );
     295         480 :             chart2::StackingDirection eStacking = chart2::StackingDirection_NO_STACKING;
     296         480 :             xSeriesProp->getPropertyValue( "StackingDirection" ) >>= eStacking;
     297         480 :             bStacked = (chart2::StackingDirection_Y_STACKING == eStacking);
     298             :         }
     299             : 
     300         480 :         aRet.realloc( bStacked ? 3 : 6 );
     301         480 :         sal_Int32* pSeq = aRet.getArray();
     302         480 :         if(!bStacked)
     303             :         {
     304         480 :             if(bSwapXAndY)
     305             :             {
     306           0 :                 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::RIGHT;
     307           0 :                 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::LEFT;
     308             :             }
     309             :             else
     310             :             {
     311         480 :                 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::TOP;
     312         480 :                 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::BOTTOM;
     313             :             }
     314             :         }
     315         480 :         *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::CENTER;
     316         480 :         if(!bStacked)
     317         480 :             *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::OUTSIDE;
     318         480 :         *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::INSIDE;
     319         480 :         *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::NEAR_ORIGIN;
     320             :     }
     321          20 :     else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_AREA) )
     322             :     {
     323           0 :         aRet.realloc(1);
     324           0 :         sal_Int32* pSeq = aRet.getArray();
     325           0 :         *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::TOP;
     326             :     }
     327          20 :     else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
     328             :     {
     329           0 :         aRet.realloc(6);
     330           0 :         sal_Int32* pSeq = aRet.getArray();
     331           0 :         *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::OUTSIDE;
     332           0 :         *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::TOP;
     333           0 :         *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::BOTTOM;
     334           0 :         *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::LEFT;
     335           0 :         *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::RIGHT;
     336           0 :         *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::CENTER;
     337             :     }
     338          20 :     else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) )
     339             :     {
     340           0 :         aRet.realloc(1);
     341           0 :         sal_Int32* pSeq = aRet.getArray();
     342           0 :         *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::OUTSIDE;
     343             :     }
     344          20 :     else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
     345             :     {
     346          20 :         aRet.realloc( 1 );
     347          20 :         sal_Int32* pSeq = aRet.getArray();
     348          20 :         *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::OUTSIDE;
     349             :     }
     350             :     else
     351             :     {
     352             :         OSL_FAIL( "unknown charttype" );
     353             :     }
     354             : 
     355        1373 :     return aRet;
     356             : }
     357             : 
     358          44 : sal_Bool ChartTypeHelper::isSupportingRightAngledAxes( const uno::Reference< chart2::XChartType >& xChartType )
     359             : {
     360          44 :     if(xChartType.is())
     361             :     {
     362          44 :         OUString aChartTypeName = xChartType->getChartType();
     363          44 :         if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
     364           0 :             return sal_False;
     365             :     }
     366          44 :     return sal_True;
     367             : }
     368             : 
     369           0 : bool ChartTypeHelper::isSupportingStartingAngle( const uno::Reference< chart2::XChartType >& xChartType )
     370             : {
     371           0 :     if(xChartType.is())
     372             :     {
     373           0 :         OUString aChartTypeName = xChartType->getChartType();
     374           0 :         if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
     375           0 :             return true;
     376             :     }
     377           0 :     return false;
     378             : }
     379           0 : bool ChartTypeHelper::isSupportingBaseValue( const uno::Reference< chart2::XChartType >& xChartType )
     380             : {
     381           0 :     if(xChartType.is())
     382             :     {
     383           0 :         OUString aChartTypeName = xChartType->getChartType();
     384           0 :         if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN)
     385           0 :             || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR)
     386           0 :             || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_AREA)
     387             :             )
     388           0 :             return true;
     389             :     }
     390           0 :     return false;
     391             : }
     392             : 
     393           0 : bool ChartTypeHelper::isSupportingAxisPositioning( const uno::Reference< chart2::XChartType >& xChartType, sal_Int32 nDimensionCount, sal_Int32 nDimensionIndex )
     394             : {
     395           0 :     if(xChartType.is())
     396             :     {
     397           0 :         OUString aChartTypeName = xChartType->getChartType();
     398           0 :         if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
     399           0 :             return false;
     400           0 :         if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) )
     401           0 :             return false;
     402             :     }
     403           0 :     if( nDimensionCount==3 )
     404           0 :         return nDimensionIndex<2;
     405           0 :     return true;
     406             : }
     407             : 
     408        4850 : bool ChartTypeHelper::isSupportingDateAxis( const uno::Reference< chart2::XChartType >& xChartType, sal_Int32 /*nDimensionCount*/, sal_Int32 nDimensionIndex )
     409             : {
     410        4850 :     if( nDimensionIndex!=0 )
     411         541 :         return false;
     412        4309 :     if( xChartType.is() )
     413             :     {
     414        4307 :         sal_Int32 nType = ChartTypeHelper::getAxisType( xChartType, nDimensionIndex );
     415        4307 :         if( nType != AxisType::CATEGORY )
     416          76 :             return false;
     417        4295 :         OUString aChartTypeName = xChartType->getChartType();
     418        4295 :         if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
     419          52 :             return false;
     420        4243 :         if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
     421           0 :             return false;
     422        4243 :         if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) )
     423           0 :             return false;
     424             :     }
     425        4245 :     return true;
     426             : }
     427             : 
     428         531 : bool ChartTypeHelper::shiftCategoryPosAtXAxisPerDefault( const uno::Reference< chart2::XChartType >& xChartType )
     429             : {
     430         531 :     if(xChartType.is())
     431             :     {
     432         531 :         OUString aChartTypeName = xChartType->getChartType();
     433        2124 :         if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN)
     434         586 :             || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR)
     435        2179 :             || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
     436         478 :             return true;
     437             :     }
     438          53 :     return false;
     439             : }
     440             : 
     441           0 : bool ChartTypeHelper::noBordersForSimpleScheme( const uno::Reference< chart2::XChartType >& xChartType )
     442             : {
     443           0 :     if(xChartType.is())
     444             :     {
     445           0 :         OUString aChartTypeName = xChartType->getChartType();
     446           0 :         if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
     447           0 :             return sal_True;
     448             :     }
     449           0 :     return sal_False;
     450             : }
     451             : 
     452          99 : sal_Int32 ChartTypeHelper::getDefaultDirectLightColor( bool bSimple, const uno::Reference< chart2::XChartType >& xChartType )
     453             : {
     454          99 :     sal_Int32 nRet = static_cast< sal_Int32 >( 0x808080 ); // grey
     455          99 :     if( xChartType .is() )
     456             :     {
     457          89 :         OUString aChartType = xChartType->getChartType();
     458          89 :         if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
     459             :         {
     460           2 :             if( bSimple )
     461           0 :                 nRet = static_cast< sal_Int32 >( 0x333333 ); // grey80
     462             :             else
     463           2 :                 nRet = static_cast< sal_Int32 >( 0xb3b3b3 ); // grey30
     464             :         }
     465         348 :         else if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_LINE)
     466         348 :             || aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) )
     467           7 :             nRet = static_cast< sal_Int32 >( 0x666666 ); // grey60
     468             :     }
     469          99 :     return nRet;
     470             : }
     471             : 
     472          99 : sal_Int32 ChartTypeHelper::getDefaultAmbientLightColor( bool bSimple, const uno::Reference< chart2::XChartType >& xChartType )
     473             : {
     474          99 :     sal_Int32 nRet = static_cast< sal_Int32 >( 0x999999 ); // grey40
     475          99 :     if( xChartType .is() )
     476             :     {
     477          89 :         OUString aChartType = xChartType->getChartType();
     478          89 :         if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
     479             :         {
     480           2 :             if( bSimple )
     481           0 :                 nRet = static_cast< sal_Int32 >( 0xcccccc ); // grey20
     482             :             else
     483           2 :                 nRet = static_cast< sal_Int32 >( 0x666666 ); // grey60
     484          89 :         }
     485             :     }
     486          99 :     return nRet;
     487             : }
     488             : 
     489          10 : drawing::Direction3D ChartTypeHelper::getDefaultSimpleLightDirection( const uno::Reference< chart2::XChartType >& xChartType )
     490             : {
     491          10 :     drawing::Direction3D aRet(0.0, 0.0, 1.0);
     492          10 :     if( xChartType .is() )
     493             :     {
     494           0 :         OUString aChartType = xChartType->getChartType();
     495           0 :         if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
     496           0 :             aRet = drawing::Direction3D(0.0, 0.8, 0.5);
     497           0 :         else if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_LINE)
     498           0 :             || aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) )
     499           0 :             aRet = drawing::Direction3D(0.9, 0.5, 0.05);
     500             :     }
     501          10 :     return aRet;
     502             : }
     503             : 
     504          89 : drawing::Direction3D ChartTypeHelper::getDefaultRealisticLightDirection( const uno::Reference< chart2::XChartType >& xChartType )
     505             : {
     506          89 :     drawing::Direction3D aRet(0.0, 0.0, 1.0);
     507          89 :     if( xChartType .is() )
     508             :     {
     509          89 :         OUString aChartType = xChartType->getChartType();
     510          89 :         if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
     511           2 :             aRet = drawing::Direction3D(0.6, 0.6, 0.6);
     512         348 :         else if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_LINE)
     513         348 :             || aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) )
     514           7 :             aRet = drawing::Direction3D(0.9, 0.5, 0.05);
     515             :     }
     516          89 :     return aRet;
     517             : }
     518             : 
     519        4307 : sal_Int32 ChartTypeHelper::getAxisType( const uno::Reference<
     520             :             XChartType >& xChartType, sal_Int32 nDimensionIndex )
     521             : {
     522             :     //retruned is a constant from constant group ::com::sun::star::chart2::AxisType
     523             : 
     524             :     //@todo ask charttype itself --> need model change first
     525        4307 :     if(!xChartType.is())
     526           0 :         return AxisType::CATEGORY;
     527             : 
     528        4307 :     OUString aChartTypeName = xChartType->getChartType();
     529        4307 :     if(2==nDimensionIndex)//z-axis
     530           0 :         return AxisType::SERIES;
     531        4307 :     if(1==nDimensionIndex)//y-axis
     532           0 :         return AxisType::REALNUMBER;
     533        4307 :     if(0==nDimensionIndex)//x-axis
     534             :     {
     535       17228 :         if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER)
     536       17228 :          || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE) )
     537          12 :             return AxisType::REALNUMBER;
     538        4295 :         return AxisType::CATEGORY;
     539             :     }
     540           0 :     return AxisType::CATEGORY;
     541             : }
     542             : 
     543         774 : sal_Int32 ChartTypeHelper::getNumberOfDisplayedSeries(
     544             :     const uno::Reference< XChartType >& xChartType,
     545             :     sal_Int32 nNumberOfSeries )
     546             : {
     547         774 :     if( xChartType.is() )
     548             :     {
     549             :         try
     550             :         {
     551         774 :             OUString aChartTypeName = xChartType->getChartType();
     552         774 :             if( aChartTypeName.equals(CHART2_SERVICE_NAME_CHARTTYPE_PIE))
     553             :             {
     554          14 :                 uno::Reference< beans::XPropertySet > xChartTypeProp( xChartType, uno::UNO_QUERY_THROW );
     555          14 :                 bool bDonut = false;
     556          42 :                 if( (xChartTypeProp->getPropertyValue( "UseRings") >>= bDonut)
     557          42 :                     && !bDonut )
     558             :                 {
     559          14 :                     return nNumberOfSeries>0 ? 1 : 0;
     560           0 :                 }
     561         760 :             }
     562             :         }
     563           0 :         catch( const uno::Exception & ex )
     564             :         {
     565             :             ASSERT_EXCEPTION( ex );
     566             :         }
     567             :     }
     568         760 :     return nNumberOfSeries;
     569             : }
     570             : 
     571         633 : uno::Sequence < sal_Int32 > ChartTypeHelper::getSupportedMissingValueTreatments( const uno::Reference< XChartType >& xChartType )
     572             : {
     573         633 :     uno::Sequence < sal_Int32 > aRet;
     574         633 :     if( !xChartType.is() )
     575           0 :         return aRet;
     576             : 
     577         633 :     bool bFound=false;
     578         633 :     bool bAmbiguous=false;
     579         633 :     StackMode eStackMode = DiagramHelper::getStackModeFromChartType( xChartType, bFound, bAmbiguous, 0 );
     580         633 :     bool bStacked = bFound && (StackMode_Y_STACKED == eStackMode);
     581             : 
     582        1266 :     OUString aChartTypeName = xChartType->getChartType();
     583        2698 :     if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN) ||
     584        2781 :         aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR) ||
     585         799 :         aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE) )
     586             :     {
     587         550 :         aRet.realloc( 2 );
     588         550 :         sal_Int32* pSeq = aRet.getArray();
     589         550 :         *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP;
     590         550 :         *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::USE_ZERO;
     591             :     }
     592          83 :     else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_AREA) )
     593             :     {
     594           0 :         aRet.realloc( bStacked ? 1 : 2 );
     595           0 :         sal_Int32* pSeq = aRet.getArray();
     596           0 :         *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::USE_ZERO;
     597           0 :         if( !bStacked )
     598           0 :             *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::CONTINUE;
     599             :     }
     600         420 :     else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_LINE) ||
     601         464 :         aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) ||
     602         171 :         aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) )
     603             :     {
     604          39 :         aRet.realloc( bStacked ? 2 : 3 );
     605          39 :         sal_Int32* pSeq = aRet.getArray();
     606          39 :         *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP;
     607          39 :         *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::USE_ZERO;
     608          39 :         if( !bStacked )
     609          38 :             *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::CONTINUE;
     610             :     }
     611          44 :     else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) )
     612             :     {
     613          25 :         aRet.realloc( 3 );
     614          25 :         sal_Int32* pSeq = aRet.getArray();
     615          25 :         *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::CONTINUE;
     616          25 :         *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP;
     617          25 :         *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::USE_ZERO;
     618             :     }
     619          46 :     else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) ||
     620          27 :         aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
     621             :     {
     622          19 :         aRet.realloc( 0 );
     623             :     }
     624             :     else
     625             :     {
     626             :         OSL_FAIL( "unknown charttype" );
     627             :     }
     628             : 
     629         633 :     return aRet;
     630             : }
     631             : 
     632         531 : bool ChartTypeHelper::isSeriesInFrontOfAxisLine( const uno::Reference< XChartType >& xChartType )
     633             : {
     634         531 :     if( xChartType.is() )
     635             :     {
     636         531 :         OUString aChartTypeName = xChartType->getChartType();
     637         531 :         if( aChartTypeName.match( CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET ) )
     638           0 :             return false;
     639             :     }
     640         531 :     return true;
     641             : }
     642             : 
     643         375 : OUString ChartTypeHelper::getRoleOfSequenceForYAxisNumberFormatDetection( const uno::Reference< XChartType >& xChartType )
     644             : {
     645         375 :     OUString aRet( "values-y" );
     646         375 :     if( !xChartType.is() )
     647           0 :         return aRet;
     648         750 :     OUString aChartTypeName = xChartType->getChartType();
     649         375 :     if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
     650           2 :         aRet = xChartType->getRoleOfSequenceForSeriesLabel();
     651         375 :     return aRet;
     652             : }
     653             : 
     654        1857 : OUString ChartTypeHelper::getRoleOfSequenceForDataLabelNumberFormatDetection( const uno::Reference< XChartType >& xChartType )
     655             : {
     656        1857 :     OUString aRet( "values-y" );
     657        1857 :     if( !xChartType.is() )
     658           0 :         return aRet;
     659        3714 :     OUString aChartTypeName = xChartType->getChartType();
     660        7428 :     if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK)
     661        7428 :         || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE) )
     662          10 :         aRet = xChartType->getRoleOfSequenceForSeriesLabel();
     663        1857 :     return aRet;
     664             : }
     665             : 
     666         100 : bool ChartTypeHelper::shouldLabelNumberFormatKeyBeDetectedFromYAxis( const uno::Reference< XChartType >& xChartType )
     667             : {
     668         100 :     bool bRet = true;
     669         100 :     OUString aChartTypeName = xChartType->getChartType();
     670         100 :     if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE) )
     671           0 :         bRet = false;
     672         100 :     return bRet;
     673             : }
     674             : 
     675           6 : bool ChartTypeHelper::isSupportingOnlyDeepStackingFor3D( const uno::Reference< XChartType >& xChartType )
     676             : {
     677           6 :     bool bRet = false;
     678           6 :     if( !xChartType.is() )
     679           0 :         return bRet;
     680             : 
     681           6 :     OUString aChartTypeName = xChartType->getChartType();
     682          28 :     if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_LINE) ||
     683          30 :         aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) ||
     684          10 :         aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_AREA) )
     685             :     {
     686           4 :         bRet = true;
     687             :     }
     688           6 :     return bRet;
     689             : }
     690             : 
     691             : //.............................................................................
     692             : } //namespace chart
     693             : //.............................................................................
     694             : 
     695             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10