From 8870c3feb87de2d3d5144e49ddc8a6310a8f8ae5 Mon Sep 17 00:00:00 2001 From: Marco Cecchetti Date: Fri, 11 Apr 2025 16:43:30 +0200 Subject: [PATCH] chart color palette for data series: dialog tab pane MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I0877212c715d320e954fcd8089d4f984eae16ac6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184265 Tested-by: Jenkins CollaboraOffice Reviewed-by: Tomaž Vajngerl Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185143 Reviewed-by: Marco Cecchetti Tested-by: Jenkins --- chart2/Library_chart2.mk | 1 + chart2/UIConfig_chart2.mk | 1 + chart2/inc/strings.hrc | 1 + .../dialogs/dlg_ObjectProperties.cxx | 16 +- .../dialogs/tp_ChartColorPalette.cxx | 188 ++++++++++++++++++ .../dialogs/tp_ChartColorPalette.hxx | 64 ++++++ .../inc/GraphicPropertyItemConverter.hxx | 5 + .../GraphicPropertyItemConverter.cxx | 22 +- .../itemsetwrapper/SchWhichPairs.hxx | 3 + .../source/inc/chartview/ChartSfxItemIds.hxx | 7 +- chart2/source/view/main/ChartItemPool.cxx | 5 +- chart2/uiconfig/ui/tp_ChartColorPalette.ui | 112 +++++++++++ include/svl/poolitem.hxx | 1 + include/svx/chrtitem.hxx | 31 +++ include/svx/unomid.hxx | 4 + svx/source/items/chrtitem.cxx | 88 ++++++++ vcl/jsdialog/enabled.cxx | 1 + 17 files changed, 546 insertions(+), 4 deletions(-) create mode 100644 chart2/source/controller/dialogs/tp_ChartColorPalette.cxx create mode 100644 chart2/source/controller/dialogs/tp_ChartColorPalette.hxx create mode 100644 chart2/uiconfig/ui/tp_ChartColorPalette.ui diff --git a/chart2/Library_chart2.mk b/chart2/Library_chart2.mk index 43e74cbe491a..ebc93b1148c8 100644 --- a/chart2/Library_chart2.mk +++ b/chart2/Library_chart2.mk @@ -138,6 +138,7 @@ $(eval $(call gb_Library_add_exception_objects,chart2,\ chart2/source/controller/dialogs/tp_3D_SceneIllumination \ chart2/source/controller/dialogs/tp_AxisLabel \ chart2/source/controller/dialogs/tp_AxisPositions \ + chart2/source/controller/dialogs/tp_ChartColorPalette \ chart2/source/controller/dialogs/tp_ChartType \ chart2/source/controller/dialogs/tp_DataLabel \ chart2/source/controller/dialogs/tp_DataPointOption \ diff --git a/chart2/UIConfig_chart2.mk b/chart2/UIConfig_chart2.mk index 93d8db3154d9..722faf0d8580 100644 --- a/chart2/UIConfig_chart2.mk +++ b/chart2/UIConfig_chart2.mk @@ -67,6 +67,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/schart,\ chart2/uiconfig/ui/tp_3D_SceneIllumination \ chart2/uiconfig/ui/tp_axisLabel \ chart2/uiconfig/ui/tp_AxisPositions \ + chart2/uiconfig/ui/tp_ChartColorPalette \ chart2/uiconfig/ui/tp_ChartType \ chart2/uiconfig/ui/tp_DataLabel \ chart2/uiconfig/ui/tp_DataPointOption \ diff --git a/chart2/inc/strings.hrc b/chart2/inc/strings.hrc index c6292baa97f5..522dd8cdedfa 100644 --- a/chart2/inc/strings.hrc +++ b/chart2/inc/strings.hrc @@ -48,6 +48,7 @@ #define STR_PAGE_APPEARANCE NC_("STR_PAGE_APPEARANCE", "Appearance") #define STR_PAGE_ILLUMINATION NC_("STR_PAGE_ILLUMINATION", "Illumination") #define STR_PAGE_ASIAN NC_("STR_PAGE_ASIAN", "Asian Typography") +#define STR_PAGE_COLOR_PALETTE NC_("STR_PAGE_COLOR_PALETTE", "Color Palette") #define STR_OBJECT_AVERAGE_LINE_WITH_PARAMETERS NC_("STR_OBJECT_AVERAGE_LINE_WITH_PARAMETERS", "Mean value line with value %AVERAGE_VALUE and standard deviation %STD_DEVIATION") #define STR_OBJECT_AXIS NC_("STR_OBJECT_AXIS", "Axis") #define STR_OBJECT_AXIS_X NC_("STR_OBJECT_AXIS_X", "X Axis") diff --git a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx index fabe013ff27d..8148bd6b880a 100644 --- a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx +++ b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx @@ -36,6 +36,7 @@ #include "tp_PolarOptions.hxx" #include "tp_DataPointOption.hxx" #include "tp_DataTable.hxx" +#include "tp_ChartColorPalette.hxx" #include #include #include @@ -342,7 +343,8 @@ SchAttribTabDlg::SchAttribTabDlg(weld::Window* pParent, m_xDialog->set_title(pDialogParameter->getLocalizedName()); - switch (pDialogParameter->getObjectType()) + ObjectType eType = pDialogParameter->getObjectType(); + switch (eType) { case OBJECTTYPE_TITLE: AddTabPage(u"border"_ustr, SchResId(STR_PAGE_BORDER), RID_SVXPAGE_LINE); @@ -359,6 +361,7 @@ SchAttribTabDlg::SchAttribTabDlg(weld::Window* pParent, AddTabPage(u"border"_ustr, SchResId(STR_PAGE_BORDER), RID_SVXPAGE_LINE); AddTabPage(u"area"_ustr, SchResId(STR_PAGE_AREA), RID_SVXPAGE_AREA); AddTabPage(u"transparent"_ustr, SchResId(STR_PAGE_TRANSPARENCY), RID_SVXPAGE_TRANSPARENCE); + AddTabPage(u"colorpalette"_ustr, SchResId(STR_PAGE_COLOR_PALETTE), ChartColorPaletteTabPage::Create); AddTabPage(u"fontname"_ustr, SchResId(STR_PAGE_FONT), RID_SVXPAGE_CHAR_NAME); AddTabPage(u"effects"_ustr, SchResId(STR_PAGE_FONT_EFFECTS), RID_SVXPAGE_CHAR_EFFECTS); AddTabPage(u"legendpos"_ustr, SchResId(STR_PAGE_POSITION), SchLegendPosTabPage::Create); @@ -384,6 +387,7 @@ SchAttribTabDlg::SchAttribTabDlg(weld::Window* pParent, AddTabPage(u"transparent"_ustr, SchResId(STR_PAGE_TRANSPARENCY), RID_SVXPAGE_TRANSPARENCE); } AddTabPage(u"border"_ustr, SchResId( m_pParameter->HasAreaProperties() ? STR_PAGE_BORDER : STR_PAGE_LINE ), RID_SVXPAGE_LINE); + AddTabPage(u"colorpalette"_ustr, SchResId(STR_PAGE_COLOR_PALETTE), ChartColorPaletteTabPage::Create); break; case OBJECTTYPE_DATA_LABEL: @@ -450,6 +454,8 @@ SchAttribTabDlg::SchAttribTabDlg(weld::Window* pParent, AddTabPage(u"border"_ustr, SchResId(STR_PAGE_BORDER), RID_SVXPAGE_LINE); AddTabPage(u"area"_ustr, SchResId(STR_PAGE_AREA), RID_SVXPAGE_AREA); AddTabPage(u"transparent"_ustr, SchResId(STR_PAGE_TRANSPARENCY), RID_SVXPAGE_TRANSPARENCE); + if (eType != OBJECTTYPE_DATA_STOCK_LOSS && eType != OBJECTTYPE_DATA_STOCK_GAIN) + AddTabPage(u"colorpalette"_ustr, SchResId(STR_PAGE_COLOR_PALETTE), ChartColorPaletteTabPage::Create); break; case OBJECTTYPE_LEGEND_ENTRY: @@ -621,6 +627,14 @@ void SchAttribTabDlg::PageCreated(const OUString& rId, SfxTabPage &rPage) pTrendlineTabPage->SetNbPoints( m_pParameter->getNbPoints() ); } } + else if (rId == "colorpalette") + { + auto* pColorPaletteTabPage = dynamic_cast( &rPage ); + if (pColorPaletteTabPage) + { + pColorPaletteTabPage->init(m_pParameter->getDocument()); + } + } } IMPL_LINK(SchAttribTabDlg, OKPressed, weld::Button&, rButton, void) diff --git a/chart2/source/controller/dialogs/tp_ChartColorPalette.cxx b/chart2/source/controller/dialogs/tp_ChartColorPalette.cxx new file mode 100644 index 000000000000..c52148c9dc17 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_ChartColorPalette.cxx @@ -0,0 +1,188 @@ +/* -*- 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 "tp_ChartColorPalette.hxx" + +#include +#include +#include +#include +#include + +namespace chart +{ +ChartColorPaletteTabPage::ChartColorPaletteTabPage(weld::Container* pPage, + weld::DialogController* pController, + const SfxItemSet& rInAttrs) + : SfxTabPage(pPage, pController, "modules/schart/ui/tp_ChartColorPalette.ui", + "tp_ChartColorPalette", &rInAttrs) + , mxColorfulValueSet(new ChartColorPalettes) + , mxColorfulValueSetWin( + new weld::CustomWeld(*m_xBuilder, "colorful_palettes", *mxColorfulValueSet)) + , mxMonoValueSet(new ChartColorPalettes) + , mxMonoValueSetWin( + new weld::CustomWeld(*m_xBuilder, "monochromatic_palettes", *mxMonoValueSet)) +{ + mxColorfulValueSet->SetColCount(2); + mxColorfulValueSet->SetLineCount(2); + mxColorfulValueSet->SetColor(Application::GetSettings().GetStyleSettings().GetFaceColor()); + + mxMonoValueSet->SetColCount(2); + mxMonoValueSet->SetLineCount(3); + mxMonoValueSet->SetColor(Application::GetSettings().GetStyleSettings().GetFaceColor()); + + mxColorfulValueSet->SetOptimalSize(); + mxColorfulValueSet->SetSelectHdl( + LINK(this, ChartColorPaletteTabPage, SelectColorfulValueSetHdl)); + + mxMonoValueSet->SetOptimalSize(); + mxMonoValueSet->SetSelectHdl(LINK(this, ChartColorPaletteTabPage, SelectMonoValueSetHdl)); +} + +ChartColorPaletteTabPage::~ChartColorPaletteTabPage() +{ + mxColorfulValueSetWin.reset(); + mxColorfulValueSet.reset(); + mxMonoValueSetWin.reset(); + mxMonoValueSet.reset(); +} + +std::unique_ptr ChartColorPaletteTabPage::Create(weld::Container* pPage, + weld::DialogController* pController, + const SfxItemSet* rInAttrs) +{ + return std::make_unique(pPage, pController, *rInAttrs); +} + +void ChartColorPaletteTabPage::init(const rtl::Reference& xChartModel) +{ + assert(xChartModel); + mxChartModel = xChartModel; + + const std::shared_ptr pTheme = mxChartModel->getDocumentTheme(); + mxHelper = std::make_unique(pTheme); + + selectItem(mxChartModel->getColorPaletteType(), mxChartModel->getColorPaletteIndex() + 1); + initColorPalettes(); +} + +void ChartColorPaletteTabPage::initColorPalettes() const +{ + if (!mxHelper) + return; + // colorful palettes + for (size_t i = 0; i < ChartColorPaletteHelper::ColorfulPaletteSize; ++i) + mxColorfulValueSet->insert(mxHelper->getColorPalette(ChartColorPaletteType::Colorful, i)); + // monotonic palettes + for (size_t i = 0; i < ChartColorPaletteHelper::MonotonicPaletteSize; ++i) + mxMonoValueSet->insert(mxHelper->getColorPalette(ChartColorPaletteType::Monochromatic, i)); +} + +void ChartColorPaletteTabPage::selectItem(const ChartColorPaletteType eType, + const sal_uInt32 nIndex) const +{ + switch (eType) + { + default: + case ChartColorPaletteType::Unknown: + mxColorfulValueSet->SetNoSelection(); + mxMonoValueSet->SetNoSelection(); + break; + case ChartColorPaletteType::Colorful: + mxMonoValueSet->SetNoSelection(); + mxColorfulValueSet->SelectItem(nIndex); + break; + case ChartColorPaletteType::Monochromatic: + mxColorfulValueSet->SetNoSelection(); + mxMonoValueSet->SelectItem(nIndex); + break; + } +} + +bool ChartColorPaletteTabPage::FillItemSet(SfxItemSet* pOutAttrs) +{ + ChartColorPaletteType eType = ChartColorPaletteType::Unknown; + sal_uInt32 nIndex = 0; + + if (!mxColorfulValueSet->IsNoSelection()) + { + eType = ChartColorPaletteType::Colorful; + nIndex = mxColorfulValueSet->GetSelectedItemId() - 1; + } + else if (!mxMonoValueSet->IsNoSelection()) + { + eType = ChartColorPaletteType::Monochromatic; + nIndex = mxMonoValueSet->GetSelectedItemId() - 1; + } + + pOutAttrs->Put(SvxChartColorPaletteItem(eType, nIndex, SCHATTR_COLOR_PALETTE)); + + return true; +} + +void ChartColorPaletteTabPage::Reset(const SfxItemSet*) +{ + selectItem(mxChartModel->getColorPaletteType(), mxChartModel->getColorPaletteIndex() + 1); +} + +DeactivateRC ChartColorPaletteTabPage::DeactivatePage(SfxItemSet* pItemSet) +{ + if (pItemSet) + FillItemSet(pItemSet); + + return DeactivateRC::LeavePage; +} + +IMPL_LINK_NOARG(ChartColorPaletteTabPage, SelectColorfulValueSetHdl, ValueSet*, void) +{ + sal_uInt32 nIndex = SelectValueSetHdl(mxColorfulValueSet); + if (nIndex != static_cast(-1)) + { + mxMonoValueSet->SetNoSelection(); + } +} + +IMPL_LINK_NOARG(ChartColorPaletteTabPage, SelectMonoValueSetHdl, ValueSet*, void) +{ + sal_uInt32 nIndex = SelectValueSetHdl(mxMonoValueSet); + if (nIndex != static_cast(-1)) + { + mxColorfulValueSet->SetNoSelection(); + } +} + +sal_uInt32 +ChartColorPaletteTabPage::SelectValueSetHdl(const std::unique_ptr& xValueSet) +{ + const sal_uInt32 nItemId = xValueSet->GetSelectedItemId(); + + if (!nItemId) + return static_cast(-1); + + const sal_uInt32 nIndex = nItemId - 1; + + if (xValueSet->getPalette(nIndex)) + { + return nIndex; + } + return static_cast(-1); +} +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/dialogs/tp_ChartColorPalette.hxx b/chart2/source/controller/dialogs/tp_ChartColorPalette.hxx new file mode 100644 index 000000000000..02cfe3cd5c94 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_ChartColorPalette.hxx @@ -0,0 +1,64 @@ +/* -*- 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 +#include + +namespace chart +{ +class ChartModel; +class ChartColorPaletteHelper; + +class ChartColorPaletteTabPage final : public SfxTabPage +{ +public: + ChartColorPaletteTabPage(weld::Container* pPage, weld::DialogController* pController, + const SfxItemSet& rInAttrs); + ~ChartColorPaletteTabPage() override; + + static std::unique_ptr + Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rInAttrs); + + bool FillItemSet(SfxItemSet* pOutAttrs) override; + void Reset(const SfxItemSet* rInAttrs) override; + DeactivateRC DeactivatePage(SfxItemSet* pItemSet) override; + + void init(const rtl::Reference& xChartModel); + +private: + void selectItem(ChartColorPaletteType eType, sal_uInt32 nIndex) const; + void initColorPalettes() const; + +private: + rtl::Reference mxChartModel; + std::unique_ptr mxHelper; + std::unique_ptr mxColorfulValueSet; + std::unique_ptr mxColorfulValueSetWin; + std::unique_ptr mxMonoValueSet; + std::unique_ptr mxMonoValueSetWin; + + DECL_LINK(SelectColorfulValueSetHdl, ValueSet*, void); + DECL_LINK(SelectMonoValueSetHdl, ValueSet*, void); + static sal_uInt32 SelectValueSetHdl(const std::unique_ptr& xValueSet); +}; +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/inc/GraphicPropertyItemConverter.hxx b/chart2/source/controller/inc/GraphicPropertyItemConverter.hxx index 9d119d53ca3a..c8a78944c96b 100644 --- a/chart2/source/controller/inc/GraphicPropertyItemConverter.hxx +++ b/chart2/source/controller/inc/GraphicPropertyItemConverter.hxx @@ -20,10 +20,14 @@ #include "ItemConverter.hxx" +#include + namespace com::sun::star::lang { class XMultiServiceFactory; } class SdrModel; +namespace chart { class ChartModel; } + namespace chart::wrapper { @@ -57,6 +61,7 @@ private: GraphicObjectType m_GraphicObjectType; SdrModel & m_rDrawModel; css::uno::Reference< css::lang::XMultiServiceFactory > m_xNamedPropertyTableFactory; + rtl::Reference m_xChartModel; }; } // namespace chart::wrapper diff --git a/chart2/source/controller/itemsetwrapper/GraphicPropertyItemConverter.cxx b/chart2/source/controller/itemsetwrapper/GraphicPropertyItemConverter.cxx index 0ca5be652a84..a6fecfb39f85 100644 --- a/chart2/source/controller/itemsetwrapper/GraphicPropertyItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/GraphicPropertyItemConverter.cxx @@ -19,10 +19,12 @@ #include #include "SchWhichPairs.hxx" +#include #include #include #include #include +#include #include #include #include @@ -144,7 +146,11 @@ GraphicPropertyItemConverter::GraphicPropertyItemConverter( m_GraphicObjectType( eObjectType ), m_rDrawModel( rDrawModel ), m_xNamedPropertyTableFactory(std::move( xNamedPropertyContainerFactory )) -{} +{ + m_xChartModel = dynamic_cast(m_xNamedPropertyTableFactory.get()); + DBG_ASSERT(m_xChartModel.is(), + "GraphicPropertyItemConverter ctor: passed XMultiServiceFactory parameter is not a ChartModel instance."); +} GraphicPropertyItemConverter::~GraphicPropertyItemConverter() {} @@ -168,6 +174,11 @@ const WhichRangesContainer& GraphicPropertyItemConverter::GetWhichPairs() const bool GraphicPropertyItemConverter::GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const { + if (nWhichId == SCHATTR_COLOR_PALETTE) + { + return false; + } + ItemPropertyMapType::const_iterator aEndIt; ItemPropertyMapType::const_iterator aIt; @@ -742,6 +753,15 @@ bool GraphicPropertyItemConverter::ApplySpecialItem( } } break; + case SCHATTR_COLOR_PALETTE: + { + const auto& rItem = static_cast(rItemSet.Get(nWhichId)); + m_xChartModel->setColorPalette(rItem.GetType(), rItem.GetIndex()); + const auto oColorPalette = m_xChartModel->getCurrentColorPalette(); + if (oColorPalette) + m_xChartModel->applyColorPaletteToDataSeries(*oColorPalette); + } + break; } return bChanged; diff --git a/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx b/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx index 676527f3fef3..8216c4b32337 100644 --- a/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx +++ b/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx @@ -59,6 +59,7 @@ const WhichRangesContainer nGridWhichPairs(svl::Items< const WhichRangesContainer nLegendWhichPairs(svl::Items< SCHATTR_LEGEND_START, SCHATTR_LEGEND_END, // 3 - 3 sch/schattr.hxx + SCHATTR_COLOR_PALETTE_START, SCHATTR_COLOR_PALETTE_END, // 107 - 107 XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx XATTR_FILL_FIRST, XATTR_FILL_LAST, // 1018 - 1046 svx/xdef.hxx SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST, // 1067 - 1078 svx/svddef.hxx @@ -121,6 +122,7 @@ const WhichRangesContainer nRowWhichPairs(svl::Items< SCHATTR_HIDE_DATA_POINT_LEGEND_ENTRY, SCHATTR_HIDE_DATA_POINT_LEGEND_ENTRY, SCHATTR_BAR_OVERLAP,SCHATTR_BAR_CONNECT, /* 98 - 100 (incl. SCHATTR_GAPWIDTH) */ SCHATTR_GROUP_BARS_PER_AXIS,SCHATTR_AXIS_FOR_ALL_SERIES, + SCHATTR_COLOR_PALETTE_START, SCHATTR_COLOR_PALETTE_END, // 107 - 107 XATTR_LINE_FIRST, XATTR_LINE_LAST, /* 1000 - 1016 svx/xdef.hxx */ XATTR_FILL_FIRST, XATTR_FILL_LAST, /* 1018 - 1046 svx/xdef.hxx */ SDRATTR_3D_FIRST, SDRATTR_3D_LAST, /* 1244 - 1334 svx/svddef.hxx */ @@ -152,6 +154,7 @@ const WhichRangesContainer nLinePropertyWhichPairs(svl::Items< >); const WhichRangesContainer nLineAndFillPropertyWhichPairs(svl::Items< + SCHATTR_COLOR_PALETTE_START, SCHATTR_COLOR_PALETTE_END, // 107 - 107 XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx XATTR_FILL_FIRST, XATTR_FILL_LAST, // 1000 - 1016 svx/xdef.hxx SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST // 1067 - 1078 svx/svddef.hxx diff --git a/chart2/source/inc/chartview/ChartSfxItemIds.hxx b/chart2/source/inc/chartview/ChartSfxItemIds.hxx index 7ddcf432cb1e..43341728d4da 100644 --- a/chart2/source/inc/chartview/ChartSfxItemIds.hxx +++ b/chart2/source/inc/chartview/ChartSfxItemIds.hxx @@ -33,6 +33,7 @@ class SvxChartKindErrorItem; class SvxChartTextOrderItem; class SvxChartRegressItem; class SdrAngleItem; +class SvxChartColorPaletteItem; // SCHATTR @@ -201,7 +202,11 @@ inline constexpr TypedWhichId SCHATTR_DATA_TABLE_OUTLINE inline constexpr TypedWhichId SCHATTR_DATA_TABLE_KEYS (SCHATTR_DATA_TABLE_START + 3); inline constexpr sal_uInt16 SCHATTR_DATA_TABLE_END (SCHATTR_DATA_TABLE_KEYS); -inline constexpr sal_uInt16 SCHATTR_END (SCHATTR_DATA_TABLE_END); +inline constexpr sal_uInt16 SCHATTR_COLOR_PALETTE_START (SCHATTR_DATA_TABLE_END + 1); +inline constexpr TypedWhichId SCHATTR_COLOR_PALETTE (SCHATTR_COLOR_PALETTE_START); +inline constexpr sal_uInt16 SCHATTR_COLOR_PALETTE_END (SCHATTR_COLOR_PALETTE); + +inline constexpr sal_uInt16 SCHATTR_END (SCHATTR_COLOR_PALETTE_END); // values for Items diff --git a/chart2/source/view/main/ChartItemPool.cxx b/chart2/source/view/main/ChartItemPool.cxx index 1a46a041fb17..84903cd42609 100644 --- a/chart2/source/view/main/ChartItemPool.cxx +++ b/chart2/source/view/main/ChartItemPool.cxx @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -179,7 +180,9 @@ static ItemInfoPackage& getItemInfoPackageChart() { SCHATTR_DATA_TABLE_HORIZONTAL_BORDER, new SfxBoolItem(SCHATTR_DATA_TABLE_HORIZONTAL_BORDER, false), 0, SFX_ITEMINFOFLAG_NONE }, { SCHATTR_DATA_TABLE_VERTICAL_BORDER, new SfxBoolItem(SCHATTR_DATA_TABLE_VERTICAL_BORDER, false), 0, SFX_ITEMINFOFLAG_NONE }, { SCHATTR_DATA_TABLE_OUTLINE, new SfxBoolItem(SCHATTR_DATA_TABLE_OUTLINE, false), 0, SFX_ITEMINFOFLAG_NONE }, - { SCHATTR_DATA_TABLE_KEYS, new SfxBoolItem(SCHATTR_DATA_TABLE_KEYS, false), 0, SFX_ITEMINFOFLAG_NONE } + { SCHATTR_DATA_TABLE_KEYS, new SfxBoolItem(SCHATTR_DATA_TABLE_KEYS, false), 0, SFX_ITEMINFOFLAG_NONE }, + { SCHATTR_COLOR_PALETTE, new SvxChartColorPaletteItem(ChartColorPaletteType::Unknown, 0, SCHATTR_COLOR_PALETTE), 0, SFX_ITEMINFOFLAG_NONE } + }}; virtual const ItemInfoStatic& getItemInfoStatic(size_t nIndex) const override { return maItemInfos[nIndex]; } diff --git a/chart2/uiconfig/ui/tp_ChartColorPalette.ui b/chart2/uiconfig/ui/tp_ChartColorPalette.ui new file mode 100644 index 000000000000..3fb233011922 --- /dev/null +++ b/chart2/uiconfig/ui/tp_ChartColorPalette.ui @@ -0,0 +1,112 @@ + + + + + + True + False + 4 + 4 + 16 + + + True + False + 4 + 4 + 3 + 0 + none + + + True + True + start + in + + + True + False + start + + + True + False + start + + + + + + + + + True + False + 2 + Colorful + + + + + + + + False + True + 8 + 0 + + + + + True + False + 4 + 4 + 3 + 0 + none + + + True + True + start + in + + + True + False + start + + + True + False + start + + + + + + + + + True + False + 2 + Monochromatic + + + + + + + + False + True + 8 + 1 + + + + diff --git a/include/svl/poolitem.hxx b/include/svl/poolitem.hxx index 259f1ac1cc06..376bc6069cd9 100644 --- a/include/svl/poolitem.hxx +++ b/include/svl/poolitem.hxx @@ -322,6 +322,7 @@ enum class SfxItemType : sal_uInt16 SvxCharReliefItemType, SvxCharRotateItemType, SvxCharScaleWidthItemType, + SvxChartColorPaletteItemType, SvxChartColorTableItemType, SvxChartIndicateItemType, SvxChartKindErrorItemType, diff --git a/include/svx/chrtitem.hxx b/include/svx/chrtitem.hxx index 5aa7fb00662d..69c91a637453 100644 --- a/include/svx/chrtitem.hxx +++ b/include/svx/chrtitem.hxx @@ -26,6 +26,8 @@ #include #include +enum class ChartColorPaletteType: sal_Int32; + enum class SvxChartTextOrder { SideBySide, @@ -150,6 +152,35 @@ public: double GetValue() const { return m_fVal; } }; +class SAL_WARN_UNUSED SVXCORE_DLLPUBLIC SvxChartColorPaletteItem final : public SfxPoolItem +{ + ChartColorPaletteType meType; + sal_uInt32 mnIndex; + +public: + static SfxPoolItem* CreateDefault(); + DECLARE_ITEM_TYPE_FUNCTION(SvxChartColorPaletteItem); + SvxChartColorPaletteItem(ChartColorPaletteType eType, sal_uInt32 nIndex, + TypedWhichId nId); + SvxChartColorPaletteItem(const SvxChartColorPaletteItem& rItem); + + virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const override; + virtual bool PutValue(const css::uno::Any& rVal, sal_uInt8 nMemberId) override; + + virtual bool GetPresentation(SfxItemPresentation ePres, MapUnit eCoreMetric, + MapUnit ePresMetric, OUString& rText, + const IntlWrapper&) const override; + + virtual bool operator==(const SfxPoolItem& rItem) const override; + virtual SvxChartColorPaletteItem* Clone(SfxItemPool* pPool = nullptr) const override; + + ChartColorPaletteType GetType() const { return meType; } + sal_uInt32 GetIndex() const { return mnIndex; } + + void SetType(const ChartColorPaletteType eType) { meType = eType; } + void SetIndex(const sal_uInt32 nIndex) { mnIndex = nIndex; } +}; + #endif // INCLUDED_SVX_CHRTITEM_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svx/unomid.hxx b/include/svx/unomid.hxx index 766996a57ac0..0af529c5797d 100644 --- a/include/svx/unomid.hxx +++ b/include/svx/unomid.hxx @@ -93,6 +93,10 @@ #define MID_LEFT 3 +// SvxChartColorPaletteItem +#define MID_CHART_COLOR_PALETTE_TYPE 0 +#define MID_CHART_COLOR_PALETTE_INDEX 1 + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/items/chrtitem.cxx b/svx/source/items/chrtitem.cxx index 8b3a4c776ce2..d7e2dc43066b 100644 --- a/svx/source/items/chrtitem.cxx +++ b/svx/source/items/chrtitem.cxx @@ -22,7 +22,10 @@ #include #include #include + +#include #include +#include using namespace ::com::sun::star; @@ -176,4 +179,89 @@ SvxChartRegressItem* SvxChartRegressItem::Clone(SfxItemPool* /*pPool*/) const return new SvxChartRegressItem(*this); } +// SvxChartColorPaletteItem implementation + +SfxPoolItem* SvxChartColorPaletteItem::CreateDefault() +{ + return new SvxChartColorPaletteItem(ChartColorPaletteType::Unknown, 0, + TypedWhichId(0)); +} + +SvxChartColorPaletteItem::SvxChartColorPaletteItem(const ChartColorPaletteType eType, + const sal_uInt32 nIndex, + const TypedWhichId nId) + : SfxPoolItem(nId) + , meType(eType) + , mnIndex(nIndex) +{ +} + +SvxChartColorPaletteItem::SvxChartColorPaletteItem(const SvxChartColorPaletteItem& rItem) + : SfxPoolItem(rItem) + , meType(rItem.meType) + , mnIndex(rItem.mnIndex) +{ +} + +bool SvxChartColorPaletteItem::QueryValue(uno::Any& rVal, const sal_uInt8 nMemberId) const +{ + if (nMemberId == MID_CHART_COLOR_PALETTE_TYPE) + { + rVal <<= static_cast(meType); + return true; + } + if (nMemberId == MID_CHART_COLOR_PALETTE_INDEX) + { + rVal <<= mnIndex; + return true; + } + return false; +} + +bool SvxChartColorPaletteItem::PutValue(const uno::Any& rVal, const sal_uInt8 nMemberId) +{ + if (nMemberId == MID_CHART_COLOR_PALETTE_TYPE) + { + sal_Int32 nType = -1; + rVal >>= nType; + meType = static_cast(nType); + return true; + } + if (nMemberId == MID_CHART_COLOR_PALETTE_INDEX) + { + rVal >>= mnIndex; + return true; + } + return false; +} + +bool SvxChartColorPaletteItem::GetPresentation(SfxItemPresentation /*ePres*/, + MapUnit /*eCoreMetric*/, MapUnit /*ePresMetric*/, + OUString& rText, const IntlWrapper&) const +{ + if (meType == ChartColorPaletteType::Colorful) + rText = u"Colorful"_ustr; + else if (meType == ChartColorPaletteType::Monochromatic) + rText = u"Monochromatic"_ustr; + else + rText = u"Unknown"_ustr; + + rText += u" "_ustr; + rText += OUString::number(mnIndex); + + return true; +} + +bool SvxChartColorPaletteItem::operator==(const SfxPoolItem& rItem) const +{ + assert(SfxPoolItem::operator==(rItem)); + const auto& rOther = static_cast(rItem); + return (meType == rOther.meType && mnIndex == rOther.mnIndex); +} + +SvxChartColorPaletteItem* SvxChartColorPaletteItem::Clone(SfxItemPool* /*pPool*/) const +{ + return new SvxChartColorPaletteItem(*this); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/jsdialog/enabled.cxx b/vcl/jsdialog/enabled.cxx index 9e0a0b5819b2..4afc5e430ca8 100644 --- a/vcl/jsdialog/enabled.cxx +++ b/vcl/jsdialog/enabled.cxx @@ -285,6 +285,7 @@ constexpr auto SchartDialogList { u"modules/schart/ui/inserttitledlg.ui" }, { u"modules/schart/ui/smoothlinesdlg.ui" }, { u"modules/schart/ui/steppedlinesdlg.ui" }, + { u"modules/schart/ui/tp_ChartColorPalette.ui" }, { u"modules/schart/ui/tp_ChartType.ui" }, { u"modules/schart/ui/tp_DataLabel.ui" }, { u"modules/schart/ui/tp_DataSource.ui" },