cui/Module_cui.mk | 1 cui/UITest_cui_options.mk | 16 +++++++++ cui/qa/uitest/options/optchartcolorspage.py | 48 ++++++++++++++++++++++++++++ cui/source/options/optchart.cxx | 35 ++++++++++++++++++++ cui/source/options/optchart.hxx | 1 include/svtools/valueset.hxx | 1 include/svx/PaletteManager.hxx | 2 - svtools/source/control/valueset.cxx | 11 +----- svx/source/tbxctrls/PaletteManager.cxx | 9 +++-- 9 files changed, 111 insertions(+), 13 deletions(-)
New commits: commit fe8dad3b7ea1e30312ba25ca328f2fc3f063979e Author: Jim Raykowski <[email protected]> AuthorDate: Mon Nov 3 00:14:58 2025 -0900 Commit: Jim Raykowski <[email protected]> CommitDate: Sun Nov 9 17:00:32 2025 +0100 related tdf#163347: Sync colour table to chart colors list selection This patch makes the selected data series entry color in the chart colors list be selected in the color table for SvxDefaultColorOptPage. The color selection made in the color table could be from a different palette than the original. The first palette in the list of palettes that has a matching color is choosen. I noticed when a color selected from the Material palette was set for a data series color, the Tonal palette was shown when reselecting it. An off by 1 index bug that causes the last palette in the list of palettes to not be searched for the color was found. Another thing I noticed is when a data series chart color was set to a color in the Freecolour HCL palette that needed to be scrolled to see it, it didn't do it. Commenting out mbScroll in the condition in the SelectItem function that checks its value solved the problem. I don't get the need for the ValueSet mbScroll variable. The only place its value can change is in the Format function. That doesn't get called in the SelectItem function unless mnCols is 0. The SelectItem function is the only place its value is checked. I don't see a problem with always checking if the visible area needs to be scrolled. This patch removes the ValueSet mbScroll variable. Change-Id: I1f05a3ad8a0b64b2a28d3001cace391379cc00c6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193437 Tested-by: Jenkins Reviewed-by: Jim Raykowski <[email protected]> diff --git a/cui/Module_cui.mk b/cui/Module_cui.mk index 53492ef291a4..34d4cbc423ad 100644 --- a/cui/Module_cui.mk +++ b/cui/Module_cui.mk @@ -30,6 +30,7 @@ $(eval $(call gb_Module_add_screenshot_targets,cui,\ $(eval $(call gb_Module_add_uicheck_targets,cui,\ UITest_cui_dialogs \ UITest_cui_tabpages \ + UITest_cui_options \ )) # vim: set noet sw=4 ts=4: diff --git a/cui/UITest_cui_options.mk b/cui/UITest_cui_options.mk new file mode 100644 index 000000000000..21c563be404a --- /dev/null +++ b/cui/UITest_cui_options.mk @@ -0,0 +1,16 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# 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/. +# + +$(eval $(call gb_UITest_UITest,cui_options)) + +$(eval $(call gb_UITest_add_modules,cui_options,$(SRCDIR)/cui/qa/uitest,\ + options/ \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/cui/qa/uitest/options/optchartcolorspage.py b/cui/qa/uitest/options/optchartcolorspage.py new file mode 100644 index 000000000000..5b4f4809341e --- /dev/null +++ b/cui/qa/uitest/options/optchartcolorspage.py @@ -0,0 +1,48 @@ +# +# 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/. +# + +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict + +# Test for cui/source/options/optchart.cxx +class Test(UITestCase): + + def hex_to_rgb(self, hex): + return str(tuple(int(hex[i:i+2], 16) for i in (0, 2, 4))).replace(" ", "") + + def test_options_charts_defaultcolors_chartcolors_colortable_color_match(self): + + with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialog: + pages = xDialog.getChild("pages") + chartsEntry = pages.getChild('4') + chartsEntry.executeAction("EXPAND", tuple()) + chartsEntryDefaultColorsEntry = chartsEntry.getChild('0') + chartsEntryDefaultColorsEntry.executeAction("SELECT", tuple()) + + chartsColors = xDialog.getChild("colors") + colorTable = xDialog.getChild("table") + + # Chart Data Series default colors + dataSeriesDefaultColors = ["004586", + "ff420e", + "ffd320", + "579d1c", + "7e0021", + "83caff", + "314004", + "aecf00", + "4b1f6f", + "ff950e", + "c5000b", + "0084d1"] + + for i in range(len(dataSeriesDefaultColors)): + chartsColorsDataSeriesEntry = chartsColors.getChild(i) + chartsColorsDataSeriesEntry.executeAction("SELECT", tuple()) + self.assertEqual(get_state_as_dict(colorTable)["CurrColorPos"], str(i)) + self.assertEqual(get_state_as_dict(colorTable)["RGB"], self.hex_to_rgb(dataSeriesDefaultColors[i])) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/cui/source/options/optchart.cxx b/cui/source/options/optchart.cxx index 4a457b167770..dce4513adc6a 100644 --- a/cui/source/options/optchart.cxx +++ b/cui/source/options/optchart.cxx @@ -89,6 +89,37 @@ void SvxDefaultColorOptPage::FillBoxChartColorLB() m_xLbChartColors->thaw(); } +IMPL_LINK_NOARG(SvxDefaultColorOptPage, LbChartColorsSelectionChangedHdl, weld::TreeView&, void) +{ + auto nIndex = m_xLbChartColors->get_selected_index(); + if (nIndex == -1) + return; + + Color& rColor(aColorList[nIndex]); + + XColorListRef xColorList; + for (size_t i = 0, nSize = aPaletteManager.GetPaletteList().size(); i < nSize; ++i) + { + aPaletteManager.SetPalette(i, true/*bPosOnly*/); + + xColorList = XPropertyList::AsColorList(XPropertyList::CreatePropertyListFromURL( + XPropertyListType::Color, aPaletteManager.GetSelectedPalettePath())); + if (!xColorList->Load()) + continue; + + auto nPos = xColorList->GetIndexOfColor(rColor); + if (nPos == -1) + continue; + + m_xLbPaletteSelector->set_active_text(aPaletteManager.GetPaletteName()); + SelectPaletteLbHdl(*m_xLbPaletteSelector); + + m_xValSetColorBox->SelectItem(m_xValSetColorBox->GetItemId(nPos)); + + return; + } +} + SvxDefaultColorOptPage::SvxDefaultColorOptPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs) : SfxTabPage(pPage, pController, u"cui/ui/optchartcolorspage.ui"_ustr, u"OptChartColorsPage"_ustr, &rInAttrs) , m_xLbChartColors(m_xBuilder->weld_tree_view(u"colors"_ustr)) @@ -101,6 +132,9 @@ SvxDefaultColorOptPage::SvxDefaultColorOptPage(weld::Container* pPage, weld::Dia { m_xLbChartColors->set_size_request(-1, m_xLbChartColors->get_height_rows(16)); + m_xLbChartColors->connect_selection_changed( + LINK(this, SvxDefaultColorOptPage, LbChartColorsSelectionChangedHdl)); + if (officecfg::Office::Chart::DefaultColor::Series::isReadOnly()) { m_xPBDefault->set_sensitive(false); @@ -145,6 +179,7 @@ void SvxDefaultColorOptPage::Construct() FillPaletteLB(); m_xLbChartColors->select( 0 ); + LbChartColorsSelectionChangedHdl(*m_xLbChartColors); } std::unique_ptr<SfxTabPage> SvxDefaultColorOptPage::Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrs ) diff --git a/cui/source/options/optchart.hxx b/cui/source/options/optchart.hxx index 22a01495b276..dca98b9f7fbf 100644 --- a/cui/source/options/optchart.hxx +++ b/cui/source/options/optchart.hxx @@ -52,6 +52,7 @@ private: DECL_LINK(RemoveChartColor, weld::Button&, void); DECL_LINK(BoxClickedHdl, ValueSet*, void); DECL_LINK(SelectPaletteLbHdl, weld::ComboBox&, void); + DECL_LINK(LbChartColorsSelectionChangedHdl, weld::TreeView&, void); void FillPaletteLB(); diff --git a/include/svtools/valueset.hxx b/include/svtools/valueset.hxx index 5a792ef0a24e..3852200ea8c2 100644 --- a/include/svtools/valueset.hxx +++ b/include/svtools/valueset.hxx @@ -215,7 +215,6 @@ private: bool mbHighlight : 1; bool mbNoSelection : 1; bool mbDoubleSel : 1; - bool mbScroll : 1; bool mbFullMode : 1; bool mbEdgeBlending : 1; bool mbHasVisibleItems : 1; diff --git a/include/svx/PaletteManager.hxx b/include/svx/PaletteManager.hxx index 98c32fb855ad..574dae22d679 100644 --- a/include/svx/PaletteManager.hxx +++ b/include/svx/PaletteManager.hxx @@ -66,7 +66,7 @@ public: void ReloadColorSet(SvxColorValueSet& rColorSet); void ReloadRecentColorSet(SvxColorValueSet& rColorSet); std::vector<OUString> GetPaletteList(); - void SetPalette( sal_Int32 nPos ); + void SetPalette(sal_Int32 nPos, bool bPosOnly = false); sal_Int32 GetPalette() const; sal_Int32 GetPaletteCount() const { return mnNumOfPalettes; } OUString GetPaletteName(); diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx index 79b793a2ee2f..32c48d356d41 100644 --- a/svtools/source/control/valueset.cxx +++ b/svtools/source/control/valueset.cxx @@ -101,7 +101,6 @@ ValueSet::ValueSet(std::unique_ptr<weld::ScrolledWindow> pScrolledWindow) mnFrameStyle = DrawFrameStyle::NONE; mbNoSelection = true; mbDoubleSel = false; - mbScroll = false; mbFullMode = true; mbEdgeBlending = false; mbHasVisibleItems = false; @@ -752,7 +751,7 @@ void ValueSet::SelectItem( sal_uInt16 nItemId ) } // if necessary scroll to the visible area - if (mbScroll && nItemId && mnCols) + if (nItemId && mnCols) { sal_uInt16 nNewLine = static_cast<sal_uInt16>(nItemPos / mnCols); if ( nNewLine < mnFirstLine ) @@ -760,7 +759,8 @@ void ValueSet::SelectItem( sal_uInt16 nItemId ) SetFirstLine(nNewLine); bNewLine = true; } - else if ( nNewLine > o3tl::make_unsigned(mnFirstLine+mnVisLines-1) ) + else if (mnFirstLine + mnVisLines - 1 >= 0 + && nNewLine > o3tl::make_unsigned(mnFirstLine + mnVisLines - 1)) { SetFirstLine(static_cast<sal_uInt16>(nNewLine-mnVisLines+1)); bNewLine = true; @@ -930,8 +930,6 @@ void ValueSet::Format(vcl::RenderContext const & rRenderContext) } // calculate number of rows - mbScroll = false; - auto nOldLines = mnLines; // Floor( (M+N-1)/N )==Ceiling( M/N ) mnLines = (static_cast<tools::Long>(nItemCount) + mnCols - 1) / mnCols; @@ -960,9 +958,6 @@ void ValueSet::Format(vcl::RenderContext const & rRenderContext) bAdjustmentOutOfDate |= nOldVisLines != mnVisLines; - if (mnLines > mnVisLines) - mbScroll = true; - if (mnLines <= mnVisLines) { SetFirstLine(0); diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx index fd9d11b0e56a..71ea035d3fe9 100644 --- a/svx/source/tbxctrls/PaletteManager.cxx +++ b/svx/source/tbxctrls/PaletteManager.cxx @@ -280,9 +280,11 @@ std::vector<OUString> PaletteManager::GetPaletteList() return aPaletteNames; } -void PaletteManager::SetPalette( sal_Int32 nPos ) +void PaletteManager::SetPalette(sal_Int32 nPos, bool bPosOnly) { mnCurrentPalette = nPos; + if (bPosOnly) + return; if( nPos != mnNumOfPalettes - 1 && nPos != 0) { mpColorList = XPropertyList::AsColorList( @@ -332,8 +334,9 @@ OUString PaletteManager::GetPaletteName() const OUString & PaletteManager::GetSelectedPalettePath() { - if (mnCurrentPalette < m_Palettes.size() && mnCurrentPalette != 0) - return m_Palettes[mnCurrentPalette - 1]->GetPath(); + auto nPalettesIndex = mnCurrentPalette - 1; + if (nPalettesIndex >= 0 && o3tl::make_unsigned(nPalettesIndex) < m_Palettes.size()) + return m_Palettes[nPalettesIndex]->GetPath(); else return EMPTY_OUSTRING; }
