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 INCLUDED_SW_SOURCE_CORE_INC_FNTCACHE_HXX
21 : #define INCLUDED_SW_SOURCE_CORE_INC_FNTCACHE_HXX
22 :
23 : #include <vcl/font.hxx>
24 : #include <vcl/vclptr.hxx>
25 : #include <tools/mempool.hxx>
26 : #include "swtypes.hxx"
27 : #include "swcache.hxx"
28 :
29 : class OutputDevice;
30 : class FontMetric;
31 : class SwFntObj;
32 : class SwDrawTextInfo;
33 : class SwViewShell;
34 : class SwSubFont;
35 : class MapMode;
36 : class Point;
37 :
38 59 : class SwFntCache : public SwCache
39 : {
40 : public:
41 59 : inline SwFntCache() : SwCache(50
42 : #ifdef DBG_UTIL
43 : , OString(RTL_CONSTASCII_STRINGPARAM("Global Font-Cache pFntCache"))
44 : #endif
45 59 : ) {}
46 :
47 : inline SwFntObj *First( );
48 : static inline SwFntObj *Next( SwFntObj *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 : vcl::Font aFont;
65 : vcl::Font *pScrFont;
66 : vcl::Font *pPrtFont;
67 : VclPtr<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 : bool bSymbol : 1;
77 : bool bPaintBlank : 1;
78 :
79 : static long nPixWidth;
80 : static MapMode *pPixMap;
81 : static VclPtr<OutputDevice> pPixOut;
82 :
83 : void calcLinePos(SwDrawTextInfo& rInf, Point& aStart, Point& aEnd, sal_Int32 nStart,
84 : sal_Int32 nWrLen, sal_Int32 nCnt, const bool bSwitchH2V, const bool bSwitchL2R,
85 : long nHalfSpace, long* pKernArray, const bool bBidiPor);
86 :
87 : public:
88 15486 : DECL_FIXEDMEMPOOL_NEWDEL(SwFntObj)
89 :
90 : SwFntObj( const SwSubFont &rFont, const void* pOwner,
91 : SwViewShell const *pSh );
92 :
93 : virtual ~SwFntObj();
94 :
95 30330 : inline vcl::Font *GetScrFont() { return pScrFont; }
96 6583 : inline vcl::Font& GetFont() { return aFont; }
97 : inline const vcl::Font& GetFont() const { return aFont; }
98 :
99 : inline sal_uInt16 GetGuessedLeading() const { return nGuessedLeading; }
100 : inline sal_uInt16 GetExtLeading() const { return nExtLeading; }
101 :
102 : sal_uInt16 GetFontAscent( const SwViewShell *pSh, const OutputDevice& rOut );
103 : sal_uInt16 GetFontHeight( const SwViewShell *pSh, const OutputDevice& rOut );
104 : sal_uInt16 GetFontLeading( const SwViewShell *pSh, const OutputDevice& rOut );
105 :
106 : void GuessLeading( const SwViewShell& rSh, const FontMetric& rMet );
107 :
108 : void SetDevFont( const SwViewShell *pSh, OutputDevice& rOut );
109 220 : inline OutputDevice* GetPrt() const { return pPrinter; }
110 605003 : inline sal_uInt16 GetZoom() const { return nZoom; }
111 581783 : inline sal_uInt16 GetPropWidth() const { return nPropWidth; }
112 0 : inline bool IsSymbol() const { return bSymbol; }
113 :
114 : void DrawText( SwDrawTextInfo &rInf );
115 : /// determine the TextSize (of the printer)
116 : Size GetTextSize( SwDrawTextInfo &rInf );
117 : sal_Int32 GetCrsrOfst( SwDrawTextInfo &rInf );
118 :
119 : void CreateScrFont( const SwViewShell& rSh, const OutputDevice& rOut );
120 : void CreatePrtFont( const OutputDevice& rOut );
121 : };
122 :
123 162190 : SwFntObj *SwFntCache::First( )
124 : {
125 162190 : return static_cast<SwFntObj *>(SwCache::First());
126 : }
127 :
128 155295 : SwFntObj *SwFntCache::Next( SwFntObj *pFntObj)
129 : {
130 155295 : return static_cast<SwFntObj *>(SwCache::Next( pFntObj ));
131 : }
132 :
133 1142911 : class SwFntAccess : public SwCacheAccess
134 : {
135 : SwViewShell const *pShell;
136 : protected:
137 : virtual SwCacheObj *NewObj( ) SAL_OVERRIDE;
138 :
139 : public:
140 : SwFntAccess( const void * &rMagic, sal_uInt16 &rIndex, const void *pOwner,
141 : SwViewShell const *pShell,
142 : bool bCheck = false );
143 1557588 : inline SwFntObj* Get() { return static_cast<SwFntObj*>( SwCacheAccess::Get() ); }
144 : };
145 :
146 : #endif
147 :
148 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|