xref: /aoo41x/main/sw/source/core/inc/fntcache.hxx (revision 1d2dbeb0)
1*1d2dbeb0SAndrew Rist /**************************************************************
2*1d2dbeb0SAndrew Rist  *
3*1d2dbeb0SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*1d2dbeb0SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*1d2dbeb0SAndrew Rist  * distributed with this work for additional information
6*1d2dbeb0SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*1d2dbeb0SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*1d2dbeb0SAndrew Rist  * "License"); you may not use this file except in compliance
9*1d2dbeb0SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*1d2dbeb0SAndrew Rist  *
11*1d2dbeb0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*1d2dbeb0SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*1d2dbeb0SAndrew Rist  * software distributed under the License is distributed on an
15*1d2dbeb0SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*1d2dbeb0SAndrew Rist  * KIND, either express or implied.  See the License for the
17*1d2dbeb0SAndrew Rist  * specific language governing permissions and limitations
18*1d2dbeb0SAndrew Rist  * under the License.
19*1d2dbeb0SAndrew Rist  *
20*1d2dbeb0SAndrew Rist  *************************************************************/
21*1d2dbeb0SAndrew Rist 
22*1d2dbeb0SAndrew Rist 
23cdf0e10cSrcweir #ifndef _FNTCACHE_HXX
24cdf0e10cSrcweir #define _FNTCACHE_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <vcl/font.hxx>
27cdf0e10cSrcweir #include <tools/mempool.hxx>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include "swtypes.hxx"
30cdf0e10cSrcweir #include "swcache.hxx"
31cdf0e10cSrcweir 
32cdf0e10cSrcweir class Printer;
33cdf0e10cSrcweir class OutputDevice;
34cdf0e10cSrcweir class FontMetric;
35cdf0e10cSrcweir class SwFntObj;
36cdf0e10cSrcweir class SwDrawTextInfo;	// DrawText
37cdf0e10cSrcweir class ViewShell;
38cdf0e10cSrcweir class SwSubFont;
39cdf0e10cSrcweir class MapMode;
40cdf0e10cSrcweir 
41cdf0e10cSrcweir /*************************************************************************
42cdf0e10cSrcweir  *                      class SwFntCache
43cdf0e10cSrcweir  *************************************************************************/
44cdf0e10cSrcweir 
45cdf0e10cSrcweir class SwFntCache : public SwCache
46cdf0e10cSrcweir {
47cdf0e10cSrcweir public:
48cdf0e10cSrcweir 
SwFntCache()49cdf0e10cSrcweir 	inline SwFntCache() : SwCache(50,50
50cdf0e10cSrcweir #ifdef DBG_UTIL
51cdf0e10cSrcweir 	, ByteString( RTL_CONSTASCII_STRINGPARAM(
52cdf0e10cSrcweir 						"Globaler Font-Cache pFntCache" ))
53cdf0e10cSrcweir #endif
54cdf0e10cSrcweir 	) {}
55cdf0e10cSrcweir 
First()56cdf0e10cSrcweir 	inline SwFntObj *First( ) { return (SwFntObj *)SwCache::First(); }
Next(SwFntObj * pFntObj)57cdf0e10cSrcweir 	inline SwFntObj *Next( SwFntObj *pFntObj)
58cdf0e10cSrcweir 		{ return (SwFntObj *)SwCache::Next( (SwCacheObj *)pFntObj ); }
59cdf0e10cSrcweir 	void Flush();
60cdf0e10cSrcweir };
61cdf0e10cSrcweir 
62cdf0e10cSrcweir // Font-Cache, globale Variable, in txtinit.Cxx angelegt/zerstoert
63cdf0e10cSrcweir extern SwFntCache *pFntCache;
64cdf0e10cSrcweir extern SwFntObj *pLastFont;
65cdf0e10cSrcweir extern sal_uInt8 *pMagicNo;
66cdf0e10cSrcweir extern Color *pWaveCol;
67cdf0e10cSrcweir 
68cdf0e10cSrcweir /*************************************************************************
69cdf0e10cSrcweir  *                      class SwFntObj
70cdf0e10cSrcweir  *************************************************************************/
71cdf0e10cSrcweir 
72cdf0e10cSrcweir class SwFntObj : public SwCacheObj
73cdf0e10cSrcweir {
74cdf0e10cSrcweir 	friend class SwFntAccess;
75cdf0e10cSrcweir 	friend void _InitCore();
76cdf0e10cSrcweir 	friend void _FinitCore();
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 	Font aFont;
79cdf0e10cSrcweir 	Font *pScrFont;
80cdf0e10cSrcweir 	Font *pPrtFont;
81cdf0e10cSrcweir     OutputDevice* pPrinter;
82cdf0e10cSrcweir     sal_uInt16 nGuessedLeading;
83cdf0e10cSrcweir     sal_uInt16 nExtLeading;
84cdf0e10cSrcweir 	sal_uInt16 nScrAscent;
85cdf0e10cSrcweir 	sal_uInt16 nPrtAscent;
86cdf0e10cSrcweir 	sal_uInt16 nScrHeight;
87cdf0e10cSrcweir 	sal_uInt16 nPrtHeight;
88cdf0e10cSrcweir 	sal_uInt16 nPropWidth;
89cdf0e10cSrcweir 	sal_uInt16 nZoom;
90cdf0e10cSrcweir 	sal_Bool bSymbol : 1;
91cdf0e10cSrcweir 	sal_Bool bPaintBlank : 1;
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 	static long nPixWidth;
94cdf0e10cSrcweir 	static MapMode *pPixMap;
95cdf0e10cSrcweir 	static OutputDevice *pPixOut;
96cdf0e10cSrcweir 
97cdf0e10cSrcweir     // SMARTTAGS
98cdf0e10cSrcweir     void calcLinePos(SwDrawTextInfo& rInf, Point& aStart, Point& aEnd, xub_StrLen nStart,
99cdf0e10cSrcweir        xub_StrLen nWrLen, xub_StrLen nCnt, const sal_Bool bSwitchH2V, const sal_Bool bSwitchL2R,
100cdf0e10cSrcweir        long nHalfSpace, long* pKernArray, const sal_Bool bBidiPor);
101cdf0e10cSrcweir 
102cdf0e10cSrcweir public:
103cdf0e10cSrcweir 	DECL_FIXEDMEMPOOL_NEWDEL(SwFntObj)
104cdf0e10cSrcweir 
105cdf0e10cSrcweir 	SwFntObj( const SwSubFont &rFont, const void* pOwner,
106cdf0e10cSrcweir 			  ViewShell *pSh );
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 	virtual ~SwFntObj();
109cdf0e10cSrcweir 
GetScrFont()110cdf0e10cSrcweir 	inline 		 Font *GetScrFont()		{ return pScrFont; }
GetFont()111cdf0e10cSrcweir 	inline 		 Font *GetFont()		{ return &aFont; }
GetFont() const112cdf0e10cSrcweir 	inline const Font *GetFont() const  { return &aFont; }
113cdf0e10cSrcweir 
GetGuessedLeading() const114cdf0e10cSrcweir     inline sal_uInt16 GetGuessedLeading() const  { return nGuessedLeading; }
GetExtLeading() const115cdf0e10cSrcweir     inline sal_uInt16 GetExtLeading() const  { return nExtLeading; }
116cdf0e10cSrcweir 
117cdf0e10cSrcweir     sal_uInt16 GetFontAscent( const ViewShell *pSh, const OutputDevice& rOut );
118cdf0e10cSrcweir     sal_uInt16 GetFontHeight( const ViewShell *pSh, const OutputDevice& rOut );
119cdf0e10cSrcweir     sal_uInt16 GetFontLeading( const ViewShell *pSh, const OutputDevice& rOut );
120cdf0e10cSrcweir 
121cdf0e10cSrcweir     void GuessLeading( const ViewShell& rSh, const FontMetric& rMet );
122cdf0e10cSrcweir 
123cdf0e10cSrcweir     void SetDevFont( const ViewShell *pSh, OutputDevice& rOut );
GetPrt() const124cdf0e10cSrcweir     inline OutputDevice* GetPrt() const { return pPrinter; }
GetZoom() const125cdf0e10cSrcweir 	inline sal_uInt16	GetZoom() const { return nZoom; }
GetPropWidth() const126cdf0e10cSrcweir 	inline sal_uInt16	GetPropWidth() const { return nPropWidth; }
IsSymbol() const127cdf0e10cSrcweir 	inline sal_Bool		IsSymbol() const { return bSymbol; }
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 	void   DrawText( SwDrawTextInfo &rInf );
130cdf0e10cSrcweir 	Size  GetTextSize( SwDrawTextInfo &rInf );
131cdf0e10cSrcweir 	xub_StrLen GetCrsrOfst( SwDrawTextInfo &rInf );
132cdf0e10cSrcweir 
133cdf0e10cSrcweir     void CreateScrFont( const ViewShell& rSh, const OutputDevice& rOut );
134cdf0e10cSrcweir     void CreatePrtFont( const OutputDevice& rOut );
135cdf0e10cSrcweir };
136cdf0e10cSrcweir 
137cdf0e10cSrcweir /*************************************************************************
138cdf0e10cSrcweir  *                      class SwFntAccess
139cdf0e10cSrcweir  *************************************************************************/
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 
142cdf0e10cSrcweir class SwFntAccess : public SwCacheAccess
143cdf0e10cSrcweir {
144cdf0e10cSrcweir 	ViewShell *pShell;
145cdf0e10cSrcweir protected:
146cdf0e10cSrcweir 	virtual SwCacheObj *NewObj( );
147cdf0e10cSrcweir 
148cdf0e10cSrcweir public:
149cdf0e10cSrcweir 	SwFntAccess( const void * &rMagic, sal_uInt16 &rIndex, const void *pOwner,
150cdf0e10cSrcweir 				 ViewShell *pShell,
151cdf0e10cSrcweir 				 sal_Bool bCheck = sal_False  );
Get()152cdf0e10cSrcweir     inline SwFntObj* Get() { return (SwFntObj*) SwCacheAccess::Get(); };
153cdf0e10cSrcweir };
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 
156cdf0e10cSrcweir #endif
157