merge the formfield patch from ooo-build
[ooovba.git] / vcl / unx / inc / salfont.h
blobab18e5e8a59ae2d1b6f9c91bf4a8bc257fb3ad6e
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: salfont.h,v $
10 * $Revision: 1.6 $
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 ************************************************************************/
31 #ifndef _SV_SALFONT_H
32 #define _SV_SALFONT_H
34 // -=-= exports =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
35 class SalFontCache;
36 struct SalFontDimension;
37 class SalFontFamily;
38 class SalFontFamilyList;
39 class SalFontStruct;
40 class SalFontStructList;
41 class SalFonts;
43 // -=-= includes -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
44 #include <salstd.hxx>
45 #include <vcl/outfont.hxx>
47 // -=-= forwards =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
48 typedef ULONG XFP_FLAGS;
50 class SalDisplay;
51 class SalFontCacheItem;
53 // -=-= SalFontCache -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
54 DECLARE_LIST( SalFontCache, SalFontCacheItem* )
56 // -=-= SalFontDimension -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
57 struct SalFontDimension
59 USHORT nHeight_; // [pixel]
60 USHORT nPtHeight_; // [point/10]
61 USHORT nAverage_; // [pixel/10]
62 USHORT nXRes_; // [dpi]
63 USHORT nYRes_; // [dpi]
64 USHORT nSlant_; // [pixel]
65 // size_t nUnderlineThickness_; // [pixel]
66 // size_t nUnderlinePosition_; // [pixel]
67 // size_t nStrikeoutAscent_; // [pixel]
68 // size_t nStrikeoutDescent_; // [pixel]
69 // Subscript, Superscript, Capital, Space ...
71 inline SalFontDimension( USHORT nA = 0, USHORT nH = 0 );
73 inline BOOL IsScalable() const;
74 inline USHORT GetWidth() const { return (nAverage_ + 5) / 10; }
75 inline Size GetSize() const;
76 inline void SetSize( const Size & rSize );
77 inline BOOL operator == ( const SalFontDimension &r ) const;
78 inline BOOL operator != ( const SalFontDimension &r ) const;
79 inline BOOL operator >= ( const SalFontDimension &r ) const;
82 inline SalFontDimension::SalFontDimension( USHORT nA, USHORT nH )
83 : nHeight_( nH ), nAverage_( nA )
84 { nPtHeight_ = nXRes_ = nYRes_ = nSlant_ = 0; }
86 inline BOOL SalFontDimension::IsScalable() const
87 { return !nHeight_ && !nPtHeight_ && !nAverage_; }
89 inline Size SalFontDimension::GetSize() const
90 { return Size( (nAverage_ + 5) / 10, nHeight_ ); }
92 inline void SalFontDimension::SetSize( const Size & rSize )
93 { nAverage_ = (USHORT)rSize.Width() * 10; nHeight_ = (USHORT)rSize.Height(); }
95 inline BOOL SalFontDimension::operator == ( const SalFontDimension &r ) const
96 { return nHeight_ == r.nHeight_ && (!r.nAverage_ || nAverage_ == r.nAverage_); }
98 inline BOOL SalFontDimension::operator != ( const SalFontDimension &r ) const
99 { return !(*this == r); }
101 inline BOOL SalFontDimension::operator >= ( const SalFontDimension &r ) const
102 { return nHeight_ > r.nHeight_
103 || (nHeight_ == r.nHeight_ && nAverage_ >= r.nAverage_); }
105 // -=-= SalFontStruct =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
106 class SalFontStruct : public ImplFontMetricData
108 friend class SalDisplay;
109 friend class SalGraphicsData;
111 SalFontCacheItem*pCache_;
113 #if (OSL_DEBUG_LEVEL > 1) || defined DBG_UTIL
114 ByteString aFontName_;
115 #endif
116 USHORT nHeightCount_; // Anzahl der Hoehen-Eintraege
117 SalFontDimension*pDimensions_; // Hoehen-Array
118 USHORT nWeight_;
120 USHORT nFoundry_; // properties indexies
121 USHORT nFamily_;
122 USHORT nWeightName_;
123 USHORT nSlant_;
124 USHORT nSetWidthName_;
125 ByteString aAddStyleName_;
126 USHORT nSpacing_;
127 USHORT nCharSet_;
128 USHORT nFaceName_;
129 BOOL mbValidFontDescription; // valid xlfd entries
131 void Init();
132 BOOL Init( SalDisplay* pDisp,
133 const char* pFontName,
134 SalFontDimension& rDim );
136 ByteString GetXFontName( const SalFontDimension& );
138 inline void SetFoundry( USHORT n )
139 { nFoundry_ = n; }
140 inline void SetFamily( USHORT n )
141 { meFamily = sal_FamilyToSal( nFamily_ = n ); }
142 inline void SetWeightName( USHORT n )
143 { meWeight = sal_WeightToSal( nWeightName_ = n ); }
144 inline void SetSlant( USHORT n )
145 { meItalic = sal_ItalicToSal( nSlant_ = n ); }
146 inline void SetSetWidthName( USHORT n )
147 { nSetWidthName_ = n; }
148 inline void SetAddStyleName( const ByteString& rAddStyle )
149 { aAddStyleName_ = rAddStyle; aAddStyleName_.ToLowerAscii(); }
150 inline void SetSpacing( USHORT n )
151 { mePitch = sal_PitchToSal( nSpacing_ = n ); }
152 inline void SetAverage( long n )
153 { mnWidth = (n + 5) / 10; }
154 void SetCharSet( USHORT n );
156 SalFontStruct( const SalFontStruct& rFont );
157 public:
158 SalFontStruct( SalDisplay* pDisp,
159 const char* pFontName,
160 SalFontDimension& rDim );
162 ~SalFontStruct();
164 inline void Cache( SalFontCacheItem *p ) { pCache_ = p; }
165 inline SalFontCacheItem*IsCache() const { return pCache_; }
166 inline BOOL IsScalable() const { return TYPE_SCALABLE==meType; }
167 inline SalFontDimension*GetDim() const { return pDimensions_; }
168 inline BOOL IsValid() const { return mbValidFontDescription; }
169 #ifdef DBG_UTIL
170 const ByteString& GetName() const { return aFontName_; }
171 #endif
173 ImplFontData *GetDevFontData();
174 SalFontCacheItem*Load( SalDisplay *pDisp, const SalFontDimension &rDim );
175 CharSet GetCharSet() { return meCharSet; }
179 // -=-= SalFontStructList =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
180 DECLARE_LIST( SalFontStructList, SalFontStruct* )
182 #endif // _SV_SALFONT_H