Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / source / core / inc / fntcache.hxx
blobbea6663e1420d6da77bfc387d1b56c16314a943b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SW_SOURCE_CORE_INC_FNTCACHE_HXX
21 #define INCLUDED_SW_SOURCE_CORE_INC_FNTCACHE_HXX
23 #include <sal/config.h>
25 #include <cstdint>
26 #include <unordered_map>
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"
35 class FontMetric;
36 class SwFntObj;
37 class SwDrawTextInfo;
38 class SwViewShell;
39 class SwSubFont;
40 class MapMode;
42 class SwFntCache : public SwCache
44 public:
45 SwFntCache() : SwCache(50
46 #ifdef DBG_UTIL
47 , OString(RTL_CONSTASCII_STRINGPARAM("Global Font-Cache pFntCache"))
48 #endif
49 ) {}
51 inline SwFntObj *First( );
52 static inline SwFntObj *Next( SwFntObj *pFntObj);
53 void Flush();
56 // Font cache, global variable, created/destroyed in txtinit.cxx
57 extern SwFntCache *pFntCache;
58 extern SwFntObj *pLastFont;
60 class SwFntObj final : public SwCacheObj
62 friend class SwFntAccess;
63 friend void InitCore();
64 friend void FinitCore();
66 vcl::Font m_aFont;
67 vcl::Font *m_pScrFont;
68 vcl::Font *m_pPrtFont;
69 VclPtr<OutputDevice> m_pPrinter;
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;
77 sal_uInt16 m_nScrHangingBaseline;
78 sal_uInt16 m_nPrtHangingBaseline;
79 sal_uInt16 m_nZoom;
80 bool m_bSymbol : 1;
81 bool m_bPaintBlank : 1;
83 static tools::Long s_nPixWidth;
84 static MapMode *s_pPixMap;
86 public:
87 SwFntObj( const SwSubFont &rFont, std::uintptr_t nFontCacheId,
88 SwViewShell const *pSh );
90 virtual ~SwFntObj() override;
92 vcl::Font *GetScrFont() { return m_pScrFont; }
93 vcl::Font& GetFont() { return m_aFont; }
94 const vcl::Font& GetFont() const { return m_aFont; }
96 sal_uInt16 GetGuessedLeading() const { return m_nGuessedLeading; }
97 sal_uInt16 GetExternalLeading() const { return m_nExtLeading; }
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 );
104 void GuessLeading( const SwViewShell& rSh, const FontMetric& rMet );
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; }
112 void DrawText( SwDrawTextInfo &rInf );
113 /// determine the TextSize (of the printer)
114 Size GetTextSize( SwDrawTextInfo &rInf );
115 TextFrameIndex GetModelPositionForViewPoint(SwDrawTextInfo &rInf);
117 void CreateScrFont( const SwViewShell& rSh, const OutputDevice& rOut );
118 void CreatePrtFont( const OutputDevice& rOut );
121 SwFntObj *SwFntCache::First( )
123 return static_cast<SwFntObj *>(SwCache::First());
126 SwFntObj *SwFntCache::Next( SwFntObj *pFntObj)
128 return static_cast<SwFntObj *>(SwCache::Next( pFntObj ));
131 class SwFntAccess final : public SwCacheAccess
133 SwViewShell const *m_pShell;
135 virtual SwCacheObj *NewObj( ) override;
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() ); }
144 #endif
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */