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