LibreOffice Module chart2 (master) 1
ColorPerPointHelper.cxx
Go to the documentation of this file.
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
21#include <DataSeries.hxx>
23#include <com/sun/star/chart2/XDataSeries.hpp>
24#include <com/sun/star/beans/XPropertyState.hpp>
25
26#include <algorithm>
27
28using namespace ::com::sun::star;
29using namespace ::com::sun::star::chart2;
30using namespace ::chart::DataSeriesProperties;
31
32namespace chart
33{
34
36 const rtl::Reference< DataSeries >& xDataSeries
37 , sal_Int32 nPointIndex
38 , const css::uno::Reference< css::beans::XPropertySet >& xDataPointProperties //may be NULL this is just for performance
39 )
40{
41 if( !xDataSeries.is() )
42 return false;
43
44 if( hasPointOwnProperties( xDataSeries, nPointIndex ))
45 {
46 uno::Reference< beans::XPropertyState > xPointState( xDataPointProperties, uno::UNO_QUERY );
47 if( !xPointState.is() )
48 {
49 xPointState.set( xDataSeries->getDataPointByIndex( nPointIndex ), uno::UNO_QUERY );
50 }
51 if( !xPointState.is() )
52 return false;
53
54 return (xPointState->getPropertyState( "Color") != beans::PropertyState_DEFAULT_VALUE );
55 }
56
57 return false;
58}
59
62 , sal_Int32 nPointIndex )
63{
64 if( xDataSeries.is() )
65 {
67 if( xDataSeries->getFastPropertyValue( PROP_DATASERIES_ATTRIBUTED_DATA_POINTS ) >>= aIndexList ) // "AttributedDataPoints"
68 {
69 const sal_Int32 * pBegIt = aIndexList.getConstArray();
70 const sal_Int32 * pEndIt = pBegIt + aIndexList.getLength();
71 return ( std::find( pBegIt, pEndIt, nPointIndex ) != pEndIt );
72 }
73 }
74
75 return false;
76}
77
78} //namespace chart
79
80/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static bool hasPointOwnColor(const rtl::Reference< ::chart::DataSeries > &xDataSeries, sal_Int32 nPointIndex, const css::uno::Reference< css::beans::XPropertySet > &xDataPointProperties)
static SAL_DLLPRIVATE bool hasPointOwnProperties(const rtl::Reference< ::chart::DataSeries > &xDataSeries, sal_Int32 nPointIndex)