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

Generated by: LCOV version 1.10