xref: /AOO41X/main/sw/source/core/inc/fntcache.hxx (revision 1d2dbeb0b7301723c6d13094e87a8714ef81a328)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _FNTCACHE_HXX
24 #define _FNTCACHE_HXX
25 
26 #include <vcl/font.hxx>
27 #include <tools/mempool.hxx>
28 
29 #include "swtypes.hxx"
30 #include "swcache.hxx"
31 
32 class Printer;
33 class OutputDevice;
34 class FontMetric;
35 class SwFntObj;
36 class SwDrawTextInfo;   // DrawText
37 class ViewShell;
38 class SwSubFont;
39 class MapMode;
40 
41 /*************************************************************************
42  *                      class SwFntCache
43  *************************************************************************/
44 
45 class SwFntCache : public SwCache
46 {
47 public:
48 
SwFntCache()49     inline SwFntCache() : SwCache(50,50
50 #ifdef DBG_UTIL
51     , ByteString( RTL_CONSTASCII_STRINGPARAM(
52                         "Globaler Font-Cache pFntCache" ))
53 #endif
54     ) {}
55 
First()56     inline SwFntObj *First( ) { return (SwFntObj *)SwCache::First(); }
Next(SwFntObj * pFntObj)57     inline SwFntObj *Next( SwFntObj *pFntObj)
58         { return (SwFntObj *)SwCache::Next( (SwCacheObj *)pFntObj ); }
59     void Flush();
60 };
61 
62 // Font-Cache, globale Variable, in txtinit.Cxx angelegt/zerstoert
63 extern SwFntCache *pFntCache;
64 extern SwFntObj *pLastFont;
65 extern sal_uInt8 *pMagicNo;
66 extern Color *pWaveCol;
67 
68 /*************************************************************************
69  *                      class SwFntObj
70  *************************************************************************/
71 
72 class SwFntObj : public SwCacheObj
73 {
74     friend class SwFntAccess;
75     friend void _InitCore();
76     friend void _FinitCore();
77 
78     Font aFont;
79     Font *pScrFont;
80     Font *pPrtFont;
81     OutputDevice* pPrinter;
82     sal_uInt16 nGuessedLeading;
83     sal_uInt16 nExtLeading;
84     sal_uInt16 nScrAscent;
85     sal_uInt16 nPrtAscent;
86     sal_uInt16 nScrHeight;
87     sal_uInt16 nPrtHeight;
88     sal_uInt16 nPropWidth;
89     sal_uInt16 nZoom;
90     sal_Bool bSymbol : 1;
91     sal_Bool bPaintBlank : 1;
92 
93     static long nPixWidth;
94     static MapMode *pPixMap;
95     static OutputDevice *pPixOut;
96 
97     // SMARTTAGS
98     void calcLinePos(SwDrawTextInfo& rInf, Point& aStart, Point& aEnd, xub_StrLen nStart,
99        xub_StrLen nWrLen, xub_StrLen nCnt, const sal_Bool bSwitchH2V, const sal_Bool bSwitchL2R,
100        long nHalfSpace, long* pKernArray, const sal_Bool bBidiPor);
101 
102 public:
103     DECL_FIXEDMEMPOOL_NEWDEL(SwFntObj)
104 
105     SwFntObj( const SwSubFont &rFont, const void* pOwner,
106               ViewShell *pSh );
107 
108     virtual ~SwFntObj();
109 
GetScrFont()110     inline       Font *GetScrFont()     { return pScrFont; }
GetFont()111     inline       Font *GetFont()        { return &aFont; }
GetFont() const112     inline const Font *GetFont() const  { return &aFont; }
113 
GetGuessedLeading() const114     inline sal_uInt16 GetGuessedLeading() const  { return nGuessedLeading; }
GetExtLeading() const115     inline sal_uInt16 GetExtLeading() const  { return nExtLeading; }
116 
117     sal_uInt16 GetFontAscent( const ViewShell *pSh, const OutputDevice& rOut );
118     sal_uInt16 GetFontHeight( const ViewShell *pSh, const OutputDevice& rOut );
119     sal_uInt16 GetFontLeading( const ViewShell *pSh, const OutputDevice& rOut );
120 
121     void GuessLeading( const ViewShell& rSh, const FontMetric& rMet );
122 
123     void SetDevFont( const ViewShell *pSh, OutputDevice& rOut );
GetPrt() const124     inline OutputDevice* GetPrt() const { return pPrinter; }
GetZoom() const125     inline sal_uInt16   GetZoom() const { return nZoom; }
GetPropWidth() const126     inline sal_uInt16   GetPropWidth() const { return nPropWidth; }
IsSymbol() const127     inline sal_Bool     IsSymbol() const { return bSymbol; }
128 
129     void   DrawText( SwDrawTextInfo &rInf );
130     Size  GetTextSize( SwDrawTextInfo &rInf );
131     xub_StrLen GetCrsrOfst( SwDrawTextInfo &rInf );
132 
133     void CreateScrFont( const ViewShell& rSh, const OutputDevice& rOut );
134     void CreatePrtFont( const OutputDevice& rOut );
135 };
136 
137 /*************************************************************************
138  *                      class SwFntAccess
139  *************************************************************************/
140 
141 
142 class SwFntAccess : public SwCacheAccess
143 {
144     ViewShell *pShell;
145 protected:
146     virtual SwCacheObj *NewObj( );
147 
148 public:
149     SwFntAccess( const void * &rMagic, sal_uInt16 &rIndex, const void *pOwner,
150                  ViewShell *pShell,
151                  sal_Bool bCheck = sal_False  );
Get()152     inline SwFntObj* Get() { return (SwFntObj*) SwCacheAccess::Get(); };
153 };
154 
155 
156 #endif
157