fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / vcl / inc / outdev.h
blobcf5feb0093ca2ce060d3826a025422f3ac0b92f7
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 _SV_OUTDEV_H
21 #define _SV_OUTDEV_H
23 #include <tools/solar.h>
24 #include <outfont.hxx>
26 #include <vector>
27 #include <list>
28 #include <set>
30 class Size;
31 class Font;
32 class VirtualDevice;
33 class ImplGetDevFontList;
34 class GetDevSizeList;
36 // -----------------------
37 // - ImplDevFontListData -
38 // -----------------------
40 // flags for mnMatchType member
41 #define IMPL_DEVFONT_SCALABLE ((sal_uIntPtr)0x00000001)
42 #define IMPL_DEVFONT_SYMBOL ((sal_uIntPtr)0x00000002)
43 #define IMPL_DEVFONT_NONESYMBOL ((sal_uIntPtr)0x00000004)
44 #define IMPL_DEVFONT_LIGHT ((sal_uIntPtr)0x00000010)
45 #define IMPL_DEVFONT_BOLD ((sal_uIntPtr)0x00000020)
46 #define IMPL_DEVFONT_NORMAL ((sal_uIntPtr)0x00000040)
47 #define IMPL_DEVFONT_NONEITALIC ((sal_uIntPtr)0x00000100)
48 #define IMPL_DEVFONT_ITALIC ((sal_uIntPtr)0x00000200)
50 // TODO: rename ImplDevFontListData to PhysicalFontFamily
51 class ImplDevFontListData
53 public:
54 ImplDevFontListData( const String& rSearchName );
55 ~ImplDevFontListData();
57 const OUString& GetFamilyName() const { return maName; }
58 const String& GetSearchName() const { return maSearchName; }
59 const OUString& GetAliasNames() const { return maMapNames; }
60 bool IsScalable() const { return mpFirst->IsScalable(); }
61 int GetMinQuality() const { return mnMinQuality; }
63 bool AddFontFace( PhysicalFontFace* );
64 void InitMatchData( const utl::FontSubstConfiguration&,
65 const String& rSearchName );
66 PhysicalFontFace* FindBestFontFace( const FontSelectPattern& rFSD ) const;
68 void GetFontHeights( std::set<int>& rHeights ) const;
69 void UpdateDevFontList( ImplGetDevFontList& ) const;
70 void UpdateCloneFontList( ImplDevFontList&,
71 bool bScalable, bool bEmbeddable ) const;
73 private:
74 friend class ImplDevFontList; // TODO: remove soon
75 PhysicalFontFace* mpFirst; // linked list of physical font faces
76 OUString maName; // Fontname (original font family name)
77 String maSearchName; // normalized font family name
78 OUString maMapNames; // fontname aliases
79 sal_uIntPtr mnTypeFaces; // Typeface Flags
80 sal_uIntPtr mnMatchType; // MATCH - Type
81 String maMatchFamilyName; // MATCH - FamilyName
82 FontWeight meMatchWeight; // MATCH - Weight
83 FontWidth meMatchWidth; // MATCH - Width
84 FontFamily meFamily;
85 FontPitch mePitch;
86 int mnMinQuality; // quality of the worst font face
90 // ----------------------
91 // - ImplGetDevFontList -
92 // ----------------------
94 // an ImplGetDevFontList is created by an ImplDevFontList
95 // it becomes invalid when original ImplDevFontList is modified
96 class ImplGetDevFontList
98 private:
99 std::vector<PhysicalFontFace*> maDevFontVector;
101 public:
102 ImplGetDevFontList() { maDevFontVector.reserve(1024); }
103 void Add( PhysicalFontFace* pFace ) { maDevFontVector.push_back( pFace ); }
104 PhysicalFontFace* Get( int nIndex ) const { return maDevFontVector[ nIndex ]; }
105 int Count() const { return maDevFontVector.size(); }
108 // ----------------------
109 // - ImplGetDevSizeList -
110 // ----------------------
112 class ImplGetDevSizeList
114 private:
115 String maFontName;
116 std::vector<int> maSizeList;
118 public:
119 ImplGetDevSizeList( const String& rFontName )
120 : maFontName( rFontName ) { maSizeList.reserve( 32 ); }
121 void Add( int nHeight ) { maSizeList.push_back( nHeight ); }
122 int Count() const { return maSizeList.size(); }
123 int Get( int nIndex ) const { return maSizeList[ nIndex ]; }
124 const String& GetFontName() const { return maFontName; }
127 // ------------------------
128 // - ImplFontSubstitution -
129 // ------------------------
130 // nowadays these substitutions are needed for backward compatibility and tight platform integration:
131 // - substitutions from configuration entries (Tools->Options->FontReplacement and/or fontconfig)
132 // - device specific substitutions (e.g. for PS printer builtin fonts)
133 // - substitutions for missing fonts defined by configuration entries (generic and/or platform dependent fallbacks)
134 // - substitutions for missing fonts defined by multi-token fontnames (e.g. fontname="SpecialFont;FallbackA;FallbackB")
135 // - substitutions for incomplete fonts (implicit, generic, EUDC and/or platform dependent fallbacks)
136 // - substitutions for missing symbol fonts by translating code points into other symbol fonts
138 class ImplFontSubstitution
140 // TODO: there is more commonality between the different substitutions
141 protected:
142 virtual ~ImplFontSubstitution() {}
145 // ImplDirectFontSubstitution is for Tools->Options->FontReplacement and PsPrinter substitutions
146 // The clss is just a simple port of the unmaintainable manual-linked-list based mechanism
147 // TODO: get rid of this class when the Tools->Options->FontReplacement tabpage is gone for good
149 struct ImplFontSubstEntry
151 String maName;
152 String maReplaceName;
153 OUString maSearchName;
154 OUString maSearchReplaceName;
155 sal_uInt16 mnFlags;
157 ImplFontSubstEntry( const OUString& rFontName, const OUString& rSubstFontName, sal_uInt16 nSubstFlags );
160 class ImplDirectFontSubstitution
161 : public ImplFontSubstitution
163 private:
164 typedef std::list<ImplFontSubstEntry> FontSubstList;
165 FontSubstList maFontSubstList;
166 public:
167 void AddFontSubstitute( const String& rFontName, const String& rSubstName, sal_uInt16 nFlags );
168 void RemoveFontSubstitute( int nIndex );
169 int GetFontSubstituteCount() const { return maFontSubstList.size(); };
170 bool Empty() const { return maFontSubstList.empty(); }
171 void Clear() { maFontSubstList.clear(); }
173 bool FindFontSubstitute( String& rSubstName, const String& rFontName, sal_uInt16 nFlags ) const;
176 // PreMatchFontSubstitution
177 // abstracts the concept of a configured font substitution
178 // before the availability of the originally selected font has been checked
179 class ImplPreMatchFontSubstitution
180 : public ImplFontSubstitution
182 public:
183 virtual bool FindFontSubstitute( FontSelectPattern& ) const = 0;
186 // ImplGlyphFallbackFontSubstitution
187 // abstracts the concept of finding the best font to support an incomplete font
188 class ImplGlyphFallbackFontSubstitution
189 : public ImplFontSubstitution
191 public:
192 virtual bool FindFontSubstitute( FontSelectPattern&, OUString& rMissingCodes ) const = 0;
195 // -----------------
196 // - ImplFontCache -
197 // -----------------
198 // TODO: closely couple with ImplDevFontList
200 class ImplFontCache
202 private:
203 ImplFontEntry* mpFirstEntry;
204 int mnRef0Count; // number of unreferenced ImplFontEntries
205 bool mbPrinter;
207 // cache of recently used font instances
208 struct IFSD_Equal { bool operator()( const FontSelectPattern&, const FontSelectPattern& ) const; };
209 struct IFSD_Hash { size_t operator()( const FontSelectPattern& ) const; };
210 typedef ::boost::unordered_map<FontSelectPattern,ImplFontEntry*,IFSD_Hash,IFSD_Equal > FontInstanceList;
211 FontInstanceList maFontInstanceList;
213 public:
214 ImplFontCache( bool bPrinter );
215 ~ImplFontCache();
217 ImplFontEntry* GetFontEntry( ImplDevFontList*,
218 const Font&, const Size& rPixelSize, float fExactHeight,
219 ImplDirectFontSubstitution* pDevSpecific );
220 ImplFontEntry* GetFontEntry( ImplDevFontList*,
221 FontSelectPattern&, ImplDirectFontSubstitution* pDevSpecific );
222 ImplFontEntry* GetGlyphFallbackFont( ImplDevFontList*, FontSelectPattern&,
223 int nFallbackLevel, OUString& rMissingCodes );
224 void Release( ImplFontEntry* );
225 void Invalidate();
228 // ------------------
229 // - ImplOutDevData -
230 // ------------------
232 namespace vcl { struct ControlLayoutData; }
233 // #i75163#
234 namespace basegfx { class B2DHomMatrix; }
236 struct ImplOutDevData
238 VirtualDevice* mpRotateDev;
239 vcl::ControlLayoutData* mpRecordLayout;
240 Rectangle maRecordRect;
241 ImplDirectFontSubstitution maDevFontSubst;
243 // #i75163#
244 basegfx::B2DHomMatrix* mpViewTransform;
245 basegfx::B2DHomMatrix* mpInverseViewTransform;
248 void ImplFreeOutDevFontData();
250 #endif // _SV_OUTDEV_H
252 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */