31#include <config_features.h>
32#include <config_vclplug.h>
36#include <rtl/bootstrap.hxx>
37#include <rtl/process.h>
45#define UNIX_DESKTOP_DETECT 1
48#define UNIX_DESKTOP_DETECT 0
52#if defined(DISABLE_DYNLOADING) || !HAVE_FEATURE_UI
53#define STATIC_SAL_INSTANCE 1
56#define STATIC_SAL_INSTANCE 0
57#include <osl/module.hxx>
62#include <UIKit/UIKit.h>
95#if !STATIC_SAL_INSTANCE
96oslModule pCloseModule =
nullptr;
100SalInstance* tryInstance(
const OUString& rModuleBase,
bool bForce =
false )
103 if (rModuleBase ==
"svp")
104 return svp_create_SalInstance();
108 OUString aUsedModuleBase(rModuleBase);
109 if (aUsedModuleBase ==
"kde5")
110 aUsedModuleBase =
"kf5";
115 "vclplug_" + aUsedModuleBase +
"lo" SAL_DLLEXTENSION );
118 if (aMod.loadRelative(
reinterpret_cast<oslGenericFunction
>(&tryInstance), aModule, SAL_LOADMODULE_GLOBAL))
120 salFactoryProc aProc =
reinterpret_cast<salFactoryProc
>(aMod.getFunctionSymbol(
"create_SalInstance"));
126 "sal plugin " << aModule <<
" produced instance " << pInst);
129 pCloseModule =
static_cast<oslModule
>(aMod);
138 if (aUsedModuleBase ==
"gtk4" || aUsedModuleBase ==
"gtk3" ||
139 aUsedModuleBase ==
"gtk3_kde5" || aUsedModuleBase ==
"kf5" ||
140 aUsedModuleBase ==
"kf6" ||
141 aUsedModuleBase ==
"qt5" || aUsedModuleBase ==
"qt6" ||
142 aUsedModuleBase ==
"win")
144 pCloseModule =
nullptr;
152 "could not load symbol create_SalInstance from shared object "
158 SAL_WARN(
"vcl.plugadapt",
"could not load shared object " << aModule);
162 SAL_INFO(
"vcl.plugadapt",
"could not load shared object " << aModule);
170#if UNIX_DESKTOP_DETECT
171#ifndef DISABLE_DYNLOADING
172extern "C" typedef DesktopType Fn_get_desktop_environment();
180#ifdef DISABLE_DYNLOADING
181 ret = get_desktop_environment();
183 OUString aModule(DESKTOP_DETECTOR_DLL_NAME);
184 oslModule aMod = osl_loadModuleRelative(
185 reinterpret_cast< oslGenericFunction
>( &tryInstance ), aModule.pData,
186 SAL_LOADMODULE_DEFAULT );
189 Fn_get_desktop_environment * pSym
190 =
reinterpret_cast<Fn_get_desktop_environment *
>(
191 osl_getAsciiFunctionSymbol(aMod,
"get_desktop_environment"));
195 osl_unloadModule( aMod );
200#if !STATIC_SAL_INSTANCE
201const char*
const* autodetect_plugin_list()
203 static const char*
const pKDEFallbackList[] =
220 static const char*
const pPlasma6FallbackList[] =
240 static const char*
const pStandardFallbackList[] =
252 static const char*
const pHeadlessFallbackList[] =
260 const char *
const * pList = pStandardFallbackList;
265 pList = pHeadlessFallbackList;
272 pList = pStandardFallbackList;
274 pList = pKDEFallbackList;
276 pList = pPlasma6FallbackList;
287bool IsHeadlessModeRequested()
292 sal_uInt32
n = rtl_getAppCommandArgCount();
293 for (sal_uInt32 i = 0;
i <
n; ++
i) {
295 rtl_getAppCommandArg(i, &arg.pData);
296 if ( arg ==
"--headless" || arg ==
"-headless" ) {
308 rtl::Bootstrap::get(
"SAL_USE_VCLPLUGIN", aUsePlugin);
309 SAL_INFO_IF(!aUsePlugin.isEmpty(),
"vcl.plugadapt",
"Requested VCL plugin: " << aUsePlugin);
314 if (aUsePlugin ==
"svp")
318 return svp_create_SalInstance();
324#if STATIC_SAL_INSTANCE
330 if( !aUsePlugin.isEmpty() )
331 pInst = tryInstance( aUsePlugin,
true );
333#if UNIX_DESKTOP_DETECT
334 const char*
const* pPluginList = pInst ? nullptr : autodetect_plugin_list();
335 for (
int i = 0; !pInst && pPluginList[
i]; ++
i)
337 pInst = tryInstance(OUString::createFromAscii(pPluginList[
i]));
338 SAL_INFO_IF(pInst,
"vcl.plugadapt",
"plugin autodetection: " << pPluginList[
i]);
343 static const char*
const pPlugin[] = {
374 for (
int i = 0; !pInst && pPlugin[
i]; ++
i)
375 pInst = tryInstance( OUString::createFromAscii( pPlugin[
i ] ) );
379 std::fprintf( stderr,
"no suitable windowing system found, exiting.\n" );
390#if !STATIC_SAL_INSTANCE
392 osl_unloadModule( pCloseModule );
396void SalAbort(
const OUString& rErrorText,
bool bDumpCore )
402 if( rErrorText.isEmpty() )
405 RaiseException( 0, EXCEPTION_NONCONTINUABLE, 0,
nullptr );
406 FatalAppExitW( 0, L
"Application Error" );
412 RaiseException( 0, EXCEPTION_NONCONTINUABLE, 0,
nullptr );
413 FatalAppExitW( 0, o3tl::toW(rErrorText.getStr()) );
417 OUString aError(rErrorText.isEmpty() ?
"Unspecified application error" : rErrorText);
420 NSLog(
@"SalAbort: %s",
OUStringToOString(rErrorText, osl_getThreadTextEncoding()).getStr());
422 if( rErrorText.isEmpty() )
423 std::fprintf( stderr,
"Unspecified Application Error\n" );
427 std::fprintf( stderr,
"%s\n",
OUStringToOString(rErrorText, osl_getThreadTextEncoding()).getStr() );
440 static OUString aDesktopEnvironment(
"headless");
442 static OUString aDesktopEnvironment(
"Windows" );
444 static OUString aDesktopEnvironment(
"MacOSX" );
445#elif defined(EMSCRIPTEN)
446 static OUString aDesktopEnvironment(
"WASM");
447#elif defined(ANDROID)
448 static OUString aDesktopEnvironment(
"android");
450 static OUString aDesktopEnvironment(
"iOS");
451#elif UNIX_DESKTOP_DETECT
453 static const char *
const desktop_strings[] = {
454 "none",
"unknown",
"GNOME",
"UNITY",
455 "XFCE",
"MATE",
"PLASMA5",
"PLASMA6",
"LXQT" };
456 static OUString aDesktopEnvironment;
457 if( aDesktopEnvironment.isEmpty())
459 aDesktopEnvironment = OUString::createFromAscii(
460 desktop_strings[lcl_get_desktop_environment()]);
463 static OUString aDesktopEnvironment(
"unknown");
465 return aDesktopEnvironment;
473 return SystemParametersInfoW(SPI_GETSCREENREADER, 0, &bIsRunning, 0)
static bool IsBitmapRendering()
Determines if bitmap rendering is enabled.
static void EnableBitmapRendering()
Enable software-only bitmap rendering.
static bool IsHeadlessModeEnabled()
Determines if headless mode is enabled.
static void addKeyValue(SAL_UNUSED_PARAMETER const OUString &, SAL_UNUSED_PARAMETER const OUString &, SAL_UNUSED_PARAMETER tAddKeyHandling)
virtual void BeforeAbort(const OUString &, bool)
enum SAL_DLLPUBLIC_RTTI DesktopType
#define SAL_INFO_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
const wchar_t *typedef BOOL
void SalAbort(const OUString &rErrorText, bool bDumpCore)
SalInstance * create_SalInstance()
const OUString & SalGetDesktopEnvironment()
void DestroySalInstance(SalInstance *pInst)
SalInstance * CreateSalInstance()
SalInstance * GetSalInstance()