summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-12-20 08:46:40 +0100
committerMiklos Vajna <vmiklos@collabora.com>2022-06-29 14:55:55 +0200
commit349fccc2840a84520054bbbbb6864fdd8f2b8112 (patch)
treea22e593ac3b918a83ef57ebe296d745725641c2b /svx
parente8b3609230406c6589c5d123f018edb38e543679 (diff)
sd theme: allow setting the color's theme index in the chardlg
This routes not only the rgb color and a name, but also a theme index from the color picker to the chardlg (only there as a start). That way the picked color will be updated if the master page theme changes. (cherry picked from commit 7d5984d7aed2bafcb599882b66bb0dde2d22ff3f) Change-Id: I7a45d7cf63c7c36013e4656c66d9b2dbc3aa0b88 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136608 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/tbxctrls/Palette.cxx13
-rw-r--r--svx/source/tbxctrls/PaletteManager.cxx36
-rw-r--r--svx/source/tbxctrls/tbcontrl.cxx33
3 files changed, 54 insertions, 28 deletions
diff --git a/svx/source/tbxctrls/Palette.cxx b/svx/source/tbxctrls/Palette.cxx
index b83b206cbe5a..fabccc8f2022 100644
--- a/svx/source/tbxctrls/Palette.cxx
+++ b/svx/source/tbxctrls/Palette.cxx
@@ -361,4 +361,17 @@ bool PaletteSOC::IsValid()
return true;
}
+namespace svx
+{
+NamedColor NamedThemedColor::ToNamedColor() const { return { m_aColor, m_aName }; }
+
+NamedThemedColor NamedThemedColor::FromNamedColor(const NamedColor& rNamedColor)
+{
+ NamedThemedColor aColor;
+ aColor.m_aColor = rNamedColor.first;
+ aColor.m_aName = rNamedColor.second;
+ return aColor;
+}
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx
index 8b0a85deb101..4ed6d3059187 100644
--- a/svx/source/tbxctrls/PaletteManager.cxx
+++ b/svx/source/tbxctrls/PaletteManager.cxx
@@ -126,6 +126,11 @@ void PaletteManager::LoadPalettes()
}
}
+bool PaletteManager::IsThemePaletteSelected() const
+{
+ return mnCurrentPalette == mnNumOfPalettes - 2;
+}
+
void PaletteManager::ReloadColorSet(SvxColorValueSet &rColorSet)
{
if( mnCurrentPalette == 0)
@@ -141,7 +146,7 @@ void PaletteManager::ReloadColorSet(SvxColorValueSet &rColorSet)
++nIx;
}
}
- else if (mnCurrentPalette == mnNumOfPalettes - 2)
+ else if (IsThemePaletteSelected())
{
SfxObjectShell* pObjectShell = SfxObjectShell::Current();
if (pObjectShell)
@@ -149,17 +154,20 @@ void PaletteManager::ReloadColorSet(SvxColorValueSet &rColorSet)
std::vector<Color> aColors = pObjectShell->GetThemeColors();
mnColorCount = aColors.size();
rColorSet.Clear();
- std::vector<OUString> aNames = {
- SvxResId(RID_SVXSTR_THEME_COLOR1), SvxResId(RID_SVXSTR_THEME_COLOR2),
- SvxResId(RID_SVXSTR_THEME_COLOR3), SvxResId(RID_SVXSTR_THEME_COLOR4),
- SvxResId(RID_SVXSTR_THEME_COLOR5), SvxResId(RID_SVXSTR_THEME_COLOR6),
- SvxResId(RID_SVXSTR_THEME_COLOR7), SvxResId(RID_SVXSTR_THEME_COLOR8),
- SvxResId(RID_SVXSTR_THEME_COLOR9), SvxResId(RID_SVXSTR_THEME_COLOR10),
- SvxResId(RID_SVXSTR_THEME_COLOR11), SvxResId(RID_SVXSTR_THEME_COLOR12),
- };
- for (int i = 0; i < 12; ++i)
+ if (aColors.size() >= 12)
{
- rColorSet.InsertItem(i, aColors[i], aNames[i]);
+ std::vector<OUString> aNames = {
+ SvxResId(RID_SVXSTR_THEME_COLOR1), SvxResId(RID_SVXSTR_THEME_COLOR2),
+ SvxResId(RID_SVXSTR_THEME_COLOR3), SvxResId(RID_SVXSTR_THEME_COLOR4),
+ SvxResId(RID_SVXSTR_THEME_COLOR5), SvxResId(RID_SVXSTR_THEME_COLOR6),
+ SvxResId(RID_SVXSTR_THEME_COLOR7), SvxResId(RID_SVXSTR_THEME_COLOR8),
+ SvxResId(RID_SVXSTR_THEME_COLOR9), SvxResId(RID_SVXSTR_THEME_COLOR10),
+ SvxResId(RID_SVXSTR_THEME_COLOR11), SvxResId(RID_SVXSTR_THEME_COLOR12),
+ };
+ for (int i = 0; i < 12; ++i)
+ {
+ rColorSet.InsertItem(i, aColors[i], aNames[i]);
+ }
}
}
}
@@ -340,12 +348,12 @@ void PaletteManager::PopupColorPicker(weld::Window* pParent, const OUString& aCo
if (mpBtnUpdater)
mpBtnUpdater->Update(aNamedColor);
AddRecentColor(aLastColor, sColorName);
- maColorSelectFunction(aCommandCopy, aNamedColor);
+ maColorSelectFunction(aCommandCopy, svx::NamedThemedColor::FromNamedColor(aNamedColor));
}
});
}
-void PaletteManager::DispatchColorCommand(const OUString& aCommand, const NamedColor& rColor)
+void PaletteManager::DispatchColorCommand(const OUString& aCommand, const svx::NamedThemedColor& rColor)
{
using namespace css::uno;
using namespace css::frame;
@@ -362,7 +370,7 @@ void PaletteManager::DispatchColorCommand(const OUString& aCommand, const NamedC
INetURLObject aObj( aCommand );
Sequence<PropertyValue> aArgs{ comphelper::makePropertyValue(aObj.GetURLPath(),
- sal_Int32(rColor.first)) };
+ sal_Int32(rColor.m_aColor)) };
URL aTargetURL;
aTargetURL.Complete = aCommand;
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 465b96c13106..eb16366d55d2 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -1969,7 +1969,12 @@ IMPL_LINK(ColorWindow, SelectHdl, ValueSet*, pColorSet, void)
maMenuButton.set_inactive();
- aColorSelectFunction(sCommand, aNamedColor);
+ auto aNamedThemedColor = svx::NamedThemedColor::FromNamedColor(aNamedColor);
+ if (mxPaletteManager->IsThemePaletteSelected())
+ {
+ aNamedThemedColor.m_nThemeIndex = pColorSet->GetSelectedItemId();
+ }
+ aColorSelectFunction(sCommand, aNamedThemedColor);
}
IMPL_LINK_NOARG(ColorWindow, SelectPaletteHdl, weld::ComboBox&, void)
@@ -2002,7 +2007,7 @@ IMPL_LINK(ColorWindow, AutoColorClickHdl, weld::Button&, rButton, void)
maMenuButton.set_inactive();
- aColorSelectFunction(sCommand, aNamedColor);
+ aColorSelectFunction(sCommand, svx::NamedThemedColor::FromNamedColor(aNamedColor));
}
IMPL_LINK_NOARG(ColorWindow, OpenPickerClickHdl, weld::Button&, void)
@@ -3888,7 +3893,7 @@ ListBoxColorWrapper::ListBoxColorWrapper(ColorListBox* pControl)
}
void ListBoxColorWrapper::operator()(
- [[maybe_unused]] const OUString& /*rCommand*/, const NamedColor& rColor)
+ [[maybe_unused]] const OUString& /*rCommand*/, const svx::NamedThemedColor& rColor)
{
mpControl->Selected(rColor);
}
@@ -3908,8 +3913,8 @@ void ColorListBox::SetSlotId(sal_uInt16 nSlotId, bool bShowNoneButton)
m_bShowNoneButton = bShowNoneButton;
m_xButton->set_popover(nullptr);
m_xColorWindow.reset();
- m_aSelectedColor = bShowNoneButton ? GetNoneColor() : GetAutoColor(m_nSlotId);
- ShowPreview(m_aSelectedColor);
+ m_aSelectedColor = svx::NamedThemedColor::FromNamedColor(bShowNoneButton ? GetNoneColor() : GetAutoColor(m_nSlotId));
+ ShowPreview(m_aSelectedColor.ToNamedColor());
createColorWindow();
}
@@ -3922,9 +3927,9 @@ ColorListBox::ColorListBox(std::unique_ptr<weld::MenuButton> pControl, TopLevelP
, m_aTopLevelParentFunction(rTopLevelParentFunction)
{
m_xButton->connect_toggled(LINK(this, ColorListBox, ToggleHdl));
- m_aSelectedColor = GetAutoColor(m_nSlotId);
+ m_aSelectedColor = svx::NamedThemedColor::FromNamedColor(GetAutoColor(m_nSlotId));
LockWidthRequest();
- ShowPreview(m_aSelectedColor);
+ ShowPreview(m_aSelectedColor.ToNamedColor());
}
IMPL_LINK(ColorListBox, ToggleHdl, weld::Toggleable&, rButton, void)
@@ -3970,7 +3975,7 @@ void ColorListBox::createColorWindow()
m_xButton->set_popover(m_xColorWindow->getTopLevel());
if (m_bShowNoneButton)
m_xColorWindow->ShowNoneButton();
- m_xColorWindow->SelectEntry(m_aSelectedColor);
+ m_xColorWindow->SelectEntry(m_aSelectedColor.ToNamedColor());
}
void ColorListBox::SelectEntry(const NamedColor& rColor)
@@ -3982,21 +3987,21 @@ void ColorListBox::SelectEntry(const NamedColor& rColor)
}
ColorWindow* pColorWindow = getColorWindow();
pColorWindow->SelectEntry(rColor);
- m_aSelectedColor = pColorWindow->GetSelectEntryColor();
- ShowPreview(m_aSelectedColor);
+ m_aSelectedColor = svx::NamedThemedColor::FromNamedColor(pColorWindow->GetSelectEntryColor());
+ ShowPreview(m_aSelectedColor.ToNamedColor());
}
void ColorListBox::SelectEntry(const Color& rColor)
{
ColorWindow* pColorWindow = getColorWindow();
pColorWindow->SelectEntry(rColor);
- m_aSelectedColor = pColorWindow->GetSelectEntryColor();
- ShowPreview(m_aSelectedColor);
+ m_aSelectedColor = svx::NamedThemedColor::FromNamedColor(pColorWindow->GetSelectEntryColor());
+ ShowPreview(m_aSelectedColor.ToNamedColor());
}
-void ColorListBox::Selected(const NamedColor& rColor)
+void ColorListBox::Selected(const svx::NamedThemedColor& rColor)
{
- ShowPreview(rColor);
+ ShowPreview(rColor.ToNamedColor());
m_aSelectedColor = rColor;
if (m_aSelectedLink.IsSet())
m_aSelectedLink.Call(*this);