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