summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/Library_sfx.mk3
-rw-r--r--sfx2/source/appl/sfxhelp.cxx47
2 files changed, 47 insertions, 3 deletions
diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk
index 750f3b354c73..8557d763a31a 100644
--- a/sfx2/Library_sfx.mk
+++ b/sfx2/Library_sfx.mk
@@ -324,6 +324,9 @@ $(eval $(call gb_Library_add_defs,sfx,\
endif
ifeq ($(OS),MACOSX)
+$(eval $(call gb_Library_add_cxxflags,sfx,\
+ $(gb_OBJCXXFLAGS) \
+))
$(eval $(call gb_Library_add_objcxxobjects,sfx,\
sfx2/source/appl/shutdowniconaqua \
))
diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx
index ce59b412d8ce..2d36e9ac5198 100644
--- a/sfx2/source/appl/sfxhelp.cxx
+++ b/sfx2/source/appl/sfxhelp.cxx
@@ -23,6 +23,13 @@
#include <set>
#include <algorithm>
#include <cassert>
+#ifdef MACOSX
+#include <premac.h>
+#include <Foundation/NSString.h>
+#include <CoreFoundation/CFURL.h>
+#include <CoreServices/CoreServices.h>
+#include <postmac.h>
+#endif
#include <sal/log.hxx>
#include <com/sun/star/uno/Reference.h>
@@ -723,7 +730,16 @@ static bool impl_showOnlineHelp( const OUString& rURL )
try
{
+#ifdef MACOSX
+ LSOpenCFURLRef(CFURLCreateWithString(kCFAllocatorDefault,
+ CFStringCreateWithCString(kCFAllocatorDefault,
+ aHelpLink.toUtf8().getStr(),
+ kCFStringEncodingUTF8),
+ NULL),
+ NULL);
+#else
sfx2::openUriExternally(aHelpLink, false);
+#endif
return true;
}
catch (const Exception&)
@@ -903,10 +919,11 @@ bool rewriteFlatpakHelpRootUrl(OUString * helpRootUrl) {
}
#define SHTML1 "<!DOCTYPE HTML><html lang=\"en-US\"><head><meta charset=\"UTF-8\">"
-#define SHTML2 "<meta http-equiv=\"refresh\" content=\"1\" url=\""
-#define SHTML3 "\"><script type=\"text/javascript\"> window.location.href = \""
+#define SHTML2 "<meta http-equiv=\"refresh\" content=\"1; url='"
+#define SHTML3 "'\"><script type=\"text/javascript\"> window.location.href = \""
#define SHTML4 "\";</script><title>Help Page Redirection</title></head><body></body></html>"
+// use a tempfile since e.g. xdg-open doesn't support URL-parameters with file:// URLs
static bool impl_showOfflineHelp( const OUString& rURL )
{
OUString aBaseInstallPath = getHelpRootURL();
@@ -940,10 +957,18 @@ static bool impl_showOfflineHelp( const OUString& rURL )
pStream->WriteUnicodeOrByteText(aTempStr);
aTempFile.CloseStream();
-
try
{
+#ifdef MACOSX
+ LSOpenCFURLRef(CFURLCreateWithString(kCFAllocatorDefault,
+ CFStringCreateWithCString(kCFAllocatorDefault,
+ aTempFile.GetURL().toUtf8().getStr(),
+ kCFStringEncodingUTF8),
+ NULL),
+ NULL);
+#else
sfx2::openUriExternally(aTempFile.GetURL(), false);
+#endif
return true;
}
catch (const Exception&)
@@ -1055,6 +1080,22 @@ bool SfxHelp::Start_Impl(const OUString& rURL, const vcl::Window* pWindow, const
impl_showOnlineHelp( aHelpURL );
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,
+ (CFStringRef)@"https://www.libreoffice.org",
+ NULL),
+ kLSRolesAll, NULL);
+ if([(NSString*)CFURLGetString(pBrowser) isEqualToString:@"file:///Applications/Safari.app/"]) {
+ impl_showOnlineHelp( aHelpURL );
+ return true;
+ }
+ }
+#endif
// If the HTML or no help is installed, but aHelpURL nevertheless references valid help content,
// that implies that this help content belongs to an extension (and thus would not be available