[Libreoffice-commits] core.git: Branch 'feature/qt5-win+mac' - 219 commits - basctl/source basctl/uiconfig chart2/source chart2/uiconfig comphelper/source compilerplugins/clang config_host/config_vclplug.h.in configure.ac connectivity/source cui/source cui/uiconfig desktop/test download.lst drawinglayer/source editeng/source external/liborcus external/pdfium external/xmlsec extras/source filter/source forms/source framework/dtd helpcontent2 i18npool/source include/comphelper include/editeng include/o3tl include/sal include/sfx2 include/svl include/svtools include/svx include/unotools include/vbahelper include/vcl include/xmloff instsetoo_native/inc_openoffice o3tl/qa readlicense_oo/license Repository.mk sc/inc scp2/source sc/qa sc/source sc/uiconfig sd/inc sd/qa sd/source sd/uiconfig setup_native/Library_inst_msu_msi.mk setup_native/Library_instooofiltmsi.mk setup_native/Library_qslnkmsi.mk setup_native/Library_reg4allmsdoc.mk setup_native/Library_regactivex.mk setup_native/Library_sdqsmsi.mk set up_native/Library_sellangmsi.mk setup_native/Library_shlxtmsi.mk setup_native/Library_sn_tools.mk setup_native/source sfx2/source sfx2/uiconfig shell/Library_desktopbe.mk shell/source solenv/clang-format solenv/sanitizers starmath/inc starmath/qa starmath/source starmath/uiconfig svl/source svtools/source svx/source svx/uiconfig sw/inc sw/PythonTest_sw_python.mk sw/qa sw/source sw/uiconfig ucb/source UnoControls/inc UnoControls/source unotools/source unoxml/source uui/source vcl/android vcl/CustomTarget_qt5_moc.mk vcl/headless vcl/inc vcl/ios vcl/Library_vcl.mk vcl/Library_vclplug_osx.mk vcl/Library_vclplug_qt5.mk vcl/Library_vclplug_win.mk vcl/Module_vcl.mk vcl/osx vcl/qa vcl/qt5 vcl/quartz vcl/README vcl/source vcl/unx vcl/win writerfilter/source xmloff/inc xmloff/source xmlsecurity/inc xmlsecurity/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Sep 20 17:11:42 UTC 2018


Rebased ref, commits from common ancestor:
commit d355fabee1d34a2d7a64c051dd37443c8a7eef79
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Mon Sep 17 11:01:59 2018 +0200
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Thu Sep 20 19:09:54 2018 +0200

    Qt5 use LO provided native file pickers
    
    This uses the native file pickers on Windows and MacOSX.
    
    Change-Id: Ic836d3ed8de0760c6c94c68d61f6eaa96f773000

diff --git a/vcl/Library_vclplug_qt5.mk b/vcl/Library_vclplug_qt5.mk
index ae29d4054bd9..ec30f06b7a9f 100644
--- a/vcl/Library_vclplug_qt5.mk
+++ b/vcl/Library_vclplug_qt5.mk
@@ -85,7 +85,7 @@ endif
 $(eval $(call gb_Library_add_exception_objects,vclplug_qt5,\
     vcl/qt5/Qt5Bitmap \
     vcl/qt5/Qt5Data \
-    vcl/qt5/Qt5FilePicker \
+    $(if $(USING_X11),vcl/qt5/Qt5FilePicker) \
     vcl/qt5/Qt5Font \
     vcl/qt5/Qt5FontFace \
     vcl/qt5/Qt5Frame \
diff --git a/vcl/qt5/Qt5Instance.cxx b/vcl/qt5/Qt5Instance.cxx
index 8557834064d8..334aba4fbdea 100644
--- a/vcl/qt5/Qt5Instance.cxx
+++ b/vcl/qt5/Qt5Instance.cxx
@@ -211,17 +211,27 @@ void Qt5Instance::ProcessEvent(SalUserEvent aEvent)
 }
 
 css::uno::Reference<css::ui::dialogs::XFilePicker2>
-Qt5Instance::createFilePicker(const css::uno::Reference<css::uno::XComponentContext>&)
+Qt5Instance::createFilePicker(const css::uno::Reference<css::uno::XComponentContext>& cntxt)
 {
+#if (defined _WIN32 || defined MACOSX)
+    return SalInstance::createFilePicker(cntxt);
+#else
+    (void)cntxt;
     return css::uno::Reference<css::ui::dialogs::XFilePicker2>(
         new Qt5FilePicker(QFileDialog::ExistingFile));
+#endif
 }
 
 css::uno::Reference<css::ui::dialogs::XFolderPicker2>
-Qt5Instance::createFolderPicker(const css::uno::Reference<css::uno::XComponentContext>&)
+Qt5Instance::createFolderPicker(const css::uno::Reference<css::uno::XComponentContext>& cntxt)
 {
+#if (defined _WIN32 || defined MACOSX)
+    return SalInstance::createFolderPicker(cntxt);
+#else
+    (void)cntxt;
     return css::uno::Reference<css::ui::dialogs::XFolderPicker2>(
         new Qt5FilePicker(QFileDialog::Directory));
+#endif
 }
 
 extern "C" {
commit a793bb8bd1405a0042592d81b7d12d9ff3d11007
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Thu Sep 13 12:23:36 2018 +0200
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Thu Sep 20 19:09:51 2018 +0200

    Unify sal plugin loaders
    
    Change-Id: Ic099761eaff80349e985ccf62e3f4aa6b2e98022

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 bcb5733ee12a..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
@@ -18447,7 +18446,6 @@ vcl/unx/kde4/tst_exclude_posted_events.hxx
 vcl/unx/kde4/tst_exclude_socket_notifiers.hxx
 vcl/unx/x11/x11sys.cxx
 vcl/unx/x11/xlimits.cxx
-vcl/win/salplug.cxx
 vcl/win/app/saldata.cxx
 vcl/win/app/salinfo.cxx
 vcl/win/app/salinst.cxx
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 184c84248eb0..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/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 472cf514f497..fdf6a04e075b 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..dd37c199fcba 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", "qt5"
+#else
+#ifdef MACOSX
+        "osx", "qt5"
+#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 c6d935327a5b..227c0d86287e 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 c9f3f056f7e9..1e0a36ce52a4 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -382,7 +382,6 @@ bool InitVCL()
     {
         pOwnSvApp = new Application();
     }
-    InitSalMain();
 
     ImplSVData* pSVData = ImplGetSVData();
 
diff --git a/vcl/win/salplug.cxx b/vcl/win/salplug.cxx
deleted file mode 100644
index 65b8f64e8810..000000000000
--- a/vcl/win/salplug.cxx
+++ /dev/null
@@ -1,198 +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();
-            }
-        }
-        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: */
commit 9ebe4777b125181ed25d3f10d96abb3264216019
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Thu Sep 13 11:32:12 2018 +0200
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Thu Sep 20 19:08:45 2018 +0200

    Qt5 build VCL plugin on MacOSX
    
    Change-Id: I6ddec483703c95faf69b7b146363376765d5d6f8

diff --git a/Repository.mk b/Repository.mk
index b2c806307083..d1aa2540d266 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -482,6 +482,7 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,ooo, \
 			AppleRemote \
 		) \
 		fps_aqua \
+		$(if $(ENABLE_QT5),vclplug_qt5) \
 		vclplug_osx \
 		MacOSXSpell \
 	) \
diff --git a/configure.ac b/configure.ac
index 587b6c3f479b..e721546db01e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -672,6 +672,7 @@ darwin*) # Mac OS X or iOS
             host=x86_64-apple-darwin
         fi
     else
+        test_qt5=yes
         _os=Darwin
         INSTROOTBASESUFFIX=/$PRODUCTNAME_WITHOUT_SPACES.app
         INSTROOTCONTENTSUFFIX=/Contents
@@ -11163,13 +11164,7 @@ if test \( "$test_kde5" = "yes" -a "$ENABLE_KDE5" = "TRUE" \) -o \
         \( "$test_qt5" = "yes" -a "$ENABLE_QT5" = "TRUE" \) -o \
         \( "$test_gtk3_kde5" = "yes" -a "$ENABLE_GTK3_KDE5" = "TRUE" \)
 then
-    qt5_incdirs="$QT5INC /usr/include/qt5 /usr/include $x_includes"
-    qt5_libdirs="$QT5LIB /usr/lib/qt5 /usr/lib $x_libraries"
-
-    if test -n "$supports_multilib"; then
-        qt5_libdirs="$qt5_libdirs /usr/lib64/qt5 /usr/lib64/qt /usr/lib64"
-    fi
-
+    qt5_fwk_search="QtCore QtGui QtWidgets QtNetwork"
     qt5_test_include="QtWidgets/qapplication.h"
     if test $_os == "WINNT"; then
         qt5_test_library="Qt5Widgets.lib"
@@ -11177,12 +11172,25 @@ then
         qt5_test_library="libQt5Widgets.so"
     fi
 
+    qt5_incdirs=""
+    qt5_libdirs=""
+    if test "$USING_X11" = TRUE; then
+        qt5_incdirs="$QT5INC /usr/include/qt5 /usr/include $x_includes"
+        qt5_libdirs="$QT5LIB /usr/lib/qt5 /usr/lib $x_libraries"
+        if test -n "$supports_multilib"; then
+            qt5_libdirs="$qt5_libdirs /usr/lib64/qt5 /usr/lib64/qt /usr/lib64"
+        fi
+    fi
+
     dnl Check for qmake5
     AC_PATH_PROGS( QMAKE5, [qmake-qt5 qmake], no, [$QT5DIR/bin:$PATH] )
     if test "$QMAKE5" = "no"; then
         AC_MSG_ERROR([Qmake not found.  Please specify the root of your Qt5 installation by exporting QT5DIR before running "configure".])
     else
-        qmake5_test_ver="`$QMAKE5 -v 2>&1 | $SED -n -e 's/^Using Qt version \(5\.[[0-9.]]\+\).*$/\1/p'`"
+        case "$host_os" in
+        darwin*) qmake5_test_ver="`$QMAKE5 -v 2>&1 | $SED -n -e 's/^Using Qt version \(5\.[[0-9.]]\{0,\}\).*$/\1/p'`" ;;
+        *) qmake5_test_ver="`$QMAKE5 -v 2>&1 | $SED -n -e 's/^Using Qt version \(5\.[[0-9.]]\+\).*$/\1/p'`" ;;
+        esac
         if test -z "$qmake5_test_ver"; then
             AC_MSG_ERROR([Wrong qmake for Qt5 found. Please specify the root of your Qt5 installation by exporting QT5DIR before running "configure".])
         fi
@@ -11195,49 +11203,86 @@ then
         fi
     fi
 
-    qt5_incdirs="`$QMAKE5 -query QT_INSTALL_HEADERS` $qt5_incdirs"
-    qt5_libdirs="`$QMAKE5 -query QT_INSTALL_LIBS` $qt5_libdirs"
-    if test $_os == "WINNT"; then
-        qt5_incdirs="`cygpath -m $qt5_incdirs`"
-        qt5_libdirs="`cygpath -m $qt5_libdirs`"
-    fi
+    qt5_cmake_incdir="`$QMAKE5 -query QT_INSTALL_HEADERS`"
+    qt5_cmake_libdir="`$QMAKE5 -query QT_INSTALL_LIBS`"
+    case "$_os" in
+    WINNT)
+        qt5_incdirs="`cygpath -m $qt5_cmake_incdir`"
+        qt5_libdirs="`cygpath -m $qt5_cmake_libdir`"
+        ;;
+    Darwin)
+        qt5_incdirs="$qt5_cmake_incdir"
+        qt5_libdirs="$qt5_cmake_libdir"
+        ;;
+    *)
+        qt5_incdirs="$qt5_cmake_incdir $qt5_incdirs"
+        qt5_libdirs="$qt5_cmake_libdir $qt5_libdirs"
+        ;;
+    esac
+    AC_MSG_NOTICE([Qt5 headers: ${qt5_cmake_incdir}])
+    AC_MSG_NOTICE([Qt5 libraries: ${qt5_cmake_libdir}])
 
