1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_VCL_INC_SALINST_HXX
21 #define INCLUDED_VCL_INC_SALINST_HXX
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>
29 #include "displayconnectiondispatch.hxx"
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>
36 namespace com::sun::star::awt
{
39 namespace comphelper
{ class SolarMutex
; }
40 namespace vcl
{ class Window
; }
47 class SystemChildWindow
;
48 struct SystemParentData
;
49 struct SalPrinterQueueInfo
;
57 class SalVirtualDevice
;
61 class ImplPrnQueueList
;
67 struct SystemGraphicsData
;
68 struct SystemWindowData
;
70 enum class VclInputFlags
;
71 enum class SalFrameStyleFlags
;
73 typedef struct _cairo_font_options cairo_font_options_t
;
75 class VCL_DLLPUBLIC SalInstance
78 rtl::Reference
< vcl::DisplayConnectionDispatch
> m_pEventInst
;
79 const std::unique_ptr
<comphelper::SolarMutex
> m_pYieldMutex
;
80 css::uno::Reference
<css::uno::XInterface
> m_clipboard
;
83 bool m_bSupportsBitmap32
= false;
84 bool m_bSupportsOpenGL
= false;
87 SalInstance(std::unique_ptr
<comphelper::SolarMutex
> pMutex
);
88 virtual ~SalInstance();
90 bool supportsBitmap32() const { return m_bSupportsBitmap32
; }
91 bool supportsOpenGL() const { return m_bSupportsOpenGL
; }
93 //called directly after Application::Init
94 virtual void AfterAppInit() {}
95 virtual bool SVMainHook(int*) { return false; }
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;
103 // Object (System Child Window)
104 virtual SalObject
* CreateObject( SalFrame
* pParent
, SystemWindowData
* pWindowData
, bool bShow
) = 0;
105 virtual void DestroyObject( SalObject
* pObject
) = 0;
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;
119 // pSetupData->mpDriverData can be 0
120 // pSetupData must be updated with the current
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;
127 virtual void GetPrinterQueueInfo( ImplPrnQueueList
* pList
) = 0;
128 virtual void GetPrinterQueueState( SalPrinterQueueInfo
* pInfo
) = 0;
129 virtual OUString
GetDefaultPrinter() = 0;
132 virtual SalTimer
* CreateSalTimer() = 0;
134 virtual SalSystem
* CreateSalSystem() = 0;
136 virtual std::shared_ptr
<SalBitmap
> CreateSalBitmap() = 0;
139 comphelper::SolarMutex
* GetYieldMutex();
140 sal_uInt32
ReleaseYieldMutexAll();
141 void AcquireYieldMutex(sal_uInt32 nCount
= 1);
143 // return true, if the current thread is the main thread
144 virtual bool IsMainThread() const = 0;
147 * Wait for the next event (if bWait) and dispatch it,
148 * includes posted events, and timers.
149 * If bHandleAllCurrentEvents - dispatch multiple posted
150 * user events. Returns true if events were processed.
152 virtual bool DoYield(bool bWait
, bool bHandleAllCurrentEvents
) = 0;
153 virtual bool AnyInput( VclInputFlags nType
) = 0;
156 virtual std::unique_ptr
<SalMenu
> CreateMenu( bool bMenuBar
, Menu
* pMenu
);
157 virtual std::unique_ptr
<SalMenuItem
> CreateMenuItem( const SalItemParams
& pItemData
);
159 // may return NULL to disable session management, only used by X11 backend
160 virtual std::unique_ptr
<SalSession
> CreateSalSession();
162 // also needs to set m_bSupportsOpenGL = true in your SalInstance implementation!
163 virtual OpenGLContext
* CreateOpenGLContext();
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
);
172 // methods for XDisplayConnection
174 void SetEventCallback( rtl::Reference
< vcl::DisplayConnectionDispatch
> const & pInstance
)
175 { m_pEventInst
= pInstance
; }
177 bool CallEventCallback( void const * pEvent
, int nBytes
);
179 virtual OUString
GetConnectionIdentifier() = 0;
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;
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
>(); }
196 // callbacks for printer updates
197 virtual void updatePrinterUpdate() {}
198 virtual void jobEndedPrinterUpdate() {}
200 /// Set the app's (somewhat) magic/main-thread to this one.
201 virtual void updateMainThread() {}
202 /// Disconnect that - good for detaching from the JavaVM on Android.
203 virtual void releaseMainThread() {}
205 /// get information about underlying versions
206 virtual OUString
getOSVersion() { return "-"; }
208 virtual const cairo_font_options_t
* GetCairoFontOptions() { return nullptr; }
210 virtual void* CreateGStreamerSink(const SystemChildWindow
*) { return nullptr; }
212 virtual void BeforeAbort(const OUString
& /* rErrorText */, bool /* bDumpCore */) {}
214 // Note: we cannot make this a global variable, because it might be initialised BEFORE the putenv() call in cppunittester.
215 static bool IsRunningUnitTest() { return getenv("LO_TESTNAME") != nullptr; }
217 // both must be implemented, if the VCL plugin needs to run via system event loop
218 virtual bool DoExecute(int &nExitCode
);
219 virtual void DoQuit();
222 // called from SVMain
223 SalInstance
* CreateSalInstance();
224 void DestroySalInstance( SalInstance
* pInst
);
226 void SalAbort( const OUString
& rErrorText
, bool bDumpCore
);
228 const OUString
& SalGetDesktopEnvironment();
230 #endif // INCLUDED_VCL_INC_SALINST_HXX
232 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */