sfx2/source/appl/sfxhelp.cxx |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

New commits:
commit 0db0e229fd2696ce9410576bdd2ba2e98cf4673d
Author:     Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
AuthorDate: Thu Jun 30 22:23:30 2022 +0200
Commit:     Adolfo Jayme Barrientos <fit...@ubuntu.com>
CommitDate: Sun Jul 3 11:18:28 2022 +0200

    tdf#149603 macOS: fix workaround to use web help if Safari is the default 
browser
    
    Safari won't access the local helpfiles from LO's app folder unless you
    enable Safari's webdeveloper menu. The workaround broke since
    f31f0038f5fd9254584a06665066faf9715d1cd8 switched from window to widget
    references and hence using a different codepath, skipping the workaround
    added in 44893662d510c4173e55ba27af02d0258a697a5d
    
    Change-Id: I0c59066fe1cef1514c6595e0439d31d3e60e02f3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136685
    Tested-by: Jenkins
    Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
    (cherry picked from commit 184a45c4176d96bf799a8f8a0fba290a8c851948)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136705
    Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>

diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx
index 4aa13c6f2c64..d11c99b30b12 100644
--- a/sfx2/source/appl/sfxhelp.cxx
+++ b/sfx2/source/appl/sfxhelp.cxx
@@ -1281,6 +1281,22 @@ bool SfxHelp::Start_Impl(const OUString& rURL, 
weld::Widget* pWidget, const OUSt
         impl_showOnlineHelp(aHelpURL, pWidget);
         return true;
     }
+#ifdef MACOSX
+    if (@available(macOS 10.14, *)) {
+        // Workaround: Safari sandboxing prevents it from accessing files in 
the LibreOffice.app folder
+        // force online-help instead if Safari is default browser.
+        CFURLRef pBrowser = LSCopyDefaultApplicationURLForURL(
+                                CFURLCreateWithString(
+                                    kCFAllocatorDefault,
+                                    
static_cast<CFStringRef>(@"https://www.libreoffice.org";),
+                                    nullptr),
+                                kLSRolesAll, nullptr);
+        if([static_cast<NSString*>(CFURLGetString(pBrowser)) 
isEqualToString:@"file:///Applications/Safari.app/"]) {
+            impl_showOnlineHelp(aHelpURL, pWidget);
+            return true;
+        }
+    }
+#endif
 
     // If the HTML or no help is installed, but aHelpURL nevertheless 
references valid help content,
     // that implies that help content belongs to an extension (and thus would 
not be available

Reply via email to