LCOV - code coverage report
Current view: top level - libreoffice/chart2/source/tools - ColorPerPointHelper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 22 0.0 %
Date: 2012-12-27 Functions: 0 2 0.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 "ColorPerPointHelper.hxx"
      22             : #include "macros.hxx"
      23             : #include <com/sun/star/chart2/XDataSeries.hpp>
      24             : #include <com/sun/star/beans/XPropertyState.hpp>
      25             : 
      26             : #include <algorithm>
      27             : 
      28             : //.............................................................................
      29             : namespace chart
      30             : {
      31             : //.............................................................................
      32             : using namespace ::com::sun::star;
      33             : using namespace ::com::sun::star::chart2;
      34             : 
      35           0 : bool ColorPerPointHelper::hasPointOwnColor(
      36             :         const ::com::sun::star::uno::Reference<
      37             :               ::com::sun::star::beans::XPropertySet >& xDataSeriesProperties
      38             :         , sal_Int32 nPointIndex
      39             :         , const ::com::sun::star::uno::Reference<
      40             :               ::com::sun::star::beans::XPropertySet >& xDataPointProperties //may be NULL this is just for performance
      41             :          )
      42             : {
      43           0 :     if( !xDataSeriesProperties.is() )
      44           0 :         return false;
      45             : 
      46           0 :     if( hasPointOwnProperties( xDataSeriesProperties, nPointIndex ))
      47             :     {
      48           0 :         uno::Reference< beans::XPropertyState > xPointState( xDataPointProperties, uno::UNO_QUERY );
      49           0 :         if( !xPointState.is() )
      50             :         {
      51           0 :             uno::Reference< XDataSeries > xSeries( xDataSeriesProperties, uno::UNO_QUERY );
      52           0 :             if(xSeries.is())
      53           0 :                 xPointState.set( xSeries->getDataPointByIndex( nPointIndex ), uno::UNO_QUERY );
      54             :         }
      55           0 :         if( !xPointState.is() )
      56           0 :             return false;
      57             : 
      58           0 :         return (xPointState->getPropertyState( C2U("Color")) != beans::PropertyState_DEFAULT_VALUE );
      59             :     }
      60             : 
      61           0 :     return false;
      62             : }
      63             : 
      64           0 : bool ColorPerPointHelper::hasPointOwnProperties(
      65             :     const ::com::sun::star::uno::Reference<
      66             :         ::com::sun::star::beans::XPropertySet >& xSeriesProperties
      67             :     , sal_Int32 nPointIndex )
      68             : {
      69           0 :     if( xSeriesProperties.is() )
      70             :     {
      71           0 :         uno::Sequence< sal_Int32 > aIndexList;
      72           0 :         if( xSeriesProperties->getPropertyValue( C2U( "AttributedDataPoints" ) ) >>= aIndexList )
      73             :         {
      74           0 :             const sal_Int32 * pBegIt = aIndexList.getConstArray();
      75           0 :             const sal_Int32 * pEndIt = pBegIt + aIndexList.getLength();
      76           0 :             return ( ::std::find( pBegIt, pEndIt, nPointIndex ) != pEndIt );
      77           0 :         }
      78             :     }
      79             : 
      80           0 :     return false;
      81             : }
      82             : 
      83             : //.............................................................................
      84             : } //namespace chart
      85             : //.............................................................................
      86             : 
      87             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10