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

Generated by: LCOV version 1.10