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 <raykowj@gmail.com>
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
@@ -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:
|
||||
@@ -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 )
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user