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 #ifndef INCLUDED_SVX_PALETTEMANAGER_HXX 20 #define INCLUDED_SVX_PALETTEMANAGER_HXX 21 22 #include <svx/Palette.hxx> 23 #include <rtl/ustring.hxx> 24 #include <svx/xtable.hxx> 25 26 #include <deque> 27 #include <vector> 28 #include <memory> 29 30 class SvxColorValueSet; 31 namespace com::sun::star::uno { class XComponentContext; } 32 namespace svx { class ToolboxButtonColorUpdater; } 33 namespace weld { class Window; } 34 35 class SVX_DLLPUBLIC PaletteManager 36 { 37 const sal_uInt16 mnMaxRecentColors; 38 39 sal_uInt16 mnNumOfPalettes; 40 sal_uInt16 mnCurrentPalette; 41 42 long mnColorCount; 43 svx::ToolboxButtonColorUpdater* mpBtnUpdater; 44 45 XColorListRef pColorList; 46 std::deque<NamedColor> maRecentColors; 47 std::vector<std::unique_ptr<Palette>> m_Palettes; 48 49 std::function<void(const OUString&, const NamedColor&)> maColorSelectFunction; 50 css::uno::Reference < css::uno::XComponentContext > m_context; 51 public: 52 PaletteManager(); 53 ~PaletteManager(); 54 PaletteManager(const PaletteManager&) = delete; 55 PaletteManager& operator=(const PaletteManager&) = delete; 56 void LoadPalettes(); 57 void ReloadColorSet(SvxColorValueSet& rColorSet); 58 void ReloadColorSet(ColorValueSet& rColorSet); 59 void ReloadRecentColorSet(SvxColorValueSet& rColorSet); 60 void ReloadRecentColorSet(ColorValueSet& rColorSet); 61 std::vector<OUString> GetPaletteList(); 62 void SetPalette( sal_Int32 nPos ); 63 sal_Int32 GetPalette() const; GetPaletteCount() const64 sal_Int32 GetPaletteCount() const { return mnNumOfPalettes; } 65 OUString GetPaletteName(); 66 OUString GetSelectedPalettePath(); 67 68 long GetColorCount() const; 69 long GetRecentColorCount() const; 70 void AddRecentColor(const Color& rRecentColor, const OUString& rColorName, bool bFront = true); 71 72 void SetBtnUpdater(svx::ToolboxButtonColorUpdater* pBtnUpdater); 73 void PopupColorPicker(weld::Window* pParent, const OUString& aCommand, const Color& rInitialColor); 74 75 void SetColorSelectFunction(const std::function<void(const OUString&, const NamedColor&)>& aColorSelectFunction); 76 77 static void DispatchColorCommand(const OUString& aCommand, const NamedColor& rColor); 78 }; 79 80 #endif // INCLUDED_SVX_PALETTEMANAGER_HXX 81 82 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 83