/src/libreoffice/include/svtools/ctrltool.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 | | |
20 | | #pragma once |
21 | | |
22 | | #include <config_options.h> |
23 | | #include <i18nlangtag/lang.h> |
24 | | #include <svtools/svtdllapi.h> |
25 | | #include <tools/fontenum.hxx> |
26 | | #include <rtl/ustring.hxx> |
27 | | #include <sal/types.h> |
28 | | #include <vcl/vclptr.hxx> |
29 | | |
30 | | #include <vector> |
31 | | #include <memory> |
32 | | #include <string_view> |
33 | | |
34 | | class FontMetric; |
35 | | class ImplFontListNameInfo; |
36 | | class OutputDevice; |
37 | | |
38 | | /* |
39 | | |
40 | | Description |
41 | | ============ |
42 | | |
43 | | class FontList |
44 | | |
45 | | This class manages all fonts which can be display on one or two output devices. |
46 | | Additionally, this class offers methods for generating the StyleName from |
47 | | bold and italics or the missing attributes from a StyleName. |
48 | | Furthermore, this class can handle synthetically reproduced fonts. |
49 | | It also works with several standard controls and standard menus. |
50 | | |
51 | | Links: |
52 | | |
53 | | class FontNameBox, class FontStyleBox, class FontSizeBox, |
54 | | class FontNameMenu, class FontSizeMenu |
55 | | |
56 | | -------------------------------------------------------------------------- |
57 | | |
58 | | FontList::FontList( OutputDevice* pDevice, OutputDevice* pDevice2 = NULL, |
59 | | bool bAll = true ); |
60 | | |
61 | | Constructor of the FontList class. The relevant fonts will be queried from |
62 | | the OutputDevice. The OutputDevice needs to exist as long as the FontList |
63 | | class exists. Optionally, a second output device can be given in order to, |
64 | | e.g., manage the fonts from both, a printer and a screen in a single FontList |
65 | | and thus also give FontMenus the fonts if both OutputDevices. |
66 | | The pDevice2 needs to exist as long as the FontList class exists. |
67 | | |
68 | | The OutputDevice given first should be the preferred one. This is usually |
69 | | the printer. Because if two different device fonts (one for the printer and |
70 | | one for the screen) exist, the ones from the "pDevice" are preferred. |
71 | | |
72 | | The third parameter governs whether only scalable or all fonts shall be queried. |
73 | | With sal_True bitmap fonts will also be queried. |
74 | | With sal_False vectorized and scalable fonts will be queried. |
75 | | |
76 | | -------------------------------------------------------------------------- |
77 | | |
78 | | String FontList::GetStyleName( const FontMetric& rFontMetric ) const; |
79 | | |
80 | | This method returns the StyleName of a FontMetric. |
81 | | If no StyleName is set, a name will be generated from the set attributes. |
82 | | |
83 | | -------------------------------------------------------------------------- |
84 | | |
85 | | OUString FontList::GetFontMapText( const FontMetric& rFontMetric ) const; |
86 | | |
87 | | This method returns a Matchstring which indicates the problem that could |
88 | | arise when using a font. This string should be displayed to the user. |
89 | | |
90 | | -------------------------------------------------------------------------- |
91 | | |
92 | | FontMetric FontList::Get( const String& rName, const String& rStyleName ) const; |
93 | | |
94 | | This method search a FontMetric for the given name and the given style name. |
95 | | The Stylename can also be a synthetic one. |
96 | | In that case the relevant FontMetric fields will be set. |
97 | | If a StyleName is provided, a FontMetric structure without a Stylename can be |
98 | | returned. To get a representation of the StyleName for displaying it to the user, |
99 | | call GetStyleName() on this FontMetric structure. |
100 | | |
101 | | Links: |
102 | | |
103 | | FontList::GetStyleName() |
104 | | |
105 | | -------------------------------------------------------------------------- |
106 | | |
107 | | FontMetric FontList::Get( const String& rName, FontWeight eWeight, |
108 | | FontItalic eItalic ) const; |
109 | | |
110 | | This method search a FontMetric structure for a provided name and styles. |
111 | | This method can also return a FontMetric without a Stylename. |
112 | | To get a representation of the StyleName to be presented to the user |
113 | | call GetStyleName() with this FontMetric. |
114 | | |
115 | | Links: |
116 | | |
117 | | FontList::GetStyleName() |
118 | | |
119 | | -------------------------------------------------------------------------- |
120 | | |
121 | | static const int* FontList::GetStdSizeAry(); |
122 | | |
123 | | This method returns the available sizes for the given font. |
124 | | As all fonts are scalable, standard sizes are returned. |
125 | | The array contains the heights of the font in tenth (1/10) point. |
126 | | The last value of the array is 0. |
127 | | The returned array will destroyed by the FontList. |
128 | | You should thus not reference the array after the next method call on the |
129 | | FontList. |
130 | | */ |
131 | | |
132 | | class SVT_DLLPUBLIC FontList |
133 | | { |
134 | | private: |
135 | | static const int aStdSizeAry[]; |
136 | | |
137 | | OUString maMapBoth; |
138 | | OUString maMapPrinterOnly; |
139 | | OUString maMapStyleNotAvailable; |
140 | | mutable OUString maMapNotAvailable; |
141 | | OUString maLight; |
142 | | OUString maLightItalic; |
143 | | OUString maNormal; |
144 | | OUString maNormalItalic; |
145 | | OUString maBold; |
146 | | OUString maBoldItalic; |
147 | | OUString maBlack; |
148 | | OUString maBlackItalic; |
149 | | VclPtr<OutputDevice> mpDev; |
150 | | VclPtr<OutputDevice> mpDev2; |
151 | | std::vector<std::unique_ptr<ImplFontListNameInfo>> m_Entries; |
152 | | std::unordered_map<OUString, OUString> maAliases; |
153 | | |
154 | | SVT_DLLPRIVATE ImplFontListNameInfo* ImplFind( std::u16string_view rSearchName, sal_uInt32* pIndex ) const; |
155 | | SVT_DLLPRIVATE ImplFontListNameInfo* ImplFindByName( std::u16string_view rStr ) const; |
156 | | SVT_DLLPRIVATE void ImplInsertFonts(OutputDevice* pDev, bool bInsertData); |
157 | | |
158 | | public: |
159 | | FontList( OutputDevice* pDevice, |
160 | | OutputDevice* pDevice2 = nullptr); |
161 | | ~FontList(); |
162 | | |
163 | | std::unique_ptr<FontList> Clone() const; |
164 | | |
165 | | const OUString & GetFontMapText( const FontMetric& rFontMetric ) const; |
166 | | |
167 | 0 | const OUString& GetNormalStr() const { return maNormal; } |
168 | 0 | const OUString& GetItalicStr() const { return maNormalItalic; } |
169 | 0 | const OUString& GetBoldStr() const { return maBold; } |
170 | 0 | const OUString& GetBoldItalicStr() const { return maBoldItalic; } |
171 | | const OUString& GetStyleName( FontWeight eWeight, FontItalic eItalic ) const; |
172 | | OUString GetStyleName( const FontMetric& rFontMetric ) const; |
173 | | |
174 | | FontMetric Get( const OUString& rName, |
175 | | const OUString& rStyleName ) const; |
176 | | FontMetric Get( const OUString& rName, |
177 | | FontWeight eWeight, |
178 | | FontItalic eItalic ) const; |
179 | | |
180 | | bool IsAvailable( std::u16string_view rName ) const; |
181 | | size_t GetFontNameCount() const |
182 | 192k | { |
183 | 192k | return m_Entries.size(); |
184 | 192k | } |
185 | | const FontMetric& GetFontName(size_t nFont) const; |
186 | | sal_Handle GetFirstFontMetric( std::u16string_view rName ) const; |
187 | | static sal_Handle GetNextFontMetric( sal_Handle hFontMetric ); |
188 | | static const FontMetric& GetFontMetric( sal_Handle hFontMetric ); |
189 | | |
190 | 0 | static const int* GetStdSizeAry() { return aStdSizeAry; } |
191 | | |
192 | | private: |
193 | | FontList( const FontList& ) = delete; |
194 | | FontList& operator =( const FontList& ) = delete; |
195 | | }; |
196 | | |
197 | | class UNLESS_MERGELIBS(SVT_DLLPUBLIC) FontSizeNames |
198 | | { |
199 | | private: |
200 | | const struct ImplFSNameItem* mpArray; |
201 | | sal_Int32 mnElem; |
202 | | |
203 | | public: |
204 | | FontSizeNames( LanguageType eLanguage /* = LANGUAGE_DONTKNOW */ ); |
205 | | |
206 | 0 | sal_Int32 Count() const { return mnElem; } |
207 | 0 | bool IsEmpty() const { return !mnElem; } |
208 | | |
209 | | sal_Int32 Name2Size( std::u16string_view ) const; |
210 | | OUString Size2Name( sal_Int32 ) const; |
211 | | |
212 | | OUString GetIndexName( sal_Int32 nIndex ) const; |
213 | | sal_Int32 GetIndexSize( sal_Int32 nIndex ) const; |
214 | | }; |
215 | | |
216 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |