summaryrefslogtreecommitdiff
path: root/fpicker
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2013-08-23 09:51:48 +0300
committerTor Lillqvist <tml@collabora.com>2014-01-28 17:33:00 +0200
commit18818412cb444e51c555c625723c69d6c8efbe48 (patch)
tree1c3f93531e6b56e3ad5c6a578d9e80ae35336487 /fpicker
parent943f165d9517468657e70747ce610543fedca649 (diff)
Make our File>Recent Documents work better when sandboxed
Store security scope bookmarks for files selected in the file picker in the user data. (I looked into storing it in the LO "registry" in the Histories/PickList thingies, but that was horribly complex.) When opening a file, if we have stored a security scope bookmark for it, use that while opening the file. Change-Id: I347ae2dd815299441c17467d9b66a226061d0ed2
Diffstat (limited to 'fpicker')
-rw-r--r--fpicker/source/aqua/SalAquaFilePicker.mm32
1 files changed, 31 insertions, 1 deletions
diff --git a/fpicker/source/aqua/SalAquaFilePicker.mm b/fpicker/source/aqua/SalAquaFilePicker.mm
index b8241dc3f673..3b085f173d8f 100644
--- a/fpicker/source/aqua/SalAquaFilePicker.mm
+++ b/fpicker/source/aqua/SalAquaFilePicker.mm
@@ -1,4 +1,4 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* -*- Mode: ObjC; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
@@ -17,6 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <config_features.h>
+
#include "sal/config.h"
#include <com/sun/star/lang/DisposedException.hpp>
@@ -300,6 +302,17 @@ uno::Sequence<rtl::OUString> SAL_CALL SalAquaFilePicker::getFiles() throw( uno::
SolarMutexGuard aGuard;
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 && HAVE_FEATURE_MACOSX_SANDBOX
+ static NSUserDefaults *userDefaults;
+ static bool triedUserDefaults = false;
+
+ if (!triedUserDefaults)
+ {
+ userDefaults = [NSUserDefaults standardUserDefaults];
+ triedUserDefaults = true;
+ }
+#endif
+
// OSL_TRACE("starting work");
/*
* If more than one file is selected in an OpenDialog, then the first result
@@ -322,6 +335,23 @@ uno::Sequence<rtl::OUString> SAL_CALL SalAquaFilePicker::getFiles() throw( uno::
for(int nIndex = 0; nIndex < nFiles; nIndex += 1)
{
NSURL *url = [files objectAtIndex:nIndex];
+
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 && HAVE_FEATURE_MACOSX_SANDBOX
+ if (userDefaults != NULL &&
+ [url respondsToSelector:@selector(bookmarkDataWithOptions:includingResourceValuesForKeys:relativeToURL:error:)])
+ {
+ NSData *data = [url bookmarkDataWithOptions:NSURLBookmarkCreationWithSecurityScope
+ includingResourceValuesForKeys:nil
+ relativeToURL:nil
+ error:nil];
+ if (data != NULL)
+ {
+ [userDefaults setObject:data
+ forKey:[@"bookmarkFor:" stringByAppendingString:[url absoluteString]]];
+ }
+ }
+#endif
+
OSL_TRACE("handling %s", [[url description] UTF8String]);
InfoType info = FULLPATH;
if (nFiles > 1) {