31#include <config_features.h>
32#include <config_vclplug.h>
36#include <rtl/bootstrap.hxx>
37#include <rtl/process.h>
44#define UNIX_DESKTOP_DETECT 1
47#define UNIX_DESKTOP_DETECT 0
50#if defined(DISABLE_DYNLOADING) || !HAVE_FEATURE_UI
51#define STATIC_SAL_INSTANCE 1
54#define STATIC_SAL_INSTANCE 0
55#include <osl/module.hxx>
60#include <UIKit/UIKit.h>
93#if !STATIC_SAL_INSTANCE
94oslModule pCloseModule =
nullptr;
98SalInstance* tryInstance(
const OUString& rModuleBase,
bool bForce =
false )
101 if (rModuleBase ==
"svp")
102 return svp_create_SalInstance();
106 OUString aUsedModuleBase(rModuleBase);
107 if (aUsedModuleBase ==
"kde5")
108 aUsedModuleBase =
"kf5";
113 "vclplug_" + aUsedModuleBase +
"lo" SAL_DLLEXTENSION );
116 if (aMod.loadRelative(
reinterpret_cast<oslGenericFunction
>(&tryInstance), aModule, SAL_LOADMODULE_GLOBAL))
118 salFactoryProc aProc =
reinterpret_cast<salFactoryProc
>(aMod.getFunctionSymbol(
"create_SalInstance"));
124 "sal plugin " << aModule <<
" produced instance " << pInst);
127 pCloseModule =
static_cast<oslModule
>(aMod);
136 if (aUsedModuleBase ==
"gtk4" || aUsedModuleBase ==
"gtk3" ||
137 aUsedModuleBase ==
"gtk3_kde5" || aUsedModuleBase ==
"kf5" ||
138 aUsedModuleBase ==
"qt5" || aUsedModuleBase ==
"qt6" ||
139 aUsedModuleBase ==
"win")
141 pCloseModule =
nullptr;
149 "could not load symbol create_SalInstance from shared object "
155 SAL_WARN(
"vcl.plugadapt",
"could not load shared object " << aModule);
159 SAL_INFO(
"vcl.plugadapt",
"could not load shared object " << aModule);
167#if UNIX_DESKTOP_DETECT
168#ifndef DISABLE_DYNLOADING
169extern "C" typedef DesktopType Fn_get_desktop_environment();
177#ifdef DISABLE_DYNLOADING
178 ret = get_desktop_environment();
180 OUString aModule(DESKTOP_DETECTOR_DLL_NAME);
181 oslModule aMod = osl_loadModuleRelative(
182 reinterpret_cast< oslGenericFunction
>( &tryInstance ), aModule.pData,
183 SAL_LOADMODULE_DEFAULT );
186 Fn_get_desktop_environment * pSym
187 =
reinterpret_cast<Fn_get_desktop_environment *
>(
188 osl_getAsciiFunctionSymbol(aMod,
"get_desktop_environment"));
192 osl_unloadModule( aMod );
197#if !STATIC_SAL_INSTANCE
198const char*
const* autodetect_plugin_list()
200 static const char*
const pKDEFallbackList[] =
217 static const char*
const pStandardFallbackList[] =
229 static const char*
const pHeadlessFallbackList[] =
237 const char *
const * pList = pStandardFallbackList;
242 pList = pHeadlessFallbackList;
249 pList = pStandardFallbackList;
251 pList = pKDEFallbackList;
262bool IsHeadlessModeRequested()
267 sal_uInt32
n = rtl_getAppCommandArgCount();
268 for (sal_uInt32 i = 0;
i <
n; ++
i) {
270 rtl_getAppCommandArg(i, &arg.pData);
271 if ( arg ==
"--headless" || arg ==
"-headless" ) {
283 rtl::Bootstrap::get(
"SAL_USE_VCLPLUGIN", aUsePlugin);
284 SAL_INFO_IF(!aUsePlugin.isEmpty(),
"vcl.plugadapt",
"Requested VCL plugin: " << aUsePlugin);
289 if (aUsePlugin ==
"svp")
293 return svp_create_SalInstance();
299#if STATIC_SAL_INSTANCE
305 if( !aUsePlugin.isEmpty() )
306 pInst = tryInstance( aUsePlugin,
true );
308#if UNIX_DESKTOP_DETECT
309 const char*
const* pPluginList = pInst ? nullptr : autodetect_plugin_list();
310 for (
int i = 0; !pInst && pPluginList[
i]; ++
i)
312 pInst = tryInstance(OUString::createFromAscii(pPluginList[
i]));
313 SAL_INFO_IF(pInst,
"vcl.plugadapt",
"plugin autodetection: " << pPluginList[
i]);
318 static const char*
const pPlugin[] = {
346 for (
int i = 0; !pInst && pPlugin[
i]; ++
i)
347 pInst = tryInstance( OUString::createFromAscii( pPlugin[
i ] ) );
351 std::fprintf( stderr,
"no suitable windowing system found, exiting.\n" );
362#if !STATIC_SAL_INSTANCE
364 osl_unloadModule( pCloseModule );
368void SalAbort(
const OUString& rErrorText,
bool bDumpCore )
374 if( rErrorText.isEmpty() )
377 RaiseException( 0, EXCEPTION_NONCONTINUABLE, 0,
nullptr );
378 FatalAppExitW( 0, L
"Application Error" );
384 RaiseException( 0, EXCEPTION_NONCONTINUABLE, 0,
nullptr );
385 FatalAppExitW( 0, o3tl::toW(rErrorText.getStr()) );
389 OUString aError(rErrorText.isEmpty() ?
"Unspecified application error" : rErrorText);
392 NSLog(
@"SalAbort: %s",
OUStringToOString(rErrorText, osl_getThreadTextEncoding()).getStr());
394 if( rErrorText.isEmpty() )
395 std::fprintf( stderr,
"Unspecified Application Error\n" );
399 std::fprintf( stderr,
"%s\n",
OUStringToOString(rErrorText, osl_getThreadTextEncoding()).getStr() );
412 static OUString aDesktopEnvironment(
"headless");
414 static OUString aDesktopEnvironment(
"Windows" );
416 static OUString aDesktopEnvironment(
"MacOSX" );
417#elif defined(EMSCRIPTEN)
418 static OUString aDesktopEnvironment(
"WASM");
419#elif defined(ANDROID)
420 static OUString aDesktopEnvironment(
"android");
422 static OUString aDesktopEnvironment(
"iOS");
423#elif UNIX_DESKTOP_DETECT
425 static const char *
const desktop_strings[] = {
426 "none",
"unknown",
"GNOME",
"UNITY",
427 "XFCE",
"MATE",
"PLASMA5",
"LXQT" };
428 static OUString aDesktopEnvironment;
429 if( aDesktopEnvironment.isEmpty())
431 aDesktopEnvironment = OUString::createFromAscii(
432 desktop_strings[lcl_get_desktop_environment()]);
435 static OUString aDesktopEnvironment(
"unknown");
437 return aDesktopEnvironment;
445 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()