[Libreoffice-commits] core.git: Branch 'feature/qt5-win+mac' - 13 commits - compilerplugins/clang config_host/config_vclplug.h.in configure.ac include/comphelper include/vcl include/xmloff officecfg/registry oox/source Repository.mk sc/uiconfig sd/uiconfig solenv/clang-format vcl/android 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/qt5 vcl/README vcl/source vcl/unx vcl/win xmloff/inc xmloff/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Sep 13 12:37:50 UTC 2018


Rebased ref, commits from common ancestor:
commit 98808c00387aa0714ead291cbe4a1ddb90024afe
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 13 12:36:50 2018 +0000

    Unify sal plugin loaders
    
    Change-Id: Ic099761eaff80349e985ccf62e3f4aa6b2e98022

diff --git a/include/vcl/svapp.hxx b/include/vcl/svapp.hxx
index 92a422cb7072..235110e5eba1 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 975f6790ad4f..f5564c59b7bb 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -490,7 +490,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 \
@@ -579,7 +579,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,\
@@ -641,7 +641,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
 
@@ -649,7 +649,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 ba39d98293a8..fad1bb358047 100644
--- a/vcl/inc/salinst.hxx
+++ b/vcl/inc/salinst.hxx
@@ -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 7c2fbeddb130..98f53ed01ebf 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 90%
rename from vcl/unx/generic/plugadapt/salplug.cxx
rename to vcl/source/app/salplug.cxx
index bce722b6ed6c..e3c2c3636e44 100644
--- a/vcl/unx/generic/plugadapt/salplug.cxx
+++ b/vcl/source/app/salplug.cxx
@@ -161,6 +161,7 @@ static DesktopType get_desktop_environment()
 
 #endif
 
+#if !(defined _WIN32 || defined MACOSX)
 static SalInstance* autodetect_plugin()
 {
     static const char* const pKDEFallbackList[] =
@@ -215,6 +216,7 @@ static SalInstance* autodetect_plugin()
 
     return pInst;
 }
