summaryrefslogtreecommitdiff
path: root/svx/source
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-12-20 08:46:40 +0100
committerMiklos Vajna <vmiklos@collabora.com>2021-12-20 11:31:53 +0100
commit7d5984d7aed2bafcb599882b66bb0dde2d22ff3f (patch)
tree6565464f4d754a7c45700ae9b63d28aafa59b8da /svx/source
parent24ea26f55ee4e8a3c69b6dc9911a8c42e56f1eb2 (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. Change-Id: I7a45d7cf63c7c36013e4656c66d9b2dbc3aa0b88 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127135 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'svx/source')
-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 2946bea56c21..9fe859e96a48 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)
@@ -3885,7 +3890,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);
}
@@ -3905,8 +3910,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();
}
@@ -3919,9 +3924,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)
@@ -3967,7 +3972,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)
@@ -3979,21 +3984,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);