merged tag ooo/OOO330_m14
[LibreOffice.git] / chart2 / source / tools / ColorPerPointHelper.cxx
blob762cb436a9a79ffd243618144516ee05eb4380f1
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_chart2.hxx"
31 #include "ColorPerPointHelper.hxx"
32 #include "macros.hxx"
33 #include <com/sun/star/chart2/XDataSeries.hpp>
34 #include <com/sun/star/beans/XPropertyState.hpp>
36 #include <algorithm>
38 //.............................................................................
39 namespace chart
41 //.............................................................................
42 using namespace ::com::sun::star;
43 using namespace ::com::sun::star::chart2;
45 //static
46 bool ColorPerPointHelper::hasPointOwnColor(
47 const ::com::sun::star::uno::Reference<
48 ::com::sun::star::beans::XPropertySet >& xDataSeriesProperties
49 , sal_Int32 nPointIndex
50 , const ::com::sun::star::uno::Reference<
51 ::com::sun::star::beans::XPropertySet >& xDataPointProperties //may be NULL this is just for performance
54 if( !xDataSeriesProperties.is() )
55 return false;
57 if( hasPointOwnProperties( xDataSeriesProperties, nPointIndex ))
59 uno::Reference< beans::XPropertyState > xPointState( xDataPointProperties, uno::UNO_QUERY );
60 if( !xPointState.is() )
62 uno::Reference< XDataSeries > xSeries( xDataSeriesProperties, uno::UNO_QUERY );
63 if(xSeries.is())
64 xPointState.set( xSeries->getDataPointByIndex( nPointIndex ), uno::UNO_QUERY );
66 if( !xPointState.is() )
67 return false;
69 return (xPointState->getPropertyState( C2U("Color")) != beans::PropertyState_DEFAULT_VALUE );
72 return false;
75 // static
76 bool ColorPerPointHelper::hasPointOwnProperties(
77 const ::com::sun::star::uno::Reference<
78 ::com::sun::star::beans::XPropertySet >& xSeriesProperties
79 , sal_Int32 nPointIndex )
81 if( xSeriesProperties.is() )
83 uno::Sequence< sal_Int32 > aIndexList;
84 if( xSeriesProperties->getPropertyValue( C2U( "AttributedDataPoints" ) ) >>= aIndexList )
86 const sal_Int32 * pBegIt = aIndexList.getConstArray();
87 const sal_Int32 * pEndIt = pBegIt + aIndexList.getLength();
88 return ( ::std::find( pBegIt, pEndIt, nPointIndex ) != pEndIt );
92 return false;
95 //.............................................................................
96 } //namespace chart
97 //.............................................................................