LibreOffice Module vcl (master) 1
salinst.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 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#ifndef INCLUDED_VCL_INC_SALINST_HXX
21#define INCLUDED_VCL_INC_SALINST_HXX
22
23#include <sal/types.h>
24#include <rtl/ref.hxx>
25#include <vcl/dllapi.h>
26#include <vcl/salgtype.hxx>
27#include <vcl/vclenum.hxx>
28
30
31#include <com/sun/star/uno/XComponentContext.hpp>
32#include <com/sun/star/ui/dialogs/XFilePicker2.hpp>
33#include <com/sun/star/ui/dialogs/XFolderPicker2.hpp>
34#include <memory>
35
36namespace com::sun::star::awt {
37 class XWindow;
38}
39namespace comphelper { class SolarMutex; }
40namespace vcl { class Window; }
41namespace weld {
42 class Builder;
43 class MessageDialog;
44 class Widget;
45 class Window;
46}
48struct SystemParentData;
50class ImplJobSetup;
51class OpenGLContext;
52class SalGraphics;
53class SalFrame;
54class SalObject;
55class SalMenu;
56class SalMenuItem;
58class SalInfoPrinter;
59class SalPrinter;
60class SalTimer;
62class SalSystem;
63class SalBitmap;
64struct SalItemParams;
65class SalSession;
66struct SystemEnvData;
68struct SystemWindowData;
69class Menu;
70enum class VclInputFlags;
71enum class SalFrameStyleFlags;
72
73typedef struct _cairo_font_options cairo_font_options_t;
74
76{
77private:
79 const std::unique_ptr<comphelper::SolarMutex> m_pYieldMutex;
80 css::uno::Reference<css::uno::XInterface> m_clipboard;
81
82protected:
83 bool m_bSupportsBitmap32 = false;
84 bool m_bSupportsOpenGL = false;
85
86public:
87 SalInstance(std::unique_ptr<comphelper::SolarMutex> pMutex);
88 virtual ~SalInstance();
89
90 bool supportsBitmap32() const { return m_bSupportsBitmap32; }
91 bool supportsOpenGL() const { return m_bSupportsOpenGL; }
92
93 //called directly after Application::Init
94 virtual void AfterAppInit() {}
95 virtual bool SVMainHook(int*) { return false; }
96
97 // Frame
98 // DisplayName for Unix ???
100 virtual SalFrame* CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle ) = 0;
101 virtual void DestroyFrame( SalFrame* pFrame ) = 0;
102
103 // Object (System Child Window)
104 virtual SalObject* CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, bool bShow ) = 0;
105 virtual void DestroyObject( SalObject* pObject ) = 0;
106
107 // VirtualDevice
108 // nDX and nDY in pixels
109 // nBitCount: 0 == default(=as window) / 1 == mono
110 // pData allows for using a system dependent graphics or device context,
111 // if a system context is passed in nDX and nDY are updated to reflect
112 // its size; otherwise these remain unchanged.
113 virtual std::unique_ptr<SalVirtualDevice>
115 tools::Long &rDX, tools::Long &rDY,
116 DeviceFormat eFormat, const SystemGraphicsData *pData = nullptr ) = 0;
117
118 // Printer
119 // pSetupData->mpDriverData can be 0
120 // pSetupData must be updated with the current
121 // JobSetup
123 ImplJobSetup* pSetupData ) = 0;
124 virtual void DestroyInfoPrinter( SalInfoPrinter* pPrinter ) = 0;
125 virtual std::unique_ptr<SalPrinter> CreatePrinter( SalInfoPrinter* pInfoPrinter ) = 0;
126
127 virtual void GetPrinterQueueInfo( ImplPrnQueueList* pList ) = 0;
128 virtual void GetPrinterQueueState( SalPrinterQueueInfo* pInfo ) = 0;
129 virtual OUString GetDefaultPrinter() = 0;
130
131 // SalTimer
132 virtual SalTimer* CreateSalTimer() = 0;
133 // SalSystem
135 // SalBitmap
136 virtual std::shared_ptr<SalBitmap> CreateSalBitmap() = 0;
137
138 // YieldMutex
139 comphelper::SolarMutex* GetYieldMutex();
140 sal_uInt32 ReleaseYieldMutexAll();
141 void AcquireYieldMutex(sal_uInt32 nCount = 1);
142
143 // return true, if the current thread is the main thread
144 virtual bool IsMainThread() const = 0;
145
152 virtual bool DoYield(bool bWait, bool bHandleAllCurrentEvents) = 0;
153 virtual bool AnyInput( VclInputFlags nType ) = 0;
154
155 // menus
156 virtual std::unique_ptr<SalMenu> CreateMenu( bool bMenuBar, Menu* pMenu );
157 virtual std::unique_ptr<SalMenuItem> CreateMenuItem( const SalItemParams& pItemData );
158
159 // may return NULL to disable session management, only used by X11 backend
160 virtual std::unique_ptr<SalSession> CreateSalSession();
161
162 // also needs to set m_bSupportsOpenGL = true in your SalInstance implementation!
163 virtual OpenGLContext* CreateOpenGLContext();
164
165 virtual std::unique_ptr<weld::Builder> CreateBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile);
166 virtual std::unique_ptr<weld::Builder> CreateInterimBuilder(vcl::Window* pParent, const OUString& rUIRoot, const OUString& rUIFile,
167 bool bAllowCycleFocusOut, sal_uInt64 nLOKWindowId = 0);
168 virtual weld::MessageDialog* CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType,
169 VclButtonsType eButtonType, const OUString& rPrimaryMessage);
170 virtual weld::Window* GetFrameWeld(const css::uno::Reference<css::awt::XWindow>& rWindow);
171
172 // methods for XDisplayConnection
173
175 { m_pEventInst = pInstance; }
176
177 bool CallEventCallback( void const * pEvent, int nBytes );
178
179 virtual OUString GetConnectionIdentifier() = 0;
180
181 // dtrans implementation
182 virtual css::uno::Reference< css::uno::XInterface > CreateClipboard( const css::uno::Sequence< css::uno::Any >& i_rArguments );
183 virtual css::uno::Reference<css::uno::XInterface> ImplCreateDragSource(const SystemEnvData*);
184 virtual css::uno::Reference<css::uno::XInterface> ImplCreateDropTarget(const SystemEnvData*);
185 css::uno::Reference<css::uno::XInterface> CreateDragSource(const SystemEnvData* = nullptr);
186 css::uno::Reference<css::uno::XInterface> CreateDropTarget(const SystemEnvData* = nullptr);
187 virtual void AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, const OUString& rDocumentService) = 0;
188
189 virtual bool hasNativeFileSelection() const { return false; }
190 // if you override this, make sure to override hasNativeFileSelection too.
191 virtual css::uno::Reference< css::ui::dialogs::XFilePicker2 > createFilePicker( const css::uno::Reference< css::uno::XComponentContext >& )
192 { return css::uno::Reference< css::ui::dialogs::XFilePicker2 >(); }
193 virtual css::uno::Reference< css::ui::dialogs::XFolderPicker2 > createFolderPicker( const css::uno::Reference< css::uno::XComponentContext >& )
194 { return css::uno::Reference< css::ui::dialogs::XFolderPicker2 >(); }
195
196 // callbacks for printer updates
197 virtual void updatePrinterUpdate() {}
198 virtual void jobStartedPrinterUpdate() {}
199 virtual void jobEndedPrinterUpdate() {}
200
202 virtual void updateMainThread() {}
204 virtual void releaseMainThread() {}
205
207 virtual OUString getOSVersion() { return "-"; }
208
209 virtual const cairo_font_options_t* GetCairoFontOptions() { return nullptr; }
210
211 virtual void* CreateGStreamerSink(const SystemChildWindow*) { return nullptr; }
212
213 virtual void BeforeAbort(const OUString& /* rErrorText */, bool /* bDumpCore */) {}
214
215 // Note: we cannot make this a global variable, because it might be initialised BEFORE the putenv() call in cppunittester.
216 static bool IsRunningUnitTest() { return getenv("LO_TESTNAME") != nullptr; }
217
218 // both must be implemented, if the VCL plugin needs to run via system event loop
219 virtual bool DoExecute(int &nExitCode);
220 virtual void DoQuit();
221};
222
223// called from SVMain
225void DestroySalInstance( SalInstance* pInst );
226
227void SalAbort( const OUString& rErrorText, bool bDumpCore );
228
229const OUString& SalGetDesktopEnvironment();
230
231#endif // INCLUDED_VCL_INC_SALINST_HXX
232
233/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: menu.hxx:116
A SalFrame is a system window (e.g. an X11 window).
Definition: salframe.hxx:115
virtual bool AnyInput(VclInputFlags nType)=0
virtual void DestroyFrame(SalFrame *pFrame)=0
virtual void GetPrinterQueueInfo(ImplPrnQueueList *pList)=0
virtual std::shared_ptr< SalBitmap > CreateSalBitmap()=0
virtual void AddToRecentDocumentList(const OUString &rFileUrl, const OUString &rMimeType, const OUString &rDocumentService)=0
virtual void BeforeAbort(const OUString &, bool)
Definition: salinst.hxx:213
rtl::Reference< vcl::DisplayConnectionDispatch > m_pEventInst
Definition: salinst.hxx:78
virtual bool SVMainHook(int *)
Definition: salinst.hxx:95
virtual bool IsMainThread() const =0
static bool IsRunningUnitTest()
Definition: salinst.hxx:216
virtual OUString GetDefaultPrinter()=0
virtual void DestroyInfoPrinter(SalInfoPrinter *pPrinter)=0
void SetEventCallback(rtl::Reference< vcl::DisplayConnectionDispatch > const &pInstance)
Definition: salinst.hxx:174
bool supportsOpenGL() const
Definition: salinst.hxx:91
virtual std::unique_ptr< SalVirtualDevice > CreateVirtualDevice(SalGraphics &rGraphics, tools::Long &rDX, tools::Long &rDY, DeviceFormat eFormat, const SystemGraphicsData *pData=nullptr)=0
virtual void jobStartedPrinterUpdate()
Definition: salinst.hxx:198
virtual SalTimer * CreateSalTimer()=0
virtual OUString getOSVersion()
get information about underlying versions
Definition: salinst.hxx:207
virtual SalFrame * CreateFrame(SalFrame *pParent, SalFrameStyleFlags nStyle)=0
virtual SalObject * CreateObject(SalFrame *pParent, SystemWindowData *pWindowData, bool bShow)=0
virtual SalInfoPrinter * CreateInfoPrinter(SalPrinterQueueInfo *pQueueInfo, ImplJobSetup *pSetupData)=0
virtual void updatePrinterUpdate()
Definition: salinst.hxx:197
virtual void DestroyObject(SalObject *pObject)=0
virtual void updateMainThread()
Set the app's (somewhat) magic/main-thread to this one.
Definition: salinst.hxx:202
virtual void GetPrinterQueueState(SalPrinterQueueInfo *pInfo)=0
virtual OUString GetConnectionIdentifier()=0
virtual bool hasNativeFileSelection() const
Definition: salinst.hxx:189
virtual css::uno::Reference< css::ui::dialogs::XFolderPicker2 > createFolderPicker(const css::uno::Reference< css::uno::XComponentContext > &)
Definition: salinst.hxx:193
virtual css::uno::Reference< css::ui::dialogs::XFilePicker2 > createFilePicker(const css::uno::Reference< css::uno::XComponentContext > &)
Definition: salinst.hxx:191
css::uno::Reference< css::uno::XInterface > m_clipboard
Definition: salinst.hxx:80
virtual void * CreateGStreamerSink(const SystemChildWindow *)
Definition: salinst.hxx:211
virtual bool DoYield(bool bWait, bool bHandleAllCurrentEvents)=0
Wait for the next event (if bWait) and dispatch it, includes posted events, and timers.
bool supportsBitmap32() const
Definition: salinst.hxx:90
virtual void AfterAppInit()
Definition: salinst.hxx:94
virtual void releaseMainThread()
Disconnect that - good for detaching from the JavaVM on Android.
Definition: salinst.hxx:204
virtual const cairo_font_options_t * GetCairoFontOptions()
Definition: salinst.hxx:209
const std::unique_ptr< comphelper::SolarMutex > m_pYieldMutex
Definition: salinst.hxx:79
virtual SalSystem * CreateSalSystem()=0
virtual std::unique_ptr< SalPrinter > CreatePrinter(SalInfoPrinter *pInfoPrinter)=0
virtual SalFrame * CreateChildFrame(SystemParentData *pParent, SalFrameStyleFlags nStyle)=0
virtual void jobEndedPrinterUpdate()
Definition: salinst.hxx:199
A non-visible drawable/buffer (e.g. an X11 Pixmap).
Definition: salvd.hxx:30
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
VclInputFlags
Definition: inputtypes.hxx:25
long Long
SalFrameStyleFlags
Definition: salframe.hxx:65
DeviceFormat
Definition: salgtype.hxx:28
void SalAbort(const OUString &rErrorText, bool bDumpCore)
Definition: salplug.cxx:368
const OUString & SalGetDesktopEnvironment()
Definition: salplug.cxx:409
void DestroySalInstance(SalInstance *pInst)
Definition: salplug.cxx:359
struct _cairo_font_options cairo_font_options_t
Definition: salinst.hxx:73
SalInstance * CreateSalInstance()
Definition: salplug.cxx:280
VclMessageType
Definition: vclenum.hxx:233
VclButtonsType
Definition: vclenum.hxx:223