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 _CTRLTOOL_HXX
21 : #define _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 :
30 : class ImplFontListNameInfo;
31 : class OutputDevice;
32 :
33 : /*************************************************************************
34 :
35 : Beschreibung
36 : ============
37 :
38 : class FontList
39 :
40 : Diese Klasse verwaltet alle Fonts, die auf einem oder zwei Ausgabegeraeten
41 : dargestellt werden koennen. Zusaetzlich bietet die Klasse Methoden an, um
42 : aus Fett und Kursiv den StyleName zu generieren oder aus einem Stylename
43 : die fehlenden Attribute. Zusaetzlich kann diese Klasse syntetisch nachgebildete
44 : Fonts verarbeiten. Diese Klasse kann mit verschiedenen Standard-Controls und
45 : Standard-Menus zusammenarbeiten.
46 :
47 : Querverweise
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 : sal_Bool bAll = sal_True );
56 :
57 : Konstruktor der Klasse FontList. Vom uebergebenen OutputDevice werden die
58 : entsprechenden Fonts abgefragt. Das OutputDevice muss solange existieren,
59 : wie auch die Klasse FontList existiert. Optional kann noch ein 2tes
60 : Ausgabedevice uebergeben werden, damit man zum Beispiel die Fonts von
61 : einem Drucker und dem Bildschirm zusammen in einer FontListe verwalten kann
62 : und somit auch den FontListen und FontMenus die Fonts von beiden OutputDevices
63 : zu uebergeben. Auch das pDevice2 muss solange existieren, wie die Klasse
64 : FontList existiert.
65 :
66 : Das OutputDevice, welches als erstes uebergeben wird, sollte das bevorzugte
67 : sein. Dies sollte im normalfall der Drucker sein. Denn wenn 2 verschiede
68 : Device-Schriften (eine fuer Drucker und eine fuer den Bildschirm) vorhanden
69 : sind, wird die vom uebergebenen Device "pDevice" bevorzugt.
70 :
71 : Mit dem dritten Parameter kann man angeben, ob nur skalierbare Schriften
72 : abgefragt werden sollen oder alle. Wenn sal_True uebergeben wird, werden auch
73 : Bitmap-Schriften mit abgefragt. Bei sal_False werden Vector-Schriften und
74 : scalierbare Schriften abgefragt.
75 :
76 : --------------------------------------------------------------------------
77 :
78 : String FontList::GetStyleName( const FontInfo& rInfo ) const;
79 :
80 : Diese Methode gibt den StyleName von einer FontInfo zurueck. Falls kein
81 : StyleName gesetzt ist, wird aus den gesetzten Attributen ein entsprechender
82 : Name generiert, der dem Anwender praesentiert werden kann.
83 :
84 : --------------------------------------------------------------------------
85 :
86 : FontInfo FontList::Get( const String& rName, const String& rStyleName ) const;
87 :
88 : Diese Methode sucht aus dem uebergebenen Namen und dem uebergebenen StyleName
89 : die entsprechende FontInfo-Struktur raus. Der Stylename kann in dieser
90 : Methode auch ein syntetischer sein. In diesem Fall werden die entsprechenden
91 : Werte in der FontInfo-Struktur entsprechend gesetzt. Wenn ein StyleName
92 : uebergeben wird, kann jedoch eine FontInfo-Struktur ohne Stylename
93 : zurueckgegeben werden. Um den StyleName dem Anwender zu repraesentieren,
94 : muss GetStyleName() mit dieser FontInfo-Struktur aufgerufen werden.
95 :
96 : Querverweise
97 :
98 : FontList::GetStyleName()
99 :
100 : --------------------------------------------------------------------------
101 :
102 : FontInfo FontList::Get( const String& rName, FontWeight eWeight,
103 : FontItalic eItalic ) const;
104 :
105 : Diese Methode sucht aus dem uebergebenen Namen und den uebergebenen Styles
106 : die entsprechende FontInfo-Struktur raus. Diese Methode kann auch eine
107 : FontInfo-Struktur ohne Stylename zurueckgegeben. Um den StyleName dem
108 : Anwender zu repraesentieren, muss GetStyleName() mit dieser FontInfo-Struktur
109 : aufgerufen werden.
110 :
111 : Querverweise
112 :
113 : FontList::GetStyleName()
114 :
115 : --------------------------------------------------------------------------
116 :
117 : const long* FontList::GetSizeAry( const FontInfo& rInfo ) const;
118 :
119 : Diese Methode liefert zum uebergebenen Font die vorhandenen Groessen.
120 : Falls es sich dabei um einen skalierbaren Font handelt, werden Standard-
121 : Groessen zurueckgegeben. Das Array enthaelt die Hoehen des Fonts in 10tel
122 : Point. Der letzte Wert des Array ist 0. Das Array, was zurueckgegeben wird,
123 : wird von der FontList wieder zerstoert. Nach dem Aufruf der naechsten Methode
124 : von der FontList, sollte deshalb das Array nicht mehr referenziert werden.
125 :
126 : *************************************************************************/
127 :
128 : // ------------
129 : // - FontList -
130 : // ------------
131 :
132 : #define FONTLIST_FONTINFO_NOTFOUND ((sal_uInt16)0xFFFF)
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 : 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 : long* mpSizeAry;
152 : OutputDevice* mpDev;
153 : OutputDevice* mpDev2;
154 : boost::ptr_vector<ImplFontListNameInfo> maEntries;
155 : #ifdef CTRLTOOL_CXX
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, sal_Bool bAll,
159 : sal_Bool bInsertData );
160 : #endif
161 :
162 : public:
163 : FontList( OutputDevice* pDevice,
164 : OutputDevice* pDevice2 = NULL,
165 : sal_Bool bAll = sal_True );
166 : ~FontList();
167 :
168 : FontList* Clone() const;
169 :
170 : OutputDevice* GetDevice() const { return mpDev; }
171 : OutputDevice* GetDevice2() const { return mpDev2; }
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 FontInfo& rInfo ) const;
179 :
180 : FontInfo Get( const OUString& rName,
181 : const OUString& rStyleName ) const;
182 : FontInfo Get( const OUString& rName,
183 : FontWeight eWeight,
184 : FontItalic eItalic ) const;
185 :
186 : sal_Bool IsAvailable( const OUString& rName ) const;
187 1034 : sal_uInt16 GetFontNameCount() const
188 : {
189 1034 : return (sal_uInt16)maEntries.size();
190 : }
191 : const FontInfo& GetFontName( sal_uInt16 nFont ) const;
192 : sal_Handle GetFirstFontInfo( const OUString& rName ) const;
193 : sal_Handle GetNextFontInfo( sal_Handle hFontInfo ) const;
194 : const FontInfo& GetFontInfo( sal_Handle hFontInfo ) const;
195 :
196 : const long* GetSizeAry( const FontInfo& rInfo ) const;
197 : static const long* GetStdSizeAry();
198 :
199 : private:
200 : FontList( const FontList& );
201 : FontList& operator =( const FontList& );
202 : };
203 :
204 :
205 : // -----------------
206 : // - FontSizeNames -
207 : // -----------------
208 :
209 : class SVT_DLLPUBLIC FontSizeNames
210 : {
211 : private:
212 : const struct ImplFSNameItem* mpArray;
213 : sal_uLong mnElem;
214 :
215 : public:
216 : FontSizeNames( LanguageType eLanguage /* = LANGUAGE_DONTKNOW */ );
217 :
218 0 : sal_uLong Count() const { return mnElem; }
219 4 : sal_Bool IsEmpty() const { return !mnElem; }
220 :
221 : long Name2Size( const String& ) const;
222 : String Size2Name( long ) const;
223 :
224 : String GetIndexName( sal_uLong nIndex ) const;
225 : long GetIndexSize( sal_uLong nIndex ) const;
226 : };
227 :
228 : #endif // _CTRLTOOL_HXX
229 :
230 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|