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 <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 SwViewShell;
33 : class SwSubFont;
34 : class MapMode;
35 : class Point;
36 :
37 0 : class SwFntCache : public SwCache
38 : {
39 : public:
40 0 : inline SwFntCache() : SwCache(50
41 : #ifdef DBG_UTIL
42 : , OString(RTL_CONSTASCII_STRINGPARAM("Global Font-Cache pFntCache"))
43 : #endif
44 0 : ) {}
45 :
46 0 : inline SwFntObj *First( ) { return (SwFntObj *)SwCache::First(); }
47 0 : inline SwFntObj *Next( SwFntObj *pFntObj)
48 0 : { 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 : void calcLinePos(SwDrawTextInfo& rInf, Point& aStart, Point& aEnd, sal_Int32 nStart,
84 : sal_Int32 nWrLen, sal_Int32 nCnt, const sal_Bool bSwitchH2V, const sal_Bool bSwitchL2R,
85 : long nHalfSpace, long* pKernArray, const sal_Bool bBidiPor);
86 :
87 : public:
88 0 : DECL_FIXEDMEMPOOL_NEWDEL(SwFntObj)
89 :
90 : SwFntObj( const SwSubFont &rFont, const void* pOwner,
91 : SwViewShell *pSh );
92 :
93 : virtual ~SwFntObj();
94 :
95 0 : inline Font *GetScrFont() { return pScrFont; }
96 0 : inline Font *GetFont() { return &aFont; }
97 : inline const 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 0 : inline OutputDevice* GetPrt() const { return pPrinter; }
110 0 : inline sal_uInt16 GetZoom() const { return nZoom; }
111 0 : inline sal_uInt16 GetPropWidth() const { return nPropWidth; }
112 0 : inline sal_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 0 : class SwFntAccess : public SwCacheAccess
124 : {
125 : SwViewShell *pShell;
126 : protected:
127 : virtual SwCacheObj *NewObj( ) SAL_OVERRIDE;
128 :
129 : public:
130 : SwFntAccess( const void * &rMagic, sal_uInt16 &rIndex, const void *pOwner,
131 : SwViewShell *pShell,
132 : sal_Bool bCheck = sal_False );
133 0 : inline SwFntObj* Get() { return (SwFntObj*) SwCacheAccess::Get(); };
134 : };
135 :
136 : #endif
137 :
138 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|