merge the formfield patch from ooo-build
[ooovba.git] / vcl / unx / source / gdi / xlfd_extd.hxx
blobb5feb4e30ee720c4013869bf5b0b90721118f8f6
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xlfd_extd.hxx,v $
10 * $Revision: 1.17 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef XLFD_EXTENDED_HXX
31 #define XLFD_EXTENDED_HXX
33 #include <salunx.h>
34 #ifndef _VCL_VCLENUM_HXX
35 #include <vcl/enum.hxx>
36 #endif
37 #ifndef _VCL_OUTFONT_HXX
38 #include <vcl/outfont.hxx>
39 #endif
41 #include <vector>
43 class Xlfd;
44 class AttributeProvider;
45 class ImplDevFontList;
46 class ByteString;
48 // --------------------------------------------------------------------------
50 // classes for Xlfd handling that contain more than a single encoding.
51 // Members that may vary through different encodings are stored in
52 // a mpEncodingInfo member. There are three different classes:
53 // true scalable fonts (truetype and type1) scalable bitmap fonts
54 // (the ugly ones) and bitmap fonts. The ExtendedXlfd stores all the members
55 // that are specific to a font outline
56 // ( e.g. adobe-times-roman-medium-r-normal- * -p- * )
57 // and specifies the interface.
59 // --------------------------------------------------------------------------
61 // base class
63 class ExtendedXlfd : public ImplDevFontAttributes
65 public:
66 ExtendedXlfd( bool bScalable );
67 virtual ~ExtendedXlfd();
68 virtual bool AddEncoding( const Xlfd* );
69 bool HasEncoding( rtl_TextEncoding ) const;
70 int GetEncodingIdx( rtl_TextEncoding nEncoding ) const;
71 unsigned short NumEncodings() const
72 { return mnEncodings; }
73 virtual int GetPixelSize() const
74 { return 0; }
75 virtual void ToString( ByteString &rString,
76 unsigned short nPixelSize,
77 rtl_TextEncoding nEncoding ) const ;
78 virtual void ToString( ByteString &rString,
79 unsigned short nPixelSize,
80 char* pMatricsString,
81 rtl_TextEncoding nEncoding ) const;
83 virtual ImplFontData* GetImplFontData() const = 0;
84 bool IsScalable() const { return mbScalable; }
85 virtual FontFamily GetFamilyType() const;
86 virtual FontWeight GetWeight() const;
87 virtual FontItalic GetSlant() const;
88 virtual FontWidth GetWidthType() const;
89 virtual FontPitch GetPitch() const;
90 virtual FontPitch GetPitch( rtl_TextEncoding ) const;
91 rtl_TextEncoding GetAsciiEncoding( int *pAsciiRange = NULL ) const;
92 rtl_TextEncoding GetEncoding() const;
93 rtl_TextEncoding GetEncoding( int i ) const;
95 int GetFontCodeRanges( sal_uInt32* pCodePairs ) const;
97 protected:
98 AttributeProvider* mpFactory;
100 public:
101 unsigned short mnFoundry;
102 unsigned short mnFamily;
103 unsigned short mnWeight;
104 unsigned short mnSlant;
105 unsigned short mnSetwidth;
106 bool mbScalable;
108 protected:
109 unsigned short mnEncodings;
110 unsigned short mnEncCapacity;
111 struct EncodingInfo {
112 unsigned char mcSpacing;
113 unsigned short mnResolutionX;
114 unsigned short mnResolutionY;
115 unsigned short mnAddstyle;
116 unsigned short mnCharset;
117 rtl_TextEncoding mnEncoding;
119 EncodingInfo& operator= ( const Xlfd *pXlfd );
120 } *mpEncodingInfo;
123 // class to handle scalable bitmap fonts
125 class ScalableBitmapXlfd : public ExtendedXlfd {
127 public:
128 ScalableBitmapXlfd();
129 virtual ~ScalableBitmapXlfd();
130 virtual void ToString( ByteString &rString,
131 unsigned short nPixelSize,
132 rtl_TextEncoding nEncoding ) const;
133 virtual void ToString( ByteString &rString,
134 unsigned short nPixelSize,
135 char* pMatricsString,
136 rtl_TextEncoding nEncoding ) const;
138 virtual ImplFontData* GetImplFontData() const ;
141 // class to handle true bitmap fonts
143 class ScalableXlfd;
145 class BitmapXlfd : public ExtendedXlfd {
147 public:
148 BitmapXlfd();
149 ~BitmapXlfd();
150 bool AddEncoding( const Xlfd* );
151 virtual int GetPixelSize() const
152 { return mnPixelSize; }
153 virtual void ToString( ByteString &rString,
154 unsigned short nPixelSize,
155 rtl_TextEncoding nEncoding ) const;
156 virtual void ToString( ByteString &rString,
157 unsigned short nPixelSize,
158 char* pMatricsString,
159 rtl_TextEncoding nEncoding ) const;
160 virtual ImplFontData* GetImplFontData() const ;
161 protected:
163 unsigned short mnPixelSize;
164 unsigned short mnPointSize;
165 unsigned short mnAverageWidth;
168 // class to handle true scalable fonts
170 class ScalableXlfd : public ExtendedXlfd {
172 friend class BitmapXlfd;
174 public:
175 ScalableXlfd();
176 virtual ~ScalableXlfd();
177 virtual void ToString( ByteString &rString,
178 unsigned short nPixelSize,
179 rtl_TextEncoding nEncoding ) const;
181 virtual void ToString( ByteString &rString,
182 unsigned short nPixelSize,
183 char* pMatricsString,
184 rtl_TextEncoding nEncoding ) const;
185 virtual ImplFontData* GetImplFontData() const ;
188 // class to maintain a list of fonts ( bitmap and scalable )
190 class XlfdStorage {
192 public:
193 XlfdStorage();
195 void Dispose();
196 void Reset();
198 void Add( const ExtendedXlfd *pXlfd );
199 void Add( const XlfdStorage *pXlfd );
200 void AnnounceFonts( ImplDevFontList* ) const;
202 protected:
204 typedef ::std::vector<const ExtendedXlfd*> XlfdList;
205 XlfdList maXlfdList;
208 // list of fonts specific for bitmap fonts
210 class BitmapXlfdStorage : public XlfdStorage {
212 public:
214 void AddBitmapFont( const Xlfd *pXlfd );
218 /* Virtual font for User Interface */
220 class VirtualXlfd : public ExtendedXlfd
222 private:
224 int GetFontQuality (unsigned short nFamily);
226 public:
227 VirtualXlfd();
228 virtual ~VirtualXlfd();
229 virtual bool AddEncoding( const Xlfd* );
230 void FilterInterfaceFont (const Xlfd *pXlfd);
231 virtual void ToString( ByteString &rString,
232 unsigned short nPixelSize,
233 rtl_TextEncoding nEncoding ) const ;
234 virtual void ToString( ByteString &rString,
235 unsigned short nPixelSize,
236 char* pMatricsString,
237 rtl_TextEncoding nEncoding ) const;
239 virtual ImplFontData* GetImplFontData() const ;
240 protected:
242 unsigned short mnExtCapacity;
243 struct ExtEncodingInfo {
244 unsigned short mnFoundry;
245 unsigned short mnFamily;
246 unsigned short mnWeight;
247 unsigned short mnSlant;
248 unsigned short mnSetwidth;
250 ExtEncodingInfo& operator= ( const Xlfd *pXlfd );
251 } *mpExtEncodingInfo;
253 friend class ExtEncodingInfo;
257 // class to describe a X11 physically available font face
259 class ImplX11FontData : public ImplFontData
261 private:
262 enum { X11IFD_MAGIC = 0x111FDA1C };
263 const ExtendedXlfd& mrXlfd;
265 public:
266 ImplX11FontData( const ExtendedXlfd&, int nHeight );
267 const ExtendedXlfd& GetExtendedXlfd() const { return mrXlfd; }
268 virtual ImplFontData* Clone() const { return new ImplX11FontData( *this ); }
269 virtual ImplFontEntry* CreateFontInstance( ImplFontSelectData& ) const;
270 virtual sal_IntPtr GetFontId() const;
272 static bool CheckFontData( const ImplFontData& r ) { return r.CheckMagic( X11IFD_MAGIC ); }
275 #endif /* XLFD_EXTENDED_HXX */