+#endif
 
 SalInstance *CreateSalInstance()
 {
@@ -231,12 +233,23 @@ SalInstance *CreateSalInstance()
     if( !aUsePlugin.isEmpty() )
         pInst = tryInstance( aUsePlugin, true );
 
+#if !(defined _WIN32 || defined MACOSX)
     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 +276,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 +293,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 +323,19 @@ SalData::SalData() :
 
 SalData::~SalData() COVERITY_NOEXCEPT_FALSE
 {
+#if !(defined _WIN32 || 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 565f349072fb..ecc338843c65 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 e8d28ba916dd..d524e8e73c9b 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -299,7 +299,6 @@ bool InitVCL()
     {
         pOwnSvApp = new Application();
     }
-    InitSalMain();
 
     ImplSVData* pSVData = ImplGetSVData();
 
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index 33f674099ed9..c414fad4cb82 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -134,7 +134,7 @@ void SalYieldMutex::doAcquire( sal_uInt32 nLockCount )
         if ( pInst->m_nNoYieldLock )
             return;
         // tdf#96887 If this is the main thread, then we must wait for two things:
-        // - the GetYieldMutex() being freed
+        // - the SalYieldMutex being unlocked
         // - SendMessage() being triggered
         // This can nicely be done using MsgWaitForMultipleObjects. The 2nd one is
         // needed because if we don't reschedule, then we create deadlocks if a
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 65554eb8d5957d7f74f768f6859944a462cbeb8a
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 13 12:36:50 2018 +0000

    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 8e9096470985..53998517faef 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
@@ -11154,13 +11155,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"
@@ -11168,12 +11163,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
@@ -11186,49 +11194,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 717c8e15e61c..fba3dc2284ae 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 978db593a328..efdf10828b55 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>
@@ -39,7 +39,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);
@@ -61,7 +61,7 @@ class VCLPLUG_QT5_PUBLIC Qt5Frame : 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
@@ -116,7 +116,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..08790758736f 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 dce3b838e543..2f35efa2bb2c 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -44,7 +44,7 @@
 #include <vcl/layout.hxx>
 #include <vcl/syswin.hxx>
 
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
 #include <cairo.h>
 #include <headless/svpgdi.hxx>
 #endif
@@ -59,7 +59,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)
@@ -165,7 +165,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;
@@ -186,7 +186,7 @@ SalGraphics* Qt5Frame::AcquireGraphics()
 
     m_bGraphicsInUse = true;
 
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
     if (m_bUseCairo)
     {
         if (!m_pOurSvpGraphics.get())
@@ -213,7 +213,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 a99efadd2960..b12c767d3bd1 100644
--- a/vcl/qt5/Qt5Instance.cxx
+++ b/vcl/qt5/Qt5Instance.cxx
@@ -93,14 +93,15 @@ SalObject* Qt5Instance::CreateObject(SalFrame* pParent, SystemWindowData*, bool
 void Qt5Instance::DestroyObject(SalObject* pObject) { delete pObject; }
 
 std::unique_ptr<SalVirtualDevice>
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
 Qt5Instance::CreateVirtualDevice(SalGraphics* pGraphics, long& nDX, long& nDY, DeviceFormat eFormat,
 #else
-Qt5Instance::CreateVirtualDevice(SalGraphics* /* pGraphics */, long& nDX, long& nDY, DeviceFormat eFormat,
+Qt5Instance::CreateVirtualDevice(SalGraphics* /* pGraphics */, long& nDX, long& nDY,
+                                 DeviceFormat eFormat,
 #endif
                                  const SystemGraphicsData* /* pData */)
 {
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
     if (m_bUseCairo)
     {
         SvpSalGraphics* pSvpSalGraphics = dynamic_cast<SvpSalGraphics*>(pGraphics);
@@ -137,7 +138,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
@@ -273,7 +274,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)
     {
@@ -286,7 +287,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 24fcabe03470..fb4a754eba60 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;
@@ -60,7 +60,7 @@ static OUString getPdfDir(const PrinterInfo& rInfo)
 }
 #endif
 
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
 SalInfoPrinter* Qt5Instance::CreateInfoPrinter(SalPrinterQueueInfo* pQueueInfo,
                                                ImplJobSetup* pJobSetup)
 {
@@ -80,7 +80,7 @@ SalInfoPrinter* Qt5Instance::CreateInfoPrinter(SalPrinterQueueInfo* /* pQueueInf
 
 void Qt5Instance::DestroyInfoPrinter(SalInfoPrinter* pPrinter) { delete pPrinter; }
 
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
 std::unique_ptr<SalPrinter> Qt5Instance::CreatePrinter(SalInfoPrinter* pInfoPrinter)
 {
     // create and initialize SalPrinter
@@ -96,7 +96,7 @@ std::unique_ptr<SalPrinter> Qt5Instance::CreatePrinter(SalInfoPrinter* /* pInfoP
 }
 #endif
 
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
 void Qt5Instance::GetPrinterQueueInfo(ImplPrnQueueList* pList)
 {
     PrinterInfoManager& rManager(PrinterInfoManager::get());
@@ -143,7 +143,7 @@ void Qt5Instance::GetPrinterQueueState(SalPrinterQueueInfo*) {}
 
 OUString Qt5Instance::GetDefaultPrinter()
 {
-#ifndef _WIN32
+#if !(defined MACOSX || defined _WIN32)
     PrinterInfoManager& rManager(PrinterInfoManager::get());
     return rManager.getDefaultPrinter();
 #else
@@ -151,7 +151,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 5b9e0d1de56ad9f7136943ea0723aec6f5ab5af8
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 13 12:36:50 2018 +0000

    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..ef26ea68e1bf 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();
+    SAL_DLLPUBLIC  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 2011d0191105..975f6790ad4f 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -443,8 +443,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 +453,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)), \
@@ -729,6 +633,18 @@ endif
 
 # OS-specific stuff
 
+# for harfbuzz
+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,\
     vcl/opengl/win/WinDeviceInfo \
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 6d43589321e2..ba39d98293a8 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 9fd13d7f52f0..7c2fbeddb130 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>
 
@@ -77,9 +78,7 @@ extern "C" {
 using namespace std;
 using namespace ::com::sun::star;
 
-static int* gpnInit = nullptr;
 static NSMenu* pDockMenu = nil;
-static bool bNoSVMain = true;
 static bool bLeftMain = false;
 
 class AquaDelayedSettingsChanged : public Idle
@@ -193,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 )
 {
@@ -309,7 +296,8 @@ void ImplSalYieldMutexRelease()
         pInst->GetYieldMutex()->release();
 }
 
-SalInstance* CreateSalInstance()
+extern "C" {
+VCLPLUG_OSX_PUBLIC SalInstance* create_SalInstance()
 {
     SalData* pSalData = new SalData;
 
@@ -347,10 +335,6 @@ SalInstance* CreateSalInstance()
 
     return pInst;
 }
-
-void DestroySalInstance( SalInstance* pInst )
-{
-    delete pInst;
 }
 
 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: */
commit ccb35c4304555b922b49a50008f4e026e778d813
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 13 12:36:50 2018 +0000

    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 d01e89a02a2f..8e9096470985 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"
@@ -4667,7 +4668,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
@@ -10007,10 +10007,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=""
@@ -10021,7 +10027,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)
@@ -11156,7 +11162,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] )
@@ -11178,6 +11188,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"
@@ -11207,7 +11221,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 0eb796330e38..978db593a328 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>
 
 class Qt5Graphics;
@@ -37,6 +39,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 SalFrame
 {
     friend class Qt5Widget;
@@ -47,12 +61,14 @@ class VCLPLUG_QT5_PUBLIC Qt5Frame : 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;
@@ -100,7 +116,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..c3c719db352b 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;
@@ -38,7 +42,7 @@ class Qt5FontFace;
 class Qt5Frame;
 class Qt5Painter;
 
-class Qt5Graphics : public SalGraphics
+class SAL_DLLPRIVATE Qt5Graphics : public SalGraphics
 {
     friend class Qt5Bitmap;
     friend class Qt5Painter;
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 3365ed4af3b8..dce3b838e543 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -44,8 +44,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)
@@ -54,10 +56,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)
@@ -161,6 +165,7 @@ void Qt5Frame::TriggerPaintEvent(QRect aRect)
     CallCallback(SalEvent::Paint, &aPaintEvt);
 }
 
+#ifndef _WIN32
 void Qt5Frame::InitSvpSalGraphics(SvpSalGraphics* pSvpSalGraphics)
 {
     int width = 640;
@@ -172,6 +177,7 @@ void Qt5Frame::InitSvpSalGraphics(SvpSalGraphics* pSvpSalGraphics)
                                 nullptr);
     TriggerPaintEvent();
 }
+#endif
 
 SalGraphics* Qt5Frame::AcquireGraphics()
 {
@@ -180,6 +186,7 @@ SalGraphics* Qt5Frame::AcquireGraphics()
 
     m_bGraphicsInUse = true;
 
+#ifndef _WIN32
     if (m_bUseCairo)
     {
         if (!m_pOurSvpGraphics.get())
@@ -190,6 +197,7 @@ SalGraphics* Qt5Frame::AcquireGraphics()
         return m_pOurSvpGraphics.get();
     }
     else
+#endif
     {
         if (!m_pQt5Graphics.get())
         {
@@ -205,9 +213,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 18be768c04c0..b8c6c8c922eb 100644
--- a/vcl/qt5/Qt5Graphics_Controls.cxx
+++ b/vcl/qt5/Qt5Graphics_Controls.cxx
@@ -594,9 +594,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();
@@ -800,6 +798,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())
         for (auto& style : aFDB.styles(family))
diff --git a/vcl/qt5/Qt5Instance.cxx b/vcl/qt5/Qt5Instance.cxx
index f2811e46db5a..a99efadd2960 100644
--- a/vcl/qt5/Qt5Instance.cxx
+++ b/vcl/qt5/Qt5Instance.cxx
@@ -44,7 +44,7 @@
 #include <headless/svpbmp.hxx>
 
 Qt5Instance::Qt5Instance(bool bUseCairo)
-    : SalGenericInstance(o3tl::make_unique<SalYieldMutex>())
+    : Qt5MocInstance()
     , m_postUserEventId(-1)
     , m_bUseCairo(bUseCairo)
 {
@@ -93,9 +93,14 @@ SalObject* Qt5Instance::CreateObject(SalFrame* pParent, SystemWindowData*, bool
 void Qt5Instance::DestroyObject(SalObject* pObject) { delete pObject; }
 
 std::unique_ptr<SalVirtualDevice>
+#ifndef _WIN32
 Qt5Instance::CreateVirtualDevice(SalGraphics* pGraphics, long& nDX, long& nDY, DeviceFormat eFormat,
+#else
+Qt5Instance::CreateVirtualDevice(SalGraphics* /* pGraphics */, long& nDX, long& nDY, DeviceFormat eFormat,
+#endif
                                  const SystemGraphicsData* /* pData */)
 {
+#ifndef _WIN32
     if (m_bUseCairo)
     {
         SvpSalGraphics* pSvpSalGraphics = dynamic_cast<SvpSalGraphics*>(pGraphics);
@@ -106,6 +111,7 @@ Qt5Instance::CreateVirtualDevice(SalGraphics* pGraphics, long& nDX, long& nDY, D
         return pVD;
     }
     else
+#endif
     {
         std::unique_ptr<SalVirtualDevice> pVD(new Qt5VirtualDevice(eFormat, 1));
         pVD->SetSize(nDX, nDY);
@@ -131,9 +137,11 @@ SalSystem* Qt5Instance::CreateSalSystem() { return new Qt5System; }
 
 std::shared_ptr<SalBitmap> Qt5Instance::CreateSalBitmap()
 {
+#ifndef _WIN32
     if (m_bUseCairo)
         return std::make_shared<SvpSalBitmap>();
     else
+#endif
         return std::make_shared<Qt5Bitmap>();
 }
 
@@ -265,23 +273,27 @@ VCLPLUG_QT5_PUBLIC SalInstance* create_SalInstance()
     for (int i = 0; i < nFakeArgc; i++)
         pFakeArgv[i] = pFakeArgvFreeable[i];
 
+#ifndef _WIN32
     char* session_manager = nullptr;
     if (getenv("SESSION_MANAGER") != nullptr)
     {
         session_manager = strdup(getenv("SESSION_MANAGER"));
         unsetenv("SESSION_MANAGER");
     }
+#endif
 
     int* pFakeArgc = new int;
     *pFakeArgc = nFakeArgc;
     pQApplication = new QApplication(*pFakeArgc, pFakeArgv);
 
+#ifndef _WIN32
     if (session_manager != nullptr)
     {
         // coverity[tainted_string] - trusted source for setenv
         setenv("SESSION_MANAGER", session_manager, 1);
         free(session_manager);
     }
+#endif
 
     QApplication::setQuitOnLastWindowClosed(false);
 
diff --git a/vcl/qt5/Qt5Instance_Print.cxx b/vcl/qt5/Qt5Instance_Print.cxx
index dd095f533c1a..24fcabe03470 100644
--- a/vcl/qt5/Qt5Instance_Print.cxx
+++ b/vcl/qt5/Qt5Instance_Print.cxx
@@ -20,23 +20,26 @@
 #include <Qt5Instance.hxx>
 #include <Qt5Printer.hxx>
 
+#ifndef _WIN32
 #include <vcl/svapp.hxx>
 #include <vcl/timer.hxx>
-#include <printerinfomanager.hxx>
 
 #include <jobset.h>
 #include <print.h>
-#include <salptype.hxx>
 #include <saldatabasic.hxx>
 
+#include <salptype.hxx>
+#include <printerinfomanager.hxx>
 #include <unx/genpspgraphics.h>
 
 using namespace psp;
+#endif
 
 /*
  *  static helpers
  */
 
+#ifndef _WIN32
 static OUString getPdfDir(const PrinterInfo& rInfo)
 {
     OUString aDir;
@@ -55,7 +58,9 @@ static OUString getPdfDir(const PrinterInfo& rInfo)
     }
     return aDir;
 }
+#endif
 
+#ifndef _WIN32
 SalInfoPrinter* Qt5Instance::CreateInfoPrinter(SalPrinterQueueInfo* pQueueInfo,
                                                ImplJobSetup* pJobSetup)
 {
@@ -65,9 +70,17 @@ SalInfoPrinter* Qt5Instance::CreateInfoPrinter(SalPrinterQueueInfo* pQueueInfo,
 
     return pPrinter;
 }
+#else
+SalInfoPrinter* Qt5Instance::CreateInfoPrinter(SalPrinterQueueInfo* /* pQueueInfo */,
+                                               ImplJobSetup* /* pJobSetup */)
+{
+    return nullptr;
+}
+#endif
 
 void Qt5Instance::DestroyInfoPrinter(SalInfoPrinter* pPrinter) { delete pPrinter; }
 
+#ifndef _WIN32
 std::unique_ptr<SalPrinter> Qt5Instance::CreatePrinter(SalInfoPrinter* pInfoPrinter)
 {
     // create and initialize SalPrinter
@@ -76,7 +89,14 @@ std::unique_ptr<SalPrinter> Qt5Instance::CreatePrinter(SalInfoPrinter* pInfoPrin
 
     return std::unique_ptr<SalPrinter>(pPrinter);
 }
+#else
+std::unique_ptr<SalPrinter> Qt5Instance::CreatePrinter(SalInfoPrinter* /* pInfoPrinter */)
+{
+    return std::unique_ptr<SalPrinter>();
+}
+#endif
 
+#ifndef _WIN32
 void Qt5Instance::GetPrinterQueueInfo(ImplPrnQueueList* pList)
 {
     PrinterInfoManager& rManager(PrinterInfoManager::get());
@@ -113,6 +133,9 @@ void Qt5Instance::GetPrinterQueueInfo(ImplPrnQueueList* pList)
         pList->Add(pInfo);
     }
 }
+#else
+void Qt5Instance::GetPrinterQueueInfo(ImplPrnQueueList* /* pList */) {}
+#endif
 
 void Qt5Instance::DeletePrinterQueueInfo(SalPrinterQueueInfo* pInfo) { delete pInfo; }
 
@@ -120,12 +143,18 @@ void Qt5Instance::GetPrinterQueueState(SalPrinterQueueInfo*) {}
 
 OUString Qt5Instance::GetDefaultPrinter()
 {
+#ifndef _WIN32
     PrinterInfoManager& rManager(PrinterInfoManager::get());
     return rManager.getDefaultPrinter();
+#else
+    return OUString();
+#endif
 }
 
-void Qt5Instance::PostPrintersChanged() {}
+#ifndef _WIN32
+void Qt5MocInstance::PostPrintersChanged() {}
 
-GenPspGraphics* Qt5Instance::CreatePrintGraphics() { return new GenPspGraphics(); }
+GenPspGraphics* Qt5MocInstance::CreatePrintGraphics() { return new GenPspGraphics(); }
+#endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Painter.cxx b/vcl/qt5/Qt5Painter.cxx
index 06eeb2895214..efaf04e9b570 100644
--- a/vcl/qt5/Qt5Painter.cxx
+++ b/vcl/qt5/Qt5Painter.cxx
@@ -20,6 +20,7 @@
 #include <Qt5Painter.hxx>
 
 #include <QtGui/QColor>
+#include <QtWidgets/QPushButton>
 
 Qt5Painter::Qt5Painter(Qt5Graphics& rGraphics, bool bPrepareBrush, sal_uInt8 nTransparency)
     : m_rGraphics(rGraphics)
diff --git a/vcl/qt5/Qt5Printer.cxx b/vcl/qt5/Qt5Printer.cxx
index 16a6a1115073..2f30b3b53720 100644
--- a/vcl/qt5/Qt5Printer.cxx
+++ b/vcl/qt5/Qt5Printer.cxx
@@ -17,10 +17,18 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <svsys.h>
+#include <salptype.hxx>
+
+#include <tools/gen.hxx>
 #include <Qt5Printer.hxx>
 
-Qt5Printer::Qt5Printer(SalInfoPrinter* pInfoPrinter)
+Qt5Printer::Qt5Printer(SalInfoPrinter* /* pInfoPrinter */)
+#ifndef _WIN32
     : PspSalPrinter(pInfoPrinter)
+#else
+    : WinSalPrinter()
+#endif
 {
 }
 
diff --git a/vcl/qt5/Qt5Tools.cxx b/vcl/qt5/Qt5Tools.cxx
index 54ac3f99e26f..b12a03539bbb 100644
--- a/vcl/qt5/Qt5Tools.cxx
+++ b/vcl/qt5/Qt5Tools.cxx
@@ -19,11 +19,13 @@
 
 #include <Qt5Tools.hxx>
 
-#include <cairo.h>
-
 #include <vcl/event.hxx>
 
+#ifndef _WIN32
+#include <cairo.h>
+
 void CairoDeleter::operator()(cairo_surface_t* pSurface) const { cairo_surface_destroy(pSurface); }
+#endif
 
 sal_uInt16 GetKeyModCode(Qt::KeyboardModifiers eKeyModifiers)
 {
diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx
index 00ab29744a67..0c487b39d58c 100644
--- a/vcl/qt5/Qt5Widget.cxx
+++ b/vcl/qt5/Qt5Widget.cxx
@@ -35,8 +35,10 @@
 #include <QtWidgets/QtWidgets>
 #include <QtWidgets/QMainWindow>
 
+#ifndef _WIN32
 #include <cairo.h>
 #include <headless/svpgdi.hxx>
+#endif
 
 void Qt5Widget::paintEvent(QPaintEvent* pEvent)
 {
@@ -44,6 +46,7 @@ void Qt5Widget::paintEvent(QPaintEvent* pEvent)
     if (!m_pFrame->m_bNullRegion)
         p.setClipRegion(m_pFrame->m_aRegion);
 
+#ifndef _WIN32
     if (m_pFrame->m_bUseCairo)
     {
         cairo_surface_t* pSurface = m_pFrame->m_pSurface.get();
@@ -54,11 +57,13 @@ void Qt5Widget::paintEvent(QPaintEvent* pEvent)
         p.drawImage(pEvent->rect().topLeft(), aImage, pEvent->rect());
     }
     else
+#endif
         p.drawImage(pEvent->rect().topLeft(), *m_pFrame->m_pQImage, pEvent->rect());
 }
 
 void Qt5Widget::resizeEvent(QResizeEvent* /*event*/)
 {
+#ifndef _WIN32
     if (m_pFrame->m_bUseCairo)
     {
         int width = size().width();
@@ -75,6 +80,7 @@ void Qt5Widget::resizeEvent(QResizeEvent* /*event*/)
         }
     }
     else
+#endif
     {
         QImage* pImage = new QImage(size(), Qt5_DefaultFormat32);
         m_pFrame->m_pQt5Graphics->ChangeQImage(pImage);
@@ -236,9 +242,11 @@ static sal_uInt16 GetKeyCode(int keyval)
             case Qt::Key_Insert:
                 nCode = KEY_INSERT;
                 break;
+#if 0
             case Qt::Key_Delete:
                 nCode = KEY_DELETE;
                 break;
+#endif
             case Qt::Key_Plus:
                 nCode = KEY_ADD;
                 break;
commit 914372ab6f588fbe586b50f4cd4e58282efd1bf6
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Wed Sep 12 10:26:52 2018 +0200
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Thu Sep 13 12:36:50 2018 +0000

    Implement Windows VCL backend as plugin
    
    Change-Id: If9c7c67f48311ac68ecc9f8e3a07f9bb7c73d962

diff --git a/Repository.mk b/Repository.mk
index b2c8c8c0d857..34ac4e5c6ae0 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -398,6 +398,8 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,ooo, \
 	$(if $(MERGELIBS),merged) \
 	migrationoo2 \

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list