chart2/source/model/main/PageBackground.cxx |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

New commits:
commit b5a35f09b3c3ccac26b403e881c799e0d09bf42a
Author:     offtkp <parisop...@gmail.com>
AuthorDate: Mon Nov 20 22:58:20 2023 +0200
Commit:     Paris Oplopoios <parisop...@gmail.com>
CommitDate: Tue Nov 21 14:24:42 2023 +0100

    chart2: Match chart background color with DOCCOLOR in Calc
    
    Chart background color would be hardcoded to white which meant newly 
inserted charts would have a different background color in Calc (in other 
components, the background color is later set to transparent)
    
    Change-Id: I6ea55389f195155a96c4c8dcc94a902b2a862178
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159751
    Tested-by: Jenkins
    Reviewed-by: Paris Oplopoios <parisop...@gmail.com>

diff --git a/chart2/source/model/main/PageBackground.cxx 
b/chart2/source/model/main/PageBackground.cxx
index 592c24d3e6a2..c866bdbb3f4a 100644
--- a/chart2/source/model/main/PageBackground.cxx
+++ b/chart2/source/model/main/PageBackground.cxx
@@ -23,6 +23,8 @@
 #include <UserDefinedProperties.hxx>
 #include <PropertyHelper.hxx>
 #include <ModifyListenerHelper.hxx>
+#include <svtools/colorcfg.hxx>
+#include <sfx2/viewsh.hxx>
 
 #include <com/sun/star/drawing/LineStyle.hpp>
 #include <cppuhelper/supportsservice.hxx>
@@ -48,7 +50,13 @@ const ::chart::tPropertyValueMap& 
StaticPageBackgroundDefaults()
             ::chart::FillProperties::AddDefaultsToMap( aTmp );
 
             // override other defaults
-            ::chart::PropertyHelper::setPropertyValue< sal_Int32 >( aTmp, 
::chart::FillProperties::PROP_FILL_COLOR, 0xffffff );
+            Color aDocColor = COL_WHITE;
+            if (SfxViewShell::Current()) {
+                aDocColor = 
SfxViewShell::Current()->GetColorConfigColor(svtools::DOCCOLOR);
+            } else {
+                SAL_WARN("chart2", "SfxViewShell::Current() returned nullptr");
+            }
+            ::chart::PropertyHelper::setPropertyValue( aTmp, 
::chart::FillProperties::PROP_FILL_COLOR, aDocColor );
             ::chart::PropertyHelper::setPropertyValue( aTmp, 
::chart::LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_NONE );
             return aTmp;
         }();

Reply via email to