tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / chart2 / source / tools / ColorPerPointHelper.cxx
blob7fcdbfaeda649141195f016f24f806f0cefafe25
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 <DataSeries.hxx>
22 #include <DataSeriesProperties.hxx>
23 #include <com/sun/star/chart2/XDataSeries.hpp>
24 #include <com/sun/star/beans/XPropertyState.hpp>
26 #include <algorithm>
28 using namespace ::com::sun::star;
29 using namespace ::chart::DataSeriesProperties;
31 namespace chart
34 bool ColorPerPointHelper::hasPointOwnColor(
35 const rtl::Reference< DataSeries >& xDataSeries
36 , sal_Int32 nPointIndex
37 , const css::uno::Reference< css::beans::XPropertySet >& xDataPointProperties //may be NULL this is just for performance
40 if( !xDataSeries.is() )
41 return false;
43 if( hasPointOwnProperties( xDataSeries, nPointIndex ))
45 uno::Reference< beans::XPropertyState > xPointState( xDataPointProperties, uno::UNO_QUERY );
46 if( !xPointState.is() )
48 xPointState.set( xDataSeries->getDataPointByIndex( nPointIndex ), uno::UNO_QUERY );
50 if( !xPointState.is() )
51 return false;
53 return (xPointState->getPropertyState( u"Color"_ustr) != beans::PropertyState_DEFAULT_VALUE );
56 return false;
59 bool ColorPerPointHelper::hasPointOwnProperties(
60 const rtl::Reference< ::chart::DataSeries >& xDataSeries
61 , sal_Int32 nPointIndex )
63 if( xDataSeries.is() )
65 uno::Sequence< sal_Int32 > aIndexList;
66 if( xDataSeries->getFastPropertyValue( PROP_DATASERIES_ATTRIBUTED_DATA_POINTS ) >>= aIndexList ) // "AttributedDataPoints"
68 return (std::find(aIndexList.begin(), aIndexList.end(), nPointIndex) != aIndexList.end());
72 return false;
75 } //namespace chart
77 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */