summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2023-05-22 14:35:19 +0900
committerTomaž Vajngerl <quikee@gmail.com>2023-05-25 03:59:01 +0200
commit9a4b768b0a22bd3ae627c7355bbd223b9cf65015 (patch)
tree673c3cc38b8ffcb8c9b321cba8579e343a61e137
parent8e87f1f2ff4df763e29bdc097786230c6293744b (diff)
svx: combine svx::NamedThemedColor into NamedColor
Change-Id: I9a9656ddce9c12564411cfcb3e8e8714ae74a418 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152236 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r--chart2/source/controller/sidebar/ChartColorWrapper.cxx2
-rw-r--r--chart2/source/controller/sidebar/ChartColorWrapper.hxx2
-rw-r--r--cui/source/inc/cuitabarea.hxx4
-rw-r--r--cui/source/tabpages/chardlg.cxx2
-rw-r--r--cui/source/tabpages/tpcolor.cxx22
-rw-r--r--include/svx/Palette.hxx23
-rw-r--r--include/svx/PaletteManager.hxx2
-rw-r--r--include/svx/colorbox.hxx10
-rw-r--r--include/svx/tbcontrl.hxx2
-rw-r--r--reportdesign/source/ui/dlg/Condition.cxx4
-rw-r--r--reportdesign/source/ui/dlg/Condition.hxx2
-rw-r--r--svx/source/tbxctrls/Palette.cxx13
-rw-r--r--svx/source/tbxctrls/PaletteManager.cxx4
-rw-r--r--svx/source/tbxctrls/tbcontrl.cxx35
14 files changed, 49 insertions, 78 deletions
diff --git a/chart2/source/controller/sidebar/ChartColorWrapper.cxx b/chart2/source/controller/sidebar/ChartColorWrapper.cxx
index 7376f37070ff..e1011a684787 100644
--- a/chart2/source/controller/sidebar/ChartColorWrapper.cxx
+++ b/chart2/source/controller/sidebar/ChartColorWrapper.cxx
@@ -87,7 +87,7 @@ ChartColorWrapper::ChartColorWrapper(
{
}
-void ChartColorWrapper::operator()([[maybe_unused]] const OUString& , const svx::NamedThemedColor& rColor)
+void ChartColorWrapper::operator()([[maybe_unused]] const OUString& , const NamedColor& rColor)
{
css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
diff --git a/chart2/source/controller/sidebar/ChartColorWrapper.hxx b/chart2/source/controller/sidebar/ChartColorWrapper.hxx
index c4d30a8a314c..6894726768d0 100644
--- a/chart2/source/controller/sidebar/ChartColorWrapper.hxx
+++ b/chart2/source/controller/sidebar/ChartColorWrapper.hxx
@@ -28,7 +28,7 @@ public:
SvxColorToolBoxControl* pControl,
OUString rPropertyName);
- void operator()(const OUString& rCommand, const svx::NamedThemedColor& rColor);
+ void operator()(const OUString& rCommand, const NamedColor& rColor);
// ColorSelectFunction signature
void updateModel(const rtl::Reference<::chart::ChartModel>& xModel);
diff --git a/cui/source/inc/cuitabarea.hxx b/cui/source/inc/cuitabarea.hxx
index 64ec01ef5abf..7399f03eb0be 100644
--- a/cui/source/inc/cuitabarea.hxx
+++ b/cui/source/inc/cuitabarea.hxx
@@ -658,7 +658,7 @@ private:
ColorModel eCM;
Color aPreviousColor;
- svx::NamedThemedColor aCurrentColor;
+ NamedColor aCurrentColor;
PaletteManager maPaletteManager;
SvxXRectPreview m_aCtlPreviewOld;
@@ -714,7 +714,7 @@ private:
DECL_LINK(SelectPaletteLBHdl, weld::ComboBox&, void);
DECL_LINK( SelectValSetHdl_Impl, ValueSet*, void );
DECL_LINK( SelectColorModeHdl_Impl, weld::Toggleable&, void );
- void ChangeColor(const svx::NamedThemedColor &rNewColor, bool bUpdatePreset = true);
+ void ChangeColor(const NamedColor &rNewColor, bool bUpdatePreset = true);
void SetColorModel(ColorModel eModel);
void ChangeColorModel();
void UpdateColorValues( bool bUpdatePreset = true );
diff --git a/cui/source/tabpages/chardlg.cxx b/cui/source/tabpages/chardlg.cxx
index 601dae8dce0e..87984d573281 100644
--- a/cui/source/tabpages/chardlg.cxx
+++ b/cui/source/tabpages/chardlg.cxx
@@ -1572,7 +1572,7 @@ bool SvxCharEffectsPage::FillItemSetColor_Impl( SfxItemSet& rSet )
sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_COLOR );
const SfxItemSet& rOldSet = GetItemSet();
- svx::NamedThemedColor aSelectedColor;
+ NamedColor aSelectedColor;
bool bChanged = m_bNewFontColor;
if (bChanged)
diff --git a/cui/source/tabpages/tpcolor.cxx b/cui/source/tabpages/tpcolor.cxx
index 799f53957678..470b1c13a866 100644
--- a/cui/source/tabpages/tpcolor.cxx
+++ b/cui/source/tabpages/tpcolor.cxx
@@ -209,9 +209,9 @@ void SvxColorTabPage::ActivatePage( const SfxItemSet& )
ChangeColorModel();
const Color aColor = pFillColorItem->GetColorValue();
- svx::NamedThemedColor aThemedColor;
- aThemedColor.m_aColor = aColor;
- ChangeColor( aThemedColor );
+ NamedColor aNamedColor;
+ aNamedColor.m_aColor = aColor;
+ ChangeColor(aNamedColor);
sal_Int32 nPos = FindInPalette( aColor );
if ( nPos != -1 )
@@ -288,9 +288,9 @@ void SvxColorTabPage::Reset( const SfxItemSet* rSet )
SetColorModel( eCM );
ChangeColorModel();
- svx::NamedThemedColor aThemedColor;
- aThemedColor.m_aColor = aNewColor;
- ChangeColor(aThemedColor);
+ NamedColor aColor;
+ aColor.m_aColor = aNewColor;
+ ChangeColor(aColor);
UpdateModified();
}
@@ -518,14 +518,14 @@ IMPL_LINK(SvxColorTabPage, SelectValSetHdl_Impl, ValueSet*, pValSet, void)
{
bThemePaletteSelected = maPaletteManager.IsThemePaletteSelected();
}
- svx::NamedThemedColor aThemedColor;
- aThemedColor.m_aColor = aColor;
+ NamedColor aNamedColor;
+ aNamedColor.m_aColor = aColor;
if (bThemePaletteSelected)
{
- PaletteManager::GetThemeIndexLumModOff(nPos, aThemedColor.m_nThemeIndex, aThemedColor.m_nLumMod, aThemedColor.m_nLumOff);
+ PaletteManager::GetThemeIndexLumModOff(nPos, aNamedColor.m_nThemeIndex, aNamedColor.m_nLumMod, aNamedColor.m_nLumOff);
}
- ChangeColor(aThemedColor, false);
+ ChangeColor(aNamedColor, false);
if (pValSet == m_xValSetColorList.get())
{
@@ -588,7 +588,7 @@ IMPL_STATIC_LINK_NOARG(SvxColorTabPage, OnMoreColorsClick, weld::Button&, void)
comphelper::dispatchCommand(".uno:AdditionsDialog", aArgs);
}
-void SvxColorTabPage::ChangeColor(const svx::NamedThemedColor &rNewColor, bool bUpdatePreset )
+void SvxColorTabPage::ChangeColor(const NamedColor &rNewColor, bool bUpdatePreset )
{
aPreviousColor = rNewColor.m_aColor;
aCurrentColor = rNewColor;
diff --git a/include/svx/Palette.hxx b/include/svx/Palette.hxx
index 8965138c7831..ebdcb63a1377 100644
--- a/include/svx/Palette.hxx
+++ b/include/svx/Palette.hxx
@@ -33,6 +33,9 @@ struct SVXCORE_DLLPUBLIC NamedColor
{
Color m_aColor;
OUString m_aName;
+ sal_Int16 m_nThemeIndex = -1;
+ sal_Int16 m_nLumMod = 10000;
+ sal_Int16 m_nLumOff = 0;
NamedColor() = default;
@@ -42,25 +45,7 @@ struct SVXCORE_DLLPUBLIC NamedColor
{}
};
-namespace svx
-{
-
-/// A color with an optional name and other theming-related properties.
-struct SVXCORE_DLLPUBLIC NamedThemedColor
-{
- Color m_aColor;
- OUString m_aName;
- sal_Int16 m_nThemeIndex = -1;
- sal_Int16 m_nLumMod = 10000;
- sal_Int16 m_nLumOff = 0;
-
- static NamedThemedColor FromNamedColor(const NamedColor& rNamedColor);
-
- NamedColor ToNamedColor() const;
-};
-}
-
-typedef std::function<void(const OUString&, const svx::NamedThemedColor&)> ColorSelectFunction;
+typedef std::function<void(const OUString&, const NamedColor&)> ColorSelectFunction;
class Palette
{
diff --git a/include/svx/PaletteManager.hxx b/include/svx/PaletteManager.hxx
index a21961ecd0ec..c6d1712a12f4 100644
--- a/include/svx/PaletteManager.hxx
+++ b/include/svx/PaletteManager.hxx
@@ -82,7 +82,7 @@ public:
static void GetThemeIndexLumModOff(sal_uInt16 nItemId, sal_Int16& rThemeIndex,
sal_Int16& rLumMod, sal_Int16& rLumOff);
- static void DispatchColorCommand(const OUString& aCommand, const svx::NamedThemedColor& rColor);
+ static void DispatchColorCommand(const OUString& aCommand, const NamedColor& rColor);
};
#endif // INCLUDED_SVX_PALETTEMANAGER_HXX
diff --git a/include/svx/colorbox.hxx b/include/svx/colorbox.hxx
index e48fe4809729..56e4511aac99 100644
--- a/include/svx/colorbox.hxx
+++ b/include/svx/colorbox.hxx
@@ -21,7 +21,7 @@ class ListBoxColorWrapper
public:
ListBoxColorWrapper(ColorListBox* pControl);
void operator()(const OUString& rCommand,
- const svx::NamedThemedColor& rColor); // ColorSelectFunction signature
+ const NamedColor& rColor); // ColorSelectFunction signature
private:
ColorListBox* mpControl;
};
@@ -36,14 +36,14 @@ private:
ListBoxColorWrapper m_aColorWrapper;
Color m_aAutoDisplayColor;
Color m_aSaveColor;
- svx::NamedThemedColor m_aSelectedColor;
+ NamedColor m_aSelectedColor;
sal_uInt16 m_nSlotId;
bool m_bShowNoneButton;
std::shared_ptr<PaletteManager> m_xPaletteManager;
TopLevelParentFunction m_aTopLevelParentFunction;
ColorStatus m_aColorStatus;
- void Selected(const svx::NamedThemedColor& rNamedColor);
+ void Selected(const NamedColor& rNamedColor);
void createColorWindow();
void LockWidthRequest(int nWidthRequest);
int CalcBestWidthRequest();
@@ -63,8 +63,8 @@ public:
void SetSlotId(sal_uInt16 nSlotId, bool bShowNoneButton = false);
Color const& GetSelectEntryColor() const { return m_aSelectedColor.m_aColor; }
- NamedColor GetSelectedEntry() const { return m_aSelectedColor.ToNamedColor(); }
- const svx::NamedThemedColor& GetSelectedEntryThemedColor() const { return m_aSelectedColor; }
+ NamedColor GetSelectedEntry() const { return m_aSelectedColor; }
+ const NamedColor& GetSelectedEntryThemedColor() const { return m_aSelectedColor; }
void SelectEntry(const NamedColor& rColor);
void SelectEntry(const Color& rColor);
diff --git a/include/svx/tbcontrl.hxx b/include/svx/tbcontrl.hxx
index e40c06f3eb44..34e65d99492a 100644
--- a/include/svx/tbcontrl.hxx
+++ b/include/svx/tbcontrl.hxx
@@ -199,7 +199,7 @@ friend class SfxStyleControllerItem_Impl;
SfxStyleFamily GetActFamily() const;
};
-typedef std::function<void(const OUString&, const svx::NamedThemedColor&)> ColorSelectFunction;
+typedef std::function<void(const OUString&, const NamedColor&)> ColorSelectFunction;
class SVXCORE_DLLPUBLIC SvxColorToolBoxControl final : public cppu::ImplInheritanceHelper< svt::PopupWindowController,
css::frame::XSubToolbarController >
diff --git a/reportdesign/source/ui/dlg/Condition.cxx b/reportdesign/source/ui/dlg/Condition.cxx
index 9c78e3df79a0..c442e4ccfcd5 100644
--- a/reportdesign/source/ui/dlg/Condition.cxx
+++ b/reportdesign/source/ui/dlg/Condition.cxx
@@ -74,9 +74,9 @@ ConditionColorWrapper::ConditionColorWrapper(Condition* pControl, sal_uInt16 nSl
}
void ConditionColorWrapper::operator()(
- [[maybe_unused]] const OUString& /*rCommand*/, const svx::NamedThemedColor& rNamedColor)
+ [[maybe_unused]] const OUString& /*rCommand*/, const NamedColor& rNamedColor)
{
- mpControl->ApplyCommand(mnSlotId, rNamedColor.ToNamedColor());
+ mpControl->ApplyCommand(mnSlotId, rNamedColor);
}
// = Condition
diff --git a/reportdesign/source/ui/dlg/Condition.hxx b/reportdesign/source/ui/dlg/Condition.hxx
index 91bb52e5a231..a5e02d09bd6e 100644
--- a/reportdesign/source/ui/dlg/Condition.hxx
+++ b/reportdesign/source/ui/dlg/Condition.hxx
@@ -58,7 +58,7 @@ namespace rptui
{
public:
ConditionColorWrapper(Condition* pControl, sal_uInt16 nSlotId);
- void operator()(const OUString& rCommand, const svx::NamedThemedColor& rColor);
+ void operator()(const OUString& rCommand, const NamedColor& rColor);
// ColorSelectFunction signature
private:
Condition* mpControl;
diff --git a/svx/source/tbxctrls/Palette.cxx b/svx/source/tbxctrls/Palette.cxx
index 5c21062f7a6a..8c81eb53167e 100644
--- a/svx/source/tbxctrls/Palette.cxx
+++ b/svx/source/tbxctrls/Palette.cxx
@@ -377,17 +377,4 @@ Palette* PaletteSOC::Clone() const
return new PaletteSOC(*this);
}
-namespace svx
-{
-NamedColor NamedThemedColor::ToNamedColor() const { return { m_aColor, m_aName }; }
-
-NamedThemedColor NamedThemedColor::FromNamedColor(const NamedColor& rNamedColor)
-{
- NamedThemedColor aColor;
- aColor.m_aColor = rNamedColor.m_aColor;
- aColor.m_aName = rNamedColor.m_aName;
- return aColor;
-}
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx
index b2f845963404..26df330b9501 100644
--- a/svx/source/tbxctrls/PaletteManager.cxx
+++ b/svx/source/tbxctrls/PaletteManager.cxx
@@ -417,12 +417,12 @@ void PaletteManager::PopupColorPicker(weld::Window* pParent, const OUString& aCo
if (mpBtnUpdater)
mpBtnUpdater->Update(aNamedColor);
AddRecentColor(aLastColor, sColorName);
- maColorSelectFunction(aCommandCopy, svx::NamedThemedColor::FromNamedColor(aNamedColor));
+ maColorSelectFunction(aCommandCopy, aNamedColor);
}
});
}
-void PaletteManager::DispatchColorCommand(const OUString& aCommand, const svx::NamedThemedColor& rColor)
+void PaletteManager::DispatchColorCommand(const OUString& aCommand, const NamedColor& rColor)
{
using namespace css;
using namespace css::uno;
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 8c62bfc31939..96ee682fa460 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -2238,14 +2238,13 @@ IMPL_LINK(ColorWindow, SelectHdl, ValueSet*, pColorSet, void)
maMenuButton.set_inactive();
- auto aNamedThemedColor = svx::NamedThemedColor::FromNamedColor(aNamedColor);
if (bThemePaletteSelected)
{
- PaletteManager::GetThemeIndexLumModOff(nSelectedItemId, aNamedThemedColor.m_nThemeIndex,
- aNamedThemedColor.m_nLumMod,
- aNamedThemedColor.m_nLumOff);
+ PaletteManager::GetThemeIndexLumModOff(nSelectedItemId, aNamedColor.m_nThemeIndex,
+ aNamedColor.m_nLumMod,
+ aNamedColor.m_nLumOff);
}
- aColorSelectFunction(sCommand, aNamedThemedColor);
+ aColorSelectFunction(sCommand, aNamedColor);
}
IMPL_LINK_NOARG(ColorWindow, SelectPaletteHdl, weld::ComboBox&, void)
@@ -2278,7 +2277,7 @@ IMPL_LINK(ColorWindow, AutoColorClickHdl, weld::Button&, rButton, void)
maMenuButton.set_inactive();
- aColorSelectFunction(sCommand, svx::NamedThemedColor::FromNamedColor(aNamedColor));
+ aColorSelectFunction(sCommand, aNamedColor);
}
IMPL_LINK_NOARG(ColorWindow, OpenPickerClickHdl, weld::Button&, void)
@@ -4264,7 +4263,7 @@ ListBoxColorWrapper::ListBoxColorWrapper(ColorListBox* pControl)
}
void ListBoxColorWrapper::operator()(
- [[maybe_unused]] const OUString& /*rCommand*/, const svx::NamedThemedColor& rColor)
+ [[maybe_unused]] const OUString& /*rCommand*/, const NamedColor& rColor)
{
mpControl->Selected(rColor);
}
@@ -4284,8 +4283,8 @@ void ColorListBox::SetSlotId(sal_uInt16 nSlotId, bool bShowNoneButton)
m_bShowNoneButton = bShowNoneButton;
m_xButton->set_popover(nullptr);
m_xColorWindow.reset();
- m_aSelectedColor = svx::NamedThemedColor::FromNamedColor(bShowNoneButton ? GetNoneColor() : GetAutoColor(m_nSlotId));
- ShowPreview(m_aSelectedColor.ToNamedColor());
+ m_aSelectedColor = bShowNoneButton ? GetNoneColor() : GetAutoColor(m_nSlotId);
+ ShowPreview(m_aSelectedColor);
createColorWindow();
}
@@ -4300,7 +4299,7 @@ ColorListBox::ColorListBox(std::unique_ptr<weld::MenuButton> pControl,
, m_aTopLevelParentFunction(std::move(aTopLevelParentFunction))
{
m_xButton->connect_toggled(LINK(this, ColorListBox, ToggleHdl));
- m_aSelectedColor = svx::NamedThemedColor::FromNamedColor(GetAutoColor(m_nSlotId));
+ m_aSelectedColor = GetAutoColor(m_nSlotId);
if (!pCache)
LockWidthRequest(CalcBestWidthRequest());
else
@@ -4309,7 +4308,7 @@ ColorListBox::ColorListBox(std::unique_ptr<weld::MenuButton> pControl,
m_xPaletteManager.reset(pCache->m_xPaletteManager->Clone());
m_xPaletteManager->SetColorSelectFunction(std::ref(m_aColorWrapper));
}
- ShowPreview(m_aSelectedColor.ToNamedColor());
+ ShowPreview(m_aSelectedColor);
}
IMPL_LINK(ColorListBox, ToggleHdl, weld::Toggleable&, rButton, void)
@@ -4355,7 +4354,7 @@ void ColorListBox::createColorWindow()
m_xButton->set_popover(m_xColorWindow->getTopLevel());
if (m_bShowNoneButton)
m_xColorWindow->ShowNoneButton();
- m_xColorWindow->SelectEntry(m_aSelectedColor.ToNamedColor());
+ m_xColorWindow->SelectEntry(m_aSelectedColor);
}
void ColorListBox::SelectEntry(const NamedColor& rColor)
@@ -4367,21 +4366,21 @@ void ColorListBox::SelectEntry(const NamedColor& rColor)
}
ColorWindow* pColorWindow = getColorWindow();
pColorWindow->SelectEntry(rColor);
- m_aSelectedColor = svx::NamedThemedColor::FromNamedColor(pColorWindow->GetSelectEntryColor());
- ShowPreview(m_aSelectedColor.ToNamedColor());
+ m_aSelectedColor = pColorWindow->GetSelectEntryColor();
+ ShowPreview(m_aSelectedColor);
}
void ColorListBox::SelectEntry(const Color& rColor)
{
ColorWindow* pColorWindow = getColorWindow();
pColorWindow->SelectEntry(rColor);
- m_aSelectedColor = svx::NamedThemedColor::FromNamedColor(pColorWindow->GetSelectEntryColor());
- ShowPreview(m_aSelectedColor.ToNamedColor());
+ m_aSelectedColor = pColorWindow->GetSelectEntryColor();
+ ShowPreview(m_aSelectedColor);
}
-void ColorListBox::Selected(const svx::NamedThemedColor& rColor)
+void ColorListBox::Selected(const NamedColor& rColor)
{
- ShowPreview(rColor.ToNamedColor());
+ ShowPreview(rColor);
m_aSelectedColor = rColor;
if (m_aSelectedLink.IsSet())
m_aSelectedLink.Call(*this);