-    AC_MSG_CHECKING([for Qt5 headers])
-    qt5_incdir="no"
-    for inc_dir in $qt5_incdirs; do
-        if test -r "$inc_dir/$qt5_test_include"; then
-            qt5_incdir="$inc_dir"
-            break
+    case "$_os" in
+    Darwin)
+        QT5_LIBS="-F ${qt5_libdirs}"
+        AC_MSG_CHECKING([for used Qt5 frameworks])
+        qt5_fwk_missing=""
+        for fwk in ${qt5_fwk_search}; do
+            if test ! -d "${qt5_libdirs}/${fwk}.framework"; then
+                qt5_fwk_missing="${qt5_fwk_missing} $fwk";
+            fi
+            QT5_LIBS="${QT5_LIBS} -framework $fwk"
+        done
+        if test -n "$qt5_fwk_missing"; then
+            AC_MSG_ERROR([Missing Qt5 frameworks in ${qt5_libdirs}:${qt5_fwk_missing}])
+        else
+            AC_MSG_RESULT([${qt5_fwk_search}])
         fi
-    done
-    AC_MSG_RESULT([$qt5_incdir])
-    if test "x$qt5_incdir" = "xno"; then
-        AC_MSG_ERROR([Qt5 headers not found.  Please specify the root of your Qt5 installation by exporting QT5DIR before running "configure".])
-    fi
+        ;;
+    *)
+        AC_MSG_CHECKING([for Qt5 headers])
+        qt5_incdir="no"
+        for inc_dir in $qt5_incdirs; do
+            if test -r "$inc_dir/$qt5_test_include"; then
+                qt5_incdir="$inc_dir"
+                break
+            fi
+        done
 
-    AC_MSG_CHECKING([for Qt5 libraries])
-    qt5_libdir="no"
-    for lib_dir in $qt5_libdirs; do
-        if test -r "$lib_dir/$qt5_test_library"; then
-            qt5_libdir="$lib_dir"
-            break
+        AC_MSG_RESULT([$qt5_incdir])
+        if test "x$qt5_incdir" = "xno"; then
+            AC_MSG_ERROR([Qt5 headers not found.  Please specify the root of your Qt5 installation by exporting QT5DIR before running "configure".])
+        fi
+
+        AC_MSG_CHECKING([for Qt5 libraries])
+        qt5_libdir="no"
+        for lib_dir in $qt5_libdirs; do
+            if test -r "$lib_dir/$qt5_test_library"; then
+                qt5_libdir="$lib_dir"
+                break
+            fi
+        done
+        AC_MSG_RESULT([$qt5_libdir])
+        if test "x$qt5_libdir" = "xno"; then
+            AC_MSG_ERROR([Qt5 libraries not found.  Please specify the root of your Qt5 installation by exporting QT5DIR before running "configure".])
         fi
-    done
-    AC_MSG_RESULT([$qt5_libdir])
-    if test "x$qt5_libdir" = "xno"; then
-        AC_MSG_ERROR([Qt5 libraries not found.  Please specify the root of your Qt5 installation by exporting QT5DIR before running "configure".])
-    fi
+
+        if test $_os == "WINNT"; then
+            QT5_LIBS="-LIBPATH:$qt5_libdir Qt5Core.lib Qt5Gui.lib Qt5Widgets.lib Qt5Network.lib"
+        else
+            QT5_LIBS="-L$qt5_libdir -lQt5Core -lQt5Gui -lQt5Widgets -lQt5Network"
+        fi
+
+        ;;
+    esac
 
     QT5_CFLAGS="-I$qt5_incdir -DQT_CLEAN_NAMESPACE -DQT_THREAD_SUPPORT"
-    QT5_CFLAGS=$(printf '%s' "$QT5_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
-    if test $_os == "WINNT"; then
-        QT5_LIBS="-LIBPATH:$qt5_libdir Qt5Core.lib Qt5Gui.lib Qt5Widgets.lib Qt5Network.lib"
-    else
-        QT5_LIBS="-L$qt5_libdir -lQt5Core -lQt5Gui -lQt5Widgets -lQt5Network"
+    if test "$_os" = "Darwin"; then
+        QT5_CFLAGS="$QT5_CFLAGS -F $qt5_cmake_libdir"
     fi
+    QT5_CFLAGS=$(printf '%s' "$QT5_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
 
     dnl Check for Meta Object Compiler
-
     AC_PATH_PROGS( MOC5, [moc-qt5 moc], no, [`dirname $qt5_libdir`/bin:$QT5DIR/bin:$PATH] )
     if test "$MOC5" = "no"; then
         AC_MSG_ERROR([Qt Meta Object Compiler not found.  Please specify
diff --git a/include/vcl/dllapi.h b/include/vcl/dllapi.h
index 805d1cb00908..668cbeb174c6 100644
--- a/include/vcl/dllapi.h
+++ b/include/vcl/dllapi.h
@@ -36,7 +36,7 @@
 #define UITEST_DLLPUBLIC SAL_DLLPUBLIC_IMPORT
 #endif
 
-#if (defined UNX  && ! defined MACOS) || defined _WIN32
+#if defined UNX || defined MACOS || defined _WIN32
 #define VCL_PLUGIN_PUBLIC VCL_DLLPUBLIC
 #else
 #define VCL_PLUGIN_PUBLIC SAL_DLLPRIVATE
diff --git a/vcl/Library_vclplug_osx.mk b/vcl/Library_vclplug_osx.mk
index 968d34b9b99b..071161c80649 100644
--- a/vcl/Library_vclplug_osx.mk
+++ b/vcl/Library_vclplug_osx.mk
@@ -26,12 +26,9 @@ $(eval $(call gb_Library_set_include,vclplug_osx,\
     -I$(SRCDIR)/vcl/inc \
 ))
 
-
-ifeq ($(SYSTEM_GLM),TRUE)
 $(eval $(call gb_Library_add_defs,vclplug_osx,\
-    -DGLM_ENABLE_EXPERIMENTAL \
+    -DVCLPLUG_OSX_IMPLEMENTATION \
 ))
-endif
 
 $(eval $(call gb_Library_use_sdk_api,vclplug_osx))
 
@@ -76,15 +73,10 @@ $(eval $(call gb_Library_use_libraries,vclplug_osx,\
 
 $(eval $(call gb_Library_use_externals,vclplug_osx,\
     boost_headers \
-    gio \
-    glm_headers \
     graphite \
     harfbuzz \
-    icu_headers \
-    icuuc \
-    lcms2 \
-    mdds_headers \
 ))
+
 ifeq ($(DISABLE_GUI),)
 $(eval $(call gb_Library_use_externals,vclplug_osx,\
      epoxy \
diff --git a/vcl/Library_vclplug_qt5.mk b/vcl/Library_vclplug_qt5.mk
index 782bea8707a9..ae29d4054bd9 100644
--- a/vcl/Library_vclplug_qt5.mk
+++ b/vcl/Library_vclplug_qt5.mk
@@ -26,6 +26,7 @@ $(eval $(call gb_Library_set_include,vclplug_qt5,\
     -I$(SRCDIR)/vcl/inc \
     -I$(SRCDIR)/vcl/inc/qt5 \
 ))
+#	$(if $(filter MACOS,$(OS)), -F $(QT5_LIBS)) \
 
 $(eval $(call gb_Library_add_defs,vclplug_qt5,\
     -DVCLPLUG_QT5_IMPLEMENTATION \
@@ -67,6 +68,7 @@ $(eval $(call gb_Library_use_externals,vclplug_qt5,\
 $(eval $(call gb_Library_add_defs,vclplug_qt5,\
     $(QT5_CFLAGS) \
 ))
+
 $(eval $(call gb_Library_add_libs,vclplug_qt5,\
     $(QT5_LIBS) \
 ))
@@ -92,12 +94,10 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_qt5,\
     vcl/qt5/Qt5Graphics_GDI \
     vcl/qt5/Qt5Graphics_Text \
     vcl/qt5/Qt5Instance \
-    vcl/qt5/Qt5Instance_Print \
     vcl/qt5/Qt5MainWindow \
     vcl/qt5/Qt5Menu \
     vcl/qt5/Qt5Object \
     vcl/qt5/Qt5Painter \
-    vcl/qt5/Qt5Printer \
     $(if $(USING_X11),vcl/qt5/Qt5System) \
     vcl/qt5/Qt5Timer \
     vcl/qt5/Qt5Tools \
@@ -105,6 +105,34 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_qt5,\
     vcl/qt5/Qt5Widget \
 ))
 
+ifeq ($(OS),MACOSX)
+$(eval $(call gb_Library_use_system_darwin_frameworks,vclplug_qt5,\
+    ApplicationServices \
+    Cocoa \
+    Carbon \
+    CoreFoundation \
+    $(if $(filter X86_64,$(CPUNAME)),,QuickTime) \
+))
+
+$(eval $(call gb_Library_add_cxxflags,vclplug_qt5,\
+    $(gb_OBJCXXFLAGS) \
+))
+
+$(eval $(call gb_Library_use_libraries,vclplug_qt5,\
+    vclplug_osx \
+))
+
+$(eval $(call gb_Library_add_objcxxobjects,vclplug_qt5,\
+    vcl/qt5/Qt5Instance_Print \
+    vcl/qt5/Qt5Printer \
+))
+else
+$(eval $(call gb_Library_add_exception_objects,vclplug_qt5,\
+    vcl/qt5/Qt5Instance_Print \
+    vcl/qt5/Qt5Printer \
+))
+endif
+
 ifeq ($(OS),LINUX)
 $(eval $(call gb_Library_add_libs,vclplug_qt5,\
     -lm \
diff --git a/vcl/Module_vcl.mk b/vcl/Module_vcl.mk
index 8fbe1fdca943..c8520fbd4c6c 100644
--- a/vcl/Module_vcl.mk
+++ b/vcl/Module_vcl.mk
@@ -108,6 +108,12 @@ $(eval $(call gb_Module_add_targets,vcl,\
     Package_osxres \
     Library_vclplug_osx \
 ))
+ifneq ($(ENABLE_QT5),)
+$(eval $(call gb_Module_add_targets,vcl,\
+    CustomTarget_qt5_moc \
+    Library_vclplug_qt5 \
+))
+endif
 endif
 
 ifeq ($(OS),WNT)
diff --git a/vcl/inc/osx/salprn.h b/vcl/inc/osx/salprn.h
index 0c7ec1e9edfd..8fd210654eac 100644
--- a/vcl/inc/osx/salprn.h
+++ b/vcl/inc/osx/salprn.h
@@ -22,13 +22,14 @@
 
 #include <osx/osxvcltypes.h>
 
+#include <vclpluginapi.h>
 #include <salprn.hxx>
 
 #include <memory>
 
 class AquaSalGraphics;
 
-class AquaSalInfoPrinter : public SalInfoPrinter
+class VCLPLUG_OSX_PUBLIC AquaSalInfoPrinter : public SalInfoPrinter
 {
     /// Printer graphics
     AquaSalGraphics*        mpGraphics;
@@ -111,7 +112,7 @@ class AquaSalInfoPrinter : public SalInfoPrinter
 };
 
 
-class AquaSalPrinter : public SalPrinter
+class VCLPLUG_OSX_PUBLIC AquaSalPrinter : public SalPrinter
 {
     AquaSalInfoPrinter*         mpInfoPrinter;          // pointer to the compatible InfoPrinter
     public:
diff --git a/vcl/inc/qt5/Qt5Data.hxx b/vcl/inc/qt5/Qt5Data.hxx
index c5a59432cb49..15460014f9ab 100644
--- a/vcl/inc/qt5/Qt5Data.hxx
+++ b/vcl/inc/qt5/Qt5Data.hxx
@@ -30,21 +30,21 @@ class GlyphCache;
 class QCursor;
 
 class VCLPLUG_QT5_PUBLIC Qt5Data
-#ifndef _WIN32
-    : public GenericUnixSalData
-#else
+#if (defined MACOSX || defined _WIN32)
     : public SalData
+#else
+    : public GenericUnixSalData
 #endif
 {
     o3tl::enumarray<PointerStyle, std::unique_ptr<QCursor>> m_aCursors;
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
     std::unique_ptr<GlyphCache> m_pGlyphCache;
 #endif
 
 public:
     explicit Qt5Data(SalInstance* pInstance);
     virtual ~Qt5Data() override;
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
     virtual void ErrorTrapPush() override;
     virtual bool ErrorTrapPop(bool bIgnoreError = true) override;
 #endif
diff --git a/vcl/inc/qt5/Qt5Frame.hxx b/vcl/inc/qt5/Qt5Frame.hxx
index d7b793827667..a3d2240a8a02 100644
--- a/vcl/inc/qt5/Qt5Frame.hxx
+++ b/vcl/inc/qt5/Qt5Frame.hxx
@@ -24,7 +24,7 @@
 
 #include "Qt5Tools.hxx"
 
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
 #include <headless/svpgdi.hxx>
 #endif
 #include <vcl/svapp.hxx>
@@ -41,7 +41,7 @@ class QScreen;
 class QImage;
 class SvpSalGraphics;
 
-#ifdef _WIN32
+#if (defined MACOSX || defined _WIN32)
 typedef void (*damageHandler)(void* handle,
                               sal_Int32 nExtentsX, sal_Int32 nExtentsY,
                               sal_Int32 nExtentsWidth, sal_Int32 nExtentsHeight);
@@ -65,7 +65,7 @@ class VCLPLUG_QT5_PUBLIC Qt5Frame : public QObject, public SalFrame
     const bool m_bUseCairo;
     std::unique_ptr<QImage> m_pQImage;
     std::unique_ptr<Qt5Graphics> m_pQt5Graphics;
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
     UniqueCairoSurface m_pSurface;
     std::unique_ptr<SvpSalGraphics> m_pOurSvpGraphics;
     // in base class, this ptr is the same as m_pOurSvpGraphic
@@ -126,7 +126,7 @@ public:
     void Damage(sal_Int32 nExtentsX, sal_Int32 nExtentsY, sal_Int32 nExtentsWidth,
                 sal_Int32 nExtentsHeight) const;
 
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
     virtual void InitSvpSalGraphics(SvpSalGraphics* pSvpSalGraphics);
 #endif
     virtual SalGraphics* AcquireGraphics() override;
diff --git a/vcl/inc/qt5/Qt5Instance.hxx b/vcl/inc/qt5/Qt5Instance.hxx
index da772569d29c..97947db1f991 100644
--- a/vcl/inc/qt5/Qt5Instance.hxx
+++ b/vcl/inc/qt5/Qt5Instance.hxx
@@ -31,7 +31,7 @@ class QApplication;
 class SalYieldMutex;
 class SalFrame;
 
-#ifdef _WIN32
+#if (defined MACOSX || defined _WIN32)
 #include <salinst.hxx>
 #include <comphelper/solarmutex.hxx>
 #else
@@ -41,7 +41,7 @@ class SalFrame;
 // Qts moc doesn't like macros, so this is handled by an extra base class
 // It also keeps all the #ifdef handling local
 class VCLPLUG_QT5_PUBLIC Qt5MocInstance
-#ifdef _WIN32
+#if (defined MACOSX || defined _WIN32)
     : public SalInstance
 #else
     : public SalGenericInstance
@@ -49,7 +49,7 @@ class VCLPLUG_QT5_PUBLIC Qt5MocInstance
 {
 public:
     Qt5MocInstance()
-#ifdef _WIN32
+#if (defined MACOSX || defined _WIN32)
         : SalInstance(o3tl::make_unique<comphelper::SolarMutex>())
 #else
         : SalGenericInstance(o3tl::make_unique<SalYieldMutex>())
@@ -57,7 +57,7 @@ public:
     {
     }
 
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
     virtual GenPspGraphics* CreatePrintGraphics() override;
     virtual void PostPrintersChanged() override;
 #endif
diff --git a/vcl/inc/qt5/Qt5Printer.hxx b/vcl/inc/qt5/Qt5Printer.hxx
index 4fcae075fe3c..84a46a9be8f7 100644
--- a/vcl/inc/qt5/Qt5Printer.hxx
+++ b/vcl/inc/qt5/Qt5Printer.hxx
@@ -19,21 +19,26 @@
 
 #pragma once
 
-#ifndef _WIN32
-#include <unx/genprn.h>
-#else
+#ifdef _WIN32
 #include <WinDef.h>
 #include <win/salprn.h>
+#else
+#ifdef MACOSX
+#include <osx/salprn.h>
+#else
+#include <unx/genprn.h>
+#endif
 #endif
-
-class Point;
-class SalFrame;
 
 class Qt5Printer
-#ifndef _WIN32
-    : public PspSalPrinter
-#else
+#ifdef _WIN32
     : public WinSalPrinter
+#else
+#ifdef MACOSX
+    : public AquaSalPrinter
+#else
+    : public PspSalPrinter
+#endif
 #endif
 {
 public:
diff --git a/vcl/inc/qt5/Qt5System.hxx b/vcl/inc/qt5/Qt5System.hxx
index 6bd732956137..ef514227ed94 100644
--- a/vcl/inc/qt5/Qt5System.hxx
+++ b/vcl/inc/qt5/Qt5System.hxx
@@ -11,21 +11,29 @@
 
 #include <vcl/sysdata.hxx>
 
-#ifndef _WIN32
-#include <unx/gensys.h>
-#else
+#ifdef _WIN32
 #include <win/salsys.h>
+#else
+#ifdef MACOSX
+#include <osx/salsys.h>
+#else
+#include <unx/gensys.h>
+#endif
 #endif
 
 class Qt5System
-#ifndef _WIN32
-    : public SalGenericSystem
-#else
+#ifdef _WIN32
     : public WinSalSystem
+#else
+#ifdef MACOSX
+    : public AquaSalSystem
+#else
+    : public SalGenericSystem
+#endif
 #endif
 {
 public:
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
     virtual unsigned int GetDisplayScreenCount() override;
     virtual tools::Rectangle GetDisplayScreenPosSizePixel(unsigned int nScreen) override;
     virtual int ShowNativeDialog(const OUString& rTitle, const OUString& rMessage,
diff --git a/vcl/qt5/Qt5Data.cxx b/vcl/qt5/Qt5Data.cxx
index e4307d4a91ad..a08dc5546b84 100644
--- a/vcl/qt5/Qt5Data.cxx
+++ b/vcl/qt5/Qt5Data.cxx
@@ -149,19 +149,19 @@
 #include <unx/x11_cursors/wsshow_curs.h>
 #include <unx/x11_cursors/wsshow_mask.h>
 
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
 #include <unx/glyphcache.hxx>
 #endif
 
 Qt5Data::Qt5Data(SalInstance* pInstance)
-#ifndef _WIN32
+#if (defined MACOSX || defined _WIN32)
+    : SalData()
+#else
     : GenericUnixSalData(SAL_DATA_QT5, pInstance)
     , m_pGlyphCache(new GlyphCache())
-#else
-    : SalData()
 #endif
 {
-#ifdef _WIN32
+#if (defined MACOSX || defined _WIN32)
     m_pInstance = pInstance;
     SetSalData(this);
 #endif
@@ -319,7 +319,7 @@ QCursor& Qt5Data::getCursor(PointerStyle ePointerStyle)
     return *m_aCursors[ePointerStyle];
 }
 
-#ifndef _WIN32
+#if !(defined _WIN32 || defined MACOSX)
 void Qt5Data::ErrorTrapPush() {}
 
 bool Qt5Data::ErrorTrapPop(bool /*bIgnoreError*/) { return false; }
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index 6fa97fedda92..51553e34fb3c 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -45,7 +45,7 @@
 #include <vcl/layout.hxx>
 #include <vcl/syswin.hxx>
 
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
 #include <cairo.h>
 #include <headless/svpgdi.hxx>
 #endif
@@ -60,7 +60,7 @@ static void SvpDamageHandler(void* handle, sal_Int32 nExtentsX, sal_Int32 nExten
 Qt5Frame::Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags nStyle, bool bUseCairo )
     : m_pTopLevel(nullptr)
     , m_bUseCairo(bUseCairo)
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
     , m_pSvpGraphics(nullptr)
 #endif
     , m_bNullRegion(true)
@@ -167,7 +167,7 @@ void Qt5Frame::TriggerPaintEvent(QRect aRect)
     CallCallback(SalEvent::Paint, &aPaintEvt);
 }
 
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
 void Qt5Frame::InitSvpSalGraphics(SvpSalGraphics* pSvpSalGraphics)
 {
     int width = 640;
@@ -188,7 +188,7 @@ SalGraphics* Qt5Frame::AcquireGraphics()
 
     m_bGraphicsInUse = true;
 
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
     if (m_bUseCairo)
     {
         if (!m_pOurSvpGraphics.get())
@@ -215,7 +215,7 @@ SalGraphics* Qt5Frame::AcquireGraphics()
 void Qt5Frame::ReleaseGraphics(SalGraphics* pSalGraph)
 {
     (void)pSalGraph;
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
     if (m_bUseCairo)
         assert(pSalGraph == m_pOurSvpGraphics.get());
     else
diff --git a/vcl/qt5/Qt5Graphics_Text.cxx b/vcl/qt5/Qt5Graphics_Text.cxx
index e39c1b8c95a3..d4c718a3194b 100644
--- a/vcl/qt5/Qt5Graphics_Text.cxx
+++ b/vcl/qt5/Qt5Graphics_Text.cxx
@@ -23,7 +23,7 @@
 #include <Qt5Painter.hxx>
 
 #include <vcl/fontcharmap.hxx>
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
 #include <unx/geninst.h>
 #include <unx/fontmanager.hxx>
 #endif
@@ -90,7 +90,7 @@ bool Qt5Graphics::GetFontCapabilities(vcl::FontCapabilities& rFontCapabilities)
 
 void Qt5Graphics::GetDevFontList(PhysicalFontCollection* pPFC)
 {
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
     static const bool bUseFontconfig = (nullptr == getenv("SAL_VCL_QT5_NO_FONTCONFIG"));
 #endif
 
@@ -100,7 +100,7 @@ void Qt5Graphics::GetDevFontList(PhysicalFontCollection* pPFC)
 
     QFontDatabase aFDB;
 
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
     if (bUseFontconfig)
     {
         ::std::vector<psp::fontID> aList;
diff --git a/vcl/qt5/Qt5Instance.cxx b/vcl/qt5/Qt5Instance.cxx
index eb0a0b3ac9d6..8557834064d8 100644
--- a/vcl/qt5/Qt5Instance.cxx
+++ b/vcl/qt5/Qt5Instance.cxx
@@ -96,7 +96,7 @@ std::unique_ptr<SalVirtualDevice>
 Qt5Instance::CreateVirtualDevice(SalGraphics* pGraphics, long& nDX, long& nDY, DeviceFormat eFormat,
                                  const SystemGraphicsData* /* pData */)
 {
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
     if (m_bUseCairo)
     {
         SvpSalGraphics* pSvpSalGraphics = dynamic_cast<SvpSalGraphics*>(pGraphics);
@@ -135,7 +135,7 @@ SalSystem* Qt5Instance::CreateSalSystem() { return new Qt5System; }
 
 std::shared_ptr<SalBitmap> Qt5Instance::CreateSalBitmap()
 {
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
     if (m_bUseCairo)
         return std::make_shared<SvpSalBitmap>();
     else
@@ -271,7 +271,7 @@ VCLPLUG_QT5_PUBLIC SalInstance* create_SalInstance()
     for (int i = 0; i < nFakeArgc; i++)
         pFakeArgv[i] = pFakeArgvFreeable[i];
 
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
     char* session_manager = nullptr;
     if (getenv("SESSION_MANAGER") != nullptr)
     {
@@ -284,7 +284,7 @@ VCLPLUG_QT5_PUBLIC SalInstance* create_SalInstance()
     *pFakeArgc = nFakeArgc;
     pQApplication = new QApplication(*pFakeArgc, pFakeArgv);
 
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
     if (session_manager != nullptr)
     {
         // coverity[tainted_string] - trusted source for setenv
diff --git a/vcl/qt5/Qt5Instance_Print.cxx b/vcl/qt5/Qt5Instance_Print.cxx
index 07f98b6c9c33..f269e32560bb 100644
--- a/vcl/qt5/Qt5Instance_Print.cxx
+++ b/vcl/qt5/Qt5Instance_Print.cxx
@@ -20,7 +20,7 @@
 #include <Qt5Instance.hxx>
 #include <Qt5Printer.hxx>
 
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
 #include <vcl/svapp.hxx>
 #include <vcl/timer.hxx>
 
@@ -39,7 +39,7 @@ using namespace psp;
  *  static helpers
  */
 
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
 static OUString getPdfDir(const PrinterInfo& rInfo)
 {
     OUString aDir;
@@ -63,7 +63,7 @@ static OUString getPdfDir(const PrinterInfo& rInfo)
 SalInfoPrinter* Qt5Instance::CreateInfoPrinter(SalPrinterQueueInfo* pQueueInfo,
                                                ImplJobSetup* pJobSetup)
 {
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
     // create and initialize SalInfoPrinter
     PspSalInfoPrinter* pPrinter = new PspSalInfoPrinter;
     configurePspInfoPrinter(pPrinter, pQueueInfo, pJobSetup);
@@ -79,7 +79,7 @@ void Qt5Instance::DestroyInfoPrinter(SalInfoPrinter* pPrinter) { delete pPrinter
 
 std::unique_ptr<SalPrinter> Qt5Instance::CreatePrinter(SalInfoPrinter* pInfoPrinter)
 {
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
     // create and initialize SalPrinter
     Qt5Printer* pPrinter = new Qt5Printer(pInfoPrinter);
     pPrinter->m_aJobData = static_cast<PspSalInfoPrinter*>(pInfoPrinter)->m_aJobData;
@@ -93,7 +93,7 @@ std::unique_ptr<SalPrinter> Qt5Instance::CreatePrinter(SalInfoPrinter* pInfoPrin
 
 void Qt5Instance::GetPrinterQueueInfo(ImplPrnQueueList* pList)
 {
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
     PrinterInfoManager& rManager(PrinterInfoManager::get());
     static const char* pNoSyncDetection = getenv("SAL_DISABLE_SYNCHRONOUS_PRINTER_DETECTION");
     if (!pNoSyncDetection || !*pNoSyncDetection)
@@ -138,7 +138,7 @@ void Qt5Instance::GetPrinterQueueState(SalPrinterQueueInfo*) {}
 
 OUString Qt5Instance::GetDefaultPrinter()
 {
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
     PrinterInfoManager& rManager(PrinterInfoManager::get());
     return rManager.getDefaultPrinter();
 #else
@@ -146,7 +146,7 @@ OUString Qt5Instance::GetDefaultPrinter()
 #endif
 }
 
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
 void Qt5MocInstance::PostPrintersChanged() {}
 
 GenPspGraphics* Qt5MocInstance::CreatePrintGraphics() { return new GenPspGraphics(); }
diff --git a/vcl/qt5/Qt5Instance_Print.mm b/vcl/qt5/Qt5Instance_Print.mm
new file mode 100644
index 000000000000..b4004831fda8
--- /dev/null
+++ b/vcl/qt5/Qt5Instance_Print.mm
@@ -0,0 +1,20 @@
+/* -*- 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 "Qt5Instance_Print.cxx"
diff --git a/vcl/qt5/Qt5Printer.cxx b/vcl/qt5/Qt5Printer.cxx
index 2f30b3b53720..9ea85124b5ec 100644
--- a/vcl/qt5/Qt5Printer.cxx
+++ b/vcl/qt5/Qt5Printer.cxx
@@ -23,11 +23,16 @@
 #include <tools/gen.hxx>
 #include <Qt5Printer.hxx>
 
+#if defined _WIN32
 Qt5Printer::Qt5Printer(SalInfoPrinter* /* pInfoPrinter */)
-#ifndef _WIN32
-    : PspSalPrinter(pInfoPrinter)
-#else
     : WinSalPrinter()
+#else
+Qt5Printer::Qt5Printer(SalInfoPrinter* pInfoPrinter)
+#ifdef MACOSX
+    : AquaSalPrinter(static_cast<AquaSalInfoPrinter*>(pInfoPrinter))
+#else
+    : PspSalPrinter(pInfoPrinter)
+#endif
 #endif
 {
 }
diff --git a/vcl/qt5/Qt5Printer.mm b/vcl/qt5/Qt5Printer.mm
new file mode 100644
index 000000000000..6f2eed046866
--- /dev/null
+++ b/vcl/qt5/Qt5Printer.mm
@@ -0,0 +1,20 @@
+/* -*- 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 "Qt5Printer.cxx"
diff --git a/vcl/qt5/Qt5Tools.cxx b/vcl/qt5/Qt5Tools.cxx
index b12a03539bbb..e14c6099d927 100644
--- a/vcl/qt5/Qt5Tools.cxx
+++ b/vcl/qt5/Qt5Tools.cxx
@@ -21,7 +21,7 @@
 
 #include <vcl/event.hxx>
 
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
 #include <cairo.h>
 
 void CairoDeleter::operator()(cairo_surface_t* pSurface) const { cairo_surface_destroy(pSurface); }
diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx
index 0c487b39d58c..440a3bb7435f 100644
--- a/vcl/qt5/Qt5Widget.cxx
+++ b/vcl/qt5/Qt5Widget.cxx
@@ -35,7 +35,7 @@
 #include <QtWidgets/QtWidgets>
 #include <QtWidgets/QMainWindow>
 
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
 #include <cairo.h>
 #include <headless/svpgdi.hxx>
 #endif
@@ -46,7 +46,7 @@ void Qt5Widget::paintEvent(QPaintEvent* pEvent)
     if (!m_pFrame->m_bNullRegion)
         p.setClipRegion(m_pFrame->m_aRegion);
 
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
     if (m_pFrame->m_bUseCairo)
     {
         cairo_surface_t* pSurface = m_pFrame->m_pSurface.get();
@@ -63,7 +63,7 @@ void Qt5Widget::paintEvent(QPaintEvent* pEvent)
 
 void Qt5Widget::resizeEvent(QResizeEvent* /*event*/)
 {
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
     if (m_pFrame->m_bUseCairo)
     {
         int width = size().width();
commit 1801dd04d5927feba094c4d609ea09796e1bf948
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Thu Sep 13 12:49:53 2018 +0200
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Thu Sep 20 19:08:44 2018 +0200

    Implement MacOSX VCL backend as plugin
    
    Change-Id: Ie90af62eff146064c3b066a8f7ca1c3a69f44c39

diff --git a/Repository.mk b/Repository.mk
index dce2caa6c7db..b2c806307083 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -482,6 +482,7 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,ooo, \
 			AppleRemote \
 		) \
 		fps_aqua \
+		vclplug_osx \
 		MacOSXSpell \
 	) \
 ))
diff --git a/include/vcl/ImageTree.hxx b/include/vcl/ImageTree.hxx
index 66a82b000ebc..6598c34c09e9 100644
--- a/include/vcl/ImageTree.hxx
+++ b/include/vcl/ImageTree.hxx
@@ -70,7 +70,7 @@ public:
     /** a crude form of life cycle control (called from DeInitVCL; otherwise,
      *  if the ImplImageTree singleton were destroyed during exit that would
      *  be too late for the destructors of the bitmaps in maIconCache)*/
-    void shutdown();
+    VCL_DLLPUBLIC void shutdown();
 };
 
 #endif
diff --git a/include/vcl/svmain.hxx b/include/vcl/svmain.hxx
index c4437b27d556..6305c090d289 100644
--- a/include/vcl/svmain.hxx
+++ b/include/vcl/svmain.hxx
@@ -25,7 +25,7 @@
 
 // #i47888# allow for alternative initialization as required for e.g. MacOSX
 bool ImplSVMainHook( int* );
-int ImplSVMain();
+VCL_DLLPUBLIC int ImplSVMain();
 
 VCL_DLLPUBLIC int SVMain();
 
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index fc74f2918ab5..c6e560baeb95 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -555,7 +555,7 @@ public:
     SalFrame*                           ImplGetFrame() const;
     SAL_DLLPRIVATE ImplFrameData*       ImplGetFrameData();
 
-    SAL_DLLPRIVATE vcl::Window*         ImplGetWindow();
+                   vcl::Window*         ImplGetWindow();
     SAL_DLLPRIVATE ImplWinData*         ImplGetWinData() const;
     SAL_DLLPRIVATE vcl::Window*         ImplGetClientWindow() const;
     SAL_DLLPRIVATE vcl::Window*         ImplGetDlgWindow( sal_uInt16 n, GetDlgWindowType nType, sal_uInt16 nStart = 0, sal_uInt16 nEnd = 0xFFFF, sal_uInt16* pIndex = nullptr );
diff --git a/solenv/clang-format/blacklist b/solenv/clang-format/blacklist
index 33208a23b5ee..bcb5733ee12a 100644
--- a/solenv/clang-format/blacklist
+++ b/solenv/clang-format/blacklist
@@ -17915,6 +17915,7 @@ 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
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 55a6095fd6d5..184c84248eb0 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -89,22 +89,6 @@ $(eval $(call gb_Library_use_libraries,vcl,\
     xmlreader \
 ))
 
-ifeq ($(OS),MACOSX)
-$(eval $(call gb_Library_add_libs,vcl,\
-    -framework IOKit \
-    -F/System/Library/PrivateFrameworks \
-    -framework CoreUI \
-    -lobjc \
-))
-endif
-ifeq ($(OS),MACOSX)
-
-$(eval $(call gb_Library_add_cxxflags,vcl,\
-    $(gb_OBJCXXFLAGS) \
-))
-
-endif
-
 ifeq ($(ENABLE_JAVA),TRUE)
 $(eval $(call gb_Library_use_libraries,vcl,\
     jvmaccess \
@@ -443,8 +427,6 @@ $(eval $(call gb_Library_add_cobjects,vcl,\
     vcl/source/filter/jpeg/transupp \
 ))
 
-# optional parts
-
 vcl_quartz_code= \
     vcl/quartz/salbmp \
     vcl/quartz/utils \
@@ -455,100 +437,6 @@ vcl_coretext_code= \
     vcl/quartz/ctfonts \
     vcl/quartz/salgdi \
 
-ifeq ($(OS),MACOSX)
-
-$(eval $(call gb_Library_add_cxxflags,vcl,\
-    $(gb_OBJCXXFLAGS) \
-))
-
-$(eval $(call gb_Library_add_defs,vcl,\
-    -DMACOSX_BUNDLE_IDENTIFIER=\"$(MACOSX_BUNDLE_IDENTIFIER)\" \
-))
-
-$(eval $(call gb_Library_add_exception_objects,vcl,\
-    $(vcl_coretext_code) \
-))
-
-$(eval $(call gb_Library_use_system_darwin_frameworks,vcl,\
-    ApplicationServices \
-))
-
-$(eval $(call gb_Library_add_objcxxobjects,vcl,\
-    vcl/osx/a11yactionwrapper \
-    vcl/osx/a11ycomponentwrapper \
-    vcl/osx/a11yfactory \
-    vcl/osx/a11yrolehelper \
-    vcl/osx/a11yselectionwrapper \
-    vcl/osx/a11ytablewrapper \
-    vcl/osx/a11ytextattributeswrapper \
-    vcl/osx/a11ytextwrapper \
-    vcl/osx/a11yutil \
-    vcl/osx/a11yvaluewrapper \
-    vcl/osx/a11ywrapper \
-    vcl/osx/a11ywrapperbutton \
-    vcl/osx/a11ywrappercheckbox \
-    vcl/osx/a11ywrappercombobox \
-    vcl/osx/a11ywrappergroup \
-    vcl/osx/a11ywrapperlist \
-    vcl/osx/a11ywrapperradiobutton \
-    vcl/osx/a11ywrapperradiogroup \
-    vcl/osx/a11ywrapperrow \
-    vcl/osx/a11ywrapperscrollarea \
-    vcl/osx/a11ywrapperscrollbar \
-    vcl/osx/a11ywrappersplitter \
-    vcl/osx/a11ywrapperstatictext \
-    vcl/osx/a11ywrappertabgroup \
-    vcl/osx/a11ywrappertextarea \
-    vcl/osx/a11ywrappertoolbar \
-    vcl/osx/salnstimer \
-    vcl/osx/vclnsapp \
-    vcl/osx/printaccessoryview \
-    vcl/osx/printview \
-    vcl/osx/salframeview \
-    vcl/osx/salnsmenu \
-))
-$(eval $(call gb_Library_add_exception_objects,vcl,\
-    vcl/osx/a11yfocuslistener \
-    vcl/osx/a11yfocustracker \
-    vcl/osx/a11ylistener \
-    vcl/osx/documentfocuslistener \
-    vcl/osx/saldata \
-    vcl/osx/salinst \
-    vcl/osx/salsys \
-    vcl/osx/saltimer \
-    vcl/osx/DataFlavorMapping \
-    vcl/osx/DragActionConversion \
-    vcl/osx/DragSource \
-    vcl/osx/DragSourceContext \
-    vcl/osx/DropTarget \
-    vcl/osx/HtmlFmtFlt \
-    vcl/osx/OSXTransferable \
-    vcl/osx/PictToBmpFlt \
-    vcl/osx/clipboard \
-    vcl/osx/service_entry \
-    $(vcl_quartz_code) \
-    vcl/quartz/salgdiutils \
-    vcl/osx/salnativewidgets \
-    vcl/osx/salprn \
-    vcl/osx/salframe \
-    vcl/osx/salmenu \
-    vcl/osx/salobj \
-))
-$(eval $(call gb_Library_use_system_darwin_frameworks,vcl,\
-    $(if $(filter X86_64,$(CPUNAME)),,QuickTime) \
-    Cocoa \
-    Carbon \
-    CoreFoundation \
-))
-
-ifneq ($(ENABLE_MACOSX_SANDBOX),TRUE)
-$(eval $(call gb_Library_use_libraries,vcl,\
-    AppleRemote \
-))
-endif
-
-endif
-
 vcl_headless_code= \
     vcl/headless/svpframe \
     $(if $(filter-out IOS,$(OS)), \
@@ -709,6 +597,7 @@ $(eval $(call gb_Library_use_externals,vcl,\
 ))
 endif
 
+
 ifeq ($(OS),IOS)
 $(eval $(call gb_Library_add_cxxflags,vcl,\
     $(gb_OBJCXXFLAGS) \
@@ -727,7 +616,18 @@ $(eval $(call gb_Library_use_system_darwin_frameworks,vcl,\
 ))
 endif
 
-# OS-specific stuff
+
+ifeq ($(OS),MACOSX)
+$(eval $(call gb_Library_use_system_darwin_frameworks,vcl,\
+    Cocoa \
+    CoreFoundation \
+))
+
+$(eval $(call gb_Library_add_exception_objects,vcl,\
+    vcl/osx/salplug \
+))
+endif
+
 
 ifeq ($(OS),WNT)
 $(eval $(call gb_Library_add_exception_objects,vcl,\
diff --git a/vcl/Library_vclplug_osx.mk b/vcl/Library_vclplug_osx.mk
new file mode 100644
index 000000000000..968d34b9b99b
--- /dev/null
+++ b/vcl/Library_vclplug_osx.mk
@@ -0,0 +1,195 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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 .
+#
+
+$(eval $(call gb_Library_Library,vclplug_osx))
+
+$(eval $(call gb_Library_set_componentfile,vclplug_osx,vcl/vcl.common))
+
+$(eval $(call gb_Library_set_include,vclplug_osx,\
+    $$(INCLUDE) \
+    -I$(SRCDIR)/vcl/inc \
+))
+
+
+ifeq ($(SYSTEM_GLM),TRUE)
+$(eval $(call gb_Library_add_defs,vclplug_osx,\
+    -DGLM_ENABLE_EXPERIMENTAL \
+))
+endif
+
+$(eval $(call gb_Library_use_sdk_api,vclplug_osx))
+
+$(eval $(call gb_Library_use_custom_headers,vclplug_osx,\
+    officecfg/registry \
+))
+
+$(eval $(call gb_Library_add_libs,vclplug_osx,\
+    -framework IOKit \
+    -F/System/Library/PrivateFrameworks \
+    -framework CoreUI \
+    -lobjc \
+))
+
+$(eval $(call gb_Library_add_cxxflags,vclplug_osx,\
+    $(gb_OBJCXXFLAGS) \
+))
+
+ifeq ($(ENABLE_JAVA),TRUE)
+$(eval $(call gb_Library_use_libraries,vclplug_osx,\
+    jvmaccess \
+))
+endif
+
+$(eval $(call gb_Library_use_libraries,vclplug_osx,\
+    vcl \
+    tl \
+    utl \
+    sot \
+    ucbhelper \
+    basegfx \
+    comphelper \
+    cppuhelper \
+    i18nlangtag \
+    i18nutil \
+    $(if $(ENABLE_JAVA), \
+        jvmaccess) \
+    cppu \
+    sal \
+    salhelper \
+))
+
+$(eval $(call gb_Library_use_externals,vclplug_osx,\
+    boost_headers \
+    gio \
+    glm_headers \
+    graphite \
+    harfbuzz \
+    icu_headers \
+    icuuc \
+    lcms2 \
+    mdds_headers \
+))
+ifeq ($(DISABLE_GUI),)
+$(eval $(call gb_Library_use_externals,vclplug_osx,\
+     epoxy \
+ ))
+endif
+
+# optional parts
+
+vcl_quartz_code= \
+    vcl/quartz/salbmp \
+    vcl/quartz/utils \
+    vcl/quartz/salgdicommon \
+    vcl/quartz/salvd \
+
+vcl_coretext_code= \
+    vcl/quartz/ctfonts \
+    vcl/quartz/salgdi \
+
+$(eval $(call gb_Library_add_cxxflags,vclplug_osx,\
+    $(gb_OBJCXXFLAGS) \
+))
+
+$(eval $(call gb_Library_add_defs,vclplug_osx,\
+    -DMACOSX_BUNDLE_IDENTIFIER=\"$(MACOSX_BUNDLE_IDENTIFIER)\" \
+))
+
+$(eval $(call gb_Library_add_exception_objects,vclplug_osx,\
+    $(vcl_coretext_code) \
+))
+
+$(eval $(call gb_Library_add_objcxxobjects,vclplug_osx,\
+    vcl/osx/a11yactionwrapper \
+    vcl/osx/a11ycomponentwrapper \
+    vcl/osx/a11yfactory \
+    vcl/osx/a11yrolehelper \
+    vcl/osx/a11yselectionwrapper \
+    vcl/osx/a11ytablewrapper \
+    vcl/osx/a11ytextattributeswrapper \
+    vcl/osx/a11ytextwrapper \
+    vcl/osx/a11yutil \
+    vcl/osx/a11yvaluewrapper \
+    vcl/osx/a11ywrapper \
+    vcl/osx/a11ywrapperbutton \
+    vcl/osx/a11ywrappercheckbox \
+    vcl/osx/a11ywrappercombobox \
+    vcl/osx/a11ywrappergroup \
+    vcl/osx/a11ywrapperlist \
+    vcl/osx/a11ywrapperradiobutton \
+    vcl/osx/a11ywrapperradiogroup \
+    vcl/osx/a11ywrapperrow \
+    vcl/osx/a11ywrapperscrollarea \
+    vcl/osx/a11ywrapperscrollbar \
+    vcl/osx/a11ywrappersplitter \
+    vcl/osx/a11ywrapperstatictext \
+    vcl/osx/a11ywrappertabgroup \
+    vcl/osx/a11ywrappertextarea \
+    vcl/osx/a11ywrappertoolbar \
+    vcl/osx/salnstimer \
+    vcl/osx/vclnsapp \
+    vcl/osx/printaccessoryview \
+    vcl/osx/printview \
+    vcl/osx/salframeview \
+    vcl/osx/salnsmenu \
+))
+
+$(eval $(call gb_Library_add_exception_objects,vclplug_osx,\
+    vcl/osx/a11yfocuslistener \
+    vcl/osx/a11yfocustracker \
+    vcl/osx/a11ylistener \
+    vcl/osx/documentfocuslistener \
+    vcl/osx/saldata \
+    vcl/osx/salinst \
+    vcl/osx/salsys \
+    vcl/osx/saltimer \
+    vcl/osx/DataFlavorMapping \
+    vcl/osx/DragActionConversion \
+    vcl/osx/DragSource \
+    vcl/osx/DragSourceContext \
+    vcl/osx/DropTarget \
+    vcl/osx/HtmlFmtFlt \
+    vcl/osx/OSXTransferable \
+    vcl/osx/PictToBmpFlt \
+    vcl/osx/clipboard \
+    vcl/osx/service_entry \
+    $(vcl_quartz_code) \
+    vcl/quartz/salgdiutils \
+    vcl/osx/salnativewidgets \
+    vcl/osx/salprn \
+    vcl/osx/salframe \
+    vcl/osx/salmenu \
+    vcl/osx/salobj \
+))
+
+$(eval $(call gb_Library_use_system_darwin_frameworks,vclplug_osx,\
+    ApplicationServices \
+    Cocoa \
+    Carbon \
+    CoreFoundation \
+    $(if $(filter X86_64,$(CPUNAME)),,QuickTime) \
+))
+
+ifneq ($(ENABLE_MACOSX_SANDBOX),TRUE)
+$(eval $(call gb_Library_use_libraries,vclplug_osx,\
+    AppleRemote \
+))
+endif
+
+# vim: set noet sw=4 ts=4:
diff --git a/vcl/Module_vcl.mk b/vcl/Module_vcl.mk
index c2a26d5e9685..8fbe1fdca943 100644
--- a/vcl/Module_vcl.mk
+++ b/vcl/Module_vcl.mk
@@ -106,6 +106,7 @@ endif
 ifeq ($(OS),MACOSX)
 $(eval $(call gb_Module_add_targets,vcl,\
     Package_osxres \
+    Library_vclplug_osx \
 ))
 endif
 
diff --git a/vcl/inc/bmpfast.hxx b/vcl/inc/bmpfast.hxx
index 6e5e22544c5d..f9a1f891bb47 100644
--- a/vcl/inc/bmpfast.hxx
+++ b/vcl/inc/bmpfast.hxx
@@ -20,6 +20,8 @@
 #ifndef INCLUDED_VCL_INC_BMPFAST_HXX
 #define INCLUDED_VCL_INC_BMPFAST_HXX
 
+#include <vcl/dllapi.h>
+
 class BitmapWriteAccess;
 class BitmapReadAccess;
 struct BitmapBuffer;
@@ -29,7 +31,7 @@ struct SalTwoRect;
 // the bmpfast functions have signatures with good compatibility to
 // their canonic counterparts, which employ the GetPixel/SetPixel methods
 
-bool ImplFastBitmapConversion( BitmapBuffer& rDst, const BitmapBuffer& rSrc,
+VCL_DLLPUBLIC bool ImplFastBitmapConversion( BitmapBuffer& rDst, const BitmapBuffer& rSrc,
         const SalTwoRect& rTwoRect );
 
 bool ImplFastBitmapBlending( BitmapWriteAccess const & rDst,
diff --git a/vcl/inc/salinst.hxx b/vcl/inc/salinst.hxx
index 9f20394fe4e6..1418ef4ef859 100644
--- a/vcl/inc/salinst.hxx
+++ b/vcl/inc/salinst.hxx
@@ -216,10 +216,6 @@ void DeInitSalData();                       // called from Application-Dtor
 
 void InitSalMain();
 
-#ifdef MACOSX
-void postInitVCLinitNSApp();
-#endif
-
 #endif // INCLUDED_VCL_INC_SALINST_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/vclpluginapi.h b/vcl/inc/vclpluginapi.h
index 88defd3972d6..fb3350e43a1f 100644
--- a/vcl/inc/vclpluginapi.h
+++ b/vcl/inc/vclpluginapi.h
@@ -47,6 +47,12 @@
 #define VCLPLUG_KDE5_PUBLIC SAL_DLLPUBLIC_IMPORT
 #endif
 
+#if defined VCLPLUG_OSX_IMPLEMENTATION
+#define VCLPLUG_OSX_PUBLIC SAL_DLLPUBLIC_EXPORT
+#else
+#define VCLPLUG_OSX_PUBLIC SAL_DLLPUBLIC_IMPORT
+#endif
+
 #if defined VCLPLUG_QT5_IMPLEMENTATION
 #define VCLPLUG_QT5_PUBLIC SAL_DLLPUBLIC_EXPORT
 #else
diff --git a/vcl/osx/salinst.cxx b/vcl/osx/salinst.cxx
index e81278b807fb..472cf514f497 100644
--- a/vcl/osx/salinst.cxx
+++ b/vcl/osx/salinst.cxx
@@ -35,7 +35,7 @@
 #include <osl/process.h>
 
 #include <rtl/ustrbuf.hxx>
-
+#include <vclpluginapi.h>
 #include <vcl/svapp.hxx>
 #include <vcl/window.hxx>
 #include <vcl/idle.hxx>
@@ -57,6 +57,7 @@
 
 #include <print.h>
 #include <salimestatus.hxx>
+#include <o3tl/make_unique.hxx>
 
 #include <comphelper/processfactory.hxx>
 
@@ -191,24 +192,12 @@ void SalAbort( const OUString& rErrorText, bool bDumpCore )
         _exit(1);
 }
 
-void InitSalData()
-{
-}
-
 const OUString& SalGetDesktopEnvironment()
 {
     static OUString aDesktopEnvironment( "MacOSX" );
     return aDesktopEnvironment;
 }
 
-void DeInitSalData()
-{
-}
-
-void InitSalMain()
-{
-}
-
 SalYieldMutex::SalYieldMutex()
     : m_aCodeBlock( nullptr )
 {
@@ -307,7 +296,8 @@ void ImplSalYieldMutexRelease()
         pInst->GetYieldMutex()->release();
 }
 
-SalInstance* CreateSalInstance()
+extern "C" {
+VCLPLUG_OSX_PUBLIC SalInstance* create_SalInstance()
 {
     SalData* pSalData = new SalData;
 
@@ -345,10 +335,6 @@ SalInstance* CreateSalInstance()
 
     return pInst;
 }
-
-void DestroySalInstance( SalInstance* pInst )
-{
-    delete pInst;
 }
 
 AquaSalInstance::AquaSalInstance()
@@ -360,6 +346,9 @@ AquaSalInstance::AquaSalInstance()
 {
     GetYieldMutex()->acquire();
     maMainThread = osl::Thread::getCurrentIdentifier();
+
+    ImplSVData* pSVData = ImplGetSVData();
+    pSVData->maAppData.mxToolkitName = OUString("osx");
 }
 
 AquaSalInstance::~AquaSalInstance()
diff --git a/vcl/osx/salplug.cxx b/vcl/osx/salplug.cxx
new file mode 100644
index 000000000000..e4f69a10ee25
--- /dev/null
+++ b/vcl/osx/salplug.cxx
@@ -0,0 +1,167 @@
+/* -*- 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/source/app/dbggui.cxx b/vcl/source/app/dbggui.cxx
index b27eed124f6c..bd87814b31c6 100644
--- a/vcl/source/app/dbggui.cxx
+++ b/vcl/source/app/dbggui.cxx
@@ -35,7 +35,6 @@
 #include <dbggui.hxx>
 
 #include <salinst.hxx>
-#include <svsys.h>
 
 #include <algorithm>
 #include <memory>
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index 3f51db953f57..c6d935327a5b 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -1135,7 +1135,7 @@ OUString Application::GetHWOSConfInfo()
         aDetails.append( VclResId(SV_APP_DEFAULT) );
     aDetails.append( "; " );
 
-#if (defined LINUX || defined _WIN32)
+#if (defined LINUX || defined _WIN32 || defined MACOSX)
     aDetails.append( SV_APP_VCLBACKEND );
     aDetails.append( GetToolkitName() );
     aDetails.append( "; " );
commit 112cb52757e85deb219c0d32306de43dc88ce4d0
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Wed Sep 12 10:30:05 2018 +0200
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Thu Sep 20 19:08:42 2018 +0200

    Qt5 build VCL plugin on Windows
    
    Change-Id: I1bb673eb2c228d767caca6a9a860bd9d113d082f

diff --git a/Repository.mk b/Repository.mk
index 34ac4e5c6ae0..dce2caa6c7db 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -473,6 +473,7 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,ooo, \
 		ado \
 		oleautobridge \
 		smplmail \
+		$(if $(ENABLE_QT5),vclplug_qt5) \
 		vclplug_win \
 		wininetbe1 \
 	) \
diff --git a/config_host/config_vclplug.h.in b/config_host/config_vclplug.h.in
index be9c136245ee..c02853d5282d 100644
--- a/config_host/config_vclplug.h.in
+++ b/config_host/config_vclplug.h.in
@@ -11,5 +11,6 @@ Settings about which X11 desktops have support enabled.
 #define ENABLE_KDE4 0
 #define ENABLE_KDE5 0
 #define ENABLE_GTK3_KDE5 0
+#define ENABLE_QT5 0
 
 #endif
diff --git a/configure.ac b/configure.ac
index ec9d8b34d416..587b6c3f479b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -636,6 +636,7 @@ cygwin*|interix*)
     test_xrender=no
     test_freetype=no
     test_fontconfig=no
+    test_qt5=yes
     _os=WINNT
 
     DLLPOST=".dll"
@@ -4676,7 +4677,6 @@ if test "$USING_X11" != TRUE; then
     build_gstreamer_0_10=no
     test_kde4=no
     test_kde5=no
-    test_qt5=no
     test_gtk3_kde5=no
     enable_cairo_canvas=no
 fi
@@ -10016,10 +10016,16 @@ dnl ===================================================================
 dnl Test which vclplugs have to be built.
 dnl ===================================================================
 R=""
-if test "$USING_X11" != TRUE; then
+if test "$USING_X11" = TRUE; then
+    R="gen"
+else
     enable_gtk=no
     enable_gtk3=no
+    if test "$_os" = "WINNT"; then
+        R="win"
+    fi
 fi
+
 GTK3_CFLAGS=""
 GTK3_LIBS=""
 ENABLE_GTK3=""
@@ -10030,7 +10036,7 @@ if test "x$enable_gtk3" = "xyes"; then
     : ${with_system_cairo:=yes}
     PKG_CHECK_MODULES(GTK3, gtk+-3.0 >= 3.18 gtk+-unix-print-3.0 gmodule-no-export-2.0 glib-2.0 >= 2.38 cairo, ENABLE_GTK3="TRUE", ENABLE_GTK3="")
     if test "x$ENABLE_GTK3" = "xTRUE"; then
-        R="gtk3"
+        R=" gtk3"
         dnl Avoid installed by unpackaged files for now.
         if test -z "$PKGFORMAT"; then
             GOBJECT_INTROSPECTION_CHECK(INTROSPECTION_REQUIRED_VERSION)
@@ -11165,7 +11171,11 @@ then
     fi
 
     qt5_test_include="QtWidgets/qapplication.h"
-    qt5_test_library="libQt5Widgets.so"
+    if test $_os == "WINNT"; then
+        qt5_test_library="Qt5Widgets.lib"
+    else
+        qt5_test_library="libQt5Widgets.so"
+    fi
 
     dnl Check for qmake5
     AC_PATH_PROGS( QMAKE5, [qmake-qt5 qmake], no, [$QT5DIR/bin:$PATH] )
@@ -11187,6 +11197,10 @@ then
 
     qt5_incdirs="`$QMAKE5 -query QT_INSTALL_HEADERS` $qt5_incdirs"
     qt5_libdirs="`$QMAKE5 -query QT_INSTALL_LIBS` $qt5_libdirs"
+    if test $_os == "WINNT"; then
+        qt5_incdirs="`cygpath -m $qt5_incdirs`"
+        qt5_libdirs="`cygpath -m $qt5_libdirs`"
+    fi
 
     AC_MSG_CHECKING([for Qt5 headers])
     qt5_incdir="no"
@@ -11216,7 +11230,11 @@ then
 
     QT5_CFLAGS="-I$qt5_incdir -DQT_CLEAN_NAMESPACE -DQT_THREAD_SUPPORT"
     QT5_CFLAGS=$(printf '%s' "$QT5_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
-    QT5_LIBS="-L$qt5_libdir -lQt5Core -lQt5Gui -lQt5Widgets -lQt5Network"
+    if test $_os == "WINNT"; then
+        QT5_LIBS="-LIBPATH:$qt5_libdir Qt5Core.lib Qt5Gui.lib Qt5Widgets.lib Qt5Network.lib"
+    else
+        QT5_LIBS="-L$qt5_libdir -lQt5Core -lQt5Gui -lQt5Widgets -lQt5Network"
+    fi
 
     dnl Check for Meta Object Compiler
 
diff --git a/vcl/Library_vclplug_qt5.mk b/vcl/Library_vclplug_qt5.mk
index d66a82319ed2..782bea8707a9 100644
--- a/vcl/Library_vclplug_qt5.mk
+++ b/vcl/Library_vclplug_qt5.mk
@@ -35,6 +35,7 @@ $(eval $(call gb_Library_use_sdk_api,vclplug_qt5))
 
 $(eval $(call gb_Library_use_libraries,vclplug_qt5,\
     $(if $(USING_X11),vclplug_gen) \
+    $(if $(filter WNT,$(OS)),vclplug_win) \
     vcl \
     tl \
     utl \
@@ -54,7 +55,7 @@ $(eval $(call gb_Library_use_libraries,vclplug_qt5,\
 
 $(eval $(call gb_Library_use_externals,vclplug_qt5,\
     boost_headers \
-    cairo \
+    $(if $(USING_X11),cairo) \
     epoxy \
     graphite \
     harfbuzz \
@@ -97,7 +98,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_qt5,\
     vcl/qt5/Qt5Object \
     vcl/qt5/Qt5Painter \
     vcl/qt5/Qt5Printer \
-    vcl/qt5/Qt5System \
+    $(if $(USING_X11),vcl/qt5/Qt5System) \
     vcl/qt5/Qt5Timer \
     vcl/qt5/Qt5Tools \
     vcl/qt5/Qt5VirtualDevice \
@@ -106,9 +107,9 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_qt5,\
 
 ifeq ($(OS),LINUX)
 $(eval $(call gb_Library_add_libs,vclplug_qt5,\
-	-lm \
-	-ldl \
-	-lpthread \
+    -lm \
+    -ldl \
+    -lpthread \
 ))
 endif
 
diff --git a/vcl/Module_vcl.mk b/vcl/Module_vcl.mk
index 4f8d26c01c4b..c2a26d5e9685 100644
--- a/vcl/Module_vcl.mk
+++ b/vcl/Module_vcl.mk
@@ -114,6 +114,12 @@ $(eval $(call gb_Module_add_targets,vcl,\
     WinResTarget_vcl \
     Library_vclplug_win \
 ))
+ifneq ($(ENABLE_QT5),)
+$(eval $(call gb_Module_add_targets,vcl,\
+    CustomTarget_qt5_moc \
+    Library_vclplug_qt5 \
+))
+endif
 endif
 
 ifeq ($(OS),HAIKU)
diff --git a/vcl/inc/qt5/Qt5Bitmap.hxx b/vcl/inc/qt5/Qt5Bitmap.hxx
index ba2ea5a2f58a..3f1421a820a5 100644
--- a/vcl/inc/qt5/Qt5Bitmap.hxx
+++ b/vcl/inc/qt5/Qt5Bitmap.hxx
@@ -19,13 +19,14 @@
 
 #pragma once
 
+#include <vclpluginapi.h>
 #include <salbmp.hxx>
 
 #include <memory>
 
 class QImage;
 
-class VCL_DLLPUBLIC Qt5Bitmap : public SalBitmap
+class VCLPLUG_QT5_PUBLIC Qt5Bitmap : public SalBitmap
 {
     std::unique_ptr<QImage> m_pImage;
     BitmapPalette m_aPalette;
diff --git a/vcl/inc/qt5/Qt5Data.hxx b/vcl/inc/qt5/Qt5Data.hxx
index 3cda6037c5e9..c5a59432cb49 100644
--- a/vcl/inc/qt5/Qt5Data.hxx
+++ b/vcl/inc/qt5/Qt5Data.hxx
@@ -29,18 +29,25 @@
 class GlyphCache;
 class QCursor;
 
-class VCLPLUG_QT5_PUBLIC Qt5Data : public GenericUnixSalData
+class VCLPLUG_QT5_PUBLIC Qt5Data
+#ifndef _WIN32
+    : public GenericUnixSalData
+#else
+    : public SalData
+#endif
 {
     o3tl::enumarray<PointerStyle, std::unique_ptr<QCursor>> m_aCursors;
+#ifndef _WIN32
     std::unique_ptr<GlyphCache> m_pGlyphCache;
+#endif
 
 public:
     explicit Qt5Data(SalInstance* pInstance);
     virtual ~Qt5Data() override;
-
+#ifndef _WIN32
     virtual void ErrorTrapPush() override;
     virtual bool ErrorTrapPop(bool bIgnoreError = true) override;
-
+#endif
     QCursor& getCursor(PointerStyle ePointerStyle);
 
     static bool noNativeControls();
diff --git a/vcl/inc/qt5/Qt5Frame.hxx b/vcl/inc/qt5/Qt5Frame.hxx
index 577a9cce2fde..d7b793827667 100644
--- a/vcl/inc/qt5/Qt5Frame.hxx
+++ b/vcl/inc/qt5/Qt5Frame.hxx
@@ -24,7 +24,9 @@
 
 #include "Qt5Tools.hxx"
 
+#ifndef _WIN32
 #include <headless/svpgdi.hxx>
+#endif
 #include <vcl/svapp.hxx>
 
 #include <QtCore/QObject>
@@ -39,6 +41,18 @@ class QScreen;
 class QImage;
 class SvpSalGraphics;
 
+#ifdef _WIN32
+typedef void (*damageHandler)(void* handle,
+                              sal_Int32 nExtentsX, sal_Int32 nExtentsY,
+                              sal_Int32 nExtentsWidth, sal_Int32 nExtentsHeight);
+
+struct VCL_DLLPUBLIC DamageHandler
+{
+    void *handle;
+    damageHandler damaged;
+};
+#endif
+
 class VCLPLUG_QT5_PUBLIC Qt5Frame : public QObject, public SalFrame
 {
     Q_OBJECT
@@ -51,12 +65,14 @@ class VCLPLUG_QT5_PUBLIC Qt5Frame : public QObject, public SalFrame
     const bool m_bUseCairo;
     std::unique_ptr<QImage> m_pQImage;
     std::unique_ptr<Qt5Graphics> m_pQt5Graphics;
+#ifndef _WIN32
     UniqueCairoSurface m_pSurface;
     std::unique_ptr<SvpSalGraphics> m_pOurSvpGraphics;
     // in base class, this ptr is the same as m_pOurSvpGraphic
     // in derived class, it can point to a derivative
     // of SvpSalGraphics (which the derived class then owns)
     SvpSalGraphics* m_pSvpGraphics;
+#endif
     DamageHandler m_aDamageHandler;
     QRegion m_aRegion;
     bool m_bNullRegion;
@@ -110,7 +126,9 @@ public:
     void Damage(sal_Int32 nExtentsX, sal_Int32 nExtentsY, sal_Int32 nExtentsWidth,
                 sal_Int32 nExtentsHeight) const;
 
+#ifndef _WIN32
     virtual void InitSvpSalGraphics(SvpSalGraphics* pSvpSalGraphics);
+#endif
     virtual SalGraphics* AcquireGraphics() override;
     virtual void ReleaseGraphics(SalGraphics* pGraphics) override;
 
diff --git a/vcl/inc/qt5/Qt5Graphics.hxx b/vcl/inc/qt5/Qt5Graphics.hxx
index 76c39146728c..dd909f0372fd 100644
--- a/vcl/inc/qt5/Qt5Graphics.hxx
+++ b/vcl/inc/qt5/Qt5Graphics.hxx
@@ -30,6 +30,10 @@
 #include "Qt5Data.hxx"
 #include "Qt5Graphics_Controls.hxx"
 
+#ifdef _WIN32
+#include <QtWidgets/QPushButton>
+#endif
+
 class PhysicalFontCollection;
 class QImage;
 class QPushButton;
diff --git a/vcl/inc/qt5/Qt5Instance.hxx b/vcl/inc/qt5/Qt5Instance.hxx
index a2ceae0139e2..da772569d29c 100644
--- a/vcl/inc/qt5/Qt5Instance.hxx
+++ b/vcl/inc/qt5/Qt5Instance.hxx
@@ -20,10 +20,10 @@
 #pragma once
 
 #include <vclpluginapi.h>
-#include <unx/geninst.h>
 #include <salusereventlist.hxx>
 
 #include <osl/conditn.hxx>
+#include <o3tl/make_unique.hxx>
 
 #include <QtCore/QObject>
 
@@ -31,8 +31,40 @@ class QApplication;
 class SalYieldMutex;
 class SalFrame;
 
+#ifdef _WIN32
+#include <salinst.hxx>
+#include <comphelper/solarmutex.hxx>
+#else
+#include <unx/geninst.h>
+#endif
+
+// Qts moc doesn't like macros, so this is handled by an extra base class
+// It also keeps all the #ifdef handling local
+class VCLPLUG_QT5_PUBLIC Qt5MocInstance
+#ifdef _WIN32
+    : public SalInstance
+#else
+    : public SalGenericInstance
+#endif
+{
+public:
+    Qt5MocInstance()
+#ifdef _WIN32
+        : SalInstance(o3tl::make_unique<comphelper::SolarMutex>())
+#else
+        : SalGenericInstance(o3tl::make_unique<SalYieldMutex>())
+#endif
+    {
+    }
+
+#ifndef _WIN32
+    virtual GenPspGraphics* CreatePrintGraphics() override;
+    virtual void PostPrintersChanged() override;
+#endif
+};
+
 class VCLPLUG_QT5_PUBLIC Qt5Instance : public QObject,
-                                       public SalGenericInstance,
+                                       public Qt5MocInstance,
                                        public SalUserEventList
 {
     Q_OBJECT
@@ -78,7 +110,6 @@ public:
     virtual void GetPrinterQueueState(SalPrinterQueueInfo* pInfo) override;
     virtual void DeletePrinterQueueInfo(SalPrinterQueueInfo* pInfo) override;
     virtual OUString GetDefaultPrinter() override;
-    virtual void PostPrintersChanged() override;
 
     virtual std::unique_ptr<SalMenu> CreateMenu(bool, Menu*) override;
     virtual std::unique_ptr<SalMenuItem> CreateMenuItem(const SalItemParams&) override;
@@ -97,8 +128,6 @@ public:
     virtual void AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType,
                                          const OUString& rDocumentService) override;
 
-    virtual GenPspGraphics* CreatePrintGraphics() override;
-
     virtual bool IsMainThread() const override;
 
     virtual void TriggerUserEventProcessing() override;
diff --git a/vcl/inc/qt5/Qt5Printer.hxx b/vcl/inc/qt5/Qt5Printer.hxx
index 81a38206e4f1..4fcae075fe3c 100644
--- a/vcl/inc/qt5/Qt5Printer.hxx
+++ b/vcl/inc/qt5/Qt5Printer.hxx
@@ -19,11 +19,22 @@
 
 #pragma once
 
+#ifndef _WIN32
 #include <unx/genprn.h>
+#else
+#include <WinDef.h>
+#include <win/salprn.h>
+#endif
 
+class Point;
 class SalFrame;
 
-class Qt5Printer : public PspSalPrinter
+class Qt5Printer
+#ifndef _WIN32
+    : public PspSalPrinter
+#else
+    : public WinSalPrinter
+#endif
 {
 public:
     Qt5Printer(SalInfoPrinter* pInfoPrinter);
diff --git a/vcl/inc/qt5/Qt5System.hxx b/vcl/inc/qt5/Qt5System.hxx
index 0d51bb29f358..6bd732956137 100644
--- a/vcl/inc/qt5/Qt5System.hxx
+++ b/vcl/inc/qt5/Qt5System.hxx
@@ -10,15 +10,27 @@
 #pragma once
 
 #include <vcl/sysdata.hxx>
+
+#ifndef _WIN32
 #include <unx/gensys.h>
+#else
+#include <win/salsys.h>
+#endif
 
-class Qt5System : public SalGenericSystem
+class Qt5System
+#ifndef _WIN32
+    : public SalGenericSystem
+#else
+    : public WinSalSystem
+#endif
 {
 public:
+#ifndef _WIN32
     virtual unsigned int GetDisplayScreenCount() override;
     virtual tools::Rectangle GetDisplayScreenPosSizePixel(unsigned int nScreen) override;
     virtual int ShowNativeDialog(const OUString& rTitle, const OUString& rMessage,
                                  const std::vector<OUString>& rButtons) override;
+#endif
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/qt5/Qt5Tools.hxx b/vcl/inc/qt5/Qt5Tools.hxx
index c919b401e191..967cac0507de 100644
--- a/vcl/inc/qt5/Qt5Tools.hxx
+++ b/vcl/inc/qt5/Qt5Tools.hxx
@@ -82,7 +82,9 @@ inline QImage::Format getBitFormat(sal_uInt16 nBitCount)
             std::abort();
             break;
     }
+#ifndef _WIN32
     return QImage::Format_Invalid;
+#endif
 }
 
 inline sal_uInt16 getFormatBits(QImage::Format eFormat)
@@ -102,10 +104,13 @@ inline sal_uInt16 getFormatBits(QImage::Format eFormat)
             return 32;
         default:
             std::abort();
+#ifndef _WIN32
             return 0;
+#endif
     }
 }
 
+#ifndef _WIN32
 typedef struct _cairo_surface cairo_surface_t;
 struct CairoDeleter
 {
@@ -113,6 +118,7 @@ struct CairoDeleter
 };
 
 typedef std::unique_ptr<cairo_surface_t, CairoDeleter> UniqueCairoSurface;
+#endif
 
 sal_uInt16 GetKeyModCode(Qt::KeyboardModifiers eKeyModifiers);
 sal_uInt16 GetMouseModCode(Qt::MouseButtons eButtons);
diff --git a/vcl/inc/win/salprn.h b/vcl/inc/win/salprn.h
index c0c6e7fb7932..ef8737acc1f4 100644
--- a/vcl/inc/win/salprn.h
+++ b/vcl/inc/win/salprn.h
@@ -70,7 +70,7 @@ public:
 };
 
 
-class WinSalPrinter : public SalPrinter
+class SAL_DLLPUBLIC_EXPORT WinSalPrinter : public SalPrinter
 {
 public:
     WinSalGraphics*         mpGraphics;             // current Printer graphics
diff --git a/vcl/inc/win/salsys.h b/vcl/inc/win/salsys.h
index 03f627b5abb2..59f087136b79 100644
--- a/vcl/inc/win/salsys.h
+++ b/vcl/inc/win/salsys.h
@@ -25,7 +25,7 @@
 #include <vector>
 #include <map>
 
-class WinSalSystem : public SalSystem
+class SAL_DLLPUBLIC_EXPORT WinSalSystem : public SalSystem
 {
 public:
     struct DisplayMonitor
diff --git a/vcl/qt5/Qt5Data.cxx b/vcl/qt5/Qt5Data.cxx
index 74ba881ea15a..e4307d4a91ad 100644
--- a/vcl/qt5/Qt5Data.cxx
+++ b/vcl/qt5/Qt5Data.cxx
@@ -149,12 +149,22 @@
 #include <unx/x11_cursors/wsshow_curs.h>
 #include <unx/x11_cursors/wsshow_mask.h>
 
+#ifndef _WIN32
 #include <unx/glyphcache.hxx>
+#endif
 
 Qt5Data::Qt5Data(SalInstance* pInstance)
+#ifndef _WIN32
     : GenericUnixSalData(SAL_DATA_QT5, pInstance)
     , m_pGlyphCache(new GlyphCache())
+#else
+    : SalData()
+#endif
 {
+#ifdef _WIN32
+    m_pInstance = pInstance;
+    SetSalData(this);
+#endif
     ImplSVData* pSVData = ImplGetSVData();
 
     // draw toolbars on separate lines
@@ -309,9 +319,11 @@ QCursor& Qt5Data::getCursor(PointerStyle ePointerStyle)
     return *m_aCursors[ePointerStyle];
 }
 
+#ifndef _WIN32
 void Qt5Data::ErrorTrapPush() {}
 
 bool Qt5Data::ErrorTrapPop(bool /*bIgnoreError*/) { return false; }
+#endif
 
 bool Qt5Data::noNativeControls()
 {
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index b42ec5e08a0c..6fa97fedda92 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -45,8 +45,10 @@
 #include <vcl/layout.hxx>
 #include <vcl/syswin.hxx>
 
+#ifndef _WIN32
 #include <cairo.h>
 #include <headless/svpgdi.hxx>
+#endif
 
 static void SvpDamageHandler(void* handle, sal_Int32 nExtentsX, sal_Int32 nExtentsY,
                              sal_Int32 nExtentsWidth, sal_Int32 nExtentsHeight)
@@ -55,10 +57,12 @@ static void SvpDamageHandler(void* handle, sal_Int32 nExtentsX, sal_Int32 nExten
     pThis->Damage(nExtentsX, nExtentsY, nExtentsWidth, nExtentsHeight);
 }
 
-Qt5Frame::Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags nStyle, bool bUseCairo)
+Qt5Frame::Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags nStyle, bool bUseCairo )
     : m_pTopLevel(nullptr)
     , m_bUseCairo(bUseCairo)
+#ifndef _WIN32
     , m_pSvpGraphics(nullptr)
+#endif
     , m_bNullRegion(true)
     , m_bGraphicsInUse(false)
     , m_ePointerStyle(PointerStyle::Arrow)
@@ -163,6 +167,7 @@ void Qt5Frame::TriggerPaintEvent(QRect aRect)
     CallCallback(SalEvent::Paint, &aPaintEvt);
 }
 
+#ifndef _WIN32
 void Qt5Frame::InitSvpSalGraphics(SvpSalGraphics* pSvpSalGraphics)
 {
     int width = 640;
@@ -174,6 +179,7 @@ void Qt5Frame::InitSvpSalGraphics(SvpSalGraphics* pSvpSalGraphics)
                                 nullptr);
     TriggerPaintEvent();
 }
+#endif
 
 SalGraphics* Qt5Frame::AcquireGraphics()
 {
@@ -182,6 +188,7 @@ SalGraphics* Qt5Frame::AcquireGraphics()
 
     m_bGraphicsInUse = true;
 
+#ifndef _WIN32
     if (m_bUseCairo)
     {
         if (!m_pOurSvpGraphics.get())
@@ -192,6 +199,7 @@ SalGraphics* Qt5Frame::AcquireGraphics()
         return m_pOurSvpGraphics.get();
     }
     else
+#endif
     {
         if (!m_pQt5Graphics.get())
         {
@@ -207,9 +215,11 @@ SalGraphics* Qt5Frame::AcquireGraphics()
 void Qt5Frame::ReleaseGraphics(SalGraphics* pSalGraph)
 {
     (void)pSalGraph;
+#ifndef _WIN32
     if (m_bUseCairo)
         assert(pSalGraph == m_pOurSvpGraphics.get());
     else
+#endif
         assert(pSalGraph == m_pQt5Graphics.get());
     m_bGraphicsInUse = false;
 }
diff --git a/vcl/qt5/Qt5Graphics.cxx b/vcl/qt5/Qt5Graphics.cxx
index fbf7ae05bf6b..05c514a0a927 100644
--- a/vcl/qt5/Qt5Graphics.cxx
+++ b/vcl/qt5/Qt5Graphics.cxx
@@ -28,6 +28,8 @@
 #include <QtWidgets/QPushButton>
 #include <QtWidgets/QWidget>
 
+#include <vcl/sysdata.hxx>
+
 Qt5Graphics::Qt5Graphics( Qt5Frame *pFrame, QImage *pQImage )
     : m_pFrame( pFrame )
     , m_pQImage( pQImage )
diff --git a/vcl/qt5/Qt5Graphics_Controls.cxx b/vcl/qt5/Qt5Graphics_Controls.cxx
index d98cdafe0137..1818fb041055 100644
--- a/vcl/qt5/Qt5Graphics_Controls.cxx
+++ b/vcl/qt5/Qt5Graphics_Controls.cxx
@@ -595,9 +595,7 @@ bool Qt5Graphics_Controls::drawNativeControl(ControlType type, ControlPart part,
     }
     else if (type == ControlType::Progress && part == ControlPart::Entire)
     {
-        SAL_WNODEPRECATED_DECLARATIONS_PUSH
-        QStyleOptionProgressBarV2 option;
-        SAL_WNODEPRECATED_DECLARATIONS_POP
+        QStyleOptionProgressBar option;
         option.minimum = 0;
         option.maximum = widgetRect.width();
         option.progress = value.getNumericVal();
@@ -801,6 +799,7 @@ bool Qt5Graphics_Controls::getNativeControlRegion(ControlType type, ControlPart
                     retVal = true;
                     break;
                 default:
+                    h = 0; w = 0;
                     break;
             }
             if (retVal)
diff --git a/vcl/qt5/Qt5Graphics_Text.cxx b/vcl/qt5/Qt5Graphics_Text.cxx
index 94aa069db0c1..e39c1b8c95a3 100644
--- a/vcl/qt5/Qt5Graphics_Text.cxx
+++ b/vcl/qt5/Qt5Graphics_Text.cxx
@@ -23,8 +23,10 @@
 #include <Qt5Painter.hxx>
 
 #include <vcl/fontcharmap.hxx>
+#ifndef _WIN32
 #include <unx/geninst.h>
 #include <unx/fontmanager.hxx>
+#endif
 
 #include <sallayout.hxx>
 #include <PhysicalFontCollection.hxx>
@@ -88,7 +90,9 @@ bool Qt5Graphics::GetFontCapabilities(vcl::FontCapabilities& rFontCapabilities)
 
 void Qt5Graphics::GetDevFontList(PhysicalFontCollection* pPFC)
 {
+#ifndef _WIN32
     static const bool bUseFontconfig = (nullptr == getenv("SAL_VCL_QT5_NO_FONTCONFIG"));
+#endif
 
     m_pFontCollection = pPFC;
     if (pPFC->Count())
@@ -96,6 +100,7 @@ void Qt5Graphics::GetDevFontList(PhysicalFontCollection* pPFC)
 
     QFontDatabase aFDB;
 
+#ifndef _WIN32
     if (bUseFontconfig)
     {
         ::std::vector<psp::fontID> aList;
@@ -114,6 +119,7 @@ void Qt5Graphics::GetDevFontList(PhysicalFontCollection* pPFC)
 
         SalGenericInstance::RegisterFontSubstitutors(pPFC);
     }
+#endif
 
     for (auto& family : aFDB.families())

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list