Line data Source code
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 : #include <saldatabasic.hxx>
15 :
16 : class SalGenericDisplay;
17 :
18 : // Not the prettiest - but helpful for migrating old code ...
19 : class SalDisplay;
20 : class GtkSalDisplay;
21 : enum SalGenericDataType { SAL_DATA_GTK, SAL_DATA_GTK3,
22 : SAL_DATA_TDE3, SAL_DATA_KDE3, SAL_DATA_KDE4,
23 : SAL_DATA_UNX, SAL_DATA_SVP,
24 : SAL_DATA_ANDROID, SAL_DATA_IOS,
25 : SAL_DATA_HEADLESS };
26 :
27 : class VCL_DLLPUBLIC SalGenericData : public SalData
28 : {
29 : protected:
30 : SalGenericDataType m_eType;
31 : SalGenericDisplay *m_pDisplay;
32 : // cached hostname to avoid slow lookup
33 : OUString m_aHostname;
34 : // for transient storage of unicode strings eg. 'u123' by input methods
35 : OUString m_aUnicodeEntry;
36 : public:
37 1 : SalGenericData( SalGenericDataType t, SalInstance *pInstance ) : SalData(), m_eType( t ), m_pDisplay( NULL ) { m_pInstance = pInstance; SetSalData( this ); }
38 0 : virtual ~SalGenericData() {}
39 0 : virtual void Dispose() {}
40 :
41 0 : SalGenericDisplay *GetDisplay() const { return m_pDisplay; }
42 0 : void SetDisplay( SalGenericDisplay *pDisp ) { m_pDisplay = pDisp; }
43 :
44 0 : const OUString& GetHostname()
45 : {
46 0 : if (m_aHostname.isEmpty())
47 0 : osl_getLocalHostname( &m_aHostname.pData );
48 0 : return m_aHostname;
49 : }
50 0 : OUString &GetUnicodeCommand()
51 : {
52 0 : return m_aUnicodeEntry;
53 : }
54 : inline SalGenericDataType GetType() const
55 : {
56 : return m_eType;
57 : }
58 :
59 : // Mostly useful for remote protocol backends
60 : virtual void ErrorTrapPush() = 0;
61 : virtual bool ErrorTrapPop( bool bIgnoreError = true ) = 0; // true on error
62 :
63 : // Not the prettiest - but helpful for migrating old code ...
64 0 : inline SalDisplay *GetSalDisplay() const
65 : {
66 : OSL_ASSERT( m_eType != SAL_DATA_GTK3 );
67 0 : return (SalDisplay *)GetDisplay();
68 : }
69 0 : inline GtkSalDisplay *GetGtkDisplay() const
70 : {
71 0 : return (GtkSalDisplay *)GetDisplay();
72 : }
73 : };
74 :
75 0 : inline SalGenericData * GetGenericData()
76 : {
77 0 : return (SalGenericData *)ImplGetSVData()->mpSalData;
78 : }
79 :
80 : #endif
81 :
82 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|