nss: upgrade to release 3.73
[LibreOffice.git] / chart2 / source / tools / ColorPerPointHelper.cxx
blob34aeb7866021e1661fba987837086f93d9d19591
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <ColorPerPointHelper.hxx>
21 #include <com/sun/star/chart2/XDataSeries.hpp>
22 #include <com/sun/star/beans/XPropertyState.hpp>
24 #include <algorithm>
26 namespace chart
28 using namespace ::com::sun::star;
29 using namespace ::com::sun::star::chart2;
31 bool ColorPerPointHelper::hasPointOwnColor(
32 const css::uno::Reference< css::beans::XPropertySet >& xDataSeriesProperties
33 , sal_Int32 nPointIndex
34 , const css::uno::Reference< css::beans::XPropertySet >& xDataPointProperties //may be NULL this is just for performance
37 if( !xDataSeriesProperties.is() )
38 return false;
40 if( hasPointOwnProperties( xDataSeriesProperties, nPointIndex ))
42 uno::Reference< beans::XPropertyState > xPointState( xDataPointProperties, uno::UNO_QUERY );
43 if( !xPointState.is() )
45 uno::Reference< XDataSeries > xSeries( xDataSeriesProperties, uno::UNO_QUERY );
46 if(xSeries.is())
47 xPointState.set( xSeries->getDataPointByIndex( nPointIndex ), uno::UNO_QUERY );
49 if( !xPointState.is() )
50 return false;
52 return (xPointState->getPropertyState( "Color") != beans::PropertyState_DEFAULT_VALUE );
55 return false;
58 bool ColorPerPointHelper::hasPointOwnProperties(
59 const css::uno::Reference< css::beans::XPropertySet >& xSeriesProperties
60 , sal_Int32 nPointIndex )
62 if( xSeriesProperties.is() )
64 uno::Sequence< sal_Int32 > aIndexList;
65 if( xSeriesProperties->getPropertyValue( "AttributedDataPoints" ) >>= aIndexList )
67 const sal_Int32 * pBegIt = aIndexList.getConstArray();
68 const sal_Int32 * pEndIt = pBegIt + aIndexList.getLength();
69 return ( std::find( pBegIt, pEndIt, nPointIndex ) != pEndIt );
73 return false;
76 } //namespace chart
78 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */