LCOV - code coverage report
Current view: top level - fpicker/source/office - iodlg.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 21 0.0 %
Date: 2014-11-03 Functions: 0 10 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_FPICKER_SOURCE_OFFICE_IODLG_HXX
      20             : #define INCLUDED_FPICKER_SOURCE_OFFICE_IODLG_HXX
      21             : 
      22             : #include <vcl/dialog.hxx>
      23             : #include <vcl/button.hxx>
      24             : #include <vcl/fixed.hxx>
      25             : #include <vcl/edit.hxx>
      26             : #include <vcl/combobox.hxx>
      27             : #include <vcl/lstbox.hxx>
      28             : #include <vcl/split.hxx>
      29             : #include <com/sun/star/beans/StringPair.hpp>
      30             : #include <com/sun/star/uno/Any.hxx>
      31             : #include <com/sun/star/uno/Sequence.hxx>
      32             : #include <com/sun/star/uno/Reference.hxx>
      33             : #include <com/sun/star/ucb/IOErrorCode.hpp>
      34             : #include <com/sun/star/ui/dialogs/XDialogClosedListener.hpp>
      35             : #include <unotools/confignode.hxx>
      36             : #include "svl/inettype.hxx"
      37             : #include "asyncfilepicker.hxx"
      38             : #include "OfficeControlAccess.hxx"
      39             : #include "fpsmartcontent.hxx"
      40             : #include <comphelper/configuration.hxx>
      41             : #include <comphelper/processfactory.hxx>
      42             : 
      43             : #include <set>
      44             : 
      45             : // @@@ using namespace com::sun::star::ucb;
      46             : 
      47             : 
      48             : 
      49             : class SvTabListBox;
      50             : class SvtFileView;
      51             : class SvtFileDialogFilter_Impl;
      52             : 
      53             : 
      54             : 
      55             : #define SFXWB_INSERT            ( 0x04000000L | WB_OPEN )
      56             : #define SFXWB_PASSWORD          WB_PASSWORD
      57             : #define SFXWB_READONLY          WB_READONLY
      58             : #define SFXWB_PATHDIALOG        WB_PATH
      59             : #define SFXWB_CLASSPATH         ( 0x08000000L | SFXWB_PATHDIALOG )
      60             : #define SFXWB_SHOWALLFOLDER     0x10000000L     // all directories including Mail/News/...
      61             : #define SFXWB_MULTISELECTION    0x20000000L     // activate Multiselection
      62             : #define SFXWB_NOREMOTE          0x40000000L
      63             : #define SFXWB_SHOWVERSIONS      0x80000000L     // show version selection
      64             : 
      65             : #define SFX_EXTRA_AUTOEXTENSION     0x00000001L
      66             : #define SFX_EXTRA_FILTEROPTIONS     0x00000002L
      67             : #define SFX_EXTRA_SHOWVERSIONS      0x00000004L
      68             : #define SFX_EXTRA_INSERTASLINK      0x00000008L
      69             : #define SFX_EXTRA_SHOWPREVIEW       0x00000010L
      70             : #define SFX_EXTRA_TEMPLATES         0x00000020L
      71             : #define SFX_EXTRA_PLAYBUTTON        0x00000040L
      72             : #define SFX_EXTRA_SELECTION         0x00000080L
      73             : #define SFX_EXTRA_IMAGE_TEMPLATE    0x00000100L
      74             : 
      75             : #define FILEDIALOG_FILTER_ALL   "*.*"
      76             : 
      77             : 
      78             : // SvtFileDialog
      79             : 
      80             : 
      81             : class SvtExpFileDlg_Impl;
      82             : class CustomContainer;
      83             : 
      84             : class SvtFileDialog : public ModalDialog, public ::svt::IFilePickerController
      85             : {
      86             : private:
      87             :     CheckBox*                   _pCbReadOnly;
      88             :     CheckBox*                   _pCbLinkBox;
      89             :     CheckBox*                   _pCbPreviewBox;
      90             :     CheckBox*                   _pCbSelection;
      91             :     PushButton*                 _pPbPlay;
      92             :     vcl::Window*                     _pPrevWin;
      93             :     FixedBitmap*                _pPrevBmp;
      94             :     CustomContainer*            _pContainer;
      95             :     SvtFileView*                _pFileView;
      96             :     Splitter*                   _pSplitter;
      97             :     ::svt::IFilePickerListener* _pFileNotifier;
      98             :     SvtExpFileDlg_Impl*         _pImp;
      99             :     WinBits                     _nExtraBits;
     100             :     bool                        _bIsInExecute   :   1;
     101             : 
     102             :     ImageList                   m_aImages;
     103             :     ::svt::SmartContent         m_aContent;
     104             : 
     105             :     ::std::set< Control* >      m_aDisabledControls;
     106             : 
     107             :     ::utl::OConfigurationNode   m_aConfiguration;
     108             :     ::rtl::Reference< ::svt::AsyncPickerAction >
     109             :                                 m_pCurrentAsyncAction;
     110             :     ::com::sun::star::uno::Reference<
     111             :         ::com::sun::star::ui::dialogs::XDialogClosedListener >
     112             :                                 m_xListener;
     113             :     bool                        m_bInExecuteAsync;
     114             :     bool                        m_bHasFilename;
     115             :     ::com::sun::star::uno::Reference < com::sun::star::uno::XComponentContext > m_context;
     116             : 
     117             :     DECL_STATIC_LINK( SvtFileDialog, FilterSelectHdl_Impl, ListBox* );
     118             :     DECL_STATIC_LINK( SvtFileDialog, NewFolderHdl_Impl, PushButton* );
     119             :     DECL_STATIC_LINK( SvtFileDialog, OpenHdl_Impl, void* );
     120             :     DECL_LINK       (                CancelHdl_Impl, void* );
     121             :     DECL_STATIC_LINK( SvtFileDialog, FileNameGetFocusHdl_Impl, void* );
     122             :     DECL_STATIC_LINK( SvtFileDialog, FileNameModifiedHdl_Impl, void* );
     123             : 
     124             :     DECL_STATIC_LINK( SvtFileDialog, URLBoxModifiedHdl_Impl, void* );
     125             :     DECL_STATIC_LINK( SvtFileDialog, ConnectToServerPressed_Hdl, void* );
     126             : 
     127             :     DECL_LINK       (                AddPlacePressed_Hdl, void* );
     128             :     DECL_LINK       (                RemovePlacePressed_Hdl, void* );
     129             :     DECL_LINK       (                Split_Hdl, void* );
     130             : 
     131             :     void                        Init_Impl( WinBits nBits );
     132             :     /** find a filter with the given wildcard
     133             :     @param _rFilter
     134             :         the wildcard pattern to look for in the filter list
     135             :     @param _bMultiExt
     136             :         allow for filters with more than one extension pattern
     137             :     @param _rFilterChanged
     138             :         set to <TRUE/> if the filter changed
     139             :     @return
     140             :         the filter which has been found
     141             :     */
     142             :     SvtFileDialogFilter_Impl*   FindFilter_Impl( const OUString& _rFilter,
     143             :                                                  bool _bMultiExt,
     144             :                                                  bool& _rFilterChanged
     145             :                                                  );
     146             :     void                        ExecuteFilter();
     147             :     void                        OpenMultiSelection_Impl();
     148             :     void                        AddControls_Impl( );
     149             : 
     150             :     DECL_LINK( SelectHdl_Impl, SvTabListBox* );
     151             :     DECL_LINK(DblClickHdl_Impl, void *);
     152             :     DECL_LINK(EntrySelectHdl_Impl, void *);
     153             :     DECL_LINK( OpenDoneHdl_Impl, SvtFileView* );
     154             :     DECL_LINK(AutoExtensionHdl_Impl, void *);
     155             :     DECL_LINK( ClickHdl_Impl, CheckBox* );
     156             :     DECL_LINK(PlayButtonHdl_Impl, void *);
     157             : 
     158             : 
     159             :     // removes a filter with wildcards from the path and returns it
     160             :     bool IsolateFilterFromPath_Impl( OUString& rPath, OUString& rFilter );
     161             : 
     162             :     void    implUpdateImages( );
     163             : 
     164             : protected:
     165             :     virtual bool                Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     166             :     void                        EnableInternet( bool bInternet );
     167             : 
     168             :     // originally from VclFileDialog
     169             :     Link                        _aOKHdl;
     170             :     Link                        _aFileSelectHdl;
     171             :     Link                        _aFilterSelectHdl;
     172             : 
     173             :     OUString                    _aPath;
     174             :     OUString                    _aDefExt;
     175             : 
     176             :     /** enables or disables the complete UI of the file picker, with only offering a
     177             :         cancel button
     178             : 
     179             :         This method preserves the "enabled" state of its controls in the following sense:
     180             :         If you disable a certain control, then disable the dialog UI, then enable the dialog
     181             :         UI, the control will still be disabled.
     182             :         This is under the assumption that you'll use EnableControl. Direct access to the control
     183             :         (such as pControl->Enable()) will break this.
     184             :     */
     185             :     void                        EnableUI( bool _bEnable );
     186             : 
     187             :     /** enables or disables a control
     188             : 
     189             :         You are strongly encouraged to prefer this method over pControl->Enable( _bEnable ). See
     190             :         <member>EnableUI</member> for details.
     191             :     */
     192             :     void                        EnableControl( Control* _pControl, bool _bEnable );
     193             :     short                       PrepareExecute();
     194             : 
     195             : public:
     196             :                                 SvtFileDialog( vcl::Window* _pParent, WinBits nBits, WinBits nExtraBits );
     197             :                                 SvtFileDialog( vcl::Window* _pParent, WinBits nBits );
     198             :                                 virtual ~SvtFileDialog();
     199             : 
     200             :     virtual long                OK();
     201             :     virtual short               Execute() SAL_OVERRIDE;
     202             :     virtual void                StartExecuteModal( const Link& rEndDialogHdl ) SAL_OVERRIDE;
     203             : 
     204             :             void                FileSelect();
     205             :             void                FilterSelect();
     206             : 
     207             :     void                        SetBlackList( const ::com::sun::star::uno::Sequence< OUString >& rBlackList );
     208             :     const ::com::sun::star::uno::Sequence< OUString >& GetBlackList() const;
     209             :     void                        SetStandardDir( const OUString& rStdDir );
     210             :     const OUString&            GetStandardDir() const;
     211             :     std::vector<OUString>       GetPathList() const;        // for MultiSelection
     212             : 
     213             :             void                AddFilter( const OUString& rFilter,
     214             :                                            const OUString& rType );
     215             : 
     216             :             void                AddFilterGroup(
     217             :                                   const OUString& _rFilter,
     218             :                                   const com::sun::star::uno::Sequence< com::sun::star::beans::StringPair >& rFilters );
     219             : 
     220             :             void                SetCurFilter( const OUString& rFilter );
     221             :             OUString            GetCurFilter() const;
     222             :             sal_uInt16          GetFilterCount() const;
     223             :             const OUString&     GetFilterName( sal_uInt16 nPos ) const;
     224             : 
     225             :     virtual void                Resize() SAL_OVERRIDE;
     226             :     virtual void                DataChanged( const DataChangedEvent& _rDCEvt ) SAL_OVERRIDE;
     227             : 
     228             :     void                        PrevLevel_Impl();
     229             :     void                        OpenURL_Impl( const OUString& rURL );
     230             : 
     231             :     inline SvtFileView*         GetView() const;
     232             : 
     233             :     void                        DisableSaveLastDirectory();
     234             :     void                        InitSize();
     235             :     void                        UpdateControls( const OUString& rURL );
     236             :     void                        EnableAutocompletion( bool _bEnable = true );
     237             : 
     238           0 :     void                        SetFileCallback( ::svt::IFilePickerListener *pNotifier ) { _pFileNotifier = pNotifier; }
     239             : 
     240             :     sal_Int32                   getTargetColorDepth();
     241             :     sal_Int32                   getAvailableWidth();
     242             :     sal_Int32                   getAvailableHeight();
     243             :     void                        setImage( sal_Int16 aImageFormat, const ::com::sun::star::uno::Any& rImage );
     244             :     bool                    setShowState( bool bShowState );
     245             :     bool                    getShowState();
     246             :     bool                    isAutoExtensionEnabled();
     247             : 
     248             :     OUString                    getCurrentFileText( ) const;
     249             :     void                        setCurrentFileText( const OUString& _rText, bool _bSelectAll = false );
     250             : 
     251             :     void                        onAsyncOperationStarted();
     252             :     void                        onAsyncOperationFinished();
     253             : 
     254             :     void                        RemovablePlaceSelected(bool enable = true);
     255             : 
     256             :     void                        displayIOException( const OUString& _rURL, ::com::sun::star::ucb::IOErrorCode _eCode );
     257             : 
     258             :     // inline
     259             :     inline void                 SetPath( const OUString& rNewURL );
     260             :     inline void                 SetHasFilename( bool bHasFilename );
     261             :     inline const OUString&      GetPath() const;
     262             :     inline void                 SetDefaultExt( const OUString& rExt );
     263             :     inline void                 EraseDefaultExt( sal_Int32 _nIndex = 0 );
     264             :     inline const OUString&      GetDefaultExt() const;
     265             :     inline void                 SetOKHdl( const Link& rLink );
     266             :     inline const Link&          GetOKHdl() const;
     267             :     inline void                 SetFileSelectHdl( const Link& rLink );
     268             :     inline const Link&          GetFileSelectHdl() const;
     269             :     inline void                 SetFilterSelectHdl( const Link& rLink );
     270             :     inline const Link&          GetFilterSelectHdl() const;
     271             : 
     272           0 :     inline Image                GetButtonImage( sal_uInt16 _nButtonId ) const { return m_aImages.GetImage( _nButtonId ); }
     273             : 
     274           0 :     bool                    ContentIsFolder( const OUString& rURL ) { return m_aContent.isFolder( rURL ) && m_aContent.isValid(); }
     275             :     bool                    ContentHasParentFolder( const OUString& rURL );
     276             :     bool                    ContentCanMakeFolder( const OUString& rURL );
     277             :     bool                    ContentGetTitle( const OUString& rURL, OUString& rTitle );
     278             : 
     279             : private:
     280             :     SvtFileDialogFilter_Impl*   implAddFilter( const OUString& _rFilter, const OUString& _rType );
     281             : 
     282             :     /** updates _pUserFilter with a new filter
     283             :         <p>No checks for necessity are made.</p>
     284             :         @param _bAllowUserDefExt
     285             :             set to <TRUE/> if a filter like "*.txt" should reset the DefaultExtension to doc.
     286             :             <p>
     287             :             In a file-save-dialog this would have the following effect:<br/>
     288             :             Say that auto-extension is checked, and the user enters *.txt, while a non-txt filter is selected.<br/>
     289             :             If _bAllowUserDefExt is set to <TRUE/>, then a user input of "foo" would save a foo.txt, but in a format
     290             :             which is determined by the filter selected (which is no txt file as said above).<br/>
     291             :             If _bAllowUserDefExt is set to <FALSE/>, the default extension will be the one of the selected filter, means
     292             :             in the above scenario a file "foo.<ext>" will be saved where ext is the extension of the selected filter.
     293             :             </p>
     294             :         @return <TRUE/> if the new filter is "*.*"
     295             :     */
     296             :     bool                    createNewUserFilter( const OUString& _rNewFilter, bool _bAllowUserDefExt );
     297             : 
     298             :     sal_uInt16                  adjustFilter( const OUString& _rFilter );
     299             : 
     300             :     // IFilePickerController, needed by OControlAccess
     301             :     virtual Control*            getControl( sal_Int16 _nControlId, bool _bLabelControl = false ) const SAL_OVERRIDE;
     302             :     virtual void                enableControl( sal_Int16 _nControlId, bool _bEnable ) SAL_OVERRIDE;
     303             :     virtual OUString            getCurFilter( ) const SAL_OVERRIDE;
     304             : 
     305             :     OUString                    implGetInitialURL( const OUString& _rPath, const OUString& _rFallback );
     306             : 
     307             :     /// executes a certain FileView action asynchronously
     308             :     void                        executeAsync(
     309             :                                     ::svt::AsyncPickerAction::Action _eAction,
     310             :                                     const OUString& _rURL,
     311             :                                     const OUString& _rFilter
     312             :                                 );
     313             : 
     314             :     /** helper function to check and append the default filter extension if
     315             :         necessary.
     316             :         The function checks if the specified filename already contains one of
     317             :         the valid extensions of the specified filter. If not the filter default
     318             :         extension is appended to the filename.
     319             : 
     320             :         @param _rFileName the filename which is checked and extended if necessary.
     321             :         @param _rFilterDefaultExtension the default extension of the used filter.
     322             :         @param _rFilterExtensions a list of one or more valid filter extensions
     323             :                of the used filter.
     324             : 
     325             :      */
     326             :     static void                 appendDefaultExtension(
     327             :                                         OUString& _rFileName,
     328             :                                         const OUString& _rFilterDefaultExtension,
     329             :                                         const OUString& _rFilterExtensions);
     330             : 
     331             :     void                        initDefaultPlaces( );
     332             : };
     333             : 
     334             : 
     335             : 
     336           0 : inline void SvtFileDialog::SetPath( const OUString& rNewURL )
     337             : {
     338           0 :     _aPath = rNewURL;
     339           0 : }
     340             : 
     341             : 
     342             : 
     343           0 : inline void SvtFileDialog::SetHasFilename( bool bHasFilename )
     344             : {
     345           0 :     m_bHasFilename = bHasFilename;
     346           0 : }
     347             : 
     348             : 
     349             : 
     350           0 : inline const OUString& SvtFileDialog::GetPath() const
     351             : {
     352           0 :     return _aPath;
     353             : }
     354             : 
     355             : 
     356             : 
     357           0 : inline void SvtFileDialog::SetDefaultExt( const OUString& rExt )
     358             : {
     359           0 :     _aDefExt = rExt;
     360           0 : }
     361             : 
     362           0 : inline void SvtFileDialog::EraseDefaultExt( sal_Int32 _nIndex )
     363             : {
     364           0 :     _aDefExt = _aDefExt.copy( 0, _nIndex );
     365           0 : }
     366             : 
     367           0 : inline const OUString& SvtFileDialog::GetDefaultExt() const
     368             : {
     369           0 :     return _aDefExt;
     370             : }
     371             : 
     372             : 
     373             : 
     374             : inline void SvtFileDialog::SetOKHdl
     375             : (
     376             :     const Link& rLink
     377             : )
     378             : {
     379             :     _aOKHdl = rLink;
     380             : }
     381             : 
     382             : 
     383             : 
     384             : inline const Link& SvtFileDialog::GetOKHdl() const
     385             : {
     386             :     return _aOKHdl;
     387             : }
     388             : 
     389             : 
     390             : 
     391             : inline void SvtFileDialog::SetFileSelectHdl
     392             : (
     393             :     const Link& rLink
     394             : )
     395             : {
     396             :     _aFileSelectHdl = rLink;
     397             : }
     398             : 
     399             : 
     400             : 
     401             : inline const Link& SvtFileDialog::GetFileSelectHdl() const
     402             : {
     403             :     return _aFileSelectHdl;
     404             : }
     405             : 
     406             : 
     407             : 
     408             : inline void SvtFileDialog::SetFilterSelectHdl
     409             : (
     410             :     const Link& rLink
     411             : )
     412             : {
     413             :     _aFilterSelectHdl = rLink;
     414             : }
     415             : 
     416             : 
     417             : 
     418             : inline const Link& SvtFileDialog::GetFilterSelectHdl() const
     419             : {
     420             :     return _aFilterSelectHdl;
     421             : }
     422             : 
     423             : 
     424             : 
     425           0 : inline SvtFileView* SvtFileDialog::GetView() const
     426             : {
     427           0 :     return _pFileView;
     428             : }
     429             : 
     430             : 
     431             : 
     432             : 
     433             : 
     434             : #define FILE_SELECTION_CHANGED  1
     435             : #define DIRECTORY_CHANGED       2
     436             : #define HELP_REQUESTED          3
     437             : #define CTRL_STATE_CHANGED      4
     438             : #define DIALOG_SIZE_CHANGED     5
     439             : 
     440             : 
     441             : #endif // INCLUDED_FPICKER_SOURCE_OFFICE_IODLG_HXX
     442             : 
     443             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10