diff options
author | Douglas Mencken <dougmencken@gmail.com> | 2014-03-02 22:06:25 -0500 |
---|---|---|
committer | Norbert Thiebaud <nthiebaud@gmail.com> | 2014-03-05 09:28:19 -0600 |
commit | 578bd15399a16b0a32e752e19ae42d989321d731 (patch) | |
tree | 7b75e8c6fc8f61414f574edd91b44558c275c81a /fpicker/source | |
parent | 644dbbc9d0098c02c8a1edd7d12daf13edca7eda (diff) |
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@gmail.com>
Tested-by: Norbert Thiebaud <nthiebaud@gmail.com>
Diffstat (limited to 'fpicker/source')
-rw-r--r-- | fpicker/source/aqua/FilterHelper.mm | 4 | ||||
-rw-r--r-- | fpicker/source/aqua/SalAquaFilePicker.mm | 4 | ||||
-rw-r--r-- | fpicker/source/aqua/SalAquaPicker.mm | 29 |
3 files changed, 37 insertions, 0 deletions
diff --git a/fpicker/source/aqua/FilterHelper.mm b/fpicker/source/aqua/FilterHelper.mm index 41327831322e..5ee7b447fa9f 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 0d62482ff561..6c2aa35f427d 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 664088fa2fe0..baff7c36f28a 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); |