xref: /aoo41x/main/vcl/inc/outdev.h (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef _SV_OUTDEV_H
29*cdf0e10cSrcweir #define _SV_OUTDEV_H
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <tools/solar.h>
32*cdf0e10cSrcweir #include <outfont.hxx>
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir #include <vector>
35*cdf0e10cSrcweir #include <list>
36*cdf0e10cSrcweir #include <set>
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir class Size;
39*cdf0e10cSrcweir class Font;
40*cdf0e10cSrcweir class VirtualDevice;
41*cdf0e10cSrcweir class ImplServerGraphics;
42*cdf0e10cSrcweir class ImplGetDevFontList;
43*cdf0e10cSrcweir class GetDevSizeList;
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir // -----------------------
46*cdf0e10cSrcweir // - ImplDevFontListData -
47*cdf0e10cSrcweir // -----------------------
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir // flags for mnMatchType member
50*cdf0e10cSrcweir #define IMPL_DEVFONT_SCALABLE       ((sal_uIntPtr)0x00000001)
51*cdf0e10cSrcweir #define IMPL_DEVFONT_SYMBOL         ((sal_uIntPtr)0x00000002)
52*cdf0e10cSrcweir #define IMPL_DEVFONT_NONESYMBOL     ((sal_uIntPtr)0x00000004)
53*cdf0e10cSrcweir #define IMPL_DEVFONT_LIGHT          ((sal_uIntPtr)0x00000010)
54*cdf0e10cSrcweir #define IMPL_DEVFONT_BOLD           ((sal_uIntPtr)0x00000020)
55*cdf0e10cSrcweir #define IMPL_DEVFONT_NORMAL         ((sal_uIntPtr)0x00000040)
56*cdf0e10cSrcweir #define IMPL_DEVFONT_NONEITALIC     ((sal_uIntPtr)0x00000100)
57*cdf0e10cSrcweir #define IMPL_DEVFONT_ITALIC         ((sal_uIntPtr)0x00000200)
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir // TODO: rename ImplDevFontListData to PhysicalFontFamily
60*cdf0e10cSrcweir class ImplDevFontListData
61*cdf0e10cSrcweir {
62*cdf0e10cSrcweir public:
63*cdf0e10cSrcweir                         ImplDevFontListData( const String& rSearchName );
64*cdf0e10cSrcweir                         ~ImplDevFontListData();
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir     const String&       GetFamilyName() const    { return maName; }
67*cdf0e10cSrcweir     const String&       GetSearchName() const    { return maSearchName; }
68*cdf0e10cSrcweir     const String&       GetAliasNames() const    { return maMapNames; }
69*cdf0e10cSrcweir     bool                IsScalable() const       { return mpFirst->IsScalable(); }
70*cdf0e10cSrcweir     int                 GetMinQuality() const    { return mnMinQuality; }
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir     bool                AddFontFace( ImplFontData* );
73*cdf0e10cSrcweir     void                InitMatchData( const utl::FontSubstConfiguration&,
74*cdf0e10cSrcweir                             const String& rSearchName );
75*cdf0e10cSrcweir     ImplFontData*       FindBestFontFace( const ImplFontSelectData& rFSD ) const;
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir     void                GetFontHeights( std::set<int>& rHeights ) const;
78*cdf0e10cSrcweir     void                UpdateDevFontList( ImplGetDevFontList& ) const;
79*cdf0e10cSrcweir     void                UpdateCloneFontList( ImplDevFontList&,
80*cdf0e10cSrcweir                             bool bScalable, bool bEmbeddable ) const;
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir private:
83*cdf0e10cSrcweir friend class ImplDevFontList; // TODO: remove soon
84*cdf0e10cSrcweir     ImplFontData*       mpFirst;            // linked list of physical font faces
85*cdf0e10cSrcweir     String              maName;             // Fontname (original font family name)
86*cdf0e10cSrcweir     String              maSearchName;       // normalized font family name
87*cdf0e10cSrcweir     String              maMapNames;         // fontname aliases
88*cdf0e10cSrcweir     sal_uIntPtr               mnTypeFaces;        // Typeface Flags
89*cdf0e10cSrcweir     sal_uIntPtr               mnMatchType;        // MATCH - Type
90*cdf0e10cSrcweir     String              maMatchFamilyName;  // MATCH - FamilyName
91*cdf0e10cSrcweir     FontWeight          meMatchWeight;      // MATCH - Weight
92*cdf0e10cSrcweir     FontWidth           meMatchWidth;       // MATCH - Width
93*cdf0e10cSrcweir     FontFamily          meFamily;
94*cdf0e10cSrcweir     FontPitch           mePitch;
95*cdf0e10cSrcweir     int                 mnMinQuality;       // quality of the worst font face
96*cdf0e10cSrcweir };
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir // ----------------------
100*cdf0e10cSrcweir // - ImplGetDevFontList -
101*cdf0e10cSrcweir // ----------------------
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir // an ImplGetDevFontList is created by an ImplDevFontList
104*cdf0e10cSrcweir // it becomes invalid when original ImplDevFontList is modified
105*cdf0e10cSrcweir class ImplGetDevFontList
106*cdf0e10cSrcweir {
107*cdf0e10cSrcweir private:
108*cdf0e10cSrcweir     std::vector<ImplFontData*> maDevFontVector;
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir public:
111*cdf0e10cSrcweir                         ImplGetDevFontList()        { maDevFontVector.reserve(1024); }
112*cdf0e10cSrcweir     void                Add( ImplFontData* pFace )  { maDevFontVector.push_back( pFace ); }
113*cdf0e10cSrcweir     ImplFontData*       Get( int nIndex ) const     { return maDevFontVector[ nIndex ]; }
114*cdf0e10cSrcweir     int                 Count() const               { return maDevFontVector.size(); }
115*cdf0e10cSrcweir };
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir // ----------------------
118*cdf0e10cSrcweir // - ImplGetDevSizeList -
119*cdf0e10cSrcweir // ----------------------
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir class ImplGetDevSizeList
122*cdf0e10cSrcweir {
123*cdf0e10cSrcweir private:
124*cdf0e10cSrcweir     String              maFontName;
125*cdf0e10cSrcweir     std::vector<int>    maSizeList;
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir public:
128*cdf0e10cSrcweir                         ImplGetDevSizeList( const String& rFontName )
129*cdf0e10cSrcweir                         : maFontName( rFontName ) { maSizeList.reserve( 32 ); }
130*cdf0e10cSrcweir     void                Add( int nHeight )      { maSizeList.push_back( nHeight ); }
131*cdf0e10cSrcweir     int                 Count() const           { return maSizeList.size(); }
132*cdf0e10cSrcweir     int                 Get( int nIndex ) const { return maSizeList[ nIndex ]; }
133*cdf0e10cSrcweir     const String&       GetFontName() const     { return maFontName; }
134*cdf0e10cSrcweir };
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir // ------------------------
137*cdf0e10cSrcweir // - ImplFontSubstitution -
138*cdf0e10cSrcweir // ------------------------
139*cdf0e10cSrcweir // nowadays these substitutions are needed for backward compatibility and tight platform integration:
140*cdf0e10cSrcweir // - substitutions from configuration entries (Tools->Options->FontReplacement and/or fontconfig)
141*cdf0e10cSrcweir // - device specific substitutions (e.g. for PS printer builtin fonts)
142*cdf0e10cSrcweir // - substitutions for missing fonts defined by configuration entries (generic and/or platform dependent fallbacks)
143*cdf0e10cSrcweir // - substitutions for missing fonts defined by multi-token fontnames (e.g. fontname="SpecialFont;FallbackA;FallbackB")
144*cdf0e10cSrcweir // - substitutions for incomplete fonts (implicit, generic, EUDC and/or platform dependent fallbacks)
145*cdf0e10cSrcweir // - substitutions for missing symbol fonts by translating code points into other symbol fonts
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir class ImplFontSubstitution
148*cdf0e10cSrcweir {
149*cdf0e10cSrcweir     // TODO: there is more commonality between the different substitutions
150*cdf0e10cSrcweir protected:
151*cdf0e10cSrcweir     virtual ~ImplFontSubstitution() {}
152*cdf0e10cSrcweir };
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir // ImplDirectFontSubstitution is for Tools->Options->FontReplacement and PsPrinter substitutions
155*cdf0e10cSrcweir // The clss is just a simple port of the unmaintainable manual-linked-list based mechanism
156*cdf0e10cSrcweir // TODO: get rid of this class when the Tools->Options->FontReplacement tabpage is gone for good
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir struct ImplFontSubstEntry
159*cdf0e10cSrcweir {
160*cdf0e10cSrcweir     String                  maName;
161*cdf0e10cSrcweir     String                  maReplaceName;
162*cdf0e10cSrcweir     String                  maSearchName;
163*cdf0e10cSrcweir     String                  maSearchReplaceName;
164*cdf0e10cSrcweir     sal_uInt16                  mnFlags;
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir     ImplFontSubstEntry(  const String& rFontName, const String& rSubstFontName, sal_uInt16 nSubstFlags );
167*cdf0e10cSrcweir };
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir class ImplDirectFontSubstitution
170*cdf0e10cSrcweir :   public ImplFontSubstitution
171*cdf0e10cSrcweir {
172*cdf0e10cSrcweir private:
173*cdf0e10cSrcweir     typedef std::list<ImplFontSubstEntry> FontSubstList;
174*cdf0e10cSrcweir     FontSubstList maFontSubstList;
175*cdf0e10cSrcweir public:
176*cdf0e10cSrcweir     void    AddFontSubstitute( const String& rFontName, const String& rSubstName, sal_uInt16 nFlags );
177*cdf0e10cSrcweir     void    RemoveFontSubstitute( int nIndex );
178*cdf0e10cSrcweir     bool    GetFontSubstitute( int nIndex, String& rFontName, String& rSubstName, sal_uInt16& rFlags ) const;
179*cdf0e10cSrcweir     int     GetFontSubstituteCount() const { return maFontSubstList.size(); };
180*cdf0e10cSrcweir     bool    Empty() const { return maFontSubstList.empty(); }
181*cdf0e10cSrcweir     void    Clear() { maFontSubstList.clear(); }
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir     bool    FindFontSubstitute( String& rSubstName, const String& rFontName, sal_uInt16 nFlags ) const;
184*cdf0e10cSrcweir };
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir // PreMatchFontSubstitution
187*cdf0e10cSrcweir // abstracts the concept of a configured font substitution
188*cdf0e10cSrcweir // before the availability of the originally selected font has been checked
189*cdf0e10cSrcweir class ImplPreMatchFontSubstitution
190*cdf0e10cSrcweir :   public ImplFontSubstitution
191*cdf0e10cSrcweir {
192*cdf0e10cSrcweir public:
193*cdf0e10cSrcweir     virtual bool FindFontSubstitute( ImplFontSelectData& ) const = 0;
194*cdf0e10cSrcweir };
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir // ImplGlyphFallbackFontSubstitution
197*cdf0e10cSrcweir // abstracts the concept of finding the best font to support an incomplete font
198*cdf0e10cSrcweir class ImplGlyphFallbackFontSubstitution
199*cdf0e10cSrcweir :   public ImplFontSubstitution
200*cdf0e10cSrcweir {
201*cdf0e10cSrcweir public:
202*cdf0e10cSrcweir     virtual bool FindFontSubstitute( ImplFontSelectData&, rtl::OUString& rMissingCodes ) const = 0;
203*cdf0e10cSrcweir };
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir // -----------------
206*cdf0e10cSrcweir // - ImplFontCache -
207*cdf0e10cSrcweir // -----------------
208*cdf0e10cSrcweir // TODO: closely couple with ImplDevFontList
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir class ImplFontCache
211*cdf0e10cSrcweir {
212*cdf0e10cSrcweir private:
213*cdf0e10cSrcweir     ImplFontEntry*      mpFirstEntry;
214*cdf0e10cSrcweir     int                 mnRef0Count;    // number of unreferenced ImplFontEntries
215*cdf0e10cSrcweir     bool                mbPrinter;
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir     // cache of recently used font instances
218*cdf0e10cSrcweir     struct IFSD_Equal { bool operator()( const ImplFontSelectData&, const ImplFontSelectData& ) const; };
219*cdf0e10cSrcweir     struct IFSD_Hash { size_t operator()( const ImplFontSelectData& ) const; };
220*cdf0e10cSrcweir     typedef ::std::hash_map<ImplFontSelectData,ImplFontEntry*,IFSD_Hash,IFSD_Equal > FontInstanceList;
221*cdf0e10cSrcweir     FontInstanceList    maFontInstanceList;
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir     // cache of recently requested font names vs. selected font names
224*cdf0e10cSrcweir     typedef ::std::hash_map<String,String,FontNameHash> FontNameList;
225*cdf0e10cSrcweir     FontNameList        maFontNameList;
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir public:
228*cdf0e10cSrcweir                         ImplFontCache( bool bPrinter );
229*cdf0e10cSrcweir                         ~ImplFontCache();
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir     ImplFontEntry*      GetFontEntry( ImplDevFontList*,
232*cdf0e10cSrcweir                              const Font&, const Size& rPixelSize, float fExactHeight,
233*cdf0e10cSrcweir 				ImplDirectFontSubstitution* pDevSpecific );
234*cdf0e10cSrcweir     ImplFontEntry*      GetFontEntry( ImplDevFontList*,
235*cdf0e10cSrcweir 		            ImplFontSelectData&, ImplDirectFontSubstitution* pDevSpecific );
236*cdf0e10cSrcweir     ImplFontEntry*      GetGlyphFallbackFont( ImplDevFontList*, ImplFontSelectData&,
237*cdf0e10cSrcweir                             int nFallbackLevel, rtl::OUString& rMissingCodes );
238*cdf0e10cSrcweir     void                Release( ImplFontEntry* );
239*cdf0e10cSrcweir     void                Invalidate();
240*cdf0e10cSrcweir };
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir // ------------------
243*cdf0e10cSrcweir // - ImplOutDevData -
244*cdf0e10cSrcweir // ------------------
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir namespace vcl { struct ControlLayoutData; }
247*cdf0e10cSrcweir // #i75163#
248*cdf0e10cSrcweir namespace basegfx { class B2DHomMatrix; }
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir struct ImplOutDevData
251*cdf0e10cSrcweir {
252*cdf0e10cSrcweir     VirtualDevice*				mpRotateDev;
253*cdf0e10cSrcweir     vcl::ControlLayoutData*		mpRecordLayout;
254*cdf0e10cSrcweir 	Rectangle					maRecordRect;
255*cdf0e10cSrcweir     ImplDirectFontSubstitution		maDevFontSubst;
256*cdf0e10cSrcweir 
257*cdf0e10cSrcweir 	// #i75163#
258*cdf0e10cSrcweir 	basegfx::B2DHomMatrix*		mpViewTransform;
259*cdf0e10cSrcweir 	basegfx::B2DHomMatrix*		mpInverseViewTransform;
260*cdf0e10cSrcweir };
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir void ImplFreeOutDevFontData();
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir #endif // _SV_OUTDEV_H
265