Coverage Report

Created: 2026-09-28 10:59

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/svx/PaletteManager.hxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
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/.
8
 *
9
 * This file incorporates work covered by the following license notice:
10
 *
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 .
18
 */
19
#pragma once
20
21
#include <svx/Palette.hxx>
22
#include <rtl/ustring.hxx>
23
#include <svx/IColorSet.hxx>
24
#include <svx/xtable.hxx>
25
#include <svx/theme/ThemeColorPaletteManager.hxx>
26
#include <vcl/ColorDialog.hxx>
27
28
#include <deque>
29
#include <vector>
30
#include <memory>
31
#include <set>
32
33
namespace svx { class ToolboxButtonColorUpdaterBase; }
34
namespace weld { class Window; }
35
namespace tools { class JsonWriter; }
36
37
class SVXCORE_DLLPUBLIC PaletteManager : public std::enable_shared_from_this<PaletteManager>
38
{
39
    const sal_uInt16        mnMaxRecentColors;
40
41
    sal_uInt16              mnNumOfPalettes;
42
    sal_uInt16              mnCurrentPalette;
43
44
    tools::Long                    mnColorCount;
45
    svx::ToolboxButtonColorUpdaterBase* mpBtnUpdater;
46
47
    XColorListRef           mpColorList;
48
    std::deque<NamedColor>  maRecentColors;
49
    std::vector<std::unique_ptr<Palette>> m_Palettes;
50
51
    ColorSelectFunction maColorSelectFunction;
52
53
    std::unique_ptr<ColorDialog> m_pColorDlg;
54
    std::optional<svx::ThemePaletteCollection> moThemePaletteCollection;
55
56
public:
57
    PaletteManager();
58
    ~PaletteManager();
59
    PaletteManager(const PaletteManager&) = delete;
60
    PaletteManager& operator=(const PaletteManager&) = delete;
61
    void        LoadPalettes();
62
    void ReloadColorSet(IColorSet& rColorSet);
63
    void ReloadRecentColorSet(IColorSet& rColorSet);
64
    std::vector<OUString> GetPaletteList();
65
    void SetPalette(sal_Int32 nPos, bool bPosOnly = false);
66
    sal_Int32   GetPalette() const;
67
0
    sal_Int32   GetPaletteCount() const { return mnNumOfPalettes; }
68
    OUString    GetPaletteName();
69
    const OUString & GetSelectedPalettePath();
70
71
    void        AddRecentColor(const Color& rRecentColor, const OUString& rColorName, bool bFront = true);
72
    void        SetSplitButtonColor(const NamedColor& rColor);
73
74
    void        SetBtnUpdater(svx::ToolboxButtonColorUpdaterBase* pBtnUpdater);
75
    void        PopupColorPicker(weld::Window* pParent, const OUString& aCommand, const Color& rInitialColor);
76
77
    void        SetColorSelectFunction(const ColorSelectFunction& aColorSelectFunction);
78
79
    bool IsThemePaletteSelected() const;
80
81
    static bool GetThemeAndEffectIndex(sal_uInt16 nItemIndex, sal_uInt16& rThemeIndex, sal_uInt16& rEffectIndex);
82
    bool GetLumModOff(sal_uInt16 nThemeIndex, sal_uInt16 nEffect, sal_Int16& rLumMod, sal_Int16& rLumOff);
83
84
    static void DispatchColorCommand(const OUString& aCommand, const NamedColor& rColor);
85
};
86
87
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */