nss: upgrade to release 3.73
[LibreOffice.git] / include / cui / cuicharmap.hxx
blob11e464912a8d007e785229f4fe6d589eb85e2b6c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
19 #ifndef INCLUDED_CUI_CUICHARMAP_HXX
20 #define INCLUDED_CUI_CUICHARMAP_HXX
22 #include <vcl/customweld.hxx>
23 #include <vcl/weld.hxx>
24 #include <vcl/virdev.hxx>
25 #include <sfx2/basedlgs.hxx>
26 #include <svl/itemset.hxx>
27 #include <svx/charmap.hxx>
28 #include <svx/searchcharmap.hxx>
29 #include <svx/ucsubset.hxx>
30 #include <sfx2/charwin.hxx>
31 #include <cui/cuidllapi.h>
32 #include <com/sun/star/frame/XFrame.hpp>
34 #include <deque>
35 #include <memory>
36 #include <utility>
38 using namespace ::com::sun::star;
39 class SubsetMap;
41 #define CHARMAP_MAXLEN 32
43 namespace svx
45 struct SvxShowCharSetItem;
48 /// Provides the show characters or texts in a drawing area with special sizes and fonts.
49 class CUI_DLLPUBLIC SvxShowText final : public weld::CustomWidgetController
51 private:
52 ScopedVclPtr<VirtualDevice> m_xVirDev;
53 OUString m_sText;
54 tools::Long mnY;
55 bool mbCenter;
56 vcl::Font m_aFont;
58 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override;
59 virtual void Resize() override;
60 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
62 public:
63 SvxShowText(const VclPtr<VirtualDevice>& rVirDev);
65 void SetFont(const vcl::Font& rFont);
66 vcl::Font const& GetFont() const { return m_aFont; }
67 void SetText(const OUString& rText);
68 OUString const& GetText() const { return m_sText; }
69 void SetCentered(bool bCenter) { mbCenter = bCenter; }
71 Size get_preferred_size() const { return GetDrawingArea()->get_preferred_size(); }
74 /** The main purpose of this dialog is to enable the use of characters
75 that are not easily accessible from the keyboard. */
76 class CUI_DLLPUBLIC SvxCharacterMap final : public SfxDialogController
78 private:
79 void init();
81 ScopedVclPtr<VirtualDevice> m_xVirDev;
82 vcl::Font aFont;
83 std::unique_ptr<const SubsetMap> pSubsetMap;
84 bool isSearchMode;
85 css::uno::Reference<css::frame::XFrame> m_xFrame;
86 std::deque<OUString> maRecentCharList;
87 std::deque<OUString> maRecentCharFontList;
88 std::deque<OUString> maFavCharList;
89 std::deque<OUString> maFavCharFontList;
90 uno::Reference<uno::XComponentContext> mxContext;
92 SvxCharView m_aRecentCharView[16];
93 SvxCharView m_aFavCharView[16];
94 SvxShowText m_aShowChar;
96 std::unique_ptr<weld::Button> m_xOKBtn;
97 std::unique_ptr<weld::Label> m_xFontText;
98 std::unique_ptr<weld::ComboBox> m_xFontLB;
99 std::unique_ptr<weld::Label> m_xSubsetText;
100 std::unique_ptr<weld::ComboBox> m_xSubsetLB;
101 std::unique_ptr<weld::Entry> m_xSearchText;
102 std::unique_ptr<weld::Entry> m_xHexCodeText;
103 std::unique_ptr<weld::Entry> m_xDecimalCodeText;
104 std::unique_ptr<weld::Button> m_xFavouritesBtn;
105 std::unique_ptr<weld::Label> m_xCharName;
106 std::unique_ptr<weld::Widget> m_xRecentGrid;
107 std::unique_ptr<weld::Widget> m_xFavGrid;
108 std::unique_ptr<weld::CustomWeld> m_xShowChar;
109 std::unique_ptr<weld::CustomWeld> m_xRecentCharView[16];
110 std::unique_ptr<weld::CustomWeld> m_xFavCharView[16];
111 std::unique_ptr<SvxShowCharSet> m_xShowSet;
112 std::unique_ptr<weld::CustomWeld> m_xShowSetArea;
113 std::unique_ptr<SvxSearchCharSet> m_xSearchSet;
114 std::unique_ptr<weld::CustomWeld> m_xSearchSetArea;
116 std::unique_ptr<SfxAllItemSet> m_xOutputSet;
118 enum class Radix : sal_Int16
120 decimal = 10,
121 hexadecimal = 16
124 DECL_LINK(FontSelectHdl, weld::ComboBox&, void);
125 DECL_LINK(SubsetSelectHdl, weld::ComboBox&, void);
126 DECL_LINK(CharDoubleClickHdl, SvxShowCharSet*, void);
127 DECL_LINK(CharSelectHdl, SvxShowCharSet*, void);
128 DECL_LINK(CharHighlightHdl, SvxShowCharSet*, void);
129 DECL_LINK(CharPreSelectHdl, SvxShowCharSet*, void);
130 DECL_LINK(FavClickHdl, SvxShowCharSet*, void);
131 DECL_LINK(SearchCharDoubleClickHdl, SvxShowCharSet*, void);
132 DECL_LINK(SearchCharSelectHdl, SvxShowCharSet*, void);
133 DECL_LINK(SearchCharHighlightHdl, SvxShowCharSet*, void);
134 DECL_LINK(SearchCharPreSelectHdl, SvxShowCharSet*, void);
135 DECL_LINK(DecimalCodeChangeHdl, weld::Entry&, void);
136 DECL_LINK(HexCodeChangeHdl, weld::Entry&, void);
137 DECL_LINK(CharClickHdl, SvxCharView*, void);
138 DECL_LINK(RecentClearClickHdl, SvxCharView*, void);
139 DECL_LINK(FavClearClickHdl, SvxCharView*, void);
140 DECL_LINK(RecentClearAllClickHdl, SvxCharView*, void);
141 DECL_LINK(FavClearAllClickHdl, SvxCharView*, void);
142 DECL_LINK(InsertClickHdl, weld::Button&, void);
143 DECL_LINK(FavSelectHdl, weld::Button&, void);
144 DECL_LINK(SearchUpdateHdl, weld::Entry&, void);
145 DECL_LINK(SearchFieldGetFocusHdl, weld::Widget&, void);
147 static void fillAllSubsets(weld::ComboBox& rListBox);
148 void selectCharByCode(Radix radix);
150 public:
151 SvxCharacterMap(weld::Widget* pParent, const SfxItemSet* pSet,
152 const css::uno::Reference<css::frame::XFrame>& rFrame);
153 virtual short run() override;
155 void set_title(const OUString& rTitle) { m_xDialog->set_title(rTitle); }
157 const SfxItemSet* GetOutputItemSet() const { return m_xOutputSet.get(); }
159 void DisableFontSelection();
161 const vcl::Font& GetCharFont() const { return aFont; }
162 void SetCharFont(const vcl::Font& rFont);
164 void SetChar(sal_UCS4);
165 sal_UCS4 GetChar() const;
167 void getRecentCharacterList(); //gets both recent char and recent char font list
168 void updateRecentCharacterList(const OUString& rChar, const OUString& rFont);
170 void getFavCharacterList(); //gets both Fav char and Fav char font list
171 void updateFavCharacterList(const OUString& rChar, const OUString& rFont);
172 void deleteFavCharacterFromList(std::u16string_view rChar, std::u16string_view rFont);
173 bool isFavChar(std::u16string_view sTitle, std::u16string_view rFont);
175 void updateRecentCharControl();
176 void insertCharToDoc(const OUString& sChar);
178 void updateFavCharControl();
179 void setFavButtonState(std::u16string_view sTitle, std::u16string_view rFont);
181 void setCharName(sal_UCS4 nDecimalValue);
183 void toggleSearchView(bool state);
185 private:
186 std::pair<std::deque<OUString>::const_iterator, std::deque<OUString>::const_iterator>
187 getRecentChar(std::u16string_view sTitle, std::u16string_view rFont) const;
189 std::pair<std::deque<OUString>::const_iterator, std::deque<OUString>::const_iterator>
190 getFavChar(std::u16string_view sTitle, std::u16string_view rFont) const;
193 #endif
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */