chart2/Library_chart2.mk                                     |    1 
 chart2/source/controller/main/ChartController_Properties.cxx |    3 
 chart2/source/inc/ColorPerPointHelper.hxx                    |   50 -------
 chart2/source/inc/DataSeries.hxx                             |    9 +
 chart2/source/model/main/DataSeries.cxx                      |   26 +++
 chart2/source/tools/ColorPerPointHelper.cxx                  |   77 -----------
 solenv/clang-format/excludelist                              |    2 
 7 files changed, 36 insertions(+), 132 deletions(-)

New commits:
commit b81f1bce7375cda4f537dac461cf57652cba67c6
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Fri Apr 11 18:42:24 2025 +0200
Commit:     Noel Grandin <noelgran...@gmail.com>
CommitDate: Fri Apr 11 21:46:25 2025 +0200

    fold ColorPerPointHelper into DataSeries
    
    Where it better belongs, and where we can do a much better implementation.
    
    Change-Id: I0ea8004778c3697bda97972cb842241459538c30
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184065
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Tested-by: Jenkins

diff --git a/chart2/Library_chart2.mk b/chart2/Library_chart2.mk
index e48159801ed6..d0b35be117aa 100644
--- a/chart2/Library_chart2.mk
+++ b/chart2/Library_chart2.mk
@@ -342,7 +342,6 @@ $(eval $(call gb_Library_add_exception_objects,chart2,\
     chart2/source/tools/CharacterProperties \
     chart2/source/tools/ChartTypeHelper \
     chart2/source/tools/ChartViewHelper \
-    chart2/source/tools/ColorPerPointHelper \
     chart2/source/tools/CommonConverters \
     chart2/source/tools/ConfigColorScheme \
     chart2/source/tools/ControllerLockGuard \
diff --git a/chart2/source/controller/main/ChartController_Properties.cxx 
b/chart2/source/controller/main/ChartController_Properties.cxx
index 2b765d50a71d..87f3d656d1fc 100644
--- a/chart2/source/controller/main/ChartController_Properties.cxx
+++ b/chart2/source/controller/main/ChartController_Properties.cxx
@@ -43,7 +43,6 @@
 #include <ChartType.hxx>
 #include <ChartTypeHelper.hxx>
 #include <ChartModel.hxx>
-#include <ColorPerPointHelper.hxx>
 #include <DataSeries.hxx>
 #include <DataSeriesProperties.hxx>
 #include <Diagram.hxx>
@@ -219,7 +218,7 @@ wrapper::ItemConverter* createItemConverter(
                         
(xSeries->getFastPropertyValue(PROP_DATASERIES_VARY_COLORS_BY_POINT) >>= 
bVaryColorsByPoint) &&
                         bVaryColorsByPoint )
                     {
-                        if( !ColorPerPointHelper::hasPointOwnColor( xSeries, 
nPointIndex, xObjectProperties ) )
+                        if( !xSeries->hasPointOwnColor( nPointIndex, 
xObjectProperties ) )
                         {
                             bUseSpecialFillColor = true;
                             OSL_ASSERT( xDiagram.is());
diff --git a/chart2/source/inc/ColorPerPointHelper.hxx 
b/chart2/source/inc/ColorPerPointHelper.hxx
deleted file mode 100644
index bfcf2022815f..000000000000
--- a/chart2/source/inc/ColorPerPointHelper.hxx
+++ /dev/null
@@ -1,50 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#pragma once
-
-#include <config_options.h>
-#include <rtl/ref.hxx>
-
-namespace com::sun::star::beans { class XPropertySet; }
-namespace com::sun::star::uno { template <class interface_type> class 
Reference; }
-
-namespace chart
-{
-class DataSeries;
-
-class ColorPerPointHelper
-{
-public:
-    static bool hasPointOwnColor(
-        const rtl::Reference< ::chart::DataSeries >& xDataSeries
-        , sal_Int32 nPointIndex
-        , const css::uno::Reference< css::beans::XPropertySet >& 
xDataPointProperties //may be NULL this is just for performance
-         );
-
-    // returns true if AttributedDataPoints contains nPointIndex and the
-    // property Color is DEFAULT
-    static bool hasPointOwnProperties(
-        const rtl::Reference< ::chart::DataSeries >& xDataSeries
-        , sal_Int32 nPointIndex );
-};
-
-} //namespace chart
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/inc/DataSeries.hxx b/chart2/source/inc/DataSeries.hxx
index 8cee22dd326e..c20c2048975c 100644
--- a/chart2/source/inc/DataSeries.hxx
+++ b/chart2/source/inc/DataSeries.hxx
@@ -153,6 +153,15 @@ public:
 
     bool hasUnhiddenData();
 
+    bool hasPointOwnColor(
+        sal_Int32 nPointIndex
+        , const css::uno::Reference< css::beans::XPropertySet >& 
xDataPointProperties //may be NULL this is just for performance
+         );
+
+    // returns true if AttributedDataPoints contains nPointIndex and the
+    // property Color is DEFAULT
+    bool hasPointOwnProperties( sal_Int32 nPointIndex );
+
 private:
 
     // late initialization to call after copy-constructing
diff --git a/chart2/source/model/main/DataSeries.cxx 
b/chart2/source/model/main/DataSeries.cxx
index 30a3a6d81908..2445a5e6e771 100644
--- a/chart2/source/model/main/DataSeries.cxx
+++ b/chart2/source/model/main/DataSeries.cxx
@@ -725,6 +725,32 @@ bool DataSeries::hasUnhiddenData()
     return false;
 }
 
+bool DataSeries::hasPointOwnColor(
+        sal_Int32 nPointIndex
+        , const css::uno::Reference< css::beans::XPropertySet >& 
xDataPointProperties //may be NULL this is just for performance
+         )
+{
+    if( hasPointOwnProperties( nPointIndex ))
+    {
+        uno::Reference< beans::XPropertyState > xPointState( 
xDataPointProperties, uno::UNO_QUERY );
+        if( !xPointState.is() )
+        {
+            xPointState.set( getDataPointByIndex( nPointIndex ), 
uno::UNO_QUERY );
+        }
+        if( !xPointState.is() )
+            return false;
+
+        return (xPointState->getPropertyState( u"Color"_ustr) != 
beans::PropertyState_DEFAULT_VALUE );
+    }
+
+    return false;
+}
+
+bool DataSeries::hasPointOwnProperties( sal_Int32 nPointIndex )
+{
+    MutexGuard aGuard( m_aMutex );
+    return m_aAttributedDataPoints.find(nPointIndex) != 
m_aAttributedDataPoints.end();
+}
 
 }  // namespace chart
 
diff --git a/chart2/source/tools/ColorPerPointHelper.cxx 
b/chart2/source/tools/ColorPerPointHelper.cxx
deleted file mode 100644
index 7fcdbfaeda64..000000000000
--- a/chart2/source/tools/ColorPerPointHelper.cxx
+++ /dev/null
@@ -1,77 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <ColorPerPointHelper.hxx>
-#include <DataSeries.hxx>
-#include <DataSeriesProperties.hxx>
-#include <com/sun/star/chart2/XDataSeries.hpp>
-#include <com/sun/star/beans/XPropertyState.hpp>
-
-#include <algorithm>
-
-using namespace ::com::sun::star;
-using namespace ::chart::DataSeriesProperties;
-
-namespace chart
-{
-
-bool ColorPerPointHelper::hasPointOwnColor(
-        const rtl::Reference< DataSeries >& xDataSeries
-        , sal_Int32 nPointIndex
-        , const css::uno::Reference< css::beans::XPropertySet >& 
xDataPointProperties //may be NULL this is just for performance
-         )
-{
-    if( !xDataSeries.is() )
-        return false;
-
-    if( hasPointOwnProperties( xDataSeries, nPointIndex ))
-    {
-        uno::Reference< beans::XPropertyState > xPointState( 
xDataPointProperties, uno::UNO_QUERY );
-        if( !xPointState.is() )
-        {
-            xPointState.set( xDataSeries->getDataPointByIndex( nPointIndex ), 
uno::UNO_QUERY );
-        }
-        if( !xPointState.is() )
-            return false;
-
-        return (xPointState->getPropertyState( u"Color"_ustr) != 
beans::PropertyState_DEFAULT_VALUE );
-    }
-
-    return false;
-}
-
-bool ColorPerPointHelper::hasPointOwnProperties(
-    const rtl::Reference< ::chart::DataSeries >& xDataSeries
-    , sal_Int32 nPointIndex )
-{
-    if( xDataSeries.is() )
-    {
-        uno::Sequence< sal_Int32 > aIndexList;
-        if( xDataSeries->getFastPropertyValue( 
PROP_DATASERIES_ATTRIBUTED_DATA_POINTS ) >>= aIndexList ) // 
"AttributedDataPoints"
-        {
-            return (std::find(aIndexList.begin(), aIndexList.end(), 
nPointIndex) != aIndexList.end());
-        }
-    }
-
-    return false;
-}
-
-} //namespace chart
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist
index 7e1c7be1a273..0e2303562cbd 100644
--- a/solenv/clang-format/excludelist
+++ b/solenv/clang-format/excludelist
@@ -879,7 +879,6 @@ chart2/source/inc/ChartType.hxx
 chart2/source/inc/ChartTypeHelper.hxx
 chart2/source/inc/ChartTypeTemplate.hxx
 chart2/source/inc/CloneHelper.hxx
-chart2/source/inc/ColorPerPointHelper.hxx
 chart2/source/inc/CommonConverters.hxx
 chart2/source/inc/CommonFunctors.hxx
 chart2/source/inc/ConfigColorScheme.hxx
@@ -1028,7 +1027,6 @@ chart2/source/tools/BaseGFXHelper.cxx
 chart2/source/tools/CachedDataSequence.cxx
 chart2/source/tools/CharacterProperties.cxx
 chart2/source/tools/ChartTypeHelper.cxx
-chart2/source/tools/ColorPerPointHelper.cxx
 chart2/source/tools/CommonConverters.cxx
 chart2/source/tools/ConfigColorScheme.cxx
 chart2/source/tools/ControllerLockGuard.cxx

Reply via email to