2001-04-27 09:35:34 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* $RCSfile: filedlghelper.cxx,v $
|
|
|
|
*
|
2001-10-26 08:12:01 +00:00
|
|
|
* $Revision: 1.64 $
|
2001-04-27 09:35:34 +00:00
|
|
|
*
|
2001-10-26 08:12:01 +00:00
|
|
|
* last change: $Author: fs $ $Date: 2001-10-26 09:12:01 $
|
2001-04-27 09:35:34 +00:00
|
|
|
*
|
|
|
|
* The Contents of this file are made available subject to the terms of
|
|
|
|
* either of the following licenses
|
|
|
|
*
|
|
|
|
* - GNU Lesser General Public License Version 2.1
|
|
|
|
* - Sun Industry Standards Source License Version 1.1
|
|
|
|
*
|
|
|
|
* Sun Microsystems Inc., October, 2000
|
|
|
|
*
|
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2000 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Sun Industry Standards Source License Version 1.1
|
|
|
|
* =================================================
|
|
|
|
* The contents of this file are subject to the Sun Industry Standards
|
|
|
|
* Source License Version 1.1 (the "License"); You may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of the
|
|
|
|
* License at http://www.openoffice.org/license.html.
|
|
|
|
*
|
|
|
|
* Software provided under this License is provided on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
|
|
|
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
|
|
|
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
|
|
|
* See the License for the specific provisions governing your rights and
|
|
|
|
* obligations concerning the Software.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* Copyright: 2000 by Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s): _______________________________________
|
|
|
|
*
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2001-06-15 07:49:37 +00:00
|
|
|
|
2001-09-18 13:57:51 +00:00
|
|
|
#ifndef _SAL_TYPES_H_
|
2001-06-15 07:49:37 +00:00
|
|
|
#include <sal/types.h>
|
2001-09-18 13:57:51 +00:00
|
|
|
#endif
|
2001-04-27 09:35:34 +00:00
|
|
|
|
2001-09-18 13:57:51 +00:00
|
|
|
#ifndef _LIST_
|
2001-06-29 08:14:59 +00:00
|
|
|
#include <list>
|
2001-09-18 13:57:51 +00:00
|
|
|
#endif
|
2001-06-29 08:14:59 +00:00
|
|
|
|
2001-04-27 09:35:34 +00:00
|
|
|
#ifndef _CPPUHELPER_IMPLBASE1_HXX_
|
|
|
|
#include <cppuhelper/implbase1.hxx>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
|
|
|
|
#include <com/sun/star/lang/XInitialization.hpp>
|
|
|
|
#endif
|
|
|
|
|
2001-06-15 07:49:37 +00:00
|
|
|
#ifndef _COM_SUN_STAR_UI_DIALOGS_COMMONFILEPICKERELEMENTIDS_HPP_
|
|
|
|
#include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_UI_DIALOGS_EXECUTABLEDIALOGRESULTS_HPP_
|
|
|
|
#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_UI_DIALOGS_EXTENDEDFILEPICKERELEMENTIDS_HPP_
|
|
|
|
#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
|
2001-04-27 09:35:34 +00:00
|
|
|
#endif
|
2001-06-15 07:49:37 +00:00
|
|
|
#ifndef _COM_SUN_STAR_UI_DIALOGS_FILEPREVIEWIMAGEFORMATS_HPP_
|
|
|
|
#include <com/sun/star/ui/dialogs/FilePreviewImageFormats.hpp>
|
2001-04-27 09:35:34 +00:00
|
|
|
#endif
|
2001-10-26 08:12:01 +00:00
|
|
|
#ifndef _COM_SUN_STAR_UI_DIALOGS_CONTROLACTIONS_HPP_
|
|
|
|
#include <com/sun/star/ui/dialogs/ControlActions.hpp>
|
2001-04-27 09:35:34 +00:00
|
|
|
#endif
|
2001-06-15 07:49:37 +00:00
|
|
|
#ifndef _COM_SUN_STAR_UI_DIALOGS_TEMPLATEDESCRIPTION_HPP_
|
|
|
|
#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
|
2001-04-27 09:35:34 +00:00
|
|
|
#endif
|
2001-06-15 07:49:37 +00:00
|
|
|
#ifndef _COM_SUN_STAR_UI_DIALOGS_XFILEPICKERCONTROLACCESS_HPP_
|
|
|
|
#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
|
2001-04-27 09:35:34 +00:00
|
|
|
#endif
|
2001-06-15 07:49:37 +00:00
|
|
|
#ifndef _COM_SUN_STAR_UI_DIALOGS_XFILEPICKER_HPP_
|
|
|
|
#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
|
2001-04-27 09:35:34 +00:00
|
|
|
#endif
|
2001-06-15 07:49:37 +00:00
|
|
|
#ifndef _COM_SUN_STAR_UI_DIALOGS_XFILEPICKERLISTENER_HPP_
|
|
|
|
#include <com/sun/star/ui/dialogs/XFilePickerListener.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_UI_DIALOGS_XFILEPICKERNOTIFIER_HPP_
|
|
|
|
#include <com/sun/star/ui/dialogs/XFilePickerNotifier.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_UI_DIALOGS_XFILEPREVIEW_HPP_
|
|
|
|
#include <com/sun/star/ui/dialogs/XFilePreview.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_UI_DIALOGS_XFILTERMANAGER_HPP_
|
|
|
|
#include <com/sun/star/ui/dialogs/XFilterManager.hpp>
|
2001-04-27 09:35:34 +00:00
|
|
|
#endif
|
2001-09-18 13:57:51 +00:00
|
|
|
#ifndef _COM_SUN_STAR_UI_DIALOGS_XFILTERGROUPMANAGER_HPP_
|
|
|
|
#include <com/sun/star/ui/dialogs/XFilterGroupManager.hpp>
|
|
|
|
#endif
|
2001-10-12 06:37:51 +00:00
|
|
|
#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
|
|
|
|
#include <com/sun/star/lang/XServiceInfo.hpp>
|
|
|
|
#endif
|
2001-10-26 08:12:01 +00:00
|
|
|
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
|
|
|
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
|
|
|
#endif
|
2001-04-27 09:35:34 +00:00
|
|
|
|
|
|
|
#ifndef _COMPHELPER_PROCESSFACTORY_HXX_
|
|
|
|
#include <comphelper/processfactory.hxx>
|
|
|
|
#endif
|
|
|
|
|
2001-09-18 13:57:51 +00:00
|
|
|
#ifndef _FILEDLGHELPER_HXX
|
2001-06-15 07:49:37 +00:00
|
|
|
#include "filedlghelper.hxx"
|
2001-09-18 13:57:51 +00:00
|
|
|
#endif
|
2001-04-27 09:35:34 +00:00
|
|
|
|
|
|
|
#ifndef _URLOBJ_HXX
|
|
|
|
#include <tools/urlobj.hxx>
|
|
|
|
#endif
|
2001-08-10 07:28:16 +00:00
|
|
|
#ifndef _SV_HELP_HXX
|
|
|
|
#include <vcl/help.hxx>
|
|
|
|
#endif
|
2001-04-27 09:35:34 +00:00
|
|
|
|
2001-09-18 13:57:51 +00:00
|
|
|
#ifndef _UNTOOLS_UCBSTREAMHELPER_HXX
|
2001-06-15 07:49:37 +00:00
|
|
|
#include <unotools/ucbstreamhelper.hxx>
|
2001-09-18 13:57:51 +00:00
|
|
|
#endif
|
|
|
|
#ifndef _UNOTOOLS_UCBHELPER_HXX
|
2001-07-03 14:43:04 +00:00
|
|
|
#include <unotools/ucbhelper.hxx>
|
2001-09-18 13:57:51 +00:00
|
|
|
#endif
|
|
|
|
#ifndef _UNOTOOLS_LOCALFILEHELPER_HXX
|
2001-07-17 15:11:24 +00:00
|
|
|
#include <unotools/localfilehelper.hxx>
|
2001-09-18 13:57:51 +00:00
|
|
|
#endif
|
|
|
|
#ifndef _VOS_THREAD_HXX_
|
2001-09-06 08:02:13 +00:00
|
|
|
#include <vos/thread.hxx>
|
2001-09-18 13:57:51 +00:00
|
|
|
#endif
|
|
|
|
#ifndef _VOS_MUTEX_HXX_
|
2001-09-06 08:02:13 +00:00
|
|
|
#include <vos/mutex.hxx>
|
2001-09-18 13:57:51 +00:00
|
|
|
#endif
|
2001-07-17 15:11:24 +00:00
|
|
|
|
2001-09-18 13:57:51 +00:00
|
|
|
#ifndef _SV_CVTGRF_HXX
|
2001-06-15 07:49:37 +00:00
|
|
|
#include <vcl/cvtgrf.hxx>
|
2001-09-18 13:57:51 +00:00
|
|
|
#endif
|
2001-06-15 07:49:37 +00:00
|
|
|
|
2001-05-16 12:23:43 +00:00
|
|
|
#ifndef _SV_MSGBOX_HXX
|
|
|
|
#include <vcl/msgbox.hxx>
|
|
|
|
#endif
|
|
|
|
|
2001-07-25 10:41:50 +00:00
|
|
|
#ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX
|
|
|
|
#include <svtools/pathoptions.hxx>
|
|
|
|
#endif
|
2001-04-27 09:35:34 +00:00
|
|
|
#ifndef _SFXITEMSET_HXX
|
|
|
|
#include <svtools/itemset.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SFXENUMITEM_HXX
|
|
|
|
#include <svtools/eitem.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SFXINTITEM_HXX
|
|
|
|
#include <svtools/intitem.hxx>
|
|
|
|
#endif
|
2001-05-16 12:23:43 +00:00
|
|
|
#ifndef _SFXSTRITEM_HXX
|
|
|
|
#include <svtools/stritem.hxx>
|
|
|
|
#endif
|
2001-04-27 09:35:34 +00:00
|
|
|
#define _SVSTDARR_STRINGSDTOR
|
|
|
|
#include <svtools/svstdarr.hxx>
|
2001-05-07 14:01:07 +00:00
|
|
|
#ifndef _FILTER_HXX
|
|
|
|
#include <svtools/filter.hxx>
|
|
|
|
#endif
|
2001-04-27 09:35:34 +00:00
|
|
|
#ifndef INCLUDED_SVTOOLS_VIEWOPTIONS_HXX
|
|
|
|
#include <svtools/viewoptions.hxx>
|
|
|
|
#endif
|
2001-08-10 07:28:16 +00:00
|
|
|
#ifndef _SVT_HELPID_HRC
|
|
|
|
#include <svtools/helpid.hrc>
|
|
|
|
#endif
|
2001-10-25 10:20:56 +00:00
|
|
|
#ifndef _UCBHELPER_CONTENT_HXX
|
|
|
|
#include <ucbhelper/content.hxx>
|
|
|
|
#endif
|
2001-04-27 09:35:34 +00:00
|
|
|
|
|
|
|
#ifndef _SFXAPP_HXX
|
|
|
|
#include "app.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _SFXDOCFILE_HXX
|
|
|
|
#include "docfile.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _SFX_OBJFAC_HXX
|
|
|
|
#include "docfac.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _SFX_FCONTNR_HXX
|
|
|
|
#include "fcontnr.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _SFX_OPENFLAG_HXX
|
|
|
|
#include "openflag.hxx"
|
|
|
|
#endif
|
2001-05-16 12:23:43 +00:00
|
|
|
#ifndef _SFX_PASSWD_HXX
|
|
|
|
#include <passwd.hxx>
|
|
|
|
#endif
|
2001-04-27 09:35:34 +00:00
|
|
|
|
2001-09-18 13:57:51 +00:00
|
|
|
#ifndef _SFX_SFXRESID_HXX
|
2001-04-27 09:35:34 +00:00
|
|
|
#include "sfxresid.hxx"
|
2001-09-18 13:57:51 +00:00
|
|
|
#endif
|
|
|
|
#ifndef _SFXSIDS_HRC
|
2001-04-27 09:35:34 +00:00
|
|
|
#include "sfxsids.hrc"
|
2001-09-18 13:57:51 +00:00
|
|
|
#endif
|
|
|
|
#ifndef _SFX_EXPLORER_HRC
|
2001-04-27 09:35:34 +00:00
|
|
|
#include "explorer.hrc"
|
2001-09-18 13:57:51 +00:00
|
|
|
#endif
|
|
|
|
#ifndef _SFX_FILEDLGHELPER_HRC
|
2001-06-15 07:49:37 +00:00
|
|
|
#include "filedlghelper.hrc"
|
2001-09-18 13:57:51 +00:00
|
|
|
#endif
|
2001-10-01 15:34:14 +00:00
|
|
|
#ifndef SFX2_FILTERGROUPING_HXX
|
|
|
|
#include "filtergrouping.hxx"
|
|
|
|
#endif
|
2001-10-12 10:02:19 +00:00
|
|
|
#ifndef _VECTOR_
|
|
|
|
#include <vector>
|
|
|
|
#endif
|
2001-04-27 09:35:34 +00:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2001-06-19 14:34:05 +00:00
|
|
|
using namespace ::com::sun::star::container;
|
2001-04-27 09:35:34 +00:00
|
|
|
using namespace ::com::sun::star::lang;
|
2001-06-15 07:49:37 +00:00
|
|
|
using namespace ::com::sun::star::ui::dialogs;
|
2001-04-27 09:35:34 +00:00
|
|
|
using namespace ::com::sun::star::uno;
|
2001-09-18 13:57:51 +00:00
|
|
|
using namespace ::com::sun::star::beans;
|
2001-04-27 09:35:34 +00:00
|
|
|
using namespace ::rtl;
|
|
|
|
using namespace ::cppu;
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2001-06-21 11:21:14 +00:00
|
|
|
#define IODLG_CONFIGNAME String(DEFINE_CONST_UNICODE("FilePicker_Save"))
|
|
|
|
#define IMPGRF_CONFIGNAME String(DEFINE_CONST_UNICODE("FilePicker_Graph"))
|
2001-10-12 12:08:18 +00:00
|
|
|
#define USERITEM_NAME OUString::createFromAscii( "UserItem" )
|
2001-04-27 09:35:34 +00:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
namespace sfx2 {
|
|
|
|
|
2001-06-27 05:25:44 +00:00
|
|
|
String EncodeSpaces_Impl( const String& rSource );
|
|
|
|
String DecodeSpaces_Impl( const String& rSource );
|
|
|
|
|
2001-10-12 10:02:19 +00:00
|
|
|
|
2001-04-27 09:35:34 +00:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
class FileDialogHelper_Impl : public WeakImplHelper1< XFilePickerListener >
|
|
|
|
{
|
|
|
|
friend class FileDialogHelper;
|
|
|
|
|
|
|
|
Reference < XFilePicker > mxFileDlg;
|
|
|
|
|
2001-10-12 10:02:19 +00:00
|
|
|
static ::std::vector< Reference < XFilePicker > >
|
|
|
|
maDialogQueue;
|
|
|
|
|
2001-05-07 14:01:07 +00:00
|
|
|
SfxFilterMatcher *mpMatcher;
|
2001-07-11 08:42:26 +00:00
|
|
|
GraphicFilter *mpGraphicFilter;
|
|
|
|
|
2001-05-07 14:01:07 +00:00
|
|
|
OUString maPath;
|
|
|
|
OUString maCurFilter;
|
2001-07-24 10:10:59 +00:00
|
|
|
OUString maSelectFilter;
|
2001-06-15 07:49:37 +00:00
|
|
|
Timer maPreViewTimer;
|
2001-07-06 11:12:41 +00:00
|
|
|
Graphic maGraphic;
|
2001-09-06 08:02:13 +00:00
|
|
|
FileDialogHelper* mpParent;
|
2001-06-15 07:49:37 +00:00
|
|
|
|
2001-09-27 15:52:29 +00:00
|
|
|
const short m_nDialogType;
|
|
|
|
|
2001-05-07 14:01:07 +00:00
|
|
|
ErrCode mnError;
|
2001-10-02 15:36:26 +00:00
|
|
|
sal_Bool mbHasPassword : 1;
|
|
|
|
sal_Bool mbIsPwdEnabled : 1;
|
|
|
|
sal_Bool m_bHaveFilterOptions : 1;
|
|
|
|
sal_Bool mbHasVersions : 1;
|
|
|
|
sal_Bool mbHasAutoExt : 1;
|
|
|
|
sal_Bool mbHasLink : 1;
|
|
|
|
sal_Bool mbHasPreview : 1;
|
|
|
|
sal_Bool mbShowPreview : 1;
|
|
|
|
sal_Bool mbIsSaveDlg : 1;
|
|
|
|
|
|
|
|
sal_Bool mbDeleteMatcher : 1;
|
|
|
|
sal_Bool mbInsert : 1;
|
2001-10-12 06:37:51 +00:00
|
|
|
sal_Bool mbSystemPicker : 1;
|
2001-04-27 09:35:34 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void addFilters( sal_uInt32 nFlags,
|
|
|
|
const SfxObjectFactory& rFactory );
|
2001-06-29 08:14:59 +00:00
|
|
|
void addFilter( const OUString& rFilterName,
|
|
|
|
const OUString& rExtension );
|
2001-05-07 14:01:07 +00:00
|
|
|
void addGraphicFilter();
|
2001-04-27 09:35:34 +00:00
|
|
|
void enablePasswordBox();
|
2001-10-02 15:36:26 +00:00
|
|
|
void updateFilterOptionsBox();
|
2001-04-27 09:35:34 +00:00
|
|
|
void updateVersions();
|
|
|
|
void dispose();
|
|
|
|
|
2001-05-04 10:52:27 +00:00
|
|
|
void loadConfig();
|
|
|
|
void saveConfig();
|
2001-04-27 09:35:34 +00:00
|
|
|
|
2001-10-02 15:36:26 +00:00
|
|
|
const SfxFilter* getCurentSfxFilter();
|
|
|
|
sal_Bool updateExtendedControl( sal_Int16 _nExtendedControlId, sal_Bool _bEnable );
|
|
|
|
|
2001-07-11 08:42:26 +00:00
|
|
|
ErrCode getGraphic( const OUString& rURL, Graphic& rGraphic ) const;
|
2001-07-25 10:41:50 +00:00
|
|
|
void setDefaultValues();
|
2001-07-11 08:42:26 +00:00
|
|
|
|
2001-10-12 10:02:19 +00:00
|
|
|
void preExecute();
|
|
|
|
void postExecute();
|
2001-10-12 06:37:51 +00:00
|
|
|
sal_Int16 implDoExecute();
|
|
|
|
|
2001-10-12 10:02:19 +00:00
|
|
|
void pushBackPicker();
|
|
|
|
void popPicker();
|
|
|
|
|
2001-10-26 08:12:01 +00:00
|
|
|
void correctVirtualDialogType();
|
|
|
|
|
|
|
|
void setControlHelpIds( const sal_Int16* _pControlId, const sal_Int32* _pHelpId );
|
|
|
|
void setDialogHelpId( const sal_Int32 _nHelpId );
|
|
|
|
|
2001-06-15 07:49:37 +00:00
|
|
|
DECL_LINK( TimeOutHdl_Impl, Timer* );
|
2001-09-06 08:02:13 +00:00
|
|
|
DECL_LINK( HandleEvent, FileDialogHelper* );
|
2001-06-15 07:49:37 +00:00
|
|
|
|
2001-04-27 09:35:34 +00:00
|
|
|
public:
|
|
|
|
// XFilePickerListener methods
|
2001-06-15 07:49:37 +00:00
|
|
|
virtual void SAL_CALL fileSelectionChanged( const FilePickerEvent& aEvent ) throw ( RuntimeException );
|
|
|
|
virtual void SAL_CALL directoryChanged( const FilePickerEvent& aEvent ) throw ( RuntimeException );
|
|
|
|
virtual OUString SAL_CALL helpRequested( const FilePickerEvent& aEvent ) throw ( RuntimeException );
|
|
|
|
virtual void SAL_CALL controlStateChanged( const FilePickerEvent& aEvent ) throw ( RuntimeException );
|
|
|
|
virtual void SAL_CALL dialogSizeChanged() throw ( RuntimeException );
|
2001-04-27 09:35:34 +00:00
|
|
|
|
|
|
|
// XEventListener methods
|
2001-06-15 07:49:37 +00:00
|
|
|
virtual void SAL_CALL disposing( const EventObject& Source ) throw ( RuntimeException );
|
2001-04-27 09:35:34 +00:00
|
|
|
|
2001-09-06 08:02:13 +00:00
|
|
|
// handle XFilePickerListener events
|
|
|
|
void handleFileSelectionChanged( const FilePickerEvent& aEvent );
|
|
|
|
void handleDirectoryChanged( const FilePickerEvent& aEvent );
|
|
|
|
OUString handleHelpRequested( const FilePickerEvent& aEvent );
|
|
|
|
void handleControlStateChanged( const FilePickerEvent& aEvent );
|
|
|
|
void handleDialogSizeChanged();
|
|
|
|
|
2001-04-27 09:35:34 +00:00
|
|
|
// Own methods
|
2001-09-06 08:02:13 +00:00
|
|
|
FileDialogHelper_Impl( FileDialogHelper* pParent,
|
|
|
|
const short nDialogType,
|
|
|
|
sal_uInt32 nFlags );
|
|
|
|
~FileDialogHelper_Impl();
|
2001-04-27 09:35:34 +00:00
|
|
|
|
2001-06-18 09:56:17 +00:00
|
|
|
ErrCode execute( SvStringsDtor*& rpURLList,
|
2001-04-27 09:35:34 +00:00
|
|
|
SfxItemSet *& rpSet,
|
|
|
|
String& rFilter );
|
|
|
|
ErrCode execute();
|
2001-05-04 10:52:27 +00:00
|
|
|
|
2001-06-21 10:12:24 +00:00
|
|
|
void setPath( const OUString& rPath );
|
2001-06-15 07:49:37 +00:00
|
|
|
void setFilter( const OUString& rFilter );
|
2001-05-04 10:52:27 +00:00
|
|
|
|
2001-06-27 05:25:44 +00:00
|
|
|
OUString getPath() const;
|
2001-06-15 07:49:37 +00:00
|
|
|
OUString getFilter() const;
|
2001-06-15 13:23:30 +00:00
|
|
|
OUString getRealFilter() const;
|
2001-07-06 11:12:41 +00:00
|
|
|
|
2001-07-11 08:42:26 +00:00
|
|
|
ErrCode getGraphic( Graphic& rGraphic ) const;
|
2001-10-12 10:02:19 +00:00
|
|
|
|
2001-10-12 12:53:19 +00:00
|
|
|
static Reference< XFilePicker > getTopMostFilePicker( );
|
2001-04-27 09:35:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
// ----------- FileDialogHelper_Impl ---------------------------
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
|
2001-10-12 10:02:19 +00:00
|
|
|
::std::vector< Reference < XFilePicker > > FileDialogHelper_Impl::maDialogQueue;
|
|
|
|
|
2001-04-27 09:35:34 +00:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
// XFilePickerListener Methods
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
void SAL_CALL FileDialogHelper_Impl::fileSelectionChanged( const FilePickerEvent& aEvent ) throw ( RuntimeException )
|
2001-09-06 08:02:13 +00:00
|
|
|
{
|
|
|
|
::vos::OGuard aGuard( Application::GetSolarMutex() );
|
|
|
|
mpParent->FileSelectionChanged( aEvent );
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
void SAL_CALL FileDialogHelper_Impl::directoryChanged( const FilePickerEvent& aEvent ) throw ( RuntimeException )
|
|
|
|
{
|
|
|
|
::vos::OGuard aGuard( Application::GetSolarMutex() );
|
|
|
|
mpParent->DirectoryChanged( aEvent );
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
OUString SAL_CALL FileDialogHelper_Impl::helpRequested( const FilePickerEvent& aEvent ) throw ( RuntimeException )
|
|
|
|
{
|
|
|
|
::vos::OGuard aGuard( Application::GetSolarMutex() );
|
|
|
|
return mpParent->HelpRequested( aEvent );
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
void SAL_CALL FileDialogHelper_Impl::controlStateChanged( const FilePickerEvent& aEvent ) throw ( RuntimeException )
|
|
|
|
{
|
|
|
|
::vos::OGuard aGuard( Application::GetSolarMutex() );
|
|
|
|
mpParent->ControlStateChanged( aEvent );
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
void SAL_CALL FileDialogHelper_Impl::dialogSizeChanged() throw ( RuntimeException )
|
|
|
|
{
|
|
|
|
::vos::OGuard aGuard( Application::GetSolarMutex() );
|
|
|
|
mpParent->DialogSizeChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
// handle XFilePickerListener events
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
void FileDialogHelper_Impl::handleFileSelectionChanged( const FilePickerEvent& aEvent )
|
2001-04-27 09:35:34 +00:00
|
|
|
{
|
|
|
|
if ( mbHasVersions )
|
|
|
|
updateVersions();
|
2001-06-15 07:49:37 +00:00
|
|
|
|
|
|
|
if ( mbShowPreview )
|
|
|
|
maPreViewTimer.Start();
|
2001-04-27 09:35:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
2001-09-06 08:02:13 +00:00
|
|
|
void FileDialogHelper_Impl::handleDirectoryChanged( const FilePickerEvent& aEvent )
|
2001-06-15 07:49:37 +00:00
|
|
|
{
|
|
|
|
if ( mbShowPreview )
|
|
|
|
TimeOutHdl_Impl( NULL );
|
|
|
|
}
|
2001-04-27 09:35:34 +00:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
2001-09-06 08:02:13 +00:00
|
|
|
OUString FileDialogHelper_Impl::handleHelpRequested( const FilePickerEvent& aEvent )
|
2001-06-15 07:49:37 +00:00
|
|
|
{
|
2001-08-10 07:28:16 +00:00
|
|
|
//!!! todo: cache the help strings (here or TRA)
|
|
|
|
|
|
|
|
ULONG nHelpId = 0;
|
2001-09-06 08:02:13 +00:00
|
|
|
// mapping from element id -> help id
|
2001-08-10 07:28:16 +00:00
|
|
|
switch ( aEvent.ElementId )
|
|
|
|
{
|
|
|
|
case ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION :
|
|
|
|
nHelpId = HID_FILESAVE_AUTOEXTENSION;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ExtendedFilePickerElementIds::CHECKBOX_PASSWORD :
|
|
|
|
nHelpId = HID_FILESAVE_SAVEWITHPASSWORD;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS :
|
|
|
|
nHelpId = HID_FILESAVE_CUSTOMIZEFILTER;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ExtendedFilePickerElementIds::CHECKBOX_READONLY :
|
|
|
|
nHelpId = HID_FILEOPEN_READONLY;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ExtendedFilePickerElementIds::CHECKBOX_LINK :
|
|
|
|
nHelpId = HID_FILEDLG_LINK_CB;
|
|
|
|
break;
|
2001-06-15 07:49:37 +00:00
|
|
|
|
2001-08-10 07:28:16 +00:00
|
|
|
case ExtendedFilePickerElementIds::CHECKBOX_PREVIEW :
|
|
|
|
nHelpId = HID_FILEDLG_PREVIEW_CB;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ExtendedFilePickerElementIds::PUSHBUTTON_PLAY :
|
|
|
|
nHelpId = HID_FILESAVE_DOPLAY;
|
|
|
|
break;
|
|
|
|
|
2001-10-04 12:05:43 +00:00
|
|
|
case ExtendedFilePickerElementIds::LISTBOX_VERSION_LABEL :
|
2001-08-10 07:28:16 +00:00
|
|
|
case ExtendedFilePickerElementIds::LISTBOX_VERSION :
|
|
|
|
nHelpId = HID_FILEOPEN_VERSION;
|
|
|
|
break;
|
|
|
|
|
2001-10-04 12:05:43 +00:00
|
|
|
case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE_LABEL :
|
2001-08-10 07:28:16 +00:00
|
|
|
case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE :
|
|
|
|
nHelpId = HID_FILESAVE_TEMPLATE;
|
|
|
|
break;
|
|
|
|
|
2001-10-04 12:05:43 +00:00
|
|
|
case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE_LABEL :
|
2001-08-10 07:28:16 +00:00
|
|
|
case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE :
|
|
|
|
nHelpId = HID_FILEOPEN_IMAGE_TEMPLATE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ExtendedFilePickerElementIds::CHECKBOX_SELECTION :
|
|
|
|
nHelpId = HID_FILESAVE_SELECTION;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
DBG_ERRORFILE( "invalid element id" );
|
|
|
|
}
|
|
|
|
|
|
|
|
OUString aHelpText;
|
|
|
|
Help* pHelp = Application::GetHelp();
|
|
|
|
if ( pHelp )
|
|
|
|
aHelpText = String( pHelp->GetHelpText( nHelpId, NULL ) );
|
2001-06-15 07:49:37 +00:00
|
|
|
return aHelpText;
|
|
|
|
}
|
2001-04-27 09:35:34 +00:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
2001-09-06 08:02:13 +00:00
|
|
|
void FileDialogHelper_Impl::handleControlStateChanged( const FilePickerEvent& aEvent )
|
2001-04-27 09:35:34 +00:00
|
|
|
{
|
2001-10-02 15:36:26 +00:00
|
|
|
switch ( aEvent.ElementId )
|
2001-06-15 07:49:37 +00:00
|
|
|
{
|
2001-10-02 15:36:26 +00:00
|
|
|
case CommonFilePickerElementIds::LISTBOX_FILTER:
|
|
|
|
updateFilterOptionsBox();
|
|
|
|
enablePasswordBox();
|
|
|
|
break;
|
2001-06-15 07:49:37 +00:00
|
|
|
|
2001-10-02 15:36:26 +00:00
|
|
|
case ExtendedFilePickerElementIds::CHECKBOX_PREVIEW:
|
|
|
|
if ( mbHasPreview )
|
2001-06-15 07:49:37 +00:00
|
|
|
{
|
2001-10-02 15:36:26 +00:00
|
|
|
Reference< XFilePickerControlAccess > xCtrlAccess( mxFileDlg, UNO_QUERY );
|
2001-06-21 10:12:24 +00:00
|
|
|
|
2001-10-02 15:36:26 +00:00
|
|
|
// check, wether or not we have to display a preview
|
|
|
|
if ( xCtrlAccess.is() )
|
2001-06-21 10:12:24 +00:00
|
|
|
{
|
2001-10-02 15:36:26 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
Any aValue = xCtrlAccess->getValue( ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, 0 );
|
|
|
|
sal_Bool bShowPreview = sal_False;
|
|
|
|
|
|
|
|
if ( aValue >>= bShowPreview )
|
|
|
|
{
|
|
|
|
mbShowPreview = bShowPreview;
|
|
|
|
TimeOutHdl_Impl( NULL );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( Exception )
|
|
|
|
{
|
|
|
|
DBG_ERRORFILE( "FileDialogHelper_Impl::controlStateChanged: caught an exception!" );
|
|
|
|
}
|
2001-06-21 10:12:24 +00:00
|
|
|
}
|
2001-06-15 07:49:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
2001-09-06 08:02:13 +00:00
|
|
|
void FileDialogHelper_Impl::handleDialogSizeChanged()
|
2001-06-15 07:49:37 +00:00
|
|
|
{
|
|
|
|
if ( mbShowPreview )
|
|
|
|
TimeOutHdl_Impl( NULL );
|
2001-04-27 09:35:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
// XEventListener Methods
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
void SAL_CALL FileDialogHelper_Impl::disposing( const EventObject& Source ) throw ( RuntimeException )
|
|
|
|
{
|
2001-09-06 08:02:13 +00:00
|
|
|
::vos::OGuard aGuard( Application::GetSolarMutex() );
|
2001-04-27 09:35:34 +00:00
|
|
|
dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
void FileDialogHelper_Impl::dispose()
|
|
|
|
{
|
|
|
|
if ( mxFileDlg.is() )
|
|
|
|
{
|
|
|
|
// remove the event listener
|
|
|
|
Reference< XFilePickerNotifier > xNotifier( mxFileDlg, UNO_QUERY );
|
|
|
|
if ( xNotifier.is() )
|
|
|
|
xNotifier->removeFilePickerListener( this );
|
|
|
|
mxFileDlg.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
2001-10-02 15:36:26 +00:00
|
|
|
const SfxFilter* FileDialogHelper_Impl::getCurentSfxFilter()
|
2001-04-27 09:35:34 +00:00
|
|
|
{
|
|
|
|
Reference< XFilterManager > xFltMgr( mxFileDlg, UNO_QUERY );
|
2001-10-02 15:36:26 +00:00
|
|
|
::rtl::OUString aFilterName = xFltMgr->getCurrentFilter();
|
2001-07-19 15:07:48 +00:00
|
|
|
|
2001-10-02 15:36:26 +00:00
|
|
|
const SfxFilter* pFilter = NULL;
|
2001-06-15 13:23:30 +00:00
|
|
|
if ( mpMatcher )
|
2001-10-02 15:36:26 +00:00
|
|
|
pFilter = mpMatcher->GetFilter4UIName( aFilterName, 0, SFX_FILTER_NOTINFILEDLG );
|
2001-04-27 09:35:34 +00:00
|
|
|
|
2001-10-02 15:36:26 +00:00
|
|
|
return pFilter;
|
|
|
|
}
|
2001-04-27 09:35:34 +00:00
|
|
|
|
2001-10-02 15:36:26 +00:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
sal_Bool FileDialogHelper_Impl::updateExtendedControl( sal_Int16 _nExtendedControlId, sal_Bool _bEnable )
|
|
|
|
{
|
|
|
|
sal_Bool bIsEnabled = sal_False;
|
2001-04-27 09:35:34 +00:00
|
|
|
|
2001-10-02 15:36:26 +00:00
|
|
|
Reference < XFilePickerControlAccess > xCtrlAccess( mxFileDlg, UNO_QUERY );
|
|
|
|
if ( xCtrlAccess.is() )
|
|
|
|
{
|
2001-06-21 10:12:24 +00:00
|
|
|
try
|
|
|
|
{
|
2001-10-02 15:36:26 +00:00
|
|
|
xCtrlAccess->enableControl( _nExtendedControlId, _bEnable );
|
|
|
|
bIsEnabled = _bEnable;
|
|
|
|
}
|
|
|
|
catch( const IllegalArgumentException& )
|
|
|
|
{
|
|
|
|
DBG_ERROR( "FileDialogHelper_Impl::updateExtendedControl: caught an exception!" );
|
2001-06-21 10:12:24 +00:00
|
|
|
}
|
2001-06-15 13:23:30 +00:00
|
|
|
}
|
2001-10-02 15:36:26 +00:00
|
|
|
return bIsEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
struct CheckFilterOptionsCapability
|
|
|
|
{
|
|
|
|
sal_Bool operator() ( const SfxFilter* _pFilter )
|
|
|
|
{
|
|
|
|
return _pFilter
|
|
|
|
&& ( 0 != ( _pFilter->GetFilterFlags() & SFX_FILTER_USESOPTIONS ) );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
void FileDialogHelper_Impl::updateFilterOptionsBox()
|
|
|
|
{
|
|
|
|
if ( !m_bHaveFilterOptions )
|
|
|
|
return;
|
|
|
|
|
|
|
|
updateExtendedControl(
|
|
|
|
ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS,
|
|
|
|
CheckFilterOptionsCapability()( getCurentSfxFilter() )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
struct CheckPasswordCapability
|
|
|
|
{
|
|
|
|
sal_Bool operator() ( const SfxFilter* _pFilter )
|
|
|
|
{
|
|
|
|
return _pFilter
|
|
|
|
&& _pFilter->UsesStorage()
|
|
|
|
&& ( SOFFICE_FILEFORMAT_60 <= _pFilter->GetVersion() );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
void FileDialogHelper_Impl::enablePasswordBox()
|
|
|
|
{
|
|
|
|
if ( ! mbHasPassword )
|
|
|
|
return;
|
|
|
|
|
|
|
|
mbIsPwdEnabled = updateExtendedControl(
|
|
|
|
ExtendedFilePickerElementIds::CHECKBOX_PASSWORD,
|
|
|
|
CheckPasswordCapability()( getCurentSfxFilter() )
|
|
|
|
);
|
2001-04-27 09:35:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
void FileDialogHelper_Impl::updateVersions()
|
|
|
|
{
|
|
|
|
Sequence < OUString > aEntries;
|
2001-06-15 07:49:37 +00:00
|
|
|
Sequence < OUString > aPathSeq = mxFileDlg->getFiles();
|
2001-04-27 09:35:34 +00:00
|
|
|
|
|
|
|
if ( aPathSeq.getLength() == 1 )
|
|
|
|
{
|
|
|
|
INetURLObject aObj( aPathSeq[0] );
|
|
|
|
|
2001-07-03 14:43:04 +00:00
|
|
|
if ( ( aObj.GetProtocol() == INET_PROT_FILE ) &&
|
|
|
|
( utl::UCBContentHelper::IsDocument( aObj.GetMainURL( INetURLObject::NO_DECODE ) ) ) )
|
2001-04-27 09:35:34 +00:00
|
|
|
{
|
2001-06-22 06:41:36 +00:00
|
|
|
SfxMedium aMed( aObj.GetMainURL( INetURLObject::NO_DECODE ),
|
|
|
|
SFX_STREAM_READONLY_MAKECOPY, TRUE );
|
2001-04-27 09:35:34 +00:00
|
|
|
const SfxVersionTableDtor* pVerTable = aMed.GetVersionList();
|
|
|
|
|
|
|
|
if ( pVerTable )
|
|
|
|
{
|
|
|
|
SvStringsDtor* pVersions = pVerTable->GetVersions();
|
|
|
|
|
|
|
|
aEntries.realloc( pVersions->Count() + 1 );
|
|
|
|
aEntries[0] = OUString( String ( SfxResId( STR_SFX_FILEDLG_ACTUALVERSION ) ) );
|
|
|
|
|
|
|
|
for ( USHORT i = 0; i < pVersions->Count(); i++ )
|
|
|
|
aEntries[ i + 1 ] = OUString( *(pVersions->GetObject(i)) );
|
|
|
|
|
|
|
|
delete pVersions;
|
|
|
|
}
|
|
|
|
else if ( aMed.GetStorage() )
|
|
|
|
{
|
2001-09-06 07:16:11 +00:00
|
|
|
SfxFilterFlags nMust = SFX_FILTER_IMPORT | SFX_FILTER_OWN, nDont = SFX_FILTER_NOTINSTALLED | SFX_FILTER_STARONEFILTER;
|
|
|
|
if ( SFX_APP()->GetFilterMatcher().GetFilter4ClipBoardId( aMed.GetStorage()->GetFormat(), nMust, nDont ) )
|
|
|
|
{
|
|
|
|
aEntries.realloc( 1 );
|
|
|
|
aEntries[0] = OUString( String ( SfxResId( STR_SFX_FILEDLG_ACTUALVERSION ) ) );
|
|
|
|
}
|
2001-04-27 09:35:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Reference < XFilePickerControlAccess > xDlg( mxFileDlg, UNO_QUERY );
|
|
|
|
Any aValue;
|
2001-06-15 07:49:37 +00:00
|
|
|
|
2001-06-21 10:12:24 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
xDlg->setValue( ExtendedFilePickerElementIds::LISTBOX_VERSION,
|
2001-10-26 08:12:01 +00:00
|
|
|
ControlActions::DELETE_ITEMS, aValue );
|
2001-06-21 10:12:24 +00:00
|
|
|
}
|
|
|
|
catch( IllegalArgumentException ){}
|
2001-06-15 07:49:37 +00:00
|
|
|
|
2001-06-15 09:48:13 +00:00
|
|
|
sal_Int32 nCount = aEntries.getLength();
|
2001-04-27 09:35:34 +00:00
|
|
|
|
2001-06-15 09:48:13 +00:00
|
|
|
if ( nCount )
|
|
|
|
{
|
2001-06-21 10:12:24 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
aValue <<= aEntries;
|
|
|
|
xDlg->setValue( ExtendedFilePickerElementIds::LISTBOX_VERSION,
|
2001-10-26 08:12:01 +00:00
|
|
|
ControlActions::ADD_ITEMS, aValue );
|
2001-06-21 10:12:24 +00:00
|
|
|
|
|
|
|
Any aPos;
|
|
|
|
aPos <<= (sal_Int32) 0;
|
|
|
|
xDlg->setValue( ExtendedFilePickerElementIds::LISTBOX_VERSION,
|
2001-10-26 08:12:01 +00:00
|
|
|
ControlActions::SET_SELECT_ITEM, aPos );
|
2001-06-21 10:12:24 +00:00
|
|
|
}
|
|
|
|
catch( IllegalArgumentException ){}
|
2001-06-15 09:48:13 +00:00
|
|
|
}
|
2001-06-15 07:49:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
IMPL_LINK( FileDialogHelper_Impl, TimeOutHdl_Impl, Timer*, EMPTYARG )
|
|
|
|
{
|
|
|
|
if ( !mbHasPreview )
|
|
|
|
return 0;
|
|
|
|
|
2001-07-06 11:12:41 +00:00
|
|
|
maGraphic.Clear();
|
|
|
|
|
2001-06-15 07:49:37 +00:00
|
|
|
Any aAny;
|
|
|
|
Reference < XFilePreview > xFilePicker( mxFileDlg, UNO_QUERY );
|
|
|
|
|
|
|
|
if ( ! xFilePicker.is() )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
Sequence < OUString > aPathSeq = mxFileDlg->getFiles();
|
|
|
|
|
|
|
|
if ( mbShowPreview && ( aPathSeq.getLength() == 1 ) )
|
|
|
|
{
|
|
|
|
OUString aURL = aPathSeq[0];
|
|
|
|
|
2001-07-11 08:42:26 +00:00
|
|
|
if ( ERRCODE_NONE == getGraphic( aURL, maGraphic ) )
|
2001-06-15 07:49:37 +00:00
|
|
|
{
|
2001-07-11 08:42:26 +00:00
|
|
|
Bitmap aBmp = maGraphic.GetBitmap();
|
2001-06-15 07:49:37 +00:00
|
|
|
|
2001-07-11 08:42:26 +00:00
|
|
|
// scale the bitmap to the correct size
|
|
|
|
sal_Int32 nOutWidth = xFilePicker->getAvailableWidth();
|
|
|
|
sal_Int32 nOutHeight = xFilePicker->getAvailableHeight();
|
|
|
|
sal_Int32 nBmpWidth = aBmp.GetSizePixel().Width();
|
|
|
|
sal_Int32 nBmpHeight = aBmp.GetSizePixel().Height();
|
2001-06-15 07:49:37 +00:00
|
|
|
|
2001-07-11 08:42:26 +00:00
|
|
|
double nXRatio = (double) nOutWidth / nBmpWidth;
|
|
|
|
double nYRatio = (double) nOutHeight / nBmpHeight;
|
2001-06-15 07:49:37 +00:00
|
|
|
|
2001-07-11 08:42:26 +00:00
|
|
|
if ( nXRatio < nYRatio )
|
|
|
|
aBmp.Scale( nXRatio, nXRatio );
|
|
|
|
else
|
|
|
|
aBmp.Scale( nYRatio, nYRatio );
|
2001-06-15 07:49:37 +00:00
|
|
|
|
2001-07-11 08:42:26 +00:00
|
|
|
nBmpWidth = aBmp.GetSizePixel().Width();
|
|
|
|
nBmpHeight = aBmp.GetSizePixel().Height();
|
2001-06-15 07:49:37 +00:00
|
|
|
|
2001-07-11 08:42:26 +00:00
|
|
|
sal_Int32 nMidX = ( nOutWidth - nBmpWidth ) / 2;
|
|
|
|
sal_Int32 nMidY = ( nOutHeight - nBmpHeight ) / 2;
|
2001-06-15 07:49:37 +00:00
|
|
|
|
2001-07-11 08:42:26 +00:00
|
|
|
Rectangle aSrcRect( 0, 0, nBmpWidth, nBmpHeight );
|
|
|
|
Rectangle aDstRect( nMidX, nMidY, nMidX + nBmpWidth, nMidY + nBmpHeight );
|
2001-06-15 07:49:37 +00:00
|
|
|
|
2001-10-08 10:22:34 +00:00
|
|
|
// #92765# Have to conserve bitmap palette. There is no method setting it explicitely,
|
|
|
|
// thus doing it this way. Performance penalty is low, as bitmap is refcounted.
|
|
|
|
Bitmap aScaledBmp( aBmp );
|
|
|
|
aScaledBmp.SetSizePixel( Size(nOutWidth, nOutHeight) );
|
2001-07-11 08:42:26 +00:00
|
|
|
aScaledBmp.Erase( Color( COL_WHITE ) );
|
|
|
|
aScaledBmp.CopyPixel( aDstRect, aSrcRect, &aBmp );
|
2001-06-15 07:49:37 +00:00
|
|
|
|
2001-07-11 08:42:26 +00:00
|
|
|
// and copy it into the Any
|
|
|
|
SvMemoryStream aData;
|
2001-06-15 07:49:37 +00:00
|
|
|
|
2001-07-11 08:42:26 +00:00
|
|
|
aData << aScaledBmp;
|
2001-06-15 07:49:37 +00:00
|
|
|
|
2001-07-11 08:42:26 +00:00
|
|
|
Sequence < sal_Int8 > aBuffer( (sal_Int8*) aData.GetData(), aData.GetSize() );
|
2001-06-15 07:49:37 +00:00
|
|
|
|
2001-07-11 08:42:26 +00:00
|
|
|
aAny <<= aBuffer;
|
|
|
|
}
|
|
|
|
}
|
2001-06-15 07:49:37 +00:00
|
|
|
|
2001-07-11 08:42:26 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
// clear the preview window
|
|
|
|
xFilePicker->setImage( FilePreviewImageFormats::BITMAP, aAny );
|
|
|
|
}
|
|
|
|
catch( IllegalArgumentException ){}
|
2001-06-15 07:49:37 +00:00
|
|
|
|
2001-07-11 08:42:26 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
ErrCode FileDialogHelper_Impl::getGraphic( const OUString& rURL,
|
|
|
|
Graphic& rGraphic ) const
|
|
|
|
{
|
|
|
|
if ( utl::UCBContentHelper::IsFolder( rURL ) )
|
|
|
|
return ERRCODE_IO_NOTAFILE;
|
|
|
|
|
2001-08-01 14:20:56 +00:00
|
|
|
if ( !mpGraphicFilter )
|
|
|
|
return ERRCODE_IO_NOTSUPPORTED;
|
|
|
|
|
2001-07-11 08:42:26 +00:00
|
|
|
// select graphic filter from dialog filter selection
|
|
|
|
OUString aCurFilter( getFilter() );
|
|
|
|
|
|
|
|
sal_uInt16 nFilter = aCurFilter.getLength() && mpGraphicFilter->GetImportFormatCount()
|
|
|
|
? mpGraphicFilter->GetImportFormatNumber( aCurFilter )
|
|
|
|
: GRFILTER_FORMAT_DONTKNOW;
|
|
|
|
|
|
|
|
INetURLObject aURLObj( rURL );
|
|
|
|
|
|
|
|
if ( aURLObj.HasError() || INET_PROT_NOT_VALID == aURLObj.GetProtocol() )
|
|
|
|
{
|
|
|
|
aURLObj.SetSmartProtocol( INET_PROT_FILE );
|
|
|
|
aURLObj.SetSmartURL( rURL );
|
|
|
|
}
|
|
|
|
|
|
|
|
ErrCode nRet = ERRCODE_NONE;
|
|
|
|
|
2001-08-20 10:57:42 +00:00
|
|
|
sal_uInt32 nFilterImportFlags = GRFILTER_I_FLAGS_SET_LOGSIZE_FOR_JPEG;
|
2001-07-11 08:42:26 +00:00
|
|
|
// non-local?
|
|
|
|
if ( INET_PROT_FILE != aURLObj.GetProtocol() )
|
|
|
|
{
|
|
|
|
SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( rURL, STREAM_READ );
|
|
|
|
|
|
|
|
if( pStream )
|
2001-08-20 10:57:42 +00:00
|
|
|
nRet = mpGraphicFilter->ImportGraphic( rGraphic, rURL, *pStream, nFilter, NULL, nFilterImportFlags );
|
2001-07-11 08:42:26 +00:00
|
|
|
else
|
2001-08-20 10:57:42 +00:00
|
|
|
nRet = mpGraphicFilter->ImportGraphic( rGraphic, aURLObj, nFilter, NULL, nFilterImportFlags );
|
2001-07-11 08:42:26 +00:00
|
|
|
delete pStream;
|
2001-06-15 07:49:37 +00:00
|
|
|
}
|
|
|
|
else
|
2001-06-21 10:12:24 +00:00
|
|
|
{
|
2001-08-20 10:57:42 +00:00
|
|
|
nRet = mpGraphicFilter->ImportGraphic( rGraphic, aURLObj, nFilter, NULL, nFilterImportFlags );
|
2001-06-21 10:12:24 +00:00
|
|
|
}
|
2001-06-15 07:49:37 +00:00
|
|
|
|
2001-07-11 08:42:26 +00:00
|
|
|
return nRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
ErrCode FileDialogHelper_Impl::getGraphic( Graphic& rGraphic ) const
|
|
|
|
{
|
|
|
|
ErrCode nRet = ERRCODE_NONE;
|
|
|
|
|
|
|
|
if ( ! maGraphic )
|
|
|
|
{
|
2001-07-20 08:46:17 +00:00
|
|
|
OUString aPath;;
|
|
|
|
Sequence < OUString > aPathSeq = mxFileDlg->getFiles();
|
|
|
|
|
|
|
|
if ( aPathSeq.getLength() == 1 )
|
|
|
|
{
|
|
|
|
aPath = aPathSeq[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( aPath.getLength() )
|
|
|
|
nRet = getGraphic( aPath, rGraphic );
|
|
|
|
else
|
|
|
|
nRet = ERRCODE_IO_GENERAL;
|
2001-07-11 08:42:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
rGraphic = maGraphic;
|
|
|
|
|
|
|
|
return nRet;
|
2001-04-27 09:35:34 +00:00
|
|
|
}
|
|
|
|
|
2001-10-12 06:37:51 +00:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
sal_Bool lcl_isSystemFilePicker( const Reference< XFilePicker >& _rxFP )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference< XServiceInfo > xSI( _rxFP, UNO_QUERY );
|
|
|
|
if ( xSI.is() && xSI->supportsService( ::rtl::OUString::createFromAscii( "com.sun.star.ui.dialogs.SystemFilePicker" ) ) )
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-27 09:35:34 +00:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
// ----------- FileDialogHelper_Impl ---------------------------
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
|
2001-09-06 08:02:13 +00:00
|
|
|
FileDialogHelper_Impl::FileDialogHelper_Impl( FileDialogHelper* pParent,
|
|
|
|
const short nDialogType,
|
2001-06-15 07:49:37 +00:00
|
|
|
sal_uInt32 nFlags )
|
2001-09-27 15:52:29 +00:00
|
|
|
:m_nDialogType( nDialogType )
|
2001-04-27 09:35:34 +00:00
|
|
|
{
|
2001-06-19 14:34:05 +00:00
|
|
|
OUString aService( RTL_CONSTASCII_USTRINGPARAM( FILE_OPEN_SERVICE_NAME ) );
|
|
|
|
|
|
|
|
Reference< XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
|
|
|
|
|
2001-04-27 09:35:34 +00:00
|
|
|
// create the file open dialog
|
2001-06-15 07:49:37 +00:00
|
|
|
// the flags can be SFXWB_INSERT or SFXWB_MULTISELECTION
|
2001-04-27 09:35:34 +00:00
|
|
|
|
2001-10-02 15:36:26 +00:00
|
|
|
mpParent = pParent;
|
|
|
|
mnError = ERRCODE_NONE;
|
|
|
|
mbHasAutoExt = sal_False;
|
|
|
|
mbHasPassword = sal_False;
|
|
|
|
m_bHaveFilterOptions = sal_False;
|
|
|
|
mbIsPwdEnabled = sal_True;
|
|
|
|
mbHasVersions = sal_False;
|
|
|
|
mbHasPreview = sal_False;
|
|
|
|
mbShowPreview = sal_False;
|
|
|
|
mbHasLink = sal_False;
|
|
|
|
mbDeleteMatcher = sal_False;
|
|
|
|
mbInsert = SFXWB_INSERT == ( nFlags & SFXWB_INSERT );
|
|
|
|
mbIsSaveDlg = sal_False;
|
2001-04-27 09:35:34 +00:00
|
|
|
|
2001-06-15 13:23:30 +00:00
|
|
|
mpMatcher = NULL;
|
2001-07-11 08:42:26 +00:00
|
|
|
mpGraphicFilter = NULL;
|
2001-06-15 13:23:30 +00:00
|
|
|
|
2001-04-27 09:35:34 +00:00
|
|
|
mxFileDlg = Reference < XFilePicker > ( xFactory->createInstance( aService ), UNO_QUERY );
|
2001-10-12 06:37:51 +00:00
|
|
|
mbSystemPicker = lcl_isSystemFilePicker( mxFileDlg );
|
2001-04-27 09:35:34 +00:00
|
|
|
|
|
|
|
Reference< XFilePickerNotifier > xNotifier( mxFileDlg, UNO_QUERY );
|
|
|
|
Reference< XInitialization > xInit( mxFileDlg, UNO_QUERY );
|
|
|
|
|
|
|
|
if ( ! mxFileDlg.is() || ! xNotifier.is() )
|
|
|
|
{
|
|
|
|
mnError = ERRCODE_ABORT;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-06-15 07:49:37 +00:00
|
|
|
Sequence < Any > aServiceType(1);
|
|
|
|
|
2001-10-26 08:12:01 +00:00
|
|
|
switch ( m_nDialogType )
|
|
|
|
{
|
2001-06-15 07:49:37 +00:00
|
|
|
case FILEOPEN_SIMPLE:
|
|
|
|
aServiceType[0] <<= TemplateDescription::FILEOPEN_SIMPLE;
|
|
|
|
break;
|
|
|
|
case FILESAVE_SIMPLE:
|
|
|
|
aServiceType[0] <<= TemplateDescription::FILESAVE_SIMPLE;
|
2001-07-17 15:11:24 +00:00
|
|
|
mbIsSaveDlg = sal_True;
|
2001-06-15 07:49:37 +00:00
|
|
|
break;
|
|
|
|
case FILESAVE_AUTOEXTENSION_PASSWORD:
|
|
|
|
aServiceType[0] <<= TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD;
|
|
|
|
mbHasPassword = sal_True;
|
|
|
|
mbHasAutoExt = sal_True;
|
2001-07-17 15:11:24 +00:00
|
|
|
mbIsSaveDlg = sal_True;
|
2001-06-15 07:49:37 +00:00
|
|
|
break;
|
|
|
|
case FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS:
|
|
|
|
aServiceType[0] <<= TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS;
|
|
|
|
mbHasPassword = sal_True;
|
2001-10-02 15:36:26 +00:00
|
|
|
m_bHaveFilterOptions = sal_True;
|
2001-06-15 07:49:37 +00:00
|
|
|
mbHasAutoExt = sal_True;
|
2001-07-17 15:11:24 +00:00
|
|
|
mbIsSaveDlg = sal_True;
|
2001-06-15 07:49:37 +00:00
|
|
|
break;
|
|
|
|
case FILESAVE_AUTOEXTENSION_SELECTION:
|
|
|
|
aServiceType[0] <<= TemplateDescription::FILESAVE_AUTOEXTENSION_SELECTION;
|
2001-09-06 08:02:13 +00:00
|
|
|
mbHasAutoExt = sal_True;
|
2001-07-17 15:11:24 +00:00
|
|
|
mbIsSaveDlg = sal_True;
|
2001-06-15 07:49:37 +00:00
|
|
|
break;
|
|
|
|
case FILESAVE_AUTOEXTENSION_TEMPLATE:
|
|
|
|
aServiceType[0] <<= TemplateDescription::FILESAVE_AUTOEXTENSION_TEMPLATE;
|
2001-09-06 08:02:13 +00:00
|
|
|
mbHasAutoExt = sal_True;
|
2001-07-17 15:11:24 +00:00
|
|
|
mbIsSaveDlg = sal_True;
|
2001-06-15 07:49:37 +00:00
|
|
|
break;
|
|
|
|
case FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE:
|
|
|
|
aServiceType[0] <<= TemplateDescription::FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE;
|
2001-05-07 14:01:07 +00:00
|
|
|
mbHasPreview = sal_True;
|
|
|
|
mbHasLink = sal_True;
|
2001-06-15 07:49:37 +00:00
|
|
|
|
|
|
|
// aPreviewTimer
|
2001-09-27 15:52:29 +00:00
|
|
|
maPreViewTimer.SetTimeout( 500 );
|
2001-06-15 07:49:37 +00:00
|
|
|
maPreViewTimer.SetTimeoutHdl( LINK( this, FileDialogHelper_Impl, TimeOutHdl_Impl ) );
|
|
|
|
break;
|
|
|
|
case FILEOPEN_PLAY:
|
|
|
|
aServiceType[0] <<= TemplateDescription::FILEOPEN_PLAY;
|
|
|
|
break;
|
|
|
|
case FILEOPEN_READONLY_VERSION:
|
|
|
|
aServiceType[0] <<= TemplateDescription::FILEOPEN_READONLY_VERSION;
|
2001-04-27 09:35:34 +00:00
|
|
|
mbHasVersions = sal_True;
|
2001-06-15 07:49:37 +00:00
|
|
|
break;
|
2001-07-25 14:48:10 +00:00
|
|
|
case FILEOPEN_LINK_PREVIEW:
|
|
|
|
aServiceType[0] <<= TemplateDescription::FILEOPEN_LINK_PREVIEW;
|
|
|
|
mbHasPreview = sal_True;
|
|
|
|
mbHasLink = sal_True;
|
|
|
|
// aPreviewTimer
|
2001-09-27 15:52:29 +00:00
|
|
|
maPreViewTimer.SetTimeout( 500 );
|
2001-07-25 14:48:10 +00:00
|
|
|
maPreViewTimer.SetTimeoutHdl( LINK( this, FileDialogHelper_Impl, TimeOutHdl_Impl ) );
|
2001-08-23 06:46:51 +00:00
|
|
|
break;
|
2001-09-06 08:02:13 +00:00
|
|
|
case FILESAVE_AUTOEXTENSION:
|
|
|
|
aServiceType[0] <<= TemplateDescription::FILESAVE_AUTOEXTENSION;
|
|
|
|
mbHasAutoExt = sal_True;
|
|
|
|
mbIsSaveDlg = sal_True;
|
|
|
|
break;
|
2001-06-15 07:49:37 +00:00
|
|
|
default:
|
|
|
|
aServiceType[0] <<= TemplateDescription::FILEOPEN_SIMPLE;
|
|
|
|
DBG_ERRORFILE( "FileDialogHelper::ctor with unknown type" );
|
2001-04-27 09:35:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( xInit.is() )
|
2001-06-15 07:49:37 +00:00
|
|
|
xInit->initialize( aServiceType );
|
2001-04-27 09:35:34 +00:00
|
|
|
|
|
|
|
// set multiselection mode
|
2001-05-07 14:01:07 +00:00
|
|
|
if ( nFlags & SFXWB_MULTISELECTION )
|
2001-04-27 09:35:34 +00:00
|
|
|
mxFileDlg->setMultiSelectionMode( sal_True );
|
|
|
|
|
2001-08-07 11:55:36 +00:00
|
|
|
if ( mbHasLink ) // generate graphic filter only on demand
|
|
|
|
addGraphicFilter();
|
|
|
|
|
2001-04-27 09:35:34 +00:00
|
|
|
// the "insert file" dialog needs another title
|
|
|
|
if ( mbInsert )
|
|
|
|
{
|
|
|
|
mxFileDlg->setTitle( OUString( String( SfxResId( STR_SFX_EXPLORERFILE_INSERT ) ) ) );
|
|
|
|
|
|
|
|
Reference < XFilePickerControlAccess > xExtDlg( mxFileDlg, UNO_QUERY );
|
|
|
|
if ( xExtDlg.is() )
|
|
|
|
{
|
2001-06-21 10:12:24 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
xExtDlg->setLabel( CommonFilePickerElementIds::PUSHBUTTON_OK,
|
|
|
|
OUString( String( SfxResId( STR_SFX_EXPLORERFILE_BUTTONINSERT ) ) ) );
|
|
|
|
}
|
|
|
|
catch( IllegalArgumentException ){}
|
2001-04-27 09:35:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// add the event listener
|
|
|
|
xNotifier->addFilePickerListener( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
FileDialogHelper_Impl::~FileDialogHelper_Impl()
|
|
|
|
{
|
2001-07-11 08:42:26 +00:00
|
|
|
delete mpGraphicFilter;
|
|
|
|
|
2001-04-27 09:35:34 +00:00
|
|
|
if ( mbDeleteMatcher )
|
|
|
|
delete mpMatcher;
|
2001-06-15 07:49:37 +00:00
|
|
|
|
|
|
|
maPreViewTimer.SetTimeoutHdl( Link() );
|
2001-04-27 09:35:34 +00:00
|
|
|
}
|
|
|
|
|
2001-09-06 08:02:13 +00:00
|
|
|
#define nMagic (sal_Int16) 0xFFFF
|
|
|
|
|
|
|
|
class PickerThread_Impl : public ::vos::OThread
|
|
|
|
{
|
|
|
|
Reference < XFilePicker > mxPicker;
|
|
|
|
::vos::OMutex maMutex;
|
|
|
|
virtual void SAL_CALL run();
|
|
|
|
sal_Int16 mnRet;
|
|
|
|
public:
|
|
|
|
PickerThread_Impl( const Reference < XFilePicker >& rPicker )
|
|
|
|
: mxPicker( rPicker ), mnRet(nMagic) {}
|
|
|
|
|
|
|
|
sal_Int16 GetReturnValue()
|
|
|
|
{ ::vos::OGuard aGuard( maMutex ); return mnRet; }
|
|
|
|
|
|
|
|
void SetReturnValue( sal_Int16 aRetValue )
|
|
|
|
{ ::vos::OGuard aGuard( maMutex ); mnRet = aRetValue; }
|
|
|
|
};
|
|
|
|
|
|
|
|
void SAL_CALL PickerThread_Impl::run()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
sal_Int16 n = mxPicker->execute();
|
|
|
|
SetReturnValue( n );
|
|
|
|
}
|
|
|
|
catch( RuntimeException& )
|
|
|
|
{
|
|
|
|
SetReturnValue( ExecutableDialogResults::CANCEL );
|
|
|
|
DBG_ERRORFILE( "RuntimeException caught" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-10-26 08:12:01 +00:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
void FileDialogHelper_Impl::setControlHelpIds( const sal_Int16* _pControlId, const sal_Int32* _pHelpId )
|
|
|
|
{
|
|
|
|
DBG_ASSERT( _pControlId && _pHelpId, "FileDialogHelper_Impl::setControlHelpIds: invalid array pointers!" );
|
|
|
|
if ( !_pControlId || !_pHelpId )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// forward these ids to the file picker
|
|
|
|
try
|
|
|
|
{
|
|
|
|
const ::rtl::OUString sHelpIdPrefix( RTL_CONSTASCII_USTRINGPARAM( "HID:" ) );
|
|
|
|
// the ids for the single controls
|
|
|
|
Reference< XFilePickerControlAccess > xControlAccess( mxFileDlg, UNO_QUERY );
|
|
|
|
if ( xControlAccess.is() )
|
|
|
|
{
|
|
|
|
while ( *_pControlId )
|
|
|
|
{
|
|
|
|
// calc the help id of the element
|
|
|
|
::rtl::OUString sId( sHelpIdPrefix );
|
|
|
|
sId += ::rtl::OUString::valueOf( *_pHelpId );
|
|
|
|
// set the help id
|
|
|
|
xControlAccess->setValue( *_pControlId, ControlActions::SET_HELP_URL, makeAny( sId ) );
|
|
|
|
|
|
|
|
++_pControlId; ++_pHelpId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
|
|
|
DBG_ERROR( "FileDialogHelper_Impl::setControlHelpIds: caught an exception while setting the help ids!" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
void FileDialogHelper_Impl::setDialogHelpId( const sal_Int32 _nHelpId )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// does the dialog haver a help URL property?
|
|
|
|
Reference< XPropertySet > xDialogProps( mxFileDlg, UNO_QUERY );
|
|
|
|
Reference< XPropertySetInfo > xInfo;
|
|
|
|
if ( xDialogProps.is() )
|
|
|
|
xInfo = xDialogProps->getPropertySetInfo( );
|
|
|
|
const ::rtl::OUString sHelpURLPropertyName( RTL_CONSTASCII_USTRINGPARAM( "HelpURL" ) );
|
|
|
|
|
|
|
|
if ( xInfo.is() && xInfo->hasPropertyByName( sHelpURLPropertyName ) )
|
|
|
|
{ // yep
|
|
|
|
::rtl::OUString sId( RTL_CONSTASCII_USTRINGPARAM( "HID:" ) );
|
|
|
|
sId += ::rtl::OUString::valueOf( _nHelpId );
|
|
|
|
xDialogProps->setPropertyValue( sHelpURLPropertyName, makeAny( sId ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
|
|
|
DBG_ERROR( "FileDialogHelper_Impl::setDialogHelpId: caught an exception while setting the help id!" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-10-12 06:37:51 +00:00
|
|
|
// ------------------------------------------------------------------------
|
2001-10-12 12:53:19 +00:00
|
|
|
Reference< XFilePicker > FileDialogHelper_Impl::getTopMostFilePicker( )
|
2001-10-12 10:02:19 +00:00
|
|
|
{
|
|
|
|
Reference< XFilePicker > xReturn;
|
2001-10-26 08:12:01 +00:00
|
|
|
DBG_ASSERT( !maDialogQueue.empty(), "FileDialogHelper_Impl::getTopMostFilePicker: no active picker!" );
|
2001-10-12 10:02:19 +00:00
|
|
|
if ( !maDialogQueue.empty() )
|
|
|
|
xReturn = *maDialogQueue.begin();
|
|
|
|
return xReturn;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
void FileDialogHelper_Impl::pushBackPicker()
|
|
|
|
{
|
|
|
|
DBG_ASSERT( mxFileDlg.is(), "FileDialogHelper_Impl::pushBackPicker: have no picker!" );
|
|
|
|
maDialogQueue.push_back( mxFileDlg );
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
void FileDialogHelper_Impl::popPicker()
|
|
|
|
{
|
|
|
|
DBG_ASSERT( !maDialogQueue.empty(), "FileDialogHelper_Impl::popPicker: no picker pushed!" );
|
|
|
|
if ( !maDialogQueue.empty() )
|
|
|
|
{
|
|
|
|
DBG_ASSERT( maDialogQueue.begin()->get() == mxFileDlg.get(), "FileDialogHelper_Impl::popPicker: invalid top-most queue element!" );
|
|
|
|
maDialogQueue.pop_back();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
void FileDialogHelper_Impl::preExecute()
|
2001-10-12 06:37:51 +00:00
|
|
|
{
|
|
|
|
loadConfig();
|
|
|
|
setDefaultValues();
|
|
|
|
enablePasswordBox();
|
|
|
|
updateFilterOptionsBox();
|
2001-10-12 10:02:19 +00:00
|
|
|
pushBackPicker();
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
void FileDialogHelper_Impl::postExecute()
|
|
|
|
{
|
|
|
|
popPicker();
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
sal_Int16 FileDialogHelper_Impl::implDoExecute()
|
|
|
|
{
|
|
|
|
preExecute();
|
2001-10-12 06:37:51 +00:00
|
|
|
|
|
|
|
sal_Int16 nRet = ExecutableDialogResults::CANCEL;
|
|
|
|
if ( mbSystemPicker )
|
|
|
|
{
|
|
|
|
PickerThread_Impl* pThread = new PickerThread_Impl( mxFileDlg );
|
|
|
|
pThread->create();
|
|
|
|
while ( pThread->GetReturnValue() == nMagic )
|
|
|
|
Application::Yield();
|
|
|
|
pThread->join();
|
|
|
|
nRet = pThread->GetReturnValue();
|
|
|
|
delete pThread;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
nRet = mxFileDlg->execute();
|
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
|
|
|
DBG_ERRORFILE( "FileDialogHelper_Impl::implDoExecute: caught an exception!" );
|
|
|
|
}
|
|
|
|
}
|
2001-10-12 10:02:19 +00:00
|
|
|
|
|
|
|
postExecute();
|
|
|
|
|
2001-10-12 06:37:51 +00:00
|
|
|
return nRet;
|
|
|
|
}
|
|
|
|
|
2001-04-27 09:35:34 +00:00
|
|
|
// ------------------------------------------------------------------------
|
2001-06-18 09:56:17 +00:00
|
|
|
ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList,
|
2001-04-27 09:35:34 +00:00
|
|
|
SfxItemSet *& rpSet,
|
|
|
|
String& rFilter )
|
|
|
|
{
|
|
|
|
rpSet = NULL;
|
|
|
|
rpURLList = NULL;
|
|
|
|
|
2001-06-27 05:25:44 +00:00
|
|
|
if ( ! mxFileDlg.is() )
|
2001-04-27 09:35:34 +00:00
|
|
|
return ERRCODE_ABORT;
|
|
|
|
|
2001-10-12 06:37:51 +00:00
|
|
|
if ( ExecutableDialogResults::CANCEL != implDoExecute() )
|
2001-04-27 09:35:34 +00:00
|
|
|
{
|
2001-09-06 08:02:13 +00:00
|
|
|
saveConfig();
|
2001-05-07 14:01:07 +00:00
|
|
|
|
2001-04-27 09:35:34 +00:00
|
|
|
// create an itemset
|
|
|
|
rpSet = new SfxAllItemSet( SFX_APP()->GetPool() );
|
|
|
|
|
2001-05-16 12:23:43 +00:00
|
|
|
Reference< XFilePickerControlAccess > xCtrlAccess( mxFileDlg, UNO_QUERY );
|
|
|
|
|
|
|
|
// check, wether or not we have to display a password box
|
2001-07-19 15:07:48 +00:00
|
|
|
if ( mbHasPassword && mbIsPwdEnabled && xCtrlAccess.is() )
|
2001-05-16 12:23:43 +00:00
|
|
|
{
|
2001-06-21 10:12:24 +00:00
|
|
|
try
|
2001-05-16 12:23:43 +00:00
|
|
|
{
|
2001-06-21 10:12:24 +00:00
|
|
|
Any aValue = xCtrlAccess->getValue( ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, 0 );
|
|
|
|
sal_Bool bPassWord = sal_False;
|
|
|
|
if ( ( aValue >>= bPassWord ) && bPassWord )
|
2001-05-16 12:23:43 +00:00
|
|
|
{
|
2001-06-21 10:12:24 +00:00
|
|
|
// ask for the password
|
|
|
|
SfxPasswordDialog aPasswordDlg( NULL );
|
|
|
|
aPasswordDlg.ShowExtras( SHOWEXTRAS_CONFIRM );
|
|
|
|
BOOL bOK = FALSE;
|
|
|
|
short nRet = aPasswordDlg.Execute();
|
|
|
|
if ( RET_OK == nRet )
|
|
|
|
{
|
|
|
|
String aPasswd = aPasswordDlg.GetPassword();
|
|
|
|
rpSet->Put( SfxStringItem( SID_PASSWORD, aPasswd ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return ERRCODE_ABORT;
|
2001-05-16 12:23:43 +00:00
|
|
|
}
|
|
|
|
}
|
2001-06-21 10:12:24 +00:00
|
|
|
catch( IllegalArgumentException ){}
|
2001-05-16 12:23:43 +00:00
|
|
|
}
|
|
|
|
|
2001-04-27 09:35:34 +00:00
|
|
|
// set the read-only flag. When inserting a file, this flag is always set
|
|
|
|
if ( mbInsert )
|
|
|
|
rpSet->Put( SfxBoolItem( SID_DOC_READONLY, sal_True ) );
|
|
|
|
else
|
|
|
|
{
|
2001-09-27 15:52:29 +00:00
|
|
|
if ( ( FILEOPEN_READONLY_VERSION == m_nDialogType ) && xCtrlAccess.is() )
|
2001-04-27 09:35:34 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2001-06-15 07:49:37 +00:00
|
|
|
Any aValue = xCtrlAccess->getValue( ExtendedFilePickerElementIds::CHECKBOX_READONLY, 0 );
|
2001-04-27 09:35:34 +00:00
|
|
|
sal_Bool bReadOnly = sal_False;
|
2001-05-11 11:38:01 +00:00
|
|
|
if ( ( aValue >>= bReadOnly ) && bReadOnly )
|
2001-04-27 09:35:34 +00:00
|
|
|
rpSet->Put( SfxBoolItem( SID_DOC_READONLY, bReadOnly ) );
|
|
|
|
}
|
2001-09-27 15:52:29 +00:00
|
|
|
catch( IllegalArgumentException )
|
|
|
|
{
|
|
|
|
DBG_ERROR( "FileDialogHelper_Impl::execute: caught an IllegalArgumentException!" );
|
|
|
|
}
|
2001-04-27 09:35:34 +00:00
|
|
|
}
|
|
|
|
}
|
2001-05-16 12:23:43 +00:00
|
|
|
if ( mbHasVersions && xCtrlAccess.is() )
|
2001-04-27 09:35:34 +00:00
|
|
|
{
|
2001-05-16 12:23:43 +00:00
|
|
|
try
|
2001-04-27 09:35:34 +00:00
|
|
|
{
|
2001-06-15 07:49:37 +00:00
|
|
|
Any aValue = xCtrlAccess->getValue( ExtendedFilePickerElementIds::LISTBOX_VERSION,
|
2001-10-26 08:12:01 +00:00
|
|
|
ControlActions::GET_SELECTED_ITEM );
|
2001-05-16 12:23:43 +00:00
|
|
|
sal_Int16 nVersion = 0;
|
|
|
|
if ( aValue >>= nVersion )
|
|
|
|
rpSet->Put( SfxInt16Item( SID_VERSION, nVersion ) );
|
2001-04-27 09:35:34 +00:00
|
|
|
}
|
2001-05-16 12:23:43 +00:00
|
|
|
catch( IllegalArgumentException ){}
|
2001-04-27 09:35:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// set the filter
|
2001-06-15 13:23:30 +00:00
|
|
|
rFilter = getRealFilter();
|
2001-04-27 09:35:34 +00:00
|
|
|
|
|
|
|
// fill the rpURLList
|
2001-06-15 07:49:37 +00:00
|
|
|
Sequence < OUString > aPathSeq = mxFileDlg->getFiles();
|
2001-04-27 09:35:34 +00:00
|
|
|
|
|
|
|
if ( aPathSeq.getLength() )
|
|
|
|
{
|
|
|
|
rpURLList = new SvStringsDtor;
|
|
|
|
|
|
|
|
if ( aPathSeq.getLength() == 1 )
|
|
|
|
{
|
2001-06-29 08:14:59 +00:00
|
|
|
OUString aFileURL( aPathSeq[0] );
|
|
|
|
|
|
|
|
String* pURL = new String( aFileURL );
|
2001-04-27 09:35:34 +00:00
|
|
|
rpURLList->Insert( pURL, 0 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-06-25 12:26:13 +00:00
|
|
|
INetURLObject aPath( aPathSeq[0] );
|
|
|
|
aPath.setFinalSlash();
|
|
|
|
|
2001-04-27 09:35:34 +00:00
|
|
|
for ( USHORT i = 1; i < aPathSeq.getLength(); ++i )
|
|
|
|
{
|
2001-06-25 12:26:13 +00:00
|
|
|
if ( i == 1 )
|
|
|
|
aPath.Append( aPathSeq[i] );
|
|
|
|
else
|
|
|
|
aPath.setName( aPathSeq[i] );
|
2001-04-27 09:35:34 +00:00
|
|
|
|
2001-06-25 12:26:13 +00:00
|
|
|
String* pURL = new String( aPath.GetMainURL( INetURLObject::NO_DECODE ) );
|
2001-04-27 09:35:34 +00:00
|
|
|
rpURLList->Insert( pURL, rpURLList->Count() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ERRCODE_NONE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return ERRCODE_ABORT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return ERRCODE_ABORT;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
ErrCode FileDialogHelper_Impl::execute()
|
|
|
|
{
|
2001-06-27 05:25:44 +00:00
|
|
|
if ( ! mxFileDlg.is() )
|
2001-04-27 09:35:34 +00:00
|
|
|
return ERRCODE_ABORT;
|
|
|
|
|
2001-10-12 06:37:51 +00:00
|
|
|
sal_Int16 nRet = implDoExecute();
|
2001-09-06 08:02:13 +00:00
|
|
|
|
|
|
|
maPath = mxFileDlg->getDisplayDirectory();
|
2001-09-06 07:47:59 +00:00
|
|
|
|
2001-10-12 06:37:51 +00:00
|
|
|
if ( ExecutableDialogResults::CANCEL == nRet )
|
2001-04-27 09:35:34 +00:00
|
|
|
return ERRCODE_ABORT;
|
|
|
|
else
|
2001-09-06 08:02:13 +00:00
|
|
|
{
|
|
|
|
saveConfig();
|
2001-04-27 09:35:34 +00:00
|
|
|
return ERRCODE_NONE;
|
2001-09-06 08:02:13 +00:00
|
|
|
}
|
2001-06-15 07:49:37 +00:00
|
|
|
}
|
|
|
|
|
2001-06-27 05:25:44 +00:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
OUString FileDialogHelper_Impl::getPath() const
|
|
|
|
{
|
|
|
|
OUString aPath;
|
|
|
|
|
|
|
|
if ( mxFileDlg.is() )
|
|
|
|
aPath = mxFileDlg->getDisplayDirectory();
|
2001-06-27 07:10:30 +00:00
|
|
|
|
|
|
|
if ( !aPath.getLength() )
|
2001-06-27 05:25:44 +00:00
|
|
|
aPath = maPath;
|
|
|
|
|
|
|
|
return aPath;
|
|
|
|
}
|
|
|
|
|
2001-06-15 07:49:37 +00:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
OUString FileDialogHelper_Impl::getFilter() const
|
|
|
|
{
|
|
|
|
OUString aFilter;
|
|
|
|
Reference< XFilterManager > xFltMgr( mxFileDlg, UNO_QUERY );
|
|
|
|
|
2001-06-15 13:23:30 +00:00
|
|
|
if ( xFltMgr.is() )
|
|
|
|
aFilter = xFltMgr->getCurrentFilter();
|
|
|
|
else
|
|
|
|
aFilter = maCurFilter;
|
|
|
|
|
|
|
|
return aFilter;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
OUString FileDialogHelper_Impl::getRealFilter() const
|
|
|
|
{
|
|
|
|
OUString aFilter;
|
|
|
|
Reference< XFilterManager > xFltMgr( mxFileDlg, UNO_QUERY );
|
|
|
|
|
2001-06-15 07:49:37 +00:00
|
|
|
if ( xFltMgr.is() )
|
|
|
|
aFilter = xFltMgr->getCurrentFilter();
|
|
|
|
|
|
|
|
if ( ! aFilter.getLength() )
|
|
|
|
aFilter = maCurFilter;
|
|
|
|
|
2001-06-15 13:23:30 +00:00
|
|
|
if ( aFilter.getLength() && mpMatcher )
|
2001-06-15 07:49:37 +00:00
|
|
|
{
|
|
|
|
const SfxFilter* pFilter = mpMatcher->GetFilter4UIName(
|
|
|
|
aFilter, 0, SFX_FILTER_NOTINFILEDLG );
|
|
|
|
if ( pFilter )
|
|
|
|
aFilter = pFilter->GetName();
|
|
|
|
}
|
|
|
|
|
|
|
|
return aFilter;
|
|
|
|
}
|
|
|
|
|
2001-06-21 10:12:24 +00:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
void FileDialogHelper_Impl::setPath( const OUString& rPath )
|
|
|
|
{
|
2001-09-06 08:02:13 +00:00
|
|
|
// We check wether the path points to a dirctory or not
|
|
|
|
//
|
2001-07-17 15:11:24 +00:00
|
|
|
// We set the display directory only, when it is on a local / remote(?)
|
|
|
|
// filesystem
|
2001-09-06 08:02:13 +00:00
|
|
|
|
|
|
|
if ( ! rPath.getLength() )
|
|
|
|
return;
|
|
|
|
/* if (! utl::LocalFileHelper::IsLocalFile( rPath ) )
|
2001-07-17 15:11:24 +00:00
|
|
|
{
|
|
|
|
return;
|
2001-09-06 08:02:13 +00:00
|
|
|
}*/
|
2001-07-17 15:11:24 +00:00
|
|
|
|
|
|
|
OUString aName;
|
2001-09-06 08:02:13 +00:00
|
|
|
OUString aPath;
|
2001-07-17 15:11:24 +00:00
|
|
|
|
|
|
|
INetURLObject aObj( rPath );
|
|
|
|
|
|
|
|
// if the given path isn't a folder, we cut off the last part
|
|
|
|
// and take it as filename and the rest of the path should be
|
|
|
|
// the folder
|
|
|
|
|
|
|
|
if ( ! utl::UCBContentHelper::IsFolder( rPath ) )
|
|
|
|
{
|
|
|
|
aName = aObj.GetName( INetURLObject::DECODE_WITH_CHARSET );
|
|
|
|
aObj.removeSegment();
|
|
|
|
}
|
|
|
|
|
2001-09-06 08:02:13 +00:00
|
|
|
aPath = aObj.GetMainURL( INetURLObject::NO_DECODE );
|
|
|
|
|
|
|
|
if ( ! utl::UCBContentHelper::IsFolder( aPath ) )
|
|
|
|
return;
|
|
|
|
else
|
|
|
|
maPath = aPath;
|
2001-06-21 10:12:24 +00:00
|
|
|
|
|
|
|
// set the path
|
2001-07-17 15:11:24 +00:00
|
|
|
if ( mxFileDlg.is() )
|
2001-06-21 10:12:24 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2001-07-17 15:11:24 +00:00
|
|
|
if ( maPath.getLength() )
|
|
|
|
mxFileDlg->setDisplayDirectory( maPath );
|
|
|
|
if ( aName.getLength() )
|
|
|
|
mxFileDlg->setDefaultName( aName );
|
2001-06-21 10:12:24 +00:00
|
|
|
}
|
|
|
|
catch( IllegalArgumentException ){}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-15 07:49:37 +00:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
void FileDialogHelper_Impl::setFilter( const OUString& rFilter )
|
|
|
|
{
|
|
|
|
maCurFilter = rFilter;
|
|
|
|
|
2001-06-15 13:23:30 +00:00
|
|
|
if ( rFilter.getLength() && mpMatcher )
|
2001-06-15 07:49:37 +00:00
|
|
|
{
|
|
|
|
const SfxFilter* pFilter = mpMatcher->GetFilter(
|
|
|
|
rFilter, 0, SFX_FILTER_NOTINFILEDLG );
|
|
|
|
if ( pFilter )
|
|
|
|
maCurFilter = pFilter->GetUIName();
|
2001-05-04 10:52:27 +00:00
|
|
|
}
|
2001-06-27 05:25:44 +00:00
|
|
|
|
|
|
|
Reference< XFilterManager > xFltMgr( mxFileDlg, UNO_QUERY );
|
|
|
|
|
|
|
|
if ( maCurFilter.getLength() && xFltMgr.is() )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
xFltMgr->setCurrentFilter( maCurFilter );
|
|
|
|
}
|
|
|
|
catch( IllegalArgumentException ){}
|
|
|
|
}
|
2001-04-27 09:35:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
void FileDialogHelper_Impl::addFilters( sal_uInt32 nFlags,
|
|
|
|
const SfxObjectFactory& rFactory )
|
|
|
|
{
|
|
|
|
Reference< XFilterManager > xFltMgr( mxFileDlg, UNO_QUERY );
|
|
|
|
|
|
|
|
if ( ! xFltMgr.is() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// create the list of filters
|
|
|
|
|
|
|
|
if ( !&rFactory )
|
|
|
|
{
|
|
|
|
SfxApplication *pSfxApp = SFX_APP();
|
|
|
|
|
|
|
|
mpMatcher = &pSfxApp->GetFilterMatcher();
|
|
|
|
mbDeleteMatcher = sal_False;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mpMatcher = new SfxFilterMatcher( rFactory.GetFilterContainer() );
|
|
|
|
mbDeleteMatcher = sal_True;
|
|
|
|
}
|
|
|
|
|
|
|
|
USHORT nFilterFlags = SFX_FILTER_EXPORT;
|
|
|
|
|
|
|
|
if( WB_OPEN == ( nFlags & WB_OPEN ) )
|
|
|
|
nFilterFlags = SFX_FILTER_IMPORT;
|
|
|
|
|
2001-05-10 10:31:14 +00:00
|
|
|
sal_Bool bHasAll = sal_False;
|
2001-04-27 09:35:34 +00:00
|
|
|
SfxFilterMatcherIter aIter( mpMatcher, nFilterFlags, SFX_FILTER_INTERNAL | SFX_FILTER_NOTINFILEDLG );
|
|
|
|
|
2001-10-01 15:34:14 +00:00
|
|
|
// append the filters
|
|
|
|
::rtl::OUString sFirstFilter;
|
2001-05-11 11:38:01 +00:00
|
|
|
if ( WB_OPEN == ( nFlags & WB_OPEN ) )
|
2001-10-01 15:34:14 +00:00
|
|
|
::sfx2::appendFiltersForOpen( aIter, xFltMgr, sFirstFilter );
|
|
|
|
else
|
|
|
|
::sfx2::appendFilters( aIter, xFltMgr, sFirstFilter );
|
2001-09-18 13:57:51 +00:00
|
|
|
|
2001-10-01 15:34:14 +00:00
|
|
|
// set our initial selected filter (if we do not already have one)
|
|
|
|
if ( maSelectFilter.getLength() )
|
|
|
|
maSelectFilter = sFirstFilter;
|
2001-04-27 09:35:34 +00:00
|
|
|
}
|
|
|
|
|
2001-06-18 09:56:17 +00:00
|
|
|
// ------------------------------------------------------------------------
|
2001-06-29 08:14:59 +00:00
|
|
|
void FileDialogHelper_Impl::addFilter( const OUString& rFilterName,
|
|
|
|
const OUString& rExtension )
|
2001-06-18 09:56:17 +00:00
|
|
|
{
|
|
|
|
Reference< XFilterManager > xFltMgr( mxFileDlg, UNO_QUERY );
|
|
|
|
|
|
|
|
if ( ! xFltMgr.is() )
|
|
|
|
return;
|
|
|
|
|
2001-06-21 10:12:24 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
xFltMgr->appendFilter( rFilterName, rExtension );
|
2001-07-24 10:10:59 +00:00
|
|
|
|
|
|
|
if ( !maSelectFilter.getLength() )
|
|
|
|
maSelectFilter = rFilterName;
|
2001-06-21 10:12:24 +00:00
|
|
|
}
|
|
|
|
catch( IllegalArgumentException )
|
|
|
|
{
|
2001-09-18 13:57:51 +00:00
|
|
|
#ifdef DBG_UTIL
|
2001-08-15 15:47:49 +00:00
|
|
|
ByteString aMsg( "Could not append Filter" );
|
|
|
|
aMsg += ByteString( String( rFilterName ), RTL_TEXTENCODING_UTF8 );
|
|
|
|
DBG_ERRORFILE( aMsg.GetBuffer() );
|
2001-09-18 13:57:51 +00:00
|
|
|
#endif
|
2001-06-21 10:12:24 +00:00
|
|
|
}
|
2001-06-18 09:56:17 +00:00
|
|
|
}
|
|
|
|
|
2001-04-27 09:35:34 +00:00
|
|
|
// ------------------------------------------------------------------------
|
2001-05-07 14:01:07 +00:00
|
|
|
void FileDialogHelper_Impl::addGraphicFilter()
|
2001-04-27 09:35:34 +00:00
|
|
|
{
|
2001-05-07 14:01:07 +00:00
|
|
|
Reference< XFilterManager > xFltMgr( mxFileDlg, UNO_QUERY );
|
2001-04-27 09:35:34 +00:00
|
|
|
|
2001-05-07 14:01:07 +00:00
|
|
|
if ( ! xFltMgr.is() )
|
|
|
|
return;
|
2001-04-27 09:35:34 +00:00
|
|
|
|
2001-05-07 14:01:07 +00:00
|
|
|
// create the list of filters
|
2001-07-11 08:42:26 +00:00
|
|
|
mpGraphicFilter = new GraphicFilter;
|
2001-08-07 13:08:46 +00:00
|
|
|
USHORT i, j, nCount = mpGraphicFilter->GetImportFormatCount();
|
2001-04-27 09:35:34 +00:00
|
|
|
|
2001-05-07 14:01:07 +00:00
|
|
|
// compute the extension string for all known import filters
|
2001-04-27 09:35:34 +00:00
|
|
|
String aExtensions;
|
|
|
|
|
|
|
|
for ( i = 0; i < nCount; i++ )
|
|
|
|
{
|
2001-08-07 13:08:46 +00:00
|
|
|
j = 0;
|
2001-09-18 13:57:51 +00:00
|
|
|
String sWildcard;
|
2001-08-07 13:08:46 +00:00
|
|
|
while( TRUE )
|
2001-04-27 09:35:34 +00:00
|
|
|
{
|
2001-09-18 13:57:51 +00:00
|
|
|
sWildcard = mpGraphicFilter->GetImportWildcard( i, j++ );
|
|
|
|
if ( !sWildcard.Len() )
|
2001-08-07 13:08:46 +00:00
|
|
|
break;
|
2001-09-18 13:57:51 +00:00
|
|
|
if ( aExtensions.Search( sWildcard ) == STRING_NOTFOUND )
|
2001-08-07 13:08:46 +00:00
|
|
|
{
|
|
|
|
if ( aExtensions.Len() )
|
|
|
|
aExtensions += sal_Unicode(';');
|
2001-09-18 13:57:51 +00:00
|
|
|
aExtensions += sWildcard;
|
2001-08-07 13:08:46 +00:00
|
|
|
}
|
2001-04-27 09:35:34 +00:00
|
|
|
}
|
|
|
|
}
|
2001-05-07 14:01:07 +00:00
|
|
|
|
2001-04-27 09:35:34 +00:00
|
|
|
#if defined(WIN) || defined(WNT)
|
2001-05-07 14:01:07 +00:00
|
|
|
if ( aExtensions.Len() > 240 )
|
|
|
|
aExtensions = String::CreateFromAscii( FILEDIALOG_FILTER_ALL );
|
2001-04-27 09:35:34 +00:00
|
|
|
#endif
|
|
|
|
|
2001-06-21 10:12:24 +00:00
|
|
|
try
|
|
|
|
{
|
2001-07-24 10:10:59 +00:00
|
|
|
OUString aAllFilterName = String( SfxResId( STR_SFX_IMPORT_ALL ) );
|
|
|
|
|
|
|
|
xFltMgr->appendFilter( aAllFilterName, aExtensions );
|
|
|
|
maSelectFilter = aAllFilterName;
|
2001-06-21 10:12:24 +00:00
|
|
|
}
|
|
|
|
catch( IllegalArgumentException )
|
|
|
|
{
|
|
|
|
DBG_ERRORFILE( "Could not append Filter" );
|
|
|
|
}
|
2001-04-27 09:35:34 +00:00
|
|
|
|
2001-05-07 14:01:07 +00:00
|
|
|
// Now add the filter
|
2001-04-27 09:35:34 +00:00
|
|
|
for ( i = 0; i < nCount; i++ )
|
|
|
|
{
|
2001-07-11 08:42:26 +00:00
|
|
|
String aName = mpGraphicFilter->GetImportFormatName( i );
|
2001-08-07 13:08:46 +00:00
|
|
|
String aExtensions;
|
|
|
|
j = 0;
|
2001-09-18 13:57:51 +00:00
|
|
|
String sWildcard;
|
2001-08-07 13:08:46 +00:00
|
|
|
while( TRUE )
|
|
|
|
{
|
2001-09-18 13:57:51 +00:00
|
|
|
sWildcard = mpGraphicFilter->GetImportWildcard( i, j++ );
|
|
|
|
if ( !sWildcard.Len() )
|
2001-08-07 13:08:46 +00:00
|
|
|
break;
|
2001-09-18 13:57:51 +00:00
|
|
|
if ( aExtensions.Search( sWildcard ) == STRING_NOTFOUND )
|
2001-08-07 13:08:46 +00:00
|
|
|
{
|
|
|
|
if ( aExtensions.Len() )
|
|
|
|
aExtensions += sal_Unicode(';');
|
2001-09-18 13:57:51 +00:00
|
|
|
aExtensions += sWildcard;
|
2001-08-07 13:08:46 +00:00
|
|
|
}
|
|
|
|
}
|
2001-06-21 10:12:24 +00:00
|
|
|
try
|
|
|
|
{
|
2001-08-07 13:08:46 +00:00
|
|
|
xFltMgr->appendFilter( aName, aExtensions );
|
2001-06-21 10:12:24 +00:00
|
|
|
}
|
|
|
|
catch( IllegalArgumentException )
|
|
|
|
{
|
|
|
|
DBG_ERRORFILE( "Could not append Filter" );
|
|
|
|
}
|
2001-04-27 09:35:34 +00:00
|
|
|
}
|
2001-05-07 14:01:07 +00:00
|
|
|
}
|
|
|
|
|
2001-05-04 10:52:27 +00:00
|
|
|
// ------------------------------------------------------------------------
|
2001-07-09 08:19:09 +00:00
|
|
|
#define GRF_CONFIG_STR " "
|
|
|
|
#define STD_CONFIG_STR "1 "
|
|
|
|
|
2001-04-27 09:35:34 +00:00
|
|
|
void FileDialogHelper_Impl::saveConfig()
|
|
|
|
{
|
2001-05-04 10:52:27 +00:00
|
|
|
Reference < XFilePickerControlAccess > xDlg( mxFileDlg, UNO_QUERY );
|
|
|
|
Any aValue;
|
|
|
|
|
|
|
|
if ( ! xDlg.is() )
|
|
|
|
return;
|
|
|
|
|
2001-06-27 05:25:44 +00:00
|
|
|
if ( mbHasPreview )
|
2001-05-04 10:52:27 +00:00
|
|
|
{
|
|
|
|
SvtViewOptions aDlgOpt( E_DIALOG, IMPGRF_CONFIGNAME );
|
2001-07-09 08:19:09 +00:00
|
|
|
String aUserData = String::CreateFromAscii( GRF_CONFIG_STR );
|
2001-05-04 10:52:27 +00:00
|
|
|
|
2001-06-21 10:12:24 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
aValue = xDlg->getValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0 );
|
|
|
|
sal_Bool bValue = sal_False;
|
2001-06-27 05:25:44 +00:00
|
|
|
aValue >>= bValue;
|
|
|
|
aUserData.SetToken( 0, ' ', String::CreateFromInt32( (sal_Int32) bValue ) );
|
2001-05-04 10:52:27 +00:00
|
|
|
|
2001-06-21 10:12:24 +00:00
|
|
|
aValue = xDlg->getValue( ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, 0 );
|
|
|
|
bValue = sal_False;
|
2001-06-27 05:25:44 +00:00
|
|
|
aValue >>= bValue;
|
|
|
|
aUserData.SetToken( 1, ' ', String::CreateFromInt32( (sal_Int32) bValue ) );
|
|
|
|
|
2001-07-03 14:43:04 +00:00
|
|
|
INetURLObject aObj( getPath() );
|
|
|
|
|
|
|
|
if ( aObj.GetProtocol() == INET_PROT_FILE )
|
|
|
|
aUserData.SetToken( 2, ' ', aObj.GetMainURL( INetURLObject::NO_DECODE ) );
|
2001-06-27 05:25:44 +00:00
|
|
|
|
|
|
|
String aFilter = getFilter();
|
|
|
|
aFilter = EncodeSpaces_Impl( aFilter );
|
|
|
|
aUserData.SetToken( 3, ' ', aFilter );
|
2001-05-04 10:52:27 +00:00
|
|
|
|
2001-10-12 12:08:18 +00:00
|
|
|
aDlgOpt.SetUserItem( USERITEM_NAME, makeAny( OUString( aUserData ) ) );
|
2001-06-21 10:12:24 +00:00
|
|
|
}
|
|
|
|
catch( IllegalArgumentException ){}
|
2001-05-04 10:52:27 +00:00
|
|
|
}
|
2001-06-27 05:25:44 +00:00
|
|
|
else
|
2001-05-04 10:52:27 +00:00
|
|
|
{
|
2001-07-17 15:11:24 +00:00
|
|
|
sal_Bool bWriteConfig = sal_False;
|
2001-05-04 10:52:27 +00:00
|
|
|
SvtViewOptions aDlgOpt( E_DIALOG, IODLG_CONFIGNAME );
|
2001-09-27 15:52:29 +00:00
|
|
|
String aUserData = String::CreateFromAscii( STD_CONFIG_STR );
|
2001-05-04 10:52:27 +00:00
|
|
|
|
|
|
|
if ( aDlgOpt.Exists() )
|
|
|
|
{
|
2001-10-12 12:08:18 +00:00
|
|
|
Any aUserItem = aDlgOpt.GetUserItem( USERITEM_NAME );
|
|
|
|
OUString aTemp;
|
|
|
|
if ( aUserItem >>= aTemp )
|
|
|
|
aUserData = String( aTemp );
|
2001-06-27 05:25:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( mbHasAutoExt )
|
|
|
|
{
|
2001-06-21 10:12:24 +00:00
|
|
|
try
|
|
|
|
{
|
2001-06-27 05:25:44 +00:00
|
|
|
aValue = xDlg->getValue( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0 );
|
|
|
|
sal_Bool bAutoExt = sal_True;
|
|
|
|
aValue >>= bAutoExt;
|
|
|
|
aUserData.SetToken( 0, ' ', String::CreateFromInt32( (sal_Int32) bAutoExt ) );
|
2001-07-17 15:11:24 +00:00
|
|
|
bWriteConfig = sal_True;
|
2001-06-21 10:12:24 +00:00
|
|
|
}
|
|
|
|
catch( IllegalArgumentException ){}
|
2001-05-04 10:52:27 +00:00
|
|
|
}
|
2001-06-27 05:25:44 +00:00
|
|
|
|
2001-07-17 15:11:24 +00:00
|
|
|
if ( ! mbIsSaveDlg )
|
|
|
|
{
|
|
|
|
OUString aPath = getPath();
|
|
|
|
if ( aPath.getLength() &&
|
|
|
|
utl::LocalFileHelper::IsLocalFile( aPath ) )
|
|
|
|
{
|
|
|
|
aUserData.SetToken( 1, ' ', aPath );
|
|
|
|
bWriteConfig = sal_True;
|
|
|
|
}
|
|
|
|
}
|
2001-06-27 05:25:44 +00:00
|
|
|
|
2001-07-17 15:11:24 +00:00
|
|
|
if ( bWriteConfig )
|
2001-10-12 12:08:18 +00:00
|
|
|
aDlgOpt.SetUserItem( USERITEM_NAME, makeAny( OUString( aUserData ) ) );
|
2001-05-04 10:52:27 +00:00
|
|
|
}
|
2001-09-06 08:02:13 +00:00
|
|
|
|
|
|
|
SfxApplication *pSfxApp = SFX_APP();
|
|
|
|
pSfxApp->SetLastDir_Impl( getPath() );
|
2001-06-27 05:25:44 +00:00
|
|
|
}
|
|
|
|
|
2001-10-25 10:20:56 +00:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
static ::rtl::OUString getInitPath( const String& _rFallback, const xub_StrLen _nFallbackToken )
|
|
|
|
{
|
|
|
|
SfxApplication *pSfxApp = SFX_APP();
|
|
|
|
String sPath = pSfxApp->GetLastDir_Impl();
|
|
|
|
|
|
|
|
if ( !sPath.Len() )
|
|
|
|
sPath = _rFallback.GetToken( _nFallbackToken, ' ' );
|
|
|
|
|
|
|
|
// check if the path points to a valid (accessible) directory
|
|
|
|
sal_Bool bValid = sal_False;
|
|
|
|
if ( sPath.Len() )
|
|
|
|
{
|
|
|
|
String sPathCheck( sPath );
|
|
|
|
if ( sPathCheck.GetBuffer()[ sPathCheck.Len() - 1 ] != '/' )
|
|
|
|
sPathCheck += '/';
|
|
|
|
sPathCheck += '.';
|
|
|
|
try
|
|
|
|
{
|
|
|
|
::ucb::Content aContent( sPathCheck, Reference< ::com::sun::star::ucb::XCommandEnvironment >() );
|
|
|
|
bValid = aContent.isFolder();
|
|
|
|
}
|
|
|
|
catch( const Exception& e )
|
|
|
|
{
|
|
|
|
e; // make compiler happy
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !bValid )
|
|
|
|
sPath.Erase();
|
|
|
|
|
|
|
|
return sPath;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-27 05:25:44 +00:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
void FileDialogHelper_Impl::loadConfig()
|
|
|
|
{
|
|
|
|
Reference < XFilePickerControlAccess > xDlg( mxFileDlg, UNO_QUERY );
|
|
|
|
Any aValue;
|
|
|
|
|
|
|
|
if ( ! xDlg.is() )
|
|
|
|
return;
|
2001-05-04 10:52:27 +00:00
|
|
|
|
2001-06-27 05:25:44 +00:00
|
|
|
if ( mbHasPreview )
|
2001-05-04 10:52:27 +00:00
|
|
|
{
|
|
|
|
SvtViewOptions aViewOpt( E_DIALOG, IMPGRF_CONFIGNAME );
|
|
|
|
String aUserData;
|
|
|
|
|
|
|
|
if ( aViewOpt.Exists() )
|
2001-10-12 12:08:18 +00:00
|
|
|
{
|
|
|
|
Any aUserItem = aViewOpt.GetUserItem( USERITEM_NAME );
|
|
|
|
OUString aTemp;
|
|
|
|
if ( aUserItem >>= aTemp )
|
|
|
|
aUserData = String( aTemp );
|
|
|
|
}
|
2001-05-04 10:52:27 +00:00
|
|
|
|
|
|
|
if ( aUserData.Len() > 0 )
|
|
|
|
{
|
2001-06-21 10:12:24 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
// respect the last "insert as link" state
|
2001-06-27 05:25:44 +00:00
|
|
|
sal_Bool bLink = (sal_Bool) aUserData.GetToken( 0, ' ' ).ToInt32();
|
2001-06-21 10:12:24 +00:00
|
|
|
aValue <<= bLink;
|
|
|
|
xDlg->setValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, aValue );
|
|
|
|
|
|
|
|
// respect the last "show preview" state
|
2001-06-27 05:25:44 +00:00
|
|
|
sal_Bool bShowPreview = (sal_Bool) aUserData.GetToken( 1, ' ' ).ToInt32();
|
2001-06-21 10:12:24 +00:00
|
|
|
aValue <<= bShowPreview;
|
|
|
|
xDlg->setValue( ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, 0, aValue );
|
|
|
|
|
2001-06-27 05:25:44 +00:00
|
|
|
if ( ! maPath.getLength() )
|
2001-10-25 10:20:56 +00:00
|
|
|
setPath( getInitPath( aUserData, 2 ) );
|
2001-06-27 05:25:44 +00:00
|
|
|
|
|
|
|
if ( ! maCurFilter.getLength() )
|
|
|
|
{
|
|
|
|
String aFilter = aUserData.GetToken( 3, ' ' );
|
|
|
|
aFilter = DecodeSpaces_Impl( aFilter );
|
|
|
|
setFilter( aFilter );
|
|
|
|
}
|
|
|
|
|
2001-06-21 10:12:24 +00:00
|
|
|
// set the member so we know that we have to show the preview
|
|
|
|
mbShowPreview = bShowPreview;
|
|
|
|
}
|
|
|
|
catch( IllegalArgumentException ){}
|
2001-05-04 10:52:27 +00:00
|
|
|
}
|
|
|
|
}
|
2001-06-27 05:25:44 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
SvtViewOptions aViewOpt( E_DIALOG, IODLG_CONFIGNAME );
|
|
|
|
String aUserData;
|
|
|
|
|
|
|
|
if ( aViewOpt.Exists() )
|
2001-10-12 12:08:18 +00:00
|
|
|
{
|
|
|
|
Any aUserItem = aViewOpt.GetUserItem( USERITEM_NAME );
|
|
|
|
OUString aTemp;
|
|
|
|
if ( aUserItem >>= aTemp )
|
|
|
|
aUserData = String( aTemp );
|
|
|
|
}
|
2001-06-27 05:25:44 +00:00
|
|
|
|
2001-07-09 08:19:09 +00:00
|
|
|
if ( ! aUserData.Len() )
|
|
|
|
aUserData = String::CreateFromAscii( STD_CONFIG_STR );
|
2001-06-27 05:25:44 +00:00
|
|
|
|
2001-07-09 08:19:09 +00:00
|
|
|
if ( ! maPath.getLength() )
|
2001-10-25 10:20:56 +00:00
|
|
|
setPath( getInitPath( aUserData, 1 ) );
|
2001-07-09 08:19:09 +00:00
|
|
|
|
|
|
|
if ( mbHasAutoExt )
|
|
|
|
{
|
|
|
|
sal_Int32 nFlag = aUserData.GetToken( 0, ' ' ).ToInt32();
|
|
|
|
aValue <<= (sal_Bool) nFlag;
|
|
|
|
try
|
2001-06-27 05:25:44 +00:00
|
|
|
{
|
2001-07-09 08:19:09 +00:00
|
|
|
xDlg->setValue( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0, aValue );
|
2001-06-27 05:25:44 +00:00
|
|
|
}
|
2001-07-09 08:19:09 +00:00
|
|
|
catch( IllegalArgumentException ){}
|
2001-06-27 05:25:44 +00:00
|
|
|
}
|
|
|
|
}
|
2001-04-27 09:35:34 +00:00
|
|
|
}
|
|
|
|
|
2001-07-25 10:41:50 +00:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
void FileDialogHelper_Impl::setDefaultValues()
|
|
|
|
{
|
|
|
|
// when no filter is set, we set the curentFilter to <all>
|
|
|
|
if ( !maCurFilter.getLength() && maSelectFilter.getLength() )
|
|
|
|
{
|
|
|
|
Reference< XFilterManager > xFltMgr( mxFileDlg, UNO_QUERY );
|
|
|
|
try
|
|
|
|
{
|
|
|
|
xFltMgr->setCurrentFilter( maSelectFilter );
|
|
|
|
}
|
|
|
|
catch( IllegalArgumentException )
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
|
|
|
|
// when no path is set, we use the standard 'work' folder
|
|
|
|
if ( ! maPath.getLength() )
|
|
|
|
{
|
|
|
|
OUString aWorkFolder = SvtPathOptions().GetWorkPath();
|
|
|
|
mxFileDlg->setDisplayDirectory( aWorkFolder );
|
|
|
|
|
|
|
|
// INetURLObject aStdDirObj( SvtPathOptions().GetWorkPath() );
|
|
|
|
//SetStandardDir( aStdDirObj.GetMainURL( INetURLObject::NO_DECODE ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-04-27 09:35:34 +00:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
// ----------- FileDialogHelper ---------------------------
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
|
2001-06-15 07:49:37 +00:00
|
|
|
FileDialogHelper::FileDialogHelper( sal_uInt32 nFlags,
|
|
|
|
const SfxObjectFactory& rFact )
|
|
|
|
{
|
2001-09-06 08:02:13 +00:00
|
|
|
mpImp = new FileDialogHelper_Impl( this, getDialogType( nFlags ), nFlags );
|
2001-06-15 07:49:37 +00:00
|
|
|
mxImp = mpImp;
|
|
|
|
|
|
|
|
// create the list of filters
|
|
|
|
mpImp->addFilters( nFlags, rFact );
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
2001-04-27 09:35:34 +00:00
|
|
|
FileDialogHelper::FileDialogHelper( sal_uInt32 nFlags )
|
|
|
|
{
|
2001-06-15 07:49:37 +00:00
|
|
|
const short nDialogType = getDialogType( nFlags );
|
|
|
|
|
2001-09-06 08:02:13 +00:00
|
|
|
mpImp = new FileDialogHelper_Impl( this, nDialogType, nFlags );
|
2001-04-27 09:35:34 +00:00
|
|
|
mxImp = mpImp;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
2001-06-15 07:49:37 +00:00
|
|
|
FileDialogHelper::FileDialogHelper( const short nDialogType,
|
|
|
|
sal_uInt32 nFlags,
|
2001-04-27 09:35:34 +00:00
|
|
|
const SfxObjectFactory& rFact )
|
|
|
|
{
|
2001-09-06 08:02:13 +00:00
|
|
|
mpImp = new FileDialogHelper_Impl( this, nDialogType, nFlags );
|
2001-04-27 09:35:34 +00:00
|
|
|
mxImp = mpImp;
|
|
|
|
|
|
|
|
// create the list of filters
|
|
|
|
mpImp->addFilters( nFlags, rFact );
|
|
|
|
}
|
|
|
|
|
2001-06-15 07:49:37 +00:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
FileDialogHelper::FileDialogHelper( const short nDialogType,
|
|
|
|
sal_uInt32 nFlags )
|
|
|
|
{
|
2001-09-06 08:02:13 +00:00
|
|
|
mpImp = new FileDialogHelper_Impl( this, nDialogType, nFlags );
|
2001-06-15 07:49:37 +00:00
|
|
|
mxImp = mpImp;
|
|
|
|
}
|
|
|
|
|
2001-04-27 09:35:34 +00:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
FileDialogHelper::~FileDialogHelper()
|
|
|
|
{
|
|
|
|
mpImp->dispose();
|
|
|
|
mxImp.clear();
|
|
|
|
}
|
|
|
|
|
2001-10-26 08:12:01 +00:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
void FileDialogHelper::SetControlHelpIds( const sal_Int16* _pControlId, const sal_Int32* _pHelpId )
|
|
|
|
{
|
|
|
|
mpImp->setControlHelpIds( _pControlId, _pHelpId );
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
void FileDialogHelper::SetDialogHelpId( const sal_Int32 _nHelpId )
|
|
|
|
{
|
|
|
|
mpImp->setDialogHelpId( _nHelpId );
|
|
|
|
}
|
|
|
|
|
2001-10-12 10:02:19 +00:00
|
|
|
// ------------------------------------------------------------------------
|
2001-10-12 12:53:19 +00:00
|
|
|
Reference< XFilePicker > FileDialogHelper::GetTopMostFilePicker( )
|
2001-10-12 10:02:19 +00:00
|
|
|
{
|
2001-10-12 12:53:19 +00:00
|
|
|
return FileDialogHelper_Impl::getTopMostFilePicker();
|
2001-10-12 10:02:19 +00:00
|
|
|
}
|
|
|
|
|
2001-04-27 09:35:34 +00:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
ErrCode FileDialogHelper::Execute( const String& rPath,
|
|
|
|
SvStringsDtor*& rpURLList,
|
|
|
|
SfxItemSet *& rpSet,
|
|
|
|
String& rFilter )
|
|
|
|
{
|
2001-06-18 09:56:17 +00:00
|
|
|
SetDisplayDirectory( rPath );
|
|
|
|
|
|
|
|
return mpImp->execute( rpURLList, rpSet, rFilter );
|
2001-04-27 09:35:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
ErrCode FileDialogHelper::Execute()
|
|
|
|
{
|
|
|
|
return mpImp->execute();
|
|
|
|
}
|
|
|
|
|
2001-05-16 12:23:43 +00:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
ErrCode FileDialogHelper::Execute( SfxItemSet *& rpSet,
|
|
|
|
String& rFilter)
|
|
|
|
{
|
|
|
|
ErrCode nRet;
|
|
|
|
SvStringsDtor* pURLList;
|
|
|
|
|
2001-06-18 09:56:17 +00:00
|
|
|
nRet = mpImp->execute( pURLList, rpSet, rFilter );
|
2001-05-16 12:23:43 +00:00
|
|
|
|
|
|
|
delete pURLList;
|
|
|
|
|
|
|
|
return nRet;
|
|
|
|
}
|
|
|
|
|
2001-04-27 09:35:34 +00:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
void FileDialogHelper::SetTitle( const String& rNewTitle )
|
|
|
|
{
|
|
|
|
if ( mpImp->mxFileDlg.is() )
|
|
|
|
mpImp->mxFileDlg->setTitle( rNewTitle );
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
String FileDialogHelper::GetPath() const
|
|
|
|
{
|
2001-06-29 08:14:59 +00:00
|
|
|
OUString aPath;
|
|
|
|
|
2001-04-27 09:35:34 +00:00
|
|
|
if ( mpImp->mxFileDlg.is() )
|
|
|
|
{
|
2001-06-15 07:49:37 +00:00
|
|
|
Sequence < OUString > aPathSeq = mpImp->mxFileDlg->getFiles();
|
2001-04-27 09:35:34 +00:00
|
|
|
|
|
|
|
if ( aPathSeq.getLength() == 1 )
|
2001-06-29 08:14:59 +00:00
|
|
|
{
|
|
|
|
aPath = aPathSeq[0];
|
|
|
|
}
|
2001-04-27 09:35:34 +00:00
|
|
|
}
|
|
|
|
|
2001-06-29 08:14:59 +00:00
|
|
|
return aPath;
|
2001-04-27 09:35:34 +00:00
|
|
|
}
|
|
|
|
|
2001-08-20 09:09:13 +00:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
Sequence < OUString > FileDialogHelper::GetMPath() const
|
|
|
|
{
|
|
|
|
if ( mpImp->mxFileDlg.is() )
|
|
|
|
return mpImp->mxFileDlg->getFiles();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Sequence < OUString > aEmpty;
|
|
|
|
return aEmpty;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-05-04 10:52:27 +00:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
String FileDialogHelper::GetDisplayDirectory() const
|
|
|
|
{
|
|
|
|
return mpImp->getPath();
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
String FileDialogHelper::GetCurrentFilter() const
|
|
|
|
{
|
|
|
|
return mpImp->getFilter();
|
|
|
|
}
|
|
|
|
|
2001-07-11 08:42:26 +00:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
ErrCode FileDialogHelper::GetGraphic( Graphic& rGraphic ) const
|
|
|
|
{
|
|
|
|
return mpImp->getGraphic( rGraphic );
|
|
|
|
}
|
2001-07-06 11:12:41 +00:00
|
|
|
|
2001-05-04 10:52:27 +00:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
void FileDialogHelper::SetDisplayDirectory( const String& rPath )
|
|
|
|
{
|
2001-07-17 15:11:24 +00:00
|
|
|
mpImp->setPath( rPath );
|
2001-06-18 09:56:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
void FileDialogHelper::AddFilter( const String& rFilterName,
|
|
|
|
const String& rExtension )
|
|
|
|
{
|
|
|
|
mpImp->addFilter( rFilterName, rExtension );
|
2001-05-04 10:52:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
void FileDialogHelper::SetCurrentFilter( const String& rFilter )
|
|
|
|
{
|
|
|
|
mpImp->setFilter( rFilter );
|
|
|
|
}
|
|
|
|
|
2001-04-27 09:35:34 +00:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
Reference < XFilePicker > FileDialogHelper::GetFilePicker() const
|
|
|
|
{
|
|
|
|
return mpImp->mxFileDlg;
|
|
|
|
}
|
|
|
|
|
2001-06-15 07:49:37 +00:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
const short FileDialogHelper::getDialogType( sal_uInt32 nFlags ) const
|
|
|
|
{
|
|
|
|
short nDialogType = FILEOPEN_SIMPLE;
|
|
|
|
|
|
|
|
if ( nFlags & WB_SAVEAS )
|
|
|
|
{
|
|
|
|
if ( nFlags & SFXWB_PASSWORD )
|
|
|
|
nDialogType = FILESAVE_AUTOEXTENSION_PASSWORD;
|
|
|
|
else
|
|
|
|
nDialogType = FILESAVE_SIMPLE;
|
|
|
|
}
|
|
|
|
else if ( nFlags & SFXWB_GRAPHIC )
|
2001-07-25 14:48:10 +00:00
|
|
|
{
|
|
|
|
if ( nFlags & SFXWB_SHOWSTYLES )
|
|
|
|
nDialogType = FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE;
|
|
|
|
else
|
|
|
|
nDialogType = FILEOPEN_LINK_PREVIEW;
|
|
|
|
}
|
2001-06-15 07:49:37 +00:00
|
|
|
else if ( SFXWB_INSERT != ( nFlags & SFXWB_INSERT ) )
|
|
|
|
nDialogType = FILEOPEN_READONLY_VERSION;
|
|
|
|
|
|
|
|
return nDialogType;
|
|
|
|
}
|
|
|
|
|
2001-09-06 08:02:13 +00:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
// XFilePickerListener Methods
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
void SAL_CALL FileDialogHelper::FileSelectionChanged( const FilePickerEvent& aEvent )
|
|
|
|
{
|
|
|
|
mpImp->handleFileSelectionChanged( aEvent );
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
void SAL_CALL FileDialogHelper::DirectoryChanged( const FilePickerEvent& aEvent )
|
|
|
|
{
|
|
|
|
mpImp->handleDirectoryChanged( aEvent );
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
OUString SAL_CALL FileDialogHelper::HelpRequested( const FilePickerEvent& aEvent )
|
|
|
|
{
|
|
|
|
return mpImp->handleHelpRequested( aEvent );
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
void SAL_CALL FileDialogHelper::ControlStateChanged( const FilePickerEvent& aEvent )
|
|
|
|
{
|
|
|
|
mpImp->handleControlStateChanged( aEvent );
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
void SAL_CALL FileDialogHelper::DialogSizeChanged()
|
|
|
|
{
|
|
|
|
mpImp->handleDialogSizeChanged();
|
|
|
|
}
|
|
|
|
|
2001-04-27 09:35:34 +00:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
|
|
|
|
ErrCode FileOpenDialog_Impl( sal_uInt32 nFlags,
|
|
|
|
const SfxObjectFactory& rFact,
|
|
|
|
SvStringsDtor *& rpURLList,
|
|
|
|
String& rFilter,
|
|
|
|
SfxItemSet *& rpSet,
|
|
|
|
String aPath )
|
|
|
|
{
|
2001-06-18 09:56:17 +00:00
|
|
|
ErrCode nRet;
|
2001-04-27 09:35:34 +00:00
|
|
|
FileDialogHelper aDialog( nFlags, rFact );
|
2001-06-18 09:56:17 +00:00
|
|
|
|
|
|
|
nRet = aDialog.Execute( aPath, rpURLList, rpSet, rFilter );
|
|
|
|
|
|
|
|
aPath = aDialog.GetDisplayDirectory();
|
|
|
|
|
|
|
|
return nRet;
|
2001-04-27 09:35:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-27 05:25:44 +00:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
String EncodeSpaces_Impl( const String& rSource )
|
|
|
|
{
|
|
|
|
String aRet( rSource );
|
|
|
|
aRet.SearchAndReplaceAll( String::CreateFromAscii( " " ),
|
|
|
|
String::CreateFromAscii( "%20" ) );
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
String DecodeSpaces_Impl( const String& rSource )
|
|
|
|
{
|
|
|
|
String aRet( rSource );
|
|
|
|
aRet.SearchAndReplaceAll( String::CreateFromAscii( "%20" ),
|
|
|
|
String::CreateFromAscii( " " ) );
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
|
2001-04-27 09:35:34 +00:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
|
2001-05-07 14:01:07 +00:00
|
|
|
} // end of namespace sfx2
|