LibreOffice Module cui (master)  1
cuicharmap.hxx
Go to the documentation of this file.
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_CUI_CUICHARMAP_HXX
20 #define INCLUDED_CUI_CUICHARMAP_HXX
21 
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>
33 
34 #include <deque>
35 #include <memory>
36 #include <utility>
37 
38 using namespace ::com::sun::star;
39 class SubsetMap;
40 
41 #define CHARMAP_MAXLEN 32
42 
43 namespace svx
44 {
45 struct SvxShowCharSetItem;
46 }
47 
50 {
51 private:
53  OUString m_sText;
55  bool mbCenter;
57 
58  virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override;
59  virtual void Resize() override;
60  virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
61 
62 public:
63  SvxShowText(const VclPtr<VirtualDevice>& rVirDev);
64 
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; }
70 
72 };
73 
77 {
78 private:
79  void init();
80 
83  std::unique_ptr<const SubsetMap> pSubsetMap;
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;
91 
92  SvxCharView m_aRecentCharView[16];
93  SvxCharView m_aFavCharView[16];
95 
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;
115 
116  std::unique_ptr<SfxAllItemSet> m_xOutputSet;
117 
118  enum class Radix : sal_Int16
119  {
120  decimal = 10,
121  hexadecimal = 16
122  };
123 
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);
146 
147  static void fillAllSubsets(weld::ComboBox& rListBox);
148  void selectCharByCode(Radix radix);
149 
150 public:
151  SvxCharacterMap(weld::Widget* pParent, const SfxItemSet* pSet,
152  const css::uno::Reference<css::frame::XFrame>& rFrame);
153  virtual short run() override;
154 
155  void set_title(const OUString& rTitle) { m_xDialog->set_title(rTitle); }
156 
157  const SfxItemSet* GetOutputItemSet() const { return m_xOutputSet.get(); }
158 
159  void DisableFontSelection();
160 
161  const vcl::Font& GetCharFont() const { return aFont; }
162  void SetCharFont(const vcl::Font& rFont);
163 
164  void SetChar(sal_UCS4);
165  sal_UCS4 GetChar() const;
166 
167  void getRecentCharacterList(); //gets both recent char and recent char font list
168  void updateRecentCharacterList(const OUString& rChar, const OUString& rFont);
169 
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);
174 
175  void updateRecentCharControl();
176  void insertCharToDoc(const OUString& sChar);
177 
178  void updateFavCharControl();
179  void setFavButtonState(std::u16string_view sTitle, std::u16string_view rFont);
180 
181  void setCharName(sal_UCS4 nDecimalValue);
182 
183  void toggleSearchView(bool state);
184 
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;
188 
189  std::pair<std::deque<OUString>::const_iterator, std::deque<OUString>::const_iterator>
190  getFavChar(std::u16string_view sTitle, std::u16string_view rFont) const;
191 };
192 
193 #endif
194 
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SvxShowText m_aShowChar
Definition: cuicharmap.hxx:94
ScopedVclPtr< VirtualDevice > m_xVirDev
Definition: cuicharmap.hxx:52
std::unique_ptr< const SubsetMap > pSubsetMap
Definition: cuicharmap.hxx:83
std::unique_ptr< weld::CustomWeld > m_xShowChar
Definition: cuicharmap.hxx:108
tools::Long mnY
Definition: cuicharmap.hxx:54
sal_uInt32 sal_UCS4
std::unique_ptr< weld::Widget > m_xFavGrid
Definition: cuicharmap.hxx:107
long Long
std::unique_ptr< SvxSearchCharSet > m_xSearchSet
Definition: cuicharmap.hxx:113
std::deque< OUString > maRecentCharList
Definition: cuicharmap.hxx:86
const vcl::Font & GetCharFont() const
Definition: cuicharmap.hxx:161
OUString const & GetText() const
Definition: cuicharmap.hxx:68
ScopedVclPtr< VirtualDevice > m_xVirDev
Definition: cuicharmap.hxx:81
Provides the show characters or texts in a drawing area with special sizes and fonts.
Definition: cuicharmap.hxx:49
std::unique_ptr< SfxAllItemSet > m_xOutputSet
Definition: cuicharmap.hxx:116
OUString m_sText
Definition: cuicharmap.hxx:53
std::unique_ptr< weld::Widget > m_xRecentGrid
Definition: cuicharmap.hxx:106
std::unique_ptr< weld::Label > m_xFontText
Definition: cuicharmap.hxx:97
std::unique_ptr< weld::ComboBox > m_xSubsetLB
Definition: cuicharmap.hxx:100
std::deque< OUString > maFavCharList
Definition: cuicharmap.hxx:88
def run
std::unique_ptr< weld::Entry > m_xDecimalCodeText
Definition: cuicharmap.hxx:103
uno::Reference< uno::XComponentContext > mxContext
Definition: cuicharmap.hxx:90
css::uno::Reference< css::frame::XFrame > m_xFrame
Definition: cuicharmap.hxx:85
std::unique_ptr< SvxShowCharSet > m_xShowSet
Definition: cuicharmap.hxx:111
std::unique_ptr< weld::Button > m_xFavouritesBtn
Definition: cuicharmap.hxx:104
vcl::Font m_aFont
Definition: cuicharmap.hxx:56
std::unique_ptr< weld::Entry > m_xHexCodeText
Definition: cuicharmap.hxx:102
const SfxItemSet * GetOutputItemSet() const
Definition: cuicharmap.hxx:157
std::unique_ptr< weld::CustomWeld > m_xSearchSetArea
Definition: cuicharmap.hxx:114
#define CUI_DLLPUBLIC
Definition: cuidllapi.h:18
std::unique_ptr< weld::Entry > m_xSearchText
Definition: cuicharmap.hxx:101
vcl::Font aFont
Definition: cuicharmap.hxx:82
virtual Size get_preferred_size() const =0
void set_title(const OUString &rTitle)
Definition: cuicharmap.hxx:155
std::deque< OUString > maFavCharFontList
Definition: cuicharmap.hxx:89
weld::DrawingArea * GetDrawingArea() const
std::deque< OUString > maRecentCharFontList
Definition: cuicharmap.hxx:87
std::unique_ptr< weld::CustomWeld > m_xShowSetArea
Definition: cuicharmap.hxx:112
Reference< XExecutableDialog > m_xDialog
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea)
FILE * init(int, char **)
Size get_preferred_size() const
Definition: cuicharmap.hxx:71
std::unique_ptr< weld::ComboBox > m_xFontLB
Definition: cuicharmap.hxx:98
void SetCentered(bool bCenter)
Definition: cuicharmap.hxx:69
vcl::Font const & GetFont() const
Definition: cuicharmap.hxx:66
The main purpose of this dialog is to enable the use of characters that are not easily accessible fro...
Definition: cuicharmap.hxx:76
std::unique_ptr< weld::Button > m_xOKBtn
Definition: cuicharmap.hxx:96
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)=0
std::unique_ptr< weld::Label > m_xSubsetText
Definition: cuicharmap.hxx:99
std::unique_ptr< weld::Label > m_xCharName
Definition: cuicharmap.hxx:105