LCOV - code coverage report
Current view: top level - include/sfx2 - filedlghelper.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 1 0.0 %
Date: 2014-04-14 Functions: 0 1 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : #ifndef INCLUDED_SFX2_FILEDLGHELPER_HXX
      20             : #define INCLUDED_SFX2_FILEDLGHELPER_HXX
      21             : 
      22             : #include <sal/config.h>
      23             : #include <sfx2/dllapi.h>
      24             : #include <sal/types.h>
      25             : #include <com/sun/star/uno/Reference.hxx>
      26             : #include <com/sun/star/uno/Sequence.hxx>
      27             : #include <rtl/ustring.hxx>
      28             : #include <tools/errcode.hxx>
      29             : #include <vcl/dialog.hxx>
      30             : #include <vcl/edit.hxx>
      31             : #include <vcl/button.hxx>
      32             : #include <vcl/graph.hxx>
      33             : #include <sfx2/sfxdefs.hxx>
      34             : #include <sfx2/sfxuno.hxx>
      35             : #include <sfx2/docfilt.hxx>
      36             : 
      37             : namespace com
      38             : {
      39             :     namespace sun
      40             :     {
      41             :         namespace star
      42             :         {
      43             :             namespace ui
      44             :             {
      45             :                 namespace dialogs
      46             :                 {
      47             :                     class XFilePicker;
      48             :                     class XFilePickerListener;
      49             :                     struct FilePickerEvent;
      50             :                     struct DialogClosedEvent;
      51             :                 }
      52             :             }
      53             :         }
      54             :     }
      55             : }
      56             : 
      57             : class SfxItemSet;
      58             : class Window;
      59             : 
      60             : // the SFXWB constants are for the nFlags parameter of the constructor
      61             : #define SFXWB_INSERT            0x04000000L     // turn Open into Insert dialog
      62             : #define SFXWB_EXPORT            0x40000000L     // turn Save into Export dialog
      63             : #define SFXWB_SAVEACOPY         0x00400000L     // turn Save into Save a Copy dialog
      64             : #define SFXWB_MULTISELECTION    0x20000000L
      65             : #define SFXWB_GRAPHIC           0x00800000L     // register graphic formats
      66             : 
      67             : #define FILEDIALOG_FILTER_ALL   "*.*"
      68             : 
      69             : #define FILE_OPEN_SERVICE_NAME_OOO   "com.sun.star.ui.dialogs.OfficeFilePicker"
      70             : 
      71             : namespace sfx2 {
      72             : 
      73             : class FileDialogHelper_Impl;
      74             : 
      75             : class SFX2_DLLPUBLIC FileDialogHelper
      76             : {
      77             : public:
      78             :     enum Context                        // context where the FileDialogHelper is used
      79             :     {
      80             :         UNKNOWN_CONTEXT,                // unknown context
      81             :         SW_INSERT_GRAPHIC,              // insert graphic in writer
      82             :         SW_INSERT_SOUND,                // insert sound in writer
      83             :         SW_INSERT_VIDEO,                // insert video in writer
      84             :         SC_INSERT_GRAPHIC,              // insert graphic in calc
      85             :         SC_INSERT_SOUND,                // insert sound in calc
      86             :         SC_INSERT_VIDEO,                // insert video in calc
      87             :         SD_INSERT_GRAPHIC,              // insert graphic in draw
      88             :         SD_INSERT_SOUND,                // insert sound in draw
      89             :         SD_INSERT_VIDEO,                // insert video in draw
      90             :         SD_EXPORT,                      // export in draw
      91             :         SI_EXPORT,                      // export in impress
      92             :         SW_EXPORT                       // export in writer
      93             :     };
      94             : 
      95             : private:
      96             :     Link    m_aDialogClosedLink;
      97             :     ErrCode m_nError;
      98             : 
      99             :     ::com::sun::star::uno::Reference < ::com::sun::star::ui::dialogs::XFilePickerListener > mxImp;
     100             :     FileDialogHelper_Impl   *mpImp;
     101             : 
     102             : 
     103             : public:
     104             :                             FileDialogHelper( sal_Int16 nDialogType,
     105             :                                               sal_Int64 nFlags,
     106             :                                               Window* _pPreferredParent = NULL );
     107             : 
     108             :                             FileDialogHelper( sal_Int16 nDialogType,
     109             :                                               sal_Int64 nFlags,
     110             :                                               const OUString& rFactory,
     111             :                                               SfxFilterFlags nMust = 0,
     112             :                                               SfxFilterFlags nDont = 0 );
     113             : 
     114             :                             FileDialogHelper( sal_Int16 nDialogType,
     115             :                                               sal_Int64 nFlags,
     116             :                                               const OUString& rFactory,
     117             :                                               sal_Int16 nDialog,
     118             :                                               SfxFilterFlags nMust,
     119             :                                               SfxFilterFlags nDont,
     120             :                                               const OUString& rStandardDir,
     121             :                                               const ::com::sun::star::uno::Sequence< OUString >& rBlackList);
     122             : 
     123             :                             FileDialogHelper( sal_Int16 nDialogType,
     124             :                                               sal_Int64 nFlags,
     125             :                                               const OUString& aFilterUIName,
     126             :                                               const OUString& aExtName,
     127             :                                               const OUString& rStandardDir,
     128             :                                               const ::com::sun::star::uno::Sequence< OUString >& rBlackList,
     129             :                                               Window* _pPreferredParent = NULL );
     130             : 
     131             : 
     132             :     virtual                 ~FileDialogHelper();
     133             : 
     134             :     ErrCode                 Execute();
     135             :     void                    StartExecuteModal( const Link& rEndDialogHdl );
     136           0 :     inline ErrCode          GetError() const { return m_nError; }
     137             :     sal_Int16               GetDialogType() const;
     138             :     bool                    IsPasswordEnabled() const;
     139             :     OUString                  GetRealFilter() const;
     140             : 
     141             :     void                    SetTitle( const OUString&  rNewTitle );
     142             :     OUString                GetPath() const;
     143             : 
     144             :     /** @deprected: Don't use this method to retrieve the selected files
     145             :         There are file picker which can provide multiple selected file which belong
     146             :         to different folders. As this method always provides the root folder for all selected
     147             :         files this cannot work.
     148             :     */
     149             :     ::com::sun::star::uno::Sequence< OUString > GetMPath() const;
     150             : 
     151             :     /** Provides the selected files with full path information */
     152             :     ::com::sun::star::uno::Sequence< OUString > GetSelectedFiles() const;
     153             : 
     154             :     void                     AddFilter( const OUString& rFilterName, const OUString& rExtension );
     155             :     void                     SetCurrentFilter( const OUString& rFilter );
     156             : 
     157             :     /** sets an initial display directory/file name
     158             : 
     159             :         @deprecated
     160             :             don't use this method. It contains a lot of magic in determining whether the
     161             :             last segment of the given path/URL denotes a file name or a folder, and by
     162             :             definition, it cannot succeed with this magic *all* the time - there will
     163             :             always be scenarios where it fails.
     164             : 
     165             :             Use SetDisplayFolder and SetFileName.
     166             :     */
     167             :     void                     SetDisplayDirectory( const OUString& rPath );
     168             : 
     169             :     /** sets a new folder whose content is to be displayed in the file picker
     170             : 
     171             :         @param _rURL
     172             :             specifies the URL of the folder whose content is to be displayed.<br/>
     173             :             If the URL doesn't denote a valid (existent and accessible) folder, the
     174             :             request is silently dropped.
     175             :         @throws ::com::sun::star::uno::RuntimeException
     176             :             if the invocation of any of the file picker or UCB methods throws a RuntimeException.
     177             :     */
     178             :     void                     SetDisplayFolder( const OUString& _rURL );
     179             : 
     180             :     /** sets an initial file name to display
     181             : 
     182             :         This method is usually used in "save-as" contexts, where the application should
     183             :         suggest an initial name for the file to save.
     184             : 
     185             :         Calling this method is nearly equivalent to calling <code>GetFilePicker().setDefaultName( _rFileName )</code>,
     186             :         with the following differences:
     187             :         <ul><li>The FileDialogHelper remembers the given file name, and upon execution,
     188             :                 strips its extension if the dialog is set up for "automatic file name extension".</li>
     189             :             <li>Exceptions thrown from the <code>XFilePicker</code> are caught and silenced.</li>
     190             :         </ul>
     191             :     */
     192             :     void                     SetFileName( const OUString& _rFileName );
     193             : 
     194             :     OUString                 GetCurrentFilter() const;
     195             :     OUString                 GetDisplayDirectory() const;
     196             :     ErrCode                  GetGraphic( Graphic& rGraphic ) const;
     197             : 
     198             :     ::com::sun::star::uno::Reference < ::com::sun::star::ui::dialogs::XFilePicker > GetFilePicker() const;
     199             : 
     200             :     // XFilePickerListener methods
     201             :     virtual void SAL_CALL   FileSelectionChanged( const ::com::sun::star::ui::dialogs::FilePickerEvent& aEvent );
     202             :     virtual void SAL_CALL   DirectoryChanged( const ::com::sun::star::ui::dialogs::FilePickerEvent& aEvent );
     203             :     virtual void SAL_CALL   ControlStateChanged( const ::com::sun::star::ui::dialogs::FilePickerEvent& aEvent );
     204             :     virtual void SAL_CALL   DialogSizeChanged();
     205             :     virtual OUString SAL_CALL    HelpRequested( const ::com::sun::star::ui::dialogs::FilePickerEvent& aEvent );
     206             : 
     207             :     // XDialogClosedListener methods
     208             :     virtual void SAL_CALL   DialogClosed( const ::com::sun::star::ui::dialogs::DialogClosedEvent& _rEvent );
     209             : 
     210             :     /** sets help ids for the controls in the dialog
     211             :         @param _pControlId
     212             :             Pointer to a 0-terminated array of control ids. They must be recruited from the
     213             :             CommonFilePickerElementIds and ExtendedFilePickerElementIds values.
     214             :         @param _pHelpId
     215             :             Pointer to an array of help ids. For each element in _pControlId, there must be
     216             :             a corresponding element herein.
     217             :     */
     218             :     void                    SetControlHelpIds( const sal_Int16* _pControlId, const char** _pHelpId );
     219             :     void                    CreateMatcher( const OUString& rName );
     220             : 
     221             :     /** sets the context of the dialog and trigger necessary actions e.g. loading config, setting help id
     222             :         @param _eNewContext
     223             :             New context for the dialog.
     224             :     */
     225             :     void                    SetContext( Context _eNewContext );
     226             : 
     227             :    DECL_LINK( ExecuteSystemFilePicker, void* );
     228             : 
     229             :    ErrCode                  Execute( std::vector<OUString>& rpURLList,
     230             :                                      SfxItemSet *&   rpSet,
     231             :                                      OUString&         rFilter,
     232             :                                      const OUString&   rDirPath );
     233             :    ErrCode                  Execute( SfxItemSet *&   rpSet,
     234             :                                      OUString&         rFilter );
     235             : };
     236             : 
     237             : #define SFX2_IMPL_DIALOG_CONFIG 0
     238             : #define SFX2_IMPL_DIALOG_SYSTEM 1
     239             : #define SFX2_IMPL_DIALOG_OOO 2
     240             : 
     241             : ErrCode FileOpenDialog_Impl( sal_Int16 nDialogType,
     242             :                              sal_Int64 nFlags,
     243             :                              const OUString& rFact,
     244             :                              std::vector<OUString>& rpURLList,
     245             :                              OUString& rFilter,
     246             :                              SfxItemSet *& rpSet,
     247             :                              const OUString* pPath = NULL,
     248             :                              sal_Int16 nDialog = SFX2_IMPL_DIALOG_CONFIG,
     249             :                              const OUString& rStandardDir = OUString(),
     250             :                              const ::com::sun::star::uno::Sequence< OUString >& rBlackList = ::com::sun::star::uno::Sequence< OUString >());
     251             : 
     252             : 
     253             : ErrCode RequestPassword(const SfxFilter* pCurrentFilter, OUString& aURL, SfxItemSet* pSet);
     254             : }
     255             : 
     256             : #endif
     257             : 
     258             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10