Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef _FNTCACHE_HXX
21 : #define _FNTCACHE_HXX
22 :
23 : #include <vcl/font.hxx>
24 : #include <tools/mempool.hxx>
25 : #include "swtypes.hxx"
26 : #include "swcache.hxx"
27 :
28 : class OutputDevice;
29 : class FontMetric;
30 : class SwFntObj;
31 : class SwDrawTextInfo;
32 : class ViewShell;
33 : class SwSubFont;
34 : class MapMode;
35 : class Point;
36 :
37 33 : class SwFntCache : public SwCache
38 : {
39 : public:
40 33 : inline SwFntCache() : SwCache(50
41 : #ifdef DBG_UTIL
42 : , OString(RTL_CONSTASCII_STRINGPARAM("Global Font-Cache pFntCache"))
43 : #endif
44 33 : ) {}
45 :
46 17816 : inline SwFntObj *First( ) { return (SwFntObj *)SwCache::First(); }
47 18997 : inline SwFntObj *Next( SwFntObj *pFntObj)
48 18997 : { return (SwFntObj *)SwCache::Next( (SwCacheObj *)pFntObj ); }
49 : void Flush();
50 : };
51 :
52 : // Font cache, global variable, created/destroyed in txtinit.cxx
53 : extern SwFntCache *pFntCache;
54 : extern SwFntObj *pLastFont;
55 : extern sal_uInt8 *pMagicNo;
56 : extern Color *pWaveCol;
57 :
58 : class SwFntObj : public SwCacheObj
59 : {
60 : friend class SwFntAccess;
61 : friend void _InitCore();
62 : friend void _FinitCore();
63 :
64 : Font aFont;
65 : Font *pScrFont;
66 : Font *pPrtFont;
67 : OutputDevice* pPrinter;
68 : sal_uInt16 nGuessedLeading;
69 : sal_uInt16 nExtLeading;
70 : sal_uInt16 nScrAscent;
71 : sal_uInt16 nPrtAscent;
72 : sal_uInt16 nScrHeight;
73 : sal_uInt16 nPrtHeight;
74 : sal_uInt16 nPropWidth;
75 : sal_uInt16 nZoom;
76 : sal_Bool bSymbol : 1;
77 : sal_Bool bPaintBlank : 1;
78 :
79 : static long nPixWidth;
80 : static MapMode *pPixMap;
81 : static OutputDevice *pPixOut;
82 :
83 : // SMARTTAGS
84 : void calcLinePos(SwDrawTextInfo& rInf, Point& aStart, Point& aEnd, xub_StrLen nStart,
85 : xub_StrLen nWrLen, xub_StrLen nCnt, const sal_Bool bSwitchH2V, const sal_Bool bSwitchL2R,
86 : long nHalfSpace, long* pKernArray, const sal_Bool bBidiPor);
87 :
88 : public:
89 3052 : DECL_FIXEDMEMPOOL_NEWDEL(SwFntObj)
90 :
91 : SwFntObj( const SwSubFont &rFont, const void* pOwner,
92 : ViewShell *pSh );
93 :
94 : virtual ~SwFntObj();
95 :
96 15120 : inline Font *GetScrFont() { return pScrFont; }
97 5990 : inline Font *GetFont() { return &aFont; }
98 : inline const Font *GetFont() const { return &aFont; }
99 :
100 : inline sal_uInt16 GetGuessedLeading() const { return nGuessedLeading; }
101 : inline sal_uInt16 GetExtLeading() const { return nExtLeading; }
102 :
103 : sal_uInt16 GetFontAscent( const ViewShell *pSh, const OutputDevice& rOut );
104 : sal_uInt16 GetFontHeight( const ViewShell *pSh, const OutputDevice& rOut );
105 : sal_uInt16 GetFontLeading( const ViewShell *pSh, const OutputDevice& rOut );
106 :
107 : void GuessLeading( const ViewShell& rSh, const FontMetric& rMet );
108 :
109 : void SetDevFont( const ViewShell *pSh, OutputDevice& rOut );
110 15 : inline OutputDevice* GetPrt() const { return pPrinter; }
111 154037 : inline sal_uInt16 GetZoom() const { return nZoom; }
112 150220 : inline sal_uInt16 GetPropWidth() const { return nPropWidth; }
113 0 : inline sal_Bool IsSymbol() const { return bSymbol; }
114 :
115 : void DrawText( SwDrawTextInfo &rInf );
116 : /// determine the TextSize (of the printer)
117 : Size GetTextSize( SwDrawTextInfo &rInf );
118 : xub_StrLen GetCrsrOfst( SwDrawTextInfo &rInf );
119 :
120 : void CreateScrFont( const ViewShell& rSh, const OutputDevice& rOut );
121 : void CreatePrtFont( const OutputDevice& rOut );
122 : };
123 :
124 269411 : class SwFntAccess : public SwCacheAccess
125 : {
126 : ViewShell *pShell;
127 : protected:
128 : virtual SwCacheObj *NewObj( );
129 :
130 : public:
131 : SwFntAccess( const void * &rMagic, sal_uInt16 &rIndex, const void *pOwner,
132 : ViewShell *pShell,
133 : sal_Bool bCheck = sal_False );
134 408683 : inline SwFntObj* Get() { return (SwFntObj*) SwCacheAccess::Get(); };
135 : };
136 :
137 : #endif
138 :
139 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|