tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / vcl / inc / unx / gendata.hxx
blob4949613c0b1090534ed03f73a4727b61cf99ca67
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/.
8 */
10 #pragma once
12 #include <osl/socket.hxx>
14 #include <svdata.hxx>
16 #include <memory>
18 #ifndef IOS
19 class FreetypeManager;
20 #endif
21 class SalGenericDisplay;
23 #ifndef IOS
25 namespace psp
27 class PrintFontManager;
28 class PrinterInfoManager;
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
38 protected:
39 SalData();
41 public:
42 virtual ~SalData();
45 #endif
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
52 #ifndef IOS
53 friend class ::psp::PrinterInfoManager;
54 #endif
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;
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
68 void InitFreetypeManager();
69 void InitPrintFontManager();
71 public:
72 GenericUnixSalData();
73 virtual ~GenericUnixSalData() override;
74 virtual void Dispose();
76 SalGenericDisplay* GetDisplay() const { return m_pDisplay; }
77 void SetDisplay(SalGenericDisplay* pDisp) { m_pDisplay = pDisp; }
79 const OUString& GetHostname()
81 if (m_aHostname.isEmpty())
82 osl_getLocalHostname(&m_aHostname.pData);
83 return m_aHostname;
86 OUString& GetUnicodeCommand() { return m_aUnicodeEntry; }
88 #ifndef IOS
90 FreetypeManager* GetFreetypeManager()
92 if (!m_pFreetypeManager)
93 InitFreetypeManager();
94 return m_pFreetypeManager.get();
97 psp::PrintFontManager* GetPrintFontManager()
99 if (!m_pPrintFontManager)
100 InitPrintFontManager();
101 // PrintFontManager needs the FreetypeManager
102 assert(m_pFreetypeManager);
103 return m_pPrintFontManager.get();
106 #endif
108 // Mostly useful for remote protocol backends
109 virtual void ErrorTrapPush() = 0;
110 virtual bool ErrorTrapPop(bool bIgnoreError = true) = 0; // true on error
113 inline GenericUnixSalData* GetGenericUnixSalData()
115 return static_cast<GenericUnixSalData*>(ImplGetSVData()->mpSalData);
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */