From 6b6eea4fc1406d84861f6295a663c95a3a1d7940 Mon Sep 17 00:00:00 2001 From: sb Date: Fri, 22 May 2009 16:22:30 +0200 Subject: #i101955# improved error reporting --- fpicker/source/office/OfficeFilePicker.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'fpicker') diff --git a/fpicker/source/office/OfficeFilePicker.cxx b/fpicker/source/office/OfficeFilePicker.cxx index 0a8b5ca76974..7ea601e57828 100644 --- a/fpicker/source/office/OfficeFilePicker.cxx +++ b/fpicker/source/office/OfficeFilePicker.cxx @@ -984,8 +984,9 @@ void SAL_CALL SvtFilePicker::appendFilterGroup( const ::rtl::OUString& sGroupTit // check the names if ( FilterNameExists( aFilters ) ) - // TODO: a more precise exception message - throw IllegalArgumentException(); + throw IllegalArgumentException( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("filter name exists")), + static_cast< OWeakObject * >(this), 1); // ensure that we have a filter list ::rtl::OUString sInitialCurrentFilter; -- cgit From ab1ce9610fa399348a164fe1f8ed52919a0fe597 Mon Sep 17 00:00:00 2001 From: sb Date: Fri, 4 Sep 2009 12:24:40 +0200 Subject: merged in DEV300_m57 --- fpicker/prj/build.lst | 1 + fpicker/prj/d.lst | 1 + fpicker/source/aqua/AquaFilePickerDelegate.hxx | 2 +- fpicker/source/aqua/AquaFilePickerDelegate.mm | 18 +- fpicker/source/aqua/ControlHelper.cxx | 53 +- fpicker/source/aqua/ControlHelper.hxx | 12 +- fpicker/source/aqua/SalAquaFilePicker.cxx | 39 +- fpicker/source/aqua/SalAquaPicker.cxx | 31 +- fpicker/source/generic/fpicker.cxx | 2 + fpicker/source/unx/kde4/FPServiceInfo.hxx | 74 +++ fpicker/source/unx/kde4/KDE4FPEntry.cxx | 136 ++++ fpicker/source/unx/kde4/KDE4FilePicker.cxx | 717 +++++++++++++++++++++ fpicker/source/unx/kde4/KDE4FilePicker.hxx | 205 ++++++ fpicker/source/unx/kde4/fps-kde4-ucd.txt | 6 + fpicker/source/unx/kde4/fps_kde4.xml | 51 ++ fpicker/source/unx/kde4/makefile.mk | 117 ++++ .../win32/filepicker/VistaFilePickerImpl.cxx | 3 + 17 files changed, 1396 insertions(+), 72 deletions(-) create mode 100644 fpicker/source/unx/kde4/FPServiceInfo.hxx create mode 100644 fpicker/source/unx/kde4/KDE4FPEntry.cxx create mode 100644 fpicker/source/unx/kde4/KDE4FilePicker.cxx create mode 100644 fpicker/source/unx/kde4/KDE4FilePicker.hxx create mode 100644 fpicker/source/unx/kde4/fps-kde4-ucd.txt create mode 100644 fpicker/source/unx/kde4/fps_kde4.xml create mode 100644 fpicker/source/unx/kde4/makefile.mk (limited to 'fpicker') diff --git a/fpicker/prj/build.lst b/fpicker/prj/build.lst index 87084f1b6656..434f22660f33 100644 --- a/fpicker/prj/build.lst +++ b/fpicker/prj/build.lst @@ -3,6 +3,7 @@ fp fpicker\inc nmake - all fp_inc NULL fp fpicker\source\generic nmake - all fp_generic fp_inc NULL fp fpicker\source\office nmake - all fp_office fp_inc NULL fp fpicker\source\unx\gnome nmake - u fp_gnome_filepicker fp_inc NULL +fp fpicker\source\unx\kde4 nmake - u fp_kde4_filepicker fp_inc NULL fp fpicker\source\aqua nmake - u fp_macosx_filepicker NULL fp fpicker\source\win32\filepicker nmake - w fp_win32_filepicker fp_inc NULL fp fpicker\source\win32\folderpicker nmake - w fp_win32_folderpicker fp_inc NULL diff --git a/fpicker/prj/d.lst b/fpicker/prj/d.lst index 05ab72c01208..7c4e0bf6024a 100644 --- a/fpicker/prj/d.lst +++ b/fpicker/prj/d.lst @@ -10,4 +10,5 @@ mkdir: %COMMON_DEST%\bin%_EXT%\hid ..\source\win32\filepicker\*.xml %_DEST%\xml%_EXT%\*.xml ..\source\win32\folderpicker\*.xml %_DEST%\xml%_EXT%\*.xml ..\source\unx\gnome\fps-gnome-ucd.txt %_DEST%\bin%_EXT%\fps-gnome-ucd.txt +..\source\unx\kde4\fps-kde4-ucd.txt %_DEST%\bin%_EXT%\fps-kde4-ucd.txt ..\source\aqua\fps-aqua-ucd.txt %_DEST%\bin%_EXT%\fps-aqua-ucd.txt 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 +#include #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 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 #include #include -#include #include #include #include @@ -357,10 +356,6 @@ uno::Sequence 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 #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__); diff --git a/fpicker/source/generic/fpicker.cxx b/fpicker/source/generic/fpicker.cxx index dec3488211c5..9bdb870ebcc8 100644 --- a/fpicker/source/generic/fpicker.cxx +++ b/fpicker/source/generic/fpicker.cxx @@ -60,6 +60,8 @@ static OUString FilePicker_getSystemPickerServiceName() return OUString (RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.ui.dialogs.GtkFilePicker")); else if (aDesktopEnvironment.equalsIgnoreAsciiCaseAscii ("kde")) return OUString (RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.ui.dialogs.KDEFilePicker")); + else if (aDesktopEnvironment.equalsIgnoreAsciiCaseAscii ("kde4")) + return OUString (RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.ui.dialogs.KDE4FilePicker")); else if (aDesktopEnvironment.equalsIgnoreAsciiCaseAscii ("macosx")) return OUString (RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.ui.dialogs.AquaFilePicker")); else diff --git a/fpicker/source/unx/kde4/FPServiceInfo.hxx b/fpicker/source/unx/kde4/FPServiceInfo.hxx new file mode 100644 index 000000000000..d0a465102768 --- /dev/null +++ b/fpicker/source/unx/kde4/FPServiceInfo.hxx @@ -0,0 +1,74 @@ +/************************************************************************* + * + * + * + * + * + * + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#pragma once + +// the service names +#define FILE_PICKER_SERVICE_NAME "com.sun.star.ui.dialogs.KDE4FilePicker" + +// the implementation names +#define FILE_PICKER_IMPL_NAME "com.sun.star.ui.dialogs.KDE4FilePicker" + +// the registry key names +// a key under which this service will be registered, +// Format: -> "/ImplName/UNO/SERVICES/ServiceName" +// +#define FILE_PICKER_REGKEY_NAME "/com.sun.star.ui.dialogs.KDE4FilePickerImpl/UNO/SERVICES/com.sun.star.ui.dialogs.KDE4FilePicker" diff --git a/fpicker/source/unx/kde4/KDE4FPEntry.cxx b/fpicker/source/unx/kde4/KDE4FPEntry.cxx new file mode 100644 index 000000000000..268c01b600b3 --- /dev/null +++ b/fpicker/source/unx/kde4/KDE4FPEntry.cxx @@ -0,0 +1,136 @@ +/************************************************************************* + * + * + * + * + * + * + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include + +#include + +#include + +#include "KDE4FilePicker.hxx" +#include "FPServiceInfo.hxx" + +using namespace ::rtl; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::registry; +using namespace ::cppu; +using ::com::sun::star::ui::dialogs::XFilePicker; + +static Reference< XInterface > SAL_CALL createInstance( const Reference< XMultiServiceFactory >& serviceManager ) +{ + return Reference< XInterface >(static_cast< XFilePicker* >( new KDE4FilePicker( serviceManager ) ) ); +} + +// the three uno functions that will be exported +extern "C" +{ + void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv ) + { + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; + } + + sal_Bool SAL_CALL component_writeInfo( void* pServiceManager, void* pRegistryKey ) + { + sal_Bool bRetVal = sal_True; + + if ( pRegistryKey ) + { + try + { + Reference< XRegistryKey > pXNewKey( static_cast< XRegistryKey* >( pRegistryKey ) ); + pXNewKey->createKey( OUString::createFromAscii( FILE_PICKER_REGKEY_NAME ) ); + } + catch( InvalidRegistryException& ) + { + OSL_ENSURE( sal_False, "InvalidRegistryException caught" ); + bRetVal = sal_False; + } + } + + return bRetVal; + } + + void* SAL_CALL component_getFactory( const sal_Char* pImplName, uno_Interface* pSrvManager, uno_Interface* pRegistryKey ) + { + void* pRet = 0; + + if ( pSrvManager && ( 0 == rtl_str_compare( pImplName, FILE_PICKER_IMPL_NAME ) ) ) + { + Sequence< OUString > aSNS( 1 ); + aSNS.getArray( )[0] = OUString::createFromAscii( FILE_PICKER_SERVICE_NAME ); + + Reference< XSingleServiceFactory > xFactory ( createSingleFactory( + reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ), + OUString::createFromAscii( pImplName ), + createInstance, + aSNS ) ); + if ( xFactory.is() ) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + } + + return pRet; + } +} diff --git a/fpicker/source/unx/kde4/KDE4FilePicker.cxx b/fpicker/source/unx/kde4/KDE4FilePicker.cxx new file mode 100644 index 000000000000..d6d852c71d93 --- /dev/null +++ b/fpicker/source/unx/kde4/KDE4FilePicker.cxx @@ -0,0 +1,717 @@ +/************************************************************************* + * + * + * + * + * + * + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): Jan Holesovsky + * + * + ************************************************************************/ + +////////////////////////////////////////////////////////////////////////// +// includes +////////////////////////////////////////////////////////////////////////// + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include + +#include "KDE4FilePicker.hxx" +#include "FPServiceInfo.hxx" + +/* ********* Hack, but needed because of conflicting types... */ +#define Region QtXRegion + +//kde has an enum that uses this...OO does too +#undef SETTINGS_MOUSE + +#include +#include +#include +#include + +#include +#include +#include + +#undef Region + +using namespace ::com::sun::star; + +using namespace ::com::sun::star::ui::dialogs; +using namespace ::com::sun::star::ui::dialogs::TemplateDescription; + +using namespace ::com::sun::star; +using namespace ::com::sun::star::ui::dialogs; +using namespace ::com::sun::star::ui::dialogs::TemplateDescription; +using namespace ::com::sun::star::ui::dialogs::ExtendedFilePickerElementIds; +using namespace ::com::sun::star::ui::dialogs::CommonFilePickerElementIds; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::uno; + +////////////////////////////////////////////////////////////////////////// +// helper functions +////////////////////////////////////////////////////////////////////////// + +namespace +{ + // controling event notifications + const bool STARTUP_SUSPENDED = true; + const bool STARTUP_ALIVE = false; + + uno::Sequence SAL_CALL FilePicker_getSupportedServiceNames() + { + uno::Sequence aRet(3); + aRet[0] = rtl::OUString::createFromAscii("com.sun.star.ui.dialogs.FilePicker"); + aRet[1] = rtl::OUString::createFromAscii("com.sun.star.ui.dialogs.SystemFilePicker"); + aRet[2] = rtl::OUString::createFromAscii("com.sun.star.ui.dialogs.KDE4FilePicker"); + return aRet; + } +} + +rtl::OUString toOUString(const QString& s) +{ + return rtl::OUString(s.toUtf8().data(), s.length(), RTL_TEXTENCODING_UTF8); +} + +QString toQString(const rtl::OUString& s) +{ + return QString::fromUtf16(s.getStr(), s.getLength()); +} + +////////////////////////////////////////////////////////////////////////// +// KDE4FilePicker +////////////////////////////////////////////////////////////////////////// + +KDE4FilePicker::KDE4FilePicker( const uno::Reference& xServiceMgr ) + : cppu::WeakComponentImplHelper8< + XFilterManager, + XFilterGroupManager, + XFilePickerControlAccess, + XFilePickerNotifier, +// TODO XFilePreview, + lang::XInitialization, + util::XCancellable, + lang::XEventListener, + lang::XServiceInfo>( _helperMutex ), + m_xServiceMgr( xServiceMgr ), + _resMgr( CREATEVERSIONRESMGR( fps_office ) ) +{ + _extraControls = new QWidget(); + + _layout = new QGridLayout(_extraControls); + + _dialog = new KFileDialog(KUrl(""), QString(""), 0, _extraControls); + _dialog->setMode(KFile::File | KFile::LocalOnly); + + //default mode + _dialog->setOperationMode(KFileDialog::Opening); +} + +KDE4FilePicker::~KDE4FilePicker() +{ + delete _resMgr; + delete _dialog; +} + +void SAL_CALL KDE4FilePicker::addFilePickerListener( const uno::Reference& xListener ) + throw( uno::RuntimeException ) +{ + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + m_xListener = xListener; +} + +void SAL_CALL KDE4FilePicker::removeFilePickerListener( const uno::Reference& ) + throw( uno::RuntimeException ) +{ + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + m_xListener.clear(); +} + +void SAL_CALL KDE4FilePicker::setTitle( const rtl::OUString &title ) + throw( uno::RuntimeException ) +{ + _dialog->setCaption(toQString(title)); +} + +sal_Int16 SAL_CALL KDE4FilePicker::execute() + throw( uno::RuntimeException ) +{ + //get the window id of the main OO window to set it for the dialog as a parent + Window *pParentWin = Application::GetDefDialogParent(); + if ( pParentWin ) + { + const SystemEnvData* pSysData = ((SystemWindow *)pParentWin)->GetSystemData(); + if ( pSysData ) + { + KWindowSystem::setMainWindow( _dialog, pSysData->aWindow); // unx only + } + } + + _dialog->setFilter(_filter); + _dialog->exec(); + + //nasty hack to get a local qt event loop going to process the dialog + //otherwise the dialog returns immediately + while (_dialog->isVisible()) + { + kapp->processEvents(QEventLoop::WaitForMoreEvents); + } + + //block and wait for user input + if (_dialog->result() == KFileDialog::Accepted) + { + return ExecutableDialogResults::OK; + } + + return ExecutableDialogResults::CANCEL; +} + +void SAL_CALL KDE4FilePicker::setMultiSelectionMode( sal_Bool multiSelect ) + throw( uno::RuntimeException ) +{ + if (multiSelect) + { + _dialog->setMode(KFile::Files | KFile::LocalOnly); + } + else + { + _dialog->setMode(KFile::File | KFile::LocalOnly); + } +} + +void SAL_CALL KDE4FilePicker::setDefaultName( const ::rtl::OUString &name ) + throw( uno::RuntimeException ) +{ + const QString url = toQString(name); + _dialog->setSelection(url); +} + +void SAL_CALL KDE4FilePicker::setDisplayDirectory( const rtl::OUString &dir ) + throw( uno::RuntimeException ) +{ + const QString url = toQString(dir); + _dialog->setStartDir(KUrl(url)); +} + +rtl::OUString SAL_CALL KDE4FilePicker::getDisplayDirectory() + throw( uno::RuntimeException ) +{ + QString dir = _dialog->baseUrl().url(); + return toOUString(dir); +} + +uno::Sequence< ::rtl::OUString > SAL_CALL KDE4FilePicker::getFiles() + throw( uno::RuntimeException ) +{ + QStringList files = _dialog->selectedFiles(); + + uno::Sequence< ::rtl::OUString > seq(files.size()); + + for (int i=0 ; ifilterWidget()->setCurrentFilter(filter); +} + +rtl::OUString SAL_CALL KDE4FilePicker::getCurrentFilter() + throw( uno::RuntimeException ) +{ + QString filter = _filters[_dialog->currentFilter()]; + + //default if not found + if (filter.isNull()) + { + filter = "ODF Text Document (.odt)"; + } + + return toOUString(filter); +} + +void SAL_CALL KDE4FilePicker::appendFilterGroup( const rtl::OUString&, const uno::Sequence& ) + throw( lang::IllegalArgumentException, uno::RuntimeException ) +{ + //TODO +} + +void SAL_CALL KDE4FilePicker::setValue( sal_Int16 controlId, sal_Int16, const uno::Any &value ) + throw( uno::RuntimeException ) +{ + QWidget* widget = _customWidgets[controlId]; + + if (widget) + { + switch (controlId) + { + case ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION: + case ExtendedFilePickerElementIds::CHECKBOX_PASSWORD: + case ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS: + case ExtendedFilePickerElementIds::CHECKBOX_READONLY: + case ExtendedFilePickerElementIds::CHECKBOX_LINK: + case ExtendedFilePickerElementIds::CHECKBOX_PREVIEW: + case ExtendedFilePickerElementIds::CHECKBOX_SELECTION: + { + QCheckBox* cb = dynamic_cast(widget); + cb->setChecked(value.getValue()); + break; + } + case ExtendedFilePickerElementIds::PUSHBUTTON_PLAY: + case ExtendedFilePickerElementIds::LISTBOX_VERSION: + case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE: + case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE: + case ExtendedFilePickerElementIds::LISTBOX_VERSION_LABEL: + case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE_LABEL: + case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE_LABEL: + case ExtendedFilePickerElementIds::LISTBOX_FILTER_SELECTOR: + break; + } + } +} + +uno::Any SAL_CALL KDE4FilePicker::getValue( sal_Int16 controlId, sal_Int16 ) + throw( uno::RuntimeException ) +{ + uno::Any res(false); + + QWidget* widget = _customWidgets[controlId]; + + if (widget) + { + switch (controlId) + { + case ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION: + case ExtendedFilePickerElementIds::CHECKBOX_PASSWORD: + case ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS: + case ExtendedFilePickerElementIds::CHECKBOX_READONLY: + case ExtendedFilePickerElementIds::CHECKBOX_LINK: + case ExtendedFilePickerElementIds::CHECKBOX_PREVIEW: + case ExtendedFilePickerElementIds::CHECKBOX_SELECTION: + { + QCheckBox* cb = dynamic_cast(widget); + res = uno::Any(cb->isChecked()); + break; + } + case ExtendedFilePickerElementIds::PUSHBUTTON_PLAY: + case ExtendedFilePickerElementIds::LISTBOX_VERSION: + case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE: + case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE: + case ExtendedFilePickerElementIds::LISTBOX_VERSION_LABEL: + case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE_LABEL: + case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE_LABEL: + case ExtendedFilePickerElementIds::LISTBOX_FILTER_SELECTOR: + break; + } + } + + return res; +} + +void SAL_CALL KDE4FilePicker::enableControl( sal_Int16 controlId, sal_Bool enable ) + throw( uno::RuntimeException ) +{ + QWidget* widget = _customWidgets[controlId]; + + if (widget) + { + widget->setEnabled(enable); + } +} + +void SAL_CALL KDE4FilePicker::setLabel( sal_Int16 controlId, const ::rtl::OUString &label ) + throw( uno::RuntimeException ) +{ + QWidget* widget = _customWidgets[controlId]; + + if (widget) + { + switch (controlId) + { + case ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION: + case ExtendedFilePickerElementIds::CHECKBOX_PASSWORD: + case ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS: + case ExtendedFilePickerElementIds::CHECKBOX_READONLY: + case ExtendedFilePickerElementIds::CHECKBOX_LINK: + case ExtendedFilePickerElementIds::CHECKBOX_PREVIEW: + case ExtendedFilePickerElementIds::CHECKBOX_SELECTION: + { + QCheckBox* cb = dynamic_cast(widget); + cb->setText(toQString(label)); + break; + } + case ExtendedFilePickerElementIds::PUSHBUTTON_PLAY: + case ExtendedFilePickerElementIds::LISTBOX_VERSION: + case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE: + case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE: + case ExtendedFilePickerElementIds::LISTBOX_VERSION_LABEL: + case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE_LABEL: + case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE_LABEL: + case ExtendedFilePickerElementIds::LISTBOX_FILTER_SELECTOR: + break; + } + } +} + +rtl::OUString SAL_CALL KDE4FilePicker::getLabel(sal_Int16 controlId) + throw ( uno::RuntimeException ) +{ + QWidget* widget = _customWidgets[controlId]; + QString label; + + if (widget) + { + switch (controlId) + { + case ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION: + case ExtendedFilePickerElementIds::CHECKBOX_PASSWORD: + case ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS: + case ExtendedFilePickerElementIds::CHECKBOX_READONLY: + case ExtendedFilePickerElementIds::CHECKBOX_LINK: + case ExtendedFilePickerElementIds::CHECKBOX_PREVIEW: + case ExtendedFilePickerElementIds::CHECKBOX_SELECTION: + { + QCheckBox* cb = dynamic_cast(widget); + label = cb->text(); + break; + } + case ExtendedFilePickerElementIds::PUSHBUTTON_PLAY: + case ExtendedFilePickerElementIds::LISTBOX_VERSION: + case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE: + case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE: + case ExtendedFilePickerElementIds::LISTBOX_VERSION_LABEL: + case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE_LABEL: + case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE_LABEL: + case ExtendedFilePickerElementIds::LISTBOX_FILTER_SELECTOR: + break; + } + } + return toOUString(label); +} + +void KDE4FilePicker::addCustomControl(sal_Int16 controlId) +{ + QWidget* widget = 0; + sal_Int32 resId = -1; + + switch (controlId) + { + case ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION: + resId = STR_SVT_FILEPICKER_AUTO_EXTENSION; + break; + case ExtendedFilePickerElementIds::CHECKBOX_PASSWORD: + resId = STR_SVT_FILEPICKER_PASSWORD; + break; + case ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS: + resId = STR_SVT_FILEPICKER_FILTER_OPTIONS; + break; + case ExtendedFilePickerElementIds::CHECKBOX_READONLY: + resId = STR_SVT_FILEPICKER_READONLY; + break; + case ExtendedFilePickerElementIds::CHECKBOX_LINK: + resId = STR_SVT_FILEPICKER_INSERT_AS_LINK; + break; + case ExtendedFilePickerElementIds::CHECKBOX_PREVIEW: + resId = STR_SVT_FILEPICKER_SHOW_PREVIEW; + break; + case ExtendedFilePickerElementIds::CHECKBOX_SELECTION: + resId = STR_SVT_FILEPICKER_SELECTION; + break; + case ExtendedFilePickerElementIds::PUSHBUTTON_PLAY: + resId = STR_SVT_FILEPICKER_PLAY; + break; + case ExtendedFilePickerElementIds::LISTBOX_VERSION: + resId = STR_SVT_FILEPICKER_VERSION; + break; + case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE: + resId = STR_SVT_FILEPICKER_TEMPLATES; + break; + case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE: + resId = STR_SVT_FILEPICKER_IMAGE_TEMPLATE; + break; + case ExtendedFilePickerElementIds::LISTBOX_VERSION_LABEL: + case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE_LABEL: + case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE_LABEL: + case ExtendedFilePickerElementIds::LISTBOX_FILTER_SELECTOR: + break; + } + + switch (controlId) + { + case ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION: + case ExtendedFilePickerElementIds::CHECKBOX_PASSWORD: + case ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS: + case ExtendedFilePickerElementIds::CHECKBOX_READONLY: + case ExtendedFilePickerElementIds::CHECKBOX_LINK: + case ExtendedFilePickerElementIds::CHECKBOX_PREVIEW: + case ExtendedFilePickerElementIds::CHECKBOX_SELECTION: + { + QString label; + + if (_resMgr && resId != -1) + { + rtl::OUString s = String(ResId( resId, *_resMgr )); + label = toQString(s); + label.replace("~", "&"); + } + + widget = new QCheckBox(label, _extraControls); + + break; + } + case ExtendedFilePickerElementIds::PUSHBUTTON_PLAY: + case ExtendedFilePickerElementIds::LISTBOX_VERSION: + case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE: + case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE: + case ExtendedFilePickerElementIds::LISTBOX_VERSION_LABEL: + case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE_LABEL: + case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE_LABEL: + case ExtendedFilePickerElementIds::LISTBOX_FILTER_SELECTOR: + break; + } + + if (widget) + { + _layout->addWidget(widget); + _customWidgets.insert(controlId, widget); + } +} + +void SAL_CALL KDE4FilePicker::initialize( const uno::Sequence &args ) + throw( uno::Exception, uno::RuntimeException ) +{ + _filter.clear(); + _filters.clear(); + + // parameter checking + uno::Any arg; + if (args.getLength() == 0) + { + throw lang::IllegalArgumentException( + rtl::OUString::createFromAscii( "no arguments" ), + static_cast< XFilePicker* >( this ), 1 ); + } + + arg = args[0]; + + if (( arg.getValueType() != ::getCppuType((sal_Int16*)0)) && + ( arg.getValueType() != ::getCppuType((sal_Int8*)0))) + { + throw lang::IllegalArgumentException( + rtl::OUString::createFromAscii( "invalid argument type" ), + static_cast< XFilePicker* >( this ), 1 ); + } + + sal_Int16 templateId = -1; + arg >>= templateId; + + //default is opening + KFileDialog::OperationMode operationMode = KFileDialog::Opening; + + switch ( templateId ) + { + case FILEOPEN_SIMPLE: + break; + + case FILESAVE_SIMPLE: + operationMode = KFileDialog::Saving; + break; + + case FILESAVE_AUTOEXTENSION: + operationMode = KFileDialog::Saving; + addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION ); + break; + + case FILESAVE_AUTOEXTENSION_PASSWORD: + { + operationMode = KFileDialog::Saving; + addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION ); + addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_PASSWORD ); + break; + } + case FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS: + { + operationMode = KFileDialog::Saving; + addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION ); + addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_PASSWORD ); + addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS ); + break; + } + case FILESAVE_AUTOEXTENSION_SELECTION: + operationMode = KFileDialog::Saving; + addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION ); + addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_SELECTION ); + break; + + case FILESAVE_AUTOEXTENSION_TEMPLATE: + operationMode = KFileDialog::Saving; + addCustomControl( ExtendedFilePickerElementIds::LISTBOX_TEMPLATE ); + break; + + case FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE: + addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_LINK ); + addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_PREVIEW ); + addCustomControl( ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE ); + break; + + case FILEOPEN_PLAY: + addCustomControl( ExtendedFilePickerElementIds::PUSHBUTTON_PLAY ); + break; + + case FILEOPEN_READONLY_VERSION: + addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_READONLY ); + addCustomControl( ExtendedFilePickerElementIds::LISTBOX_VERSION ); + break; + + case FILEOPEN_LINK_PREVIEW: + addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_LINK ); + addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_PREVIEW ); + break; + + default: + throw lang::IllegalArgumentException( + rtl::OUString::createFromAscii( "Unknown template" ), + static_cast< XFilePicker* >( this ), + 1 ); + } + + _dialog->setOperationMode(operationMode); +} + +void SAL_CALL KDE4FilePicker::cancel() + throw ( uno::RuntimeException ) +{ + +} + +void SAL_CALL KDE4FilePicker::disposing( const lang::EventObject &rEvent ) + throw( uno::RuntimeException ) +{ + uno::Reference xFilePickerListener( rEvent.Source, uno::UNO_QUERY ); + + if ( xFilePickerListener.is() ) + { + removeFilePickerListener( xFilePickerListener ); + } +} + +rtl::OUString SAL_CALL KDE4FilePicker::getImplementationName() + throw( uno::RuntimeException ) +{ + return rtl::OUString::createFromAscii( FILE_PICKER_IMPL_NAME ); +} + +sal_Bool SAL_CALL KDE4FilePicker::supportsService( const rtl::OUString& ServiceName ) + throw( uno::RuntimeException ) +{ + uno::Sequence< ::rtl::OUString > SupportedServicesNames = FilePicker_getSupportedServiceNames(); + + for ( sal_Int32 n = SupportedServicesNames.getLength(); n--; ) + { + if ( SupportedServicesNames[n].compareTo( ServiceName ) == 0 ) + return sal_True; + } + + return sal_False; +} + +uno::Sequence< ::rtl::OUString > SAL_CALL KDE4FilePicker::getSupportedServiceNames() + throw( uno::RuntimeException ) +{ + return FilePicker_getSupportedServiceNames(); +} diff --git a/fpicker/source/unx/kde4/KDE4FilePicker.hxx b/fpicker/source/unx/kde4/KDE4FilePicker.hxx new file mode 100644 index 000000000000..da355852798a --- /dev/null +++ b/fpicker/source/unx/kde4/KDE4FilePicker.hxx @@ -0,0 +1,205 @@ +/************************************************************************* + * + * + * + * + * + * + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): Jan Holesovsky + * + * + ************************************************************************/ + +#pragma once + +#include + +#include +#include +#include +#include +#include +#include +//#include +#include + +#include +#include + +#include + +#include +#include + +class KFileDialog; +class QWidget; +class QLayout; + +class ResMgr; + +class KDE4FilePicker : + public cppu::WeakComponentImplHelper8< + ::com::sun::star::ui::dialogs::XFilterManager, + ::com::sun::star::ui::dialogs::XFilterGroupManager, + ::com::sun::star::ui::dialogs::XFilePickerControlAccess, + ::com::sun::star::ui::dialogs::XFilePickerNotifier, +// TODO ::com::sun::star::ui::dialogs::XFilePreview, + ::com::sun::star::lang::XInitialization, + ::com::sun::star::util::XCancellable, + ::com::sun::star::lang::XEventListener, + ::com::sun::star::lang::XServiceInfo > +{ +protected: + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceMgr; // to instanciate own services + + ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener > m_xListener; + + ResMgr *_resMgr; + + //the dialog to display + KFileDialog* _dialog; + + osl::Mutex _helperMutex; + + //running filter string to add to dialog + QString _filter; + + //filter for reverse lookup of filter text + QHash _filters; + + //mapping of SAL control ID's to created custom controls + QHash _customWidgets; + + //widget to contain extra custom controls + QWidget* _extraControls; + + //layout for extra custom controls + QLayout* _layout; + +public: + KDE4FilePicker( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceMgr ); + virtual ~KDE4FilePicker(); + + // XFilePickerNotifier + + virtual void SAL_CALL addFilePickerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener >& xListener ) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeFilePickerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener >& xListener ) throw( ::com::sun::star::uno::RuntimeException ); + + // XExecutableDialog functions + + virtual void SAL_CALL setTitle( const ::rtl::OUString &rTitle ) throw( ::com::sun::star::uno::RuntimeException ); + virtual sal_Int16 SAL_CALL execute() throw( ::com::sun::star::uno::RuntimeException ); + + // XFilePicker functions + + virtual void SAL_CALL setMultiSelectionMode( sal_Bool bMode ) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL setDefaultName( const ::rtl::OUString &rName ) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL setDisplayDirectory( const ::rtl::OUString &rDirectory ) throw( ::com::sun::star::uno::RuntimeException ); + virtual ::rtl::OUString SAL_CALL getDisplayDirectory() throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getFiles() throw( ::com::sun::star::uno::RuntimeException ); + + // XFilterManager functions + + virtual void SAL_CALL appendFilter( const ::rtl::OUString &rTitle, const ::rtl::OUString &rFilter ) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL setCurrentFilter( const ::rtl::OUString &rTitle ) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); + virtual ::rtl::OUString SAL_CALL getCurrentFilter() throw( ::com::sun::star::uno::RuntimeException ); + + // XFilterGroupManager functions + + virtual void SAL_CALL appendFilterGroup( const ::rtl::OUString &rGroupTitle, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::StringPair > &rFilters ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + + // XFilePickerControlAccess functions + + virtual void SAL_CALL setValue( sal_Int16 nControlId, sal_Int16 nControlAction, const ::com::sun::star::uno::Any &rValue ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getValue( sal_Int16 nControlId, sal_Int16 nControlAction ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL enableControl( sal_Int16 nControlId, sal_Bool bEnable ) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL setLabel( sal_Int16 nControlId, const ::rtl::OUString &rLabel ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getLabel( sal_Int16 nControlId ) throw (::com::sun::star::uno::RuntimeException); + + /* TODO XFilePreview + + virtual ::com::sun::star::uno::Sequence< sal_Int16 > SAL_CALL getSupportedImageFormats( ) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getTargetColorDepth( ) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getAvailableWidth( ) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getAvailableHeight( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setImage( sal_Int16 aImageFormat, const ::com::sun::star::uno::Any &rImage ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL setShowState( sal_Bool bShowState ) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL getShowState( ) throw (::com::sun::star::uno::RuntimeException); + */ + + // XInitialization + + virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > &rArguments ) throw( ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException ); + + // XCancellable + + virtual void SAL_CALL cancel( ) throw( ::com::sun::star::uno::RuntimeException ); + + // XEventListener + + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject &rEvent ) throw( ::com::sun::star::uno::RuntimeException ); + + // XServiceInfo + + virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString &rServiceName ) throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ); + +private: + // prevent copy and assignment + KDE4FilePicker( const KDE4FilePicker& ); + KDE4FilePicker& operator=( const KDE4FilePicker& ); + + //add a custom control widget to the file dialog + void addCustomControl(sal_Int16 controlId); + +}; diff --git a/fpicker/source/unx/kde4/fps-kde4-ucd.txt b/fpicker/source/unx/kde4/fps-kde4-ucd.txt new file mode 100644 index 000000000000..8ecc4e0a0a52 --- /dev/null +++ b/fpicker/source/unx/kde4/fps-kde4-ucd.txt @@ -0,0 +1,6 @@ +[ComponentDescriptor] +ImplementationName=com.sun.star.ui.dialogs.KDE4FilePicker +ComponentName=fps_kde4.uno.so +LoaderName=com.sun.star.loader.SharedLibrary +[SupportedServices] +com.sun.star.ui.dialogs.KDE4FilePicker diff --git a/fpicker/source/unx/kde4/fps_kde4.xml b/fpicker/source/unx/kde4/fps_kde4.xml new file mode 100644 index 000000000000..a12bf894186a --- /dev/null +++ b/fpicker/source/unx/kde4/fps_kde4.xml @@ -0,0 +1,51 @@ + + + + fps_kde4 + + Jan Holesovsky + com.sun.star.comp.ui.dialogs.FilePicker + + The KDE implementation of the FilePicker service. + + com.sun.star.loader.SharedLibrary + c++ + + com.sun.star.ui.dialogs.FilePicker + ... + com.sun.star.ui.dialogs.XExecutableDialog + com.sun.star.ui.dialogs.XFilePicker + com.sun.star.ui.dialogs.XFilterManager + com.sun.star.ui.dialogs.XFilterGroupManager + com.sun.star.ui.dialogs.XFilePickerListener + com.sun.star.ui.dialogs.ExecutableDialogException + com.sun.star.ui.dialogs.XFilePickerNotifier + com.sun.star.ui.dialogs.XFilePickerControlAccess + com.sun.star.ui.dialogs.XFilePreview + com.sun.star.ui.dialogs.ExtendedFilePickerElementIds + com.sun.star.ui.dialogs.ExecutableDialogResults + com.sun.star.ui.dialogs.FilePickerEvent + com.sun.star.ui.dialogs.CommonFilePickerElementIds + com.sun.star.ui.dialogs.ListboxControlActions + com.sun.star.ui.dialogs.TemplateDescription + com.sun.star.ui.dialogs.FilePreviewImageFormats + com.sun.star.util.XCancellable + com.sun.star.lang.XComponent + com.sun.star.lang.XMultiServiceFactory + com.sun.star.lang.XSingleServiceFactory + com.sun.star.lang.XServiceInfo + com.sun.star.lang.XTypeProvider + com.sun.star.lang.IllegalArgumentException + com.sun.star.uno.TypeClass + com.sun.star.uno.XWeak + com.sun.star.uno.XAggregation + com.sun.star.registry.XRegistryKey + com.sun.star.container.XSet + + cppuhelper + cppu + sal + cppuhelper + cppu2 + sal2 + diff --git a/fpicker/source/unx/kde4/makefile.mk b/fpicker/source/unx/kde4/makefile.mk new file mode 100644 index 000000000000..6f9db777bcb6 --- /dev/null +++ b/fpicker/source/unx/kde4/makefile.mk @@ -0,0 +1,117 @@ +#************************************************************************* +# +# +# +# +# +# +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/..$/.. + +PRJNAME=fpicker +TARGET=fps_kde4.uno +LIBTARGET=NO +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk +DLLPRE= + +# ------------------------------------------------------------------ + +# Currently just KDE is supported... +.IF "$(GUIBASE)" != "unx" || "$(ENABLE_KDE4)" != "TRUE" + +dummy: + @echo "Nothing to build. GUIBASE == $(GUIBASE), ENABLE_KDE4 is not set" + +.ELSE # we build for KDE + +CFLAGS+= $(KDE4_CFLAGS) + +# --- Files -------------------------------------------------------- + +SLOFILES =\ + $(SLO)$/KDE4FilePicker.obj \ + $(SLO)$/KDE4FilePicker.moc.obj \ + $(SLO)$/KDE4FPEntry.obj + +SHL1NOCHECK=TRUE +SHL1TARGET=$(TARGET) +SHL1STDLIBS=$(CPPULIB)\ + $(CPPUHELPERLIB)\ + $(SALLIB)\ + $(VCLLIB)\ + $(TOOLSLIB) \ + $(KDE4_LIBS) -lkio -lkfile + + +SHL1OBJS=$(SLOFILES) +SHL1DEF=$(MISC)$/$(SHL1TARGET).def + +DEF1NAME=$(SHL1TARGET) +DEF1VERSIONMAP=exports.map + +.ENDIF + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + +$(MISC)$/KDE4FilePicker.moc.cxx : KDE4FilePicker.hxx + $(MOC4) $< -o $@ diff --git a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx index 23467f148f4b..8b465513ca6a 100644 --- a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx +++ b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx @@ -40,6 +40,9 @@ #include #include #include +#ifdef __MINGW32__ +#include +#endif #include "..\misc\WinImplHelper.hxx" inline bool is_current_process_window(HWND hwnd) -- cgit