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 
86 public:
87  SalInstance(std::unique_ptr<comphelper::SolarMutex> pMutex);
88  virtual ~SalInstance();
89 
90  //called directly after Application::Init
91  virtual void AfterAppInit() {}
92  virtual bool SVMainHook(int*) { return false; }
93 
94  // Frame
95  // DisplayName for Unix ???
96  virtual SalFrame* CreateChildFrame( SystemParentData* pParent, SalFrameStyleFlags nStyle ) = 0;
97  virtual SalFrame* CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle ) = 0;
98  virtual void DestroyFrame( SalFrame* pFrame ) = 0;
99 
100  // Object (System Child Window)
101  virtual SalObject* CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, bool bShow ) = 0;
102  virtual void DestroyObject( SalObject* pObject ) = 0;
103 
104  // VirtualDevice
105  // nDX and nDY in pixels
106  // nBitCount: 0 == default(=as window) / 1 == mono
107  // pData allows for using a system dependent graphics or device context,
108  // if a system context is passed in nDX and nDY are updated to reflect
109  // its size; otherwise these remain unchanged.
110  virtual std::unique_ptr<SalVirtualDevice>
111  CreateVirtualDevice( SalGraphics* pGraphics,
112  long &rDX, long &rDY,
113  DeviceFormat eFormat, const SystemGraphicsData *pData = nullptr ) = 0;
114 
115  // Printer
116  // pSetupData->mpDriverData can be 0
117  // pSetupData must be updated with the current
118  // JobSetup
119  virtual SalInfoPrinter* CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo,
120  ImplJobSetup* pSetupData ) = 0;
121  virtual void DestroyInfoPrinter( SalInfoPrinter* pPrinter ) = 0;
122  virtual std::unique_ptr<SalPrinter> CreatePrinter( SalInfoPrinter* pInfoPrinter ) = 0;
123 
124  virtual void GetPrinterQueueInfo( ImplPrnQueueList* pList ) = 0;
125  virtual void GetPrinterQueueState( SalPrinterQueueInfo* pInfo ) = 0;
126  virtual OUString GetDefaultPrinter() = 0;
127 
128  // SalTimer
129  virtual SalTimer* CreateSalTimer() = 0;
130  // SalSystem
131  virtual SalSystem* CreateSalSystem() = 0;
132  // SalBitmap
133  virtual std::shared_ptr<SalBitmap> CreateSalBitmap() = 0;
134  // BackendCapabilities
135  virtual std::shared_ptr<vcl::BackendCapabilities> GetBackendCapabilities()
136  {
137  return std::make_shared<vcl::BackendCapabilities>();
138  }
139 
140  // YieldMutex
141  comphelper::SolarMutex* GetYieldMutex();
142  sal_uInt32 ReleaseYieldMutexAll();
143  void AcquireYieldMutex(sal_uInt32 nCount = 1);
144 
145  // return true, if the current thread is the main thread
146  virtual bool IsMainThread() const = 0;
147 
154  virtual bool DoYield(bool bWait, bool bHandleAllCurrentEvents) = 0;
155  virtual bool AnyInput( VclInputFlags nType ) = 0;
156 
157  // menus
158  virtual std::unique_ptr<SalMenu> CreateMenu( bool bMenuBar, Menu* pMenu );
159  virtual std::unique_ptr<SalMenuItem> CreateMenuItem( const SalItemParams& pItemData );
160 
161  // may return NULL to disable session management, only used by X11 backend
162  virtual std::unique_ptr<SalSession> CreateSalSession();
163 
164  virtual OpenGLContext* CreateOpenGLContext() = 0;
165 
166  virtual weld::Builder* CreateBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile);
167  static weld::Builder* CreateInterimBuilder(vcl::Window* pParent, const OUString& rUIRoot, const OUString& rUIFile);
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 > CreateDragSource();
184  virtual css::uno::Reference< css::uno::XInterface > CreateDropTarget();
185  virtual void AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, const OUString& rDocumentService) = 0;
186 
187  virtual bool hasNativeFileSelection() const { return false; }
188  // if you override this, make sure to override hasNativeFileSelection too.
189  virtual css::uno::Reference< css::ui::dialogs::XFilePicker2 > createFilePicker( const css::uno::Reference< css::uno::XComponentContext >& )
190  { return css::uno::Reference< css::ui::dialogs::XFilePicker2 >(); }
191  virtual css::uno::Reference< css::ui::dialogs::XFolderPicker2 > createFolderPicker( const css::uno::Reference< css::uno::XComponentContext >& )
192  { return css::uno::Reference< css::ui::dialogs::XFolderPicker2 >(); }
193 
194  // callbacks for printer updates
195  virtual void updatePrinterUpdate() {}
196  virtual void jobStartedPrinterUpdate() {}
197  virtual void jobEndedPrinterUpdate() {}
198 
199  virtual void updateMainThread() {}
200 
202  virtual OUString getOSVersion() { return "-"; }
203 
204  virtual const cairo_font_options_t* GetCairoFontOptions() { return nullptr; }
205 
206  virtual void* CreateGStreamerSink(const SystemChildWindow*) { return nullptr; }
207 };
208 
209 // called from SVMain
211 void DestroySalInstance( SalInstance* pInst );
212 
213 void SalAbort( const OUString& rErrorText, bool bDumpCore );
214 
215 VCL_DLLPUBLIC const OUString& SalGetDesktopEnvironment();
216 
217 #endif // INCLUDED_VCL_INC_SALINST_HXX
218 
219 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual const cairo_font_options_t * GetCairoFontOptions()
Definition: salinst.hxx:204
void DestroySalInstance(SalInstance *pInst)
Definition: salplug.cxx:283
void SalAbort(const OUString &rErrorText, bool bDumpCore)
Definition: salplug.cxx:293
VclButtonsType
Definition: vclenum.hxx:243
#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:189
virtual css::uno::Reference< css::ui::dialogs::XFolderPicker2 > createFolderPicker(const css::uno::Reference< css::uno::XComponentContext > &)
Definition: salinst.hxx:191
virtual bool hasNativeFileSelection() const
Definition: salinst.hxx:187
VclInputFlags
Definition: inputtypes.hxx:25
SalInstance * CreateSalInstance()
Definition: salplug.cxx:228
VclMessageType
Definition: vclenum.hxx:253
virtual void updateMainThread()
Definition: salinst.hxx:199
virtual void AfterAppInit()
Definition: salinst.hxx:91
virtual void jobEndedPrinterUpdate()
Definition: salinst.hxx:197
virtual OUString getOSVersion()
get information about underlying versions
Definition: salinst.hxx:202
virtual std::shared_ptr< vcl::BackendCapabilities > GetBackendCapabilities()
Definition: salinst.hxx:135
virtual bool SVMainHook(int *)
Definition: salinst.hxx:92
VCL_DLLPUBLIC const OUString & SalGetDesktopEnvironment()
Definition: salplug.cxx:308
virtual void jobStartedPrinterUpdate()
Definition: salinst.hxx:196
virtual void * CreateGStreamerSink(const SystemChildWindow *)
Definition: salinst.hxx:206
virtual void updatePrinterUpdate()
Definition: salinst.hxx:195
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:121
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:174
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
rtl::Reference< vcl::DisplayConnectionDispatch > m_pEventInst
Definition: salinst.hxx:83