[Libreoffice-commits] core.git: Branch 'feature/qt5-win' - include/vcl Repository.mk vcl/inc vcl/Library_vcl.mk vcl/Library_vclplug_osx.mk vcl/Module_vcl.mk vcl/osx vcl/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Sep 12 18:04:39 UTC 2018


 Repository.mk                 |    1 
 include/vcl/ImageTree.hxx     |    2 
 include/vcl/svmain.hxx        |    2 
 include/vcl/window.hxx        |    2 
 vcl/Library_vcl.mk            |  113 +++---------------------
 vcl/Library_vclplug_osx.mk    |  195 ++++++++++++++++++++++++++++++++++++++++++
 vcl/Module_vcl.mk             |    1 
 vcl/inc/bmpfast.hxx           |    4 
 vcl/inc/osx/salinst.h         |    5 -
 vcl/inc/salinst.hxx           |    4 
 vcl/inc/vclpluginapi.h        |    6 +
 vcl/osx/saldata.cxx           |    8 +
 vcl/osx/salinst.cxx           |  137 +++++++----------------------
 vcl/osx/salmenu.cxx           |  190 +++++++++++++++++++---------------------
 vcl/osx/salplug.cxx           |  167 +++++++++++++++++++++++++++++++++++
 vcl/osx/vclnsapp.mm           |   16 ---
 vcl/source/app/svmain.cxx     |   10 --
 vcl/source/app/svmainhook.cxx |   34 -------
 18 files changed, 528 insertions(+), 369 deletions(-)

New commits:
commit 55a5917777004d84bf4a5c5814c9e5ff7dd73f3c
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Wed Sep 12 19:56:39 2018 +0200
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Wed Sep 12 18:03:52 2018 +0000

    Make osx a vclplug
    
    Also removes this nested NSApplicationMain calling.
    Now builds our own app menu.
    Still needs passing of debug options to cocoa.
    
    Change-Id: I4179ec6e03b5e3d7ba9dd4cee38aa51cb452d20f

diff --git a/Repository.mk b/Repository.mk
index bf5af2f647c2..fff511dc8fed 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -485,6 +485,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/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index a2e66ebba63b..1c7fc607f5a1 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -373,7 +373,6 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
     vcl/source/app/svapp \
     vcl/source/app/svdata \
     vcl/source/app/svmain \
-    vcl/source/app/svmainhook \
     vcl/source/app/timer \
     vcl/source/app/unohelp2 \
     vcl/source/app/unohelp \
@@ -444,7 +443,11 @@ $(eval $(call gb_Library_add_cobjects,vcl,\
     vcl/source/filter/jpeg/transupp \
 ))
 
-# optional parts
+ifneq ($(ENABLE_MACOSX_SANDBOX),TRUE)
+$(eval $(call gb_Library_use_libraries,vcl,\
+    AppleRemote \
+))
+endif
 
 vcl_quartz_code= \
     vcl/quartz/salbmp \
@@ -456,100 +459,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)), \
@@ -730,6 +639,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/osx/salinst.h b/vcl/inc/osx/salinst.h
index 8e15730a3843..9164cdab3de0 100644
--- a/vcl/inc/osx/salinst.h
+++ b/vcl/inc/osx/salinst.h
@@ -76,7 +76,7 @@ class AquaSalInstance : public SalInstance, public SalUserEventList
 public:
     virtual void TriggerUserEventProcessing() override;
 
-    SalYieldMutex*                          mpSalYieldMutex;        // Sal-Yield-Mutex
+    std::unique_ptr<SalYieldMutex>          mpSalYieldMutex;
     OUString                                maDefaultPrinter;
     oslThreadIdentifier                     maMainThread;
     int                                     mnActivePrintJobs;
@@ -91,6 +91,8 @@ public:
     AquaSalInstance();
     virtual ~AquaSalInstance() override;
 
+    virtual void AfterAppInit() override;
+
     virtual SalFrame*       CreateChildFrame( SystemParentData* pParent, SalFrameStyleFlags nStyle ) override;
     virtual SalFrame*       CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle ) override;
     virtual void            DestroyFrame( SalFrame* pFrame ) override;
