1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fntcache.hxx,v $
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 ************************************************************************/
33 #include <vcl/font.hxx>
34 #include <tools/mempool.hxx>
36 #include "swtypes.hxx"
37 #include "swcache.hxx"
43 class SwDrawTextInfo
; // DrawText
48 /*************************************************************************
50 *************************************************************************/
52 class SwFntCache
: public SwCache
56 inline SwFntCache() : SwCache(50,50
58 , ByteString( RTL_CONSTASCII_STRINGPARAM(
59 "Globaler Font-Cache pFntCache" ))
63 inline SwFntObj
*First( ) { return (SwFntObj
*)SwCache::First(); }
64 inline SwFntObj
*Next( SwFntObj
*pFntObj
)
65 { return (SwFntObj
*)SwCache::Next( (SwCacheObj
*)pFntObj
); }
69 // Font-Cache, globale Variable, in txtinit.Cxx angelegt/zerstoert
70 extern SwFntCache
*pFntCache
;
71 extern SwFntObj
*pLastFont
;
72 extern BYTE
*pMagicNo
;
73 extern Color
*pWaveCol
;
75 /*************************************************************************
77 *************************************************************************/
79 class SwFntObj
: public SwCacheObj
81 friend class SwFntAccess
;
82 friend void _InitCore();
83 friend void _FinitCore();
88 OutputDevice
* pPrinter
;
89 USHORT nGuessedLeading
;
100 static long nPixWidth
;
101 static MapMode
*pPixMap
;
102 static OutputDevice
*pPixOut
;
105 void calcLinePos(SwDrawTextInfo
& rInf
, Point
& aStart
, Point
& aEnd
, xub_StrLen nStart
,
106 xub_StrLen nWrLen
, xub_StrLen nCnt
, const BOOL bSwitchH2V
, const BOOL bSwitchL2R
,
107 long nHalfSpace
, long* pKernArray
, const BOOL bBidiPor
);
110 DECL_FIXEDMEMPOOL_NEWDEL(SwFntObj
)
112 SwFntObj( const SwSubFont
&rFont
, const void* pOwner
,
117 inline Font
*GetScrFont() { return pScrFont
; }
118 inline Font
*GetFont() { return &aFont
; }
119 inline const Font
*GetFont() const { return &aFont
; }
121 inline USHORT
GetGuessedLeading() const { return nGuessedLeading
; }
122 inline USHORT
GetExtLeading() const { return nExtLeading
; }
124 USHORT
GetFontAscent( const ViewShell
*pSh
, const OutputDevice
& rOut
);
125 USHORT
GetFontHeight( const ViewShell
*pSh
, const OutputDevice
& rOut
);
126 USHORT
GetFontLeading( const ViewShell
*pSh
, const OutputDevice
& rOut
);
128 void GuessLeading( const ViewShell
& rSh
, const FontMetric
& rMet
);
130 void SetDevFont( const ViewShell
*pSh
, OutputDevice
& rOut
);
131 inline OutputDevice
* GetPrt() const { return pPrinter
; }
132 inline USHORT
GetZoom() const { return nZoom
; }
133 inline USHORT
GetPropWidth() const { return nPropWidth
; }
134 inline BOOL
IsSymbol() const { return bSymbol
; }
136 void DrawText( SwDrawTextInfo
&rInf
);
137 Size
GetTextSize( SwDrawTextInfo
&rInf
);
138 xub_StrLen
GetCrsrOfst( SwDrawTextInfo
&rInf
);
140 void CreateScrFont( const ViewShell
& rSh
, const OutputDevice
& rOut
);
141 void CreatePrtFont( const OutputDevice
& rOut
);
144 /*************************************************************************
146 *************************************************************************/
149 class SwFntAccess
: public SwCacheAccess
153 virtual SwCacheObj
*NewObj( );
156 SwFntAccess( const void * &rMagic
, USHORT
&rIndex
, const void *pOwner
,
158 BOOL bCheck
= FALSE
);
159 inline SwFntObj
* Get() { return (SwFntObj
*) SwCacheAccess::Get(); };