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 GlyphCache;
20 class SalGenericDisplay;
21 namespace psp
22 {
23 class PrintFontManager;
24 }
25 
27 {
37 };
38 
40 {
41 private:
44  // cached hostname to avoid slow lookup
45  OUString m_aHostname;
46  // for transient storage of unicode strings eg. 'u123' by input methods
47  OUString m_aUnicodeEntry;
48 
49  std::unique_ptr<GlyphCache> m_pGlyphCache;
50  std::unique_ptr<psp::PrintFontManager> m_pPrintFontManager;
51 
52  void InitGlyphCache();
53  void InitPrintFontManager();
54 
55 public:
56  GenericUnixSalData(GenericUnixSalDataType const t, SalInstance* const pInstance);
57  virtual ~GenericUnixSalData() override;
58  virtual void Dispose() {}
59 
60  SalGenericDisplay* GetDisplay() const { return m_pDisplay; }
61  void SetDisplay(SalGenericDisplay* pDisp) { m_pDisplay = pDisp; }
62 
63  const OUString& GetHostname()
64  {
65  if (m_aHostname.isEmpty())
66  osl_getLocalHostname(&m_aHostname.pData);
67  return m_aHostname;
68  }
69 
70  OUString& GetUnicodeCommand() { return m_aUnicodeEntry; }
71 
72  GenericUnixSalDataType GetType() const { return m_eType; }
73 
75  {
76  if (!m_pGlyphCache)
77  InitGlyphCache();
78  return m_pGlyphCache.get();
79  }
80 
82  {
83  if (!m_pPrintFontManager)
84  InitPrintFontManager();
85  // PrintFontManager needs the GlyphCache
86  assert(m_pGlyphCache.get());
87  return m_pPrintFontManager.get();
88  }
89 
90  // Mostly useful for remote protocol backends
91  virtual void ErrorTrapPush() = 0;
92  virtual bool ErrorTrapPop(bool bIgnoreError = true) = 0; // true on error
93 };
94 
96 {
97  return static_cast<GenericUnixSalData*>(ImplGetSVData()->mpSalData);
98 }
99 
100 #endif
101 
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
GenericUnixSalDataType GetType() const
Definition: gendata.hxx:72
GenericUnixSalDataType const m_eType
Definition: gendata.hxx:42
SalData * mpSalData
Definition: svdata.hxx:335
OUString m_aUnicodeEntry
Definition: gendata.hxx:47
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
GlyphCache * GetGlyphCache()
Definition: gendata.hxx:74
OUString & GetUnicodeCommand()
Definition: gendata.hxx:70
void SetDisplay(SalGenericDisplay *pDisp)
Definition: gendata.hxx:61
SalGenericDisplay * GetDisplay() const
Definition: gendata.hxx:60
OUString m_aHostname
Definition: gendata.hxx:45
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:67
const OUString & GetHostname()
Definition: gendata.hxx:63
virtual void Dispose()
Definition: gendata.hxx:58
std::unique_ptr< GlyphCache > m_pGlyphCache
Definition: gendata.hxx:49
std::unique_ptr< psp::PrintFontManager > m_pPrintFontManager
Definition: gendata.hxx:50
psp::PrintFontManager * GetPrintFontManager()
Definition: gendata.hxx:81
GenericUnixSalDataType
Definition: gendata.hxx:26
SalGenericDisplay * m_pDisplay
Definition: gendata.hxx:43
GenericUnixSalData * GetGenericUnixSalData()
Definition: gendata.hxx:95