merge the formfield patch from ooo-build
[ooovba.git] / chart2 / source / tools / ColorPerPointHelper.cxx
blob2403bc8ca10fa88c50a5ac019647c63e11725ea5
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ColorPerPointHelper.cxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_chart2.hxx"
34 #include "ColorPerPointHelper.hxx"
35 #include "macros.hxx"
36 #include <com/sun/star/chart2/XDataSeries.hpp>
37 #include <com/sun/star/beans/XPropertyState.hpp>
39 #include <algorithm>
41 //.............................................................................
42 namespace chart
44 //.............................................................................
45 using namespace ::com::sun::star;
46 using namespace ::com::sun::star::chart2;
48 //static
49 bool ColorPerPointHelper::hasPointOwnColor(
50 const ::com::sun::star::uno::Reference<
51 ::com::sun::star::beans::XPropertySet >& xDataSeriesProperties
52 , sal_Int32 nPointIndex
53 , const ::com::sun::star::uno::Reference<
54 ::com::sun::star::beans::XPropertySet >& xDataPointProperties //may be NULL this is just for performance
57 if( !xDataSeriesProperties.is() )
58 return false;
60 if( hasPointOwnProperties( xDataSeriesProperties, nPointIndex ))
62 uno::Reference< beans::XPropertyState > xPointState( xDataPointProperties, uno::UNO_QUERY );
63 if( !xPointState.is() )
65 uno::Reference< XDataSeries > xSeries( xDataSeriesProperties, uno::UNO_QUERY );
66 if(xSeries.is())
67 xPointState.set( xSeries->getDataPointByIndex( nPointIndex ), uno::UNO_QUERY );
69 if( !xPointState.is() )
70 return false;
72 return (xPointState->getPropertyState( C2U("Color")) != beans::PropertyState_DEFAULT_VALUE );
75 return false;
78 // static
79 bool ColorPerPointHelper::hasPointOwnProperties(
80 const ::com::sun::star::uno::Reference<
81 ::com::sun::star::beans::XPropertySet >& xSeriesProperties
82 , sal_Int32 nPointIndex )
84 if( xSeriesProperties.is() )
86 uno::Sequence< sal_Int32 > aIndexList;
87 if( xSeriesProperties->getPropertyValue( C2U( "AttributedDataPoints" ) ) >>= aIndexList )
89 const sal_Int32 * pBegIt = aIndexList.getConstArray();
90 const sal_Int32 * pEndIt = pBegIt + aIndexList.getLength();
91 return ( ::std::find( pBegIt, pEndIt, nPointIndex ) != pEndIt );
95 return false;
98 //.............................................................................
99 } //namespace chart
100 //.............................................................................