@@ -148,7 +150,6 @@ public:
     void endedPrintJob() { mnActivePrintJobs--; }
 
     // event subtypes for NSApplicationDefined events
-    static const short AppExecuteSVMain   = 0x7fff;
     static const short AppEndLoopEvent    = 1;
     static const short AppStartTimerEvent = 10;
     static const short YieldWakeupEvent   = 20;
diff --git a/vcl/inc/salinst.hxx b/vcl/inc/salinst.hxx
index 38fdccf54620..7b93edd5c76c 100644
--- a/vcl/inc/salinst.hxx
+++ b/vcl/inc/salinst.hxx
@@ -215,10 +215,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/saldata.cxx b/vcl/osx/saldata.cxx
index 3357adbcd60a..033114dae7e1 100644
--- a/vcl/osx/saldata.cxx
+++ b/vcl/osx/saldata.cxx
@@ -54,6 +54,7 @@ SalData::SalData()
     mnDPIX( 0 ),
     mnDPIY( 0 )
 {
+    SetSalData(this);
     maCursors.fill( INVALID_CURSOR_PTR );
     if( s_aAutoReleaseKey == nullptr )
         s_aAutoReleaseKey = osl_createThreadKey( releasePool );
@@ -85,6 +86,13 @@ SalData::~SalData()
     if ( mpAppleRemoteMainController )
         [mpAppleRemoteMainController release];
 #endif
+
+    if( mpStatusItem )
+    {
+        [mpStatusItem release];
+        mpStatusItem = nil;
+    }
+    SetSalData( nullptr );
 }
 
 void SalData::ensureThreadAutoreleasePool()
diff --git a/vcl/osx/salinst.cxx b/vcl/osx/salinst.cxx
index 17f7d89adb07..08359f04f7db 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
@@ -143,23 +142,7 @@ bool AquaSalInstance::isOnCommandLine( const OUString& rArg )
     return false;
 }
 
