1*353d8f4dSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*353d8f4dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*353d8f4dSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*353d8f4dSAndrew Rist * distributed with this work for additional information 6*353d8f4dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*353d8f4dSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*353d8f4dSAndrew Rist * "License"); you may not use this file except in compliance 9*353d8f4dSAndrew Rist * with the License. You may obtain a copy of the License at 10*353d8f4dSAndrew Rist * 11*353d8f4dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*353d8f4dSAndrew Rist * 13*353d8f4dSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*353d8f4dSAndrew Rist * software distributed under the License is distributed on an 15*353d8f4dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*353d8f4dSAndrew Rist * KIND, either express or implied. See the License for the 17*353d8f4dSAndrew Rist * specific language governing permissions and limitations 18*353d8f4dSAndrew Rist * under the License. 19*353d8f4dSAndrew Rist * 20*353d8f4dSAndrew Rist *************************************************************/ 21*353d8f4dSAndrew Rist 22*353d8f4dSAndrew Rist 23cdf0e10cSrcweir #ifndef _FILEDLGHELPER_HXX 24cdf0e10cSrcweir #define _FILEDLGHELPER_HXX 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include "sal/config.h" 27cdf0e10cSrcweir #include "sfx2/dllapi.h" 28cdf0e10cSrcweir #include "sal/types.h" 29cdf0e10cSrcweir #include <com/sun/star/uno/Reference.hxx> 30cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx> 31cdf0e10cSrcweir #include <rtl/ustring.hxx> 32cdf0e10cSrcweir #include <tools/solar.h> 33cdf0e10cSrcweir #include <tools/string.hxx> 34cdf0e10cSrcweir #include <tools/errcode.hxx> 35cdf0e10cSrcweir #include <vcl/dialog.hxx> 36cdf0e10cSrcweir #include <vcl/edit.hxx> 37cdf0e10cSrcweir #ifndef _SV_BUTTON_HXX 38cdf0e10cSrcweir #include <vcl/button.hxx> 39cdf0e10cSrcweir #endif 40cdf0e10cSrcweir #include <vcl/graph.hxx> 41cdf0e10cSrcweir #include <sfx2/sfxdefs.hxx> 42cdf0e10cSrcweir #include <sfx2/sfxuno.hxx> 43cdf0e10cSrcweir 44cdf0e10cSrcweir //----------------------------------------------------------------------------- 45cdf0e10cSrcweir 46cdf0e10cSrcweir namespace com 47cdf0e10cSrcweir { 48cdf0e10cSrcweir namespace sun 49cdf0e10cSrcweir { 50cdf0e10cSrcweir namespace star 51cdf0e10cSrcweir { 52cdf0e10cSrcweir namespace ui 53cdf0e10cSrcweir { 54cdf0e10cSrcweir namespace dialogs 55cdf0e10cSrcweir { 56cdf0e10cSrcweir class XFilePicker; 57cdf0e10cSrcweir class XFilePickerListener; 58cdf0e10cSrcweir struct FilePickerEvent; 59cdf0e10cSrcweir struct DialogClosedEvent; 60cdf0e10cSrcweir } 61cdf0e10cSrcweir } 62cdf0e10cSrcweir } 63cdf0e10cSrcweir } 64cdf0e10cSrcweir } 65cdf0e10cSrcweir 66cdf0e10cSrcweir class SfxItemSet; 67cdf0e10cSrcweir class SvStringsDtor; 68cdf0e10cSrcweir class Window; 69cdf0e10cSrcweir 70cdf0e10cSrcweir //----------------------------------------------------------------------------- 71cdf0e10cSrcweir /* 72cdf0e10cSrcweir #define WB_PATH 0x00100000L 73cdf0e10cSrcweir #define WB_OPEN 0x00200000L 74cdf0e10cSrcweir #define WB_SAVEAS 0x00400000L 75cdf0e10cSrcweir #define WB_PASSWORD 0x01000000L 76cdf0e10cSrcweir #define WB_READONLY 0x02000000L 77cdf0e10cSrcweir */ 78cdf0e10cSrcweir 79cdf0e10cSrcweir #define SFXWB_INSERT ( 0x04000000L | WB_OPEN ) // ((WinBits)0x00200000) 80cdf0e10cSrcweir #define SFXWB_PASSWORD WB_PASSWORD // ((WinBits)0x01000000) 81cdf0e10cSrcweir #define SFXWB_READONLY WB_READONLY // ((WinBits)0x02000000) 82cdf0e10cSrcweir #define SFXWB_PATHDIALOG WB_PATH // ((WinBits)0x00100000) 83cdf0e10cSrcweir #define SFXWB_CLASSPATH ( 0x08000000L | SFXWB_PATHDIALOG ) 84cdf0e10cSrcweir #define SFXWB_SHOWALLFOLDER 0x10000000L // alle Ordner auch Mail/News/... 85cdf0e10cSrcweir #define SFXWB_MULTISELECTION 0x20000000L // Multiselection an 86cdf0e10cSrcweir #define SFXWB_NOREMOTE 0x40000000L 87cdf0e10cSrcweir #define SFXWB_SHOWVERSIONS 0x80000000L // Versionsauswahl anzeigen 88cdf0e10cSrcweir 89cdf0e10cSrcweir #define SFXWB_GRAPHIC 0x00800000L // FileOpen with link and preview box 90cdf0e10cSrcweir #define SFXWB_SHOWSTYLES 0x01000000L // FileOpen with link and preview box and styles 91cdf0e10cSrcweir 92cdf0e10cSrcweir #define SFXWB_EXPORT ( 0x040000000L | WB_SAVEAS ) // Export dialog 93cdf0e10cSrcweir 94cdf0e10cSrcweir #define FILEDIALOG_FILTER_ALL "*.*" 95cdf0e10cSrcweir 96cdf0e10cSrcweir #define FILE_OPEN_SERVICE_NAME "com.sun.star.ui.dialogs.FilePicker" 97cdf0e10cSrcweir #define FOLDER_PICKER_SERVICE_NAME "com.sun.star.ui.dialogs.FolderPicker" 98cdf0e10cSrcweir #define FILE_OPEN_SERVICE_NAME_SYSTEM "com.sun.star.ui.dialogs.SystemFilePicker" 99cdf0e10cSrcweir #define FILE_OPEN_SERVICE_NAME_OOO "com.sun.star.ui.dialogs.OfficeFilePicker" 100cdf0e10cSrcweir 101cdf0e10cSrcweir //----------------------------------------------------------------------------- 102cdf0e10cSrcweir 103cdf0e10cSrcweir namespace sfx2 { 104cdf0e10cSrcweir 105cdf0e10cSrcweir class FileDialogHelper_Impl; 106cdf0e10cSrcweir 107cdf0e10cSrcweir class SFX2_DLLPUBLIC FileDialogHelper 108cdf0e10cSrcweir { 109cdf0e10cSrcweir public: 110cdf0e10cSrcweir enum Context // context where the FileDialogHelper is used 111cdf0e10cSrcweir { 112cdf0e10cSrcweir UNKNOWN_CONTEXT, // unknown context 113cdf0e10cSrcweir SW_INSERT_GRAPHIC, // insert graphic in writer 114cdf0e10cSrcweir SW_INSERT_SOUND, // insert sound in writer 115cdf0e10cSrcweir SW_INSERT_VIDEO, // insert video in writer 116cdf0e10cSrcweir SC_INSERT_GRAPHIC, // insert graphic in calc 117cdf0e10cSrcweir SC_INSERT_SOUND, // insert sound in calc 118cdf0e10cSrcweir SC_INSERT_VIDEO, // insert video in calc 119cdf0e10cSrcweir SD_INSERT_GRAPHIC, // insert graphic in draw 120cdf0e10cSrcweir SD_INSERT_SOUND, // insert sound in draw 121cdf0e10cSrcweir SD_INSERT_VIDEO, // insert video in draw 122cdf0e10cSrcweir SD_EXPORT, // export in draw 123cdf0e10cSrcweir SI_EXPORT, // export in impress 124cdf0e10cSrcweir SW_EXPORT // export in writer 125cdf0e10cSrcweir }; 126cdf0e10cSrcweir 127cdf0e10cSrcweir private: 128cdf0e10cSrcweir Link m_aDialogClosedLink; 129cdf0e10cSrcweir ErrCode m_nError; 130cdf0e10cSrcweir 131cdf0e10cSrcweir ::com::sun::star::uno::Reference < ::com::sun::star::ui::dialogs::XFilePickerListener > mxImp; 132cdf0e10cSrcweir FileDialogHelper_Impl *mpImp; 133cdf0e10cSrcweir 134cdf0e10cSrcweir //#if 0 // _SOLAR__PRIVATE 135cdf0e10cSrcweir 136cdf0e10cSrcweir SAL_DLLPRIVATE sal_Int16 getDialogType( sal_Int64 nFlags ) const; 137cdf0e10cSrcweir 138cdf0e10cSrcweir //#endif 139cdf0e10cSrcweir 140cdf0e10cSrcweir public: 141cdf0e10cSrcweir FileDialogHelper( sal_Int64 nFlags, 142cdf0e10cSrcweir const String& rFactory, 143cdf0e10cSrcweir sal_Int16 nDialog, 144cdf0e10cSrcweir SfxFilterFlags nMust, 145cdf0e10cSrcweir SfxFilterFlags nDont ); 146cdf0e10cSrcweir 147cdf0e10cSrcweir FileDialogHelper( sal_Int64 nFlags, 148cdf0e10cSrcweir const String& rFact, 149cdf0e10cSrcweir sal_Int16 nDialog, 150cdf0e10cSrcweir SfxFilterFlags nMust, 151cdf0e10cSrcweir SfxFilterFlags nDont, 152cdf0e10cSrcweir const String& rStandardDir, 153cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList); 154cdf0e10cSrcweir 155cdf0e10cSrcweir FileDialogHelper( sal_Int64 nFlags, 156cdf0e10cSrcweir const String& rFactory, 157cdf0e10cSrcweir SfxFilterFlags nMust = 0, 158cdf0e10cSrcweir SfxFilterFlags nDont = 0 ); 159cdf0e10cSrcweir 160cdf0e10cSrcweir FileDialogHelper( sal_Int16 nDialogType, 161cdf0e10cSrcweir sal_Int64 nFlags, 162cdf0e10cSrcweir const String& rFactory, 163cdf0e10cSrcweir SfxFilterFlags nMust = 0, 164cdf0e10cSrcweir SfxFilterFlags nDont = 0 ); 165cdf0e10cSrcweir 166cdf0e10cSrcweir FileDialogHelper( sal_Int16 nDialogType, 167cdf0e10cSrcweir sal_Int64 nFlags, 168cdf0e10cSrcweir const String& rFactory, 169cdf0e10cSrcweir sal_Int16 nDialog, 170cdf0e10cSrcweir SfxFilterFlags nMust, 171cdf0e10cSrcweir SfxFilterFlags nDont, 172cdf0e10cSrcweir const String& rStandardDir, 173cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList); 174cdf0e10cSrcweir 175cdf0e10cSrcweir FileDialogHelper( sal_Int64 nFlags ); 176cdf0e10cSrcweir 177cdf0e10cSrcweir FileDialogHelper( sal_Int16 nDialogType, 178cdf0e10cSrcweir sal_Int64 nFlags, 179cdf0e10cSrcweir Window* _pPreferredParent = NULL ); 180cdf0e10cSrcweir 181cdf0e10cSrcweir FileDialogHelper( sal_Int16 nDialogType, 182cdf0e10cSrcweir sal_Int64 nFlags, 183cdf0e10cSrcweir const ::rtl::OUString& aFilterUIName, 184cdf0e10cSrcweir const ::rtl::OUString& aExtName, 185cdf0e10cSrcweir const ::rtl::OUString& rStandardDir, 186cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList, 187cdf0e10cSrcweir Window* _pPreferredParent = NULL ); 188cdf0e10cSrcweir 189cdf0e10cSrcweir 190cdf0e10cSrcweir virtual ~FileDialogHelper(); 191cdf0e10cSrcweir 192cdf0e10cSrcweir ErrCode Execute(); 193cdf0e10cSrcweir void StartExecuteModal( const Link& rEndDialogHdl ); GetError() const194cdf0e10cSrcweir inline ErrCode GetError() const { return m_nError; } 195cdf0e10cSrcweir sal_Int16 GetDialogType() const; 196cdf0e10cSrcweir sal_Bool IsPasswordEnabled() const; 197cdf0e10cSrcweir String GetRealFilter() const; 198cdf0e10cSrcweir 199cdf0e10cSrcweir void SetTitle( const String& rNewTitle ); 200cdf0e10cSrcweir String GetPath() const; 201cdf0e10cSrcweir 202cdf0e10cSrcweir /** @deprected: Don't use this method to retrieve the selected files 203cdf0e10cSrcweir There are file picker which can provide multiple selected file which belong 204cdf0e10cSrcweir to different folders. As this method always provides the root folder for all selected 205cdf0e10cSrcweir files this cannot work. 206cdf0e10cSrcweir */ 207cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > GetMPath() const; 208cdf0e10cSrcweir 209cdf0e10cSrcweir /** Provides the selected files with full path information */ 210cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > GetSelectedFiles() const; 211cdf0e10cSrcweir 212cdf0e10cSrcweir void AddFilter( const String& rFilterName, const String& rExtension ); 213cdf0e10cSrcweir void SetCurrentFilter( const String& rFilter ); 214cdf0e10cSrcweir 215cdf0e10cSrcweir /** sets an initial display directory/file name 216cdf0e10cSrcweir 217cdf0e10cSrcweir @deprecated 218cdf0e10cSrcweir don't use this method. It contains a lot of magic in determining whether the 219cdf0e10cSrcweir last segment of the given path/URL denotes a file name or a folder, and by 220cdf0e10cSrcweir definition, it cannot succeed with this magic *all* the time - there will 221cdf0e10cSrcweir always be scenarios where it fails. 222cdf0e10cSrcweir 223cdf0e10cSrcweir Use SetDisplayFolder and SetFileName. 224cdf0e10cSrcweir */ 225cdf0e10cSrcweir void SetDisplayDirectory( const String& rPath ); 226cdf0e10cSrcweir 227cdf0e10cSrcweir /** sets a new folder whose content is to be displayed in the file picker 228cdf0e10cSrcweir 229cdf0e10cSrcweir @param _rURL 230cdf0e10cSrcweir specifies the URL of the folder whose content is to be displayed.<br/> 231cdf0e10cSrcweir If the URL doesn't denote a valid (existent and accessible) folder, the 232cdf0e10cSrcweir request is silently dropped. 233cdf0e10cSrcweir @throws ::com::sun::star::uno::RuntimeException 234cdf0e10cSrcweir if the invocation of any of the file picker or UCB methods throws a RuntimeException. 235cdf0e10cSrcweir */ 236cdf0e10cSrcweir void SetDisplayFolder( const String& _rURL ); 237cdf0e10cSrcweir 238cdf0e10cSrcweir /** sets an initial file name to display 239cdf0e10cSrcweir 240cdf0e10cSrcweir This method is usually used in "save-as" contexts, where the application should 241cdf0e10cSrcweir suggest an initial name for the file to save. 242cdf0e10cSrcweir 243cdf0e10cSrcweir Calling this method is nearly equivalent to calling <code>GetFilePicker().setDefaultName( _rFileName )</code>, 244cdf0e10cSrcweir with the following differences: 245cdf0e10cSrcweir <ul><li>The FileDialogHelper remembers the given file name, and upon execution, 246cdf0e10cSrcweir strips its extension if the dialog is set up for "automatic file name extension".</li> 247cdf0e10cSrcweir <li>Exceptions thrown from the <code>XFilePicker</code> are caught and silenced.</li> 248cdf0e10cSrcweir </ul> 249cdf0e10cSrcweir */ 250cdf0e10cSrcweir void SetFileName( const String& _rFileName ); 251cdf0e10cSrcweir 252cdf0e10cSrcweir String GetCurrentFilter() const; 253cdf0e10cSrcweir String GetDisplayDirectory() const; 254cdf0e10cSrcweir ErrCode GetGraphic( Graphic& rGraphic ) const; 255cdf0e10cSrcweir 256cdf0e10cSrcweir ::com::sun::star::uno::Reference < ::com::sun::star::ui::dialogs::XFilePicker > GetFilePicker() const; 257cdf0e10cSrcweir 258cdf0e10cSrcweir // XFilePickerListener methods 259cdf0e10cSrcweir virtual void SAL_CALL FileSelectionChanged( const ::com::sun::star::ui::dialogs::FilePickerEvent& aEvent ); 260cdf0e10cSrcweir virtual void SAL_CALL DirectoryChanged( const ::com::sun::star::ui::dialogs::FilePickerEvent& aEvent ); 261cdf0e10cSrcweir virtual void SAL_CALL ControlStateChanged( const ::com::sun::star::ui::dialogs::FilePickerEvent& aEvent ); 262cdf0e10cSrcweir virtual void SAL_CALL DialogSizeChanged(); 263cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL HelpRequested( const ::com::sun::star::ui::dialogs::FilePickerEvent& aEvent ); 264cdf0e10cSrcweir 265cdf0e10cSrcweir // XDialogClosedListener methods 266cdf0e10cSrcweir virtual void SAL_CALL DialogClosed( const ::com::sun::star::ui::dialogs::DialogClosedEvent& _rEvent ); 267cdf0e10cSrcweir 268cdf0e10cSrcweir // retrieves the top-most file picker - i.e. the instance which is currently beeing executed 269cdf0e10cSrcweir static ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePicker > 270cdf0e10cSrcweir GetTopMostFilePicker( ); 271cdf0e10cSrcweir 272cdf0e10cSrcweir /** sets help ids for the controls in the dialog 273cdf0e10cSrcweir @param _pControlId 274cdf0e10cSrcweir Pointer to a 0-terminated array of control ids. They must be recruited from the 275cdf0e10cSrcweir CommonFilePickerElementIds and ExtendedFilePickerElementIds values. 276cdf0e10cSrcweir @param _pHelpId 277cdf0e10cSrcweir Pointer to an array of help ids. For each element in _pControlId, there must be 278cdf0e10cSrcweir a corresponding element herein. 279cdf0e10cSrcweir */ 280cdf0e10cSrcweir void SetControlHelpIds( const sal_Int16* _pControlId, const char** _pHelpId ); 281cdf0e10cSrcweir void CreateMatcher( const String& rName ); 282cdf0e10cSrcweir 283cdf0e10cSrcweir /** sets the context of the dialog and trigger necessary actions e.g. loading config, setting help id 284cdf0e10cSrcweir @param _eNewContext 285cdf0e10cSrcweir New context for the dialog. 286cdf0e10cSrcweir */ 287cdf0e10cSrcweir void SetContext( Context _eNewContext ); 288cdf0e10cSrcweir 289cdf0e10cSrcweir DECL_LINK( ExecuteSystemFilePicker, void* ); 290cdf0e10cSrcweir 291cdf0e10cSrcweir //#if 0 // _SOLAR__PRIVATE 292cdf0e10cSrcweir ErrCode Execute( SvStringsDtor*& rpURLList, 293cdf0e10cSrcweir SfxItemSet *& rpSet, 294cdf0e10cSrcweir String& rFilter, 295cdf0e10cSrcweir const String& rDirPath ); 296cdf0e10cSrcweir ErrCode Execute( SfxItemSet *& rpSet, 297cdf0e10cSrcweir String& rFilter ); 298cdf0e10cSrcweir //#endif 299cdf0e10cSrcweir }; 300cdf0e10cSrcweir 301cdf0e10cSrcweir #define SFX2_IMPL_DIALOG_CONFIG 0 302cdf0e10cSrcweir #define SFX2_IMPL_DIALOG_SYSTEM 1 303cdf0e10cSrcweir #define SFX2_IMPL_DIALOG_OOO 2 304cdf0e10cSrcweir 305cdf0e10cSrcweir //#if 0 // _SOLAR__PRIVATE 306cdf0e10cSrcweir ErrCode FileOpenDialog_Impl( sal_Int64 nFlags, 307cdf0e10cSrcweir const String& rFact, 308cdf0e10cSrcweir SvStringsDtor *& rpURLList, 309cdf0e10cSrcweir String& rFilter, 310cdf0e10cSrcweir SfxItemSet *& rpSet, 311cdf0e10cSrcweir const String* pPath = NULL, 312cdf0e10cSrcweir sal_Int16 nDialog = SFX2_IMPL_DIALOG_CONFIG, 313cdf0e10cSrcweir const String& rStandardDir = String::CreateFromAscii( "" ), 314cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList = ::com::sun::star::uno::Sequence< ::rtl::OUString >()); 315cdf0e10cSrcweir //#endif 316cdf0e10cSrcweir } 317cdf0e10cSrcweir 318cdf0e10cSrcweir //----------------------------------------------------------------------------- 319cdf0e10cSrcweir 320cdf0e10cSrcweir #endif 321cdf0e10cSrcweir 322