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 SystemGraphicsData;
67 struct SystemWindowData;
68 class Menu;
69 enum class VclInputFlags;
70 enum class SalFrameStyleFlags;
71 
72 typedef struct _cairo_font_options cairo_font_options_t;
73 
75 {
76 private:
78  const std::unique_ptr<comphelper::SolarMutex> m_pYieldMutex;
79  css::uno::Reference<css::uno::XInterface> m_clipboard;
80 
81 protected:
82  bool m_bSupportsBitmap32 = false;
83  bool m_bSupportsOpenGL = false;
84 
85 public:
86  SalInstance(std::unique_ptr<comphelper::SolarMutex> pMutex);
87  virtual ~SalInstance();
88 
89  bool supportsBitmap32() const { return m_bSupportsBitmap32; }
90  bool supportsOpenGL() const { return m_bSupportsOpenGL; }
91 
92  //called directly after Application::Init
93  virtual void AfterAppInit() {}
94  virtual bool SVMainHook(int*) { return false; }
95 
96  // Frame
97  // DisplayName for Unix ???
98  virtual SalFrame* CreateChildFrame( SystemParentData* pParent, SalFrameStyleFlags nStyle ) = 0;
99  virtual SalFrame* CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle ) = 0;
100  virtual void DestroyFrame( SalFrame* pFrame ) = 0;
101 
102  // Object (System Child Window)
103  virtual SalObject* CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, bool bShow ) = 0;
104  virtual void DestroyObject( SalObject* pObject ) = 0;
105 
106  // VirtualDevice
107  // nDX and nDY in pixels
108  // nBitCount: 0 == default(=as window) / 1 == mono
109  // pData allows for using a system dependent graphics or device context,
110  // if a system context is passed in nDX and nDY are updated to reflect
111  // its size; otherwise these remain unchanged.
112  virtual std::unique_ptr<SalVirtualDevice>
113  CreateVirtualDevice( SalGraphics& rGraphics,
114  tools::Long &rDX, tools::Long &rDY,
115  DeviceFormat eFormat, const SystemGraphicsData *pData = nullptr ) = 0;
116 
117  // Printer
118  // pSetupData->mpDriverData can be 0
119  // pSetupData must be updated with the current
120  // JobSetup
121  virtual SalInfoPrinter* CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo,
122  ImplJobSetup* pSetupData ) = 0;
123  virtual void DestroyInfoPrinter( SalInfoPrinter* pPrinter ) = 0;
124  virtual std::unique_ptr<SalPrinter> CreatePrinter( SalInfoPrinter* pInfoPrinter ) = 0;
125 
126  virtual void GetPrinterQueueInfo( ImplPrnQueueList* pList ) = 0;
127  virtual void GetPrinterQueueState( SalPrinterQueueInfo* pInfo ) = 0;
128  virtual OUString GetDefaultPrinter() = 0;
129 
130  // SalTimer
131  virtual SalTimer* CreateSalTimer() = 0;
132  // SalSystem
133  virtual SalSystem* CreateSalSystem() = 0;
134  // SalBitmap
135  virtual std::shared_ptr<SalBitmap> CreateSalBitmap() = 0;
136 
137  // YieldMutex
138  comphelper::SolarMutex* GetYieldMutex();
139  sal_uInt32 ReleaseYieldMutexAll();
140  void AcquireYieldMutex(sal_uInt32 nCount = 1);
141 
142  // return true, if the current thread is the main thread
143  virtual bool IsMainThread() const = 0;
144 
151  virtual bool DoYield(bool bWait, bool bHandleAllCurrentEvents) = 0;
152  virtual bool AnyInput( VclInputFlags nType ) = 0;
153 
154  // menus
155  virtual std::unique_ptr<SalMenu> CreateMenu( bool bMenuBar, Menu* pMenu );
156  virtual std::unique_ptr<SalMenuItem> CreateMenuItem( const SalItemParams& pItemData );
157 
158  // may return NULL to disable session management, only used by X11 backend
159  virtual std::unique_ptr<SalSession> CreateSalSession();
160 
161  // also needs to set m_bSupportsOpenGL = true in your SalInstance implementation!
162  virtual OpenGLContext* CreateOpenGLContext();
163 
164  virtual weld::Builder* CreateBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile);
165  virtual weld::Builder* CreateInterimBuilder(vcl::Window* pParent, const OUString& rUIRoot, const OUString& rUIFile,
166  bool bAllowCycleFocusOut, sal_uInt64 nLOKWindowId = 0);
167  virtual weld::MessageDialog* CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType,
168  VclButtonsType eButtonType, const OUString& rPrimaryMessage);
169  virtual weld::Window* GetFrameWeld(const css::uno::Reference<css::awt::XWindow>& rWindow);
170 
171  // methods for XDisplayConnection
172 
174  { m_pEventInst = pInstance; }
175 
176  bool CallEventCallback( void const * pEvent, int nBytes );
177 
178  virtual OUString GetConnectionIdentifier() = 0;
179 
180  // dtrans implementation
181  virtual css::uno::Reference< css::uno::XInterface > CreateClipboard( const css::uno::Sequence< css::uno::Any >& i_rArguments );
182  virtual css::uno::Reference< css::uno::XInterface > CreateDragSource();
183  virtual css::uno::Reference< css::uno::XInterface > CreateDropTarget();
184  virtual void AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, const OUString& rDocumentService) = 0;
185 
186  virtual bool hasNativeFileSelection() const { return false; }
187  // if you override this, make sure to override hasNativeFileSelection too.
188  virtual css::uno::Reference< css::ui::dialogs::XFilePicker2 > createFilePicker( const css::uno::Reference< css::uno::XComponentContext >& )
189  { return css::uno::Reference< css::ui::dialogs::XFilePicker2 >(); }
190  virtual css::uno::Reference< css::ui::dialogs::XFolderPicker2 > createFolderPicker( const css::uno::Reference< css::uno::XComponentContext >& )
191  { return css::uno::Reference< css::ui::dialogs::XFolderPicker2 >(); }
192 
193  // callbacks for printer updates
194  virtual void updatePrinterUpdate() {}
195  virtual void jobStartedPrinterUpdate() {}
196  virtual void jobEndedPrinterUpdate() {}
197 
199  virtual void updateMainThread() {}
201  virtual void releaseMainThread() {}
202 
204  virtual OUString getOSVersion() { return "-"; }
205 
206  virtual const cairo_font_options_t* GetCairoFontOptions() { return nullptr; }
207 
208  virtual void* CreateGStreamerSink(const SystemChildWindow*) { return nullptr; }
209 
210  virtual void BeforeAbort(const OUString& /* rErrorText */, bool /* bDumpCore */) {}
211 };
212 
213 // called from SVMain
215 void DestroySalInstance( SalInstance* pInst );
216 
217 void SalAbort( const OUString& rErrorText, bool bDumpCore );
218 
219 const OUString& SalGetDesktopEnvironment();
220 
221 #ifdef DISABLE_DYNLOADING
222 extern "C" SalInstance *create_SalInstance();
223 #endif
224 
225 #endif // INCLUDED_VCL_INC_SALINST_HXX
226 
227 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual const cairo_font_options_t * GetCairoFontOptions()
Definition: salinst.hxx:206
void DestroySalInstance(SalInstance *pInst)
Definition: salplug.cxx:305
void SalAbort(const OUString &rErrorText, bool bDumpCore)
Definition: salplug.cxx:317
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:188
virtual css::uno::Reference< css::ui::dialogs::XFolderPicker2 > createFolderPicker(const css::uno::Reference< css::uno::XComponentContext > &)
Definition: salinst.hxx:190
virtual bool hasNativeFileSelection() const
Definition: salinst.hxx:186
VclInputFlags
Definition: inputtypes.hxx:25
SalInstance * CreateSalInstance()
Definition: salplug.cxx:250
VclMessageType
Definition: vclenum.hxx:252
virtual void updateMainThread()
Set the app's (somewhat) magic/main-thread to this one.
Definition: salinst.hxx:199
virtual void AfterAppInit()
Definition: salinst.hxx:93
const OUString & SalGetDesktopEnvironment()
Definition: salplug.cxx:356
virtual void jobEndedPrinterUpdate()
Definition: salinst.hxx:196
virtual void releaseMainThread()
Disconnect that - good for detaching from the JavaVM on Android.
Definition: salinst.hxx:201
virtual OUString getOSVersion()
get information about underlying versions
Definition: salinst.hxx:204
virtual void BeforeAbort(const OUString &, bool)
Definition: salinst.hxx:210
virtual bool SVMainHook(int *)
Definition: salinst.hxx:94
virtual void jobStartedPrinterUpdate()
Definition: salinst.hxx:195
bool supportsBitmap32() const
Definition: salinst.hxx:89
virtual void * CreateGStreamerSink(const SystemChildWindow *)
Definition: salinst.hxx:208
virtual void updatePrinterUpdate()
Definition: salinst.hxx:194
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:72
Definition: menu.hxx:123
const std::unique_ptr< comphelper::SolarMutex > m_pYieldMutex
Definition: salinst.hxx:78
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:90
void SetEventCallback(rtl::Reference< vcl::DisplayConnectionDispatch > const &pInstance)
Definition: salinst.hxx:173
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
css::uno::Reference< css::uno::XInterface > m_clipboard
Definition: salinst.hxx:79
rtl::Reference< vcl::DisplayConnectionDispatch > m_pEventInst
Definition: salinst.hxx:77