merge the formfield patch from ooo-build
[ooovba.git] / vcl / unx / inc / xfont.hxx
blobfbb73b4322f2e5d77690127d6d93548ce2b46711
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: xfont.hxx,v $
10 * $Revision: 1.19 $
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 EXTENDED_FONTSTRUCT_HXX
31 #define EXTENDED_FONTSTRUCT_HXX
33 #ifndef _XLIB_H_
34 #include <tools/prex.h>
35 #include <X11/Xlib.h>
36 #include <tools/postx.h>
37 #endif
38 #include <tools/ref.hxx>
39 #include <rtl/tencinfo.h>
40 #include <vcl/vclenum.hxx>
41 #include <vcl/sallayout.hxx>
43 typedef unsigned short sal_MultiByte;
45 class ImplFontMetricData;
46 class ExtendedXlfd;
48 struct VerticalTextItem
50 BOOL mbFixed;
51 XFontStruct* mpXFontStruct;
52 const sal_Unicode* mpString;
53 int mnLength;
54 int mnTransX;
55 int mnTransY;
56 int mnFixedAdvance;
57 int* mpAdvanceAry;
59 VerticalTextItem( XFontStruct* pXFontStruct,
60 const sal_Unicode* pString,
61 int nLength,
62 int nTransX,
63 int nTransY,
64 int nFixedAdvance )
65 : mbFixed( TRUE ),
66 mpXFontStruct( pXFontStruct ),
67 mpString( pString ),
68 mnLength( nLength ),
69 mnTransX( nTransX ),
70 mnTransY( nTransY ),
71 mnFixedAdvance( nFixedAdvance )
74 VerticalTextItem( XFontStruct* pXFontStruct,
75 const sal_Unicode* pString,
76 int nLength,
77 int nTransX,
78 int nTransY,
79 int* pAdvanceAry )
80 : mbFixed( FALSE ),
81 mpXFontStruct( pXFontStruct ),
82 mpString( pString ),
83 mnLength( nLength ),
84 mnTransX( nTransX ),
85 mnTransY( nTransY ),
86 mpAdvanceAry( pAdvanceAry )
89 ~VerticalTextItem()
91 if (!mbFixed)
93 delete( mpAdvanceAry );
98 class ExtendedFontStruct : public SvRefBase
100 private:
101 Display* mpDisplay;
102 Size maPixelSize;
103 float mfXScale;
104 float mfYScale;
105 sal_Size mnDefaultWidth;
106 sal_Bool mbVertical;
107 rtl_TextEncoding mnCachedEncoding;
108 rtl_TextEncoding mnAsciiEncoding;
110 ExtendedXlfd* mpXlfd;
111 XFontStruct** mpXFontStruct;
113 // unicode range cache
114 mutable sal_uInt32* mpRangeCodes;
115 mutable int mnRangeCount;
117 int LoadEncoding( rtl_TextEncoding nEncoding );
118 FontPitch GetSpacing( rtl_TextEncoding nEncoding );
119 bool GetFontBoundingBox( XCharStruct *pCharStruct,
120 int *pAscent, int *pDescent ) ;
122 sal_Size GetDefaultWidth();
123 sal_Size GetCharWidth8( sal_Unicode nFrom, sal_Unicode nTo,
124 sal_Int32 *pWidthArray,
125 rtl_TextEncoding nEncoding );
126 sal_Size GetCharWidthUTF16( sal_Unicode nFrom, sal_Unicode nTo,
127 sal_Int32 *pWidthArray );
128 sal_Size GetCharWidth16( sal_Unicode nFrom, sal_Unicode nTo,
129 sal_Int32 *pWidthArray, ExtendedFontStruct *pFallback );
130 public:
131 ExtendedFontStruct( Display* pDisplay,
132 const Size& rPixelSize, sal_Bool bVertical,
133 ExtendedXlfd* pXlfd );
134 ~ExtendedFontStruct();
135 bool Match( const ExtendedXlfd *pXlfd,
136 const Size& rPixelSize, sal_Bool bVertical ) const;
137 XFontStruct* GetFontStruct( rtl_TextEncoding nEncoding );
138 XFontStruct* GetFontStruct( sal_Unicode nChar,
139 rtl_TextEncoding *pEncoding );
140 bool ToImplFontMetricData( ImplFontMetricData *pMetric );
141 rtl_TextEncoding GetAsciiEncoding( int *pAsciiRange = NULL ) const;
142 sal_Size GetCharWidth( sal_Unicode,
143 sal_Int32* pPhysWidth, sal_Int32* pLogWidth );
144 int GetFontCodeRanges( sal_uInt32* pCodePairs ) const;
145 bool HasUnicodeChar( sal_Unicode ) const;
148 // Declaration and Implementation for ExtendedFontStructRef: Add RefCounting
149 // to ExtendedFontStruct (it's not possible to separate decl and impl into
150 // a separate source file: all ref member functions are inline
151 SV_DECL_IMPL_REF( ExtendedFontStruct );
153 class X11FontLayout : public GenericSalLayout
155 public:
156 X11FontLayout( ExtendedFontStruct& );
157 virtual bool LayoutText( ImplLayoutArgs& );
158 virtual void AdjustLayout( ImplLayoutArgs& );
159 virtual void DrawText( SalGraphics& ) const;
161 private:
162 ExtendedFontStruct& mrFont;
165 #endif /* EXTENDED_FONTSTRUCT_HXX */