-// initialize the cocoa VCL_NSApplication object
-// returns an NSAutoreleasePool that must be released when the event loop begins
-static void initNSApp()
-{
-    // create our cocoa NSApplication
-    [VCL_NSApplication sharedApplication];
-
-    SalData::ensureThreadAutoreleasePool();
-
-    // put cocoa into multithreaded mode
-    [NSThread detachNewThreadSelector:@selector(enableCocoaThreads:) toTarget:[[CocoaThreadEnabler alloc] init] withObject:nil];
-
-    // activate our delegate methods
-    [NSApp setDelegate: NSApp];
-}
-
-void postInitVCLinitNSApp()
+void AquaSalInstance::AfterAppInit()
 {
     [[NSNotificationCenter defaultCenter] addObserver: NSApp
                                           selector: @selector(systemColorsChanged:)
@@ -196,38 +179,6 @@ void postInitVCLinitNSApp()
 #endif
 }
 
-bool ImplSVMainHook( int * pnInit )
-{
-    if (comphelper::LibreOfficeKit::isActive())
-        return false;
-
-    NSAutoreleasePool * pool = [ [ NSAutoreleasePool alloc ] init ];
-    unlink([[NSString stringWithFormat:@"%@/Library/Saved Application State/%s.savedState/restorecount.plist", NSHomeDirectory(), MACOSX_BUNDLE_IDENTIFIER] UTF8String]);
-    unlink([[NSString stringWithFormat:@"%@/Library/Saved Application State/%s.savedState/restorecount.txt", NSHomeDirectory(), MACOSX_BUNDLE_IDENTIFIER] UTF8String]);
-    [ pool drain ];
-
-    gpnInit = pnInit;
-
-    bNoSVMain = false;
-    initNSApp();
-
-    OUString aExeURL, aExe;
-    osl_getExecutableFile( &aExeURL.pData );
-    osl_getSystemPathFromFileURL( aExeURL.pData, &aExe.pData );
-    OString aByteExe( OUStringToOString( aExe, osl_getThreadTextEncoding() ) );
-
-#ifdef DEBUG
-    aByteExe += OString ( " NSAccessibilityDebugLogLevel 1" );
-    const char* pArgv[] = { aByteExe.getStr(), NULL };
-    NSApplicationMain( 3, pArgv );
-#else
-    const char* pArgv[] = { aByteExe.getStr(), nullptr };
-    NSApplicationMain( 1, pArgv );
-#endif
-
-    return TRUE;   // indicate that ImplSVMainHook is implemented
-}
-
 void SalAbort( const OUString& rErrorText, bool bDumpCore )
 {
     if( rErrorText.isEmpty() )
@@ -241,34 +192,12 @@ void SalAbort( const OUString& rErrorText, bool bDumpCore )
         _exit(1);
 }
 
-void InitSalData()
-{
-    SalData *pSalData = new SalData;
-    SetSalData( pSalData );
-}
-
 const OUString& SalGetDesktopEnvironment()
 {
     static OUString aDesktopEnvironment( "MacOSX" );
     return aDesktopEnvironment;
 }
 
-void DeInitSalData()
-{
-    SalData *pSalData = GetSalData();
-    if( pSalData->mpStatusItem )
-    {
-        [pSalData->mpStatusItem release];
-        pSalData->mpStatusItem = nil;
-    }
-    delete pSalData;
-    SetSalData( nullptr );
-}
-
-void InitSalMain()
-{
-}
-
 SalYieldMutex::SalYieldMutex()
     : m_aCodeBlock( nullptr )
 {
@@ -367,14 +296,27 @@ void ImplSalYieldMutexRelease()
         pInst->mpSalYieldMutex->release();
 }
 
-SalInstance* CreateSalInstance()
+extern "C" {
+VCLPLUG_OSX_PUBLIC SalInstance* create_SalInstance()
 {
-    // this is the case for not using SVMain
-    // not so good
-    if( bNoSVMain )
-        initNSApp();
+    SalData* pSalData = new SalData;
+
+    NSAutoreleasePool * pool = [ [ NSAutoreleasePool alloc ] init ];
+    unlink([[NSString stringWithFormat:@"%@/Library/Saved Application State/%s.savedState/restorecount.plist", NSHomeDirectory(), MACOSX_BUNDLE_IDENTIFIER] UTF8String]);
+    unlink([[NSString stringWithFormat:@"%@/Library/Saved Application State/%s.savedState/restorecount.txt", NSHomeDirectory(), MACOSX_BUNDLE_IDENTIFIER] UTF8String]);
+    [ pool drain ];
+
+    // create our cocoa NSApplication
+    [VCL_NSApplication sharedApplication];
+
+    SalData::ensureThreadAutoreleasePool();
+
+    // put cocoa into multithreaded mode
+    [NSThread detachNewThreadSelector:@selector(enableCocoaThreads:) toTarget:[[CocoaThreadEnabler alloc] init] withObject:nil];
+
+    // activate our delegate methods
+    [NSApp setDelegate: NSApp];
 
-    SalData* pSalData = GetSalData();
     SAL_WARN_IF( pSalData->mpInstance != nullptr, "vcl", "more than one instance created" );
     AquaSalInstance* pInst = new AquaSalInstance;
 
@@ -389,29 +331,32 @@ SalInstance* CreateSalInstance()
     ImplGetSVData()->maNWFData.mbProgressNeedsErase = true;
     ImplGetSVData()->maNWFData.mnStatusBarLowerRightOffset = 10;
 
+    [NSApp finishLaunching];
+
     return pInst;
 }
-
-void DestroySalInstance( SalInstance* pInst )
-{
-    delete pInst;
 }
 
 AquaSalInstance::AquaSalInstance()
-    : mnActivePrintJobs( 0 )
+    : mpSalYieldMutex(o3tl::make_unique<SalYieldMutex>())
+    , mnActivePrintJobs( 0 )
     , mbIsLiveResize( false )
     , mbNoYieldLock( false )
     , mbTimerProcessed( false )
 {
-    mpSalYieldMutex = new SalYieldMutex;
     mpSalYieldMutex->acquire();
     maMainThread = osl::Thread::getCurrentIdentifier();
 }
 
 AquaSalInstance::~AquaSalInstance()
 {
-    mpSalYieldMutex->release();
-    delete mpSalYieldMutex;
+    [NSApp stop: NSApp];
+    bLeftMain = true;
+    if( pDockMenu )
+    {
+        [pDockMenu release];
+        pDockMenu = nil;
+    }
 }
 
 void AquaSalInstance::TriggerUserEventProcessing()
@@ -429,7 +374,7 @@ void AquaSalInstance::ProcessEvent( SalUserEvent aEvent )
 
 comphelper::SolarMutex* AquaSalInstance::GetYieldMutex()
 {
-    return mpSalYieldMutex;
+    return mpSalYieldMutex.get();
 }
 
 sal_uInt32 AquaSalInstance::ReleaseYieldMutexAll()
@@ -460,20 +405,6 @@ void AquaSalInstance::handleAppDefinedEvent( NSEvent* pEvent )
     case AppEndLoopEvent:
         [NSApp stop: NSApp];
         break;
-    case AppExecuteSVMain:
-    {
-        int nResult = ImplSVMain();
-        if( gpnInit )
-            *gpnInit = nResult;
-        [NSApp stop: NSApp];
-        bLeftMain = true;
-        if( pDockMenu )
-        {
-            [pDockMenu release];
-            pDockMenu = nil;
-        }
-        break;
-    }
     case DispatchTimerEvent:
     {
         AquaSalInstance *pInst = GetSalData()->mpInstance;
diff --git a/vcl/osx/salmenu.cxx b/vcl/osx/salmenu.cxx
index ee0e99278892..4ec9e7d70871 100644
--- a/vcl/osx/salmenu.cxx
+++ b/vcl/osx/salmenu.cxx
@@ -112,111 +112,99 @@ static MainMenuSelector* pMainMenuSelector = nil;
 
 static void initAppMenu()
 {
-    static bool bOnce = true;
-    if( bOnce )
-    {
-        bOnce = false;
+    static bool bInitialized = false;
+    if (bInitialized)
+        return;
 
-        // get the main menu
-        NSMenu* pMainMenu = [NSApp mainMenu];
-        if( pMainMenu != nil )
-        {
-            // create the action selector
-            pMainMenuSelector = [[MainMenuSelector alloc] init];
+    // get the main menu
+    NSMenu* pMainMenu = [NSApp mainMenu];
+    assert(pMainMenu == nil);
+    if (pMainMenu != nil)
+        return;
 
-            // get the proper submenu
-            NSMenu* pAppMenu = [[pMainMenu itemAtIndex: 0] submenu];
-            if( pAppMenu )
-            {
-                // insert about entry
-                OUString aAbout(VclResId(SV_STDTEXT_ABOUT));
-                NSString* pString = CreateNSString( aAbout );
-                NSMenuItem* pNewItem = [pAppMenu insertItemWithTitle: pString
-                                                 action: @selector(showAbout:)
-                                                 keyEquivalent: @""
-                                                 atIndex: 0];
-                if (pString)
-                    [pString release];
-                if( pNewItem )
-                {
-                    [pNewItem setTarget: pMainMenuSelector];
-                    [pAppMenu insertItem: [NSMenuItem separatorItem] atIndex: 1];
-                }
-
-                // insert preferences entry
-                OUString aPref(VclResId(SV_STDTEXT_PREFERENCES));
-                pString = CreateNSString( aPref );
-                pNewItem = [pAppMenu insertItemWithTitle: pString
-                                     action: @selector(showPreferences:)
-                                     keyEquivalent: @","
-                                     atIndex: 2];
-                if (pString)
-                    [pString release];
-                if( pNewItem )
-                {
+    bInitialized = true;
+
+    NSMenu* pAppMenu = nil;
+    NSMenuItem* pNewItem = nil;
+
+    pMainMenu = [[[NSMenu alloc] initWithTitle: @"Main Menu"] autorelease];
+    pNewItem = [pMainMenu addItemWithTitle: @"Application"
+        action: nil
+        keyEquivalent: @""];
+    pAppMenu = [[[NSMenu alloc] initWithTitle: @"Application"] autorelease];
+    [pNewItem setSubmenu: pAppMenu];
+    [NSApp setMainMenu: pMainMenu];
+
+    pMainMenuSelector = [[MainMenuSelector alloc] init];
+
+    // about
+    NSString* pString = CreateNSString(VclResId(SV_STDTEXT_ABOUT));
+    pNewItem = [pAppMenu addItemWithTitle: pString
+        action: @selector(showAbout:)
+        keyEquivalent: @""];
+    [pString release];
+    [pNewItem setTarget: pMainMenuSelector];
+
+    [pAppMenu addItem:[NSMenuItem separatorItem]];
+
+    // preferences
+    pString = CreateNSString(VclResId(SV_STDTEXT_PREFERENCES));
+    pNewItem = [pAppMenu addItemWithTitle: pString
+        action: @selector(showPreferences:)
+        keyEquivalent: @","];
+    [pString release];
 SAL_WNODEPRECATED_DECLARATIONS_PUSH
-// 'NSCommandKeyMask' is deprecated: first deprecated in macOS 10.12
-                    [pNewItem setKeyEquivalentModifierMask: NSCommandKeyMask];
+    // 'NSCommandKeyMask' is deprecated: first deprecated in macOS 10.12
+    [pNewItem setKeyEquivalentModifierMask: NSCommandKeyMask];
 SAL_WNODEPRECATED_DECLARATIONS_POP
-                    [pNewItem setTarget: pMainMenuSelector];
-                    [pAppMenu insertItem: [NSMenuItem separatorItem] atIndex: 3];
-                }
-
-                // WARNING: ultra ugly code ahead
-
-                // rename standard entries
-                // rename "Services"
-                pNewItem = [pAppMenu itemAtIndex: 4];
-                if( pNewItem )
-                {
-                    pString = CreateNSString(VclResId(SV_MENU_MAC_SERVICES));
-                    [pNewItem  setTitle: pString];
-                    if( pString )
-                        [pString release];
-                }
-
-                // rename "Hide NewApplication"
-                pNewItem = [pAppMenu itemAtIndex: 6];
-                if( pNewItem )
-                {
-                    pString = CreateNSString(VclResId(SV_MENU_MAC_HIDEAPP));
-                    [pNewItem  setTitle: pString];
-                    if( pString )
-                        [pString release];
-                }
-
-                // rename "Hide Others"
-                pNewItem = [pAppMenu itemAtIndex: 7];
-                if( pNewItem )
-                {
-                    pString = CreateNSString(VclResId(SV_MENU_MAC_HIDEALL));
-                    [pNewItem  setTitle: pString];
-                    if( pString )
-                        [pString release];
-                }
-
-                // rename "Show all"
-                pNewItem = [pAppMenu itemAtIndex: 8];
-                if( pNewItem )
-                {
-                    pString = CreateNSString(VclResId(SV_MENU_MAC_SHOWALL));
-                    [pNewItem  setTitle: pString];
-                    if( pString )
-                        [pString release];
-                }
-
-                // rename "Quit NewApplication"
-                pNewItem = [pAppMenu itemAtIndex: 10];
-                if( pNewItem )
-                {
-                    pString = CreateNSString(VclResId(SV_MENU_MAC_QUITAPP));
-                    [pNewItem  setTitle: pString];
-                    if( pString )
-                        [pString release];
-                }
-            }
-        }
-    }
+    [pNewItem setTarget: pMainMenuSelector];
+
+    [pAppMenu addItem:[NSMenuItem separatorItem]];
+
+    // Services item and menu
+    pString = CreateNSString(VclResId(SV_MENU_MAC_SERVICES));
+    pNewItem = [pAppMenu addItemWithTitle: pString
+        action: nil
+        keyEquivalent: @""];
+    NSMenu *servicesMenu = [[[NSMenu alloc] initWithTitle:@"Services"] autorelease];
+    [pNewItem setSubmenu: servicesMenu];
+    [NSApp setServicesMenu: servicesMenu];
+
+    [pAppMenu addItem:[NSMenuItem separatorItem]];
+
+    // Hide Application
+    pString = CreateNSString(VclResId(SV_MENU_MAC_HIDEAPP));
+    [pAppMenu addItemWithTitle: pString
+        action:@selector(hide:)
+        keyEquivalent:@"h"];
+    [pString release];
+
+    // Hide Others
+    pString = CreateNSString(VclResId(SV_MENU_MAC_HIDEALL));
+    [pAppMenu addItemWithTitle: pString
+        action:@selector(hideOtherApplications:)
+        keyEquivalent:@"h"];
+    [pString release];
+SAL_WNODEPRECATED_DECLARATIONS_PUSH
+    // 'NSCommandKeyMask' is deprecated: first deprecated in macOS 10.12
+    [pNewItem setKeyEquivalentModifierMask: NSCommandKeyMask | NSAlternateKeyMask];
+SAL_WNODEPRECATED_DECLARATIONS_POP
+
+    // Show All
+    pString = CreateNSString(VclResId(SV_MENU_MAC_SHOWALL));
+    [pAppMenu addItemWithTitle: pString
+        action:@selector(unhideAllApplications:)
+        keyEquivalent:@""];
+    [pString release];
+
+    [pAppMenu addItem:[NSMenuItem separatorItem]];
+
+    // Quit
+    pString = CreateNSString(VclResId(SV_MENU_MAC_QUITAPP));
+    [pAppMenu addItemWithTitle: pString
+        action:@selector(terminate:)
+        keyEquivalent:@"q"];
+    [pString release];
 }
 
 std::unique_ptr<SalMenu> AquaSalInstance::CreateMenu( bool bMenuBar, Menu* pVCLMenu )
diff --git a/vcl/osx/salplug.cxx b/vcl/osx/salplug.cxx
new file mode 100644
index 000000000000..e4f69a10ee25
--- /dev/null
+++ b/vcl/osx/salplug.cxx
@@ -0,0 +1,167 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <osl/module.hxx>
+#include <osl/process.h>
+
+#include <rtl/bootstrap.hxx>
+#include <rtl/process.h>
+#include <sal/log.hxx>
+
+#include <salinst.hxx>
+#include <saldatabasic.hxx>
+#include <config_vclplug.h>
+#include <desktop/crashreport.hxx>
+
+#include <cstdio>
+
+extern "C" {
+typedef SalInstance*(*salFactoryProc)();
+}
+
+static oslModule pCloseModule = nullptr;
+
+static SalInstance* tryInstance( const OUString& rModuleBase, bool bForce = false )
+{
+    SalInstance* pInst = nullptr;
+    OUString aModule(
+#ifdef SAL_DLLPREFIX
+            SAL_DLLPREFIX
+#endif
+            "vclplug_" + rModuleBase + "lo" SAL_DLLEXTENSION );
+
+    osl::Module aMod;
+    if (aMod.loadRelative(reinterpret_cast<oslGenericFunction>(&tryInstance), aModule, SAL_LOADMODULE_GLOBAL))
+    {
+        salFactoryProc aProc = reinterpret_cast<salFactoryProc>(aMod.getFunctionSymbol("create_SalInstance"));
+        if (aProc)
+        {
+            pInst = aProc();
+            SAL_INFO(
+                "vcl.plugadapt",
+                "sal plugin " << aModule << " produced instance " << pInst);
+            if (pInst)
+            {
+                pCloseModule = static_cast<oslModule>(aMod);
+                aMod.release();
+            }
+        }
+        else
+        {
+            SAL_WARN(
+                "vcl.plugadapt",
+                "could not load symbol create_SalInstance from shared object "
+                    << aModule);
+        }
+    }
+    else if (bForce)
+    {
+        SAL_WARN("vcl.plugadapt", "could not load shared object " << aModule);
+    }
+    else
+    {
+        SAL_INFO("vcl.plugadapt", "could not load shared object " << aModule);
+    }
+
+    // coverity[leaked_storage] - this is on purpose
+    return pInst;
+}
+
+SalInstance *CreateSalInstance()
+{
+    SalInstance *pInst = nullptr;
+
+    OUString aUsePlugin;
+    rtl::Bootstrap::get( "SAL_USE_VCLPLUGIN", aUsePlugin );
+
+    if( !aUsePlugin.isEmpty() )
+        pInst = tryInstance( aUsePlugin, true );
+
+    // fallback, try everything
+    static const char* const pPlugin[] = { "osx" };
+
+    for ( int i = 0; !pInst && i != SAL_N_ELEMENTS(pPlugin); ++i )
+        pInst = tryInstance( OUString::createFromAscii( pPlugin[ i ] ) );
+
+    if( ! pInst )
+    {
+        std::fprintf( stderr, "no suitable windowing system found, exiting.\n" );
+        _exit( 1 );
+    }
+
+    // acquire SolarMutex
+    pInst->AcquireYieldMutex();
+
+    return pInst;
+}
+
+void DestroySalInstance( SalInstance *pInst )
+{
+    // release SolarMutex
+    pInst->ReleaseYieldMutexAll();
+
+    delete pInst;
+    if( pCloseModule )
+        osl_unloadModule( pCloseModule );
+}
+
+void InitSalData()
+{
+}
+
+void DeInitSalData()
+{
+}
+
+void InitSalMain()
+{
+}
+
+void SalAbort( const OUString& rErrorText, bool bDumpCore )
+{
+    if( rErrorText.isEmpty() )
+        std::fprintf( stderr, "Application Error\n" );
+    else
+    {
+        CrashReporter::AddKeyValue("AbortMessage", rErrorText);
+        std::fprintf( stderr, "%s\n", OUStringToOString(rErrorText, osl_getThreadTextEncoding()).getStr() );
+    }
+    if( bDumpCore )
+        abort();
+    else
+        _exit(1);
+}
+
+const OUString& SalGetDesktopEnvironment()
+{
+    static OUString aDesktopEnvironment( "Windows" );
+    return aDesktopEnvironment;
+}
+
+SalData::SalData() :
+    m_pInstance(nullptr),
+    m_pPIManager(nullptr)
+{
+}
+
+SalData::~SalData() COVERITY_NOEXCEPT_FALSE
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/osx/vclnsapp.mm b/vcl/osx/vclnsapp.mm
index f60b478a185f..7bbdc9d8843f 100644
--- a/vcl/osx/vclnsapp.mm
+++ b/vcl/osx/vclnsapp.mm
@@ -62,22 +62,6 @@
 -(void)applicationDidFinishLaunching:(NSNotification*)pNotification
 {
     (void)pNotification;
-
-SAL_WNODEPRECATED_DECLARATIONS_PUSH
-        // 'NSApplicationDefined' is deprecated: first deprecated in macOS 10.12
-    NSEvent* pEvent = [NSEvent otherEventWithType: NSApplicationDefined
-                               location: NSZeroPoint
-                               modifierFlags: 0
-                               timestamp: [[NSProcessInfo processInfo] systemUptime]
-                               windowNumber: 0
-                               context: nil
-                               subtype: AquaSalInstance::AppExecuteSVMain
-                               data1: 0
-                               data2: 0 ];
-SAL_WNODEPRECATED_DECLARATIONS_POP
-    assert( pEvent );
-    [NSApp postEvent: pEvent atStart: NO];
-
     if( [NSWindow respondsToSelector:@selector(allowsAutomaticWindowTabbing)] )
     {
         NSWindow.allowsAutomaticWindowTabbing = NO;
diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index beed24273e0d..3f8eae56836f 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -192,10 +192,6 @@ int ImplSVMain()
 
     bool bInit = isInitVCL() || InitVCL();
 
-#ifdef MACOSX
-    postInitVCLinitNSApp();
-#endif
-
     if( bInit )
     {
         // call application main
@@ -234,11 +230,7 @@ int ImplSVMain()
 
 int SVMain()
 {
-    int nRet;
-    if( !Application::IsConsoleOnly() && ImplSVMainHook( &nRet ) )
-        return nRet;
-    else
-        return ImplSVMain();
+    return ImplSVMain();
 }
 
 // This variable is set when no Application object has been instantiated
diff --git a/vcl/source/app/svmainhook.cxx b/vcl/source/app/svmainhook.cxx
deleted file mode 100644
index a66bbc186f92..000000000000
--- a/vcl/source/app/svmainhook.cxx
+++ /dev/null
@@ -1,34 +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 <sal/config.h>
-
-#include <vcl/svmain.hxx>
-
-#ifndef MACOSX
-// MacOSX implementation of ImplSVMainHook is in osx/salinst.cxx
-
-bool ImplSVMainHook( int * )
-{
-    return false;   // indicate that ImplSVMainHook is not implemented
-}
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list