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 {
39 namespace sun {
40 namespace star {
41 namespace awt {
42  class XWindow;
43 }
44 } } }
45 namespace comphelper { class SolarMutex; }
46 namespace vcl { class Window; }
47 namespace weld {
48  class Builder;
49  class MessageDialog;
50  class Widget;
51  class Window;
52 }
53 class SystemChildWindow;
54 struct SystemParentData;
55 struct SalPrinterQueueInfo;
56 class ImplJobSetup;
57 class OpenGLContext;
58 class SalGraphics;
59 class SalFrame;
60 class SalObject;
61 class SalMenu;
62 class SalMenuItem;
63 class SalVirtualDevice;
64 class SalInfoPrinter;
65 class SalPrinter;
66 class SalTimer;
67 class ImplPrnQueueList;
68 class SalSystem;
69 class SalBitmap;
70 struct SalItemParams;
71 class SalSession;
72 struct SystemGraphicsData;
73 struct SystemWindowData;
74 class Menu;
75 enum class VclInputFlags;
76 enum class SalFrameStyleFlags;
77 
78 typedef struct _cairo_font_options cairo_font_options_t;
79 
81 {
82 private:
84  const std::unique_ptr<comphelper::SolarMutex> m_pYieldMutex;
85  css::uno::Reference<css::uno::XInterface> m_clipboard;
86 
87 public:
88  SalInstance(std::unique_ptr<comphelper::SolarMutex> pMutex);
89  virtual ~SalInstance();
90 
91  //called directly after Application::Init
92  virtual void AfterAppInit() {}
93  virtual bool SVMainHook(int*) { return false; }
94 
95  // Frame
96  // DisplayName for Unix ???
97  virtual SalFrame* CreateChildFrame( SystemParentData* pParent, SalFrameStyleFlags nStyle ) = 0;
98  virtual SalFrame* CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle ) = 0;
99  virtual void DestroyFrame( SalFrame* pFrame ) = 0;
100 
101  // Object (System Child Window)
102  virtual SalObject* CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, bool bShow ) = 0;
103  virtual void DestroyObject( SalObject* pObject ) = 0;
104 
105  // VirtualDevice
106  // nDX and nDY in pixels
107  // nBitCount: 0 == default(=as window) / 1 == mono
108  // pData allows for using a system dependent graphics or device context,
109  // if a system context is passed in nDX and nDY are updated to reflect
110  // its size; otherwise these remain unchanged.
111  virtual std::unique_ptr<SalVirtualDevice>
112  CreateVirtualDevice( SalGraphics* pGraphics,
113  long &rDX, long &rDY,
114  DeviceFormat eFormat, const SystemGraphicsData *pData = nullptr ) = 0;
115 
116  // Printer
117  // pSetupData->mpDriverData can be 0
118  // pSetupData must be updated with the current
119  // JobSetup
120  virtual SalInfoPrinter* CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo,
121  ImplJobSetup* pSetupData ) = 0;
122  virtual void DestroyInfoPrinter( SalInfoPrinter* pPrinter ) = 0;
123  virtual std::unique_ptr<SalPrinter> CreatePrinter( SalInfoPrinter* pInfoPrinter ) = 0;
124 
125  virtual void GetPrinterQueueInfo( ImplPrnQueueList* pList ) = 0;
126  virtual void GetPrinterQueueState( SalPrinterQueueInfo* pInfo ) = 0;
127  virtual OUString GetDefaultPrinter() = 0;
128 
129  // SalTimer
130  virtual SalTimer* CreateSalTimer() = 0;
131  // SalSystem
132  virtual SalSystem* CreateSalSystem() = 0;
133  // SalBitmap
134  virtual std::shared_ptr<SalBitmap> CreateSalBitmap() = 0;
135  // BackendCapabilities
136  virtual std::shared_ptr<vcl::BackendCapabilities> GetBackendCapabilities()
137  {
138  return std::make_shared<vcl::BackendCapabilities>();
139  }
140 
141  // YieldMutex
142  comphelper::SolarMutex* GetYieldMutex();
143  sal_uInt32 ReleaseYieldMutexAll();
144  void AcquireYieldMutex(sal_uInt32 nCount = 1);
145 
146  // return true, if the current thread is the main thread
147  virtual bool IsMainThread() const = 0;
148 
155  virtual bool DoYield(bool bWait, bool bHandleAllCurrentEvents) = 0;
156  virtual bool AnyInput( VclInputFlags nType ) = 0;
157 
158  // menus
159  virtual std::unique_ptr<SalMenu> CreateMenu( bool bMenuBar, Menu* pMenu );
160  virtual std::unique_ptr<SalMenuItem> CreateMenuItem( const SalItemParams& pItemData );
161 
162  // may return NULL to disable session management, only used by X11 backend
163  virtual std::unique_ptr<SalSession> CreateSalSession();
164 
165  virtual OpenGLContext* CreateOpenGLContext() = 0;
166 
167  virtual weld::Builder* CreateBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile);
168  virtual weld::Builder* CreateInterimBuilder(vcl::Window* pParent, const OUString& rUIRoot, const OUString& rUIFile, sal_uInt64 nLOKWindowId = 0);
169  virtual weld::MessageDialog* CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType,
170  VclButtonsType eButtonType, const OUString& rPrimaryMessage);
171  virtual weld::Window* GetFrameWeld(const css::uno::Reference<css::awt::XWindow>& rWindow);
172 
173  // methods for XDisplayConnection
174 
176  { m_pEventInst = pInstance; }
177 
178  bool CallEventCallback( void const * pEvent, int nBytes );
179 
180  virtual OUString GetConnectionIdentifier() = 0;
181 
182  // dtrans implementation
183  virtual css::uno::Reference< css::uno::XInterface > CreateClipboard( const css::uno::Sequence< css::uno::Any >& i_rArguments );
184  virtual css::uno::Reference< css::uno::XInterface > CreateDragSource();
185  virtual css::uno::Reference< css::uno::XInterface > CreateDropTarget();
186  virtual void AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, const OUString& rDocumentService) = 0;
187 
188  virtual bool hasNativeFileSelection() const { return false; }
189  // if you override this, make sure to override hasNativeFileSelection too.
190  virtual css::uno::Reference< css::ui::dialogs::XFilePicker2 > createFilePicker( const css::uno::Reference< css::uno::XComponentContext >& )
191  { return css::uno::Reference< css::ui::dialogs::XFilePicker2 >(); }
192  virtual css::uno::Reference< css::ui::dialogs::XFolderPicker2 > createFolderPicker( const css::uno::Reference< css::uno::XComponentContext >& )
193  { return css::uno::Reference< css::ui::dialogs::XFolderPicker2 >(); }
194 
195  // callbacks for printer updates
196  virtual void updatePrinterUpdate() {}
197  virtual void jobStartedPrinterUpdate() {}
198  virtual void jobEndedPrinterUpdate() {}
199 
201  virtual void updateMainThread() {}
203  virtual void releaseMainThread() {}
204 
206  virtual OUString getOSVersion() { return "-"; }
207 
208  virtual const cairo_font_options_t* GetCairoFontOptions() { return nullptr; }
209 
210  virtual void* CreateGStreamerSink(const SystemChildWindow*) { return nullptr; }
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 #endif // INCLUDED_VCL_INC_SALINST_HXX
222 
223 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual const cairo_font_options_t * GetCairoFontOptions()
Definition: salinst.hxx:208
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:190
exports com.sun.star. awt
virtual css::uno::Reference< css::ui::dialogs::XFolderPicker2 > createFolderPicker(const css::uno::Reference< css::uno::XComponentContext > &)
Definition: salinst.hxx:192
virtual bool hasNativeFileSelection() const
Definition: salinst.hxx:188
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:201
virtual void AfterAppInit()
Definition: salinst.hxx:92
const OUString & SalGetDesktopEnvironment()
Definition: salplug.cxx:308
virtual void jobEndedPrinterUpdate()
Definition: salinst.hxx:198
virtual void releaseMainThread()
Disconnect that - good for detaching from the JavaVM on Android.
Definition: salinst.hxx:203
virtual OUString getOSVersion()
get information about underlying versions
Definition: salinst.hxx:206
virtual std::shared_ptr< vcl::BackendCapabilities > GetBackendCapabilities()
Definition: salinst.hxx:136
virtual bool SVMainHook(int *)
Definition: salinst.hxx:93
virtual void jobStartedPrinterUpdate()
Definition: salinst.hxx:197
virtual void * CreateGStreamerSink(const SystemChildWindow *)
Definition: salinst.hxx:210
virtual void updatePrinterUpdate()
Definition: salinst.hxx:196
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:78
Definition: menu.hxx:118
const std::unique_ptr< comphelper::SolarMutex > m_pYieldMutex
Definition: salinst.hxx:84
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:175
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
css::uno::Reference< css::uno::XInterface > m_clipboard
Definition: salinst.hxx:85
rtl::Reference< vcl::DisplayConnectionDispatch > m_pEventInst
Definition: salinst.hxx:83