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 
36 namespace com::sun::star::awt {
37  class XWindow;
38 }
39 namespace comphelper { class SolarMutex; }
40 namespace vcl { class Window; }
41 namespace weld {
42  class Builder;
43  class MessageDialog;
44  class Widget;
45  class Window;
46 }
47 class SystemChildWindow;
48 struct SystemParentData;
49 struct SalPrinterQueueInfo;
50 class ImplJobSetup;
51 class OpenGLContext;
52 class SalGraphics;
53 class SalFrame;
54 class SalObject;
55 class SalMenu;
56 class SalMenuItem;
57 class SalVirtualDevice;
58 class SalInfoPrinter;
59 class SalPrinter;
60 class SalTimer;
61 class ImplPrnQueueList;
62 class SalSystem;
63 class SalBitmap;
64 struct SalItemParams;
65 class SalSession;
66 struct SystemEnvData;
67 struct SystemGraphicsData;
68 struct SystemWindowData;
69 class Menu;
70 enum class VclInputFlags;
71 enum class SalFrameStyleFlags;
72 
73 typedef struct _cairo_font_options cairo_font_options_t;
74 
76 {
77 private:
79  const std::unique_ptr<comphelper::SolarMutex> m_pYieldMutex;
80  css::uno::Reference<css::uno::XInterface> m_clipboard;
81 
82 protected:
83  bool m_bSupportsBitmap32 = false;
84  bool m_bSupportsOpenGL = false;
85 
86 public:
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 ???
99  virtual SalFrame* CreateChildFrame( SystemParentData* pParent, SalFrameStyleFlags nStyle ) = 0;
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>
114  CreateVirtualDevice( SalGraphics& rGraphics,
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
122  virtual SalInfoPrinter* CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo,
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
134  virtual SalSystem* CreateSalSystem() = 0;
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 
219 // called from SVMain
221 void DestroySalInstance( SalInstance* pInst );
222 
223 void SalAbort( const OUString& rErrorText, bool bDumpCore );
224 
225 const OUString& SalGetDesktopEnvironment();
226 
227 #ifdef DISABLE_DYNLOADING
228 extern "C" SalInstance *create_SalInstance();
229 #endif
230 
231 #endif // INCLUDED_VCL_INC_SALINST_HXX
232 
233 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual const cairo_font_options_t * GetCairoFontOptions()
Definition: salinst.hxx:209
void DestroySalInstance(SalInstance *pInst)
Definition: salplug.cxx:325
void SalAbort(const OUString &rErrorText, bool bDumpCore)
Definition: salplug.cxx:334
static bool IsRunningUnitTest()
Definition: salinst.hxx:216
VclButtonsType
Definition: vclenum.hxx:242
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
long Long
virtual css::uno::Reference< css::ui::dialogs::XFilePicker2 > createFilePicker(const css::uno::Reference< css::uno::XComponentContext > &)
Definition: salinst.hxx:191
virtual css::uno::Reference< css::ui::dialogs::XFolderPicker2 > createFolderPicker(const css::uno::Reference< css::uno::XComponentContext > &)
Definition: salinst.hxx:193
virtual bool hasNativeFileSelection() const
Definition: salinst.hxx:189
VclInputFlags
Definition: inputtypes.hxx:25
SalInstance * CreateSalInstance()
Definition: salplug.cxx:261
VclMessageType
Definition: vclenum.hxx:252
virtual void updateMainThread()
Set the app's (somewhat) magic/main-thread to this one.
Definition: salinst.hxx:202
virtual void AfterAppInit()
Definition: salinst.hxx:94
const OUString & SalGetDesktopEnvironment()
Definition: salplug.cxx:373
virtual void jobEndedPrinterUpdate()
Definition: salinst.hxx:199
virtual void releaseMainThread()
Disconnect that - good for detaching from the JavaVM on Android.
Definition: salinst.hxx:204
virtual OUString getOSVersion()
get information about underlying versions
Definition: salinst.hxx:207
virtual void BeforeAbort(const OUString &, bool)
Definition: salinst.hxx:213
virtual bool SVMainHook(int *)
Definition: salinst.hxx:95
virtual void jobStartedPrinterUpdate()
Definition: salinst.hxx:198
bool supportsBitmap32() const
Definition: salinst.hxx:90
virtual void * CreateGStreamerSink(const SystemChildWindow *)
Definition: salinst.hxx:211
virtual void updatePrinterUpdate()
Definition: salinst.hxx:197
DeviceFormat
Definition: salgtype.hxx:28
A SalFrame is a system window (e.g. an X11 window).
Definition: salframe.hxx:114
struct _cairo_font_options cairo_font_options_t
Definition: salinst.hxx:73
Definition: menu.hxx:115
const std::unique_ptr< comphelper::SolarMutex > m_pYieldMutex
Definition: salinst.hxx:79
SalFrameStyleFlags
Definition: salframe.hxx:64
A non-visible drawable/buffer (e.g. an X11 Pixmap).
Definition: salvd.hxx:28
bool supportsOpenGL() const
Definition: salinst.hxx:91
void SetEventCallback(rtl::Reference< vcl::DisplayConnectionDispatch > const &pInstance)
Definition: salinst.hxx:174
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
css::uno::Reference< css::uno::XInterface > m_clipboard
Definition: salinst.hxx:80
rtl::Reference< vcl::DisplayConnectionDispatch > m_pEventInst
Definition: salinst.hxx:78