[Libreoffice-commits] core.git: fpicker/source
Douglas Mencken
dougmencken at gmail.com
Wed Mar 5 07:28:39 PST 2014
fpicker/source/aqua/FilterHelper.mm | 4 ++++
fpicker/source/aqua/SalAquaFilePicker.mm | 4 ++++
fpicker/source/aqua/SalAquaPicker.mm | 29 +++++++++++++++++++++++++++++
3 files changed, 37 insertions(+)
New commits:
commit 578bd15399a16b0a32e752e19ae42d989321d731
Author: Douglas Mencken <dougmencken at gmail.com>
Date: Sun Mar 2 22:06:25 2014 -0500
Currently used file pickers API doesn't work for OS X < 10.6
Change-Id: I69592ada3a413cae2d0def2faa495db44894ed3f
Reviewed-on: https://gerrit.libreoffice.org/8430
Reviewed-by: Norbert Thiebaud <nthiebaud at gmail.com>
Tested-by: Norbert Thiebaud <nthiebaud at gmail.com>
diff --git a/fpicker/source/aqua/FilterHelper.mm b/fpicker/source/aqua/FilterHelper.mm
index 4132783..5ee7b44 100644
--- a/fpicker/source/aqua/FilterHelper.mm
+++ b/fpicker/source/aqua/FilterHelper.mm
@@ -385,7 +385,11 @@ sal_Bool FilterHelper::filenameMatchesFilter(NSString* sFilename)
}
NSFileManager *manager = [NSFileManager defaultManager];
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060
+ NSDictionary* pAttribs = [manager fileAttributesAtPath: sFilename traverseLink: NO];
+#else
NSDictionary* pAttribs = [manager attributesOfItemAtPath: sFilename error: nil];
+#endif
if( pAttribs )
{
NSObject* pType = [pAttribs objectForKey: NSFileType];
diff --git a/fpicker/source/aqua/SalAquaFilePicker.mm b/fpicker/source/aqua/SalAquaFilePicker.mm
index 0d62482..6c2aa35 100644
--- a/fpicker/source/aqua/SalAquaFilePicker.mm
+++ b/fpicker/source/aqua/SalAquaFilePicker.mm
@@ -761,7 +761,11 @@ void SalAquaFilePicker::updateSaveFileNameExtension() {
rtl::OUString suffix = (*(aStringList.begin())).copy(1);
NSString *requiredFileType = [NSString stringWithOUString:suffix];
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060
+ [m_pDialog setRequiredFileType:requiredFileType];
+#else
[m_pDialog setAllowedFileTypes:[NSArray arrayWithObjects:requiredFileType, nil]];
+#endif
OSL_TRACE("disallowing other file types");
[m_pDialog setAllowsOtherFileTypes:NO];
diff --git a/fpicker/source/aqua/SalAquaPicker.mm b/fpicker/source/aqua/SalAquaPicker.mm
index 664088f..baff7c3 100644
--- a/fpicker/source/aqua/SalAquaPicker.mm
+++ b/fpicker/source/aqua/SalAquaPicker.mm
@@ -165,6 +165,19 @@ int SalAquaPicker::run()
int retVal = 0;
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060
+ NSString *startDirectory;
+ if (m_sDisplayDirectory.getLength() > 0) {
+ NSString *temp = [NSString stringWithOUString:m_sDisplayDirectory];
+ NSURL *url = [NSURL URLWithString:temp];
+ startDirectory = [url path];
+
+ OSL_TRACE("start dir: %s", [startDirectory UTF8String]);
+ }
+ else {
+ startDirectory = NSHomeDirectory();
+ }
+#else
NSURL *startDirectory;
if (m_sDisplayDirectory.getLength() > 0) {
NSString *temp = [NSString stringWithOUString:m_sDisplayDirectory];
@@ -175,17 +188,26 @@ int SalAquaPicker::run()
else {
startDirectory = [NSURL fileURLWithPath:NSHomeDirectory() isDirectory:YES];
}
+#endif
switch(m_nDialogType) {
case NAVIGATIONSERVICES_DIRECTORY:
case NAVIGATIONSERVICES_OPEN:
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060
+ retVal = [(NSOpenPanel*)m_pDialog runModalForDirectory:startDirectory file:nil types:nil];
+#else
[m_pDialog setDirectoryURL:startDirectory];
retVal = [(NSOpenPanel*)m_pDialog runModal];
+#endif
break;
case NAVIGATIONSERVICES_SAVE:
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060
+ retVal = [m_pDialog runModalForDirectory:startDirectory file:[NSString stringWithOUString:((SalAquaFilePicker*)this)->getSaveFileName()]];
+#else
[m_pDialog setDirectoryURL:startDirectory];
[m_pDialog setNameFieldStringValue:[NSString stringWithOUString:((SalAquaFilePicker*)this)->getSaveFileName()]];
retVal = [m_pDialog runModal];
+#endif
break;
// [m_pDialog beginSheetForDirectory:startDirectory file:[m_pDialog saveFilename] modalForWindow:[NSApp keyWindow] modalDelegate:((SalAquaFilePicker*)this)->getDelegate() didEndSelector:@selector(savePanelDidEnd:returnCode:contextInfo:) contextInfo:nil];
default:
@@ -193,10 +215,17 @@ int SalAquaPicker::run()
}
if (retVal == NSFileHandlingPanelOKButton) {
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060
+ NSString* pDir = [m_pDialog directory];
+ if (pDir) {
+ implsetDisplayDirectory([[NSURL fileURLWithPath:pDir] OUStringForInfo:FULLPATH]);
+ }
+#else
NSURL* pDir = [m_pDialog directoryURL];
if (pDir) {
implsetDisplayDirectory([pDir OUStringForInfo:FULLPATH]);
}
+#endif
}
DBG_PRINT_EXIT(CLASS_NAME, __func__, retVal);
More information about the Libreoffice-commits
mailing list