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 
32 
33 #include <com/sun/star/uno/XComponentContext.hpp>
34 #include <com/sun/star/ui/dialogs/XFilePicker2.hpp>
35 #include <com/sun/star/ui/dialogs/XFolderPicker2.hpp>
36 #include <memory>
37 
38 namespace com::sun::star::awt {
39  class XWindow;
40 }
41 namespace comphelper { class SolarMutex; }
42 namespace vcl { class Window; }
43 namespace weld {
44  class Builder;
45  class MessageDialog;
46  class Widget;
47  class Window;
48 }
49 class SystemChildWindow;
50 struct SystemParentData;
51 struct SalPrinterQueueInfo;
52 class ImplJobSetup;
53 class OpenGLContext;
54 class SalGraphics;
55 class SalFrame;
56 class SalObject;
57 class SalMenu;
58 class SalMenuItem;
59 class SalVirtualDevice;
60 class SalInfoPrinter;
61 class SalPrinter;
62 class SalTimer;
63 class ImplPrnQueueList;
64 class SalSystem;
65 class SalBitmap;
66 struct SalItemParams;
67 class SalSession;
68 struct SystemGraphicsData;
69 struct SystemWindowData;
70 class Menu;
71 enum class VclInputFlags;
72 enum class SalFrameStyleFlags;
73 
74 typedef struct _cairo_font_options cairo_font_options_t;
75 
77 {
78 private:
80  const std::unique_ptr<comphelper::SolarMutex> m_pYieldMutex;
81  css::uno::Reference<css::uno::XInterface> m_clipboard;
82 
83 public:
84  SalInstance(std::unique_ptr<comphelper::SolarMutex> pMutex);
85  virtual ~SalInstance();
86 
87  //called directly after Application::Init
88  virtual void AfterAppInit() {}
89  virtual bool SVMainHook(int*) { return false; }
90 
91  // Frame
92  // DisplayName for Unix ???
93  virtual SalFrame* CreateChildFrame( SystemParentData* pParent, SalFrameStyleFlags nStyle ) = 0;
94  virtual SalFrame* CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle ) = 0;
95  virtual void DestroyFrame( SalFrame* pFrame ) = 0;
96 
97  // Object (System Child Window)
98  virtual SalObject* CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, bool bShow ) = 0;
99  virtual void DestroyObject( SalObject* pObject ) = 0;
100 
101  // VirtualDevice
102  // nDX and nDY in pixels
103  // nBitCount: 0 == default(=as window) / 1 == mono
104  // pData allows for using a system dependent graphics or device context,
105  // if a system context is passed in nDX and nDY are updated to reflect
106  // its size; otherwise these remain unchanged.
107  virtual std::unique_ptr<SalVirtualDevice>
108  CreateVirtualDevice( SalGraphics* pGraphics,
109  long &rDX, long &rDY,
110  DeviceFormat eFormat, const SystemGraphicsData *pData = nullptr ) = 0;
111 
112  // Printer
113  // pSetupData->mpDriverData can be 0
114  // pSetupData must be updated with the current
115  // JobSetup
116  virtual SalInfoPrinter* CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo,
117  ImplJobSetup* pSetupData ) = 0;
118  virtual void DestroyInfoPrinter( SalInfoPrinter* pPrinter ) = 0;
119  virtual std::unique_ptr<SalPrinter> CreatePrinter( SalInfoPrinter* pInfoPrinter ) = 0;
120 
121  virtual void GetPrinterQueueInfo( ImplPrnQueueList* pList ) = 0;
122  virtual void GetPrinterQueueState( SalPrinterQueueInfo* pInfo ) = 0;
123  virtual OUString GetDefaultPrinter() = 0;
124 
125  // SalTimer
126  virtual SalTimer* CreateSalTimer() = 0;
127  // SalSystem
128  virtual SalSystem* CreateSalSystem() = 0;
129  // SalBitmap
130  virtual std::shared_ptr<SalBitmap> CreateSalBitmap() = 0;
131  // BackendCapabilities
132  virtual std::shared_ptr<vcl::BackendCapabilities> GetBackendCapabilities()
133  {
134  return std::make_shared<vcl::BackendCapabilities>();
135  }
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  virtual OpenGLContext* CreateOpenGLContext() = 0;
162 
163  virtual weld::Builder* CreateBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile);
164  virtual weld::Builder* CreateInterimBuilder(vcl::Window* pParent, const OUString& rUIRoot, const OUString& rUIFile,
165  bool bAllowCycleFocusOut, sal_uInt64 nLOKWindowId = 0);
166  virtual weld::MessageDialog* CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType,
167  VclButtonsType eButtonType, const OUString& rPrimaryMessage);
168  virtual weld::Window* GetFrameWeld(const css::uno::Reference<css::awt::XWindow>& rWindow);
169 
170  // methods for XDisplayConnection
171 
173  { m_pEventInst = pInstance; }
174 
175  bool CallEventCallback( void const * pEvent, int nBytes );
176 
177  virtual OUString GetConnectionIdentifier() = 0;
178 
179  // dtrans implementation
180  virtual css::uno::Reference< css::uno::XInterface > CreateClipboard( const css::uno::Sequence< css::uno::Any >& i_rArguments );
181  virtual css::uno::Reference< css::uno::XInterface > CreateDragSource();
182  virtual css::uno::Reference< css::uno::XInterface > CreateDropTarget();
183  virtual void AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, const OUString& rDocumentService) = 0;
184 
185  virtual bool hasNativeFileSelection() const { return false; }
186  // if you override this, make sure to override hasNativeFileSelection too.
187  virtual css::uno::Reference< css::ui::dialogs::XFilePicker2 > createFilePicker( const css::uno::Reference< css::uno::XComponentContext >& )
188  { return css::uno::Reference< css::ui::dialogs::XFilePicker2 >(); }
189  virtual css::uno::Reference< css::ui::dialogs::XFolderPicker2 > createFolderPicker( const css::uno::Reference< css::uno::XComponentContext >& )
190  { return css::uno::Reference< css::ui::dialogs::XFolderPicker2 >(); }
191 
192  // callbacks for printer updates
193  virtual void updatePrinterUpdate() {}
194  virtual void jobStartedPrinterUpdate() {}
195  virtual void jobEndedPrinterUpdate() {}
196 
198  virtual void updateMainThread() {}
200  virtual void releaseMainThread() {}
201 
203  virtual OUString getOSVersion() { return "-"; }
204 
205  virtual const cairo_font_options_t* GetCairoFontOptions() { return nullptr; }
206 
207  virtual void* CreateGStreamerSink(const SystemChildWindow*) { return nullptr; }
208 };
209 
210 // called from SVMain
212 void DestroySalInstance( SalInstance* pInst );
213 
214 void SalAbort( const OUString& rErrorText, bool bDumpCore );
215 
216 const OUString& SalGetDesktopEnvironment();
217 
218 #endif // INCLUDED_VCL_INC_SALINST_HXX
219 
220 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual const cairo_font_options_t * GetCairoFontOptions()
Definition: salinst.hxx:205
void DestroySalInstance(SalInstance *pInst)
Definition: salplug.cxx:283
void SalAbort(const OUString &rErrorText, bool bDumpCore)
Definition: salplug.cxx:293
VclButtonsType
Definition: vclenum.hxx:246
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
virtual css::uno::Reference< css::ui::dialogs::XFilePicker2 > createFilePicker(const css::uno::Reference< css::uno::XComponentContext > &)
Definition: salinst.hxx:187
virtual css::uno::Reference< css::ui::dialogs::XFolderPicker2 > createFolderPicker(const css::uno::Reference< css::uno::XComponentContext > &)
Definition: salinst.hxx:189
virtual bool hasNativeFileSelection() const
Definition: salinst.hxx:185
VclInputFlags
Definition: inputtypes.hxx:25
SalInstance * CreateSalInstance()
Definition: salplug.cxx:228
VclMessageType
Definition: vclenum.hxx:256
virtual void updateMainThread()
Set the app's (somewhat) magic/main-thread to this one.
Definition: salinst.hxx:198
virtual void AfterAppInit()
Definition: salinst.hxx:88
const OUString & SalGetDesktopEnvironment()
Definition: salplug.cxx:308
virtual void jobEndedPrinterUpdate()
Definition: salinst.hxx:195
virtual void releaseMainThread()
Disconnect that - good for detaching from the JavaVM on Android.
Definition: salinst.hxx:200
virtual OUString getOSVersion()
get information about underlying versions
Definition: salinst.hxx:203
virtual std::shared_ptr< vcl::BackendCapabilities > GetBackendCapabilities()
Definition: salinst.hxx:132
virtual bool SVMainHook(int *)
Definition: salinst.hxx:89
virtual void jobStartedPrinterUpdate()
Definition: salinst.hxx:194
virtual void * CreateGStreamerSink(const SystemChildWindow *)
Definition: salinst.hxx:207
virtual void updatePrinterUpdate()
Definition: salinst.hxx:193
DeviceFormat
Definition: salgtype.hxx:28
A SalFrame is a system window (e.g. an X11 window).
Definition: salframe.hxx:112
struct _cairo_font_options cairo_font_options_t
Definition: salinst.hxx:74
Definition: menu.hxx:118
const std::unique_ptr< comphelper::SolarMutex > m_pYieldMutex
Definition: salinst.hxx:80
SalFrameStyleFlags
Definition: salframe.hxx:64
A non-visible drawable/buffer (e.g. an X11 Pixmap).
Definition: salvd.hxx:28
void SetEventCallback(rtl::Reference< vcl::DisplayConnectionDispatch > const &pInstance)
Definition: salinst.hxx:172
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
css::uno::Reference< css::uno::XInterface > m_clipboard
Definition: salinst.hxx:81
rtl::Reference< vcl::DisplayConnectionDispatch > m_pEventInst
Definition: salinst.hxx:79