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 <saldatabasic.hxx>
16 
17 #include <memory>
18 
19 class FreetypeManager;
20 class SalGenericDisplay;
21 namespace psp
22 {
23 class PrintFontManager;
24 }
25 
27 {
28 private:
30  // cached hostname to avoid slow lookup
31  OUString m_aHostname;
32  // for transient storage of unicode strings eg. 'u123' by input methods
33  OUString m_aUnicodeEntry;
34 
35  std::unique_ptr<FreetypeManager> m_pFreetypeManager;
36  std::unique_ptr<psp::PrintFontManager> m_pPrintFontManager;
37 
38  void InitFreetypeManager();
39  void InitPrintFontManager();
40 
41 public:
42  GenericUnixSalData(SalInstance* const pInstance);
43  virtual ~GenericUnixSalData() override;
44  virtual void Dispose() {}
45 
46  SalGenericDisplay* GetDisplay() const { return m_pDisplay; }
47  void SetDisplay(SalGenericDisplay* pDisp) { m_pDisplay = pDisp; }
48 
49  const OUString& GetHostname()
50  {
51  if (m_aHostname.isEmpty())
52  osl_getLocalHostname(&m_aHostname.pData);
53  return m_aHostname;
54  }
55 
56  OUString& GetUnicodeCommand() { return m_aUnicodeEntry; }
57 
59  {
60  if (!m_pFreetypeManager)
61  InitFreetypeManager();
62  return m_pFreetypeManager.get();
63  }
64 
66  {
67  if (!m_pPrintFontManager)
68  InitPrintFontManager();
69  // PrintFontManager needs the FreetypeManager
70  assert(m_pFreetypeManager);
71  return m_pPrintFontManager.get();
72  }
73 
74  // Mostly useful for remote protocol backends
75  virtual void ErrorTrapPush() = 0;
76  virtual bool ErrorTrapPop(bool bIgnoreError = true) = 0; // true on error
77 };
78 
80 {
81  return static_cast<GenericUnixSalData*>(ImplGetSVData()->mpSalData);
82 }
83 
84 #endif
85 
86 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SalData * mpSalData
Definition: svdata.hxx:384
OUString m_aUnicodeEntry
Definition: gendata.hxx:33
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
FreetypeManager * GetFreetypeManager()
Definition: gendata.hxx:58
OUString & GetUnicodeCommand()
Definition: gendata.hxx:56
void SetDisplay(SalGenericDisplay *pDisp)
Definition: gendata.hxx:47
SalGenericDisplay * GetDisplay() const
Definition: gendata.hxx:46
std::unique_ptr< FreetypeManager > m_pFreetypeManager
Definition: gendata.hxx:35
OUString m_aHostname
Definition: gendata.hxx:31
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:75
The FreetypeManager caches various aspects of Freetype fonts.
Definition: glyphcache.hxx:74
const OUString & GetHostname()
Definition: gendata.hxx:49
virtual void Dispose()
Definition: gendata.hxx:44
std::unique_ptr< psp::PrintFontManager > m_pPrintFontManager
Definition: gendata.hxx:36
psp::PrintFontManager * GetPrintFontManager()
Definition: gendata.hxx:65
SalGenericDisplay * m_pDisplay
Definition: gendata.hxx:29
GenericUnixSalData * GetGenericUnixSalData()
Definition: gendata.hxx:79