1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 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. 14 * 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). 20 * 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. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_chart2.hxx" 30 31 #include "ColorPerPointHelper.hxx" 32 #include "macros.hxx" 33 #include <com/sun/star/chart2/XDataSeries.hpp> 34 #include <com/sun/star/beans/XPropertyState.hpp> 35 36 #include <algorithm> 37 38 //............................................................................. 39 namespace chart 40 { 41 //............................................................................. 42 using namespace ::com::sun::star; 43 using namespace ::com::sun::star::chart2; 44 45 bool ColorPerPointHelper::hasPointOwnColor( 46 const ::com::sun::star::uno::Reference< 47 ::com::sun::star::beans::XPropertySet >& xDataSeriesProperties 48 , sal_Int32 nPointIndex 49 , const ::com::sun::star::uno::Reference< 50 ::com::sun::star::beans::XPropertySet >& xDataPointProperties //may be NULL this is just for performance 51 ) 52 { 53 if( !xDataSeriesProperties.is() ) 54 return false; 55 56 if( hasPointOwnProperties( xDataSeriesProperties, nPointIndex )) 57 { 58 uno::Reference< beans::XPropertyState > xPointState( xDataPointProperties, uno::UNO_QUERY ); 59 if( !xPointState.is() ) 60 { 61 uno::Reference< XDataSeries > xSeries( xDataSeriesProperties, uno::UNO_QUERY ); 62 if(xSeries.is()) 63 xPointState.set( xSeries->getDataPointByIndex( nPointIndex ), uno::UNO_QUERY ); 64 } 65 if( !xPointState.is() ) 66 return false; 67 68 return (xPointState->getPropertyState( C2U("Color")) != beans::PropertyState_DEFAULT_VALUE ); 69 } 70 71 return false; 72 } 73 74 bool ColorPerPointHelper::hasPointOwnProperties( 75 const ::com::sun::star::uno::Reference< 76 ::com::sun::star::beans::XPropertySet >& xSeriesProperties 77 , sal_Int32 nPointIndex ) 78 { 79 if( xSeriesProperties.is() ) 80 { 81 uno::Sequence< sal_Int32 > aIndexList; 82 if( xSeriesProperties->getPropertyValue( C2U( "AttributedDataPoints" ) ) >>= aIndexList ) 83 { 84 const sal_Int32 * pBegIt = aIndexList.getConstArray(); 85 const sal_Int32 * pEndIt = pBegIt + aIndexList.getLength(); 86 return ( ::std::find( pBegIt, pEndIt, nPointIndex ) != pEndIt ); 87 } 88 } 89 90 return false; 91 } 92 93 //............................................................................. 94 } //namespace chart 95 //............................................................................. 96