Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _CTRLTOOL_HXX
30 : : #define _CTRLTOOL_HXX
31 : :
32 : : #include <boost/ptr_container/ptr_vector.hpp>
33 : :
34 : : #include "svtools/svtdllapi.h"
35 : :
36 : : #include <sal/types.h>
37 : : #include <vcl/metric.hxx>
38 : :
39 : : class ImplFontListNameInfo;
40 : : class OutputDevice;
41 : :
42 : : /*************************************************************************
43 : :
44 : : Beschreibung
45 : : ============
46 : :
47 : : class FontList
48 : :
49 : : Diese Klasse verwaltet alle Fonts, die auf einem oder zwei Ausgabegeraeten
50 : : dargestellt werden koennen. Zusaetzlich bietet die Klasse Methoden an, um
51 : : aus Fett und Kursiv den StyleName zu generieren oder aus einem Stylename
52 : : die fehlenden Attribute. Zusaetzlich kann diese Klasse syntetisch nachgebildete
53 : : Fonts verarbeiten. Diese Klasse kann mit verschiedenen Standard-Controls und
54 : : Standard-Menus zusammenarbeiten.
55 : :
56 : : Querverweise
57 : :
58 : : class FontNameBox, class FontStyleBox, class FontSizeBox,
59 : : class FontNameMenu, class FontSizeMenu
60 : :
61 : : --------------------------------------------------------------------------
62 : :
63 : : FontList::FontList( OutputDevice* pDevice, OutputDevice* pDevice2 = NULL,
64 : : sal_Bool bAll = sal_True );
65 : :
66 : : Konstruktor der Klasse FontList. Vom uebergebenen OutputDevice werden die
67 : : entsprechenden Fonts abgefragt. Das OutputDevice muss solange existieren,
68 : : wie auch die Klasse FontList existiert. Optional kann noch ein 2tes
69 : : Ausgabedevice uebergeben werden, damit man zum Beispiel die Fonts von
70 : : einem Drucker und dem Bildschirm zusammen in einer FontListe verwalten kann
71 : : und somit auch den FontListen und FontMenus die Fonts von beiden OutputDevices
72 : : zu uebergeben. Auch das pDevice2 muss solange existieren, wie die Klasse
73 : : FontList existiert.
74 : :
75 : : Das OutputDevice, welches als erstes uebergeben wird, sollte das bevorzugte
76 : : sein. Dies sollte im normalfall der Drucker sein. Denn wenn 2 verschiede
77 : : Device-Schriften (eine fuer Drucker und eine fuer den Bildschirm) vorhanden
78 : : sind, wird die vom uebergebenen Device "pDevice" bevorzugt.
79 : :
80 : : Mit dem dritten Parameter kann man angeben, ob nur skalierbare Schriften
81 : : abgefragt werden sollen oder alle. Wenn sal_True uebergeben wird, werden auch
82 : : Bitmap-Schriften mit abgefragt. Bei sal_False werden Vector-Schriften und
83 : : scalierbare Schriften abgefragt.
84 : :
85 : : --------------------------------------------------------------------------
86 : :
87 : : String FontList::GetStyleName( const FontInfo& rInfo ) const;
88 : :
89 : : Diese Methode gibt den StyleName von einer FontInfo zurueck. Falls kein
90 : : StyleName gesetzt ist, wird aus den gesetzten Attributen ein entsprechender
91 : : Name generiert, der dem Anwender praesentiert werden kann.
92 : :
93 : : --------------------------------------------------------------------------
94 : :
95 : : XubString FontList::GetFontMapText( const FontInfo& rInfo ) const;
96 : :
97 : : Diese Methode gibt einen Matchstring zurueck, der dem Anwender
98 : : anzeigen soll, welche Probleme es mit diesem Font geben kann.
99 : :
100 : : --------------------------------------------------------------------------
101 : :
102 : : FontInfo FontList::Get( const String& rName, const String& rStyleName ) const;
103 : :
104 : : Diese Methode sucht aus dem uebergebenen Namen und dem uebergebenen StyleName
105 : : die entsprechende FontInfo-Struktur raus. Der Stylename kann in dieser
106 : : Methode auch ein syntetischer sein. In diesem Fall werden die entsprechenden
107 : : Werte in der FontInfo-Struktur entsprechend gesetzt. Wenn ein StyleName
108 : : uebergeben wird, kann jedoch eine FontInfo-Struktur ohne Stylename
109 : : zurueckgegeben werden. Um den StyleName dem Anwender zu repraesentieren,
110 : : muss GetStyleName() mit dieser FontInfo-Struktur aufgerufen werden.
111 : :
112 : : Querverweise
113 : :
114 : : FontList::GetStyleName()
115 : :
116 : : --------------------------------------------------------------------------
117 : :
118 : : FontInfo FontList::Get( const String& rName, FontWeight eWeight,
119 : : FontItalic eItalic ) const;
120 : :
121 : : Diese Methode sucht aus dem uebergebenen Namen und den uebergebenen Styles
122 : : die entsprechende FontInfo-Struktur raus. Diese Methode kann auch eine
123 : : FontInfo-Struktur ohne Stylename zurueckgegeben. Um den StyleName dem
124 : : Anwender zu repraesentieren, muss GetStyleName() mit dieser FontInfo-Struktur
125 : : aufgerufen werden.
126 : :
127 : : Querverweise
128 : :
129 : : FontList::GetStyleName()
130 : :
131 : : --------------------------------------------------------------------------
132 : :
133 : : const long* FontList::GetSizeAry( const FontInfo& rInfo ) const;
134 : :
135 : : Diese Methode liefert zum uebergebenen Font die vorhandenen Groessen.
136 : : Falls es sich dabei um einen skalierbaren Font handelt, werden Standard-
137 : : Groessen zurueckgegeben. Das Array enthaelt die Hoehen des Fonts in 10tel
138 : : Point. Der letzte Wert des Array ist 0. Das Array, was zurueckgegeben wird,
139 : : wird von der FontList wieder zerstoert. Nach dem Aufruf der naechsten Methode
140 : : von der FontList, sollte deshalb das Array nicht mehr referenziert werden.
141 : :
142 : : *************************************************************************/
143 : :
144 : : // ------------
145 : : // - FontList -
146 : : // ------------
147 : :
148 : : #define FONTLIST_FONTINFO_NOTFOUND ((sal_uInt16)0xFFFF)
149 : :
150 : : #define FONTLIST_FONTNAMETYPE_PRINTER ((sal_uInt16)0x0001)
151 : : #define FONTLIST_FONTNAMETYPE_SCREEN ((sal_uInt16)0x0002)
152 : : #define FONTLIST_FONTNAMETYPE_SCALABLE ((sal_uInt16)0x0004)
153 : :
154 : : class SVT_DLLPUBLIC FontList
155 : : {
156 : : private:
157 : : XubString maMapBoth;
158 : : XubString maMapPrinterOnly;
159 : : XubString maMapScreenOnly;
160 : : XubString maMapSizeNotAvailable;
161 : : XubString maMapStyleNotAvailable;
162 : : XubString maMapNotAvailable;
163 : : XubString maLight;
164 : : XubString maLightItalic;
165 : : XubString maNormal;
166 : : XubString maNormalItalic;
167 : : XubString maBold;
168 : : XubString maBoldItalic;
169 : : XubString maBlack;
170 : : XubString maBlackItalic;
171 : : long* mpSizeAry;
172 : : OutputDevice* mpDev;
173 : : OutputDevice* mpDev2;
174 : : boost::ptr_vector<ImplFontListNameInfo> maEntries;
175 : : #ifdef CTRLTOOL_CXX
176 : : SVT_DLLPRIVATE ImplFontListNameInfo* ImplFind( const XubString& rSearchName, sal_uLong* pIndex ) const;
177 : : SVT_DLLPRIVATE ImplFontListNameInfo* ImplFindByName( const XubString& rStr ) const;
178 : : SVT_DLLPRIVATE void ImplInsertFonts( OutputDevice* pDev, sal_Bool bAll,
179 : : sal_Bool bInsertData );
180 : : #endif
181 : :
182 : : public:
183 : : FontList( OutputDevice* pDevice,
184 : : OutputDevice* pDevice2 = NULL,
185 : : sal_Bool bAll = sal_True );
186 : : ~FontList();
187 : :
188 : : FontList* Clone() const;
189 : :
190 : : OutputDevice* GetDevice() const { return mpDev; }
191 : : OutputDevice* GetDevice2() const { return mpDev2; }
192 : : XubString GetFontMapText( const FontInfo& rInfo ) const;
193 : :
194 : 0 : const XubString& GetNormalStr() const { return maNormal; }
195 : 0 : const XubString& GetItalicStr() const { return maNormalItalic; }
196 : 0 : const XubString& GetBoldStr() const { return maBold; }
197 : 0 : const XubString& GetBoldItalicStr() const { return maBoldItalic; }
198 : : const XubString& GetStyleName( FontWeight eWeight, FontItalic eItalic ) const;
199 : : XubString GetStyleName( const FontInfo& rInfo ) const;
200 : :
201 : : FontInfo Get( const XubString& rName,
202 : : const XubString& rStyleName ) const;
203 : : FontInfo Get( const XubString& rName,
204 : : FontWeight eWeight,
205 : : FontItalic eItalic ) const;
206 : :
207 : : sal_Bool IsAvailable( const XubString& rName ) const;
208 : 2690 : sal_uInt16 GetFontNameCount() const
209 : 2690 : { return (sal_uInt16)maEntries.size(); }
210 : : const FontInfo& GetFontName( sal_uInt16 nFont ) const;
211 : : sal_uInt16 GetFontNameType( sal_uInt16 nFont ) const;
212 : : sal_Handle GetFirstFontInfo( const XubString& rName ) const;
213 : : sal_Handle GetNextFontInfo( sal_Handle hFontInfo ) const;
214 : : const FontInfo& GetFontInfo( sal_Handle hFontInfo ) const;
215 : :
216 : : const long* GetSizeAry( const FontInfo& rInfo ) const;
217 : : static const long* GetStdSizeAry();
218 : :
219 : : private:
220 : : FontList( const FontList& );
221 : : FontList& operator =( const FontList& );
222 : : };
223 : :
224 : :
225 : : // -----------------
226 : : // - FontSizeNames -
227 : : // -----------------
228 : :
229 : : class SVT_DLLPUBLIC FontSizeNames
230 : : {
231 : : private:
232 : : const struct ImplFSNameItem* mpArray;
233 : : sal_uLong mnElem;
234 : :
235 : : public:
236 : : FontSizeNames( LanguageType eLanguage /* = LANGUAGE_DONTKNOW */ );
237 : :
238 : 0 : sal_uLong Count() const { return mnElem; }
239 : 1481 : sal_Bool IsEmpty() const { return !mnElem; }
240 : :
241 : : long Name2Size( const String& ) const;
242 : : String Size2Name( long ) const;
243 : :
244 : : String GetIndexName( sal_uLong nIndex ) const;
245 : : long GetIndexSize( sal_uLong nIndex ) const;
246 : : };
247 : :
248 : : #endif // _CTRLTOOL_HXX
249 : :
250 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|