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 <boost/ptr_container/ptr_vector.hpp>
25 #include <svtools/svtdllapi.h>
26 #include <rtl/ustring.hxx>
27 #include <sal/types.h>
28 #include <vcl/metric.hxx>
29 #include <tools/solar.h>
31 class ImplFontListNameInfo
;
41 This class manages all fonts which can be display on one or two output devices.
42 Additionally, this class offers methods for generating the StyleName from
43 bold and italics or the missing attributes from a StyleName.
44 Furthermore, this class can handle synthetically reproduced fonts.
45 It also works with several standard controls and standard menus.
49 class FontNameBox, class FontStyleBox, class FontSizeBox,
50 class FontNameMenu, class FontSizeMenu
52 --------------------------------------------------------------------------
54 FontList::FontList( OutputDevice* pDevice, OutputDevice* pDevice2 = NULL,
57 Constructor of the FontList class. The relevant fonts will be queried from
58 the OutputDevice. The OutputDevice needs to exist as long as the FontList
59 class exists. Optionally, a second output device can be given in order to,
60 e.g., manage the fonts from both, a printer and a screen in a single FontList
61 and thus also give FontMenus the fonts if both OutputDevices.
62 The pDevice2 needs to exist as long as the FontList class exists.
64 The OutputDevice given first should be the preferred one. This is usually
65 the printer. Because if two different device fonts (one for the printer and
66 one for the screen) exist, the ones from the "pDevice" are preferred.
68 The third paramter governs whether only scalable or all fonts shall be queried.
69 With sal_True Bitmap-Schriften will also be queried.
70 With sal_False vectorized and scalable fonts will be queried.
72 --------------------------------------------------------------------------
74 String FontList::GetStyleName( const vcl::FontInfo& rInfo ) const;
76 This method returns the StyleName of a vcl::FontInfo.
77 If no StyleName is set, a name will be generated from the set attributes.
79 --------------------------------------------------------------------------
81 OUString FontList::GetFontMapText( const vcl::FontInfo& rInfo ) const;
83 This method returns a Matchstring which indicates the problem that could
84 arise when using a font. This string should be displayed to the user.
86 --------------------------------------------------------------------------
88 vcl::FontInfo FontList::Get( const String& rName, const String& rStyleName ) const;
90 This method search a vcl::FontInfo for the given name and the given style name.
91 The Stylename can also be a synthetic one.
92 In that case the relevant vcl::FontInfo fields will be set.
93 If a StyleName is provived, a vcl::FontInfo structure without a Stylename can be
94 returned. To get a representation of the StyleName for displaying it to the user,
95 call GetStyleName() on this vcl::FontInfo structure.
99 FontList::GetStyleName()
101 --------------------------------------------------------------------------
103 vcl::FontInfo FontList::Get( const String& rName, FontWeight eWeight,
104 FontItalic eItalic ) const;
106 This method search a vcl::FontInfo structure for a provided name and styles.
107 This method can also return a vcl::FontInfo without a Stylename.
108 To get a representation of the StyleName to be presented to the user
109 call GetStyleName() with this vcl::FontInfo.
113 FontList::GetStyleName()
115 --------------------------------------------------------------------------
117 const sal_IntPtr* FontList::GetSizeAry( const vcl::FontInfo& rInfo ) const;
119 This method returns the available sizes for the given font.
120 If it is a scalable font, standard sizes are returned.
121 The array contains the heights of the font in tenth (1/10) point.
122 The last value of the array is 0.
123 The returned array will destroyed by the FontList.
124 You should thus not reference the array after the next method call on the
129 #define FONTLIST_FONTINFO_NOTFOUND ((sal_uInt16)0xFFFF)
131 class SVT_DLLPUBLIC FontList
134 static const sal_IntPtr aStdSizeAry
[];
137 OUString maMapPrinterOnly
;
138 OUString maMapScreenOnly
;
139 OUString maMapStyleNotAvailable
;
140 mutable OUString maMapNotAvailable
;
142 OUString maLightItalic
;
144 OUString maNormalItalic
;
146 OUString maBoldItalic
;
148 OUString maBlackItalic
;
149 sal_IntPtr
* mpSizeAry
;
150 VclPtr
<OutputDevice
> mpDev
;
151 VclPtr
<OutputDevice
> mpDev2
;
152 boost::ptr_vector
<ImplFontListNameInfo
> maEntries
;
154 SVT_DLLPRIVATE ImplFontListNameInfo
* ImplFind( const OUString
& rSearchName
, sal_uLong
* pIndex
) const;
155 SVT_DLLPRIVATE ImplFontListNameInfo
* ImplFindByName( const OUString
& rStr
) const;
156 SVT_DLLPRIVATE
void ImplInsertFonts( OutputDevice
* pDev
, bool bAll
,
160 FontList( OutputDevice
* pDevice
,
161 OutputDevice
* pDevice2
= NULL
,
165 FontList
* Clone() const;
167 OutputDevice
* GetDevice() const { return mpDev
; }
168 OutputDevice
* GetDevice2() const { return mpDev2
; }
169 OUString
GetFontMapText( const vcl::FontInfo
& rInfo
) const;
171 const OUString
& GetNormalStr() const { return maNormal
; }
172 const OUString
& GetItalicStr() const { return maNormalItalic
; }
173 const OUString
& GetBoldStr() const { return maBold
; }
174 const OUString
& GetBoldItalicStr() const { return maBoldItalic
; }
175 const OUString
& GetStyleName( FontWeight eWeight
, FontItalic eItalic
) const;
176 OUString
GetStyleName( const vcl::FontInfo
& rInfo
) const;
178 vcl::FontInfo
Get( const OUString
& rName
,
179 const OUString
& rStyleName
) const;
180 vcl::FontInfo
Get( const OUString
& rName
,
182 FontItalic eItalic
) const;
184 bool IsAvailable( const OUString
& rName
) const;
185 sal_uInt16
GetFontNameCount() const
187 return (sal_uInt16
)maEntries
.size();
189 const vcl::FontInfo
& GetFontName( sal_uInt16 nFont
) const;
190 sal_Handle
GetFirstFontInfo( const OUString
& rName
) const;
191 static sal_Handle
GetNextFontInfo( sal_Handle hFontInfo
);
192 static const vcl::FontInfo
& GetFontInfo( sal_Handle hFontInfo
);
194 const sal_IntPtr
* GetSizeAry( const vcl::FontInfo
& rInfo
) const;
195 static const sal_IntPtr
* GetStdSizeAry() { return aStdSizeAry
; }
198 FontList( const FontList
& ) SAL_DELETED_FUNCTION
;
199 FontList
& operator =( const FontList
& ) SAL_DELETED_FUNCTION
;
202 class SVT_DLLPUBLIC FontSizeNames
205 const struct ImplFSNameItem
* mpArray
;
209 FontSizeNames( LanguageType eLanguage
/* = LANGUAGE_DONTKNOW */ );
211 sal_uLong
Count() const { return mnElem
; }
212 bool IsEmpty() const { return !mnElem
; }
214 long Name2Size( const OUString
& ) const;
215 OUString
Size2Name( long ) const;
217 OUString
GetIndexName( sal_uLong nIndex
) const;
218 long GetIndexSize( sal_uLong nIndex
) const;
221 #endif // INCLUDED_SVTOOLS_CTRLTOOL_HXX
223 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */