/src/libreoffice/vcl/inc/unx/gendata.hxx
Line | Count | Source |
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 | | |
10 | | #pragma once |
11 | | |
12 | | #include <osl/socket.hxx> |
13 | | |
14 | | #include <svdata.hxx> |
15 | | |
16 | | #include <memory> |
17 | | |
18 | | #ifndef IOS |
19 | | class FreetypeManager; |
20 | | #endif |
21 | | class SalGenericDisplay; |
22 | | |
23 | | #ifndef IOS |
24 | | |
25 | | namespace psp |
26 | | { |
27 | | class PrintFontManager; |
28 | | class PrinterInfoManager; |
29 | | } |
30 | | |
31 | | // SalData is a bit of a mess. For ImplSVData we need a SalData base class. |
32 | | // Windows, MacOS and iOS implement their own SalData class, so there is no |
33 | | // way to do inheritance from the "top" in all plugins. We also really don't |
34 | | // want to rename GenericUnixSalData and don't want to reinterpret_cast some |
35 | | // dummy pointer everywhere, so this seems the only sensible solution. |
36 | | class VCL_PLUGIN_PUBLIC SalData |
37 | | { |
38 | | protected: |
39 | | SalData(); |
40 | | |
41 | | public: |
42 | | virtual ~SalData(); |
43 | | }; |
44 | | |
45 | | #endif |
46 | | |
47 | | // This class is kind of a misnomer. What this class is mainly about is the |
48 | | // usage of Freetype and Fontconfig, which happens to match all *nix backends; |
49 | | // except that the osx and ios backends are *nix but don't use this. |
50 | | class VCL_PLUGIN_PUBLIC GenericUnixSalData : public SalData |
51 | | { |
52 | | #ifndef IOS |
53 | | friend class ::psp::PrinterInfoManager; |
54 | | #endif |
55 | | |
56 | | SalGenericDisplay* m_pDisplay; |
57 | | // cached hostname to avoid slow lookup |
58 | | OUString m_aHostname; |
59 | | // for transient storage of unicode strings eg. 'u123' by input methods |
60 | | OUString m_aUnicodeEntry; |
61 | | |
62 | | #ifndef IOS |
63 | | std::unique_ptr<FreetypeManager> m_pFreetypeManager; |
64 | | std::unique_ptr<psp::PrintFontManager> m_pPrintFontManager; |
65 | | std::unique_ptr<psp::PrinterInfoManager> m_pPrinterInfoManager; |
66 | | #endif |
67 | | |
68 | | void InitFreetypeManager(); |
69 | | void InitPrintFontManager(); |
70 | | |
71 | | public: |
72 | | GenericUnixSalData(); |
73 | | virtual ~GenericUnixSalData() override; |
74 | | virtual void Dispose(); |
75 | | |
76 | 0 | SalGenericDisplay* GetDisplay() const { return m_pDisplay; } |
77 | 0 | void SetDisplay(SalGenericDisplay* pDisp) { m_pDisplay = pDisp; } |
78 | | |
79 | | const OUString& GetHostname() |
80 | 0 | { |
81 | 0 | if (m_aHostname.isEmpty()) |
82 | 0 | osl_getLocalHostname(&m_aHostname.pData); |
83 | 0 | return m_aHostname; |
84 | 0 | } |
85 | | |
86 | 0 | OUString& GetUnicodeCommand() { return m_aUnicodeEntry; } |
87 | | |
88 | | #ifndef IOS |
89 | | |
90 | | FreetypeManager* GetFreetypeManager() |
91 | 179k | { |
92 | 179k | if (!m_pFreetypeManager) |
93 | 108 | InitFreetypeManager(); |
94 | 179k | return m_pFreetypeManager.get(); |
95 | 179k | } |
96 | | |
97 | | psp::PrintFontManager* GetPrintFontManager() |
98 | 223 | { |
99 | 223 | if (!m_pPrintFontManager) |
100 | 108 | InitPrintFontManager(); |
101 | | // PrintFontManager needs the FreetypeManager |
102 | 223 | assert(m_pFreetypeManager); |
103 | 223 | return m_pPrintFontManager.get(); |
104 | 223 | } |
105 | | |
106 | | #endif |
107 | | |
108 | | // Mostly useful for remote protocol backends |
109 | | virtual void ErrorTrapPush() = 0; |
110 | | virtual bool ErrorTrapPop(bool bIgnoreError = true) = 0; // true on error |
111 | | }; |
112 | | |
113 | | inline GenericUnixSalData* GetGenericUnixSalData() |
114 | 179k | { |
115 | 179k | return static_cast<GenericUnixSalData*>(ImplGetSVData()->mpSalData); |
116 | 179k | } |
117 | | |
118 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |