1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
20 #ifndef INCLUDED_SVTOOLS_CTRLTOOL_HXX
21 #define INCLUDED_SVTOOLS_CTRLTOOL_HXX
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>
33 class ImplFontListNameInfo
;
43 This class manages all fonts which can be display on one or two output devices.
44 Additionally, this class offers methods for generating the StyleName from
45 bold and italics or the missing attributes from a StyleName.
46 Furthermore, this class can handle synthetically reproduced fonts.
47 It also works with several standard controls and standard menus.
51 class FontNameBox, class FontStyleBox, class FontSizeBox,
52 class FontNameMenu, class FontSizeMenu
54 --------------------------------------------------------------------------
56 FontList::FontList( OutputDevice* pDevice, OutputDevice* pDevice2 = NULL,
59 Constructor of the FontList class. The relevant fonts will be queried from
60 the OutputDevice. The OutputDevice needs to exist as long as the FontList
61 class exists. Optionally, a second output device can be given in order to,
62 e.g., manage the fonts from both, a printer and a screen in a single FontList
63 and thus also give FontMenus the fonts if both OutputDevices.
64 The pDevice2 needs to exist as long as the FontList class exists.
66 The OutputDevice given first should be the preferred one. This is usually
67 the printer. Because if two different device fonts (one for the printer and
68 one for the screen) exist, the ones from the "pDevice" are preferred.
70 The third parameter governs whether only scalable or all fonts shall be queried.
71 With sal_True bitmap fonts will also be queried.
72 With sal_False vectorized and scalable fonts will be queried.
74 --------------------------------------------------------------------------
76 String FontList::GetStyleName( const FontMetric& rFontMetric ) const;
78 This method returns the StyleName of a FontMetric.
79 If no StyleName is set, a name will be generated from the set attributes.
81 --------------------------------------------------------------------------
83 OUString FontList::GetFontMapText( const FontMetric& rFontMetric ) const;
85 This method returns a Matchstring which indicates the problem that could
86 arise when using a font. This string should be displayed to the user.
88 --------------------------------------------------------------------------
90 FontMetric FontList::Get( const String& rName, const String& rStyleName ) const;
92 This method search a FontMetric for the given name and the given style name.
93 The Stylename can also be a synthetic one.
94 In that case the relevant FontMetric fields will be set.
95 If a StyleName is provided, a FontMetric structure without a Stylename can be
96 returned. To get a representation of the StyleName for displaying it to the user,
97 call GetStyleName() on this FontMetric structure.
101 FontList::GetStyleName()
103 --------------------------------------------------------------------------
105 FontMetric FontList::Get( const String& rName, FontWeight eWeight,
106 FontItalic eItalic ) const;
108 This method search a FontMetric structure for a provided name and styles.
109 This method can also return a FontMetric without a Stylename.
110 To get a representation of the StyleName to be presented to the user
111 call GetStyleName() with this FontMetric.
115 FontList::GetStyleName()
117 --------------------------------------------------------------------------
119 const sal_IntPtr* FontList::GetSizeAry( const FontMetric& rFontMetric ) const;
121 This method returns the available sizes for the given font.
122 If it is a scalable font, standard sizes are returned.
123 The array contains the heights of the font in tenth (1/10) point.
124 The last value of the array is 0.
125 The returned array will destroyed by the FontList.
126 You should thus not reference the array after the next method call on the
130 class SVT_DLLPUBLIC FontList
133 static const sal_IntPtr aStdSizeAry
[];
136 OUString maMapPrinterOnly
;
137 OUString maMapStyleNotAvailable
;
138 mutable OUString maMapNotAvailable
;
140 OUString maLightItalic
;
142 OUString maNormalItalic
;
144 OUString maBoldItalic
;
146 OUString maBlackItalic
;
147 mutable std::unique_ptr
<sal_IntPtr
[]>
149 VclPtr
<OutputDevice
> mpDev
;
150 VclPtr
<OutputDevice
> mpDev2
;
151 std::vector
<std::unique_ptr
<ImplFontListNameInfo
>> m_Entries
;
153 SVT_DLLPRIVATE ImplFontListNameInfo
* ImplFind( const OUString
& rSearchName
, sal_uInt32
* pIndex
) const;
154 SVT_DLLPRIVATE ImplFontListNameInfo
* ImplFindByName( const OUString
& rStr
) const;
155 SVT_DLLPRIVATE
void ImplInsertFonts(OutputDevice
* pDev
, bool bInsertData
);
158 FontList( OutputDevice
* pDevice
,
159 OutputDevice
* pDevice2
= nullptr);
162 std::unique_ptr
<FontList
> Clone() const;
164 OUString
GetFontMapText( const FontMetric
& rFontMetric
) const;
166 const OUString
& GetNormalStr() const { return maNormal
; }
167 const OUString
& GetItalicStr() const { return maNormalItalic
; }
168 const OUString
& GetBoldStr() const { return maBold
; }
169 const OUString
& GetBoldItalicStr() const { return maBoldItalic
; }
170 const OUString
& GetStyleName( FontWeight eWeight
, FontItalic eItalic
) const;
171 OUString
GetStyleName( const FontMetric
& rFontMetric
) const;
173 FontMetric
Get( const OUString
& rName
,
174 const OUString
& rStyleName
) const;
175 FontMetric
Get( const OUString
& rName
,
177 FontItalic eItalic
) const;
179 bool IsAvailable( const OUString
& rName
) const;
180 size_t GetFontNameCount() const
182 return m_Entries
.size();
184 const FontMetric
& GetFontName(size_t nFont
) const;
185 sal_Handle
GetFirstFontMetric( const OUString
& rName
) const;
186 static sal_Handle
GetNextFontMetric( sal_Handle hFontMetric
);
187 static const FontMetric
& GetFontMetric( sal_Handle hFontMetric
);
189 const sal_IntPtr
* GetSizeAry( const FontMetric
& rFontMetric
) const;
190 static const sal_IntPtr
* GetStdSizeAry() { return aStdSizeAry
; }
193 FontList( const FontList
& ) = delete;
194 FontList
& operator =( const FontList
& ) = delete;
197 class SVT_DLLPUBLIC FontSizeNames
200 const struct ImplFSNameItem
* mpArray
;
204 FontSizeNames( LanguageType eLanguage
/* = LANGUAGE_DONTKNOW */ );
206 sal_Int32
Count() const { return mnElem
; }
207 bool IsEmpty() const { return !mnElem
; }
209 sal_Int32
Name2Size( const OUString
& ) const;
210 OUString
Size2Name( sal_Int32
) const;
212 OUString
GetIndexName( sal_Int32 nIndex
) const;
213 sal_Int32
GetIndexSize( sal_Int32 nIndex
) const;
216 #endif // INCLUDED_SVTOOLS_CTRLTOOL_HXX
218 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */