xref: /AOO41X/main/svtools/inc/svtools/ctrltool.hxx (revision 01aa44aa134af97080e2cf8e8bf3a0a4cd1cffe0)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _CTRLTOOL_HXX
25 #define _CTRLTOOL_HXX
26 
27 #include "svtools/svtdllapi.h"
28 
29 #ifndef _SAL_TYPES_H
30 #include <sal/types.h>
31 #endif
32 #include <tools/list.hxx>
33 #ifndef _METRIC_HXX
34 #include <vcl/metric.hxx>
35 #endif
36 
37 class ImplFontListNameInfo;
38 class OutputDevice;
39 
40 /*************************************************************************
41 
42 Beschreibung
43 ============
44 
45 class FontList
46 
47 Diese Klasse verwaltet alle Fonts, die auf einem oder zwei Ausgabegeraeten
48 dargestellt werden koennen. Zusaetzlich bietet die Klasse Methoden an, um
49 aus Fett und Kursiv den StyleName zu generieren oder aus einem Stylename
50 die fehlenden Attribute. Zusaetzlich kann diese Klasse syntetisch nachgebildete
51 Fonts verarbeiten. Diese Klasse kann mit verschiedenen Standard-Controls und
52 Standard-Menus zusammenarbeiten.
53 
54 Querverweise
55 
56 class FontNameBox, class FontStyleBox, class FontSizeBox,
57 class FontNameMenu, class FontStyleMenu, class FontSizeMenu
58 
59 --------------------------------------------------------------------------
60 
61 FontList::FontList( OutputDevice* pDevice, OutputDevice* pDevice2 = NULL,
62                     sal_Bool bAll = sal_True );
63 
64 Konstruktor der Klasse FontList. Vom uebergebenen OutputDevice werden die
65 entsprechenden Fonts abgefragt. Das OutputDevice muss solange existieren,
66 wie auch die Klasse FontList existiert. Optional kann noch ein 2tes
67 Ausgabedevice uebergeben werden, damit man zum Beispiel die Fonts von
68 einem Drucker und dem Bildschirm zusammen in einer FontListe verwalten kann
69 und somit auch den FontListen und FontMenus die Fonts von beiden OutputDevices
70 zu uebergeben. Auch das pDevice2 muss solange existieren, wie die Klasse
71 FontList existiert.
72 
73 Das OutputDevice, welches als erstes uebergeben wird, sollte das bevorzugte
74 sein. Dies sollte im normalfall der Drucker sein. Denn wenn 2 verschiede
75 Device-Schriften (eine fuer Drucker und eine fuer den Bildschirm) vorhanden
76 sind, wird die vom uebergebenen Device "pDevice" bevorzugt.
77 
78 Mit dem dritten Parameter kann man angeben, ob nur skalierbare Schriften
79 abgefragt werden sollen oder alle. Wenn sal_True uebergeben wird, werden auch
80 Bitmap-Schriften mit abgefragt. Bei sal_False werden Vector-Schriften und
81 scalierbare Schriften abgefragt.
82 
83 --------------------------------------------------------------------------
84 
85 String FontList::GetStyleName( const FontInfo& rInfo ) const;
86 
87 Diese Methode gibt den StyleName von einer FontInfo zurueck. Falls kein
88 StyleName gesetzt ist, wird aus den gesetzten Attributen ein entsprechender
89 Name generiert, der dem Anwender praesentiert werden kann.
90 
91 --------------------------------------------------------------------------
92 
93 XubString FontList::GetFontMapText( const FontInfo& rInfo ) const;
94 
95 Diese Methode gibt einen Matchstring zurueck, der dem Anwender
96 anzeigen soll, welche Probleme es mit diesem Font geben kann.
97 
98 --------------------------------------------------------------------------
99 
100 FontInfo FontList::Get( const String& rName, const String& rStyleName ) const;
101 
102 Diese Methode sucht aus dem uebergebenen Namen und dem uebergebenen StyleName
103 die entsprechende FontInfo-Struktur raus. Der Stylename kann in dieser
104 Methode auch ein syntetischer sein. In diesem Fall werden die entsprechenden
105 Werte in der FontInfo-Struktur entsprechend gesetzt. Wenn ein StyleName
106 uebergeben wird, kann jedoch eine FontInfo-Struktur ohne Stylename
107 zurueckgegeben werden. Um den StyleName dem Anwender zu repraesentieren,
108 muss GetStyleName() mit dieser FontInfo-Struktur aufgerufen werden.
109 
110 Querverweise
111 
112 FontList::GetStyleName()
113 
114 --------------------------------------------------------------------------
115 
116 FontInfo FontList::Get( const String& rName, FontWeight eWeight,
117                         FontItalic eItalic ) const;
118 
119 Diese Methode sucht aus dem uebergebenen Namen und den uebergebenen Styles
120 die entsprechende FontInfo-Struktur raus. Diese Methode kann auch eine
121 FontInfo-Struktur ohne Stylename zurueckgegeben. Um den StyleName dem
122 Anwender zu repraesentieren, muss GetStyleName() mit dieser FontInfo-Struktur
123 aufgerufen werden.
124 
125 Querverweise
126 
127 FontList::GetStyleName()
128 
129 --------------------------------------------------------------------------
130 
131 const long* FontList::GetSizeAry( const FontInfo& rInfo ) const;
132 
133 Diese Methode liefert zum uebergebenen Font die vorhandenen Groessen.
134 Falls es sich dabei um einen skalierbaren Font handelt, werden Standard-
135 Groessen zurueckgegeben. Das Array enthaelt die Hoehen des Fonts in 10tel
136 Point. Der letzte Wert des Array ist 0. Das Array, was zurueckgegeben wird,
137 wird von der FontList wieder zerstoert. Nach dem Aufruf der naechsten Methode
138 von der FontList, sollte deshalb das Array nicht mehr referenziert werden.
139 
140 *************************************************************************/
141 
142 // ------------
143 // - FontList -
144 // ------------
145 
146 #define FONTLIST_FONTINFO_NOTFOUND  ((sal_uInt16)0xFFFF)
147 
148 #define FONTLIST_FONTNAMETYPE_PRINTER           ((sal_uInt16)0x0001)
149 #define FONTLIST_FONTNAMETYPE_SCREEN            ((sal_uInt16)0x0002)
150 #define FONTLIST_FONTNAMETYPE_SCALABLE          ((sal_uInt16)0x0004)
151 
152 class SVT_DLLPUBLIC FontList : private List
153 {
154 private:
155     XubString               maMapBoth;
156     XubString               maMapPrinterOnly;
157     XubString               maMapScreenOnly;
158     XubString               maMapSizeNotAvailable;
159     XubString               maMapStyleNotAvailable;
160     XubString               maMapNotAvailable;
161     XubString               maLight;
162     XubString               maLightItalic;
163     XubString               maNormal;
164     XubString               maNormalItalic;
165     XubString               maBold;
166     XubString               maBoldItalic;
167     XubString               maBlack;
168     XubString               maBlackItalic;
169     long*                   mpSizeAry;
170     OutputDevice*           mpDev;
171     OutputDevice*           mpDev2;
172 
173 #ifdef CTRLTOOL_CXX
174     SVT_DLLPRIVATE ImplFontListNameInfo*    ImplFind( const XubString& rSearchName, sal_uLong* pIndex ) const;
175     SVT_DLLPRIVATE ImplFontListNameInfo*    ImplFindByName( const XubString& rStr ) const;
176     SVT_DLLPRIVATE void                 ImplInsertFonts( OutputDevice* pDev, sal_Bool bAll,
177                                              sal_Bool bInsertData );
178 #endif
179 
180 public:
181                             FontList( OutputDevice* pDevice,
182                                       OutputDevice* pDevice2 = NULL,
183                                       sal_Bool bAll = sal_True );
184                             ~FontList();
185 
186     FontList*               Clone() const;
187 
GetDevice() const188     OutputDevice*           GetDevice() const { return mpDev; }
GetDevice2() const189     OutputDevice*           GetDevice2() const { return mpDev2; }
190     XubString               GetFontMapText( const FontInfo& rInfo ) const;
191     sal_uInt16                  GetFontNameType( const XubString& rFontName ) const;
192 
GetNormalStr() const193     const XubString&        GetNormalStr() const { return maNormal; }
GetItalicStr() const194     const XubString&        GetItalicStr() const { return maNormalItalic; }
GetBoldStr() const195     const XubString&        GetBoldStr() const { return maBold; }
GetBoldItalicStr() const196     const XubString&        GetBoldItalicStr() const { return maBoldItalic; }
197     const XubString&        GetStyleName( FontWeight eWeight, FontItalic eItalic ) const;
198     XubString               GetStyleName( const FontInfo& rInfo ) const;
199 
200     FontInfo                Get( const XubString& rName,
201                                  const XubString& rStyleName ) const;
202     FontInfo                Get( const XubString& rName,
203                                  FontWeight eWeight,
204                                  FontItalic eItalic ) const;
205 
206     sal_Bool                    IsAvailable( const XubString& rName ) const;
GetFontNameCount() const207     sal_uInt16                  GetFontNameCount() const
208                                 { return (sal_uInt16)List::Count(); }
209     const FontInfo&         GetFontName( sal_uInt16 nFont ) const;
210     sal_uInt16                  GetFontNameType( sal_uInt16 nFont ) const;
211     sal_Handle              GetFirstFontInfo( const XubString& rName ) const;
212     sal_Handle              GetNextFontInfo( sal_Handle hFontInfo ) const;
213     const FontInfo&         GetFontInfo( sal_Handle hFontInfo ) const;
214 
215     const long*             GetSizeAry( const FontInfo& rInfo ) const;
216     static const long*      GetStdSizeAry();
217 
218 private:
219                             FontList( const FontList& );
220     FontList&               operator =( const FontList& );
221 };
222 
223 
224 // -----------------
225 // - FontSizeNames -
226 // -----------------
227 
228 class SVT_DLLPUBLIC FontSizeNames
229 {
230 private:
231     struct ImplFSNameItem*  mpArray;
232     sal_uLong                   mnElem;
233 
234 public:
235                             FontSizeNames( LanguageType eLanguage /* = LANGUAGE_DONTKNOW */ );
236 
Count() const237     sal_uLong                   Count() const { return mnElem; }
IsEmpty() const238     sal_Bool                    IsEmpty() const { return !mnElem; }
239 
240     long                    Name2Size( const String& ) const;
241     String                  Size2Name( long ) const;
242 
243     String                  GetIndexName( sal_uLong nIndex ) const;
244     long                    GetIndexSize( sal_uLong nIndex ) const;
245 };
246 
247 #endif  // _CTRLTOOL_HXX
248