1*d119d52dSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*d119d52dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*d119d52dSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*d119d52dSAndrew Rist * distributed with this work for additional information 6*d119d52dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*d119d52dSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*d119d52dSAndrew Rist * "License"); you may not use this file except in compliance 9*d119d52dSAndrew Rist * with the License. You may obtain a copy of the License at 10*d119d52dSAndrew Rist * 11*d119d52dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*d119d52dSAndrew Rist * 13*d119d52dSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*d119d52dSAndrew Rist * software distributed under the License is distributed on an 15*d119d52dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*d119d52dSAndrew Rist * KIND, either express or implied. See the License for the 17*d119d52dSAndrew Rist * specific language governing permissions and limitations 18*d119d52dSAndrew Rist * under the License. 19*d119d52dSAndrew Rist * 20*d119d52dSAndrew Rist *************************************************************/ 21*d119d52dSAndrew Rist 22*d119d52dSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sfx2.hxx" 26cdf0e10cSrcweir #include <sfx2/filedlghelper.hxx> 27cdf0e10cSrcweir #include <sal/types.h> 28cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp> 29cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp> 30cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> 31cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> 32cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/FilePreviewImageFormats.hpp> 33cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/ControlActions.hpp> 34cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> 35cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XControlInformation.hpp> 36cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp> 37cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePickerNotifier.hpp> 38cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePreview.hpp> 39cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilterManager.hpp> 40cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilterGroupManager.hpp> 41cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFolderPicker.hpp> 42cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePicker2.hpp> 43cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp> 44cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 45cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 46cdf0e10cSrcweir #include <com/sun/star/beans/NamedValue.hpp> 47cdf0e10cSrcweir #include <com/sun/star/embed/ElementModes.hpp> 48cdf0e10cSrcweir #include <com/sun/star/container/XEnumeration.hpp> 49cdf0e10cSrcweir #include <com/sun/star/container/XContainerQuery.hpp> 50cdf0e10cSrcweir #include <com/sun/star/task/XInteractionRequest.hpp> 51cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp> 52cdf0e10cSrcweir 53cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 54cdf0e10cSrcweir #include <comphelper/types.hxx> 55cdf0e10cSrcweir #include <comphelper/sequenceashashmap.hxx> 56cdf0e10cSrcweir #include <comphelper/stillreadwriteinteraction.hxx> 57cdf0e10cSrcweir #include <tools/urlobj.hxx> 58cdf0e10cSrcweir #include <vcl/help.hxx> 59cdf0e10cSrcweir #include <unotools/ucbstreamhelper.hxx> 60cdf0e10cSrcweir #include <unotools/ucbhelper.hxx> 61cdf0e10cSrcweir #include <unotools/localfilehelper.hxx> 62cdf0e10cSrcweir #include <vos/thread.hxx> 63cdf0e10cSrcweir #include <vos/mutex.hxx> 64cdf0e10cSrcweir #include <vos/security.hxx> 65cdf0e10cSrcweir #include <vcl/cvtgrf.hxx> 66cdf0e10cSrcweir #include <vcl/msgbox.hxx> 67cdf0e10cSrcweir #include <vcl/mnemonic.hxx> 68cdf0e10cSrcweir #include <unotools/pathoptions.hxx> 69cdf0e10cSrcweir #include <unotools/securityoptions.hxx> 70cdf0e10cSrcweir #include <svl/itemset.hxx> 71cdf0e10cSrcweir #include <svl/eitem.hxx> 72cdf0e10cSrcweir #include <svl/intitem.hxx> 73cdf0e10cSrcweir #include <svl/stritem.hxx> 74cdf0e10cSrcweir #include <svtools/filter.hxx> 75cdf0e10cSrcweir #include <unotools/viewoptions.hxx> 76cdf0e10cSrcweir #include <unotools/moduleoptions.hxx> 77cdf0e10cSrcweir #include <svtools/helpid.hrc> 78cdf0e10cSrcweir #include <comphelper/docpasswordrequest.hxx> 79cdf0e10cSrcweir #include <comphelper/docpasswordhelper.hxx> 80cdf0e10cSrcweir #include <ucbhelper/content.hxx> 81cdf0e10cSrcweir #include <ucbhelper/commandenvironment.hxx> 82cdf0e10cSrcweir #include <comphelper/storagehelper.hxx> 83cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx> 84cdf0e10cSrcweir #include <sfx2/app.hxx> 85cdf0e10cSrcweir #include <sfx2/frame.hxx> 86cdf0e10cSrcweir #include <sfx2/docfile.hxx> 87cdf0e10cSrcweir #include <sfx2/docfac.hxx> 88cdf0e10cSrcweir #include "openflag.hxx" 89cdf0e10cSrcweir #include <sfx2/passwd.hxx> 90cdf0e10cSrcweir #include "sfx2/sfxresid.hxx" 91cdf0e10cSrcweir #include <sfx2/sfxsids.hrc> 92cdf0e10cSrcweir #include "filedlghelper.hrc" 93cdf0e10cSrcweir #include "filtergrouping.hxx" 94cdf0e10cSrcweir #include <sfx2/request.hxx> 95cdf0e10cSrcweir #include "filedlgimpl.hxx" 96cdf0e10cSrcweir #include <helpid.hrc> 97cdf0e10cSrcweir #include <sfxlocal.hrc> 98cdf0e10cSrcweir 99cdf0e10cSrcweir //----------------------------------------------------------------------------- 100cdf0e10cSrcweir 101cdf0e10cSrcweir using namespace ::com::sun::star; 102cdf0e10cSrcweir using namespace ::com::sun::star::container; 103cdf0e10cSrcweir using namespace ::com::sun::star::lang; 104cdf0e10cSrcweir using namespace ::com::sun::star::ui::dialogs; 105cdf0e10cSrcweir using namespace ::com::sun::star::ui::dialogs::TemplateDescription; 106cdf0e10cSrcweir using namespace ::com::sun::star::uno; 107cdf0e10cSrcweir using namespace ::com::sun::star::beans; 108cdf0e10cSrcweir using namespace ::rtl; 109cdf0e10cSrcweir using namespace ::cppu; 110cdf0e10cSrcweir 111cdf0e10cSrcweir //----------------------------------------------------------------------------- 112cdf0e10cSrcweir 113cdf0e10cSrcweir #define IODLG_CONFIGNAME String(DEFINE_CONST_UNICODE("FilePicker_Save")) 114cdf0e10cSrcweir #define IMPGRF_CONFIGNAME String(DEFINE_CONST_UNICODE("FilePicker_Graph")) 115cdf0e10cSrcweir #define USERITEM_NAME ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "UserItem" )) 116cdf0e10cSrcweir 117cdf0e10cSrcweir //----------------------------------------------------------------------------- 118cdf0e10cSrcweir 119cdf0e10cSrcweir namespace sfx2 120cdf0e10cSrcweir { 121cdf0e10cSrcweir 122cdf0e10cSrcweir const OUString* GetLastFilterConfigId( FileDialogHelper::Context _eContext ) 123cdf0e10cSrcweir { 124cdf0e10cSrcweir static const OUString aSD_EXPORT_IDENTIFIER( RTL_CONSTASCII_USTRINGPARAM( "SdExportLastFilter" ) ); 125cdf0e10cSrcweir static const OUString aSI_EXPORT_IDENTIFIER( RTL_CONSTASCII_USTRINGPARAM( "SiExportLastFilter" ) ); 126cdf0e10cSrcweir static const OUString aSW_EXPORT_IDENTIFIER( RTL_CONSTASCII_USTRINGPARAM( "SwExportLastFilter" ) ); 127cdf0e10cSrcweir 128cdf0e10cSrcweir const OUString* pRet = NULL; 129cdf0e10cSrcweir 130cdf0e10cSrcweir switch( _eContext ) 131cdf0e10cSrcweir { 132cdf0e10cSrcweir case FileDialogHelper::SD_EXPORT: pRet = &aSD_EXPORT_IDENTIFIER; break; 133cdf0e10cSrcweir case FileDialogHelper::SI_EXPORT: pRet = &aSI_EXPORT_IDENTIFIER; break; 134cdf0e10cSrcweir case FileDialogHelper::SW_EXPORT: pRet = &aSW_EXPORT_IDENTIFIER; break; 135cdf0e10cSrcweir default: break; 136cdf0e10cSrcweir } 137cdf0e10cSrcweir 138cdf0e10cSrcweir return pRet; 139cdf0e10cSrcweir } 140cdf0e10cSrcweir 141cdf0e10cSrcweir String EncodeSpaces_Impl( const String& rSource ); 142cdf0e10cSrcweir String DecodeSpaces_Impl( const String& rSource ); 143cdf0e10cSrcweir 144cdf0e10cSrcweir // ------------------------------------------------------------------------ 145cdf0e10cSrcweir // ----------- FileDialogHelper_Impl --------------------------- 146cdf0e10cSrcweir // ------------------------------------------------------------------------ 147cdf0e10cSrcweir 148cdf0e10cSrcweir // ------------------------------------------------------------------------ 149cdf0e10cSrcweir // XFilePickerListener Methods 150cdf0e10cSrcweir // ------------------------------------------------------------------------ 151cdf0e10cSrcweir void SAL_CALL FileDialogHelper_Impl::fileSelectionChanged( const FilePickerEvent& aEvent ) throw ( RuntimeException ) 152cdf0e10cSrcweir { 153cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 154cdf0e10cSrcweir mpAntiImpl->FileSelectionChanged( aEvent ); 155cdf0e10cSrcweir } 156cdf0e10cSrcweir 157cdf0e10cSrcweir // ------------------------------------------------------------------------ 158cdf0e10cSrcweir void SAL_CALL FileDialogHelper_Impl::directoryChanged( const FilePickerEvent& aEvent ) throw ( RuntimeException ) 159cdf0e10cSrcweir { 160cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 161cdf0e10cSrcweir mpAntiImpl->DirectoryChanged( aEvent ); 162cdf0e10cSrcweir } 163cdf0e10cSrcweir 164cdf0e10cSrcweir // ------------------------------------------------------------------------ 165cdf0e10cSrcweir OUString SAL_CALL FileDialogHelper_Impl::helpRequested( const FilePickerEvent& aEvent ) throw ( RuntimeException ) 166cdf0e10cSrcweir { 167cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 168cdf0e10cSrcweir return mpAntiImpl->HelpRequested( aEvent ); 169cdf0e10cSrcweir } 170cdf0e10cSrcweir 171cdf0e10cSrcweir // ------------------------------------------------------------------------ 172cdf0e10cSrcweir void SAL_CALL FileDialogHelper_Impl::controlStateChanged( const FilePickerEvent& aEvent ) throw ( RuntimeException ) 173cdf0e10cSrcweir { 174cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 175cdf0e10cSrcweir mpAntiImpl->ControlStateChanged( aEvent ); 176cdf0e10cSrcweir } 177cdf0e10cSrcweir 178cdf0e10cSrcweir // ------------------------------------------------------------------------ 179cdf0e10cSrcweir void SAL_CALL FileDialogHelper_Impl::dialogSizeChanged() throw ( RuntimeException ) 180cdf0e10cSrcweir { 181cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 182cdf0e10cSrcweir mpAntiImpl->DialogSizeChanged(); 183cdf0e10cSrcweir } 184cdf0e10cSrcweir 185cdf0e10cSrcweir // ------------------------------------------------------------------------ 186cdf0e10cSrcweir // XDialogClosedListener Methods 187cdf0e10cSrcweir // ------------------------------------------------------------------------ 188cdf0e10cSrcweir void SAL_CALL FileDialogHelper_Impl::dialogClosed( const DialogClosedEvent& _rEvent ) throw ( RuntimeException ) 189cdf0e10cSrcweir { 190cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 191cdf0e10cSrcweir mpAntiImpl->DialogClosed( _rEvent ); 192cdf0e10cSrcweir postExecute( _rEvent.DialogResult ); 193cdf0e10cSrcweir } 194cdf0e10cSrcweir 195cdf0e10cSrcweir // ------------------------------------------------------------------------ 196cdf0e10cSrcweir // handle XFilePickerListener events 197cdf0e10cSrcweir // ------------------------------------------------------------------------ 198cdf0e10cSrcweir void FileDialogHelper_Impl::handleFileSelectionChanged( const FilePickerEvent& ) 199cdf0e10cSrcweir { 200cdf0e10cSrcweir if ( mbHasVersions ) 201cdf0e10cSrcweir updateVersions(); 202cdf0e10cSrcweir 203cdf0e10cSrcweir if ( mbShowPreview ) 204cdf0e10cSrcweir maPreViewTimer.Start(); 205cdf0e10cSrcweir } 206cdf0e10cSrcweir 207cdf0e10cSrcweir // ------------------------------------------------------------------------ 208cdf0e10cSrcweir void FileDialogHelper_Impl::handleDirectoryChanged( const FilePickerEvent& ) 209cdf0e10cSrcweir { 210cdf0e10cSrcweir if ( mbShowPreview ) 211cdf0e10cSrcweir TimeOutHdl_Impl( NULL ); 212cdf0e10cSrcweir } 213cdf0e10cSrcweir 214cdf0e10cSrcweir // ------------------------------------------------------------------------ 215cdf0e10cSrcweir OUString FileDialogHelper_Impl::handleHelpRequested( const FilePickerEvent& aEvent ) 216cdf0e10cSrcweir { 217cdf0e10cSrcweir //!!! todo: cache the help strings (here or TRA) 218cdf0e10cSrcweir 219cdf0e10cSrcweir rtl::OString sHelpId; 220cdf0e10cSrcweir // mapping from element id -> help id 221cdf0e10cSrcweir switch ( aEvent.ElementId ) 222cdf0e10cSrcweir { 223cdf0e10cSrcweir case ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION : 224cdf0e10cSrcweir sHelpId = HID_FILESAVE_AUTOEXTENSION; 225cdf0e10cSrcweir break; 226cdf0e10cSrcweir 227cdf0e10cSrcweir case ExtendedFilePickerElementIds::CHECKBOX_PASSWORD : 228cdf0e10cSrcweir sHelpId = HID_FILESAVE_SAVEWITHPASSWORD; 229cdf0e10cSrcweir break; 230cdf0e10cSrcweir 231cdf0e10cSrcweir case ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS : 232cdf0e10cSrcweir sHelpId = HID_FILESAVE_CUSTOMIZEFILTER; 233cdf0e10cSrcweir break; 234cdf0e10cSrcweir 235cdf0e10cSrcweir case ExtendedFilePickerElementIds::CHECKBOX_READONLY : 236cdf0e10cSrcweir sHelpId = HID_FILEOPEN_READONLY; 237cdf0e10cSrcweir break; 238cdf0e10cSrcweir 239cdf0e10cSrcweir case ExtendedFilePickerElementIds::CHECKBOX_LINK : 240cdf0e10cSrcweir sHelpId = HID_FILEDLG_LINK_CB; 241cdf0e10cSrcweir break; 242cdf0e10cSrcweir 243cdf0e10cSrcweir case ExtendedFilePickerElementIds::CHECKBOX_PREVIEW : 244cdf0e10cSrcweir sHelpId = HID_FILEDLG_PREVIEW_CB; 245cdf0e10cSrcweir break; 246cdf0e10cSrcweir 247cdf0e10cSrcweir case ExtendedFilePickerElementIds::PUSHBUTTON_PLAY : 248cdf0e10cSrcweir sHelpId = HID_FILESAVE_DOPLAY; 249cdf0e10cSrcweir break; 250cdf0e10cSrcweir 251cdf0e10cSrcweir case ExtendedFilePickerElementIds::LISTBOX_VERSION_LABEL : 252cdf0e10cSrcweir case ExtendedFilePickerElementIds::LISTBOX_VERSION : 253cdf0e10cSrcweir sHelpId = HID_FILEOPEN_VERSION; 254cdf0e10cSrcweir break; 255cdf0e10cSrcweir 256cdf0e10cSrcweir case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE_LABEL : 257cdf0e10cSrcweir case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE : 258cdf0e10cSrcweir sHelpId = HID_FILESAVE_TEMPLATE; 259cdf0e10cSrcweir break; 260cdf0e10cSrcweir 261cdf0e10cSrcweir case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE_LABEL : 262cdf0e10cSrcweir case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE : 263cdf0e10cSrcweir sHelpId = HID_FILEOPEN_IMAGE_TEMPLATE; 264cdf0e10cSrcweir break; 265cdf0e10cSrcweir 266cdf0e10cSrcweir case ExtendedFilePickerElementIds::CHECKBOX_SELECTION : 267cdf0e10cSrcweir sHelpId = HID_FILESAVE_SELECTION; 268cdf0e10cSrcweir break; 269cdf0e10cSrcweir 270cdf0e10cSrcweir default: 271cdf0e10cSrcweir DBG_ERRORFILE( "invalid element id" ); 272cdf0e10cSrcweir } 273cdf0e10cSrcweir 274cdf0e10cSrcweir OUString aHelpText; 275cdf0e10cSrcweir Help* pHelp = Application::GetHelp(); 276cdf0e10cSrcweir if ( pHelp ) 277cdf0e10cSrcweir aHelpText = String( pHelp->GetHelpText( String( ByteString(sHelpId), RTL_TEXTENCODING_UTF8), NULL ) ); 278cdf0e10cSrcweir return aHelpText; 279cdf0e10cSrcweir } 280cdf0e10cSrcweir 281cdf0e10cSrcweir // ------------------------------------------------------------------------ 282cdf0e10cSrcweir void FileDialogHelper_Impl::handleControlStateChanged( const FilePickerEvent& aEvent ) 283cdf0e10cSrcweir { 284cdf0e10cSrcweir switch ( aEvent.ElementId ) 285cdf0e10cSrcweir { 286cdf0e10cSrcweir case CommonFilePickerElementIds::LISTBOX_FILTER: 287cdf0e10cSrcweir updateFilterOptionsBox(); 288cdf0e10cSrcweir enablePasswordBox( sal_False ); 289cdf0e10cSrcweir updateSelectionBox(); 290cdf0e10cSrcweir // only use it for export and with our own dialog 291cdf0e10cSrcweir if ( mbExport && !mbSystemPicker ) 292cdf0e10cSrcweir updateExportButton(); 293cdf0e10cSrcweir break; 294cdf0e10cSrcweir 295cdf0e10cSrcweir case ExtendedFilePickerElementIds::CHECKBOX_PREVIEW: 296cdf0e10cSrcweir updatePreviewState(); 297cdf0e10cSrcweir break; 298cdf0e10cSrcweir } 299cdf0e10cSrcweir } 300cdf0e10cSrcweir 301cdf0e10cSrcweir // ------------------------------------------------------------------------ 302cdf0e10cSrcweir void FileDialogHelper_Impl::handleDialogSizeChanged() 303cdf0e10cSrcweir { 304cdf0e10cSrcweir if ( mbShowPreview ) 305cdf0e10cSrcweir TimeOutHdl_Impl( NULL ); 306cdf0e10cSrcweir } 307cdf0e10cSrcweir 308cdf0e10cSrcweir // ------------------------------------------------------------------------ 309cdf0e10cSrcweir // XEventListener Methods 310cdf0e10cSrcweir // ------------------------------------------------------------------------ 311cdf0e10cSrcweir void SAL_CALL FileDialogHelper_Impl::disposing( const EventObject& ) throw ( RuntimeException ) 312cdf0e10cSrcweir { 313cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 314cdf0e10cSrcweir dispose(); 315cdf0e10cSrcweir } 316cdf0e10cSrcweir 317cdf0e10cSrcweir // ------------------------------------------------------------------------ 318cdf0e10cSrcweir // ------------------------------------------------------------------------ 319cdf0e10cSrcweir // ------------------------------------------------------------------------ 320cdf0e10cSrcweir void FileDialogHelper_Impl::dispose() 321cdf0e10cSrcweir { 322cdf0e10cSrcweir if ( mxFileDlg.is() ) 323cdf0e10cSrcweir { 324cdf0e10cSrcweir // remove the event listener 325cdf0e10cSrcweir uno::Reference< XFilePickerNotifier > xNotifier( mxFileDlg, UNO_QUERY ); 326cdf0e10cSrcweir if ( xNotifier.is() ) 327cdf0e10cSrcweir xNotifier->removeFilePickerListener( this ); 328cdf0e10cSrcweir 329cdf0e10cSrcweir ::comphelper::disposeComponent( mxFileDlg ); 330cdf0e10cSrcweir mxFileDlg.clear(); 331cdf0e10cSrcweir } 332cdf0e10cSrcweir } 333cdf0e10cSrcweir 334cdf0e10cSrcweir // ------------------------------------------------------------------------ 335cdf0e10cSrcweir String FileDialogHelper_Impl::getCurrentFilterUIName() const 336cdf0e10cSrcweir { 337cdf0e10cSrcweir String aFilterName; 338cdf0e10cSrcweir uno::Reference< XFilterManager > xFltMgr( mxFileDlg, UNO_QUERY ); 339cdf0e10cSrcweir 340cdf0e10cSrcweir if( xFltMgr.is() ) 341cdf0e10cSrcweir { 342cdf0e10cSrcweir aFilterName = xFltMgr->getCurrentFilter(); 343cdf0e10cSrcweir 344cdf0e10cSrcweir if ( aFilterName.Len() && isShowFilterExtensionEnabled() ) 345cdf0e10cSrcweir aFilterName = getFilterName( aFilterName ); 346cdf0e10cSrcweir } 347cdf0e10cSrcweir 348cdf0e10cSrcweir return aFilterName; 349cdf0e10cSrcweir } 350cdf0e10cSrcweir 351cdf0e10cSrcweir // ------------------------------------------------------------------------ 352cdf0e10cSrcweir void FileDialogHelper_Impl::LoadLastUsedFilter( const OUString& _rContextIdentifier ) 353cdf0e10cSrcweir { 354cdf0e10cSrcweir SvtViewOptions aDlgOpt( E_DIALOG, IODLG_CONFIGNAME ); 355cdf0e10cSrcweir 356cdf0e10cSrcweir if( aDlgOpt.Exists() ) 357cdf0e10cSrcweir { 358cdf0e10cSrcweir OUString aLastFilter; 359cdf0e10cSrcweir if( aDlgOpt.GetUserItem( _rContextIdentifier ) >>= aLastFilter ) 360cdf0e10cSrcweir setFilter( aLastFilter ); 361cdf0e10cSrcweir } 362cdf0e10cSrcweir } 363cdf0e10cSrcweir 364cdf0e10cSrcweir // ------------------------------------------------------------------------ 365cdf0e10cSrcweir void FileDialogHelper_Impl::SaveLastUsedFilter( const OUString& _rContextIdentifier ) 366cdf0e10cSrcweir { 367cdf0e10cSrcweir SvtViewOptions( E_DIALOG, IODLG_CONFIGNAME ).SetUserItem( _rContextIdentifier, 368cdf0e10cSrcweir makeAny( getFilterWithExtension( getFilter() ) ) ); 369cdf0e10cSrcweir } 370cdf0e10cSrcweir 371cdf0e10cSrcweir // ------------------------------------------------------------------------ 372cdf0e10cSrcweir void FileDialogHelper_Impl::SaveLastUsedFilter( void ) 373cdf0e10cSrcweir { 374cdf0e10cSrcweir const OUString* pConfigId = GetLastFilterConfigId( meContext ); 375cdf0e10cSrcweir if( pConfigId ) 376cdf0e10cSrcweir SaveLastUsedFilter( *pConfigId ); 377cdf0e10cSrcweir } 378cdf0e10cSrcweir 379cdf0e10cSrcweir // ------------------------------------------------------------------------ 380cdf0e10cSrcweir const SfxFilter* FileDialogHelper_Impl::getCurentSfxFilter() 381cdf0e10cSrcweir { 382cdf0e10cSrcweir String aFilterName = getCurrentFilterUIName(); 383cdf0e10cSrcweir 384cdf0e10cSrcweir const SfxFilter* pFilter = NULL; 385cdf0e10cSrcweir if ( mpMatcher && aFilterName.Len() ) 386cdf0e10cSrcweir pFilter = mpMatcher->GetFilter4UIName( aFilterName, m_nMustFlags, m_nDontFlags ); 387cdf0e10cSrcweir 388cdf0e10cSrcweir return pFilter; 389cdf0e10cSrcweir } 390cdf0e10cSrcweir 391cdf0e10cSrcweir // ------------------------------------------------------------------------ 392cdf0e10cSrcweir sal_Bool FileDialogHelper_Impl::updateExtendedControl( sal_Int16 _nExtendedControlId, sal_Bool _bEnable ) 393cdf0e10cSrcweir { 394cdf0e10cSrcweir sal_Bool bIsEnabled = sal_False; 395cdf0e10cSrcweir 396cdf0e10cSrcweir uno::Reference < XFilePickerControlAccess > xCtrlAccess( mxFileDlg, UNO_QUERY ); 397cdf0e10cSrcweir if ( xCtrlAccess.is() ) 398cdf0e10cSrcweir { 399cdf0e10cSrcweir try 400cdf0e10cSrcweir { 401cdf0e10cSrcweir xCtrlAccess->enableControl( _nExtendedControlId, _bEnable ); 402cdf0e10cSrcweir bIsEnabled = _bEnable; 403cdf0e10cSrcweir } 404cdf0e10cSrcweir catch( const IllegalArgumentException& ) 405cdf0e10cSrcweir { 406cdf0e10cSrcweir DBG_ERROR( "FileDialogHelper_Impl::updateExtendedControl: caught an exception!" ); 407cdf0e10cSrcweir } 408cdf0e10cSrcweir } 409cdf0e10cSrcweir return bIsEnabled; 410cdf0e10cSrcweir } 411cdf0e10cSrcweir 412cdf0e10cSrcweir // ------------------------------------------------------------------------ 413cdf0e10cSrcweir sal_Bool FileDialogHelper_Impl::CheckFilterOptionsCapability( const SfxFilter* _pFilter ) 414cdf0e10cSrcweir { 415cdf0e10cSrcweir sal_Bool bResult = sal_False; 416cdf0e10cSrcweir 417cdf0e10cSrcweir if( mxFilterCFG.is() && _pFilter ) 418cdf0e10cSrcweir { 419cdf0e10cSrcweir try { 420cdf0e10cSrcweir Sequence < PropertyValue > aProps; 421cdf0e10cSrcweir Any aAny = mxFilterCFG->getByName( _pFilter->GetName() ); 422cdf0e10cSrcweir if ( aAny >>= aProps ) 423cdf0e10cSrcweir { 424cdf0e10cSrcweir ::rtl::OUString aServiceName; 425cdf0e10cSrcweir sal_Int32 nPropertyCount = aProps.getLength(); 426cdf0e10cSrcweir for( sal_Int32 nProperty=0; nProperty < nPropertyCount; ++nProperty ) 427cdf0e10cSrcweir { 428cdf0e10cSrcweir if( aProps[nProperty].Name.equals( DEFINE_CONST_OUSTRING( "UIComponent") ) ) 429cdf0e10cSrcweir { 430cdf0e10cSrcweir aProps[nProperty].Value >>= aServiceName; 431cdf0e10cSrcweir if( aServiceName.getLength() ) 432cdf0e10cSrcweir bResult = sal_True; 433cdf0e10cSrcweir } 434cdf0e10cSrcweir } 435cdf0e10cSrcweir } 436cdf0e10cSrcweir } 437cdf0e10cSrcweir catch( Exception& ) 438cdf0e10cSrcweir { 439cdf0e10cSrcweir } 440cdf0e10cSrcweir } 441cdf0e10cSrcweir 442cdf0e10cSrcweir return bResult; 443cdf0e10cSrcweir } 444cdf0e10cSrcweir 445cdf0e10cSrcweir // ------------------------------------------------------------------------ 446cdf0e10cSrcweir sal_Bool FileDialogHelper_Impl::isInOpenMode() const 447cdf0e10cSrcweir { 448cdf0e10cSrcweir sal_Bool bRet = sal_False; 449cdf0e10cSrcweir 450cdf0e10cSrcweir switch ( m_nDialogType ) 451cdf0e10cSrcweir { 452cdf0e10cSrcweir case FILEOPEN_SIMPLE: 453cdf0e10cSrcweir case FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE: 454cdf0e10cSrcweir case FILEOPEN_PLAY: 455cdf0e10cSrcweir case FILEOPEN_READONLY_VERSION: 456cdf0e10cSrcweir case FILEOPEN_LINK_PREVIEW: 457cdf0e10cSrcweir bRet = sal_True; 458cdf0e10cSrcweir } 459cdf0e10cSrcweir 460cdf0e10cSrcweir return bRet; 461cdf0e10cSrcweir } 462cdf0e10cSrcweir 463cdf0e10cSrcweir // ------------------------------------------------------------------------ 464cdf0e10cSrcweir 465cdf0e10cSrcweir void FileDialogHelper_Impl::updateFilterOptionsBox() 466cdf0e10cSrcweir { 467cdf0e10cSrcweir if ( !m_bHaveFilterOptions ) 468cdf0e10cSrcweir return; 469cdf0e10cSrcweir 470cdf0e10cSrcweir updateExtendedControl( 471cdf0e10cSrcweir ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS, 472cdf0e10cSrcweir CheckFilterOptionsCapability( getCurentSfxFilter() ) 473cdf0e10cSrcweir ); 474cdf0e10cSrcweir } 475cdf0e10cSrcweir 476cdf0e10cSrcweir // ------------------------------------------------------------------------ 477cdf0e10cSrcweir 478cdf0e10cSrcweir void FileDialogHelper_Impl::updateExportButton() 479cdf0e10cSrcweir { 480cdf0e10cSrcweir uno::Reference < XFilePickerControlAccess > xCtrlAccess( mxFileDlg, UNO_QUERY ); 481cdf0e10cSrcweir if ( xCtrlAccess.is() ) 482cdf0e10cSrcweir { 483cdf0e10cSrcweir OUString sEllipses( RTL_CONSTASCII_USTRINGPARAM( "..." ) ); 484cdf0e10cSrcweir OUString sOldLabel( xCtrlAccess->getLabel( CommonFilePickerElementIds::PUSHBUTTON_OK ) ); 485cdf0e10cSrcweir 486cdf0e10cSrcweir // initialize button label; we need the label with the mnemonic char 487cdf0e10cSrcweir if ( !maButtonLabel.getLength() || maButtonLabel.indexOf( MNEMONIC_CHAR ) == -1 ) 488cdf0e10cSrcweir { 489cdf0e10cSrcweir // cut the ellipses, if necessary 490cdf0e10cSrcweir sal_Int32 nIndex = sOldLabel.indexOf( sEllipses ); 491cdf0e10cSrcweir if ( -1 == nIndex ) 492cdf0e10cSrcweir nIndex = sOldLabel.getLength(); 493cdf0e10cSrcweir maButtonLabel = sOldLabel.copy( 0, nIndex ); 494cdf0e10cSrcweir } 495cdf0e10cSrcweir 496cdf0e10cSrcweir OUString sLabel = maButtonLabel; 497cdf0e10cSrcweir // filter with options -> append ellipses on export button label 498cdf0e10cSrcweir if ( CheckFilterOptionsCapability( getCurentSfxFilter() ) ) 499cdf0e10cSrcweir sLabel += OUString( RTL_CONSTASCII_USTRINGPARAM( "..." ) ); 500cdf0e10cSrcweir 501cdf0e10cSrcweir if ( sOldLabel != sLabel ) 502cdf0e10cSrcweir { 503cdf0e10cSrcweir try 504cdf0e10cSrcweir { 505cdf0e10cSrcweir xCtrlAccess->setLabel( CommonFilePickerElementIds::PUSHBUTTON_OK, sLabel ); 506cdf0e10cSrcweir } 507cdf0e10cSrcweir catch( const IllegalArgumentException& ) 508cdf0e10cSrcweir { 509cdf0e10cSrcweir DBG_ERRORFILE( "FileDialogHelper_Impl::updateExportButton: caught an exception!" ); 510cdf0e10cSrcweir } 511cdf0e10cSrcweir } 512cdf0e10cSrcweir } 513cdf0e10cSrcweir } 514cdf0e10cSrcweir 515cdf0e10cSrcweir // ------------------------------------------------------------------------ 516cdf0e10cSrcweir void FileDialogHelper_Impl::updateSelectionBox() 517cdf0e10cSrcweir { 518cdf0e10cSrcweir if ( !mbHasSelectionBox ) 519cdf0e10cSrcweir return; 520cdf0e10cSrcweir 521cdf0e10cSrcweir // Does the selection box exist? 522cdf0e10cSrcweir sal_Bool bSelectionBoxFound = sal_False; 523cdf0e10cSrcweir uno::Reference< XControlInformation > xCtrlInfo( mxFileDlg, UNO_QUERY ); 524cdf0e10cSrcweir if ( xCtrlInfo.is() ) 525cdf0e10cSrcweir { 526cdf0e10cSrcweir Sequence< ::rtl::OUString > aCtrlList = xCtrlInfo->getSupportedControls(); 527cdf0e10cSrcweir sal_uInt32 nCount = aCtrlList.getLength(); 528cdf0e10cSrcweir for ( sal_uInt32 nCtrl = 0; nCtrl < nCount; ++nCtrl ) 529cdf0e10cSrcweir if ( aCtrlList[ nCtrl ].equalsAscii("SelectionBox") ) 530cdf0e10cSrcweir { 531cdf0e10cSrcweir bSelectionBoxFound = sal_False; 532cdf0e10cSrcweir break; 533cdf0e10cSrcweir } 534cdf0e10cSrcweir } 535cdf0e10cSrcweir 536cdf0e10cSrcweir if ( bSelectionBoxFound ) 537cdf0e10cSrcweir { 538cdf0e10cSrcweir const SfxFilter* pFilter = getCurentSfxFilter(); 539cdf0e10cSrcweir mbSelectionFltrEnabled = updateExtendedControl( 540cdf0e10cSrcweir ExtendedFilePickerElementIds::CHECKBOX_SELECTION, 541cdf0e10cSrcweir ( mbSelectionEnabled && pFilter && ( pFilter->GetFilterFlags() & SFX_FILTER_SUPPORTSSELECTION ) != 0 ) ); 542cdf0e10cSrcweir uno::Reference< XFilePickerControlAccess > xCtrlAccess( mxFileDlg, UNO_QUERY ); 543cdf0e10cSrcweir xCtrlAccess->setValue( ExtendedFilePickerElementIds::CHECKBOX_SELECTION, 0, makeAny( (sal_Bool)mbSelection ) ); 544cdf0e10cSrcweir } 545cdf0e10cSrcweir } 546cdf0e10cSrcweir 547cdf0e10cSrcweir // ------------------------------------------------------------------------ 548cdf0e10cSrcweir void FileDialogHelper_Impl::enablePasswordBox( sal_Bool bInit ) 549cdf0e10cSrcweir { 550cdf0e10cSrcweir if ( ! mbHasPassword ) 551cdf0e10cSrcweir return; 552cdf0e10cSrcweir 553cdf0e10cSrcweir sal_Bool bWasEnabled = mbIsPwdEnabled; 554cdf0e10cSrcweir 555cdf0e10cSrcweir const SfxFilter* pCurrentFilter = getCurentSfxFilter(); 556cdf0e10cSrcweir mbIsPwdEnabled = updateExtendedControl( 557cdf0e10cSrcweir ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, 558cdf0e10cSrcweir pCurrentFilter && ( pCurrentFilter->GetFilterFlags() & SFX_FILTER_ENCRYPTION ) 559cdf0e10cSrcweir ); 560cdf0e10cSrcweir 561cdf0e10cSrcweir if( bInit ) 562cdf0e10cSrcweir { 563cdf0e10cSrcweir // in case of inintialization previous state is not interesting 564cdf0e10cSrcweir if( mbIsPwdEnabled ) 565cdf0e10cSrcweir { 566cdf0e10cSrcweir uno::Reference< XFilePickerControlAccess > xCtrlAccess( mxFileDlg, UNO_QUERY ); 567cdf0e10cSrcweir if( mbPwdCheckBoxState ) 568cdf0e10cSrcweir xCtrlAccess->setValue( ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, 0, makeAny( sal_True ) ); 569cdf0e10cSrcweir } 570cdf0e10cSrcweir } 571cdf0e10cSrcweir else if( !bWasEnabled && mbIsPwdEnabled ) 572cdf0e10cSrcweir { 573cdf0e10cSrcweir uno::Reference< XFilePickerControlAccess > xCtrlAccess( mxFileDlg, UNO_QUERY ); 574cdf0e10cSrcweir if( mbPwdCheckBoxState ) 575cdf0e10cSrcweir xCtrlAccess->setValue( ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, 0, makeAny( sal_True ) ); 576cdf0e10cSrcweir } 577cdf0e10cSrcweir else if( bWasEnabled && !mbIsPwdEnabled ) 578cdf0e10cSrcweir { 579cdf0e10cSrcweir // remember user settings until checkbox is enabled 580cdf0e10cSrcweir uno::Reference< XFilePickerControlAccess > xCtrlAccess( mxFileDlg, UNO_QUERY ); 581cdf0e10cSrcweir Any aValue = xCtrlAccess->getValue( ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, 0 ); 582cdf0e10cSrcweir sal_Bool bPassWord = sal_False; 583cdf0e10cSrcweir mbPwdCheckBoxState = ( aValue >>= bPassWord ) && bPassWord; 584cdf0e10cSrcweir xCtrlAccess->setValue( ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, 0, makeAny( sal_False ) ); 585cdf0e10cSrcweir } 586cdf0e10cSrcweir } 587cdf0e10cSrcweir 588cdf0e10cSrcweir // ------------------------------------------------------------------------ 589cdf0e10cSrcweir void FileDialogHelper_Impl::updatePreviewState( sal_Bool _bUpdatePreviewWindow ) 590cdf0e10cSrcweir { 591cdf0e10cSrcweir if ( mbHasPreview ) 592cdf0e10cSrcweir { 593cdf0e10cSrcweir uno::Reference< XFilePickerControlAccess > xCtrlAccess( mxFileDlg, UNO_QUERY ); 594cdf0e10cSrcweir 595cdf0e10cSrcweir // check, wether or not we have to display a preview 596cdf0e10cSrcweir if ( xCtrlAccess.is() ) 597cdf0e10cSrcweir { 598cdf0e10cSrcweir try 599cdf0e10cSrcweir { 600cdf0e10cSrcweir Any aValue = xCtrlAccess->getValue( ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, 0 ); 601cdf0e10cSrcweir sal_Bool bShowPreview = sal_False; 602cdf0e10cSrcweir 603cdf0e10cSrcweir if ( aValue >>= bShowPreview ) 604cdf0e10cSrcweir { 605cdf0e10cSrcweir mbShowPreview = bShowPreview; 606cdf0e10cSrcweir 607cdf0e10cSrcweir // #97633 608cdf0e10cSrcweir // setShowState has currently no effect for the 609cdf0e10cSrcweir // OpenOffice FilePicker (see svtools/source/filepicker/iodlg.cxx) 610cdf0e10cSrcweir uno::Reference< XFilePreview > xFilePreview( mxFileDlg, UNO_QUERY ); 611cdf0e10cSrcweir if ( xFilePreview.is() ) 612cdf0e10cSrcweir xFilePreview->setShowState( mbShowPreview ); 613cdf0e10cSrcweir 614cdf0e10cSrcweir if ( _bUpdatePreviewWindow ) 615cdf0e10cSrcweir TimeOutHdl_Impl( NULL ); 616cdf0e10cSrcweir } 617cdf0e10cSrcweir } 618cdf0e10cSrcweir catch( Exception ) 619cdf0e10cSrcweir { 620cdf0e10cSrcweir DBG_ERRORFILE( "FileDialogHelper_Impl::updatePreviewState: caught an exception!" ); 621cdf0e10cSrcweir } 622cdf0e10cSrcweir } 623cdf0e10cSrcweir } 624cdf0e10cSrcweir } 625cdf0e10cSrcweir 626cdf0e10cSrcweir // ------------------------------------------------------------------------ 627cdf0e10cSrcweir void FileDialogHelper_Impl::updateVersions() 628cdf0e10cSrcweir { 629cdf0e10cSrcweir Sequence < OUString > aEntries; 630cdf0e10cSrcweir Sequence < OUString > aPathSeq = mxFileDlg->getFiles(); 631cdf0e10cSrcweir 632cdf0e10cSrcweir if ( aPathSeq.getLength() == 1 ) 633cdf0e10cSrcweir { 634cdf0e10cSrcweir INetURLObject aObj( aPathSeq[0] ); 635cdf0e10cSrcweir 636cdf0e10cSrcweir if ( ( aObj.GetProtocol() == INET_PROT_FILE ) && 637cdf0e10cSrcweir ( utl::UCBContentHelper::IsDocument( aObj.GetMainURL( INetURLObject::NO_DECODE ) ) ) ) 638cdf0e10cSrcweir { 639cdf0e10cSrcweir try 640cdf0e10cSrcweir { 641cdf0e10cSrcweir uno::Reference< embed::XStorage > xStorage = ::comphelper::OStorageHelper::GetStorageFromURL( 642cdf0e10cSrcweir aObj.GetMainURL( INetURLObject::NO_DECODE ), 643cdf0e10cSrcweir embed::ElementModes::READ ); 644cdf0e10cSrcweir 645cdf0e10cSrcweir DBG_ASSERT( xStorage.is(), "The method must return the storage or throw an exception!" ); 646cdf0e10cSrcweir if ( !xStorage.is() ) 647cdf0e10cSrcweir throw uno::RuntimeException(); 648cdf0e10cSrcweir 649cdf0e10cSrcweir uno::Sequence < util::RevisionTag > xVersions = SfxMedium::GetVersionList( xStorage ); 650cdf0e10cSrcweir 651cdf0e10cSrcweir aEntries.realloc( xVersions.getLength() + 1 ); 652cdf0e10cSrcweir aEntries[0] = OUString( String ( SfxResId( STR_SFX_FILEDLG_ACTUALVERSION ) ) ); 653cdf0e10cSrcweir 654cdf0e10cSrcweir for ( sal_Int32 i=0; i<xVersions.getLength(); i++ ) 655cdf0e10cSrcweir aEntries[ i + 1 ] = xVersions[i].Identifier; 656cdf0e10cSrcweir 657cdf0e10cSrcweir // TODO/LATER: not sure that this information must be shown in future ( binfilter? ) 658cdf0e10cSrcweir //REMOVE else 659cdf0e10cSrcweir //REMOVE { 660cdf0e10cSrcweir //REMOVE SfxFilterFlags nMust = SFX_FILTER_IMPORT | SFX_FILTER_OWN; 661cdf0e10cSrcweir //REMOVE SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED | SFX_FILTER_STARONEFILTER; 662cdf0e10cSrcweir //REMOVE if ( SFX_APP()->GetFilterMatcher().GetFilter4ClipBoardId( pStor->GetFormat(), nMust, nDont ) ) 663cdf0e10cSrcweir //REMOVE { 664cdf0e10cSrcweir //REMOVE aEntries.realloc( 1 ); 665cdf0e10cSrcweir //REMOVE aEntries[0] = OUString( String ( SfxResId( STR_SFX_FILEDLG_ACTUALVERSION ) ) ); 666cdf0e10cSrcweir //REMOVE } 667cdf0e10cSrcweir //REMOVE } 668cdf0e10cSrcweir } 669cdf0e10cSrcweir catch( uno::Exception& ) 670cdf0e10cSrcweir { 671cdf0e10cSrcweir } 672cdf0e10cSrcweir } 673cdf0e10cSrcweir } 674cdf0e10cSrcweir 675cdf0e10cSrcweir uno::Reference < XFilePickerControlAccess > xDlg( mxFileDlg, UNO_QUERY ); 676cdf0e10cSrcweir Any aValue; 677cdf0e10cSrcweir 678cdf0e10cSrcweir try 679cdf0e10cSrcweir { 680cdf0e10cSrcweir xDlg->setValue( ExtendedFilePickerElementIds::LISTBOX_VERSION, 681cdf0e10cSrcweir ControlActions::DELETE_ITEMS, aValue ); 682cdf0e10cSrcweir } 683cdf0e10cSrcweir catch( IllegalArgumentException ){} 684cdf0e10cSrcweir 685cdf0e10cSrcweir sal_Int32 nCount = aEntries.getLength(); 686cdf0e10cSrcweir 687cdf0e10cSrcweir if ( nCount ) 688cdf0e10cSrcweir { 689cdf0e10cSrcweir try 690cdf0e10cSrcweir { 691cdf0e10cSrcweir aValue <<= aEntries; 692cdf0e10cSrcweir xDlg->setValue( ExtendedFilePickerElementIds::LISTBOX_VERSION, 693cdf0e10cSrcweir ControlActions::ADD_ITEMS, aValue ); 694cdf0e10cSrcweir 695cdf0e10cSrcweir Any aPos; 696cdf0e10cSrcweir aPos <<= (sal_Int32) 0; 697cdf0e10cSrcweir xDlg->setValue( ExtendedFilePickerElementIds::LISTBOX_VERSION, 698cdf0e10cSrcweir ControlActions::SET_SELECT_ITEM, aPos ); 699cdf0e10cSrcweir } 700cdf0e10cSrcweir catch( IllegalArgumentException ){} 701cdf0e10cSrcweir } 702cdf0e10cSrcweir } 703cdf0e10cSrcweir 704cdf0e10cSrcweir // ----------------------------------------------------------------------- 705cdf0e10cSrcweir class OReleaseSolarMutex 706cdf0e10cSrcweir { 707cdf0e10cSrcweir private: 708cdf0e10cSrcweir const sal_Int32 m_nAquireCount; 709cdf0e10cSrcweir public: 710cdf0e10cSrcweir OReleaseSolarMutex( ) 711cdf0e10cSrcweir :m_nAquireCount( Application::ReleaseSolarMutex() ) 712cdf0e10cSrcweir { 713cdf0e10cSrcweir } 714cdf0e10cSrcweir ~OReleaseSolarMutex( ) 715cdf0e10cSrcweir { 716cdf0e10cSrcweir Application::AcquireSolarMutex( m_nAquireCount ); 717cdf0e10cSrcweir } 718cdf0e10cSrcweir }; 719cdf0e10cSrcweir 720cdf0e10cSrcweir // ----------------------------------------------------------------------- 721cdf0e10cSrcweir IMPL_LINK( FileDialogHelper_Impl, TimeOutHdl_Impl, Timer*, EMPTYARG ) 722cdf0e10cSrcweir { 723cdf0e10cSrcweir if ( !mbHasPreview ) 724cdf0e10cSrcweir return 0; 725cdf0e10cSrcweir 726cdf0e10cSrcweir maGraphic.Clear(); 727cdf0e10cSrcweir 728cdf0e10cSrcweir Any aAny; 729cdf0e10cSrcweir uno::Reference < XFilePreview > xFilePicker( mxFileDlg, UNO_QUERY ); 730cdf0e10cSrcweir 731cdf0e10cSrcweir if ( ! xFilePicker.is() ) 732cdf0e10cSrcweir return 0; 733cdf0e10cSrcweir 734cdf0e10cSrcweir Sequence < OUString > aPathSeq = mxFileDlg->getFiles(); 735cdf0e10cSrcweir 736cdf0e10cSrcweir if ( mbShowPreview && ( aPathSeq.getLength() == 1 ) ) 737cdf0e10cSrcweir { 738cdf0e10cSrcweir OUString aURL = aPathSeq[0]; 739cdf0e10cSrcweir 740cdf0e10cSrcweir if ( ERRCODE_NONE == getGraphic( aURL, maGraphic ) ) 741cdf0e10cSrcweir { 742cdf0e10cSrcweir // #89491 743cdf0e10cSrcweir // changed the code slightly; 744cdf0e10cSrcweir // before: the bitmap was scaled and 745cdf0e10cSrcweir // surrounded a white frame 746cdf0e10cSrcweir // now: the bitmap will only be scaled 747cdf0e10cSrcweir // and the filepicker implementation 748cdf0e10cSrcweir // is responsible for placing it at its 749cdf0e10cSrcweir // proper position and painting a frame 750cdf0e10cSrcweir 751cdf0e10cSrcweir Bitmap aBmp = maGraphic.GetBitmap(); 752cdf0e10cSrcweir 753cdf0e10cSrcweir // scale the bitmap to the correct size 754cdf0e10cSrcweir sal_Int32 nOutWidth = xFilePicker->getAvailableWidth(); 755cdf0e10cSrcweir sal_Int32 nOutHeight = xFilePicker->getAvailableHeight(); 756cdf0e10cSrcweir sal_Int32 nBmpWidth = aBmp.GetSizePixel().Width(); 757cdf0e10cSrcweir sal_Int32 nBmpHeight = aBmp.GetSizePixel().Height(); 758cdf0e10cSrcweir 759cdf0e10cSrcweir double nXRatio = (double) nOutWidth / nBmpWidth; 760cdf0e10cSrcweir double nYRatio = (double) nOutHeight / nBmpHeight; 761cdf0e10cSrcweir 762cdf0e10cSrcweir if ( nXRatio < nYRatio ) 763cdf0e10cSrcweir aBmp.Scale( nXRatio, nXRatio ); 764cdf0e10cSrcweir else 765cdf0e10cSrcweir aBmp.Scale( nYRatio, nYRatio ); 766cdf0e10cSrcweir 767cdf0e10cSrcweir // #94505# Convert to true color, to allow CopyPixel 768cdf0e10cSrcweir aBmp.Convert( BMP_CONVERSION_24BIT ); 769cdf0e10cSrcweir 770cdf0e10cSrcweir // and copy it into the Any 771cdf0e10cSrcweir SvMemoryStream aData; 772cdf0e10cSrcweir 773cdf0e10cSrcweir aData << aBmp; 774cdf0e10cSrcweir 775cdf0e10cSrcweir const Sequence < sal_Int8 > aBuffer( 776cdf0e10cSrcweir static_cast< const sal_Int8* >(aData.GetData()), 777cdf0e10cSrcweir aData.GetEndOfData() ); 778cdf0e10cSrcweir 779cdf0e10cSrcweir aAny <<= aBuffer; 780cdf0e10cSrcweir } 781cdf0e10cSrcweir } 782cdf0e10cSrcweir 783cdf0e10cSrcweir try 784cdf0e10cSrcweir { 785cdf0e10cSrcweir OReleaseSolarMutex aReleaseForCallback; 786cdf0e10cSrcweir // clear the preview window 787cdf0e10cSrcweir xFilePicker->setImage( FilePreviewImageFormats::BITMAP, aAny ); 788cdf0e10cSrcweir } 789cdf0e10cSrcweir catch( IllegalArgumentException ) 790cdf0e10cSrcweir { 791cdf0e10cSrcweir } 792cdf0e10cSrcweir 793cdf0e10cSrcweir return 0; 794cdf0e10cSrcweir } 795cdf0e10cSrcweir 796cdf0e10cSrcweir // ------------------------------------------------------------------------ 797cdf0e10cSrcweir ErrCode FileDialogHelper_Impl::getGraphic( const OUString& rURL, 798cdf0e10cSrcweir Graphic& rGraphic ) const 799cdf0e10cSrcweir { 800cdf0e10cSrcweir if ( utl::UCBContentHelper::IsFolder( rURL ) ) 801cdf0e10cSrcweir return ERRCODE_IO_NOTAFILE; 802cdf0e10cSrcweir 803cdf0e10cSrcweir if ( !mpGraphicFilter ) 804cdf0e10cSrcweir return ERRCODE_IO_NOTSUPPORTED; 805cdf0e10cSrcweir 806cdf0e10cSrcweir // select graphic filter from dialog filter selection 807cdf0e10cSrcweir OUString aCurFilter( getFilter() ); 808cdf0e10cSrcweir 809cdf0e10cSrcweir sal_uInt16 nFilter = aCurFilter.getLength() && mpGraphicFilter->GetImportFormatCount() 810cdf0e10cSrcweir ? mpGraphicFilter->GetImportFormatNumber( aCurFilter ) 811cdf0e10cSrcweir : GRFILTER_FORMAT_DONTKNOW; 812cdf0e10cSrcweir 813cdf0e10cSrcweir INetURLObject aURLObj( rURL ); 814cdf0e10cSrcweir 815cdf0e10cSrcweir if ( aURLObj.HasError() || INET_PROT_NOT_VALID == aURLObj.GetProtocol() ) 816cdf0e10cSrcweir { 817cdf0e10cSrcweir aURLObj.SetSmartProtocol( INET_PROT_FILE ); 818cdf0e10cSrcweir aURLObj.SetSmartURL( rURL ); 819cdf0e10cSrcweir } 820cdf0e10cSrcweir 821cdf0e10cSrcweir ErrCode nRet = ERRCODE_NONE; 822cdf0e10cSrcweir 823cdf0e10cSrcweir sal_uInt32 nFilterImportFlags = GRFILTER_I_FLAGS_SET_LOGSIZE_FOR_JPEG; 824cdf0e10cSrcweir // non-local? 825cdf0e10cSrcweir if ( INET_PROT_FILE != aURLObj.GetProtocol() ) 826cdf0e10cSrcweir { 827cdf0e10cSrcweir SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( rURL, STREAM_READ ); 828cdf0e10cSrcweir 829cdf0e10cSrcweir if( pStream ) 830cdf0e10cSrcweir nRet = mpGraphicFilter->ImportGraphic( rGraphic, rURL, *pStream, nFilter, NULL, nFilterImportFlags ); 831cdf0e10cSrcweir else 832cdf0e10cSrcweir nRet = mpGraphicFilter->ImportGraphic( rGraphic, aURLObj, nFilter, NULL, nFilterImportFlags ); 833cdf0e10cSrcweir delete pStream; 834cdf0e10cSrcweir } 835cdf0e10cSrcweir else 836cdf0e10cSrcweir { 837cdf0e10cSrcweir nRet = mpGraphicFilter->ImportGraphic( rGraphic, aURLObj, nFilter, NULL, nFilterImportFlags ); 838cdf0e10cSrcweir } 839cdf0e10cSrcweir 840cdf0e10cSrcweir return nRet; 841cdf0e10cSrcweir } 842cdf0e10cSrcweir 843cdf0e10cSrcweir // ------------------------------------------------------------------------ 844cdf0e10cSrcweir ErrCode FileDialogHelper_Impl::getGraphic( Graphic& rGraphic ) const 845cdf0e10cSrcweir { 846cdf0e10cSrcweir ErrCode nRet = ERRCODE_NONE; 847cdf0e10cSrcweir 848cdf0e10cSrcweir if ( ! maGraphic ) 849cdf0e10cSrcweir { 850cdf0e10cSrcweir OUString aPath;; 851cdf0e10cSrcweir Sequence < OUString > aPathSeq = mxFileDlg->getFiles(); 852cdf0e10cSrcweir 853cdf0e10cSrcweir if ( aPathSeq.getLength() == 1 ) 854cdf0e10cSrcweir { 855cdf0e10cSrcweir aPath = aPathSeq[0]; 856cdf0e10cSrcweir } 857cdf0e10cSrcweir 858cdf0e10cSrcweir if ( aPath.getLength() ) 859cdf0e10cSrcweir nRet = getGraphic( aPath, rGraphic ); 860cdf0e10cSrcweir else 861cdf0e10cSrcweir nRet = ERRCODE_IO_GENERAL; 862cdf0e10cSrcweir } 863cdf0e10cSrcweir else 864cdf0e10cSrcweir rGraphic = maGraphic; 865cdf0e10cSrcweir 866cdf0e10cSrcweir return nRet; 867cdf0e10cSrcweir } 868cdf0e10cSrcweir 869cdf0e10cSrcweir // ------------------------------------------------------------------------ 870cdf0e10cSrcweir sal_Bool lcl_isSystemFilePicker( const uno::Reference< XFilePicker >& _rxFP ) 871cdf0e10cSrcweir { 872cdf0e10cSrcweir try 873cdf0e10cSrcweir { 874cdf0e10cSrcweir uno::Reference< XServiceInfo > xSI( _rxFP, UNO_QUERY ); 875cdf0e10cSrcweir if ( xSI.is() && xSI->supportsService( DEFINE_CONST_OUSTRING( "com.sun.star.ui.dialogs.SystemFilePicker" ) ) ) 876cdf0e10cSrcweir return sal_True; 877cdf0e10cSrcweir } 878cdf0e10cSrcweir catch( const Exception& ) 879cdf0e10cSrcweir { 880cdf0e10cSrcweir } 881cdf0e10cSrcweir return sal_False; 882cdf0e10cSrcweir } 883cdf0e10cSrcweir 884cdf0e10cSrcweir 885cdf0e10cSrcweir // ------------------------------------------------------------------------ 886cdf0e10cSrcweir // ----------- FileDialogHelper_Impl --------------------------- 887cdf0e10cSrcweir // ------------------------------------------------------------------------ 888cdf0e10cSrcweir 889cdf0e10cSrcweir FileDialogHelper_Impl::FileDialogHelper_Impl( 890cdf0e10cSrcweir FileDialogHelper* _pAntiImpl, 891cdf0e10cSrcweir sal_Int16 nDialogType, 892cdf0e10cSrcweir sal_Int64 nFlags, 893cdf0e10cSrcweir sal_Int16 nDialog, 894cdf0e10cSrcweir Window* _pPreferredParentWindow, 895cdf0e10cSrcweir const String& sStandardDir, 896cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList 897cdf0e10cSrcweir ) 898cdf0e10cSrcweir :m_nDialogType ( nDialogType ) 899cdf0e10cSrcweir ,meContext ( FileDialogHelper::UNKNOWN_CONTEXT ) 900cdf0e10cSrcweir { 901cdf0e10cSrcweir const char* pServiceName=0; 902cdf0e10cSrcweir if ( nDialog == SFX2_IMPL_DIALOG_SYSTEM ) 903cdf0e10cSrcweir pServiceName = FILE_OPEN_SERVICE_NAME_OOO; 904cdf0e10cSrcweir else if ( nDialog == SFX2_IMPL_DIALOG_OOO ) 905cdf0e10cSrcweir pServiceName = FILE_OPEN_SERVICE_NAME_OOO; 906cdf0e10cSrcweir else 907cdf0e10cSrcweir pServiceName = FILE_OPEN_SERVICE_NAME; 908cdf0e10cSrcweir OUString aService = ::rtl::OUString::createFromAscii( pServiceName ); 909cdf0e10cSrcweir 910cdf0e10cSrcweir uno::Reference< XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); 911cdf0e10cSrcweir 912cdf0e10cSrcweir // create the file open dialog 913cdf0e10cSrcweir // the flags can be SFXWB_INSERT or SFXWB_MULTISELECTION 914cdf0e10cSrcweir 915cdf0e10cSrcweir mpPreferredParentWindow = _pPreferredParentWindow; 916cdf0e10cSrcweir mpAntiImpl = _pAntiImpl; 917cdf0e10cSrcweir mnError = ERRCODE_NONE; 918cdf0e10cSrcweir mbHasAutoExt = sal_False; 919cdf0e10cSrcweir mbHasPassword = sal_False; 920cdf0e10cSrcweir m_bHaveFilterOptions = sal_False; 921cdf0e10cSrcweir mbIsPwdEnabled = sal_True; 922cdf0e10cSrcweir mbHasVersions = sal_False; 923cdf0e10cSrcweir mbHasPreview = sal_False; 924cdf0e10cSrcweir mbShowPreview = sal_False; 925cdf0e10cSrcweir mbHasLink = sal_False; 926cdf0e10cSrcweir mbDeleteMatcher = sal_False; 927cdf0e10cSrcweir mbInsert = SFXWB_INSERT == ( nFlags & SFXWB_INSERT ); 928cdf0e10cSrcweir mbExport = SFXWB_EXPORT == ( nFlags & SFXWB_EXPORT ); 929cdf0e10cSrcweir mbIsSaveDlg = sal_False; 930cdf0e10cSrcweir mbPwdCheckBoxState = sal_False; 931cdf0e10cSrcweir mbSelection = sal_False; 932cdf0e10cSrcweir mbSelectionEnabled = sal_True; 933cdf0e10cSrcweir mbHasSelectionBox = sal_False; 934cdf0e10cSrcweir mbSelectionFltrEnabled = sal_False; 935cdf0e10cSrcweir 936cdf0e10cSrcweir // default settings 937cdf0e10cSrcweir m_nDontFlags = SFX_FILTER_INTERNAL | SFX_FILTER_NOTINFILEDLG | SFX_FILTER_NOTINSTALLED; 938cdf0e10cSrcweir if( WB_OPEN == ( nFlags & WB_OPEN ) ) 939cdf0e10cSrcweir m_nMustFlags = SFX_FILTER_IMPORT; 940cdf0e10cSrcweir else 941cdf0e10cSrcweir m_nMustFlags = SFX_FILTER_EXPORT; 942cdf0e10cSrcweir 943cdf0e10cSrcweir 944cdf0e10cSrcweir mpMatcher = NULL; 945cdf0e10cSrcweir mpGraphicFilter = NULL; 946cdf0e10cSrcweir mnPostUserEventId = 0; 947cdf0e10cSrcweir 948cdf0e10cSrcweir // create the picker component 949cdf0e10cSrcweir mxFileDlg = mxFileDlg.query( xFactory->createInstance( aService ) ); 950cdf0e10cSrcweir mbSystemPicker = lcl_isSystemFilePicker( mxFileDlg ); 951cdf0e10cSrcweir 952cdf0e10cSrcweir uno::Reference< XFilePickerNotifier > xNotifier( mxFileDlg, UNO_QUERY ); 953cdf0e10cSrcweir uno::Reference< XInitialization > xInit( mxFileDlg, UNO_QUERY ); 954cdf0e10cSrcweir 955cdf0e10cSrcweir if ( ! mxFileDlg.is() || ! xNotifier.is() ) 956cdf0e10cSrcweir { 957cdf0e10cSrcweir mnError = ERRCODE_ABORT; 958cdf0e10cSrcweir return; 959cdf0e10cSrcweir } 960cdf0e10cSrcweir 961cdf0e10cSrcweir 962cdf0e10cSrcweir if ( xInit.is() ) 963cdf0e10cSrcweir { 964cdf0e10cSrcweir sal_Int16 nTemplateDescription = TemplateDescription::FILEOPEN_SIMPLE; 965cdf0e10cSrcweir 966cdf0e10cSrcweir switch ( m_nDialogType ) 967cdf0e10cSrcweir { 968cdf0e10cSrcweir case FILEOPEN_SIMPLE: 969cdf0e10cSrcweir nTemplateDescription = TemplateDescription::FILEOPEN_SIMPLE; 970cdf0e10cSrcweir break; 971cdf0e10cSrcweir 972cdf0e10cSrcweir case FILESAVE_SIMPLE: 973cdf0e10cSrcweir nTemplateDescription = TemplateDescription::FILESAVE_SIMPLE; 974cdf0e10cSrcweir mbIsSaveDlg = sal_True; 975cdf0e10cSrcweir break; 976cdf0e10cSrcweir 977cdf0e10cSrcweir case FILESAVE_AUTOEXTENSION_PASSWORD: 978cdf0e10cSrcweir nTemplateDescription = TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD; 979cdf0e10cSrcweir mbHasPassword = sal_True; 980cdf0e10cSrcweir mbHasAutoExt = sal_True; 981cdf0e10cSrcweir mbIsSaveDlg = sal_True; 982cdf0e10cSrcweir break; 983cdf0e10cSrcweir 984cdf0e10cSrcweir case FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS: 985cdf0e10cSrcweir nTemplateDescription = TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS; 986cdf0e10cSrcweir mbHasPassword = sal_True; 987cdf0e10cSrcweir 988cdf0e10cSrcweir m_bHaveFilterOptions = sal_True; 989cdf0e10cSrcweir if( xFactory.is() ) 990cdf0e10cSrcweir { 991cdf0e10cSrcweir mxFilterCFG = uno::Reference< XNameAccess >( 992cdf0e10cSrcweir xFactory->createInstance( DEFINE_CONST_OUSTRING( "com.sun.star.document.FilterFactory" ) ), 993cdf0e10cSrcweir UNO_QUERY ); 994cdf0e10cSrcweir } 995cdf0e10cSrcweir 996cdf0e10cSrcweir mbHasAutoExt = sal_True; 997cdf0e10cSrcweir mbIsSaveDlg = sal_True; 998cdf0e10cSrcweir break; 999cdf0e10cSrcweir 1000cdf0e10cSrcweir case FILESAVE_AUTOEXTENSION_SELECTION: 1001cdf0e10cSrcweir nTemplateDescription = TemplateDescription::FILESAVE_AUTOEXTENSION_SELECTION; 1002cdf0e10cSrcweir mbHasAutoExt = sal_True; 1003cdf0e10cSrcweir mbIsSaveDlg = sal_True; 1004cdf0e10cSrcweir mbHasSelectionBox = sal_True; 1005cdf0e10cSrcweir if ( mbExport && !mxFilterCFG.is() && xFactory.is() ) 1006cdf0e10cSrcweir { 1007cdf0e10cSrcweir mxFilterCFG = uno::Reference< XNameAccess >( 1008cdf0e10cSrcweir xFactory->createInstance( DEFINE_CONST_OUSTRING( "com.sun.star.document.FilterFactory" ) ), 1009cdf0e10cSrcweir UNO_QUERY ); 1010cdf0e10cSrcweir } 1011cdf0e10cSrcweir break; 1012cdf0e10cSrcweir 1013cdf0e10cSrcweir case FILESAVE_AUTOEXTENSION_TEMPLATE: 1014cdf0e10cSrcweir nTemplateDescription = TemplateDescription::FILESAVE_AUTOEXTENSION_TEMPLATE; 1015cdf0e10cSrcweir mbHasAutoExt = sal_True; 1016cdf0e10cSrcweir mbIsSaveDlg = sal_True; 1017cdf0e10cSrcweir break; 1018cdf0e10cSrcweir 1019cdf0e10cSrcweir case FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE: 1020cdf0e10cSrcweir nTemplateDescription = TemplateDescription::FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE; 1021cdf0e10cSrcweir mbHasPreview = sal_True; 1022cdf0e10cSrcweir mbHasLink = sal_True; 1023cdf0e10cSrcweir 1024cdf0e10cSrcweir // aPreviewTimer 1025cdf0e10cSrcweir maPreViewTimer.SetTimeout( 500 ); 1026cdf0e10cSrcweir maPreViewTimer.SetTimeoutHdl( LINK( this, FileDialogHelper_Impl, TimeOutHdl_Impl ) ); 1027cdf0e10cSrcweir break; 1028cdf0e10cSrcweir 1029cdf0e10cSrcweir case FILEOPEN_PLAY: 1030cdf0e10cSrcweir nTemplateDescription = TemplateDescription::FILEOPEN_PLAY; 1031cdf0e10cSrcweir break; 1032cdf0e10cSrcweir 1033cdf0e10cSrcweir case FILEOPEN_READONLY_VERSION: 1034cdf0e10cSrcweir nTemplateDescription = TemplateDescription::FILEOPEN_READONLY_VERSION; 1035cdf0e10cSrcweir mbHasVersions = sal_True; 1036cdf0e10cSrcweir break; 1037cdf0e10cSrcweir 1038cdf0e10cSrcweir case FILEOPEN_LINK_PREVIEW: 1039cdf0e10cSrcweir nTemplateDescription = TemplateDescription::FILEOPEN_LINK_PREVIEW; 1040cdf0e10cSrcweir mbHasPreview = sal_True; 1041cdf0e10cSrcweir mbHasLink = sal_True; 1042cdf0e10cSrcweir // aPreviewTimer 1043cdf0e10cSrcweir maPreViewTimer.SetTimeout( 500 ); 1044cdf0e10cSrcweir maPreViewTimer.SetTimeoutHdl( LINK( this, FileDialogHelper_Impl, TimeOutHdl_Impl ) ); 1045cdf0e10cSrcweir break; 1046cdf0e10cSrcweir 1047cdf0e10cSrcweir case FILESAVE_AUTOEXTENSION: 1048cdf0e10cSrcweir nTemplateDescription = TemplateDescription::FILESAVE_AUTOEXTENSION; 1049cdf0e10cSrcweir mbHasAutoExt = sal_True; 1050cdf0e10cSrcweir mbIsSaveDlg = sal_True; 1051cdf0e10cSrcweir break; 1052cdf0e10cSrcweir 1053cdf0e10cSrcweir default: 1054cdf0e10cSrcweir DBG_ERRORFILE( "FileDialogHelper::ctor with unknown type" ); 1055cdf0e10cSrcweir break; 1056cdf0e10cSrcweir } 1057cdf0e10cSrcweir 1058cdf0e10cSrcweir 1059cdf0e10cSrcweir 1060cdf0e10cSrcweir //Sequence < Any > aInitArguments( mbSystemPicker || !mpPreferredParentWindow ? 1 : 3 ); 1061cdf0e10cSrcweir Sequence < Any > aInitArguments( !mpPreferredParentWindow ? 3 : 4 ); 1062cdf0e10cSrcweir 1063cdf0e10cSrcweir // This is a hack. We currently know that the internal file picker implementation 1064cdf0e10cSrcweir // supports the extended arguments as specified below. 1065cdf0e10cSrcweir // TODO: 1066cdf0e10cSrcweir // a) adjust the service description so that it includes the TemplateDescription and ParentWindow args 1067cdf0e10cSrcweir // b) adjust the implementation of the system file picker to that it recognizes it 1068cdf0e10cSrcweir if ( mbSystemPicker ) 1069cdf0e10cSrcweir { 1070cdf0e10cSrcweir aInitArguments[0] <<= nTemplateDescription; 1071cdf0e10cSrcweir } 1072cdf0e10cSrcweir else 1073cdf0e10cSrcweir { 1074cdf0e10cSrcweir aInitArguments[0] <<= NamedValue( 1075cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TemplateDescription" ) ), 1076cdf0e10cSrcweir makeAny( nTemplateDescription ) 1077cdf0e10cSrcweir ); 1078cdf0e10cSrcweir 1079cdf0e10cSrcweir ::rtl::OUString sStandardDirTemp = ::rtl::OUString( sStandardDir ); 1080cdf0e10cSrcweir 1081cdf0e10cSrcweir aInitArguments[1] <<= NamedValue( 1082cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StandardDir" ) ), 1083cdf0e10cSrcweir makeAny( sStandardDirTemp ) 1084cdf0e10cSrcweir ); 1085cdf0e10cSrcweir 1086cdf0e10cSrcweir aInitArguments[2] <<= NamedValue( 1087cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BlackList" ) ), 1088cdf0e10cSrcweir makeAny( rBlackList ) 1089cdf0e10cSrcweir ); 1090cdf0e10cSrcweir 1091cdf0e10cSrcweir 1092cdf0e10cSrcweir if ( mpPreferredParentWindow ) 1093cdf0e10cSrcweir aInitArguments[3] <<= NamedValue( 1094cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ParentWindow" ) ), 1095cdf0e10cSrcweir makeAny( VCLUnoHelper::GetInterface( mpPreferredParentWindow ) ) 1096cdf0e10cSrcweir ); 1097cdf0e10cSrcweir 1098cdf0e10cSrcweir 1099cdf0e10cSrcweir } 1100cdf0e10cSrcweir 1101cdf0e10cSrcweir try 1102cdf0e10cSrcweir { 1103cdf0e10cSrcweir xInit->initialize( aInitArguments ); 1104cdf0e10cSrcweir } 1105cdf0e10cSrcweir catch( const Exception& ) 1106cdf0e10cSrcweir { 1107cdf0e10cSrcweir DBG_ERROR( "FileDialogHelper_Impl::FileDialogHelper_Impl: could not initialize the picker!" ); 1108cdf0e10cSrcweir } 1109cdf0e10cSrcweir } 1110cdf0e10cSrcweir 1111cdf0e10cSrcweir 1112cdf0e10cSrcweir // set multiselection mode 1113cdf0e10cSrcweir if ( nFlags & SFXWB_MULTISELECTION ) 1114cdf0e10cSrcweir mxFileDlg->setMultiSelectionMode( sal_True ); 1115cdf0e10cSrcweir 1116cdf0e10cSrcweir if ( mbHasLink ) // generate graphic filter only on demand 1117cdf0e10cSrcweir addGraphicFilter(); 1118cdf0e10cSrcweir 1119cdf0e10cSrcweir // Export dialog 1120cdf0e10cSrcweir if ( mbExport ) 1121cdf0e10cSrcweir { 1122cdf0e10cSrcweir mxFileDlg->setTitle( OUString( String( SfxResId( STR_SFX_EXPLORERFILE_EXPORT ) ) ) ); 1123cdf0e10cSrcweir try { 1124cdf0e10cSrcweir com::sun::star::uno::Reference < XFilePickerControlAccess > xCtrlAccess( mxFileDlg, UNO_QUERY_THROW ); 1125cdf0e10cSrcweir xCtrlAccess->enableControl( ExtendedFilePickerElementIds::LISTBOX_FILTER_SELECTOR, sal_True ); 1126cdf0e10cSrcweir } 1127cdf0e10cSrcweir catch( const Exception & ) { } 1128cdf0e10cSrcweir } 1129cdf0e10cSrcweir 1130cdf0e10cSrcweir // the "insert file" dialog needs another title 1131cdf0e10cSrcweir if ( mbInsert ) 1132cdf0e10cSrcweir { 1133cdf0e10cSrcweir mxFileDlg->setTitle( OUString( String( SfxResId( STR_SFX_EXPLORERFILE_INSERT ) ) ) ); 1134cdf0e10cSrcweir uno::Reference < XFilePickerControlAccess > xExtDlg( mxFileDlg, UNO_QUERY ); 1135cdf0e10cSrcweir if ( xExtDlg.is() ) 1136cdf0e10cSrcweir { 1137cdf0e10cSrcweir try 1138cdf0e10cSrcweir { 1139cdf0e10cSrcweir xExtDlg->setLabel( CommonFilePickerElementIds::PUSHBUTTON_OK, 1140cdf0e10cSrcweir OUString( String( SfxResId( STR_SFX_EXPLORERFILE_BUTTONINSERT ) ) ) ); 1141cdf0e10cSrcweir } 1142cdf0e10cSrcweir catch( IllegalArgumentException ){} 1143cdf0e10cSrcweir } 1144cdf0e10cSrcweir } 1145cdf0e10cSrcweir 1146cdf0e10cSrcweir // add the event listener 1147cdf0e10cSrcweir xNotifier->addFilePickerListener( this ); 1148cdf0e10cSrcweir } 1149cdf0e10cSrcweir 1150cdf0e10cSrcweir // ------------------------------------------------------------------------ 1151cdf0e10cSrcweir FileDialogHelper_Impl::~FileDialogHelper_Impl() 1152cdf0e10cSrcweir { 1153cdf0e10cSrcweir // Remove user event if we haven't received it yet 1154cdf0e10cSrcweir if ( mnPostUserEventId ) 1155cdf0e10cSrcweir Application::RemoveUserEvent( mnPostUserEventId ); 1156cdf0e10cSrcweir mnPostUserEventId = 0; 1157cdf0e10cSrcweir 1158cdf0e10cSrcweir delete mpGraphicFilter; 1159cdf0e10cSrcweir 1160cdf0e10cSrcweir if ( mbDeleteMatcher ) 1161cdf0e10cSrcweir delete mpMatcher; 1162cdf0e10cSrcweir 1163cdf0e10cSrcweir maPreViewTimer.SetTimeoutHdl( Link() ); 1164cdf0e10cSrcweir 1165cdf0e10cSrcweir ::comphelper::disposeComponent( mxFileDlg ); 1166cdf0e10cSrcweir } 1167cdf0e10cSrcweir 1168cdf0e10cSrcweir #define nMagic -1 1169cdf0e10cSrcweir 1170cdf0e10cSrcweir class PickerThread_Impl : public ::vos::OThread 1171cdf0e10cSrcweir { 1172cdf0e10cSrcweir uno::Reference < XFilePicker > mxPicker; 1173cdf0e10cSrcweir ::vos::OMutex maMutex; 1174cdf0e10cSrcweir virtual void SAL_CALL run(); 1175cdf0e10cSrcweir sal_Int16 mnRet; 1176cdf0e10cSrcweir public: 1177cdf0e10cSrcweir PickerThread_Impl( const uno::Reference < XFilePicker >& rPicker ) 1178cdf0e10cSrcweir : mxPicker( rPicker ), mnRet(nMagic) {} 1179cdf0e10cSrcweir 1180cdf0e10cSrcweir sal_Int16 GetReturnValue() 1181cdf0e10cSrcweir { ::vos::OGuard aGuard( maMutex ); return mnRet; } 1182cdf0e10cSrcweir 1183cdf0e10cSrcweir void SetReturnValue( sal_Int16 aRetValue ) 1184cdf0e10cSrcweir { ::vos::OGuard aGuard( maMutex ); mnRet = aRetValue; } 1185cdf0e10cSrcweir }; 1186cdf0e10cSrcweir 1187cdf0e10cSrcweir void SAL_CALL PickerThread_Impl::run() 1188cdf0e10cSrcweir { 1189cdf0e10cSrcweir try 1190cdf0e10cSrcweir { 1191cdf0e10cSrcweir sal_Int16 n = mxPicker->execute(); 1192cdf0e10cSrcweir SetReturnValue( n ); 1193cdf0e10cSrcweir } 1194cdf0e10cSrcweir catch( RuntimeException& ) 1195cdf0e10cSrcweir { 1196cdf0e10cSrcweir SetReturnValue( ExecutableDialogResults::CANCEL ); 1197cdf0e10cSrcweir DBG_ERRORFILE( "RuntimeException caught" ); 1198cdf0e10cSrcweir } 1199cdf0e10cSrcweir } 1200cdf0e10cSrcweir 1201cdf0e10cSrcweir // ------------------------------------------------------------------------ 1202cdf0e10cSrcweir void FileDialogHelper_Impl::setControlHelpIds( const sal_Int16* _pControlId, const char** _pHelpId ) 1203cdf0e10cSrcweir { 1204cdf0e10cSrcweir DBG_ASSERT( _pControlId && _pHelpId, "FileDialogHelper_Impl::setControlHelpIds: invalid array pointers!" ); 1205cdf0e10cSrcweir if ( !_pControlId || !_pHelpId ) 1206cdf0e10cSrcweir return; 1207cdf0e10cSrcweir 1208cdf0e10cSrcweir // forward these ids to the file picker 1209cdf0e10cSrcweir try 1210cdf0e10cSrcweir { 1211cdf0e10cSrcweir const ::rtl::OUString sHelpIdPrefix( RTL_CONSTASCII_USTRINGPARAM( INET_HID_SCHEME ) ); 1212cdf0e10cSrcweir // the ids for the single controls 1213cdf0e10cSrcweir uno::Reference< XFilePickerControlAccess > xControlAccess( mxFileDlg, UNO_QUERY ); 1214cdf0e10cSrcweir if ( xControlAccess.is() ) 1215cdf0e10cSrcweir { 1216cdf0e10cSrcweir while ( *_pControlId ) 1217cdf0e10cSrcweir { 1218cdf0e10cSrcweir DBG_ASSERT( INetURLObject( rtl::OStringToOUString( *_pHelpId, RTL_TEXTENCODING_UTF8 ) ).GetProtocol() == INET_PROT_NOT_VALID, "Wrong HelpId!" ); 1219cdf0e10cSrcweir ::rtl::OUString sId( sHelpIdPrefix ); 1220cdf0e10cSrcweir sId += ::rtl::OUString( *_pHelpId, strlen( *_pHelpId ), RTL_TEXTENCODING_UTF8 ); 1221cdf0e10cSrcweir xControlAccess->setValue( *_pControlId, ControlActions::SET_HELP_URL, makeAny( sId ) ); 1222cdf0e10cSrcweir 1223cdf0e10cSrcweir ++_pControlId; ++_pHelpId; 1224cdf0e10cSrcweir } 1225cdf0e10cSrcweir } 1226cdf0e10cSrcweir } 1227cdf0e10cSrcweir catch( const Exception& ) 1228cdf0e10cSrcweir { 1229cdf0e10cSrcweir DBG_ERROR( "FileDialogHelper_Impl::setControlHelpIds: caught an exception while setting the help ids!" ); 1230cdf0e10cSrcweir } 1231cdf0e10cSrcweir } 1232cdf0e10cSrcweir 1233cdf0e10cSrcweir // ------------------------------------------------------------------------ 1234cdf0e10cSrcweir IMPL_LINK( FileDialogHelper_Impl, InitControls, void*, NOTINTERESTEDIN ) 1235cdf0e10cSrcweir { 1236cdf0e10cSrcweir (void)NOTINTERESTEDIN; 1237cdf0e10cSrcweir mnPostUserEventId = 0; 1238cdf0e10cSrcweir enablePasswordBox( sal_True ); 1239cdf0e10cSrcweir updateFilterOptionsBox( ); 1240cdf0e10cSrcweir updateSelectionBox( ); 1241cdf0e10cSrcweir 1242cdf0e10cSrcweir return 0L; 1243cdf0e10cSrcweir } 1244cdf0e10cSrcweir 1245cdf0e10cSrcweir // ------------------------------------------------------------------------ 1246cdf0e10cSrcweir void FileDialogHelper_Impl::preExecute() 1247cdf0e10cSrcweir { 1248cdf0e10cSrcweir loadConfig( ); 1249cdf0e10cSrcweir setDefaultValues( ); 1250cdf0e10cSrcweir updatePreviewState( sal_False ); 1251cdf0e10cSrcweir 1252cdf0e10cSrcweir implInitializeFileName( ); 1253cdf0e10cSrcweir // #106079# / 2002-12-09 / fs@openoffice.org 1254cdf0e10cSrcweir 1255cdf0e10cSrcweir #if !(defined(MACOSX) && defined(QUARTZ)) && !defined(WNT) 1256cdf0e10cSrcweir // allow for dialog implementations which need to be executed before they return valid values for 1257cdf0e10cSrcweir // current filter and such 1258cdf0e10cSrcweir 1259cdf0e10cSrcweir // On Vista (at least SP1) it's the same as on MacOSX, the modal dialog won't let message pass 1260cdf0e10cSrcweir // through before it returns from execution 1261cdf0e10cSrcweir mnPostUserEventId = Application::PostUserEvent( LINK( this, FileDialogHelper_Impl, InitControls ) ); 1262cdf0e10cSrcweir #else 1263cdf0e10cSrcweir // However, the Mac OS X implementation's pickers run modally in execute and so the event doesn't 1264cdf0e10cSrcweir // get through in time... so we call the methods directly 1265cdf0e10cSrcweir enablePasswordBox( sal_True ); 1266cdf0e10cSrcweir updateFilterOptionsBox( ); 1267cdf0e10cSrcweir updateSelectionBox( ); 1268cdf0e10cSrcweir #endif 1269cdf0e10cSrcweir } 1270cdf0e10cSrcweir 1271cdf0e10cSrcweir // ------------------------------------------------------------------------ 1272cdf0e10cSrcweir void FileDialogHelper_Impl::postExecute( sal_Int16 _nResult ) 1273cdf0e10cSrcweir { 1274cdf0e10cSrcweir if ( ExecutableDialogResults::CANCEL != _nResult ) 1275cdf0e10cSrcweir saveConfig(); 1276cdf0e10cSrcweir } 1277cdf0e10cSrcweir 1278cdf0e10cSrcweir // ------------------------------------------------------------------------ 1279cdf0e10cSrcweir void FileDialogHelper_Impl::implInitializeFileName( ) 1280cdf0e10cSrcweir { 1281cdf0e10cSrcweir if ( maFileName.getLength() ) 1282cdf0e10cSrcweir { 1283cdf0e10cSrcweir INetURLObject aObj( maPath ); 1284cdf0e10cSrcweir aObj.Append( maFileName ); 1285cdf0e10cSrcweir 1286cdf0e10cSrcweir // in case we're operating as save dialog, and "auto extension" is checked, 1287cdf0e10cSrcweir // cut the extension from the name 1288cdf0e10cSrcweir // #106079# / 2002-12-09 / fs@openoffice.org 1289cdf0e10cSrcweir if ( mbIsSaveDlg && mbHasAutoExt ) 1290cdf0e10cSrcweir { 1291cdf0e10cSrcweir try 1292cdf0e10cSrcweir { 1293cdf0e10cSrcweir sal_Bool bAutoExtChecked = sal_False; 1294cdf0e10cSrcweir 1295cdf0e10cSrcweir uno::Reference < XFilePickerControlAccess > xControlAccess( mxFileDlg, UNO_QUERY ); 1296cdf0e10cSrcweir if ( xControlAccess.is() 1297cdf0e10cSrcweir && ( xControlAccess->getValue( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0 ) 1298cdf0e10cSrcweir >>= bAutoExtChecked 1299cdf0e10cSrcweir ) 1300cdf0e10cSrcweir ) 1301cdf0e10cSrcweir { 1302cdf0e10cSrcweir if ( bAutoExtChecked ) 1303cdf0e10cSrcweir { // cut the extension 1304cdf0e10cSrcweir aObj.removeExtension( ); 1305cdf0e10cSrcweir mxFileDlg->setDefaultName( aObj.GetName( INetURLObject::DECODE_WITH_CHARSET ) ); 1306cdf0e10cSrcweir } 1307cdf0e10cSrcweir } 1308cdf0e10cSrcweir } 1309cdf0e10cSrcweir catch( const Exception& ) 1310cdf0e10cSrcweir { 1311cdf0e10cSrcweir DBG_ERROR( "FileDialogHelper_Impl::implInitializeFileName: could not ask for the auto-extension current-value!" ); 1312cdf0e10cSrcweir } 1313cdf0e10cSrcweir } 1314cdf0e10cSrcweir } 1315cdf0e10cSrcweir } 1316cdf0e10cSrcweir 1317cdf0e10cSrcweir // ------------------------------------------------------------------------ 1318cdf0e10cSrcweir sal_Int16 FileDialogHelper_Impl::implDoExecute() 1319cdf0e10cSrcweir { 1320cdf0e10cSrcweir preExecute(); 1321cdf0e10cSrcweir 1322cdf0e10cSrcweir sal_Int16 nRet = ExecutableDialogResults::CANCEL; 1323cdf0e10cSrcweir 1324cdf0e10cSrcweir //On MacOSX the native file picker has to run in the primordial thread because of drawing issues 1325cdf0e10cSrcweir //On Linux the native gtk file picker, when backed by gnome-vfs2, needs to be run in the same 1326cdf0e10cSrcweir //primordial thread as the ucb gnome-vfs2 provider was initialized in. 1327cdf0e10cSrcweir /* 1328cdf0e10cSrcweir #ifdef WNT 1329cdf0e10cSrcweir if ( mbSystemPicker ) 1330cdf0e10cSrcweir { 1331cdf0e10cSrcweir PickerThread_Impl* pThread = new PickerThread_Impl( mxFileDlg ); 1332cdf0e10cSrcweir pThread->create(); 1333cdf0e10cSrcweir while ( pThread->GetReturnValue() == nMagic ) 1334cdf0e10cSrcweir Application::Yield(); 1335cdf0e10cSrcweir pThread->join(); 1336cdf0e10cSrcweir nRet = pThread->GetReturnValue(); 1337cdf0e10cSrcweir delete pThread; 1338cdf0e10cSrcweir } 1339cdf0e10cSrcweir else 1340cdf0e10cSrcweir #endif 1341cdf0e10cSrcweir */ 1342cdf0e10cSrcweir { 1343cdf0e10cSrcweir try 1344cdf0e10cSrcweir { 1345cdf0e10cSrcweir #ifdef WNT 1346cdf0e10cSrcweir if ( mbSystemPicker ) 1347cdf0e10cSrcweir { 1348cdf0e10cSrcweir OReleaseSolarMutex aSolarMutex; 1349cdf0e10cSrcweir nRet = mxFileDlg->execute(); 1350cdf0e10cSrcweir } 1351cdf0e10cSrcweir else 1352cdf0e10cSrcweir #endif 1353cdf0e10cSrcweir nRet = mxFileDlg->execute(); 1354cdf0e10cSrcweir } 1355cdf0e10cSrcweir catch( const Exception& ) 1356cdf0e10cSrcweir { 1357cdf0e10cSrcweir DBG_ERRORFILE( "FileDialogHelper_Impl::implDoExecute: caught an exception!" ); 1358cdf0e10cSrcweir } 1359cdf0e10cSrcweir } 1360cdf0e10cSrcweir 1361cdf0e10cSrcweir postExecute( nRet ); 1362cdf0e10cSrcweir 1363cdf0e10cSrcweir return nRet; 1364cdf0e10cSrcweir } 1365cdf0e10cSrcweir 1366cdf0e10cSrcweir // ------------------------------------------------------------------------ 1367cdf0e10cSrcweir void FileDialogHelper_Impl::implStartExecute() 1368cdf0e10cSrcweir { 1369cdf0e10cSrcweir DBG_ASSERT( mxFileDlg.is(), "invalid file dialog" ); 1370cdf0e10cSrcweir 1371cdf0e10cSrcweir preExecute(); 1372cdf0e10cSrcweir 1373cdf0e10cSrcweir if ( mbSystemPicker ) 1374cdf0e10cSrcweir { 1375cdf0e10cSrcweir } 1376cdf0e10cSrcweir else 1377cdf0e10cSrcweir { 1378cdf0e10cSrcweir try 1379cdf0e10cSrcweir { 1380cdf0e10cSrcweir uno::Reference< XAsynchronousExecutableDialog > xAsyncDlg( mxFileDlg, UNO_QUERY ); 1381cdf0e10cSrcweir if ( xAsyncDlg.is() ) 1382cdf0e10cSrcweir xAsyncDlg->startExecuteModal( this ); 1383cdf0e10cSrcweir } 1384cdf0e10cSrcweir catch( const Exception& ) 1385cdf0e10cSrcweir { 1386cdf0e10cSrcweir DBG_ERRORFILE( "FileDialogHelper_Impl::implDoExecute: caught an exception!" ); 1387cdf0e10cSrcweir } 1388cdf0e10cSrcweir } 1389cdf0e10cSrcweir } 1390cdf0e10cSrcweir 1391cdf0e10cSrcweir // ------------------------------------------------------------------------ 1392cdf0e10cSrcweir String FileDialogHelper_Impl::implEnsureURLExtension(const String& sURL, 1393cdf0e10cSrcweir const String& /*sExtension*/) 1394cdf0e10cSrcweir { 1395cdf0e10cSrcweir return sURL; 1396cdf0e10cSrcweir /* 1397cdf0e10cSrcweir // This feature must be active for file save/export only ! 1398cdf0e10cSrcweir if ( 1399cdf0e10cSrcweir (! mbIsSaveDlg) && 1400cdf0e10cSrcweir (! mbExport ) 1401cdf0e10cSrcweir ) 1402cdf0e10cSrcweir return sURL; 1403cdf0e10cSrcweir 1404cdf0e10cSrcweir // no extension available (because "ALL *.*" was selected) ? 1405cdf0e10cSrcweir // Nod idea what else should happen here .-) 1406cdf0e10cSrcweir if (sExtension.Len() < 1) 1407cdf0e10cSrcweir return sURL; 1408cdf0e10cSrcweir 1409cdf0e10cSrcweir // Some FilePicker implementations already add the right extension ... 1410cdf0e10cSrcweir // or might be the user used the right one already ... 1411cdf0e10cSrcweir // Dont create duplicate extension. 1412cdf0e10cSrcweir INetURLObject aURL(sURL); 1413cdf0e10cSrcweir if (aURL.getExtension().equals(sExtension)) 1414cdf0e10cSrcweir return sURL; 1415cdf0e10cSrcweir 1416cdf0e10cSrcweir // Ignore any other extension set by the user. 1417cdf0e10cSrcweir // Make sure suitable extension is used always. 1418cdf0e10cSrcweir // e.g. "test.bla.odt" for "ODT" 1419cdf0e10cSrcweir ::rtl::OUStringBuffer sNewURL(256); 1420cdf0e10cSrcweir sNewURL.append (sURL ); 1421cdf0e10cSrcweir sNewURL.appendAscii("." ); 1422cdf0e10cSrcweir sNewURL.append (sExtension); 1423cdf0e10cSrcweir return sNewURL.makeStringAndClear(); 1424cdf0e10cSrcweir */ 1425cdf0e10cSrcweir } 1426cdf0e10cSrcweir 1427cdf0e10cSrcweir // ------------------------------------------------------------------------ 1428cdf0e10cSrcweir void lcl_saveLastURLs(SvStringsDtor*& rpURLList , 1429cdf0e10cSrcweir ::comphelper::SequenceAsVector< ::rtl::OUString >& lLastURLs ) 1430cdf0e10cSrcweir { 1431cdf0e10cSrcweir lLastURLs.clear(); 1432cdf0e10cSrcweir sal_uInt16 c = rpURLList->Count(); 1433cdf0e10cSrcweir sal_uInt16 i = 0; 1434cdf0e10cSrcweir for (i=0; i<c; ++i) 1435cdf0e10cSrcweir lLastURLs.push_back(*(rpURLList->GetObject(i))); 1436cdf0e10cSrcweir } 1437cdf0e10cSrcweir 1438cdf0e10cSrcweir // ------------------------------------------------------------------------ 1439cdf0e10cSrcweir void FileDialogHelper_Impl::implGetAndCacheFiles(const uno::Reference< XInterface >& xPicker , 1440cdf0e10cSrcweir SvStringsDtor*& rpURLList, 1441cdf0e10cSrcweir const SfxFilter* pFilter ) 1442cdf0e10cSrcweir { 1443cdf0e10cSrcweir rpURLList = NULL; 1444cdf0e10cSrcweir 1445cdf0e10cSrcweir String sExtension; 1446cdf0e10cSrcweir if (pFilter) 1447cdf0e10cSrcweir { 1448cdf0e10cSrcweir sExtension = pFilter->GetDefaultExtension (); 1449cdf0e10cSrcweir sExtension.EraseAllChars( '*' ); 1450cdf0e10cSrcweir sExtension.EraseAllChars( '.' ); 1451cdf0e10cSrcweir } 1452cdf0e10cSrcweir 1453cdf0e10cSrcweir // a) the new way (optional!) 1454cdf0e10cSrcweir uno::Reference< XFilePicker2 > xPickNew(xPicker, UNO_QUERY); 1455cdf0e10cSrcweir if (xPickNew.is()) 1456cdf0e10cSrcweir { 1457cdf0e10cSrcweir rpURLList = new SvStringsDtor; 1458cdf0e10cSrcweir Sequence< OUString > lFiles = xPickNew->getSelectedFiles(); 1459cdf0e10cSrcweir ::sal_Int32 nFiles = lFiles.getLength(); 1460cdf0e10cSrcweir for (::sal_Int32 i = 0; i < nFiles; i++) 1461cdf0e10cSrcweir { 1462cdf0e10cSrcweir String* pURL = new String(implEnsureURLExtension(lFiles[i], sExtension)); 1463cdf0e10cSrcweir rpURLList->Insert( pURL, rpURLList->Count() ); 1464cdf0e10cSrcweir } 1465cdf0e10cSrcweir } 1466cdf0e10cSrcweir 1467cdf0e10cSrcweir // b) the olde way ... non optional. 1468cdf0e10cSrcweir else 1469cdf0e10cSrcweir { 1470cdf0e10cSrcweir uno::Reference< XFilePicker > xPickOld(xPicker, UNO_QUERY_THROW); 1471cdf0e10cSrcweir Sequence< OUString > lFiles = xPickOld->getFiles(); 1472cdf0e10cSrcweir ::sal_Int32 nFiles = lFiles.getLength(); 1473cdf0e10cSrcweir if ( nFiles == 1 ) 1474cdf0e10cSrcweir { 1475cdf0e10cSrcweir rpURLList = new SvStringsDtor; 1476cdf0e10cSrcweir String* pURL = new String(implEnsureURLExtension(lFiles[0], sExtension)); 1477cdf0e10cSrcweir rpURLList->Insert( pURL, 0 ); 1478cdf0e10cSrcweir } 1479cdf0e10cSrcweir else 1480cdf0e10cSrcweir if ( nFiles > 1 ) 1481cdf0e10cSrcweir { 1482cdf0e10cSrcweir rpURLList = new SvStringsDtor; 1483cdf0e10cSrcweir 1484cdf0e10cSrcweir INetURLObject aPath( lFiles[0] ); 1485cdf0e10cSrcweir aPath.setFinalSlash(); 1486cdf0e10cSrcweir 1487cdf0e10cSrcweir for (::sal_Int32 i = 1; i < nFiles; i++) 1488cdf0e10cSrcweir { 1489cdf0e10cSrcweir if (i == 1) 1490cdf0e10cSrcweir aPath.Append( lFiles[i] ); 1491cdf0e10cSrcweir else 1492cdf0e10cSrcweir aPath.setName( lFiles[i] ); 1493cdf0e10cSrcweir 1494cdf0e10cSrcweir String* pURL = new String(implEnsureURLExtension(aPath.GetMainURL( INetURLObject::NO_DECODE ), sExtension) ); 1495cdf0e10cSrcweir rpURLList->Insert( pURL, rpURLList->Count() ); 1496cdf0e10cSrcweir } 1497cdf0e10cSrcweir } 1498cdf0e10cSrcweir } 1499cdf0e10cSrcweir 1500cdf0e10cSrcweir lcl_saveLastURLs(rpURLList, mlLastURLs); 1501cdf0e10cSrcweir } 1502cdf0e10cSrcweir 1503cdf0e10cSrcweir // ------------------------------------------------------------------------ 1504cdf0e10cSrcweir ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, 1505cdf0e10cSrcweir SfxItemSet *& rpSet, 1506cdf0e10cSrcweir String& rFilter ) 1507cdf0e10cSrcweir { 1508cdf0e10cSrcweir // rFilter is a pure output parameter, it shouldn't be used for anything else 1509cdf0e10cSrcweir // changing this would surely break code 1510cdf0e10cSrcweir // rpSet is in/out parameter, usually just a media-descriptor that can be changed by dialog 1511cdf0e10cSrcweir 1512cdf0e10cSrcweir uno::Reference< XFilePickerControlAccess > xCtrlAccess( mxFileDlg, UNO_QUERY ); 1513cdf0e10cSrcweir 1514cdf0e10cSrcweir // retrieves parameters from rpSet 1515cdf0e10cSrcweir // for now only Password is used 1516cdf0e10cSrcweir if ( rpSet ) 1517cdf0e10cSrcweir { 1518cdf0e10cSrcweir // check password checkbox if the document had password before 1519cdf0e10cSrcweir if( mbHasPassword ) 1520cdf0e10cSrcweir { 1521cdf0e10cSrcweir SFX_ITEMSET_ARG( rpSet, pPassItem, SfxBoolItem, SID_PASSWORDINTERACTION, sal_False ); 1522cdf0e10cSrcweir mbPwdCheckBoxState = ( pPassItem != NULL && pPassItem->GetValue() ); 1523cdf0e10cSrcweir 1524cdf0e10cSrcweir // in case the document has password to modify, the dialog should be shown 1525cdf0e10cSrcweir SFX_ITEMSET_ARG( rpSet, pPassToModifyItem, SfxUnoAnyItem, SID_MODIFYPASSWORDINFO, sal_False ); 1526cdf0e10cSrcweir mbPwdCheckBoxState |= ( pPassToModifyItem && pPassToModifyItem->GetValue().hasValue() ); 1527cdf0e10cSrcweir } 1528cdf0e10cSrcweir 1529cdf0e10cSrcweir SFX_ITEMSET_ARG( rpSet, pSelectItem, SfxBoolItem, SID_SELECTION, sal_False ); 1530cdf0e10cSrcweir if ( pSelectItem ) 1531cdf0e10cSrcweir mbSelection = pSelectItem->GetValue(); 1532cdf0e10cSrcweir else 1533cdf0e10cSrcweir mbSelectionEnabled = sal_False; 1534cdf0e10cSrcweir 1535cdf0e10cSrcweir // the password will be set in case user decide so 1536cdf0e10cSrcweir rpSet->ClearItem( SID_PASSWORDINTERACTION ); 1537cdf0e10cSrcweir rpSet->ClearItem( SID_PASSWORD ); 1538cdf0e10cSrcweir rpSet->ClearItem( SID_ENCRYPTIONDATA ); 1539cdf0e10cSrcweir rpSet->ClearItem( SID_RECOMMENDREADONLY ); 1540cdf0e10cSrcweir rpSet->ClearItem( SID_MODIFYPASSWORDINFO ); 1541cdf0e10cSrcweir 1542cdf0e10cSrcweir } 1543cdf0e10cSrcweir 1544cdf0e10cSrcweir if ( mbHasPassword && !mbPwdCheckBoxState ) 1545cdf0e10cSrcweir { 1546cdf0e10cSrcweir SvtSecurityOptions aSecOpt; 1547cdf0e10cSrcweir mbPwdCheckBoxState = ( 1548cdf0e10cSrcweir aSecOpt.IsOptionSet( SvtSecurityOptions::E_DOCWARN_RECOMMENDPASSWORD ) ); 1549cdf0e10cSrcweir } 1550cdf0e10cSrcweir 1551cdf0e10cSrcweir rpURLList = NULL; 1552cdf0e10cSrcweir 1553cdf0e10cSrcweir if ( ! mxFileDlg.is() ) 1554cdf0e10cSrcweir return ERRCODE_ABORT; 1555cdf0e10cSrcweir 1556cdf0e10cSrcweir if ( ExecutableDialogResults::CANCEL != implDoExecute() ) 1557cdf0e10cSrcweir { 1558cdf0e10cSrcweir // create an itemset if there is no 1559cdf0e10cSrcweir if( !rpSet ) 1560cdf0e10cSrcweir rpSet = new SfxAllItemSet( SFX_APP()->GetPool() ); 1561cdf0e10cSrcweir 1562cdf0e10cSrcweir // the item should remain only if it was set by the dialog 1563cdf0e10cSrcweir rpSet->ClearItem( SID_SELECTION ); 1564cdf0e10cSrcweir 1565cdf0e10cSrcweir if( mbExport && mbHasSelectionBox ) 1566cdf0e10cSrcweir { 1567cdf0e10cSrcweir try 1568cdf0e10cSrcweir { 1569cdf0e10cSrcweir Any aValue = xCtrlAccess->getValue( ExtendedFilePickerElementIds::CHECKBOX_SELECTION, 0 ); 1570cdf0e10cSrcweir sal_Bool bSelection = sal_False; 1571cdf0e10cSrcweir if ( aValue >>= bSelection ) 1572cdf0e10cSrcweir rpSet->Put( SfxBoolItem( SID_SELECTION, bSelection ) ); 1573cdf0e10cSrcweir } 1574cdf0e10cSrcweir catch( IllegalArgumentException ) 1575cdf0e10cSrcweir { 1576cdf0e10cSrcweir DBG_ERROR( "FileDialogHelper_Impl::execute: caught an IllegalArgumentException!" ); 1577cdf0e10cSrcweir } 1578cdf0e10cSrcweir } 1579cdf0e10cSrcweir 1580cdf0e10cSrcweir 1581cdf0e10cSrcweir // set the read-only flag. When inserting a file, this flag is always set 1582cdf0e10cSrcweir if ( mbInsert ) 1583cdf0e10cSrcweir rpSet->Put( SfxBoolItem( SID_DOC_READONLY, sal_True ) ); 1584cdf0e10cSrcweir else 1585cdf0e10cSrcweir { 1586cdf0e10cSrcweir if ( ( FILEOPEN_READONLY_VERSION == m_nDialogType ) && xCtrlAccess.is() ) 1587cdf0e10cSrcweir { 1588cdf0e10cSrcweir try 1589cdf0e10cSrcweir { 1590cdf0e10cSrcweir Any aValue = xCtrlAccess->getValue( ExtendedFilePickerElementIds::CHECKBOX_READONLY, 0 ); 1591cdf0e10cSrcweir sal_Bool bReadOnly = sal_False; 1592cdf0e10cSrcweir if ( ( aValue >>= bReadOnly ) && bReadOnly ) 1593cdf0e10cSrcweir rpSet->Put( SfxBoolItem( SID_DOC_READONLY, bReadOnly ) ); 1594cdf0e10cSrcweir } 1595cdf0e10cSrcweir catch( IllegalArgumentException ) 1596cdf0e10cSrcweir { 1597cdf0e10cSrcweir DBG_ERROR( "FileDialogHelper_Impl::execute: caught an IllegalArgumentException!" ); 1598cdf0e10cSrcweir } 1599cdf0e10cSrcweir } 1600cdf0e10cSrcweir } 1601cdf0e10cSrcweir if ( mbHasVersions && xCtrlAccess.is() ) 1602cdf0e10cSrcweir { 1603cdf0e10cSrcweir try 1604cdf0e10cSrcweir { 1605cdf0e10cSrcweir Any aValue = xCtrlAccess->getValue( ExtendedFilePickerElementIds::LISTBOX_VERSION, 1606cdf0e10cSrcweir ControlActions::GET_SELECTED_ITEM_INDEX ); 1607cdf0e10cSrcweir sal_Int32 nVersion = 0; 1608cdf0e10cSrcweir if ( ( aValue >>= nVersion ) && nVersion > 0 ) 1609cdf0e10cSrcweir // open a special version; 0 == current version 1610cdf0e10cSrcweir rpSet->Put( SfxInt16Item( SID_VERSION, (short)nVersion ) ); 1611cdf0e10cSrcweir } 1612cdf0e10cSrcweir catch( IllegalArgumentException ){} 1613cdf0e10cSrcweir } 1614cdf0e10cSrcweir 1615cdf0e10cSrcweir // set the filter 1616cdf0e10cSrcweir getRealFilter( rFilter ); 1617cdf0e10cSrcweir 1618cdf0e10cSrcweir const SfxFilter* pCurrentFilter = getCurentSfxFilter(); 1619cdf0e10cSrcweir 1620cdf0e10cSrcweir // fill the rpURLList 1621cdf0e10cSrcweir implGetAndCacheFiles( mxFileDlg, rpURLList, pCurrentFilter ); 1622cdf0e10cSrcweir if ( rpURLList == NULL || rpURLList->GetObject(0) == NULL ) 1623cdf0e10cSrcweir return ERRCODE_ABORT; 1624cdf0e10cSrcweir 1625cdf0e10cSrcweir // check, wether or not we have to display a password box 1626cdf0e10cSrcweir if ( pCurrentFilter && mbHasPassword && mbIsPwdEnabled && xCtrlAccess.is() ) 1627cdf0e10cSrcweir { 1628cdf0e10cSrcweir try 1629cdf0e10cSrcweir { 1630cdf0e10cSrcweir Any aValue = xCtrlAccess->getValue( ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, 0 ); 1631cdf0e10cSrcweir sal_Bool bPassWord = sal_False; 1632cdf0e10cSrcweir if ( ( aValue >>= bPassWord ) && bPassWord ) 1633cdf0e10cSrcweir { 1634cdf0e10cSrcweir // ask for a password 1635cdf0e10cSrcweir uno::Reference < ::com::sun::star::task::XInteractionHandler > xInteractionHandler( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.comp.uui.UUIInteractionHandler")), UNO_QUERY ); 1636cdf0e10cSrcweir 1637cdf0e10cSrcweir if( xInteractionHandler.is() ) 1638cdf0e10cSrcweir { 1639cdf0e10cSrcweir // TODO: need a save way to distinguish MS filters from other filters 1640cdf0e10cSrcweir // for now MS-filters are the only alien filters that support encryption 1641cdf0e10cSrcweir sal_Bool bMSType = !pCurrentFilter->IsOwnFormat(); 1642cdf0e10cSrcweir ::comphelper::DocPasswordRequestType eType = bMSType ? 1643cdf0e10cSrcweir ::comphelper::DocPasswordRequestType_MS : 1644cdf0e10cSrcweir ::comphelper::DocPasswordRequestType_STANDARD; 1645cdf0e10cSrcweir 1646cdf0e10cSrcweir ::rtl::Reference< ::comphelper::DocPasswordRequest > pPasswordRequest( new ::comphelper::DocPasswordRequest( eType, ::com::sun::star::task::PasswordRequestMode_PASSWORD_CREATE, *(rpURLList->GetObject(0)), ( pCurrentFilter->GetFilterFlags() & SFX_FILTER_PASSWORDTOMODIFY ) != 0 ) ); 1647cdf0e10cSrcweir 1648cdf0e10cSrcweir uno::Reference< com::sun::star::task::XInteractionRequest > rRequest( pPasswordRequest.get() ); 1649cdf0e10cSrcweir xInteractionHandler->handle( rRequest ); 1650cdf0e10cSrcweir if ( pPasswordRequest->isPassword() ) 1651cdf0e10cSrcweir { 1652cdf0e10cSrcweir if ( pPasswordRequest->getPassword().getLength() ) 1653cdf0e10cSrcweir { 1654cdf0e10cSrcweir // TODO/LATER: The filters should show the password dialog themself in future 1655cdf0e10cSrcweir if ( bMSType ) 1656cdf0e10cSrcweir { 1657cdf0e10cSrcweir // all the current MS-filters use MSCodec_Std97 implementation 1658cdf0e10cSrcweir uno::Sequence< sal_Int8 > aUniqueID = ::comphelper::DocPasswordHelper::GenerateRandomByteSequence( 16 ); 1659cdf0e10cSrcweir uno::Sequence< sal_Int8 > aEncryptionKey = ::comphelper::DocPasswordHelper::GenerateStd97Key( pPasswordRequest->getPassword(), aUniqueID ); 1660cdf0e10cSrcweir 1661cdf0e10cSrcweir if ( aEncryptionKey.getLength() ) 1662cdf0e10cSrcweir { 1663cdf0e10cSrcweir ::comphelper::SequenceAsHashMap aHashData; 1664cdf0e10cSrcweir aHashData[ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "STD97EncryptionKey" ) ) ] <<= aEncryptionKey; 1665cdf0e10cSrcweir aHashData[ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "STD97UniqueID" ) ) ] <<= aUniqueID; 1666cdf0e10cSrcweir 1667cdf0e10cSrcweir rpSet->Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, uno::makeAny( aHashData.getAsConstNamedValueList() ) ) ); 1668cdf0e10cSrcweir } 1669cdf0e10cSrcweir else 1670cdf0e10cSrcweir return ERRCODE_IO_NOTSUPPORTED; 1671cdf0e10cSrcweir } 1672cdf0e10cSrcweir else 1673cdf0e10cSrcweir { 1674cdf0e10cSrcweir rpSet->Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, uno::makeAny( ::comphelper::OStorageHelper::CreatePackageEncryptionData( pPasswordRequest->getPassword() ) ) ) ); 1675cdf0e10cSrcweir } 1676cdf0e10cSrcweir } 1677cdf0e10cSrcweir 1678cdf0e10cSrcweir if ( pPasswordRequest->getRecommendReadOnly() ) 1679cdf0e10cSrcweir rpSet->Put( SfxBoolItem( SID_RECOMMENDREADONLY, sal_True ) ); 1680cdf0e10cSrcweir 1681cdf0e10cSrcweir if ( bMSType ) 1682cdf0e10cSrcweir { 1683cdf0e10cSrcweir // the empty password has 0 as Hash 1684cdf0e10cSrcweir sal_Int32 nHash = SfxMedium::CreatePasswordToModifyHash( pPasswordRequest->getPasswordToModify(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextDocument" ) ).equals( pCurrentFilter->GetServiceName() ) ); 1685cdf0e10cSrcweir if ( nHash ) 1686cdf0e10cSrcweir rpSet->Put( SfxUnoAnyItem( SID_MODIFYPASSWORDINFO, uno::makeAny( nHash ) ) ); 1687cdf0e10cSrcweir } 1688cdf0e10cSrcweir else 1689cdf0e10cSrcweir { 1690cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aModifyPasswordInfo = ::comphelper::DocPasswordHelper::GenerateNewModifyPasswordInfo( pPasswordRequest->getPasswordToModify() ); 1691cdf0e10cSrcweir if ( aModifyPasswordInfo.getLength() ) 1692cdf0e10cSrcweir rpSet->Put( SfxUnoAnyItem( SID_MODIFYPASSWORDINFO, uno::makeAny( aModifyPasswordInfo ) ) ); 1693cdf0e10cSrcweir } 1694cdf0e10cSrcweir } 1695cdf0e10cSrcweir else 1696cdf0e10cSrcweir return ERRCODE_ABORT; 1697cdf0e10cSrcweir } 1698cdf0e10cSrcweir } 1699cdf0e10cSrcweir } 1700cdf0e10cSrcweir catch( IllegalArgumentException ){} 1701cdf0e10cSrcweir } 1702cdf0e10cSrcweir 1703cdf0e10cSrcweir SaveLastUsedFilter(); 1704cdf0e10cSrcweir return ERRCODE_NONE; 1705cdf0e10cSrcweir } 1706cdf0e10cSrcweir else 1707cdf0e10cSrcweir return ERRCODE_ABORT; 1708cdf0e10cSrcweir } 1709cdf0e10cSrcweir 1710cdf0e10cSrcweir // ------------------------------------------------------------------------ 1711cdf0e10cSrcweir ErrCode FileDialogHelper_Impl::execute() 1712cdf0e10cSrcweir { 1713cdf0e10cSrcweir if ( ! mxFileDlg.is() ) 1714cdf0e10cSrcweir return ERRCODE_ABORT; 1715cdf0e10cSrcweir 1716cdf0e10cSrcweir sal_Int16 nRet = implDoExecute(); 1717cdf0e10cSrcweir 1718cdf0e10cSrcweir maPath = mxFileDlg->getDisplayDirectory(); 1719cdf0e10cSrcweir 1720cdf0e10cSrcweir if ( ExecutableDialogResults::CANCEL == nRet ) 1721cdf0e10cSrcweir return ERRCODE_ABORT; 1722cdf0e10cSrcweir else 1723cdf0e10cSrcweir { 1724cdf0e10cSrcweir return ERRCODE_NONE; 1725cdf0e10cSrcweir } 1726cdf0e10cSrcweir } 1727cdf0e10cSrcweir 1728cdf0e10cSrcweir // ------------------------------------------------------------------------ 1729cdf0e10cSrcweir OUString FileDialogHelper_Impl::getPath() const 1730cdf0e10cSrcweir { 1731cdf0e10cSrcweir OUString aPath; 1732cdf0e10cSrcweir 1733cdf0e10cSrcweir if ( mxFileDlg.is() ) 1734cdf0e10cSrcweir aPath = mxFileDlg->getDisplayDirectory(); 1735cdf0e10cSrcweir 1736cdf0e10cSrcweir if ( !aPath.getLength() ) 1737cdf0e10cSrcweir aPath = maPath; 1738cdf0e10cSrcweir 1739cdf0e10cSrcweir return aPath; 1740cdf0e10cSrcweir } 1741cdf0e10cSrcweir 1742cdf0e10cSrcweir // ------------------------------------------------------------------------ 1743cdf0e10cSrcweir OUString FileDialogHelper_Impl::getFilter() const 1744cdf0e10cSrcweir { 1745cdf0e10cSrcweir String aFilter = getCurrentFilterUIName(); 1746cdf0e10cSrcweir 1747cdf0e10cSrcweir if( !aFilter.Len() ) 1748cdf0e10cSrcweir aFilter = maCurFilter; 1749cdf0e10cSrcweir 1750cdf0e10cSrcweir return aFilter; 1751cdf0e10cSrcweir } 1752cdf0e10cSrcweir 1753cdf0e10cSrcweir // ------------------------------------------------------------------------ 1754cdf0e10cSrcweir void FileDialogHelper_Impl::getRealFilter( String& _rFilter ) const 1755cdf0e10cSrcweir { 1756cdf0e10cSrcweir _rFilter = getCurrentFilterUIName(); 1757cdf0e10cSrcweir 1758cdf0e10cSrcweir if ( !_rFilter.Len() ) 1759cdf0e10cSrcweir _rFilter = maCurFilter; 1760cdf0e10cSrcweir 1761cdf0e10cSrcweir if ( _rFilter.Len() && mpMatcher ) 1762cdf0e10cSrcweir { 1763cdf0e10cSrcweir const SfxFilter* pFilter = 1764cdf0e10cSrcweir mpMatcher->GetFilter4UIName( _rFilter, m_nMustFlags, m_nDontFlags ); 1765cdf0e10cSrcweir _rFilter = pFilter ? pFilter->GetFilterName() : _rFilter.Erase(); 1766cdf0e10cSrcweir } 1767cdf0e10cSrcweir } 1768cdf0e10cSrcweir 1769cdf0e10cSrcweir // ------------------------------------------------------------------------ 1770cdf0e10cSrcweir void FileDialogHelper_Impl::displayFolder( const ::rtl::OUString& _rPath ) 1771cdf0e10cSrcweir { 1772cdf0e10cSrcweir if ( ! _rPath.getLength() ) 1773cdf0e10cSrcweir // nothing to do 1774cdf0e10cSrcweir return; 1775cdf0e10cSrcweir 1776cdf0e10cSrcweir /* 1777cdf0e10cSrcweir if ( !::utl::UCBContentHelper::IsFolder( _rPath ) ) 1778cdf0e10cSrcweir // only valid folders accepted here 1779cdf0e10cSrcweir return; 1780cdf0e10cSrcweir */ 1781cdf0e10cSrcweir 1782cdf0e10cSrcweir maPath = _rPath; 1783cdf0e10cSrcweir if ( mxFileDlg.is() ) 1784cdf0e10cSrcweir { 1785cdf0e10cSrcweir try 1786cdf0e10cSrcweir { 1787cdf0e10cSrcweir mxFileDlg->setDisplayDirectory( maPath ); 1788cdf0e10cSrcweir } 1789cdf0e10cSrcweir catch( const IllegalArgumentException& ) 1790cdf0e10cSrcweir { 1791cdf0e10cSrcweir DBG_ERROR( "FileDialogHelper_Impl::displayFolder: caught an exception!" ); 1792cdf0e10cSrcweir } 1793cdf0e10cSrcweir } 1794cdf0e10cSrcweir } 1795cdf0e10cSrcweir 1796cdf0e10cSrcweir // ------------------------------------------------------------------------ 1797cdf0e10cSrcweir void FileDialogHelper_Impl::setFileName( const ::rtl::OUString& _rFile ) 1798cdf0e10cSrcweir { 1799cdf0e10cSrcweir maFileName = _rFile; 1800cdf0e10cSrcweir if ( mxFileDlg.is() ) 1801cdf0e10cSrcweir { 1802cdf0e10cSrcweir try 1803cdf0e10cSrcweir { 1804cdf0e10cSrcweir mxFileDlg->setDefaultName( maFileName ); 1805cdf0e10cSrcweir } 1806cdf0e10cSrcweir catch( const IllegalArgumentException& ) 1807cdf0e10cSrcweir { 1808cdf0e10cSrcweir DBG_ERROR( "FileDialogHelper_Impl::setFileName: caught an exception!" ); 1809cdf0e10cSrcweir } 1810cdf0e10cSrcweir } 1811cdf0e10cSrcweir } 1812cdf0e10cSrcweir 1813cdf0e10cSrcweir // ------------------------------------------------------------------------ 1814cdf0e10cSrcweir void FileDialogHelper_Impl::setFilter( const OUString& rFilter ) 1815cdf0e10cSrcweir { 1816cdf0e10cSrcweir DBG_ASSERT( rFilter.indexOf(':') == -1, "Old filter name used!"); 1817cdf0e10cSrcweir 1818cdf0e10cSrcweir maCurFilter = rFilter; 1819cdf0e10cSrcweir 1820cdf0e10cSrcweir if ( rFilter.getLength() && mpMatcher ) 1821cdf0e10cSrcweir { 1822cdf0e10cSrcweir const SfxFilter* pFilter = mpMatcher->GetFilter4FilterName( 1823cdf0e10cSrcweir rFilter, m_nMustFlags, m_nDontFlags ); 1824cdf0e10cSrcweir if ( pFilter ) 1825cdf0e10cSrcweir maCurFilter = pFilter->GetUIName(); 1826cdf0e10cSrcweir } 1827cdf0e10cSrcweir 1828cdf0e10cSrcweir uno::Reference< XFilterManager > xFltMgr( mxFileDlg, UNO_QUERY ); 1829cdf0e10cSrcweir 1830cdf0e10cSrcweir if ( maCurFilter.getLength() && xFltMgr.is() ) 1831cdf0e10cSrcweir { 1832cdf0e10cSrcweir try 1833cdf0e10cSrcweir { 1834cdf0e10cSrcweir xFltMgr->setCurrentFilter( maCurFilter ); 1835cdf0e10cSrcweir } 1836cdf0e10cSrcweir catch( IllegalArgumentException ){} 1837cdf0e10cSrcweir } 1838cdf0e10cSrcweir } 1839cdf0e10cSrcweir 1840cdf0e10cSrcweir // ------------------------------------------------------------------------ 1841cdf0e10cSrcweir void FileDialogHelper_Impl::createMatcher( const String& rFactory ) 1842cdf0e10cSrcweir { 1843cdf0e10cSrcweir mpMatcher = new SfxFilterMatcher( SfxObjectShell::GetServiceNameFromFactory(rFactory) ); 1844cdf0e10cSrcweir mbDeleteMatcher = sal_True; 1845cdf0e10cSrcweir } 1846cdf0e10cSrcweir 1847cdf0e10cSrcweir // ------------------------------------------------------------------------ 1848cdf0e10cSrcweir void FileDialogHelper_Impl::addFilters( sal_Int64 nFlags, 1849cdf0e10cSrcweir const String& rFactory, 1850cdf0e10cSrcweir SfxFilterFlags nMust, 1851cdf0e10cSrcweir SfxFilterFlags nDont ) 1852cdf0e10cSrcweir { 1853cdf0e10cSrcweir uno::Reference< XFilterManager > xFltMgr( mxFileDlg, UNO_QUERY ); 1854cdf0e10cSrcweir 1855cdf0e10cSrcweir if ( ! xFltMgr.is() ) 1856cdf0e10cSrcweir return; 1857cdf0e10cSrcweir 1858cdf0e10cSrcweir // we still need a matcher to convert UI names to filter names 1859cdf0e10cSrcweir if ( !rFactory.Len() ) 1860cdf0e10cSrcweir { 1861cdf0e10cSrcweir SfxApplication *pSfxApp = SFX_APP(); 1862cdf0e10cSrcweir mpMatcher = &pSfxApp->GetFilterMatcher(); 1863cdf0e10cSrcweir mbDeleteMatcher = sal_False; 1864cdf0e10cSrcweir } 1865cdf0e10cSrcweir else 1866cdf0e10cSrcweir { 1867cdf0e10cSrcweir mpMatcher = new SfxFilterMatcher( rFactory ); 1868cdf0e10cSrcweir mbDeleteMatcher = sal_True; 1869cdf0e10cSrcweir } 1870cdf0e10cSrcweir 1871cdf0e10cSrcweir uno::Reference< XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory(); 1872cdf0e10cSrcweir uno::Reference< XContainerQuery > xFilterCont( 1873cdf0e10cSrcweir xSMGR->createInstance(::rtl::OUString::createFromAscii("com.sun.star.document.FilterFactory")), 1874cdf0e10cSrcweir UNO_QUERY); 1875cdf0e10cSrcweir if ( ! xFilterCont.is() ) 1876cdf0e10cSrcweir return; 1877cdf0e10cSrcweir 1878cdf0e10cSrcweir m_nMustFlags |= nMust; 1879cdf0e10cSrcweir m_nDontFlags |= nDont; 1880cdf0e10cSrcweir 1881cdf0e10cSrcweir // create the list of filters 1882cdf0e10cSrcweir ::rtl::OUStringBuffer sQuery(256); 1883cdf0e10cSrcweir sQuery.appendAscii("getSortedFilterList()"); 1884cdf0e10cSrcweir sQuery.appendAscii(":module=" ); 1885cdf0e10cSrcweir sQuery.append (rFactory ); // use long name here ! 1886cdf0e10cSrcweir sQuery.appendAscii(":iflags=" ); 1887cdf0e10cSrcweir sQuery.append (::rtl::OUString::valueOf((sal_Int32)m_nMustFlags)); 1888cdf0e10cSrcweir sQuery.appendAscii(":eflags=" ); 1889cdf0e10cSrcweir sQuery.append (::rtl::OUString::valueOf((sal_Int32)m_nDontFlags)); 1890cdf0e10cSrcweir 1891cdf0e10cSrcweir uno::Reference< XEnumeration > xResult; 1892cdf0e10cSrcweir try 1893cdf0e10cSrcweir { 1894cdf0e10cSrcweir xResult = xFilterCont->createSubSetEnumerationByQuery(sQuery.makeStringAndClear()); 1895cdf0e10cSrcweir } 1896cdf0e10cSrcweir catch( uno::Exception& ) 1897cdf0e10cSrcweir { 1898cdf0e10cSrcweir DBG_ERRORFILE( "Could not get filters from the configuration!" ); 1899cdf0e10cSrcweir } 1900cdf0e10cSrcweir 1901cdf0e10cSrcweir TSortedFilterList aIter (xResult); 1902cdf0e10cSrcweir 1903cdf0e10cSrcweir // no matcher any longer used ... 1904cdf0e10cSrcweir mbDeleteMatcher = sal_False; 1905cdf0e10cSrcweir 1906cdf0e10cSrcweir // append the filters 1907cdf0e10cSrcweir ::rtl::OUString sFirstFilter; 1908cdf0e10cSrcweir if ( WB_OPEN == ( nFlags & WB_OPEN ) ) 1909cdf0e10cSrcweir ::sfx2::appendFiltersForOpen( aIter, xFltMgr, sFirstFilter, *this ); 1910cdf0e10cSrcweir else if ( mbExport ) 1911cdf0e10cSrcweir ::sfx2::appendExportFilters( aIter, xFltMgr, sFirstFilter, *this ); 1912cdf0e10cSrcweir else 1913cdf0e10cSrcweir ::sfx2::appendFiltersForSave( aIter, xFltMgr, sFirstFilter, *this, rFactory ); 1914cdf0e10cSrcweir 1915cdf0e10cSrcweir // set our initial selected filter (if we do not already have one) 1916cdf0e10cSrcweir if ( !maSelectFilter.getLength() ) 1917cdf0e10cSrcweir maSelectFilter = sFirstFilter; 1918cdf0e10cSrcweir } 1919cdf0e10cSrcweir 1920cdf0e10cSrcweir // ------------------------------------------------------------------------ 1921cdf0e10cSrcweir void FileDialogHelper_Impl::addFilter( const OUString& rFilterName, 1922cdf0e10cSrcweir const OUString& rExtension ) 1923cdf0e10cSrcweir { 1924cdf0e10cSrcweir uno::Reference< XFilterManager > xFltMgr( mxFileDlg, UNO_QUERY ); 1925cdf0e10cSrcweir 1926cdf0e10cSrcweir if ( ! xFltMgr.is() ) 1927cdf0e10cSrcweir return; 1928cdf0e10cSrcweir 1929cdf0e10cSrcweir try 1930cdf0e10cSrcweir { 1931cdf0e10cSrcweir xFltMgr->appendFilter( rFilterName, rExtension ); 1932cdf0e10cSrcweir 1933cdf0e10cSrcweir if ( !maSelectFilter.getLength() ) 1934cdf0e10cSrcweir maSelectFilter = rFilterName; 1935cdf0e10cSrcweir } 1936cdf0e10cSrcweir catch( IllegalArgumentException ) 1937cdf0e10cSrcweir { 1938cdf0e10cSrcweir #ifdef DBG_UTIL 1939cdf0e10cSrcweir ByteString aMsg( "Could not append Filter" ); 1940cdf0e10cSrcweir aMsg += ByteString( String( rFilterName ), RTL_TEXTENCODING_UTF8 ); 1941cdf0e10cSrcweir DBG_ERRORFILE( aMsg.GetBuffer() ); 1942cdf0e10cSrcweir #endif 1943cdf0e10cSrcweir } 1944cdf0e10cSrcweir } 1945cdf0e10cSrcweir 1946cdf0e10cSrcweir // ------------------------------------------------------------------------ 1947cdf0e10cSrcweir void FileDialogHelper_Impl::addGraphicFilter() 1948cdf0e10cSrcweir { 1949cdf0e10cSrcweir uno::Reference< XFilterManager > xFltMgr( mxFileDlg, UNO_QUERY ); 1950cdf0e10cSrcweir 1951cdf0e10cSrcweir if ( ! xFltMgr.is() ) 1952cdf0e10cSrcweir return; 1953cdf0e10cSrcweir 1954cdf0e10cSrcweir // create the list of filters 1955cdf0e10cSrcweir mpGraphicFilter = new GraphicFilter; 1956cdf0e10cSrcweir sal_uInt16 i, j, nCount = mpGraphicFilter->GetImportFormatCount(); 1957cdf0e10cSrcweir 1958cdf0e10cSrcweir // compute the extension string for all known import filters 1959cdf0e10cSrcweir String aExtensions; 1960cdf0e10cSrcweir 1961cdf0e10cSrcweir for ( i = 0; i < nCount; i++ ) 1962cdf0e10cSrcweir { 1963cdf0e10cSrcweir j = 0; 1964cdf0e10cSrcweir String sWildcard; 1965cdf0e10cSrcweir while( sal_True ) 1966cdf0e10cSrcweir { 1967cdf0e10cSrcweir sWildcard = mpGraphicFilter->GetImportWildcard( i, j++ ); 1968cdf0e10cSrcweir if ( !sWildcard.Len() ) 1969cdf0e10cSrcweir break; 1970cdf0e10cSrcweir if ( aExtensions.Search( sWildcard ) == STRING_NOTFOUND ) 1971cdf0e10cSrcweir { 1972cdf0e10cSrcweir if ( aExtensions.Len() ) 1973cdf0e10cSrcweir aExtensions += sal_Unicode(';'); 1974cdf0e10cSrcweir aExtensions += sWildcard; 1975cdf0e10cSrcweir } 1976cdf0e10cSrcweir } 1977cdf0e10cSrcweir } 1978cdf0e10cSrcweir 1979cdf0e10cSrcweir #if defined(WNT) 1980cdf0e10cSrcweir if ( aExtensions.Len() > 240 ) 1981cdf0e10cSrcweir aExtensions = DEFINE_CONST_UNICODE( FILEDIALOG_FILTER_ALL ); 1982cdf0e10cSrcweir #endif 1983cdf0e10cSrcweir sal_Bool bIsInOpenMode = isInOpenMode(); 1984cdf0e10cSrcweir 1985cdf0e10cSrcweir try 1986cdf0e10cSrcweir { 1987cdf0e10cSrcweir OUString aAllFilterName = String( SfxResId( STR_SFX_IMPORT_ALL ) ); 1988cdf0e10cSrcweir aAllFilterName = ::sfx2::addExtension( aAllFilterName, aExtensions, bIsInOpenMode, *this ); 1989cdf0e10cSrcweir 1990cdf0e10cSrcweir xFltMgr->appendFilter( aAllFilterName, aExtensions ); 1991cdf0e10cSrcweir maSelectFilter = aAllFilterName; 1992cdf0e10cSrcweir } 1993cdf0e10cSrcweir catch( IllegalArgumentException ) 1994cdf0e10cSrcweir { 1995cdf0e10cSrcweir DBG_ERRORFILE( "Could not append Filter" ); 1996cdf0e10cSrcweir } 1997cdf0e10cSrcweir 1998cdf0e10cSrcweir // Now add the filter 1999cdf0e10cSrcweir for ( i = 0; i < nCount; i++ ) 2000cdf0e10cSrcweir { 2001cdf0e10cSrcweir String aName = mpGraphicFilter->GetImportFormatName( i ); 2002cdf0e10cSrcweir String aExt; 2003cdf0e10cSrcweir j = 0; 2004cdf0e10cSrcweir String sWildcard; 2005cdf0e10cSrcweir while( sal_True ) 2006cdf0e10cSrcweir { 2007cdf0e10cSrcweir sWildcard = mpGraphicFilter->GetImportWildcard( i, j++ ); 2008cdf0e10cSrcweir if ( !sWildcard.Len() ) 2009cdf0e10cSrcweir break; 2010cdf0e10cSrcweir if ( aExt.Search( sWildcard ) == STRING_NOTFOUND ) 2011cdf0e10cSrcweir { 2012cdf0e10cSrcweir if ( aExt.Len() ) 2013cdf0e10cSrcweir aExt += sal_Unicode(';'); 2014cdf0e10cSrcweir aExt += sWildcard; 2015cdf0e10cSrcweir } 2016cdf0e10cSrcweir } 2017cdf0e10cSrcweir aName = ::sfx2::addExtension( aName, aExt, bIsInOpenMode, *this ); 2018cdf0e10cSrcweir try 2019cdf0e10cSrcweir { 2020cdf0e10cSrcweir xFltMgr->appendFilter( aName, aExt ); 2021cdf0e10cSrcweir } 2022cdf0e10cSrcweir catch( IllegalArgumentException ) 2023cdf0e10cSrcweir { 2024cdf0e10cSrcweir DBG_ERRORFILE( "Could not append Filter" ); 2025cdf0e10cSrcweir } 2026cdf0e10cSrcweir } 2027cdf0e10cSrcweir } 2028cdf0e10cSrcweir 2029cdf0e10cSrcweir // ------------------------------------------------------------------------ 2030cdf0e10cSrcweir #define GRF_CONFIG_STR " " 2031cdf0e10cSrcweir #define STD_CONFIG_STR "1 " 2032cdf0e10cSrcweir 2033cdf0e10cSrcweir void FileDialogHelper_Impl::saveConfig() 2034cdf0e10cSrcweir { 2035cdf0e10cSrcweir uno::Reference < XFilePickerControlAccess > xDlg( mxFileDlg, UNO_QUERY ); 2036cdf0e10cSrcweir Any aValue; 2037cdf0e10cSrcweir 2038cdf0e10cSrcweir if ( ! xDlg.is() ) 2039cdf0e10cSrcweir return; 2040cdf0e10cSrcweir 2041cdf0e10cSrcweir if ( mbHasPreview ) 2042cdf0e10cSrcweir { 2043cdf0e10cSrcweir SvtViewOptions aDlgOpt( E_DIALOG, IMPGRF_CONFIGNAME ); 2044cdf0e10cSrcweir String aUserData = DEFINE_CONST_UNICODE( GRF_CONFIG_STR ); 2045cdf0e10cSrcweir 2046cdf0e10cSrcweir try 2047cdf0e10cSrcweir { 2048cdf0e10cSrcweir aValue = xDlg->getValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0 ); 2049cdf0e10cSrcweir sal_Bool bValue = sal_False; 2050cdf0e10cSrcweir aValue >>= bValue; 2051cdf0e10cSrcweir aUserData.SetToken( 0, ' ', String::CreateFromInt32( (sal_Int32) bValue ) ); 2052cdf0e10cSrcweir 2053cdf0e10cSrcweir aValue = xDlg->getValue( ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, 0 ); 2054cdf0e10cSrcweir bValue = sal_False; 2055cdf0e10cSrcweir aValue >>= bValue; 2056cdf0e10cSrcweir aUserData.SetToken( 1, ' ', String::CreateFromInt32( (sal_Int32) bValue ) ); 2057cdf0e10cSrcweir 2058cdf0e10cSrcweir INetURLObject aObj( getPath() ); 2059cdf0e10cSrcweir 2060cdf0e10cSrcweir if ( aObj.GetProtocol() == INET_PROT_FILE ) 2061cdf0e10cSrcweir aUserData.SetToken( 2, ' ', aObj.GetMainURL( INetURLObject::NO_DECODE ) ); 2062cdf0e10cSrcweir 2063cdf0e10cSrcweir String aFilter = getFilter(); 2064cdf0e10cSrcweir aFilter = EncodeSpaces_Impl( aFilter ); 2065cdf0e10cSrcweir aUserData.SetToken( 3, ' ', aFilter ); 2066cdf0e10cSrcweir 2067cdf0e10cSrcweir aDlgOpt.SetUserItem( USERITEM_NAME, makeAny( OUString( aUserData ) ) ); 2068cdf0e10cSrcweir } 2069cdf0e10cSrcweir catch( IllegalArgumentException ){} 2070cdf0e10cSrcweir } 2071cdf0e10cSrcweir else 2072cdf0e10cSrcweir { 2073cdf0e10cSrcweir sal_Bool bWriteConfig = sal_False; 2074cdf0e10cSrcweir SvtViewOptions aDlgOpt( E_DIALOG, IODLG_CONFIGNAME ); 2075cdf0e10cSrcweir String aUserData = DEFINE_CONST_UNICODE( STD_CONFIG_STR ); 2076cdf0e10cSrcweir 2077cdf0e10cSrcweir if ( aDlgOpt.Exists() ) 2078cdf0e10cSrcweir { 2079cdf0e10cSrcweir Any aUserItem = aDlgOpt.GetUserItem( USERITEM_NAME ); 2080cdf0e10cSrcweir OUString aTemp; 2081cdf0e10cSrcweir if ( aUserItem >>= aTemp ) 2082cdf0e10cSrcweir aUserData = String( aTemp ); 2083cdf0e10cSrcweir } 2084cdf0e10cSrcweir 2085cdf0e10cSrcweir if ( mbHasAutoExt ) 2086cdf0e10cSrcweir { 2087cdf0e10cSrcweir try 2088cdf0e10cSrcweir { 2089cdf0e10cSrcweir aValue = xDlg->getValue( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0 ); 2090cdf0e10cSrcweir sal_Bool bAutoExt = sal_True; 2091cdf0e10cSrcweir aValue >>= bAutoExt; 2092cdf0e10cSrcweir aUserData.SetToken( 0, ' ', String::CreateFromInt32( (sal_Int32) bAutoExt ) ); 2093cdf0e10cSrcweir bWriteConfig = sal_True; 2094cdf0e10cSrcweir } 2095cdf0e10cSrcweir catch( IllegalArgumentException ){} 2096cdf0e10cSrcweir } 2097cdf0e10cSrcweir 2098cdf0e10cSrcweir if ( ! mbIsSaveDlg ) 2099cdf0e10cSrcweir { 2100cdf0e10cSrcweir OUString aPath = getPath(); 2101cdf0e10cSrcweir if ( aPath.getLength() && 2102cdf0e10cSrcweir utl::LocalFileHelper::IsLocalFile( aPath ) ) 2103cdf0e10cSrcweir { 2104cdf0e10cSrcweir aUserData.SetToken( 1, ' ', aPath ); 2105cdf0e10cSrcweir bWriteConfig = sal_True; 2106cdf0e10cSrcweir } 2107cdf0e10cSrcweir } 2108cdf0e10cSrcweir 2109cdf0e10cSrcweir if( mbHasSelectionBox && mbSelectionFltrEnabled ) 2110cdf0e10cSrcweir { 2111cdf0e10cSrcweir try 2112cdf0e10cSrcweir { 2113cdf0e10cSrcweir aValue = xDlg->getValue( ExtendedFilePickerElementIds::CHECKBOX_SELECTION, 0 ); 2114cdf0e10cSrcweir sal_Bool bSelection = sal_True; 2115cdf0e10cSrcweir aValue >>= bSelection; 2116cdf0e10cSrcweir if ( aUserData.GetTokenCount(' ') < 3 ) 2117cdf0e10cSrcweir aUserData.Append(' '); 2118cdf0e10cSrcweir aUserData.SetToken( 2, ' ', String::CreateFromInt32( (sal_Int32) bSelection ) ); 2119cdf0e10cSrcweir bWriteConfig = sal_True; 2120cdf0e10cSrcweir } 2121cdf0e10cSrcweir catch( IllegalArgumentException ){} 2122cdf0e10cSrcweir } 2123cdf0e10cSrcweir 2124cdf0e10cSrcweir if ( bWriteConfig ) 2125cdf0e10cSrcweir aDlgOpt.SetUserItem( USERITEM_NAME, makeAny( OUString( aUserData ) ) ); 2126cdf0e10cSrcweir } 2127cdf0e10cSrcweir 2128cdf0e10cSrcweir SfxApplication *pSfxApp = SFX_APP(); 2129cdf0e10cSrcweir pSfxApp->SetLastDir_Impl( getPath() ); 2130cdf0e10cSrcweir } 2131cdf0e10cSrcweir 2132cdf0e10cSrcweir // ------------------------------------------------------------------------ 2133cdf0e10cSrcweir namespace 2134cdf0e10cSrcweir { 2135cdf0e10cSrcweir static ::rtl::OUString getInitPath( const String& _rFallback, const xub_StrLen _nFallbackToken ) 2136cdf0e10cSrcweir { 2137cdf0e10cSrcweir SfxApplication *pSfxApp = SFX_APP(); 2138cdf0e10cSrcweir String sPath = pSfxApp->GetLastDir_Impl(); 2139cdf0e10cSrcweir 2140cdf0e10cSrcweir if ( !sPath.Len() ) 2141cdf0e10cSrcweir sPath = _rFallback.GetToken( _nFallbackToken, ' ' ); 2142cdf0e10cSrcweir 2143cdf0e10cSrcweir // check if the path points to a valid (accessible) directory 2144cdf0e10cSrcweir sal_Bool bValid = sal_False; 2145cdf0e10cSrcweir if ( sPath.Len() ) 2146cdf0e10cSrcweir { 2147cdf0e10cSrcweir String sPathCheck( sPath ); 2148cdf0e10cSrcweir if ( sPathCheck.GetBuffer()[ sPathCheck.Len() - 1 ] != '/' ) 2149cdf0e10cSrcweir sPathCheck += '/'; 2150cdf0e10cSrcweir sPathCheck += '.'; 2151cdf0e10cSrcweir try 2152cdf0e10cSrcweir { 2153cdf0e10cSrcweir ::ucbhelper::Content aContent( sPathCheck, uno::Reference< ucb::XCommandEnvironment >() ); 2154cdf0e10cSrcweir bValid = aContent.isFolder(); 2155cdf0e10cSrcweir } 2156cdf0e10cSrcweir catch( Exception& ) {} 2157cdf0e10cSrcweir } 2158cdf0e10cSrcweir 2159cdf0e10cSrcweir if ( !bValid ) 2160cdf0e10cSrcweir sPath.Erase(); 2161cdf0e10cSrcweir 2162cdf0e10cSrcweir return sPath; 2163cdf0e10cSrcweir } 2164cdf0e10cSrcweir } 2165cdf0e10cSrcweir 2166cdf0e10cSrcweir // ------------------------------------------------------------------------ 2167cdf0e10cSrcweir void FileDialogHelper_Impl::loadConfig() 2168cdf0e10cSrcweir { 2169cdf0e10cSrcweir uno::Reference < XFilePickerControlAccess > xDlg( mxFileDlg, UNO_QUERY ); 2170cdf0e10cSrcweir Any aValue; 2171cdf0e10cSrcweir 2172cdf0e10cSrcweir if ( ! xDlg.is() ) 2173cdf0e10cSrcweir return; 2174cdf0e10cSrcweir 2175cdf0e10cSrcweir if ( mbHasPreview ) 2176cdf0e10cSrcweir { 2177cdf0e10cSrcweir SvtViewOptions aViewOpt( E_DIALOG, IMPGRF_CONFIGNAME ); 2178cdf0e10cSrcweir String aUserData; 2179cdf0e10cSrcweir 2180cdf0e10cSrcweir if ( aViewOpt.Exists() ) 2181cdf0e10cSrcweir { 2182cdf0e10cSrcweir Any aUserItem = aViewOpt.GetUserItem( USERITEM_NAME ); 2183cdf0e10cSrcweir OUString aTemp; 2184cdf0e10cSrcweir if ( aUserItem >>= aTemp ) 2185cdf0e10cSrcweir aUserData = String( aTemp ); 2186cdf0e10cSrcweir } 2187cdf0e10cSrcweir 2188cdf0e10cSrcweir if ( aUserData.Len() > 0 ) 2189cdf0e10cSrcweir { 2190cdf0e10cSrcweir try 2191cdf0e10cSrcweir { 2192cdf0e10cSrcweir // respect the last "insert as link" state 2193cdf0e10cSrcweir sal_Bool bLink = (sal_Bool) aUserData.GetToken( 0, ' ' ).ToInt32(); 2194cdf0e10cSrcweir aValue <<= bLink; 2195cdf0e10cSrcweir xDlg->setValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, aValue ); 2196cdf0e10cSrcweir 2197cdf0e10cSrcweir // respect the last "show preview" state 2198cdf0e10cSrcweir sal_Bool bShowPreview = (sal_Bool) aUserData.GetToken( 1, ' ' ).ToInt32(); 2199cdf0e10cSrcweir aValue <<= bShowPreview; 2200cdf0e10cSrcweir xDlg->setValue( ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, 0, aValue ); 2201cdf0e10cSrcweir 2202cdf0e10cSrcweir if ( !maPath.getLength() ) 2203cdf0e10cSrcweir displayFolder( getInitPath( aUserData, 2 ) ); 2204cdf0e10cSrcweir 2205cdf0e10cSrcweir if ( ! maCurFilter.getLength() ) 2206cdf0e10cSrcweir { 2207cdf0e10cSrcweir String aFilter = aUserData.GetToken( 3, ' ' ); 2208cdf0e10cSrcweir aFilter = DecodeSpaces_Impl( aFilter ); 2209cdf0e10cSrcweir setFilter( aFilter ); 2210cdf0e10cSrcweir } 2211cdf0e10cSrcweir 2212cdf0e10cSrcweir // set the member so we know that we have to show the preview 2213cdf0e10cSrcweir mbShowPreview = bShowPreview; 2214cdf0e10cSrcweir } 2215cdf0e10cSrcweir catch( IllegalArgumentException ){} 2216cdf0e10cSrcweir } 2217cdf0e10cSrcweir 2218cdf0e10cSrcweir if ( !maPath.getLength() ) 2219cdf0e10cSrcweir displayFolder( SvtPathOptions().GetGraphicPath() ); 2220cdf0e10cSrcweir } 2221cdf0e10cSrcweir else 2222cdf0e10cSrcweir { 2223cdf0e10cSrcweir SvtViewOptions aViewOpt( E_DIALOG, IODLG_CONFIGNAME ); 2224cdf0e10cSrcweir String aUserData; 2225cdf0e10cSrcweir 2226cdf0e10cSrcweir if ( aViewOpt.Exists() ) 2227cdf0e10cSrcweir { 2228cdf0e10cSrcweir Any aUserItem = aViewOpt.GetUserItem( USERITEM_NAME ); 2229cdf0e10cSrcweir OUString aTemp; 2230cdf0e10cSrcweir if ( aUserItem >>= aTemp ) 2231cdf0e10cSrcweir aUserData = String( aTemp ); 2232cdf0e10cSrcweir } 2233cdf0e10cSrcweir 2234cdf0e10cSrcweir if ( ! aUserData.Len() ) 2235cdf0e10cSrcweir aUserData = DEFINE_CONST_UNICODE( STD_CONFIG_STR ); 2236cdf0e10cSrcweir 2237cdf0e10cSrcweir if ( ! maPath.getLength() ) 2238cdf0e10cSrcweir displayFolder( getInitPath( aUserData, 1 ) ); 2239cdf0e10cSrcweir 2240cdf0e10cSrcweir if ( mbHasAutoExt ) 2241cdf0e10cSrcweir { 2242cdf0e10cSrcweir sal_Int32 nFlag = aUserData.GetToken( 0, ' ' ).ToInt32(); 2243cdf0e10cSrcweir aValue <<= (sal_Bool) nFlag; 2244cdf0e10cSrcweir try 2245cdf0e10cSrcweir { 2246cdf0e10cSrcweir xDlg->setValue( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0, aValue ); 2247cdf0e10cSrcweir } 2248cdf0e10cSrcweir catch( IllegalArgumentException ){} 2249cdf0e10cSrcweir } 2250cdf0e10cSrcweir 2251cdf0e10cSrcweir if( mbHasSelectionBox ) 2252cdf0e10cSrcweir { 2253cdf0e10cSrcweir sal_Int32 nFlag = aUserData.GetToken( 2, ' ' ).ToInt32(); 2254cdf0e10cSrcweir aValue <<= (sal_Bool) nFlag; 2255cdf0e10cSrcweir try 2256cdf0e10cSrcweir { 2257cdf0e10cSrcweir xDlg->setValue( ExtendedFilePickerElementIds::CHECKBOX_SELECTION, 0, aValue ); 2258cdf0e10cSrcweir } 2259cdf0e10cSrcweir catch( IllegalArgumentException ){} 2260cdf0e10cSrcweir } 2261cdf0e10cSrcweir 2262cdf0e10cSrcweir if ( !maPath.getLength() ) 2263cdf0e10cSrcweir displayFolder( SvtPathOptions().GetWorkPath() ); 2264cdf0e10cSrcweir } 2265cdf0e10cSrcweir } 2266cdf0e10cSrcweir 2267cdf0e10cSrcweir // ------------------------------------------------------------------------ 2268cdf0e10cSrcweir void FileDialogHelper_Impl::setDefaultValues() 2269cdf0e10cSrcweir { 2270cdf0e10cSrcweir // when no filter is set, we set the curentFilter to <all> 2271cdf0e10cSrcweir if ( !maCurFilter.getLength() && maSelectFilter.getLength() ) 2272cdf0e10cSrcweir { 2273cdf0e10cSrcweir uno::Reference< XFilterManager > xFltMgr( mxFileDlg, UNO_QUERY ); 2274cdf0e10cSrcweir try 2275cdf0e10cSrcweir { 2276cdf0e10cSrcweir xFltMgr->setCurrentFilter( maSelectFilter ); 2277cdf0e10cSrcweir } 2278cdf0e10cSrcweir catch( IllegalArgumentException ) 2279cdf0e10cSrcweir {} 2280cdf0e10cSrcweir } 2281cdf0e10cSrcweir 2282cdf0e10cSrcweir // when no path is set, we use the standard 'work' folder 2283cdf0e10cSrcweir if ( ! maPath.getLength() ) 2284cdf0e10cSrcweir { 2285cdf0e10cSrcweir OUString aWorkFolder = SvtPathOptions().GetWorkPath(); 2286cdf0e10cSrcweir try 2287cdf0e10cSrcweir { 2288cdf0e10cSrcweir mxFileDlg->setDisplayDirectory( aWorkFolder ); 2289cdf0e10cSrcweir } 2290cdf0e10cSrcweir catch( const Exception& ) 2291cdf0e10cSrcweir { 2292cdf0e10cSrcweir DBG_ERROR( "FileDialogHelper_Impl::setDefaultValues: caught an exception while setting the display directory!" ); 2293cdf0e10cSrcweir } 2294cdf0e10cSrcweir 2295cdf0e10cSrcweir // INetURLObject aStdDirObj( SvtPathOptions().GetWorkPath() ); 2296cdf0e10cSrcweir //SetStandardDir( aStdDirObj.GetMainURL( INetURLObject::NO_DECODE ) ); 2297cdf0e10cSrcweir } 2298cdf0e10cSrcweir } 2299cdf0e10cSrcweir 2300cdf0e10cSrcweir sal_Bool FileDialogHelper_Impl::isShowFilterExtensionEnabled() const 2301cdf0e10cSrcweir { 2302cdf0e10cSrcweir return !maFilters.empty(); 2303cdf0e10cSrcweir } 2304cdf0e10cSrcweir 2305cdf0e10cSrcweir void FileDialogHelper_Impl::addFilterPair( const OUString& rFilter, 2306cdf0e10cSrcweir const OUString& rFilterWithExtension ) 2307cdf0e10cSrcweir { 2308cdf0e10cSrcweir maFilters.push_back( FilterPair( rFilter, rFilterWithExtension ) ); 2309cdf0e10cSrcweir 2310cdf0e10cSrcweir } 2311cdf0e10cSrcweir 2312cdf0e10cSrcweir OUString FileDialogHelper_Impl::getFilterName( const OUString& rFilterWithExtension ) const 2313cdf0e10cSrcweir { 2314cdf0e10cSrcweir OUString sRet; 2315cdf0e10cSrcweir for( ::std::vector< FilterPair >::const_iterator pIter = maFilters.begin(); pIter != maFilters.end(); ++pIter ) 2316cdf0e10cSrcweir { 2317cdf0e10cSrcweir if ( (*pIter).Second == rFilterWithExtension ) 2318cdf0e10cSrcweir { 2319cdf0e10cSrcweir sRet = (*pIter).First; 2320cdf0e10cSrcweir break; 2321cdf0e10cSrcweir } 2322cdf0e10cSrcweir } 2323cdf0e10cSrcweir return sRet; 2324cdf0e10cSrcweir } 2325cdf0e10cSrcweir 2326cdf0e10cSrcweir OUString FileDialogHelper_Impl::getFilterWithExtension( const OUString& rFilter ) const 2327cdf0e10cSrcweir { 2328cdf0e10cSrcweir OUString sRet; 2329cdf0e10cSrcweir for( ::std::vector< FilterPair >::const_iterator pIter = maFilters.begin(); pIter != maFilters.end(); ++pIter ) 2330cdf0e10cSrcweir { 2331cdf0e10cSrcweir if ( (*pIter).First == rFilter ) 2332cdf0e10cSrcweir { 2333cdf0e10cSrcweir sRet = (*pIter).Second; 2334cdf0e10cSrcweir break; 2335cdf0e10cSrcweir } 2336cdf0e10cSrcweir } 2337cdf0e10cSrcweir return sRet; 2338cdf0e10cSrcweir } 2339cdf0e10cSrcweir 2340cdf0e10cSrcweir void FileDialogHelper_Impl::SetContext( FileDialogHelper::Context _eNewContext ) 2341cdf0e10cSrcweir { 2342cdf0e10cSrcweir meContext = _eNewContext; 2343cdf0e10cSrcweir 2344cdf0e10cSrcweir sal_Int32 nNewHelpId = 0; 2345cdf0e10cSrcweir OUString aConfigId; 2346cdf0e10cSrcweir 2347cdf0e10cSrcweir switch( _eNewContext ) 2348cdf0e10cSrcweir { 2349cdf0e10cSrcweir // #104952# dependency to SVX not allowed! When used again, another solution has to be found 2350cdf0e10cSrcweir // case FileDialogHelper::SW_INSERT_GRAPHIC: 2351cdf0e10cSrcweir // case FileDialogHelper::SC_INSERT_GRAPHIC: 2352cdf0e10cSrcweir // case FileDialogHelper::SD_INSERT_GRAPHIC: nNewHelpId = SID_INSERT_GRAPHIC; break; 2353cdf0e10cSrcweir case FileDialogHelper::SW_INSERT_SOUND: 2354cdf0e10cSrcweir case FileDialogHelper::SC_INSERT_SOUND: 2355cdf0e10cSrcweir case FileDialogHelper::SD_INSERT_SOUND: nNewHelpId = SID_INSERT_SOUND; break; 2356cdf0e10cSrcweir case FileDialogHelper::SW_INSERT_VIDEO: 2357cdf0e10cSrcweir case FileDialogHelper::SC_INSERT_VIDEO: 2358cdf0e10cSrcweir case FileDialogHelper::SD_INSERT_VIDEO: nNewHelpId = SID_INSERT_VIDEO; break; 2359cdf0e10cSrcweir default: break; 2360cdf0e10cSrcweir } 2361cdf0e10cSrcweir 2362cdf0e10cSrcweir const OUString* pConfigId = GetLastFilterConfigId( _eNewContext ); 2363cdf0e10cSrcweir if( pConfigId ) 2364cdf0e10cSrcweir LoadLastUsedFilter( *pConfigId ); 2365cdf0e10cSrcweir } 2366cdf0e10cSrcweir 2367cdf0e10cSrcweir // ------------------------------------------------------------------------ 2368cdf0e10cSrcweir // ----------- FileDialogHelper --------------------------- 2369cdf0e10cSrcweir // ------------------------------------------------------------------------ 2370cdf0e10cSrcweir 2371cdf0e10cSrcweir FileDialogHelper::FileDialogHelper( 2372cdf0e10cSrcweir sal_Int64 nFlags, 2373cdf0e10cSrcweir const String& rFact, 2374cdf0e10cSrcweir SfxFilterFlags nMust, 2375cdf0e10cSrcweir SfxFilterFlags nDont ) 2376cdf0e10cSrcweir { 2377cdf0e10cSrcweir mpImp = new FileDialogHelper_Impl( this, getDialogType( nFlags ), nFlags ); 2378cdf0e10cSrcweir mxImp = mpImp; 2379cdf0e10cSrcweir 2380cdf0e10cSrcweir // create the list of filters 2381cdf0e10cSrcweir mpImp->addFilters( nFlags, SfxObjectShell::GetServiceNameFromFactory(rFact), nMust, nDont ); 2382cdf0e10cSrcweir } 2383cdf0e10cSrcweir 2384cdf0e10cSrcweir FileDialogHelper::FileDialogHelper( 2385cdf0e10cSrcweir sal_Int64 nFlags, 2386cdf0e10cSrcweir const String& rFact, 2387cdf0e10cSrcweir sal_Int16 nDialog, 2388cdf0e10cSrcweir SfxFilterFlags nMust, 2389cdf0e10cSrcweir SfxFilterFlags nDont, 2390cdf0e10cSrcweir const String& rStandardDir, 2391cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList) 2392cdf0e10cSrcweir { 2393cdf0e10cSrcweir mpImp = new FileDialogHelper_Impl( this, getDialogType( nFlags ), nFlags, nDialog, NULL , rStandardDir, rBlackList ); 2394cdf0e10cSrcweir mxImp = mpImp; 2395cdf0e10cSrcweir 2396cdf0e10cSrcweir // create the list of filters 2397cdf0e10cSrcweir mpImp->addFilters( nFlags, SfxObjectShell::GetServiceNameFromFactory(rFact), nMust, nDont ); 2398cdf0e10cSrcweir } 2399cdf0e10cSrcweir 2400cdf0e10cSrcweir FileDialogHelper::FileDialogHelper( 2401cdf0e10cSrcweir sal_Int64 nFlags, 2402cdf0e10cSrcweir const String& rFact, 2403cdf0e10cSrcweir sal_Int16 nDialog, 2404cdf0e10cSrcweir SfxFilterFlags nMust, 2405cdf0e10cSrcweir SfxFilterFlags nDont ) 2406cdf0e10cSrcweir { 2407cdf0e10cSrcweir mpImp = new FileDialogHelper_Impl( this, getDialogType( nFlags ), nFlags, nDialog ); 2408cdf0e10cSrcweir mxImp = mpImp; 2409cdf0e10cSrcweir 2410cdf0e10cSrcweir // create the list of filters 2411cdf0e10cSrcweir mpImp->addFilters( nFlags, SfxObjectShell::GetServiceNameFromFactory(rFact), nMust, nDont ); 2412cdf0e10cSrcweir } 2413cdf0e10cSrcweir 2414cdf0e10cSrcweir // ------------------------------------------------------------------------ 2415cdf0e10cSrcweir FileDialogHelper::FileDialogHelper( sal_Int64 nFlags ) 2416cdf0e10cSrcweir { 2417cdf0e10cSrcweir sal_Int16 nDialogType = getDialogType( nFlags ); 2418cdf0e10cSrcweir 2419cdf0e10cSrcweir mpImp = new FileDialogHelper_Impl( this, nDialogType, nFlags ); 2420cdf0e10cSrcweir mxImp = mpImp; 2421cdf0e10cSrcweir } 2422cdf0e10cSrcweir 2423cdf0e10cSrcweir // ------------------------------------------------------------------------ 2424cdf0e10cSrcweir FileDialogHelper::FileDialogHelper( 2425cdf0e10cSrcweir sal_Int16 nDialogType, 2426cdf0e10cSrcweir sal_Int64 nFlags, 2427cdf0e10cSrcweir const String& rFact, 2428cdf0e10cSrcweir SfxFilterFlags nMust, 2429cdf0e10cSrcweir SfxFilterFlags nDont ) 2430cdf0e10cSrcweir { 2431cdf0e10cSrcweir mpImp = new FileDialogHelper_Impl( this, nDialogType, nFlags ); 2432cdf0e10cSrcweir mxImp = mpImp; 2433cdf0e10cSrcweir 2434cdf0e10cSrcweir // create the list of filters 2435cdf0e10cSrcweir mpImp->addFilters( nFlags, SfxObjectShell::GetServiceNameFromFactory(rFact), nMust, nDont ); 2436cdf0e10cSrcweir } 2437cdf0e10cSrcweir 2438cdf0e10cSrcweir // ------------------------------------------------------------------------ 2439cdf0e10cSrcweir FileDialogHelper::FileDialogHelper( 2440cdf0e10cSrcweir sal_Int16 nDialogType, 2441cdf0e10cSrcweir sal_Int64 nFlags, 2442cdf0e10cSrcweir const String& rFact, 2443cdf0e10cSrcweir sal_Int16 nDialog, 2444cdf0e10cSrcweir SfxFilterFlags nMust, 2445cdf0e10cSrcweir SfxFilterFlags nDont, 2446cdf0e10cSrcweir const String& rStandardDir, 2447cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList) 2448cdf0e10cSrcweir { 2449cdf0e10cSrcweir mpImp = new FileDialogHelper_Impl( this, nDialogType, nFlags, nDialog, NULL, rStandardDir, rBlackList ); 2450cdf0e10cSrcweir mxImp = mpImp; 2451cdf0e10cSrcweir 2452cdf0e10cSrcweir // create the list of filters 2453cdf0e10cSrcweir mpImp->addFilters( nFlags, SfxObjectShell::GetServiceNameFromFactory(rFact), nMust, nDont ); 2454cdf0e10cSrcweir } 2455cdf0e10cSrcweir 2456cdf0e10cSrcweir // ------------------------------------------------------------------------ 2457cdf0e10cSrcweir FileDialogHelper::FileDialogHelper( 2458cdf0e10cSrcweir sal_Int16 nDialogType, 2459cdf0e10cSrcweir sal_Int64 nFlags, 2460cdf0e10cSrcweir Window* _pPreferredParent ) 2461cdf0e10cSrcweir { 2462cdf0e10cSrcweir mpImp = new FileDialogHelper_Impl( this, nDialogType, nFlags, SFX2_IMPL_DIALOG_CONFIG, _pPreferredParent ); 2463cdf0e10cSrcweir mxImp = mpImp; 2464cdf0e10cSrcweir } 2465cdf0e10cSrcweir 2466cdf0e10cSrcweir // ------------------------------------------------------------------------ 2467cdf0e10cSrcweir FileDialogHelper::FileDialogHelper( 2468cdf0e10cSrcweir sal_Int16 nDialogType, 2469cdf0e10cSrcweir sal_Int64 nFlags, 2470cdf0e10cSrcweir const ::rtl::OUString& aFilterUIName, 2471cdf0e10cSrcweir const ::rtl::OUString& aExtName, 2472cdf0e10cSrcweir const ::rtl::OUString& rStandardDir, 2473cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList, 2474cdf0e10cSrcweir Window* _pPreferredParent ) 2475cdf0e10cSrcweir { 2476cdf0e10cSrcweir mpImp = new FileDialogHelper_Impl( this, nDialogType, nFlags, SFX2_IMPL_DIALOG_CONFIG, _pPreferredParent,rStandardDir, rBlackList ); 2477cdf0e10cSrcweir mxImp = mpImp; 2478cdf0e10cSrcweir 2479cdf0e10cSrcweir // the wildcard here is expected in form "*.extension" 2480cdf0e10cSrcweir ::rtl::OUString aWildcard; 2481cdf0e10cSrcweir if ( aExtName.indexOf( (sal_Unicode)'*' ) != 0 ) 2482cdf0e10cSrcweir { 2483cdf0e10cSrcweir if ( aExtName.getLength() && aExtName.indexOf( (sal_Unicode)'.' ) != 0 ) 2484cdf0e10cSrcweir aWildcard = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "*." ) ); 2485cdf0e10cSrcweir else 2486cdf0e10cSrcweir aWildcard = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "*" ) ); 2487cdf0e10cSrcweir } 2488cdf0e10cSrcweir 2489cdf0e10cSrcweir aWildcard += aExtName; 2490cdf0e10cSrcweir 2491cdf0e10cSrcweir ::rtl::OUString aUIString = 2492cdf0e10cSrcweir ::sfx2::addExtension( aFilterUIName, aWildcard, ( WB_OPEN == ( nFlags & WB_OPEN ) ), *mpImp ); 2493cdf0e10cSrcweir AddFilter( aUIString, aWildcard ); 2494cdf0e10cSrcweir } 2495cdf0e10cSrcweir 2496cdf0e10cSrcweir // ------------------------------------------------------------------------ 2497cdf0e10cSrcweir FileDialogHelper::~FileDialogHelper() 2498cdf0e10cSrcweir { 2499cdf0e10cSrcweir mpImp->dispose(); 2500cdf0e10cSrcweir mxImp.clear(); 2501cdf0e10cSrcweir } 2502cdf0e10cSrcweir 2503cdf0e10cSrcweir // ------------------------------------------------------------------------ 2504cdf0e10cSrcweir void FileDialogHelper::CreateMatcher( const String& rFactory ) 2505cdf0e10cSrcweir { 2506cdf0e10cSrcweir mpImp->createMatcher( SfxObjectShell::GetServiceNameFromFactory(rFactory) ); 2507cdf0e10cSrcweir } 2508cdf0e10cSrcweir 2509cdf0e10cSrcweir // ------------------------------------------------------------------------ 2510cdf0e10cSrcweir void FileDialogHelper::SetControlHelpIds( const sal_Int16* _pControlId, const char** _pHelpId ) 2511cdf0e10cSrcweir { 2512cdf0e10cSrcweir mpImp->setControlHelpIds( _pControlId, _pHelpId ); 2513cdf0e10cSrcweir } 2514cdf0e10cSrcweir 2515cdf0e10cSrcweir void FileDialogHelper::SetContext( Context _eNewContext ) 2516cdf0e10cSrcweir { 2517cdf0e10cSrcweir mpImp->SetContext( _eNewContext ); 2518cdf0e10cSrcweir } 2519cdf0e10cSrcweir 2520cdf0e10cSrcweir // ------------------------------------------------------------------------ 2521cdf0e10cSrcweir IMPL_LINK( FileDialogHelper, ExecuteSystemFilePicker, void*, EMPTYARG ) 2522cdf0e10cSrcweir { 2523cdf0e10cSrcweir m_nError = mpImp->execute(); 2524cdf0e10cSrcweir if ( m_aDialogClosedLink.IsSet() ) 2525cdf0e10cSrcweir m_aDialogClosedLink.Call( this ); 2526cdf0e10cSrcweir 2527cdf0e10cSrcweir return 0L; 2528cdf0e10cSrcweir } 2529cdf0e10cSrcweir 2530cdf0e10cSrcweir // ------------------------------------------------------------------------ 2531cdf0e10cSrcweir // rDirPath has to be a directory 2532cdf0e10cSrcweir ErrCode FileDialogHelper::Execute( SvStringsDtor*& rpURLList, 2533cdf0e10cSrcweir SfxItemSet *& rpSet, 2534cdf0e10cSrcweir String& rFilter, 2535cdf0e10cSrcweir const String& rDirPath ) 2536cdf0e10cSrcweir { 2537cdf0e10cSrcweir SetDisplayFolder( rDirPath ); 2538cdf0e10cSrcweir return mpImp->execute( rpURLList, rpSet, rFilter ); 2539cdf0e10cSrcweir } 2540cdf0e10cSrcweir 2541cdf0e10cSrcweir 2542cdf0e10cSrcweir // ------------------------------------------------------------------------ 2543cdf0e10cSrcweir ErrCode FileDialogHelper::Execute() 2544cdf0e10cSrcweir { 2545cdf0e10cSrcweir return mpImp->execute(); 2546cdf0e10cSrcweir } 2547cdf0e10cSrcweir 2548cdf0e10cSrcweir // ------------------------------------------------------------------------ 2549cdf0e10cSrcweir ErrCode FileDialogHelper::Execute( SfxItemSet *& rpSet, 2550cdf0e10cSrcweir String& rFilter ) 2551cdf0e10cSrcweir { 2552cdf0e10cSrcweir ErrCode nRet; 2553cdf0e10cSrcweir SvStringsDtor* pURLList; 2554cdf0e10cSrcweir 2555cdf0e10cSrcweir nRet = mpImp->execute( pURLList, rpSet, rFilter ); 2556cdf0e10cSrcweir 2557cdf0e10cSrcweir delete pURLList; 2558cdf0e10cSrcweir 2559cdf0e10cSrcweir return nRet; 2560cdf0e10cSrcweir } 2561cdf0e10cSrcweir 2562cdf0e10cSrcweir void FileDialogHelper::StartExecuteModal( const Link& rEndDialogHdl ) 2563cdf0e10cSrcweir { 2564cdf0e10cSrcweir m_aDialogClosedLink = rEndDialogHdl; 2565cdf0e10cSrcweir m_nError = ERRCODE_NONE; 2566cdf0e10cSrcweir if ( mpImp->isSystemFilePicker() ) 2567cdf0e10cSrcweir Application::PostUserEvent( LINK( this, FileDialogHelper, ExecuteSystemFilePicker ) ); 2568cdf0e10cSrcweir else 2569cdf0e10cSrcweir mpImp->implStartExecute(); 2570cdf0e10cSrcweir } 2571cdf0e10cSrcweir 2572cdf0e10cSrcweir // ------------------------------------------------------------------------ 2573cdf0e10cSrcweir 2574cdf0e10cSrcweir short FileDialogHelper::GetDialogType() const 2575cdf0e10cSrcweir { 2576cdf0e10cSrcweir return mpImp ? mpImp->m_nDialogType : 0; 2577cdf0e10cSrcweir } 2578cdf0e10cSrcweir 2579cdf0e10cSrcweir // ------------------------------------------------------------------------ 2580cdf0e10cSrcweir 2581cdf0e10cSrcweir sal_Bool FileDialogHelper::IsPasswordEnabled() const 2582cdf0e10cSrcweir { 2583cdf0e10cSrcweir return mpImp ? mpImp->isPasswordEnabled() : sal_False; 2584cdf0e10cSrcweir } 2585cdf0e10cSrcweir 2586cdf0e10cSrcweir // ------------------------------------------------------------------------ 2587cdf0e10cSrcweir 2588cdf0e10cSrcweir String FileDialogHelper::GetRealFilter() const 2589cdf0e10cSrcweir { 2590cdf0e10cSrcweir String sFilter; 2591cdf0e10cSrcweir if ( mpImp ) 2592cdf0e10cSrcweir mpImp->getRealFilter( sFilter ); 2593cdf0e10cSrcweir return sFilter; 2594cdf0e10cSrcweir } 2595cdf0e10cSrcweir 2596cdf0e10cSrcweir // ------------------------------------------------------------------------ 2597cdf0e10cSrcweir void FileDialogHelper::SetTitle( const String& rNewTitle ) 2598cdf0e10cSrcweir { 2599cdf0e10cSrcweir if ( mpImp->mxFileDlg.is() ) 2600cdf0e10cSrcweir mpImp->mxFileDlg->setTitle( rNewTitle ); 2601cdf0e10cSrcweir } 2602cdf0e10cSrcweir 2603cdf0e10cSrcweir // ------------------------------------------------------------------------ 2604cdf0e10cSrcweir String FileDialogHelper::GetPath() const 2605cdf0e10cSrcweir { 2606cdf0e10cSrcweir OUString aPath; 2607cdf0e10cSrcweir 2608cdf0e10cSrcweir if ( mpImp->mlLastURLs.size() > 0) 2609cdf0e10cSrcweir return mpImp->mlLastURLs[0]; 2610cdf0e10cSrcweir 2611cdf0e10cSrcweir if ( mpImp->mxFileDlg.is() ) 2612cdf0e10cSrcweir { 2613cdf0e10cSrcweir Sequence < OUString > aPathSeq = mpImp->mxFileDlg->getFiles(); 2614cdf0e10cSrcweir 2615cdf0e10cSrcweir if ( aPathSeq.getLength() == 1 ) 2616cdf0e10cSrcweir { 2617cdf0e10cSrcweir aPath = aPathSeq[0]; 2618cdf0e10cSrcweir } 2619cdf0e10cSrcweir } 2620cdf0e10cSrcweir 2621cdf0e10cSrcweir return aPath; 2622cdf0e10cSrcweir } 2623cdf0e10cSrcweir 2624cdf0e10cSrcweir // ------------------------------------------------------------------------ 2625cdf0e10cSrcweir Sequence < OUString > FileDialogHelper::GetMPath() const 2626cdf0e10cSrcweir { 2627cdf0e10cSrcweir if ( mpImp->mlLastURLs.size() > 0) 2628cdf0e10cSrcweir return mpImp->mlLastURLs.getAsConstList(); 2629cdf0e10cSrcweir 2630cdf0e10cSrcweir if ( mpImp->mxFileDlg.is() ) 2631cdf0e10cSrcweir return mpImp->mxFileDlg->getFiles(); 2632cdf0e10cSrcweir else 2633cdf0e10cSrcweir { 2634cdf0e10cSrcweir Sequence < OUString > aEmpty; 2635cdf0e10cSrcweir return aEmpty; 2636cdf0e10cSrcweir } 2637cdf0e10cSrcweir } 2638cdf0e10cSrcweir 2639cdf0e10cSrcweir // ------------------------------------------------------------------------ 2640cdf0e10cSrcweir Sequence< ::rtl::OUString > FileDialogHelper::GetSelectedFiles() const 2641cdf0e10cSrcweir { 2642cdf0e10cSrcweir // a) the new way (optional!) 2643cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > aResultSeq; 2644cdf0e10cSrcweir uno::Reference< XFilePicker2 > xPickNew(mpImp->mxFileDlg, UNO_QUERY); 2645cdf0e10cSrcweir if (xPickNew.is()) 2646cdf0e10cSrcweir { 2647cdf0e10cSrcweir aResultSeq = xPickNew->getSelectedFiles(); 2648cdf0e10cSrcweir } 2649cdf0e10cSrcweir // b) the olde way ... non optional. 2650cdf0e10cSrcweir else 2651cdf0e10cSrcweir { 2652cdf0e10cSrcweir uno::Reference< XFilePicker > xPickOld(mpImp->mxFileDlg, UNO_QUERY_THROW); 2653cdf0e10cSrcweir Sequence< OUString > lFiles = xPickOld->getFiles(); 2654cdf0e10cSrcweir ::sal_Int32 nFiles = lFiles.getLength(); 2655cdf0e10cSrcweir if ( nFiles > 1 ) 2656cdf0e10cSrcweir { 2657cdf0e10cSrcweir aResultSeq = Sequence< ::rtl::OUString >( nFiles-1 ); 2658cdf0e10cSrcweir 2659cdf0e10cSrcweir INetURLObject aPath( lFiles[0] ); 2660cdf0e10cSrcweir aPath.setFinalSlash(); 2661cdf0e10cSrcweir 2662cdf0e10cSrcweir for (::sal_Int32 i = 1; i < nFiles; i++) 2663cdf0e10cSrcweir { 2664cdf0e10cSrcweir if (i == 1) 2665cdf0e10cSrcweir aPath.Append( lFiles[i] ); 2666cdf0e10cSrcweir else 2667cdf0e10cSrcweir aPath.setName( lFiles[i] ); 2668cdf0e10cSrcweir 2669cdf0e10cSrcweir aResultSeq[i-1] = ::rtl::OUString(aPath.GetMainURL( INetURLObject::NO_DECODE )); 2670cdf0e10cSrcweir } 2671cdf0e10cSrcweir } 2672cdf0e10cSrcweir else 2673cdf0e10cSrcweir aResultSeq = lFiles; 2674cdf0e10cSrcweir } 2675cdf0e10cSrcweir 2676cdf0e10cSrcweir return aResultSeq; 2677cdf0e10cSrcweir } 2678cdf0e10cSrcweir 2679cdf0e10cSrcweir // ------------------------------------------------------------------------ 2680cdf0e10cSrcweir String FileDialogHelper::GetDisplayDirectory() const 2681cdf0e10cSrcweir { 2682cdf0e10cSrcweir return mpImp->getPath(); 2683cdf0e10cSrcweir } 2684cdf0e10cSrcweir 2685cdf0e10cSrcweir // ------------------------------------------------------------------------ 2686cdf0e10cSrcweir String FileDialogHelper::GetCurrentFilter() const 2687cdf0e10cSrcweir { 2688cdf0e10cSrcweir return mpImp->getFilter(); 2689cdf0e10cSrcweir } 2690cdf0e10cSrcweir 2691cdf0e10cSrcweir // ------------------------------------------------------------------------ 2692cdf0e10cSrcweir ErrCode FileDialogHelper::GetGraphic( Graphic& rGraphic ) const 2693cdf0e10cSrcweir { 2694cdf0e10cSrcweir return mpImp->getGraphic( rGraphic ); 2695cdf0e10cSrcweir } 2696cdf0e10cSrcweir 2697cdf0e10cSrcweir // ------------------------------------------------------------------------ 2698cdf0e10cSrcweir static int impl_isFolder( const OUString& rPath ) 2699cdf0e10cSrcweir { 2700cdf0e10cSrcweir uno::Reference< task::XInteractionHandler > xHandler; 2701cdf0e10cSrcweir try 2702cdf0e10cSrcweir { 2703cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW ); 2704cdf0e10cSrcweir xHandler.set( xFactory->createInstance( DEFINE_CONST_OUSTRING( "com.sun.star.task.InteractionHandler" ) ), 2705cdf0e10cSrcweir uno::UNO_QUERY_THROW ); 2706cdf0e10cSrcweir } 2707cdf0e10cSrcweir catch ( Exception const & ) 2708cdf0e10cSrcweir { 2709cdf0e10cSrcweir } 2710cdf0e10cSrcweir 2711cdf0e10cSrcweir ::rtl::Reference< ::comphelper::StillReadWriteInteraction > aHandler = new ::comphelper::StillReadWriteInteraction( xHandler ); 2712cdf0e10cSrcweir 2713cdf0e10cSrcweir try 2714cdf0e10cSrcweir { 2715cdf0e10cSrcweir ::ucbhelper::Content aContent( 2716cdf0e10cSrcweir rPath, new ::ucbhelper::CommandEnvironment( static_cast< task::XInteractionHandler* > ( aHandler.get() ), uno::Reference< ucb::XProgressHandler >() ) ); 2717cdf0e10cSrcweir if ( aContent.isFolder() ) 2718cdf0e10cSrcweir return 1; 2719cdf0e10cSrcweir 2720cdf0e10cSrcweir return 0; 2721cdf0e10cSrcweir } 2722cdf0e10cSrcweir catch ( Exception const & ) 2723cdf0e10cSrcweir { 2724cdf0e10cSrcweir } 2725cdf0e10cSrcweir 2726cdf0e10cSrcweir return -1; 2727cdf0e10cSrcweir } 2728cdf0e10cSrcweir 2729cdf0e10cSrcweir void FileDialogHelper::SetDisplayDirectory( const String& _rPath ) 2730cdf0e10cSrcweir { 2731cdf0e10cSrcweir if ( !_rPath.Len() ) 2732cdf0e10cSrcweir return; 2733cdf0e10cSrcweir 2734cdf0e10cSrcweir // if the given path isn't a folder, we cut off the last part 2735cdf0e10cSrcweir // and take it as filename and the rest of the path should be 2736cdf0e10cSrcweir // the folder 2737cdf0e10cSrcweir 2738cdf0e10cSrcweir INetURLObject aObj( _rPath ); 2739cdf0e10cSrcweir 2740cdf0e10cSrcweir ::rtl::OUString sFileName = aObj.GetName( INetURLObject::DECODE_WITH_CHARSET ); 2741cdf0e10cSrcweir aObj.removeSegment(); 2742cdf0e10cSrcweir ::rtl::OUString sPath = aObj.GetMainURL( INetURLObject::NO_DECODE ); 2743cdf0e10cSrcweir 2744cdf0e10cSrcweir int nIsFolder = impl_isFolder( _rPath ); 2745cdf0e10cSrcweir if ( nIsFolder == 0 || 2746cdf0e10cSrcweir ( nIsFolder == -1 && impl_isFolder( sPath ) == 1 ) ) 2747cdf0e10cSrcweir { 2748cdf0e10cSrcweir mpImp->setFileName( sFileName ); 2749cdf0e10cSrcweir mpImp->displayFolder( sPath ); 2750cdf0e10cSrcweir } 2751cdf0e10cSrcweir else 2752cdf0e10cSrcweir { 2753cdf0e10cSrcweir INetURLObject aObjPathName( _rPath ); 2754cdf0e10cSrcweir ::rtl::OUString sFolder( aObjPathName.GetMainURL( INetURLObject::NO_DECODE ) ); 2755cdf0e10cSrcweir if ( sFolder.getLength() == 0 ) 2756cdf0e10cSrcweir { 2757cdf0e10cSrcweir // _rPath is not a valid path -> fallback to home directory 2758cdf0e10cSrcweir vos:: OSecurity aSecurity; 2759cdf0e10cSrcweir aSecurity.getHomeDir( sFolder ); 2760cdf0e10cSrcweir } 2761cdf0e10cSrcweir mpImp->displayFolder( sFolder ); 2762cdf0e10cSrcweir } 2763cdf0e10cSrcweir } 2764cdf0e10cSrcweir 2765cdf0e10cSrcweir // ------------------------------------------------------------------------ 2766cdf0e10cSrcweir void FileDialogHelper::SetDisplayFolder( const String& _rURL ) 2767cdf0e10cSrcweir { 2768cdf0e10cSrcweir mpImp->displayFolder( _rURL ); 2769cdf0e10cSrcweir } 2770cdf0e10cSrcweir 2771cdf0e10cSrcweir // ------------------------------------------------------------------------ 2772cdf0e10cSrcweir void FileDialogHelper::SetFileName( const String& _rFileName ) 2773cdf0e10cSrcweir { 2774cdf0e10cSrcweir mpImp->setFileName( _rFileName ); 2775cdf0e10cSrcweir } 2776cdf0e10cSrcweir 2777cdf0e10cSrcweir // ------------------------------------------------------------------------ 2778cdf0e10cSrcweir void FileDialogHelper::AddFilter( const String& rFilterName, 2779cdf0e10cSrcweir const String& rExtension ) 2780cdf0e10cSrcweir { 2781cdf0e10cSrcweir mpImp->addFilter( rFilterName, rExtension ); 2782cdf0e10cSrcweir } 2783cdf0e10cSrcweir 2784cdf0e10cSrcweir // ------------------------------------------------------------------------ 2785cdf0e10cSrcweir void FileDialogHelper::SetCurrentFilter( const String& rFilter ) 2786cdf0e10cSrcweir { 2787cdf0e10cSrcweir String sFilter( rFilter ); 2788cdf0e10cSrcweir if ( mpImp->isShowFilterExtensionEnabled() ) 2789cdf0e10cSrcweir sFilter = mpImp->getFilterWithExtension( rFilter ); 2790cdf0e10cSrcweir mpImp->setFilter( sFilter ); 2791cdf0e10cSrcweir } 2792cdf0e10cSrcweir 2793cdf0e10cSrcweir // ------------------------------------------------------------------------ 2794cdf0e10cSrcweir uno::Reference < XFilePicker > FileDialogHelper::GetFilePicker() const 2795cdf0e10cSrcweir { 2796cdf0e10cSrcweir return mpImp->mxFileDlg; 2797cdf0e10cSrcweir } 2798cdf0e10cSrcweir 2799cdf0e10cSrcweir // ------------------------------------------------------------------------ 2800cdf0e10cSrcweir sal_Int16 FileDialogHelper::getDialogType( sal_Int64 nFlags ) const 2801cdf0e10cSrcweir { 2802cdf0e10cSrcweir sal_Int16 nDialogType = FILEOPEN_SIMPLE; 2803cdf0e10cSrcweir 2804cdf0e10cSrcweir if ( nFlags & WB_SAVEAS ) 2805cdf0e10cSrcweir { 2806cdf0e10cSrcweir if ( nFlags & SFXWB_PASSWORD ) 2807cdf0e10cSrcweir nDialogType = FILESAVE_AUTOEXTENSION_PASSWORD; 2808cdf0e10cSrcweir else 2809cdf0e10cSrcweir nDialogType = FILESAVE_SIMPLE; 2810cdf0e10cSrcweir } 2811cdf0e10cSrcweir else if ( nFlags & SFXWB_GRAPHIC ) 2812cdf0e10cSrcweir { 2813cdf0e10cSrcweir if ( nFlags & SFXWB_SHOWSTYLES ) 2814cdf0e10cSrcweir nDialogType = FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE; 2815cdf0e10cSrcweir else 2816cdf0e10cSrcweir nDialogType = FILEOPEN_LINK_PREVIEW; 2817cdf0e10cSrcweir } 2818cdf0e10cSrcweir else if ( SFXWB_INSERT != ( nFlags & SFXWB_INSERT ) ) 2819cdf0e10cSrcweir nDialogType = FILEOPEN_READONLY_VERSION; 2820cdf0e10cSrcweir 2821cdf0e10cSrcweir return nDialogType; 2822cdf0e10cSrcweir } 2823cdf0e10cSrcweir 2824cdf0e10cSrcweir // ------------------------------------------------------------------------ 2825cdf0e10cSrcweir // XFilePickerListener Methods 2826cdf0e10cSrcweir // ------------------------------------------------------------------------ 2827cdf0e10cSrcweir void SAL_CALL FileDialogHelper::FileSelectionChanged( const FilePickerEvent& aEvent ) 2828cdf0e10cSrcweir { 2829cdf0e10cSrcweir mpImp->handleFileSelectionChanged( aEvent ); 2830cdf0e10cSrcweir } 2831cdf0e10cSrcweir 2832cdf0e10cSrcweir // ------------------------------------------------------------------------ 2833cdf0e10cSrcweir void SAL_CALL FileDialogHelper::DirectoryChanged( const FilePickerEvent& aEvent ) 2834cdf0e10cSrcweir { 2835cdf0e10cSrcweir mpImp->handleDirectoryChanged( aEvent ); 2836cdf0e10cSrcweir } 2837cdf0e10cSrcweir 2838cdf0e10cSrcweir // ------------------------------------------------------------------------ 2839cdf0e10cSrcweir OUString SAL_CALL FileDialogHelper::HelpRequested( const FilePickerEvent& aEvent ) 2840cdf0e10cSrcweir { 2841cdf0e10cSrcweir return mpImp->handleHelpRequested( aEvent ); 2842cdf0e10cSrcweir } 2843cdf0e10cSrcweir 2844cdf0e10cSrcweir // ------------------------------------------------------------------------ 2845cdf0e10cSrcweir void SAL_CALL FileDialogHelper::ControlStateChanged( const FilePickerEvent& aEvent ) 2846cdf0e10cSrcweir { 2847cdf0e10cSrcweir mpImp->handleControlStateChanged( aEvent ); 2848cdf0e10cSrcweir } 2849cdf0e10cSrcweir 2850cdf0e10cSrcweir // ------------------------------------------------------------------------ 2851cdf0e10cSrcweir void SAL_CALL FileDialogHelper::DialogSizeChanged() 2852cdf0e10cSrcweir { 2853cdf0e10cSrcweir mpImp->handleDialogSizeChanged(); 2854cdf0e10cSrcweir } 2855cdf0e10cSrcweir 2856cdf0e10cSrcweir // ------------------------------------------------------------------------ 2857cdf0e10cSrcweir void SAL_CALL FileDialogHelper::DialogClosed( const DialogClosedEvent& _rEvent ) 2858cdf0e10cSrcweir { 2859cdf0e10cSrcweir m_nError = ( RET_OK == _rEvent.DialogResult ) ? ERRCODE_NONE : ERRCODE_ABORT; 2860cdf0e10cSrcweir if ( m_aDialogClosedLink.IsSet() ) 2861cdf0e10cSrcweir m_aDialogClosedLink.Call( this ); 2862cdf0e10cSrcweir } 2863cdf0e10cSrcweir 2864cdf0e10cSrcweir // ------------------------------------------------------------------------ 2865cdf0e10cSrcweir // ------------------------------------------------------------------------ 2866cdf0e10cSrcweir // ------------------------------------------------------------------------ 2867cdf0e10cSrcweir 2868cdf0e10cSrcweir ErrCode FileOpenDialog_Impl( sal_Int64 nFlags, 2869cdf0e10cSrcweir const String& rFact, 2870cdf0e10cSrcweir SvStringsDtor *& rpURLList, 2871cdf0e10cSrcweir String& rFilter, 2872cdf0e10cSrcweir SfxItemSet *& rpSet, 2873cdf0e10cSrcweir const String* pPath, 2874cdf0e10cSrcweir sal_Int16 nDialog, 2875cdf0e10cSrcweir const String& rStandardDir, 2876cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList ) 2877cdf0e10cSrcweir { 2878cdf0e10cSrcweir ErrCode nRet; 2879cdf0e10cSrcweir FileDialogHelper aDialog( nFlags, rFact, nDialog, 0, 0, rStandardDir, rBlackList ); 2880cdf0e10cSrcweir 2881cdf0e10cSrcweir String aPath; 2882cdf0e10cSrcweir if ( pPath ) 2883cdf0e10cSrcweir aPath = *pPath; 2884cdf0e10cSrcweir 2885cdf0e10cSrcweir nRet = aDialog.Execute( rpURLList, rpSet, rFilter, aPath ); 2886cdf0e10cSrcweir DBG_ASSERT( rFilter.SearchAscii(": ") == STRING_NOTFOUND, "Old filter name used!"); 2887cdf0e10cSrcweir 2888cdf0e10cSrcweir return nRet; 2889cdf0e10cSrcweir } 2890cdf0e10cSrcweir 2891cdf0e10cSrcweir 2892cdf0e10cSrcweir // ------------------------------------------------------------------------ 2893cdf0e10cSrcweir String EncodeSpaces_Impl( const String& rSource ) 2894cdf0e10cSrcweir { 2895cdf0e10cSrcweir String sRet( rSource ); 2896cdf0e10cSrcweir sRet.SearchAndReplaceAll( DEFINE_CONST_UNICODE( " " ), DEFINE_CONST_UNICODE( "%20" ) ); 2897cdf0e10cSrcweir return sRet; 2898cdf0e10cSrcweir } 2899cdf0e10cSrcweir 2900cdf0e10cSrcweir // ------------------------------------------------------------------------ 2901cdf0e10cSrcweir String DecodeSpaces_Impl( const String& rSource ) 2902cdf0e10cSrcweir { 2903cdf0e10cSrcweir String sRet( rSource ); 2904cdf0e10cSrcweir sRet.SearchAndReplaceAll( DEFINE_CONST_UNICODE( "%20" ), DEFINE_CONST_UNICODE( " " ) ); 2905cdf0e10cSrcweir return sRet; 2906cdf0e10cSrcweir } 2907cdf0e10cSrcweir 2908cdf0e10cSrcweir // ------------------------------------------------------------------------ 2909cdf0e10cSrcweir 2910cdf0e10cSrcweir } // end of namespace sfx2 2911cdf0e10cSrcweir 2912