Line data Source code
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 : #ifndef INCLUDED_SVTOOLS_CTRLTOOL_HXX
21 : #define INCLUDED_SVTOOLS_CTRLTOOL_HXX
22 :
23 : #include <boost/ptr_container/ptr_vector.hpp>
24 :
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>
30 :
31 : class ImplFontListNameInfo;
32 : class OutputDevice;
33 :
34 : /*
35 :
36 : Description
37 : ============
38 :
39 : class FontList
40 :
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.
46 :
47 : Links:
48 :
49 : class FontNameBox, class FontStyleBox, class FontSizeBox,
50 : class FontNameMenu, class FontSizeMenu
51 :
52 : --------------------------------------------------------------------------
53 :
54 : FontList::FontList( OutputDevice* pDevice, OutputDevice* pDevice2 = NULL,
55 : bool bAll = true );
56 :
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.
63 :
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.
67 :
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.
71 :
72 : --------------------------------------------------------------------------
73 :
74 : String FontList::GetStyleName( const vcl::FontInfo& rInfo ) const;
75 :
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.
78 :
79 : --------------------------------------------------------------------------
80 :
81 : OUString FontList::GetFontMapText( const vcl::FontInfo& rInfo ) const;
82 :
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.
85 :
86 : --------------------------------------------------------------------------
87 :
88 : vcl::FontInfo FontList::Get( const String& rName, const String& rStyleName ) const;
89 :
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.
96 :
97 : Links:
98 :
99 : FontList::GetStyleName()
100 :
101 : --------------------------------------------------------------------------
102 :
103 : vcl::FontInfo FontList::Get( const String& rName, FontWeight eWeight,
104 : FontItalic eItalic ) const;
105 :
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.
110 :
111 : Links:
112 :
113 : FontList::GetStyleName()
114 :
115 : --------------------------------------------------------------------------
116 :
117 : const sal_IntPtr* FontList::GetSizeAry( const vcl::FontInfo& rInfo ) const;
118 :
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
125 : FontList.
126 : */
127 :
128 :
129 : #define FONTLIST_FONTINFO_NOTFOUND ((sal_uInt16)0xFFFF)
130 :
131 : #define FONTLIST_FONTNAMETYPE_PRINTER ((sal_uInt16)0x0001)
132 : #define FONTLIST_FONTNAMETYPE_SCREEN ((sal_uInt16)0x0002)
133 :
134 : class SVT_DLLPUBLIC FontList
135 : {
136 : private:
137 : OUString maMapBoth;
138 : OUString maMapPrinterOnly;
139 : OUString maMapScreenOnly;
140 : OUString maMapSizeNotAvailable;
141 : OUString maMapStyleNotAvailable;
142 : mutable OUString maMapNotAvailable;
143 : OUString maLight;
144 : OUString maLightItalic;
145 : OUString maNormal;
146 : OUString maNormalItalic;
147 : OUString maBold;
148 : OUString maBoldItalic;
149 : OUString maBlack;
150 : OUString maBlackItalic;
151 : sal_IntPtr* mpSizeAry;
152 : OutputDevice* mpDev;
153 : OutputDevice* mpDev2;
154 : boost::ptr_vector<ImplFontListNameInfo> maEntries;
155 :
156 : SVT_DLLPRIVATE ImplFontListNameInfo* ImplFind( const OUString& rSearchName, sal_uLong* pIndex ) const;
157 : SVT_DLLPRIVATE ImplFontListNameInfo* ImplFindByName( const OUString& rStr ) const;
158 : SVT_DLLPRIVATE void ImplInsertFonts( OutputDevice* pDev, bool bAll,
159 : bool bInsertData );
160 :
161 : public:
162 : FontList( OutputDevice* pDevice,
163 : OutputDevice* pDevice2 = NULL,
164 : bool bAll = true );
165 : ~FontList();
166 :
167 : FontList* Clone() const;
168 :
169 : OutputDevice* GetDevice() const { return mpDev; }
170 : OutputDevice* GetDevice2() const { return mpDev2; }
171 : OUString GetFontMapText( const vcl::FontInfo& rInfo ) const;
172 :
173 0 : const OUString& GetNormalStr() const { return maNormal; }
174 0 : const OUString& GetItalicStr() const { return maNormalItalic; }
175 0 : const OUString& GetBoldStr() const { return maBold; }
176 0 : const OUString& GetBoldItalicStr() const { return maBoldItalic; }
177 : const OUString& GetStyleName( FontWeight eWeight, FontItalic eItalic ) const;
178 : OUString GetStyleName( const vcl::FontInfo& rInfo ) const;
179 :
180 : vcl::FontInfo Get( const OUString& rName,
181 : const OUString& rStyleName ) const;
182 : vcl::FontInfo Get( const OUString& rName,
183 : FontWeight eWeight,
184 : FontItalic eItalic ) const;
185 :
186 : bool IsAvailable( const OUString& rName ) const;
187 11086 : sal_uInt16 GetFontNameCount() const
188 : {
189 11086 : return (sal_uInt16)maEntries.size();
190 : }
191 : const vcl::FontInfo& GetFontName( sal_uInt16 nFont ) const;
192 : sal_Handle GetFirstFontInfo( const OUString& rName ) const;
193 : sal_Handle GetNextFontInfo( sal_Handle hFontInfo ) const;
194 : const vcl::FontInfo& GetFontInfo( sal_Handle hFontInfo ) const;
195 :
196 : const sal_IntPtr* GetSizeAry( const vcl::FontInfo& rInfo ) const;
197 : static const sal_IntPtr* GetStdSizeAry();
198 :
199 : private:
200 : FontList( const FontList& );
201 : FontList& operator =( const FontList& );
202 : };
203 :
204 : class SVT_DLLPUBLIC FontSizeNames
205 : {
206 : private:
207 : const struct ImplFSNameItem* mpArray;
208 : sal_uLong mnElem;
209 :
210 : public:
211 : FontSizeNames( LanguageType eLanguage /* = LANGUAGE_DONTKNOW */ );
212 :
213 0 : sal_uLong Count() const { return mnElem; }
214 4006 : bool IsEmpty() const { return !mnElem; }
215 :
216 : long Name2Size( const OUString& ) const;
217 : OUString Size2Name( long ) const;
218 :
219 : OUString GetIndexName( sal_uLong nIndex ) const;
220 : long GetIndexSize( sal_uLong nIndex ) const;
221 : };
222 :
223 : #endif // INCLUDED_SVTOOLS_CTRLTOOL_HXX
224 :
225 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|