update dev300-m58
[ooovba.git] / sw / source / core / inc / fntcache.hxx
blob740ef9b992353011dc9c0e803ed03f2cea252336
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: fntcache.hxx,v $
10 * $Revision: 1.13 $
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 _FNTCACHE_HXX
31 #define _FNTCACHE_HXX
33 #include <vcl/font.hxx>
34 #include <tools/mempool.hxx>
36 #include "swtypes.hxx"
37 #include "swcache.hxx"
39 class Printer;
40 class OutputDevice;
41 class FontMetric;
42 class SwFntObj;
43 class SwDrawTextInfo; // DrawText
44 class ViewShell;
45 class SwSubFont;
46 class MapMode;
48 /*************************************************************************
49 * class SwFntCache
50 *************************************************************************/
52 class SwFntCache : public SwCache
54 public:
56 inline SwFntCache() : SwCache(50,50
57 #ifndef PRODUCT
58 , ByteString( RTL_CONSTASCII_STRINGPARAM(
59 "Globaler Font-Cache pFntCache" ))
60 #endif
61 ) {}
63 inline SwFntObj *First( ) { return (SwFntObj *)SwCache::First(); }
64 inline SwFntObj *Next( SwFntObj *pFntObj)
65 { return (SwFntObj *)SwCache::Next( (SwCacheObj *)pFntObj ); }
66 void Flush();
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 /*************************************************************************
76 * class SwFntObj
77 *************************************************************************/
79 class SwFntObj : public SwCacheObj
81 friend class SwFntAccess;
82 friend void _InitCore();
83 friend void _FinitCore();
85 Font aFont;
86 Font *pScrFont;
87 Font *pPrtFont;
88 OutputDevice* pPrinter;
89 USHORT nGuessedLeading;
90 USHORT nExtLeading;
91 USHORT nScrAscent;
92 USHORT nPrtAscent;
93 USHORT nScrHeight;
94 USHORT nPrtHeight;
95 USHORT nPropWidth;
96 USHORT nZoom;
97 BOOL bSymbol : 1;
98 BOOL bPaintBlank : 1;
100 static long nPixWidth;
101 static MapMode *pPixMap;
102 static OutputDevice *pPixOut;
104 // SMARTTAGS
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);
109 public:
110 DECL_FIXEDMEMPOOL_NEWDEL(SwFntObj)
112 SwFntObj( const SwSubFont &rFont, const void* pOwner,
113 ViewShell *pSh );
115 virtual ~SwFntObj();
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 /*************************************************************************
145 * class SwFntAccess
146 *************************************************************************/
149 class SwFntAccess : public SwCacheAccess
151 ViewShell *pShell;
152 protected:
153 virtual SwCacheObj *NewObj( );
155 public:
156 SwFntAccess( const void * &rMagic, USHORT &rIndex, const void *pOwner,
157 ViewShell *pShell,
158 BOOL bCheck = FALSE );
159 inline SwFntObj* Get() { return (SwFntObj*) SwCacheAccess::Get(); };
163 #endif