Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _FNTCACHE_HXX
30 : : #define _FNTCACHE_HXX
31 : :
32 : : #include <vcl/font.hxx>
33 : : #include <tools/mempool.hxx>
34 : : #include "swtypes.hxx"
35 : : #include "swcache.hxx"
36 : :
37 : : class OutputDevice;
38 : : class FontMetric;
39 : : class SwFntObj;
40 : : class SwDrawTextInfo;
41 : : class ViewShell;
42 : : class SwSubFont;
43 : : class MapMode;
44 : :
45 : 73 : class SwFntCache : public SwCache
46 : : {
47 : : public:
48 : 73 : inline SwFntCache() : SwCache(50
49 : : #ifdef DBG_UTIL
50 : : , rtl::OString(RTL_CONSTASCII_STRINGPARAM("Global Font-Cache pFntCache"))
51 : : #endif
52 : 73 : ) {}
53 : :
54 : 21127 : inline SwFntObj *First( ) { return (SwFntObj *)SwCache::First(); }
55 : 25966 : inline SwFntObj *Next( SwFntObj *pFntObj)
56 : 25966 : { return (SwFntObj *)SwCache::Next( (SwCacheObj *)pFntObj ); }
57 : : void Flush();
58 : : };
59 : :
60 : : // Font cache, global variable, created/destroyed in txtinit.cxx
61 : : extern SwFntCache *pFntCache;
62 : : extern SwFntObj *pLastFont;
63 : : extern sal_uInt8 *pMagicNo;
64 : : extern Color *pWaveCol;
65 : :
66 : : class SwFntObj : public SwCacheObj
67 : : {
68 : : friend class SwFntAccess;
69 : : friend void _InitCore();
70 : : friend void _FinitCore();
71 : :
72 : : Font aFont;
73 : : Font *pScrFont;
74 : : Font *pPrtFont;
75 : : OutputDevice* pPrinter;
76 : : sal_uInt16 nGuessedLeading;
77 : : sal_uInt16 nExtLeading;
78 : : sal_uInt16 nScrAscent;
79 : : sal_uInt16 nPrtAscent;
80 : : sal_uInt16 nScrHeight;
81 : : sal_uInt16 nPrtHeight;
82 : : sal_uInt16 nPropWidth;
83 : : sal_uInt16 nZoom;
84 : : sal_Bool bSymbol : 1;
85 : : sal_Bool bPaintBlank : 1;
86 : :
87 : : static long nPixWidth;
88 : : static MapMode *pPixMap;
89 : : static OutputDevice *pPixOut;
90 : :
91 : : // SMARTTAGS
92 : : void calcLinePos(SwDrawTextInfo& rInf, Point& aStart, Point& aEnd, xub_StrLen nStart,
93 : : xub_StrLen nWrLen, xub_StrLen nCnt, const sal_Bool bSwitchH2V, const sal_Bool bSwitchL2R,
94 : : long nHalfSpace, long* pKernArray, const sal_Bool bBidiPor);
95 : :
96 : : public:
97 [ + - ][ + - ]: 4576 : DECL_FIXEDMEMPOOL_NEWDEL(SwFntObj)
98 : :
99 : : SwFntObj( const SwSubFont &rFont, const void* pOwner,
100 : : ViewShell *pSh );
101 : :
102 : : virtual ~SwFntObj();
103 : :
104 : 35093 : inline Font *GetScrFont() { return pScrFont; }
105 : 22705 : inline Font *GetFont() { return &aFont; }
106 : : inline const Font *GetFont() const { return &aFont; }
107 : :
108 : : inline sal_uInt16 GetGuessedLeading() const { return nGuessedLeading; }
109 : : inline sal_uInt16 GetExtLeading() const { return nExtLeading; }
110 : :
111 : : sal_uInt16 GetFontAscent( const ViewShell *pSh, const OutputDevice& rOut );
112 : : sal_uInt16 GetFontHeight( const ViewShell *pSh, const OutputDevice& rOut );
113 : : sal_uInt16 GetFontLeading( const ViewShell *pSh, const OutputDevice& rOut );
114 : :
115 : : void GuessLeading( const ViewShell& rSh, const FontMetric& rMet );
116 : :
117 : : void SetDevFont( const ViewShell *pSh, OutputDevice& rOut );
118 : 7 : inline OutputDevice* GetPrt() const { return pPrinter; }
119 : 316779 : inline sal_uInt16 GetZoom() const { return nZoom; }
120 : 310826 : inline sal_uInt16 GetPropWidth() const { return nPropWidth; }
121 : 0 : inline sal_Bool IsSymbol() const { return bSymbol; }
122 : :
123 : : void DrawText( SwDrawTextInfo &rInf );
124 : : Size GetTextSize( SwDrawTextInfo &rInf );
125 : : xub_StrLen GetCrsrOfst( SwDrawTextInfo &rInf );
126 : :
127 : : void CreateScrFont( const ViewShell& rSh, const OutputDevice& rOut );
128 : : void CreatePrtFont( const OutputDevice& rOut );
129 : : };
130 : :
131 [ - + ]: 547191 : class SwFntAccess : public SwCacheAccess
132 : : {
133 : : ViewShell *pShell;
134 : : protected:
135 : : virtual SwCacheObj *NewObj( );
136 : :
137 : : public:
138 : : SwFntAccess( const void * &rMagic, sal_uInt16 &rIndex, const void *pOwner,
139 : : ViewShell *pShell,
140 : : sal_Bool bCheck = sal_False );
141 : 846130 : inline SwFntObj* Get() { return (SwFntObj*) SwCacheAccess::Get(); };
142 : : };
143 : :
144 : : #endif
145 : :
146 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|