1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <svx/Palette.hxx>
22 #include <rtl/ustring.hxx>
23 #include <svx/xtable.hxx>
24 #include <svtools/colrdlg.hxx>
25 #include <svx/theme/ThemeColorPaletteManager.hxx>
31 namespace com::sun::star::uno
{ class XComponentContext
; }
32 namespace svx
{ class ToolboxButtonColorUpdaterBase
; }
33 namespace weld
{ class Window
; }
34 namespace model
{ class ColorSet
; }
36 class SVXCORE_DLLPUBLIC PaletteManager
38 const sal_uInt16 mnMaxRecentColors
;
40 sal_uInt16 mnNumOfPalettes
;
41 sal_uInt16 mnCurrentPalette
;
43 tools::Long mnColorCount
;
44 svx::ToolboxButtonColorUpdaterBase
* mpBtnUpdater
;
46 XColorListRef pColorList
;
47 std::deque
<NamedColor
> maRecentColors
;
48 std::vector
<std::unique_ptr
<Palette
>> m_Palettes
;
50 ColorSelectFunction maColorSelectFunction
;
52 std::unique_ptr
<SvColorDialog
> m_pColorDlg
;
53 std::optional
<svx::ThemePaletteCollection
> moThemePaletteCollection
;
55 PaletteManager(const PaletteManager
* pClone
);
59 PaletteManager(const PaletteManager
&) = delete;
60 PaletteManager
& operator=(const PaletteManager
&) = delete;
62 void ReloadColorSet(SvxColorValueSet
& rColorSet
);
63 void ReloadRecentColorSet(SvxColorValueSet
& rColorSet
);
64 std::vector
<OUString
> GetPaletteList();
65 void SetPalette( sal_Int32 nPos
);
66 sal_Int32
GetPalette() const;
67 sal_Int32
GetPaletteCount() const { return mnNumOfPalettes
; }
68 OUString
GetPaletteName();
69 OUString
GetSelectedPalettePath();
71 tools::Long
GetColorCount() const;
72 tools::Long
GetRecentColorCount() const;
73 void AddRecentColor(const Color
& rRecentColor
, const OUString
& rColorName
, bool bFront
= true);
74 void SetSplitButtonColor(const NamedColor
& rColor
);
76 void SetBtnUpdater(svx::ToolboxButtonColorUpdaterBase
* pBtnUpdater
);
77 void PopupColorPicker(weld::Window
* pParent
, const OUString
& aCommand
, const Color
& rInitialColor
);
79 void SetColorSelectFunction(const ColorSelectFunction
& aColorSelectFunction
);
81 bool IsThemePaletteSelected() const;
83 PaletteManager
* Clone() const;
85 static bool GetThemeAndEffectIndex(sal_uInt16 nItemId
, sal_uInt16
& rThemeIndex
, sal_uInt16
& rEffectIndex
);
86 bool GetLumModOff(sal_uInt16 nThemeIndex
, sal_uInt16 nEffect
, sal_Int16
& rLumMod
, sal_Int16
& rLumOff
);
88 static void DispatchColorCommand(const OUString
& aCommand
, const NamedColor
& rColor
);
91 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */