include/vcl/svapp.hxx         |    5 -
 solenv/clang-format/blacklist |    4 
 vcl/Library_vcl.mk            |   20 ++--
 vcl/README                    |    2 
 vcl/android/androidinst.cxx   |    5 -
 vcl/headless/headlessinst.cxx |    5 -
 vcl/inc/osx/saldata.hxx       |    2 
 vcl/inc/salinst.hxx           |    7 -
 vcl/inc/win/saldata.hxx       |    1 
 vcl/ios/iosinst.cxx           |    5 -
 vcl/osx/salinst.cxx           |    6 -
 vcl/osx/salplug.cxx           |  167 -----------------------------------
 vcl/source/app/salplug.cxx    |  165 ++++++++++++++++++++--------------
 vcl/source/app/svapp.cxx      |    2 
 vcl/source/app/svmain.cxx     |    1 
 vcl/win/app/salplug.cxx       |  199 ------------------------------------------
 16 files changed, 115 insertions(+), 481 deletions(-)

New commits:
commit 0f3be2e19fa408d7069d586ccf04cb3f3eccd6b9
Author:     Jan-Marek Glogowski <glo...@fbihome.de>
AuthorDate: Thu Sep 13 12:23:36 2018 +0200
Commit:     Jan-Marek Glogowski <glo...@fbihome.de>
CommitDate: Tue Oct 2 11:24:38 2018 +0200

    Unify sal plugin loaders
    
    Change-Id: Ic099761eaff80349e985ccf62e3f4aa6b2e98022
    Reviewed-on: https://gerrit.libreoffice.org/61103
    Tested-by: Jenkins
    Reviewed-by: Jan-Marek Glogowski <glo...@fbihome.de>

diff --git a/include/vcl/svapp.hxx b/include/vcl/svapp.hxx
index e3c33af5d774..8fd852a5cb53 100644
--- a/include/vcl/svapp.hxx
+++ b/include/vcl/svapp.hxx
@@ -259,8 +259,6 @@ public:
     platform specific data structures.
 
     @attention The initialization of the application itself is done in Init()
-
-    @see    InitSalData is implemented by platform specific code.
     */
                                 Application();
 
@@ -268,9 +266,6 @@ public:
 
      Deinitializes the LibreOffice global instance data structure, then
      deinitializes any platform specific data structures.
-
-     @see   ImplDeInitSVData deinitializes the global instance data,
-            DeInitSalData is implemented by platform specific code
     */
     virtual                     ~Application();
 
diff --git a/solenv/clang-format/blacklist b/solenv/clang-format/blacklist
index 116e97c043fc..1b9f24a6c8a6 100644
--- a/solenv/clang-format/blacklist
+++ b/solenv/clang-format/blacklist
@@ -17915,7 +17915,6 @@ vcl/osx/salinst.cxx
 vcl/osx/salmenu.cxx
 vcl/osx/salnativewidgets.cxx
 vcl/osx/salobj.cxx
-vcl/osx/salplug.cxx
 vcl/osx/salprn.cxx
 vcl/osx/salsys.cxx
 vcl/osx/saltimer.cxx
@@ -17958,6 +17957,7 @@ vcl/source/app/dndhelp.cxx
 vcl/source/app/help.cxx
 vcl/source/app/i18nhelp.cxx
 vcl/source/app/idle.cxx
+vcl/source/app/salplug.cxx
 vcl/source/app/salusereventlist.cxx
 vcl/source/app/salvtables.cxx
 vcl/source/app/scheduler.cxx
@@ -18323,7 +18323,6 @@ vcl/unx/generic/gdi/xrender_peer.cxx
 vcl/unx/generic/gdi/xrender_peer.hxx
 vcl/unx/generic/glyphs/freetype_glyphcache.cxx
 vcl/unx/generic/glyphs/glyphcache.cxx
-vcl/unx/generic/plugadapt/salplug.cxx
 vcl/unx/generic/print/bitmap_gfx.cxx
 vcl/unx/generic/print/common_gfx.cxx
 vcl/unx/generic/print/genprnpsp.cxx
@@ -18450,7 +18449,6 @@ vcl/unx/x11/xlimits.cxx
 vcl/win/app/saldata.cxx
 vcl/win/app/salinfo.cxx
 vcl/win/app/salinst.cxx
-vcl/win/app/salplug.cxx
 vcl/win/app/salshl.cxx
 vcl/win/app/saltimer.cxx
 vcl/win/gdi/DWriteTextRenderer.cxx
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index d8fd456b3417..e75ff64b2b34 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -106,6 +106,7 @@ $(eval $(call gb_Library_use_externals,vcl,\
     lcms2 \
     mdds_headers \
 ))
+
 ifeq ($(DISABLE_GUI),)
 $(eval $(call gb_Library_use_externals,vcl,\
      epoxy \
@@ -474,7 +475,7 @@ vcl_headless_freetype_code=\
 
 ifeq ($(USING_X11),TRUE)
 $(eval $(call gb_Library_add_exception_objects,vcl,\
-    vcl/unx/generic/plugadapt/salplug \
+    vcl/source/app/salplug \
     vcl/unx/generic/printer/jobdata \
     vcl/unx/generic/printer/ppdparser \
     vcl/unx/generic/gdi/nativewindowhandleprovider \
@@ -520,8 +521,10 @@ $(eval $(call gb_Library_add_libs,vcl,\
     -lpthread \
 ))
 endif
-else
- $(eval $(call gb_Library_add_exception_objects,vcl,\
+
+else # ! DISABLE_GUI
+
+$(eval $(call gb_Library_add_exception_objects,vcl,\
     vcl/opengl/DeviceInfo \
     vcl/opengl/gdiimpl \
     vcl/opengl/salbmp \
@@ -547,7 +550,8 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
     vcl/opengl/x11/X11DeviceInfo \
 ))
 endif
-endif
+endif # ! DISABLE_GUI
+
 
 ifeq ($(OS),HAIKU)
 $(eval $(call gb_Library_add_exception_objects,vcl,\
@@ -563,7 +567,7 @@ $(eval $(call gb_Library_add_libs,vcl,\
 ))
 
 $(eval $(call gb_Library_add_exception_objects,vcl, \
-    $(if $(or $(ENABLE_QT5),$(ENABLE_KDE5)),vcl/unx/generic/plugadapt/salplug) 
\
+    $(if $(or $(ENABLE_QT5),$(ENABLE_KDE5)),vcl/source/app/salplug) \
 ))
 
 $(eval $(call gb_Library_use_externals,vcl,\
@@ -574,6 +578,7 @@ $(eval $(call gb_Library_use_externals,vcl,\
 ))
 endif
 
+
 ifeq ($(OS),ANDROID)
 $(eval $(call gb_Library_add_libs,vcl,\
     -llog \
@@ -605,7 +610,6 @@ $(eval $(call gb_Library_add_cxxflags,vcl,\
 $(eval $(call gb_Library_add_exception_objects,vcl,\
     vcl/ios/iosinst \
     vcl/ios/dummies \
-    $(vcl_really_generic_code) \
     $(vcl_coretext_code) \
     $(vcl_quartz_code) \
     $(vcl_headless_code) \
@@ -624,7 +628,7 @@ $(eval $(call gb_Library_use_system_darwin_frameworks,vcl,\
 ))
 
 $(eval $(call gb_Library_add_exception_objects,vcl,\
-    vcl/osx/salplug \
+    vcl/source/app/salplug \
 ))
 endif
 
@@ -633,7 +637,7 @@ ifeq ($(OS),WNT)
 $(eval $(call gb_Library_add_exception_objects,vcl,\
     vcl/opengl/win/WinDeviceInfo \
     vcl/opengl/win/blocklist_parser \
-    vcl/win/app/salplug \
+    vcl/source/app/salplug \
 ))
 
 $(eval $(call gb_Library_use_system_win32_libs,vcl,\
diff --git a/vcl/README b/vcl/README
index ae0408b830a2..5a869ef77b9f 100644
--- a/vcl/README
+++ b/vcl/README
@@ -80,7 +80,7 @@ LibreOffice (and OpenOffice).
 == COM threading ==
 
 The way COM is used in LO generally:
-- vcl InitSalData() puts main thread into Single-threaded Apartment (STA)
+- vcl puts main thread into Single-threaded Apartment (STA)
 - oslWorkerWrapperFunction() puts every thread spawned via oslCreateThread()
   into MTA (free-threaded)
 
diff --git a/vcl/android/androidinst.cxx b/vcl/android/androidinst.cxx
index 42830ef66dbf..da3889145bb7 100644
--- a/vcl/android/androidinst.cxx
+++ b/vcl/android/androidinst.cxx
@@ -152,11 +152,6 @@ SalFrame *AndroidSalInstance::CreateFrame( SalFrame* 
pParent, SalFrameStyleFlags
     return new AndroidSalFrame( this, pParent, nStyle );
 }
 
-// All the interesting stuff is slaved from the AndroidSalInstance
-void InitSalData()   {}
-void DeInitSalData() {}
-void InitSalMain()   {}
-
 void SalAbort( const OUString& rErrorText, bool bDumpCore )
 {
     OUString aError( rErrorText );
diff --git a/vcl/headless/headlessinst.cxx b/vcl/headless/headlessinst.cxx
index 8326592c7da0..cd9982e208da 100644
--- a/vcl/headless/headlessinst.cxx
+++ b/vcl/headless/headlessinst.cxx
@@ -51,11 +51,6 @@ public:
     virtual bool ErrorTrapPop( bool ) override { return false; }
 };
 
-// All the interesting stuff is slaved from the AndroidSalInstance
-void InitSalData()   {}
-void DeInitSalData() {}
-void InitSalMain()   {}
-
 void SalAbort( const OUString& rErrorText, bool bDumpCore )
 {
     OUString aError( rErrorText );
diff --git a/vcl/inc/osx/saldata.hxx b/vcl/inc/osx/saldata.hxx
index f813118803d2..483902ff21cf 100644
--- a/vcl/inc/osx/saldata.hxx
+++ b/vcl/inc/osx/saldata.hxx
@@ -57,7 +57,7 @@ class SystemFontList;
 #define INVALID_CURSOR_PTR reinterpret_cast<NSCursor*>(0xdeadbeef)
 
 // Singleton, instantiated from Application::Application() in
-// vcl/source/app/svapp.cxx through InitSalData().
+// vcl/source/app/svapp.cxx.
 
 class SalData
 {
diff --git a/vcl/inc/salinst.hxx b/vcl/inc/salinst.hxx
index 1418ef4ef859..b365fe6545ca 100644
--- a/vcl/inc/salinst.hxx
+++ b/vcl/inc/salinst.hxx
@@ -77,7 +77,7 @@ enum class SalFrameStyleFlags;
 
 typedef struct _cairo_font_options cairo_font_options_t;
 
-class VCL_PLUGIN_PUBLIC SalInstance
+class VCL_DLLPUBLIC SalInstance
 {
 private:
     rtl::Reference< vcl::DisplayConnectionDispatch > m_pEventInst;
@@ -211,11 +211,6 @@ void SalAbort( const OUString& rErrorText, bool bDumpCore 
);
 
 VCL_DLLPUBLIC const OUString& SalGetDesktopEnvironment();
 
-void InitSalData();                         // called from Application-Ctor
-void DeInitSalData();                       // called from Application-Dtor
-
-void InitSalMain();
-
 #endif // INCLUDED_VCL_INC_SALINST_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/win/saldata.hxx b/vcl/inc/win/saldata.hxx
index 8f5a3b87b415..ae43b12af4ab 100644
--- a/vcl/inc/win/saldata.hxx
+++ b/vcl/inc/win/saldata.hxx
@@ -118,7 +118,6 @@ public:
     std::set< HMENU >       mhMenuSet;              // keeps track of menu 
handles created by VCL, used by IsKnownMenuHandle()
     std::map< UINT,sal_uInt16 > maVKMap;      // map some dynamic VK_* entries
 
-    // must be deleted before exit(), so delete it in DeInitSalData()
     std::unique_ptr<TextOutRenderer> m_pD2DWriteTextOutRenderer;
     // tdf#107205 need 2 instances because D2DWrite can't rotate text
     std::unique_ptr<TextOutRenderer> m_pExTextOutRenderer;
diff --git a/vcl/ios/iosinst.cxx b/vcl/ios/iosinst.cxx
index 588fa07f8a2a..cddcdf743840 100644
--- a/vcl/ios/iosinst.cxx
+++ b/vcl/ios/iosinst.cxx
@@ -138,11 +138,6 @@ SalFrame *IosSalInstance::CreateFrame( SalFrame* pParent, 
SalFrameStyleFlags nSt
     return new IosSalFrame( this, pParent, nStyle );
 }
 
-// All the interesting stuff is slaved from the IosSalInstance
-void InitSalData()   {}
-void DeInitSalData() {}
-void InitSalMain()   {}
-
 void SalAbort( const OUString& rErrorText, bool bDumpCore )
 {
     (void) bDumpCore;
diff --git a/vcl/osx/salinst.cxx b/vcl/osx/salinst.cxx
index 8fe681f37853..426aa2972ec6 100644
--- a/vcl/osx/salinst.cxx
+++ b/vcl/osx/salinst.cxx
@@ -192,12 +192,6 @@ void SalAbort( const OUString& rErrorText, bool bDumpCore )
         _exit(1);
 }
 
-const OUString& SalGetDesktopEnvironment()
-{
-    static OUString aDesktopEnvironment( "MacOSX" );
-    return aDesktopEnvironment;
-}
-
 SalYieldMutex::SalYieldMutex()
     : m_aCodeBlock( nullptr )
 {
diff --git a/vcl/osx/salplug.cxx b/vcl/osx/salplug.cxx
deleted file mode 100644
index e4f69a10ee25..000000000000
--- a/vcl/osx/salplug.cxx
+++ /dev/null
@@ -1,167 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <osl/module.hxx>
-#include <osl/process.h>
-
-#include <rtl/bootstrap.hxx>
-#include <rtl/process.h>
-#include <sal/log.hxx>
-
-#include <salinst.hxx>
-#include <saldatabasic.hxx>
-#include <config_vclplug.h>
-#include <desktop/crashreport.hxx>
-
-#include <cstdio>
-
-extern "C" {
-typedef SalInstance*(*salFactoryProc)();
-}
-
-static oslModule pCloseModule = nullptr;
-
-static SalInstance* tryInstance( const OUString& rModuleBase, bool bForce = 
false )
-{
-    SalInstance* pInst = nullptr;
-    OUString aModule(
-#ifdef SAL_DLLPREFIX
-            SAL_DLLPREFIX
-#endif
-            "vclplug_" + rModuleBase + "lo" SAL_DLLEXTENSION );
-
-    osl::Module aMod;
-    if (aMod.loadRelative(reinterpret_cast<oslGenericFunction>(&tryInstance), 
aModule, SAL_LOADMODULE_GLOBAL))
-    {
-        salFactoryProc aProc = 
reinterpret_cast<salFactoryProc>(aMod.getFunctionSymbol("create_SalInstance"));
-        if (aProc)
-        {
-            pInst = aProc();
-            SAL_INFO(
-                "vcl.plugadapt",
-                "sal plugin " << aModule << " produced instance " << pInst);
-            if (pInst)
-            {
-                pCloseModule = static_cast<oslModule>(aMod);
-                aMod.release();
-            }
-        }
-        else
-        {
-            SAL_WARN(
-                "vcl.plugadapt",
-                "could not load symbol create_SalInstance from shared object "
-                    << aModule);
-        }
-    }
-    else if (bForce)
-    {
-        SAL_WARN("vcl.plugadapt", "could not load shared object " << aModule);
-    }
-    else
-    {
-        SAL_INFO("vcl.plugadapt", "could not load shared object " << aModule);
-    }
-
-    // coverity[leaked_storage] - this is on purpose
-    return pInst;
-}
-
-SalInstance *CreateSalInstance()
-{
-    SalInstance *pInst = nullptr;
-
-    OUString aUsePlugin;
-    rtl::Bootstrap::get( "SAL_USE_VCLPLUGIN", aUsePlugin );
-
-    if( !aUsePlugin.isEmpty() )
-        pInst = tryInstance( aUsePlugin, true );
-
-    // fallback, try everything
-    static const char* const pPlugin[] = { "osx" };
-
-    for ( int i = 0; !pInst && i != SAL_N_ELEMENTS(pPlugin); ++i )
-        pInst = tryInstance( OUString::createFromAscii( pPlugin[ i ] ) );
-
-    if( ! pInst )
-    {
-        std::fprintf( stderr, "no suitable windowing system found, exiting.\n" 
);
-        _exit( 1 );
-    }
-
-    // acquire SolarMutex
-    pInst->AcquireYieldMutex();
-
-    return pInst;
-}
-
-void DestroySalInstance( SalInstance *pInst )
-{
-    // release SolarMutex
-    pInst->ReleaseYieldMutexAll();
-
-    delete pInst;
-    if( pCloseModule )
-        osl_unloadModule( pCloseModule );
-}
-
-void InitSalData()
-{
-}
-
-void DeInitSalData()
-{
-}
-
-void InitSalMain()
-{
-}
-
-void SalAbort( const OUString& rErrorText, bool bDumpCore )
-{
-    if( rErrorText.isEmpty() )
-        std::fprintf( stderr, "Application Error\n" );
-    else
-    {
-        CrashReporter::AddKeyValue("AbortMessage", rErrorText);
-        std::fprintf( stderr, "%s\n", OUStringToOString(rErrorText, 
osl_getThreadTextEncoding()).getStr() );
-    }
-    if( bDumpCore )
-        abort();
-    else
-        _exit(1);
-}
-
-const OUString& SalGetDesktopEnvironment()
-{
-    static OUString aDesktopEnvironment( "Windows" );
-    return aDesktopEnvironment;
-}
-
-SalData::SalData() :
-    m_pInstance(nullptr),
-    m_pPIManager(nullptr)
-{
-}
-
-SalData::~SalData() COVERITY_NOEXCEPT_FALSE
-{
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/generic/plugadapt/salplug.cxx b/vcl/source/app/salplug.cxx
similarity index 83%
rename from vcl/unx/generic/plugadapt/salplug.cxx
rename to vcl/source/app/salplug.cxx
index bce722b6ed6c..441964e3a4c3 100644
--- a/vcl/unx/generic/plugadapt/salplug.cxx
+++ b/vcl/source/app/salplug.cxx
@@ -25,16 +25,32 @@
 #include <sal/log.hxx>
 
 #include <salinst.hxx>
-#include <unx/gensys.h>
-#include <unx/gendata.hxx>
-#include <headless/svpinst.hxx>
-#include <unx/desktops.hxx>
-#include <printerinfomanager.hxx>
 #include <config_vclplug.h>
 #include <desktop/crashreport.hxx>
 
-#include <cstdio>
+#ifndef _WIN32
+#include <headless/svpinst.hxx>
+#include <printerinfomanager.hxx>
+#include <unx/desktops.hxx>
+#include <unx/gensys.h>
+#include <unx/gendata.hxx>
+
 #include <unistd.h>
+#else
+#include <saldatabasic.hxx>
+#include <Windows.h>
+#endif
+
+#include <cstdio>
+
+#ifdef ANDROID
+#error "Android has no plugin infrastructure!"
+#endif
+
+#if !(defined _WIN32 || defined MACOSX)
+#define DESKTOPDETECT
+#define HEADLESS_VCLPLUG
+#endif
 
 extern "C" {
 typedef SalInstance*(*salFactoryProc)();
@@ -42,32 +58,14 @@ typedef SalInstance*(*salFactoryProc)();
 
 namespace {
 
-// HACK to obtain Application::IsHeadlessModeEnabled early on, before
-// Application::EnableHeadlessMode has potentially been called:
-bool IsHeadlessModeRequested()
-{
-    if (Application::IsHeadlessModeEnabled()) {
-        return true;
-    }
-    sal_uInt32 n = rtl_getAppCommandArgCount();
-    for (sal_uInt32 i = 0; i < n; ++i) {
-        OUString arg;
-        rtl_getAppCommandArg(i, &arg.pData);
-        if ( arg == "--headless" || arg == "-headless" ) {
-            return true;
-        }
-    }
-    return false;
-}
-
-}
+oslModule pCloseModule = nullptr;
 
-static oslModule pCloseModule = nullptr;
-
-static SalInstance* tryInstance( const OUString& rModuleBase, bool bForce = 
false )
+SalInstance* tryInstance( const OUString& rModuleBase, bool bForce = false )
 {
+#ifdef HEADLESS_VCLPLUG
     if (rModuleBase == "svp")
         return svp_create_SalInstance();
+#endif
 
     SalInstance* pInst = nullptr;
     OUString aModule(
@@ -91,7 +89,6 @@ static SalInstance* tryInstance( const OUString& rModuleBase, 
bool bForce = fals
                 pCloseModule = static_cast<oslModule>(aMod);
                 aMod.release();
 
-#ifndef ANDROID
                 /*
                  * Recent GTK+ versions load their modules with RTLD_LOCAL, so 
we can
                  * not access the 'gnome_accessibility_module_shutdown' 
anymore.
@@ -100,11 +97,10 @@ static SalInstance* tryInstance( const OUString& 
rModuleBase, bool bForce = fals
                  * #i109007# KDE3 seems to have the same problem.
                  * And same applies for KDE4.
                  */
-                if( rModuleBase == "gtk" || rModuleBase == "gtk3" || 
rModuleBase == "kde4" || rModuleBase == "gtk3_kde5")
+                if( rModuleBase == "gtk" || rModuleBase == "gtk3" || 
rModuleBase == "kde4" || rModuleBase == "gtk3_kde5" || rModuleBase == "win" )
                 {
                     pCloseModule = nullptr;
                 }
-#endif
             }
         }
         else
@@ -128,15 +124,10 @@ static SalInstance* tryInstance( const OUString& 
rModuleBase, bool bForce = fals
     return pInst;
 }
 
-#if !defined(ANDROID)
-
-namespace {
-
+#ifdef DESKTOPDETECT
 extern "C" typedef DesktopType Fn_get_desktop_environment();
 
-}
-
-static DesktopType get_desktop_environment()
+DesktopType get_desktop_environment()
 {
     OUString aModule(DESKTOP_DETECTOR_DLL_NAME);
     oslModule aMod = osl_loadModuleRelative(
@@ -155,18 +146,12 @@ static DesktopType get_desktop_environment()
     return ret;
 }
 
-#else
-
-#define get_desktop_environment() DESKTOP_NONE // For now...
-
-#endif
-
-static SalInstance* autodetect_plugin()
+SalInstance* autodetect_plugin()
 {
     static const char* const pKDEFallbackList[] =
     {
 #if ENABLE_KDE5
-       "kde5",
+        "kde5",
 #endif
 #if ENABLE_GTK3_KDE5
         "gtk3_kde5",
@@ -182,19 +167,24 @@ static SalInstance* autodetect_plugin()
         "gtk3", "gtk", "gen", nullptr
     };
 
+#ifdef HEADLESS_VCLPLUG
     static const char* const pHeadlessFallbackList[] =
     {
         "svp", nullptr
     };
+#endif
 
     DesktopType desktop = get_desktop_environment();
     const char * const * pList = pStandardFallbackList;
     int nListEntry = 0;
 
+#ifdef HEADLESS_VCLPLUG
     // no server at all: dummy plugin
     if ( desktop == DESKTOP_NONE )
         pList = pHeadlessFallbackList;
-    else if ( desktop == DESKTOP_GNOME ||
+    else
+#endif
+        if ( desktop == DESKTOP_GNOME ||
               desktop == DESKTOP_UNITY ||
               desktop == DESKTOP_XFCE  ||
               desktop == DESKTOP_MATE )
@@ -215,28 +205,62 @@ static SalInstance* autodetect_plugin()
 
     return pInst;
 }
+#endif // DESKTOPDETECT
+
+#ifdef HEADLESS_VCLPLUG
+// HACK to obtain Application::IsHeadlessModeEnabled early on, before
+// Application::EnableHeadlessMode has potentially been called:
+bool IsHeadlessModeRequested()
+{
+    if (Application::IsHeadlessModeEnabled()) {
+        return true;
+    }
+    sal_uInt32 n = rtl_getAppCommandArgCount();
+    for (sal_uInt32 i = 0; i < n; ++i) {
+        OUString arg;
+        rtl_getAppCommandArg(i, &arg.pData);
+        if ( arg == "--headless" || arg == "-headless" ) {
+            return true;
+        }
+    }
+    return false;
+}
+#endif
+
+} // anonymous namespace
 
 SalInstance *CreateSalInstance()
 {
     SalInstance *pInst = nullptr;
 
     OUString aUsePlugin;
+#ifdef HEADLESS_VCLPLUG
     if( IsHeadlessModeRequested() )
         aUsePlugin = "svp";
     else
-    {
+#endif
         rtl::Bootstrap::get( "SAL_USE_VCLPLUGIN", aUsePlugin );
-    }
 
     if( !aUsePlugin.isEmpty() )
         pInst = tryInstance( aUsePlugin, true );
 
+#ifdef DESKTOPDETECT
     if( ! pInst )
         pInst = autodetect_plugin();
+#endif
 
     // fallback, try everything
     static const char* const pPlugin[] = {
-        "gtk3", "gtk", "kde5", "kde4", "gen" };
+#ifdef _WIN32
+        "win"
+#else
+#ifdef MACOSX
+        "osx"
+#else
+        "gtk3", "gtk", "kde5", "kde4", "gen"
+#endif
+#endif
+     };
 
     for ( int i = 0; !pInst && i != SAL_N_ELEMENTS(pPlugin); ++i )
         pInst = tryInstance( OUString::createFromAscii( pPlugin[ i ] ) );
@@ -263,18 +287,6 @@ void DestroySalInstance( SalInstance *pInst )
         osl_unloadModule( pCloseModule );
 }
 
-void InitSalData()
-{
-}
-
-void DeInitSalData()
-{
-}
-
-void InitSalMain()
-{
-}
-
 void SalAbort( const OUString& rErrorText, bool bDumpCore )
 {
     if( rErrorText.isEmpty() )
@@ -292,17 +304,26 @@ void SalAbort( const OUString& rErrorText, bool bDumpCore 
)
 
 const OUString& SalGetDesktopEnvironment()
 {
+#ifdef _WIN32
+    static OUString aDesktopEnvironment( "Windows" );
+
+#else
+#ifdef MACOSX
+    static OUString aDesktopEnvironment( "MacOSX" );
+#else
     // Order to match desktops.hxx' DesktopType
     static const char * const desktop_strings[] = {
         "none", "unknown", "GNOME", "UNITY",
         "XFCE", "MATE", "KDE4", "KDE5" };
-    static OUString aRet;
-    if( aRet.isEmpty())
+    static OUString aDesktopEnvironment;
+    if( aDesktopEnvironment.isEmpty())
     {
-        aRet = OUString::createFromAscii(
+        aDesktopEnvironment = OUString::createFromAscii(
             desktop_strings[get_desktop_environment()]);
     }
-    return aRet;
+#endif
+#endif
+    return aDesktopEnvironment;
 }
 
 SalData::SalData() :
@@ -313,7 +334,19 @@ SalData::SalData() :
 
 SalData::~SalData() COVERITY_NOEXCEPT_FALSE
 {
+#if (defined UNX && !defined MACOSX)
     psp::PrinterInfoManager::release();
+#endif
+}
+
+#ifdef _WIN32
+bool HasAtHook()
+{
+    BOOL bIsRunning = FALSE;
+    // pvParam must be BOOL
+    return SystemParametersInfoW(SPI_GETSCREENREADER, 0, &bIsRunning, 0)
+        && bIsRunning;
 }
+#endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index c1aeac0639c0..09f80fbd0af7 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -182,13 +182,11 @@ Application::Application()
     osl_setEnvironment(aVar.pData, aValue.pData);
 
     ImplGetSVData()->mpApp = this;
-    InitSalData();
 }
 
 Application::~Application()
 {
     ImplDeInitSVData();
-    DeInitSalData();
     ImplGetSVData()->mpApp = nullptr;
 }
 
diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index 0b49311a2051..4f660133ebf6 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -299,7 +299,6 @@ bool InitVCL()
     {
         pOwnSvApp = new Application();
     }
-    InitSalMain();
 
     ImplSVData* pSVData = ImplGetSVData();
 
diff --git a/vcl/win/app/salplug.cxx b/vcl/win/app/salplug.cxx
deleted file mode 100644
index 1ef61976a23d..000000000000
--- a/vcl/win/app/salplug.cxx
+++ /dev/null
@@ -1,199 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <osl/module.hxx>
-#include <osl/process.h>
-
-#include <rtl/bootstrap.hxx>
-#include <rtl/process.h>
-#include <sal/log.hxx>
-
-#include <salinst.hxx>
-#include <saldatabasic.hxx>
-#include <config_vclplug.h>
-#include <desktop/crashreport.hxx>
-
-#include <cstdio>
-#include <Windows.h>
-
-extern "C" {
-typedef SalInstance*(*salFactoryProc)();
-}
-
-namespace {
-
-// HACK to obtain Application::IsHeadlessModeEnabled early on, before
-// Application::EnableHeadlessMode has potentially been called:
-bool IsHeadlessModeRequested()
-{
-    if (Application::IsHeadlessModeEnabled()) {
-        return true;
-    }
-    sal_uInt32 n = rtl_getAppCommandArgCount();
-    for (sal_uInt32 i = 0; i < n; ++i) {
-        OUString arg;
-        rtl_getAppCommandArg(i, &arg.pData);
-        if ( arg == "--headless" || arg == "-headless" ) {
-            return true;
-        }
-    }
-    return false;
-}
-
-}
-
-static oslModule pCloseModule = nullptr;
-
-static SalInstance* tryInstance( const OUString& rModuleBase, bool bForce = 
false )
-{
-    SalInstance* pInst = nullptr;
-    OUString aModule(
-#ifdef SAL_DLLPREFIX
-            SAL_DLLPREFIX
-#endif
-            "vclplug_" + rModuleBase + "lo" SAL_DLLEXTENSION );
-
-    osl::Module aMod;
-    if (aMod.loadRelative(reinterpret_cast<oslGenericFunction>(&tryInstance), 
aModule, SAL_LOADMODULE_GLOBAL))
-    {
-        salFactoryProc aProc = 
reinterpret_cast<salFactoryProc>(aMod.getFunctionSymbol("create_SalInstance"));
-        if (aProc)
-        {
-            pInst = aProc();
-            SAL_INFO(
-                "vcl.plugadapt",
-                "sal plugin " << aModule << " produced instance " << pInst);
-            if (pInst)
-            {
-                pCloseModule = static_cast<oslModule>(aMod);
-                aMod.release();
-                pCloseModule = nullptr;
-            }
-        }
-        else
-        {
-            SAL_WARN(
-                "vcl.plugadapt",
-                "could not load symbol create_SalInstance from shared object "
-                    << aModule);
-        }
-    }
-    else if (bForce)
-    {
-        SAL_WARN("vcl.plugadapt", "could not load shared object " << aModule);
-    }
-    else
-    {
-        SAL_INFO("vcl.plugadapt", "could not load shared object " << aModule);
-    }
-
-    // coverity[leaked_storage] - this is on purpose
-    return pInst;
-}
-
-SalInstance *CreateSalInstance()
-{
-    SalInstance *pInst = nullptr;
-
-    OUString aUsePlugin;
-    rtl::Bootstrap::get( "SAL_USE_VCLPLUGIN", aUsePlugin );
-
-    if( !aUsePlugin.isEmpty() )
-        pInst = tryInstance( aUsePlugin, true );
-
-    // fallback, try everything
-    static const char* const pPlugin[] = { "win" };
-
-    for ( int i = 0; !pInst && i != SAL_N_ELEMENTS(pPlugin); ++i )
-        pInst = tryInstance( OUString::createFromAscii( pPlugin[ i ] ) );
-
-    if( ! pInst )
-    {
-        std::fprintf( stderr, "no suitable windowing system found, exiting.\n" 
);
-        _exit( 1 );
-    }
-
-    // acquire SolarMutex
-    pInst->AcquireYieldMutex();
-
-    return pInst;
-}
-
-void DestroySalInstance( SalInstance *pInst )
-{
-    // release SolarMutex
-    pInst->ReleaseYieldMutexAll();
-
-    delete pInst;
-    if( pCloseModule )
-        osl_unloadModule( pCloseModule );
-}
-
-void InitSalData()
-{
-}
-
-void DeInitSalData()
-{
-}
-
-void InitSalMain()
-{
-}
-
-void SalAbort( const OUString& rErrorText, bool bDumpCore )
-{
-    if( rErrorText.isEmpty() )
-        std::fprintf( stderr, "Application Error\n" );
-    else
-    {
-        CrashReporter::AddKeyValue("AbortMessage", rErrorText);
-        std::fprintf( stderr, "%s\n", OUStringToOString(rErrorText, 
osl_getThreadTextEncoding()).getStr() );
-    }
-    if( bDumpCore )
-        abort();
-    else
-        _exit(1);
-}
-
-const OUString& SalGetDesktopEnvironment()
-{
-    static OUString aDesktopEnvironment( "Windows" );
-    return aDesktopEnvironment;
-}
-
-SalData::SalData() :
-    m_pInstance(nullptr),
-    m_pPIManager(nullptr)
-{
-}
-
-SalData::~SalData() COVERITY_NOEXCEPT_FALSE
-{
-}
-
-bool HasAtHook()
-{
-    BOOL bIsRunning = FALSE;
-    // pvParam must be BOOL
-    return SystemParametersInfoW(SPI_GETSCREENREADER, 0, &bIsRunning, 0)
-        && bIsRunning;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to