diff options
author | Release Engineers <releng@openoffice.org> | 2009-08-27 02:09:26 +0000 |
---|---|---|
committer | Release Engineers <releng@openoffice.org> | 2009-08-27 02:09:26 +0000 |
commit | c0033d1ddadee302880a4527f9a91198ccb35e75 (patch) | |
tree | b09c20bcf90320cd2b7f51460dd821a5755640d1 | |
parent | 05a1a258cf2aab6e33750ff2c00bcd8827348146 (diff) |
CWS-TOOLING: integrate CWS aquafilepicker04
2009-08-07 08:33:29 +0200 fheckl r274747 : issue 102102 add OOo autoextension checkbox
2009-08-04 19:37:42 +0200 fheckl r274631 : issue 93899 simpler patch
2009-08-03 23:22:16 +0200 fheckl r274601 : issue 93899 directory is now correctly remembered
-rw-r--r-- | fpicker/source/aqua/AquaFilePickerDelegate.hxx | 2 | ||||
-rw-r--r-- | fpicker/source/aqua/AquaFilePickerDelegate.mm | 18 | ||||
-rw-r--r-- | fpicker/source/aqua/ControlHelper.cxx | 53 | ||||
-rw-r--r-- | fpicker/source/aqua/ControlHelper.hxx | 12 | ||||
-rw-r--r-- | fpicker/source/aqua/SalAquaFilePicker.cxx | 39 | ||||
-rw-r--r-- | fpicker/source/aqua/SalAquaPicker.cxx | 31 |
6 files changed, 83 insertions, 72 deletions
diff --git a/fpicker/source/aqua/AquaFilePickerDelegate.hxx b/fpicker/source/aqua/AquaFilePickerDelegate.hxx index e3191962a131..6e5afc8bb5cc 100644 --- a/fpicker/source/aqua/AquaFilePickerDelegate.hxx +++ b/fpicker/source/aqua/AquaFilePickerDelegate.hxx @@ -49,11 +49,11 @@ class FilterHelper; - (void)setFilterHelper:(FilterHelper*)filterHelper; - (MacOSBOOL)panel:(id)sender shouldShowFilename:(NSString *)filename; - - (void)panelSelectionDidChange:(id)sender; - (void)panel:(id)sender directoryDidChange:(NSString *)path; - (void)filterSelectedAtIndex:(id)sender; +- (void)autoextensionChanged:(id)sender; @end diff --git a/fpicker/source/aqua/AquaFilePickerDelegate.mm b/fpicker/source/aqua/AquaFilePickerDelegate.mm index 7a557495191b..d73e5d82ff16 100644 --- a/fpicker/source/aqua/AquaFilePickerDelegate.mm +++ b/fpicker/source/aqua/AquaFilePickerDelegate.mm @@ -27,6 +27,8 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ +#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> +#include <com/sun/star/uno/Any.hxx> #ifndef _SALAQUAFILEPICKER_HXX_ #include "SalAquaFilePicker.hxx" @@ -106,5 +108,19 @@ filePicker->filterControlChanged(); } +- (void)autoextensionChanged:(id)sender +{ + if (sender == nil) { + return; + } + + if ([sender class] != [NSButton class]) { + return; + } + uno::Any aValue; + aValue <<= ([((NSButton*)sender) state] == NSOnState); + + filePicker->setValue(::com::sun::star::ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0, aValue); +} -@end
\ No newline at end of file +@end diff --git a/fpicker/source/aqua/ControlHelper.cxx b/fpicker/source/aqua/ControlHelper.cxx index 6919133612da..4ff3d1c33835 100644 --- a/fpicker/source/aqua/ControlHelper.cxx +++ b/fpicker/source/aqua/ControlHelper.cxx @@ -61,7 +61,6 @@ ControlHelper::ControlHelper() , m_bUserPaneNeeded( false ) , m_bIsUserPaneLaidOut(false) , m_bIsFilterControlNeeded(false) -, m_bAutoFilenameExtension(true) , m_pFilterHelper(NULL) { DBG_PRINT_ENTRY(CLASS_NAME, __func__); @@ -174,12 +173,7 @@ void ControlHelper::enableControl( const sal_Int16 nControlId, const sal_Bool bE ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if (nControlId == ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION) { - OSL_TRACE(" autoextension checkbox cannot be changed"); - DBG_PRINT_EXIT(CLASS_NAME, __func__); - return; - } - else if (nControlId == ExtendedFilePickerElementIds::CHECKBOX_PREVIEW) { + if (nControlId == ExtendedFilePickerElementIds::CHECKBOX_PREVIEW) { OSL_TRACE(" preview checkbox cannot be changed"); DBG_PRINT_EXIT(CLASS_NAME, __func__); return; @@ -268,12 +262,7 @@ void ControlHelper::setValue( sal_Int16 nControlId, sal_Int16 nControlAction, co ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if (nControlId == ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION) { - /* see comment in the header file */ - //rValue >>= m_bAutoFilenameExtension; - OSL_TRACE(" value is a bool: %d", m_bAutoFilenameExtension); - } - else if (nControlId == ExtendedFilePickerElementIds::CHECKBOX_PREVIEW) { + if (nControlId == ExtendedFilePickerElementIds::CHECKBOX_PREVIEW) { OSL_TRACE(" value for preview is unchangeable"); } else { @@ -307,25 +296,19 @@ uno::Any ControlHelper::getValue( sal_Int16 nControlId, sal_Int16 nControlAction ::vos::OGuard aGuard( Application::GetSolarMutex() ); uno::Any aRetval; - if (nControlId == ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION) { - aRetval <<= m_bAutoFilenameExtension; - OSL_TRACE("value is a bool (autoextension): %d", m_bAutoFilenameExtension); - } - else { - NSControl* pControl = getControl( nControlId ); + NSControl* pControl = getControl( nControlId ); - if( pControl == nil ) { - OSL_TRACE("get value for unknown control %d", nControlId); - aRetval <<= sal_True; - } else { - if( [pControl class] == [NSPopUpButton class] ) { - aRetval = HandleGetListValue(pControl, nControlAction); - } else if( [pControl class] == [NSButton class] ) { - //NSLog(@"control: %@", [[pControl cell] title]); - sal_Bool bValue = [(NSButton*)pControl state] == NSOnState ? sal_True : sal_False; - aRetval <<= bValue; - OSL_TRACE("value is a bool (checkbox): %d", bValue); - } + if( pControl == nil ) { + OSL_TRACE("get value for unknown control %d", nControlId); + aRetval <<= sal_True; + } else { + if( [pControl class] == [NSPopUpButton class] ) { + aRetval = HandleGetListValue(pControl, nControlAction); + } else if( [pControl class] == [NSButton class] ) { + //NSLog(@"control: %@", [[pControl cell] title]); + sal_Bool bValue = [(NSButton*)pControl state] == NSOnState ? sal_True : sal_False; + aRetval <<= bValue; + OSL_TRACE("value is a bool (checkbox): %d", bValue); } } @@ -528,7 +511,7 @@ void ControlHelper::createControls() } } - for (int i = 1; i < TOGGLE_LAST; i++) { + for (int i = 0/*#i102102*/; i < TOGGLE_LAST; i++) { if (true == m_bToggleVisibility[i]) { m_bUserPaneNeeded = true; @@ -542,6 +525,11 @@ void ControlHelper::createControls() [button setState:NSOffState]; + if (i == AUTOEXTENSION) { + [button setTarget:m_pDelegate]; + [button setAction:@selector(autoextensionChanged:)]; + } + m_pToggles[i] = button; m_aActiveControls.push_back(m_pToggles[i]); @@ -790,6 +778,7 @@ case ExtendedFilePickerElementIds::LISTBOX_##elem##_LABEL: \ switch( nControlId ) { + MAP_TOGGLE( AUTOEXTENSION ); MAP_TOGGLE( PASSWORD ); MAP_TOGGLE( FILTEROPTIONS ); MAP_TOGGLE( READONLY ); diff --git a/fpicker/source/aqua/ControlHelper.hxx b/fpicker/source/aqua/ControlHelper.hxx index 4dbee2e818fe..081377a24dc6 100644 --- a/fpicker/source/aqua/ControlHelper.hxx +++ b/fpicker/source/aqua/ControlHelper.hxx @@ -127,7 +127,7 @@ public: } inline bool isAutoExtensionEnabled() { - return m_bAutoFilenameExtension; + return ([((NSButton*) m_pToggles[AUTOEXTENSION]) state] == NSOnState); } private: @@ -168,16 +168,6 @@ private: /** indicates if a filter control is needed */ bool m_bIsFilterControlNeeded; - /* - * With issue #78852 the GUI option to set automatic filename extension was removed but - * so far the setting is still in effect and so the value for has to be saved and possibly be restored - * also. - * But with issue #FILLME users were starting to get confused on Windows so we decided to have - * autoextension always on and have it selectable for the user again. - */ - /** indicates if a filename extension is to automatically be appended to a user entered file name */ - bool m_bAutoFilenameExtension; - /** a list with all actively used controls */ ::std::list<NSControl*> m_aActiveControls; diff --git a/fpicker/source/aqua/SalAquaFilePicker.cxx b/fpicker/source/aqua/SalAquaFilePicker.cxx index 5cd5247dac37..8f79c5d2201d 100644 --- a/fpicker/source/aqua/SalAquaFilePicker.cxx +++ b/fpicker/source/aqua/SalAquaFilePicker.cxx @@ -35,7 +35,6 @@ #include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> -#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> #include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp> #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> #include <cppuhelper/interfacecontainer.h> @@ -357,10 +356,6 @@ uno::Sequence<rtl::OUString> SAL_CALL SalAquaFilePicker::getFiles() throw( uno:: if (nFiles > 1) { aSelectedFiles[0] = OUString(sDirectoryURL); } - - implsetDisplayDirectory(sDirectoryURL); - - OSL_TRACE("dir url: %s", OUStringToOString(sDirectoryURL, RTL_TEXTENCODING_UTF8).getStr()); } short nSequenceIndex = nFiles > 1 ? nIndex + 1 : nIndex; @@ -453,12 +448,7 @@ throw( uno::RuntimeException ) m_pControlHelper->setValue(nControlId, nControlAction, rValue); if (nControlId == ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION && m_nDialogType == NAVIGATIONSERVICES_SAVE) { - sal_Bool bAutoExtensionOn = sal_False; - rValue >>= bAutoExtensionOn; - if (bAutoExtensionOn == sal_True) { - [m_pDialog setExtensionHidden:bAutoExtensionOn]; - updateSaveFileNameExtension(); - } + updateSaveFileNameExtension(); } DBG_PRINT_EXIT(CLASS_NAME, __func__); @@ -775,21 +765,30 @@ void SalAquaFilePicker::updateSaveFileNameExtension() { return; } - if (m_pControlHelper->isAutoExtensionEnabled() == false) - return; + // we need to set this here again because initial setting does + //[m_pDialog setExtensionHidden:YES]; ::vos::OGuard aGuard( Application::GetSolarMutex() ); - ensureFilterHelper(); + if (m_pControlHelper->isAutoExtensionEnabled() == false) { + OSL_TRACE("allowing other file types"); + [m_pDialog setAllowedFileTypes:nil]; + [m_pDialog setAllowsOtherFileTypes:YES]; + } else { + ensureFilterHelper(); - OUStringList aStringList = m_pFilterHelper->getCurrentFilterSuffixList(); - if( aStringList.empty()) // #i9328# - return; + OUStringList aStringList = m_pFilterHelper->getCurrentFilterSuffixList(); + if( aStringList.empty()) // #i9328# + return; - rtl::OUString suffix = (*(aStringList.begin())).copy(1); - NSString *requiredFileType = [NSString stringWithOUString:suffix]; + rtl::OUString suffix = (*(aStringList.begin())).copy(1); + NSString *requiredFileType = [NSString stringWithOUString:suffix]; - [m_pDialog setRequiredFileType:requiredFileType]; + [m_pDialog setRequiredFileType:requiredFileType]; + + OSL_TRACE("disallowing other file types"); + [m_pDialog setAllowsOtherFileTypes:NO]; + } DBG_PRINT_EXIT(CLASS_NAME, __func__); } diff --git a/fpicker/source/aqua/SalAquaPicker.cxx b/fpicker/source/aqua/SalAquaPicker.cxx index 0f326e1e2d29..aaf311de020a 100644 --- a/fpicker/source/aqua/SalAquaPicker.cxx +++ b/fpicker/source/aqua/SalAquaPicker.cxx @@ -48,12 +48,17 @@ #include "CFStringUtilities.hxx" #include "NSString_OOoAdditions.hxx" +#ifndef _NSURL_OOOADDITIONS_HXX_ +#include "NSURL_OOoAdditions.hxx" +#endif + #include "SalAquaFilePicker.hxx" #include <stdio.h> #pragma mark DEFINES #define CLASS_NAME "SalAquaPicker" +#define kSetHideExtensionStateKey @"NSNavLastUserSetHideExtensionButtonState" //------------------------------------------------------------------------ // namespace directives @@ -114,8 +119,22 @@ void SAL_CALL SalAquaPicker::implInitialize() case NAVIGATIONSERVICES_SAVE: OSL_TRACE("NAVIGATIONSERVICES_SAVE"); m_pDialog = [NSSavePanel savePanel]; - [(NSSavePanel*)m_pDialog setCanSelectHiddenExtension:YES]; - [(NSSavePanel*)m_pDialog setExtensionHidden:NO]; + [(NSSavePanel*)m_pDialog setCanSelectHiddenExtension:NO]; //changed for issue #102102 + /* I would have loved to use + * [(NSSavePanel*)m_pDialog setExtensionHidden:YES]; + * here but unfortunately this + * a) only works when the dialog is already displayed because it seems to act on the corresponding checkbox (that we don't show but that doesn't matter) + * b) Mac OS X saves this setting on an application-based level which means that the last state is always being restored again when the app runs for the next time + * + * So the only reliable way seems to be using the NSUserDefaults object because that is where that value is stored and + * to just overwrite it if it has the wrong value. + */ + NSUserDefaults *pDefaults = [NSUserDefaults standardUserDefaults]; + NSNumber *pExtn = [pDefaults objectForKey:kSetHideExtensionStateKey]; + if(pExtn == nil || [pExtn boolValue] == NO) { + OSL_TRACE("Hiding extension"); + [pDefaults setBool:YES forKey:kSetHideExtensionStateKey]; + } break; case NAVIGATIONSERVICES_DIRECTORY: @@ -188,6 +207,9 @@ int SalAquaPicker::run() break; } + if (retVal == NSFileHandlingPanelOKButton) { + implsetDisplayDirectory([[NSURL fileURLWithPath:[m_pDialog directory]] OUStringForInfo:FULLPATH]); + } DBG_PRINT_EXIT(CLASS_NAME, __func__, retVal); @@ -217,11 +239,6 @@ void SAL_CALL SalAquaPicker::implsetDisplayDirectory( const rtl::OUString& aDire if (aDirectory != m_sDisplayDirectory) { m_sDisplayDirectory = aDirectory; - - if (m_pDialog != nil) { - //NSLog(@"would change now to:%@", [NSString stringWithOUString:aDirectory]); - // [m_pDialog setDirectory:[NSString stringWithOUString:aDirectory]]; - } } DBG_PRINT_EXIT(CLASS_NAME, __func__); |