LibreOffice Module sw (master)  1
fntcache.hxx
Go to the documentation of this file.
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 <sal/config.h>
24 
25 #include <cstdint>
26 #include <unordered_map>
27 
28 #include <vcl/font.hxx>
29 #include <vcl/glyphitem.hxx>
30 #include <vcl/vclptr.hxx>
31 #include <vcl/outdev.hxx>
32 #include "swcache.hxx"
33 #include "TextFrameIndex.hxx"
34 
35 class FontMetric;
36 class SwFntObj;
37 class SwDrawTextInfo;
38 class SwViewShell;
39 class SwSubFont;
40 class MapMode;
41 
42 class SwFntCache : public SwCache
43 {
44 public:
46 #ifdef DBG_UTIL
47  , OString(RTL_CONSTASCII_STRINGPARAM("Global Font-Cache pFntCache"))
48 #endif
49  ) {}
50 
51  inline SwFntObj *First( );
52  static inline SwFntObj *Next( SwFntObj *pFntObj);
53  void Flush();
54 };
55 
56 // Font cache, global variable, created/destroyed in txtinit.cxx
57 extern SwFntCache *pFntCache;
58 extern SwFntObj *pLastFont;
59 
60 class SwFntObj final : public SwCacheObj
61 {
62  friend class SwFntAccess;
63  friend void InitCore();
64  friend void FinitCore();
65 
70  sal_uInt16 m_nGuessedLeading;
71  sal_uInt16 m_nExtLeading;
72  sal_uInt16 m_nScrAscent;
73  sal_uInt16 m_nPrtAscent;
74  sal_uInt16 m_nScrHeight;
75  sal_uInt16 m_nPrtHeight;
76  sal_uInt16 m_nPropWidth;
79  sal_uInt16 m_nZoom;
80  bool m_bSymbol : 1;
81  bool m_bPaintBlank : 1;
82 
84  static MapMode *s_pPixMap;
85 
86 public:
87  SwFntObj( const SwSubFont &rFont, std::uintptr_t nFontCacheId,
88  SwViewShell const *pSh );
89 
90  virtual ~SwFntObj() override;
91 
93  vcl::Font& GetFont() { return m_aFont; }
94  const vcl::Font& GetFont() const { return m_aFont; }
95 
96  sal_uInt16 GetGuessedLeading() const { return m_nGuessedLeading; }
97  sal_uInt16 GetExternalLeading() const { return m_nExtLeading; }
98 
99  sal_uInt16 GetFontAscent( const SwViewShell *pSh, const OutputDevice& rOut );
100  sal_uInt16 GetFontHeight( const SwViewShell *pSh, const OutputDevice& rOut );
101  sal_uInt16 GetFontLeading( const SwViewShell *pSh, const OutputDevice& rOut );
102  sal_uInt16 GetFontHangingBaseline( const SwViewShell *pSh, const OutputDevice& rOut );
103 
104  void GuessLeading( const SwViewShell& rSh, const FontMetric& rMet );
105 
106  void SetDevFont( const SwViewShell *pSh, OutputDevice& rOut );
107  OutputDevice* GetPrt() const { return m_pPrinter; }
108  sal_uInt16 GetZoom() const { return m_nZoom; }
109  sal_uInt16 GetPropWidth() const { return m_nPropWidth; }
110  bool IsSymbol() const { return m_bSymbol; }
111 
112  void DrawText( SwDrawTextInfo &rInf );
116 
117  void CreateScrFont( const SwViewShell& rSh, const OutputDevice& rOut );
118  void CreatePrtFont( const OutputDevice& rOut );
119 };
120 
122 {
123  return static_cast<SwFntObj *>(SwCache::First());
124 }
125 
127 {
128  return static_cast<SwFntObj *>(SwCache::Next( pFntObj ));
129 }
130 
131 class SwFntAccess final : public SwCacheAccess
132 {
134 
135  virtual SwCacheObj *NewObj( ) override;
136 
137 public:
138  SwFntAccess( const void*& rnFontCacheId, sal_uInt16 &rIndex, const void *pOwner,
139  SwViewShell const *pShell,
140  bool bCheck = false );
141  SwFntObj* Get() { return static_cast<SwFntObj*>( SwCacheAccess::Get() ); }
142 };
143 
144 #endif
145 
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OutputDevice * GetPrt() const
Definition: fntcache.hxx:107
SwFntObj * pLastFont
Definition: fntcache.cxx:66
sal_uInt16 m_nExtLeading
Definition: fntcache.hxx:71
void CreateScrFont(const SwViewShell &rSh, const OutputDevice &rOut)
Definition: fntcache.cxx:417
virtual SwCacheObj * NewObj() override
Can be use in NewObj.
Definition: fntcache.cxx:2258
SwFntAccess(const void *&rnFontCacheId, sal_uInt16 &rIndex, const void *pOwner, SwViewShell const *pShell, bool bCheck=false)
Definition: fntcache.cxx:2154
bool m_bPaintBlank
Definition: fntcache.hxx:81
sal_uInt16 m_nPropWidth
Definition: fntcache.hxx:76
SwCacheObj * First()
Definition: swcache.hxx:115
sal_uInt16 GetFontHeight(const SwViewShell *pSh, const OutputDevice &rOut)
Definition: fntcache.cxx:311
bool m_bSymbol
Definition: fntcache.hxx:80
static SwCacheObj * Next(SwCacheObj *pCacheObj)
Definition: swcache.hxx:222
long Long
TextFrameIndex GetModelPositionForViewPoint(SwDrawTextInfo &rInf)
Definition: fntcache.cxx:1965
sal_uInt16 GetFontAscent(const SwViewShell *pSh, const OutputDevice &rOut)
Definition: fntcache.cxx:273
sal_uInt16 m_nScrHeight
Definition: fntcache.hxx:74
sal_uInt16 GetGuessedLeading() const
Definition: fntcache.hxx:96
sal_uInt16 GetZoom() const
Definition: fntcache.hxx:108
VclPtr< OutputDevice > m_pPrinter
Definition: fntcache.hxx:69
SwCacheObj * Get(bool isDuplicateOwnerAllowed)
Definition: swcache.hxx:257
vcl::Font & GetFont()
Definition: fntcache.hxx:93
static SwFntObj * Next(SwFntObj *pFntObj)
Definition: fntcache.hxx:126
sal_uInt16 GetFontLeading(const SwViewShell *pSh, const OutputDevice &rOut)
Definition: fntcache.cxx:350
void Flush()
Definition: fntcache.cxx:92
bool IsSymbol() const
Definition: fntcache.hxx:110
vcl::Font * m_pScrFont
Definition: fntcache.hxx:67
void CreatePrtFont(const OutputDevice &rOut)
Definition: fntcache.cxx:133
vcl::Font * m_pPrtFont
Definition: fntcache.hxx:68
void GuessLeading(const SwViewShell &rSh, const FontMetric &rMet)
Definition: fntcache.cxx:492
SwViewShell const * m_pShell
Definition: fntcache.hxx:133
sal_uInt16 GetFontHangingBaseline(const SwViewShell *pSh, const OutputDevice &rOut)
Definition: fntcache.cxx:401
static MapMode * s_pPixMap
Definition: fntcache.hxx:84
sal_uInt16 m_nZoom
Definition: fntcache.hxx:79
sal_uInt16 GetPropWidth() const
Definition: fntcache.hxx:109
SwFntCache * pFntCache
Definition: fntcache.cxx:64
friend void FinitCore()
Definition: init.cxx:668
vcl::Font * GetScrFont()
Definition: fntcache.hxx:92
void SetDevFont(const SwViewShell *pSh, OutputDevice &rOut)
Definition: fntcache.cxx:572
SwFntObj * Get()
Definition: fntcache.hxx:141
sal_uInt16 m_nScrHangingBaseline
Definition: fntcache.hxx:77
virtual ~SwFntObj() override
Definition: fntcache.cxx:125
The Cache object base class Users of the Cache must derive a class from the SwCacheObj and store thei...
Definition: swcache.hxx:134
sal_uInt16 m_nPrtAscent
Definition: fntcache.hxx:73
SwFntObj * First()
Definition: fntcache.hxx:121
SwFntObj(const SwSubFont &rFont, std::uintptr_t nFontCacheId, SwViewShell const *pSh)
Definition: fntcache.cxx:102
friend void InitCore()
Definition: init.cxx:449
void DrawText(SwDrawTextInfo &rInf)
Definition: fntcache.cxx:790
Access class for the Cache.
Definition: swcache.hxx:195
sal_uInt16 m_nGuessedLeading
Definition: fntcache.hxx:70
static tools::Long s_nPixWidth
Definition: fntcache.hxx:83
vcl::Font m_aFont
Definition: fntcache.hxx:66
sal_uInt16 m_nPrtHangingBaseline
Definition: fntcache.hxx:78
sal_uInt16 GetExternalLeading() const
Definition: fntcache.hxx:97
const vcl::Font & GetFont() const
Definition: fntcache.hxx:94
sal_uInt16 m_nScrAscent
Definition: fntcache.hxx:72
Size GetTextSize(SwDrawTextInfo &rInf)
determine the TextSize (of the printer)
Definition: fntcache.cxx:1806
sal_uInt16 m_nPrtHeight
Definition: fntcache.hxx:75