summaryrefslogtreecommitdiffstats
path: root/vcl/inc/generic/gendata.hxx
blob: 334193d402a54e6d8d4699ec26a17593c372e135 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#ifndef INCLUDED_VCL_INC_GENERIC_GENDATA_HXX
#define INCLUDED_VCL_INC_GENERIC_GENDATA_HXX

#include <osl/socket.hxx>
#include <saldatabasic.hxx>

class SalGenericDisplay;

// Not the prettiest - but helpful for migrating old code ...
class SalDisplay;
class GtkSalDisplay;
enum SalGenericDataType { SAL_DATA_GTK, SAL_DATA_GTK3,
                          SAL_DATA_TDE3, SAL_DATA_KDE3, SAL_DATA_KDE4,
                          SAL_DATA_UNX, SAL_DATA_SVP,
                          SAL_DATA_ANDROID, SAL_DATA_IOS,
                          SAL_DATA_HEADLESS };

class VCL_DLLPUBLIC SalGenericData : public SalData
{
 protected:
    SalGenericDataType m_eType;
    SalGenericDisplay *m_pDisplay;
    // cached hostname to avoid slow lookup
    OUString      m_aHostname;
    // for transient storage of unicode strings eg. 'u123' by input methods
    OUString      m_aUnicodeEntry;
 public:
    SalGenericData( SalGenericDataType t, SalInstance *pInstance ) : SalData(), m_eType( t ), m_pDisplay( NULL ) { m_pInstance = pInstance; SetSalData( this ); }
    virtual ~SalGenericData() {}
    virtual void Dispose() {}

    SalGenericDisplay *GetDisplay() const { return m_pDisplay; }
    void               SetDisplay( SalGenericDisplay *pDisp ) { m_pDisplay = pDisp; }

    const OUString& GetHostname()
    {
        if (m_aHostname.isEmpty())
            osl_getLocalHostname( &m_aHostname.pData );
        return m_aHostname;
    }
    OUString &GetUnicodeCommand()
    {
        return m_aUnicodeEntry;
    }
    inline SalGenericDataType GetType() const
    {
        return m_eType;
    }

    // Mostly useful for remote protocol backends
    virtual void ErrorTrapPush() = 0;
    virtual bool ErrorTrapPop( bool bIgnoreError = true ) = 0; // true on error

    // Not the prettiest - but helpful for migrating old code ...
    inline SalDisplay *GetSalDisplay() const
    {
        OSL_ASSERT( m_eType != SAL_DATA_GTK3 );
        return (SalDisplay *)GetDisplay();
    }
    inline GtkSalDisplay *GetGtkDisplay() const
    {
        return (GtkSalDisplay *)GetDisplay();
    }
};

inline SalGenericData * GetGenericData()
{
    return static_cast<SalGenericData *>(ImplGetSVData()->mpSalData);
}

#endif

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */