LCOV - code coverage report
Current view: top level - sfx2/source/dialog - filedlghelper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 1232 0.0 %
Date: 2012-08-25 Functions: 0 115 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 2506 0.0 %

           Branch data     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                 :            : 
      20                 :            : #include <sfx2/filedlghelper.hxx>
      21                 :            : #include <sal/types.h>
      22                 :            : #include <com/sun/star/lang/XInitialization.hpp>
      23                 :            : #include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
      24                 :            : #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
      25                 :            : #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
      26                 :            : #include <com/sun/star/ui/dialogs/FilePreviewImageFormats.hpp>
      27                 :            : #include <com/sun/star/ui/dialogs/ControlActions.hpp>
      28                 :            : #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
      29                 :            : #include <com/sun/star/ui/dialogs/XControlInformation.hpp>
      30                 :            : #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
      31                 :            : #include <com/sun/star/ui/dialogs/XFilePickerNotifier.hpp>
      32                 :            : #include <com/sun/star/ui/dialogs/XFilePreview.hpp>
      33                 :            : #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
      34                 :            : #include <com/sun/star/ui/dialogs/XFilterGroupManager.hpp>
      35                 :            : #include <com/sun/star/ui/dialogs/XFolderPicker.hpp>
      36                 :            : #include <com/sun/star/ui/dialogs/XFilePicker2.hpp>
      37                 :            : #include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp>
      38                 :            : #include <com/sun/star/lang/XServiceInfo.hpp>
      39                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      40                 :            : #include <com/sun/star/beans/NamedValue.hpp>
      41                 :            : #include <com/sun/star/embed/ElementModes.hpp>
      42                 :            : #include <com/sun/star/container/XEnumeration.hpp>
      43                 :            : #include <com/sun/star/container/XContainerQuery.hpp>
      44                 :            : #include <com/sun/star/task/XInteractionRequest.hpp>
      45                 :            : #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
      46                 :            : 
      47                 :            : #include <comphelper/processfactory.hxx>
      48                 :            : #include <comphelper/sequenceashashmap.hxx>
      49                 :            : #include <comphelper/stillreadwriteinteraction.hxx>
      50                 :            : #include <comphelper/string.hxx>
      51                 :            : #include <comphelper/types.hxx>
      52                 :            : #include <tools/urlobj.hxx>
      53                 :            : #include <vcl/help.hxx>
      54                 :            : #include <unotools/ucbstreamhelper.hxx>
      55                 :            : #include <unotools/ucbhelper.hxx>
      56                 :            : #include <unotools/localfilehelper.hxx>
      57                 :            : #include <osl/file.hxx>
      58                 :            : #include <osl/mutex.hxx>
      59                 :            : #include <osl/security.hxx>
      60                 :            : #include <osl/thread.hxx>
      61                 :            : #include <vcl/cvtgrf.hxx>
      62                 :            : #include <vcl/msgbox.hxx>
      63                 :            : #include <vcl/mnemonic.hxx>
      64                 :            : #include <unotools/pathoptions.hxx>
      65                 :            : #include <unotools/securityoptions.hxx>
      66                 :            : #include <svl/itemset.hxx>
      67                 :            : #include <svl/eitem.hxx>
      68                 :            : #include <svl/intitem.hxx>
      69                 :            : #include <svl/stritem.hxx>
      70                 :            : #include <svtools/filter.hxx>
      71                 :            : #include <unotools/viewoptions.hxx>
      72                 :            : #include <unotools/moduleoptions.hxx>
      73                 :            : #include <svtools/helpid.hrc>
      74                 :            : #include <comphelper/docpasswordrequest.hxx>
      75                 :            : #include <comphelper/docpasswordhelper.hxx>
      76                 :            : #include <ucbhelper/content.hxx>
      77                 :            : #include <ucbhelper/commandenvironment.hxx>
      78                 :            : #include <comphelper/storagehelper.hxx>
      79                 :            : #include <toolkit/helper/vclunohelper.hxx>
      80                 :            : #include <sfx2/app.hxx>
      81                 :            : #include <sfx2/frame.hxx>
      82                 :            : #include <sfx2/docfile.hxx>
      83                 :            : #include <sfx2/docfac.hxx>
      84                 :            : #include "openflag.hxx"
      85                 :            : #include <sfx2/passwd.hxx>
      86                 :            : #include "sfx2/sfxresid.hxx"
      87                 :            : #include <sfx2/sfxsids.hrc>
      88                 :            : #include "filedlghelper.hrc"
      89                 :            : #include "filtergrouping.hxx"
      90                 :            : #include <sfx2/request.hxx>
      91                 :            : #include "filedlgimpl.hxx"
      92                 :            : #include <helpid.hrc>
      93                 :            : #include <sfxlocal.hrc>
      94                 :            : #include <rtl/oustringostreaminserter.hxx>
      95                 :            : #include <rtl/strbuf.hxx>
      96                 :            : 
      97                 :            : #ifdef UNX
      98                 :            : #include <errno.h>
      99                 :            : #include <sys/stat.h>
     100                 :            : #endif
     101                 :            : 
     102                 :            : //-----------------------------------------------------------------------------
     103                 :            : 
     104                 :            : using namespace ::com::sun::star;
     105                 :            : using namespace ::com::sun::star::container;
     106                 :            : using namespace ::com::sun::star::lang;
     107                 :            : using namespace ::com::sun::star::ui::dialogs;
     108                 :            : using namespace ::com::sun::star::ui::dialogs::TemplateDescription;
     109                 :            : using namespace ::com::sun::star::uno;
     110                 :            : using namespace ::com::sun::star::beans;
     111                 :            : using namespace ::rtl;
     112                 :            : using namespace ::cppu;
     113                 :            : 
     114                 :            : //-----------------------------------------------------------------------------
     115                 :            : 
     116                 :            : #define IODLG_CONFIGNAME        String(DEFINE_CONST_UNICODE("FilePicker_Save"))
     117                 :            : #define IMPGRF_CONFIGNAME       String(DEFINE_CONST_UNICODE("FilePicker_Graph"))
     118                 :            : #define USERITEM_NAME           ::rtl::OUString("UserItem" )
     119                 :            : 
     120                 :            : //-----------------------------------------------------------------------------
     121                 :            : 
     122                 :            : namespace sfx2
     123                 :            : {
     124                 :            : 
     125                 :          0 : const OUString* GetLastFilterConfigId( FileDialogHelper::Context _eContext )
     126                 :            : {
     127 [ #  # ][ #  # ]:          0 :     static const OUString aSD_EXPORT_IDENTIFIER( "SdExportLastFilter"  );
     128 [ #  # ][ #  # ]:          0 :     static const OUString aSI_EXPORT_IDENTIFIER( "SiExportLastFilter"  );
     129 [ #  # ][ #  # ]:          0 :     static const OUString aSW_EXPORT_IDENTIFIER( "SwExportLastFilter"  );
     130                 :            : 
     131                 :          0 :     const OUString* pRet = NULL;
     132                 :            : 
     133   [ #  #  #  # ]:          0 :     switch( _eContext )
     134                 :            :     {
     135                 :          0 :         case FileDialogHelper::SD_EXPORT: pRet = &aSD_EXPORT_IDENTIFIER; break;
     136                 :          0 :         case FileDialogHelper::SI_EXPORT: pRet = &aSI_EXPORT_IDENTIFIER; break;
     137                 :          0 :         case FileDialogHelper::SW_EXPORT: pRet = &aSW_EXPORT_IDENTIFIER; break;
     138                 :          0 :         default: break;
     139                 :            :     }
     140                 :            : 
     141                 :          0 :     return pRet;
     142                 :            : }
     143                 :            : 
     144                 :            : String EncodeSpaces_Impl( const String& rSource );
     145                 :            : String DecodeSpaces_Impl( const String& rSource );
     146                 :            : 
     147                 :            : // ------------------------------------------------------------------------
     148                 :            : // -----------      FileDialogHelper_Impl       ---------------------------
     149                 :            : // ------------------------------------------------------------------------
     150                 :            : 
     151                 :            : // ------------------------------------------------------------------------
     152                 :            : // XFilePickerListener Methods
     153                 :            : // ------------------------------------------------------------------------
     154                 :          0 : void SAL_CALL FileDialogHelper_Impl::fileSelectionChanged( const FilePickerEvent& aEvent ) throw ( RuntimeException )
     155                 :            : {
     156         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     157 [ #  # ][ #  # ]:          0 :     mpAntiImpl->FileSelectionChanged( aEvent );
     158                 :          0 : }
     159                 :            : 
     160                 :            : // ------------------------------------------------------------------------
     161                 :          0 : void SAL_CALL FileDialogHelper_Impl::directoryChanged( const FilePickerEvent& aEvent ) throw ( RuntimeException )
     162                 :            : {
     163         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     164 [ #  # ][ #  # ]:          0 :     mpAntiImpl->DirectoryChanged( aEvent );
     165                 :          0 : }
     166                 :            : 
     167                 :            : // ------------------------------------------------------------------------
     168                 :          0 : OUString SAL_CALL FileDialogHelper_Impl::helpRequested( const FilePickerEvent& aEvent ) throw ( RuntimeException )
     169                 :            : {
     170         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     171 [ #  # ][ #  # ]:          0 :     return mpAntiImpl->HelpRequested( aEvent );
     172                 :            : }
     173                 :            : 
     174                 :            : // ------------------------------------------------------------------------
     175                 :          0 : void SAL_CALL FileDialogHelper_Impl::controlStateChanged( const FilePickerEvent& aEvent ) throw ( RuntimeException )
     176                 :            : {
     177         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     178 [ #  # ][ #  # ]:          0 :     mpAntiImpl->ControlStateChanged( aEvent );
     179                 :          0 : }
     180                 :            : 
     181                 :            : // ------------------------------------------------------------------------
     182                 :          0 : void SAL_CALL FileDialogHelper_Impl::dialogSizeChanged() throw ( RuntimeException )
     183                 :            : {
     184         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     185 [ #  # ][ #  # ]:          0 :     mpAntiImpl->DialogSizeChanged();
     186                 :          0 : }
     187                 :            : 
     188                 :            : // ------------------------------------------------------------------------
     189                 :            : // XDialogClosedListener Methods
     190                 :            : // ------------------------------------------------------------------------
     191                 :          0 : void SAL_CALL FileDialogHelper_Impl::dialogClosed( const DialogClosedEvent& _rEvent ) throw ( RuntimeException )
     192                 :            : {
     193         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     194         [ #  # ]:          0 :     mpAntiImpl->DialogClosed( _rEvent );
     195 [ #  # ][ #  # ]:          0 :     postExecute( _rEvent.DialogResult );
     196                 :          0 : }
     197                 :            : 
     198                 :            : // ------------------------------------------------------------------------
     199                 :            : // handle XFilePickerListener events
     200                 :            : // ------------------------------------------------------------------------
     201                 :          0 : void FileDialogHelper_Impl::handleFileSelectionChanged( const FilePickerEvent& )
     202                 :            : {
     203         [ #  # ]:          0 :     if ( mbHasVersions )
     204                 :          0 :         updateVersions();
     205                 :            : 
     206         [ #  # ]:          0 :     if ( mbShowPreview )
     207                 :          0 :         maPreViewTimer.Start();
     208                 :          0 : }
     209                 :            : 
     210                 :            : // ------------------------------------------------------------------------
     211                 :          0 : void FileDialogHelper_Impl::handleDirectoryChanged( const FilePickerEvent& )
     212                 :            : {
     213         [ #  # ]:          0 :     if ( mbShowPreview )
     214                 :          0 :         TimeOutHdl_Impl( NULL );
     215                 :          0 : }
     216                 :            : 
     217                 :            : // ------------------------------------------------------------------------
     218                 :          0 : OUString FileDialogHelper_Impl::handleHelpRequested( const FilePickerEvent& aEvent )
     219                 :            : {
     220                 :            :     //!!! todo: cache the help strings (here or TRA)
     221                 :            : 
     222                 :          0 :     rtl::OString sHelpId;
     223                 :            :     // mapping from element id -> help id
     224   [ #  #  #  #  :          0 :     switch ( aEvent.ElementId )
          #  #  #  #  #  
                #  #  # ]
     225                 :            :     {
     226                 :            :         case ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION :
     227                 :          0 :             sHelpId = HID_FILESAVE_AUTOEXTENSION;
     228                 :          0 :             break;
     229                 :            : 
     230                 :            :         case ExtendedFilePickerElementIds::CHECKBOX_PASSWORD :
     231                 :          0 :             sHelpId = HID_FILESAVE_SAVEWITHPASSWORD;
     232                 :          0 :             break;
     233                 :            : 
     234                 :            :         case ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS :
     235                 :          0 :             sHelpId = HID_FILESAVE_CUSTOMIZEFILTER;
     236                 :          0 :             break;
     237                 :            : 
     238                 :            :         case ExtendedFilePickerElementIds::CHECKBOX_READONLY :
     239                 :          0 :             sHelpId = HID_FILEOPEN_READONLY;
     240                 :          0 :             break;
     241                 :            : 
     242                 :            :         case ExtendedFilePickerElementIds::CHECKBOX_LINK :
     243                 :          0 :             sHelpId = HID_FILEDLG_LINK_CB;
     244                 :          0 :             break;
     245                 :            : 
     246                 :            :         case ExtendedFilePickerElementIds::CHECKBOX_PREVIEW :
     247                 :          0 :             sHelpId = HID_FILEDLG_PREVIEW_CB;
     248                 :          0 :             break;
     249                 :            : 
     250                 :            :         case ExtendedFilePickerElementIds::PUSHBUTTON_PLAY :
     251                 :          0 :             sHelpId = HID_FILESAVE_DOPLAY;
     252                 :          0 :             break;
     253                 :            : 
     254                 :            :         case ExtendedFilePickerElementIds::LISTBOX_VERSION_LABEL :
     255                 :            :         case ExtendedFilePickerElementIds::LISTBOX_VERSION :
     256                 :          0 :             sHelpId = HID_FILEOPEN_VERSION;
     257                 :          0 :             break;
     258                 :            : 
     259                 :            :         case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE_LABEL :
     260                 :            :         case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE :
     261                 :          0 :             sHelpId = HID_FILESAVE_TEMPLATE;
     262                 :          0 :             break;
     263                 :            : 
     264                 :            :         case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE_LABEL :
     265                 :            :         case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE :
     266                 :          0 :             sHelpId = HID_FILEOPEN_IMAGE_TEMPLATE;
     267                 :          0 :             break;
     268                 :            : 
     269                 :            :         case ExtendedFilePickerElementIds::CHECKBOX_SELECTION :
     270                 :          0 :             sHelpId = HID_FILESAVE_SELECTION;
     271                 :          0 :             break;
     272                 :            : 
     273                 :            :         default:
     274                 :            :             SAL_WARN( "sfx2.dialog", "invalid element id" );
     275                 :            :     }
     276                 :            : 
     277                 :          0 :     OUString aHelpText;
     278         [ #  # ]:          0 :     Help* pHelp = Application::GetHelp();
     279         [ #  # ]:          0 :     if ( pHelp )
     280 [ #  # ][ #  # ]:          0 :         aHelpText = String( pHelp->GetHelpText( rtl::OStringToOUString(sHelpId, RTL_TEXTENCODING_UTF8), NULL ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     281                 :          0 :     return aHelpText;
     282                 :            : }
     283                 :            : 
     284                 :            : // ------------------------------------------------------------------------
     285                 :          0 : void FileDialogHelper_Impl::handleControlStateChanged( const FilePickerEvent& aEvent )
     286                 :            : {
     287      [ #  #  # ]:          0 :     switch ( aEvent.ElementId )
     288                 :            :     {
     289                 :            :         case CommonFilePickerElementIds::LISTBOX_FILTER:
     290                 :          0 :             updateFilterOptionsBox();
     291                 :          0 :             enablePasswordBox( sal_False );
     292                 :          0 :             updateSelectionBox();
     293                 :            :             // only use it for export and with our own dialog
     294 [ #  # ][ #  # ]:          0 :             if ( mbExport && !mbSystemPicker )
     295                 :          0 :                 updateExportButton();
     296                 :          0 :             break;
     297                 :            : 
     298                 :            :         case ExtendedFilePickerElementIds::CHECKBOX_PREVIEW:
     299                 :          0 :             updatePreviewState();
     300                 :          0 :             break;
     301                 :            :     }
     302                 :          0 : }
     303                 :            : 
     304                 :            : // ------------------------------------------------------------------------
     305                 :          0 : void FileDialogHelper_Impl::handleDialogSizeChanged()
     306                 :            : {
     307         [ #  # ]:          0 :     if ( mbShowPreview )
     308                 :          0 :         TimeOutHdl_Impl( NULL );
     309                 :          0 : }
     310                 :            : 
     311                 :            : // ------------------------------------------------------------------------
     312                 :            : // XEventListener Methods
     313                 :            : // ------------------------------------------------------------------------
     314                 :          0 : void SAL_CALL FileDialogHelper_Impl::disposing( const EventObject& ) throw ( RuntimeException )
     315                 :            : {
     316         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     317 [ #  # ][ #  # ]:          0 :     dispose();
     318                 :          0 : }
     319                 :            : 
     320                 :            : // ------------------------------------------------------------------------
     321                 :            : 
     322                 :          0 : void FileDialogHelper_Impl::dispose()
     323                 :            : {
     324         [ #  # ]:          0 :     if ( mxFileDlg.is() )
     325                 :            :     {
     326                 :            :         // remove the event listener
     327         [ #  # ]:          0 :         uno::Reference< XFilePickerNotifier > xNotifier( mxFileDlg, UNO_QUERY );
     328         [ #  # ]:          0 :         if ( xNotifier.is() )
     329 [ #  # ][ #  # ]:          0 :             xNotifier->removeFilePickerListener( this );
                 [ #  # ]
     330                 :            : 
     331         [ #  # ]:          0 :         ::comphelper::disposeComponent( mxFileDlg );
     332                 :          0 :         mxFileDlg.clear();
     333                 :            :     }
     334                 :          0 : }
     335                 :            : 
     336                 :            : // ------------------------------------------------------------------------
     337                 :          0 : String FileDialogHelper_Impl::getCurrentFilterUIName() const
     338                 :            : {
     339         [ #  # ]:          0 :     String aFilterName;
     340         [ #  # ]:          0 :     uno::Reference< XFilterManager > xFltMgr( mxFileDlg, UNO_QUERY );
     341                 :            : 
     342         [ #  # ]:          0 :     if( xFltMgr.is() )
     343                 :            :     {
     344 [ #  # ][ #  # ]:          0 :         aFilterName = xFltMgr->getCurrentFilter();
                 [ #  # ]
     345                 :            : 
     346 [ #  # ][ #  # ]:          0 :         if ( aFilterName.Len() && isShowFilterExtensionEnabled() )
                 [ #  # ]
     347 [ #  # ][ #  # ]:          0 :             aFilterName = getFilterName( aFilterName );
                 [ #  # ]
     348                 :            :     }
     349                 :            : 
     350                 :          0 :     return aFilterName;
     351                 :            : }
     352                 :            : 
     353                 :            : // ------------------------------------------------------------------------
     354                 :          0 : void FileDialogHelper_Impl::LoadLastUsedFilter( const OUString& _rContextIdentifier )
     355                 :            : {
     356 [ #  # ][ #  # ]:          0 :     SvtViewOptions aDlgOpt( E_DIALOG, IODLG_CONFIGNAME );
         [ #  # ][ #  # ]
     357                 :            : 
     358 [ #  # ][ #  # ]:          0 :     if( aDlgOpt.Exists() )
     359                 :            :     {
     360                 :          0 :         OUString    aLastFilter;
     361 [ #  # ][ #  # ]:          0 :         if( aDlgOpt.GetUserItem( _rContextIdentifier ) >>= aLastFilter )
     362         [ #  # ]:          0 :             setFilter( aLastFilter );
     363         [ #  # ]:          0 :     }
     364                 :          0 : }
     365                 :            : 
     366                 :            : // ------------------------------------------------------------------------
     367                 :          0 : void FileDialogHelper_Impl::SaveLastUsedFilter( const OUString& _rContextIdentifier )
     368                 :            : {
     369                 :            :     SvtViewOptions( E_DIALOG, IODLG_CONFIGNAME ).SetUserItem( _rContextIdentifier,
     370 [ #  # ][ #  # ]:          0 :                         makeAny( getFilterWithExtension( getFilter() ) ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     371                 :          0 : }
     372                 :            : 
     373                 :            : // ------------------------------------------------------------------------
     374                 :          0 : void FileDialogHelper_Impl::SaveLastUsedFilter( void )
     375                 :            : {
     376                 :          0 :     const OUString* pConfigId = GetLastFilterConfigId( meContext );
     377         [ #  # ]:          0 :     if( pConfigId )
     378                 :          0 :         SaveLastUsedFilter( *pConfigId );
     379                 :          0 : }
     380                 :            : 
     381                 :            : // ------------------------------------------------------------------------
     382                 :          0 : const SfxFilter* FileDialogHelper_Impl::getCurentSfxFilter()
     383                 :            : {
     384         [ #  # ]:          0 :     String aFilterName = getCurrentFilterUIName();
     385                 :            : 
     386                 :          0 :     const SfxFilter* pFilter = NULL;
     387 [ #  # ][ #  # ]:          0 :     if ( mpMatcher && aFilterName.Len() )
                 [ #  # ]
     388         [ #  # ]:          0 :         pFilter = mpMatcher->GetFilter4UIName( aFilterName, m_nMustFlags, m_nDontFlags );
     389                 :            : 
     390         [ #  # ]:          0 :     return pFilter;
     391                 :            : }
     392                 :            : 
     393                 :            : // ------------------------------------------------------------------------
     394                 :          0 : sal_Bool FileDialogHelper_Impl::updateExtendedControl( sal_Int16 _nExtendedControlId, sal_Bool _bEnable )
     395                 :            : {
     396                 :          0 :     sal_Bool bIsEnabled = sal_False;
     397                 :            : 
     398         [ #  # ]:          0 :     uno::Reference < XFilePickerControlAccess > xCtrlAccess( mxFileDlg, UNO_QUERY );
     399         [ #  # ]:          0 :     if ( xCtrlAccess.is() )
     400                 :            :     {
     401                 :            :         try
     402                 :            :         {
     403 [ #  # ][ #  # ]:          0 :             xCtrlAccess->enableControl( _nExtendedControlId, _bEnable );
     404                 :          0 :             bIsEnabled = _bEnable;
     405                 :            :         }
     406         [ #  # ]:          0 :         catch( const IllegalArgumentException& )
     407                 :            :         {
     408                 :            :             OSL_FAIL( "FileDialogHelper_Impl::updateExtendedControl: caught an exception!" );
     409                 :            :         }
     410                 :            :     }
     411         [ #  # ]:          0 :     return bIsEnabled;
     412                 :            : }
     413                 :            : 
     414                 :            : // ------------------------------------------------------------------------
     415                 :          0 : sal_Bool FileDialogHelper_Impl::CheckFilterOptionsCapability( const SfxFilter* _pFilter )
     416                 :            : {
     417                 :          0 :     sal_Bool bResult = sal_False;
     418                 :            : 
     419 [ #  # ][ #  # ]:          0 :     if( mxFilterCFG.is() && _pFilter )
                 [ #  # ]
     420                 :            :     {
     421                 :            :         try {
     422         [ #  # ]:          0 :                Sequence < PropertyValue > aProps;
     423 [ #  # ][ #  # ]:          0 :                Any aAny = mxFilterCFG->getByName( _pFilter->GetName() );
                 [ #  # ]
     424 [ #  # ][ #  # ]:          0 :                if ( aAny >>= aProps )
     425                 :            :                {
     426                 :          0 :                    ::rtl::OUString aServiceName;
     427                 :          0 :                    sal_Int32 nPropertyCount = aProps.getLength();
     428         [ #  # ]:          0 :                    for( sal_Int32 nProperty=0; nProperty < nPropertyCount; ++nProperty )
     429                 :            :                 {
     430 [ #  # ][ #  # ]:          0 :                        if( aProps[nProperty].Name.equals( DEFINE_CONST_OUSTRING( "UIComponent") ) )
                 [ #  # ]
     431                 :            :                        {
     432         [ #  # ]:          0 :                            aProps[nProperty].Value >>= aServiceName;
     433         [ #  # ]:          0 :                         if( !aServiceName.isEmpty() )
     434                 :          0 :                             bResult = sal_True;
     435                 :            :                     }
     436                 :          0 :                 }
     437 [ #  # ][ #  # ]:          0 :             }
     438                 :            :         }
     439                 :          0 :         catch( const Exception& )
     440                 :            :         {
     441                 :            :         }
     442                 :            :     }
     443                 :            : 
     444                 :          0 :     return bResult;
     445                 :            : }
     446                 :            : 
     447                 :            : // ------------------------------------------------------------------------
     448                 :          0 : sal_Bool FileDialogHelper_Impl::isInOpenMode() const
     449                 :            : {
     450                 :          0 :     sal_Bool bRet = sal_False;
     451                 :            : 
     452         [ #  # ]:          0 :     switch ( m_nDialogType )
     453                 :            :     {
     454                 :            :         case FILEOPEN_SIMPLE:
     455                 :            :         case FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE:
     456                 :            :         case FILEOPEN_PLAY:
     457                 :            :         case FILEOPEN_READONLY_VERSION:
     458                 :            :         case FILEOPEN_LINK_PREVIEW:
     459                 :          0 :             bRet = sal_True;
     460                 :            :     }
     461                 :            : 
     462                 :          0 :     return bRet;
     463                 :            : }
     464                 :            : 
     465                 :            : // ------------------------------------------------------------------------
     466                 :            : 
     467                 :          0 : void FileDialogHelper_Impl::updateFilterOptionsBox()
     468                 :            : {
     469         [ #  # ]:          0 :     if ( !m_bHaveFilterOptions )
     470                 :          0 :         return;
     471                 :            : 
     472                 :            :     updateExtendedControl(
     473                 :            :         ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS,
     474                 :          0 :         CheckFilterOptionsCapability( getCurentSfxFilter() )
     475                 :          0 :     );
     476                 :            : }
     477                 :            : 
     478                 :            : // ------------------------------------------------------------------------
     479                 :            : 
     480                 :          0 : void FileDialogHelper_Impl::updateExportButton()
     481                 :            : {
     482         [ #  # ]:          0 :     uno::Reference < XFilePickerControlAccess > xCtrlAccess( mxFileDlg, UNO_QUERY );
     483         [ #  # ]:          0 :     if ( xCtrlAccess.is() )
     484                 :            :     {
     485                 :          0 :         OUString sEllipses( "..."  );
     486 [ #  # ][ #  # ]:          0 :         OUString sOldLabel( xCtrlAccess->getLabel( CommonFilePickerElementIds::PUSHBUTTON_OK ) );
     487                 :            : 
     488                 :            :         // initialize button label; we need the label with the mnemonic char
     489 [ #  # ][ #  # ]:          0 :         if ( maButtonLabel.isEmpty() || maButtonLabel.indexOf( MNEMONIC_CHAR ) == -1 )
                 [ #  # ]
     490                 :            :         {
     491                 :            :             // cut the ellipses, if necessary
     492                 :          0 :             sal_Int32 nIndex = sOldLabel.indexOf( sEllipses );
     493         [ #  # ]:          0 :             if ( -1 == nIndex )
     494                 :          0 :                 nIndex = sOldLabel.getLength();
     495                 :          0 :             maButtonLabel = sOldLabel.copy( 0, nIndex );
     496                 :            :         }
     497                 :            : 
     498                 :          0 :         OUString sLabel = maButtonLabel;
     499                 :            :         // filter with options -> append ellipses on export button label
     500 [ #  # ][ #  # ]:          0 :         if ( CheckFilterOptionsCapability( getCurentSfxFilter() ) )
                 [ #  # ]
     501                 :          0 :             sLabel += OUString( "..."  );
     502                 :            : 
     503         [ #  # ]:          0 :         if ( sOldLabel != sLabel )
     504                 :            :         {
     505                 :            :             try
     506                 :            :             {
     507 [ #  # ][ #  # ]:          0 :                 xCtrlAccess->setLabel( CommonFilePickerElementIds::PUSHBUTTON_OK, sLabel );
     508                 :            :             }
     509         [ #  # ]:          0 :             catch( const IllegalArgumentException& )
     510                 :            :             {
     511                 :            :                 SAL_WARN( "sfx2.dialog", "FileDialogHelper_Impl::updateExportButton: caught an exception!" );
     512                 :            :             }
     513                 :          0 :         }
     514                 :          0 :     }
     515         [ #  # ]:          0 : }
     516                 :            : 
     517                 :            : // ------------------------------------------------------------------------
     518                 :          0 : void FileDialogHelper_Impl::updateSelectionBox()
     519                 :            : {
     520         [ #  # ]:          0 :     if ( !mbHasSelectionBox )
     521                 :          0 :         return;
     522                 :            : 
     523                 :            :     // Does the selection box exist?
     524                 :          0 :     sal_Bool bSelectionBoxFound = sal_False;
     525         [ #  # ]:          0 :     uno::Reference< XControlInformation > xCtrlInfo( mxFileDlg, UNO_QUERY );
     526         [ #  # ]:          0 :     if ( xCtrlInfo.is() )
     527                 :            :     {
     528 [ #  # ][ #  # ]:          0 :         Sequence< ::rtl::OUString > aCtrlList = xCtrlInfo->getSupportedControls();
     529                 :          0 :         sal_uInt32 nCount = aCtrlList.getLength();
     530         [ #  # ]:          0 :         for ( sal_uInt32 nCtrl = 0; nCtrl < nCount; ++nCtrl )
     531 [ #  # ][ #  # ]:          0 :             if ( aCtrlList[ nCtrl ] == "SelectionBox" )
     532                 :            :             {
     533                 :          0 :                 bSelectionBoxFound = sal_False;
     534                 :          0 :                 break;
     535         [ #  # ]:          0 :             }
     536                 :            :     }
     537                 :            : 
     538         [ #  # ]:          0 :     if ( bSelectionBoxFound )
     539                 :            :     {
     540         [ #  # ]:          0 :         const SfxFilter* pFilter = getCurentSfxFilter();
     541                 :            :         mbSelectionFltrEnabled = updateExtendedControl(
     542                 :            :             ExtendedFilePickerElementIds::CHECKBOX_SELECTION,
     543 [ #  # ][ #  # ]:          0 :             ( mbSelectionEnabled && pFilter && ( pFilter->GetFilterFlags() & SFX_FILTER_SUPPORTSSELECTION ) != 0 ) );
         [ #  # ][ #  # ]
     544         [ #  # ]:          0 :         uno::Reference< XFilePickerControlAccess > xCtrlAccess( mxFileDlg, UNO_QUERY );
     545 [ #  # ][ #  # ]:          0 :         xCtrlAccess->setValue( ExtendedFilePickerElementIds::CHECKBOX_SELECTION, 0, makeAny( (sal_Bool)mbSelection ) );
                 [ #  # ]
     546                 :          0 :     }
     547                 :            : }
     548                 :            : 
     549                 :            : // ------------------------------------------------------------------------
     550                 :          0 : void FileDialogHelper_Impl::enablePasswordBox( sal_Bool bInit )
     551                 :            : {
     552         [ #  # ]:          0 :     if ( ! mbHasPassword )
     553                 :          0 :         return;
     554                 :            : 
     555                 :          0 :     sal_Bool bWasEnabled = mbIsPwdEnabled;
     556                 :            : 
     557                 :          0 :     const SfxFilter* pCurrentFilter = getCurentSfxFilter();
     558                 :            :     mbIsPwdEnabled = updateExtendedControl(
     559                 :            :         ExtendedFilePickerElementIds::CHECKBOX_PASSWORD,
     560                 :          0 :         pCurrentFilter && ( pCurrentFilter->GetFilterFlags() & SFX_FILTER_ENCRYPTION )
     561   [ #  #  #  # ]:          0 :     );
     562                 :            : 
     563         [ #  # ]:          0 :     if( bInit )
     564                 :            :     {
     565                 :            :         // in case of inintialization previous state is not interesting
     566         [ #  # ]:          0 :         if( mbIsPwdEnabled )
     567                 :            :         {
     568         [ #  # ]:          0 :             uno::Reference< XFilePickerControlAccess > xCtrlAccess( mxFileDlg, UNO_QUERY );
     569         [ #  # ]:          0 :             if( mbPwdCheckBoxState )
     570 [ #  # ][ #  # ]:          0 :                 xCtrlAccess->setValue( ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, 0, makeAny( sal_True ) );
                 [ #  # ]
     571                 :            :         }
     572                 :            :     }
     573 [ #  # ][ #  # ]:          0 :     else if( !bWasEnabled && mbIsPwdEnabled )
     574                 :            :     {
     575         [ #  # ]:          0 :         uno::Reference< XFilePickerControlAccess > xCtrlAccess( mxFileDlg, UNO_QUERY );
     576         [ #  # ]:          0 :         if( mbPwdCheckBoxState )
     577 [ #  # ][ #  # ]:          0 :             xCtrlAccess->setValue( ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, 0, makeAny( sal_True ) );
                 [ #  # ]
     578                 :            :     }
     579 [ #  # ][ #  # ]:          0 :     else if( bWasEnabled && !mbIsPwdEnabled )
     580                 :            :     {
     581                 :            :         // remember user settings until checkbox is enabled
     582         [ #  # ]:          0 :         uno::Reference< XFilePickerControlAccess > xCtrlAccess( mxFileDlg, UNO_QUERY );
     583 [ #  # ][ #  # ]:          0 :         Any aValue = xCtrlAccess->getValue( ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, 0 );
     584                 :          0 :         sal_Bool bPassWord = sal_False;
     585 [ #  # ][ #  # ]:          0 :         mbPwdCheckBoxState = ( aValue >>= bPassWord ) && bPassWord;
     586 [ #  # ][ #  # ]:          0 :         xCtrlAccess->setValue( ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, 0, makeAny( sal_False ) );
                 [ #  # ]
     587                 :            :     }
     588                 :            : }
     589                 :            : 
     590                 :            : // ------------------------------------------------------------------------
     591                 :          0 : void FileDialogHelper_Impl::updatePreviewState( sal_Bool _bUpdatePreviewWindow )
     592                 :            : {
     593         [ #  # ]:          0 :     if ( mbHasPreview )
     594                 :            :     {
     595         [ #  # ]:          0 :         uno::Reference< XFilePickerControlAccess > xCtrlAccess( mxFileDlg, UNO_QUERY );
     596                 :            : 
     597                 :            :         // check, whether or not we have to display a preview
     598         [ #  # ]:          0 :         if ( xCtrlAccess.is() )
     599                 :            :         {
     600                 :            :             try
     601                 :            :             {
     602 [ #  # ][ #  # ]:          0 :                 Any aValue = xCtrlAccess->getValue( ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, 0 );
     603                 :          0 :                 sal_Bool bShowPreview = sal_False;
     604                 :            : 
     605         [ #  # ]:          0 :                 if ( aValue >>= bShowPreview )
     606                 :            :                 {
     607                 :          0 :                     mbShowPreview = bShowPreview;
     608                 :            : 
     609                 :            :                     // setShowState has currently no effect for the
     610                 :            :                     // OpenOffice FilePicker (see svtools/source/filepicker/iodlg.cxx)
     611         [ #  # ]:          0 :                     uno::Reference< XFilePreview > xFilePreview( mxFileDlg, UNO_QUERY );
     612         [ #  # ]:          0 :                     if ( xFilePreview.is() )
     613 [ #  # ][ #  # ]:          0 :                         xFilePreview->setShowState( mbShowPreview );
     614                 :            : 
     615         [ #  # ]:          0 :                     if ( _bUpdatePreviewWindow )
     616         [ #  # ]:          0 :                         TimeOutHdl_Impl( NULL );
     617         [ #  # ]:          0 :                 }
     618                 :            :             }
     619         [ #  # ]:          0 :             catch( const Exception& )
     620                 :            :             {
     621                 :            :                 SAL_WARN( "sfx2.dialog", "FileDialogHelper_Impl::updatePreviewState: caught an exception!" );
     622                 :            :             }
     623                 :          0 :         }
     624                 :            :     }
     625                 :          0 : }
     626                 :            : 
     627                 :            : // ------------------------------------------------------------------------
     628                 :          0 : void FileDialogHelper_Impl::updateVersions()
     629                 :            : {
     630         [ #  # ]:          0 :     Sequence < OUString > aEntries;
     631 [ #  # ][ #  # ]:          0 :     Sequence < OUString > aPathSeq = mxFileDlg->getFiles();
     632                 :            : 
     633         [ #  # ]:          0 :     if ( aPathSeq.getLength() == 1 )
     634                 :            :     {
     635 [ #  # ][ #  # ]:          0 :         INetURLObject aObj( aPathSeq[0] );
     636                 :            : 
     637 [ #  # ][ #  # ]:          0 :         if ( ( aObj.GetProtocol() == INET_PROT_FILE ) &&
                 [ #  # ]
     638 [ #  # ][ #  # ]:          0 :             ( utl::UCBContentHelper::IsDocument( aObj.GetMainURL( INetURLObject::NO_DECODE ) ) ) )
         [ #  # ][ #  # ]
     639                 :            :         {
     640                 :            :             try
     641                 :            :             {
     642                 :            :                 uno::Reference< embed::XStorage > xStorage = ::comphelper::OStorageHelper::GetStorageFromURL(
     643                 :            :                                                                 aObj.GetMainURL( INetURLObject::NO_DECODE ),
     644 [ #  # ][ #  # ]:          0 :                                                                 embed::ElementModes::READ );
     645                 :            : 
     646                 :            :                 DBG_ASSERT( xStorage.is(), "The method must return the storage or throw an exception!" );
     647         [ #  # ]:          0 :                 if ( !xStorage.is() )
     648         [ #  # ]:          0 :                     throw uno::RuntimeException();
     649                 :            : 
     650         [ #  # ]:          0 :                 uno::Sequence < util::RevisionTag > xVersions = SfxMedium::GetVersionList( xStorage );
     651                 :            : 
     652         [ #  # ]:          0 :                 aEntries.realloc( xVersions.getLength() + 1 );
     653 [ #  # ][ #  # ]:          0 :                 aEntries[0] = SfxResId( STR_SFX_FILEDLG_ACTUALVERSION ).toString();
                 [ #  # ]
     654                 :            : 
     655         [ #  # ]:          0 :                 for ( sal_Int32 i=0; i<xVersions.getLength(); i++ )
     656 [ #  # ][ #  # ]:          0 :                     aEntries[ i + 1 ] = xVersions[i].Identifier;
         [ #  # ][ #  # ]
     657                 :            :             }
     658         [ #  # ]:          0 :             catch( const uno::Exception& )
     659                 :            :             {
     660                 :            :             }
     661 [ #  # ][ #  # ]:          0 :         }
     662                 :            :     }
     663                 :            : 
     664         [ #  # ]:          0 :     uno::Reference < XFilePickerControlAccess > xDlg( mxFileDlg, UNO_QUERY );
     665                 :          0 :     Any aValue;
     666                 :            : 
     667                 :            :     try
     668                 :            :     {
     669         [ #  # ]:          0 :         xDlg->setValue( ExtendedFilePickerElementIds::LISTBOX_VERSION,
     670         [ #  # ]:          0 :                         ControlActions::DELETE_ITEMS, aValue );
     671                 :            :     }
     672         [ #  # ]:          0 :     catch( const IllegalArgumentException& ){}
     673                 :            : 
     674                 :          0 :     sal_Int32 nCount = aEntries.getLength();
     675                 :            : 
     676         [ #  # ]:          0 :     if ( nCount )
     677                 :            :     {
     678                 :            :         try
     679                 :            :         {
     680         [ #  # ]:          0 :             aValue <<= aEntries;
     681         [ #  # ]:          0 :             xDlg->setValue( ExtendedFilePickerElementIds::LISTBOX_VERSION,
     682         [ #  # ]:          0 :                             ControlActions::ADD_ITEMS, aValue );
     683                 :            : 
     684                 :          0 :             Any aPos;
     685         [ #  # ]:          0 :             aPos <<= (sal_Int32) 0;
     686         [ #  # ]:          0 :             xDlg->setValue( ExtendedFilePickerElementIds::LISTBOX_VERSION,
     687 [ #  # ][ #  # ]:          0 :                             ControlActions::SET_SELECT_ITEM, aPos );
     688                 :            :         }
     689         [ #  # ]:          0 :         catch( const IllegalArgumentException& ){}
     690 [ #  # ][ #  # ]:          0 :     }
     691                 :          0 : }
     692                 :            : 
     693                 :            : // -----------------------------------------------------------------------
     694                 :          0 : IMPL_LINK_NOARG(FileDialogHelper_Impl, TimeOutHdl_Impl)
     695                 :            : {
     696         [ #  # ]:          0 :     if ( !mbHasPreview )
     697                 :          0 :         return 0;
     698                 :            : 
     699         [ #  # ]:          0 :     maGraphic.Clear();
     700                 :            : 
     701                 :          0 :     Any aAny;
     702         [ #  # ]:          0 :     uno::Reference < XFilePreview > xFilePicker( mxFileDlg, UNO_QUERY );
     703                 :            : 
     704         [ #  # ]:          0 :     if ( ! xFilePicker.is() )
     705                 :          0 :         return 0;
     706                 :            : 
     707 [ #  # ][ #  # ]:          0 :     Sequence < OUString > aPathSeq = mxFileDlg->getFiles();
     708                 :            : 
     709 [ #  # ][ #  # ]:          0 :     if ( mbShowPreview && ( aPathSeq.getLength() == 1 ) )
                 [ #  # ]
     710                 :            :     {
     711         [ #  # ]:          0 :         OUString    aURL = aPathSeq[0];
     712                 :            : 
     713 [ #  # ][ #  # ]:          0 :         if ( ERRCODE_NONE == getGraphic( aURL, maGraphic ) )
     714                 :            :         {
     715                 :            :             // changed the code slightly;
     716                 :            :             // before: the bitmap was scaled and
     717                 :            :             // surrounded a white frame
     718                 :            :             // now: the bitmap will only be scaled
     719                 :            :             // and the filepicker implementation
     720                 :            :             // is responsible for placing it at its
     721                 :            :             // proper position and painting a frame
     722                 :            : 
     723         [ #  # ]:          0 :             Bitmap aBmp = maGraphic.GetBitmap();
     724         [ #  # ]:          0 :             if ( !aBmp.IsEmpty() )
     725                 :            :             {
     726                 :            :                 // scale the bitmap to the correct size
     727 [ #  # ][ #  # ]:          0 :                 sal_Int32 nOutWidth  = xFilePicker->getAvailableWidth();
     728 [ #  # ][ #  # ]:          0 :                 sal_Int32 nOutHeight = xFilePicker->getAvailableHeight();
     729         [ #  # ]:          0 :                 sal_Int32 nBmpWidth  = aBmp.GetSizePixel().Width();
     730         [ #  # ]:          0 :                 sal_Int32 nBmpHeight = aBmp.GetSizePixel().Height();
     731                 :            : 
     732                 :          0 :                 double nXRatio = (double) nOutWidth / nBmpWidth;
     733                 :          0 :                 double nYRatio = (double) nOutHeight / nBmpHeight;
     734                 :            : 
     735         [ #  # ]:          0 :                 if ( nXRatio < nYRatio )
     736         [ #  # ]:          0 :                     aBmp.Scale( nXRatio, nXRatio );
     737                 :            :                 else
     738         [ #  # ]:          0 :                     aBmp.Scale( nYRatio, nYRatio );
     739                 :            : 
     740                 :            :                 // Convert to true color, to allow CopyPixel
     741         [ #  # ]:          0 :                 aBmp.Convert( BMP_CONVERSION_24BIT );
     742                 :            : 
     743                 :            :                 // and copy it into the Any
     744         [ #  # ]:          0 :                 SvMemoryStream aData;
     745                 :            : 
     746         [ #  # ]:          0 :                 aData << aBmp;
     747                 :            : 
     748                 :            :                 const Sequence < sal_Int8 > aBuffer(
     749         [ #  # ]:          0 :                     static_cast< const sal_Int8* >(aData.GetData()),
     750         [ #  # ]:          0 :                     aData.GetEndOfData() );
     751                 :            : 
     752 [ #  # ][ #  # ]:          0 :                 aAny <<= aBuffer;
                 [ #  # ]
     753         [ #  # ]:          0 :             }
     754                 :          0 :         }
     755                 :            :     }
     756                 :            : 
     757                 :            :     try
     758                 :            :     {
     759         [ #  # ]:          0 :         SolarMutexReleaser aReleaseForCallback;
     760                 :            :         // clear the preview window
     761 [ #  # ][ #  # ]:          0 :         xFilePicker->setImage( FilePreviewImageFormats::BITMAP, aAny );
         [ #  # ][ #  # ]
     762                 :            :     }
     763         [ #  # ]:          0 :     catch( const IllegalArgumentException& )
     764                 :            :     {
     765                 :            :     }
     766                 :            : 
     767         [ #  # ]:          0 :     return 0;
     768                 :            : }
     769                 :            : 
     770                 :            : // ------------------------------------------------------------------------
     771                 :          0 : ErrCode FileDialogHelper_Impl::getGraphic( const OUString& rURL,
     772                 :            :                                            Graphic& rGraphic ) const
     773                 :            : {
     774 [ #  # ][ #  # ]:          0 :     if ( utl::UCBContentHelper::IsFolder( rURL ) )
     775                 :          0 :         return ERRCODE_IO_NOTAFILE;
     776                 :            : 
     777         [ #  # ]:          0 :     if ( !mpGraphicFilter )
     778                 :          0 :         return ERRCODE_IO_NOTSUPPORTED;
     779                 :            : 
     780                 :            :     // select graphic filter from dialog filter selection
     781         [ #  # ]:          0 :     OUString aCurFilter( getFilter() );
     782                 :            : 
     783         [ #  # ]:          0 :     sal_uInt16 nFilter = !aCurFilter.isEmpty() && mpGraphicFilter->GetImportFormatCount()
     784 [ #  # ][ #  # ]:          0 :                     ? mpGraphicFilter->GetImportFormatNumber( aCurFilter )
         [ #  # ][ #  # ]
     785 [ #  # ][ #  # ]:          0 :                     : GRFILTER_FORMAT_DONTKNOW;
                 [ #  # ]
     786                 :            : 
     787         [ #  # ]:          0 :     INetURLObject aURLObj( rURL );
     788                 :            : 
     789 [ #  # ][ #  # ]:          0 :     if ( aURLObj.HasError() || INET_PROT_NOT_VALID == aURLObj.GetProtocol() )
                 [ #  # ]
     790                 :            :     {
     791                 :          0 :         aURLObj.SetSmartProtocol( INET_PROT_FILE );
     792         [ #  # ]:          0 :         aURLObj.SetSmartURL( rURL );
     793                 :            :     }
     794                 :            : 
     795                 :          0 :     ErrCode nRet = ERRCODE_NONE;
     796                 :            : 
     797                 :          0 :     sal_uInt32 nFilterImportFlags = GRFILTER_I_FLAGS_SET_LOGSIZE_FOR_JPEG;
     798                 :            :     // non-local?
     799         [ #  # ]:          0 :     if ( INET_PROT_FILE != aURLObj.GetProtocol() )
     800                 :            :     {
     801 [ #  # ][ #  # ]:          0 :         SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( rURL, STREAM_READ );
                 [ #  # ]
     802                 :            : 
     803         [ #  # ]:          0 :         if( pStream )
     804 [ #  # ][ #  # ]:          0 :             nRet = mpGraphicFilter->ImportGraphic( rGraphic, rURL, *pStream, nFilter, NULL, nFilterImportFlags );
                 [ #  # ]
     805                 :            :         else
     806         [ #  # ]:          0 :             nRet = mpGraphicFilter->ImportGraphic( rGraphic, aURLObj, nFilter, NULL, nFilterImportFlags );
     807 [ #  # ][ #  # ]:          0 :         delete pStream;
     808                 :            :     }
     809                 :            :     else
     810                 :            :     {
     811         [ #  # ]:          0 :         nRet = mpGraphicFilter->ImportGraphic( rGraphic, aURLObj, nFilter, NULL, nFilterImportFlags );
     812                 :            :     }
     813                 :            : 
     814         [ #  # ]:          0 :     return nRet;
     815                 :            : }
     816                 :            : 
     817                 :            : // ------------------------------------------------------------------------
     818                 :          0 : ErrCode FileDialogHelper_Impl::getGraphic( Graphic& rGraphic ) const
     819                 :            : {
     820                 :          0 :     ErrCode nRet = ERRCODE_NONE;
     821                 :            : 
     822         [ #  # ]:          0 :     if ( ! maGraphic )
     823                 :            :     {
     824                 :          0 :         OUString aPath;;
     825 [ #  # ][ #  # ]:          0 :         Sequence < OUString > aPathSeq = mxFileDlg->getFiles();
     826                 :            : 
     827         [ #  # ]:          0 :         if ( aPathSeq.getLength() == 1 )
     828                 :            :         {
     829         [ #  # ]:          0 :             aPath = aPathSeq[0];
     830                 :            :         }
     831                 :            : 
     832         [ #  # ]:          0 :         if ( !aPath.isEmpty() )
     833         [ #  # ]:          0 :             nRet = getGraphic( aPath, rGraphic );
     834                 :            :         else
     835         [ #  # ]:          0 :             nRet = ERRCODE_IO_GENERAL;
     836                 :            :     }
     837                 :            :     else
     838                 :          0 :         rGraphic = maGraphic;
     839                 :            : 
     840                 :          0 :     return nRet;
     841                 :            : }
     842                 :            : 
     843                 :            : // ------------------------------------------------------------------------
     844                 :          0 : static bool lcl_isSystemFilePicker( const uno::Reference< XFilePicker >& _rxFP )
     845                 :            : {
     846                 :            :     try
     847                 :            :     {
     848         [ #  # ]:          0 :         uno::Reference< XServiceInfo > xSI( _rxFP, UNO_QUERY );
     849         [ #  # ]:          0 :         if ( !xSI.is() )
     850                 :          0 :             return true;
     851 [ #  # ][ #  # ]:          0 :         return xSI->supportsService( DEFINE_CONST_OUSTRING( "com.sun.star.ui.dialogs.SystemFilePicker" ) );
         [ #  # ][ #  # ]
     852                 :            :     }
     853                 :          0 :     catch( const Exception& )
     854                 :            :     {
     855                 :            :     }
     856                 :          0 :     return false;
     857                 :            : }
     858                 :            : 
     859                 :            : enum open_or_save_t {OPEN, SAVE, UNDEFINED};
     860                 :          0 : static open_or_save_t lcl_OpenOrSave(sal_Int16 const nDialogType)
     861                 :            : {
     862      [ #  #  # ]:          0 :     switch (nDialogType)
     863                 :            :     {
     864                 :            :         case FILEOPEN_SIMPLE:
     865                 :            :         case FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE:
     866                 :            :         case FILEOPEN_PLAY:
     867                 :            :         case FILEOPEN_READONLY_VERSION:
     868                 :            :         case FILEOPEN_LINK_PREVIEW:
     869                 :          0 :             return OPEN;
     870                 :            :         case FILESAVE_SIMPLE:
     871                 :            :         case FILESAVE_AUTOEXTENSION_PASSWORD:
     872                 :            :         case FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS:
     873                 :            :         case FILESAVE_AUTOEXTENSION_SELECTION:
     874                 :            :         case FILESAVE_AUTOEXTENSION_TEMPLATE:
     875                 :            :         case FILESAVE_AUTOEXTENSION:
     876                 :          0 :             return SAVE;
     877                 :            :         default:
     878                 :            :             assert(false); // invalid dialog type
     879                 :            :     }
     880                 :          0 :     return UNDEFINED;
     881                 :            : }
     882                 :            : 
     883                 :            : // ------------------------------------------------------------------------
     884                 :            : // -----------      FileDialogHelper_Impl       ---------------------------
     885                 :            : // ------------------------------------------------------------------------
     886                 :            : 
     887                 :          0 : FileDialogHelper_Impl::FileDialogHelper_Impl(
     888                 :            :     FileDialogHelper* _pAntiImpl,
     889                 :            :     sal_Int16 nDialogType,
     890                 :            :     sal_Int64 nFlags,
     891                 :            :     sal_Int16 nDialog,
     892                 :            :     Window* _pPreferredParentWindow,
     893                 :            :     const String& sStandardDir,
     894                 :            :     const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList
     895                 :            :     )
     896                 :            :     :m_nDialogType          ( nDialogType )
     897 [ #  # ][ #  # ]:          0 :     ,meContext              ( FileDialogHelper::UNKNOWN_CONTEXT )
         [ #  # ][ #  # ]
     898                 :            : {
     899                 :          0 :     const char* pServiceName=0;
     900         [ #  # ]:          0 :     if ( nDialog == SFX2_IMPL_DIALOG_SYSTEM )
     901                 :          0 :         pServiceName = FILE_OPEN_SERVICE_NAME_OOO;
     902         [ #  # ]:          0 :     else if ( nDialog == SFX2_IMPL_DIALOG_OOO )
     903                 :          0 :         pServiceName = FILE_OPEN_SERVICE_NAME_OOO;
     904                 :            :     else
     905                 :          0 :         pServiceName = FILE_OPEN_SERVICE_NAME;
     906                 :          0 :     OUString aService = ::rtl::OUString::createFromAscii( pServiceName );
     907                 :            : 
     908         [ #  # ]:          0 :     uno::Reference< XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
     909                 :            : 
     910                 :            :     // create the file open dialog
     911                 :            :     // the flags can be SFXWB_INSERT or SFXWB_MULTISELECTION
     912                 :            : 
     913                 :          0 :     mpPreferredParentWindow = _pPreferredParentWindow;
     914                 :          0 :     mpAntiImpl              = _pAntiImpl;
     915                 :          0 :     mnError                 = ERRCODE_NONE;
     916                 :          0 :     mbHasAutoExt            = sal_False;
     917                 :          0 :     mbHasPassword           = sal_False;
     918                 :          0 :     m_bHaveFilterOptions    = sal_False;
     919                 :          0 :     mbIsPwdEnabled          = sal_True;
     920                 :          0 :     mbHasVersions           = sal_False;
     921                 :          0 :     mbHasPreview            = sal_False;
     922                 :          0 :     mbShowPreview           = sal_False;
     923                 :          0 :     mbAddGraphicFilter      = SFXWB_GRAPHIC == (nFlags & SFXWB_GRAPHIC);
     924                 :          0 :     mbDeleteMatcher         = sal_False;
     925                 :          0 :     mbInsert                = SFXWB_INSERT == ( nFlags & SFXWB_INSERT );
     926                 :          0 :     mbExport                = SFXWB_EXPORT == ( nFlags & SFXWB_EXPORT );
     927                 :          0 :     mbIsSaveDlg             = sal_False;
     928                 :          0 :     mbPwdCheckBoxState      = sal_False;
     929                 :          0 :     mbSelection             = sal_False;
     930                 :          0 :     mbSelectionEnabled      = sal_True;
     931                 :          0 :     mbHasSelectionBox       = sal_False;
     932                 :          0 :     mbSelectionFltrEnabled  = sal_False;
     933                 :            : 
     934                 :            :     // default settings
     935                 :          0 :     m_nDontFlags = SFX_FILTER_INTERNAL | SFX_FILTER_NOTINFILEDLG | SFX_FILTER_NOTINSTALLED;
     936         [ #  # ]:          0 :     if (OPEN == lcl_OpenOrSave(m_nDialogType))
     937                 :          0 :         m_nMustFlags = SFX_FILTER_IMPORT;
     938                 :            :     else
     939                 :          0 :         m_nMustFlags = SFX_FILTER_EXPORT;
     940                 :            : 
     941                 :            : 
     942                 :          0 :     mpMatcher = NULL;
     943                 :          0 :     mpGraphicFilter = NULL;
     944                 :          0 :     mnPostUserEventId = 0;
     945                 :            : 
     946                 :            :     // create the picker component
     947 [ #  # ][ #  # ]:          0 :     mxFileDlg = mxFileDlg.query( xFactory->createInstance( aService ) );
         [ #  # ][ #  # ]
     948         [ #  # ]:          0 :     mbSystemPicker = lcl_isSystemFilePicker( mxFileDlg );
     949                 :            : 
     950         [ #  # ]:          0 :     uno::Reference< XFilePickerNotifier > xNotifier( mxFileDlg, UNO_QUERY );
     951         [ #  # ]:          0 :     uno::Reference< XInitialization > xInit( mxFileDlg, UNO_QUERY );
     952                 :            : 
     953 [ #  # ][ #  # ]:          0 :     if ( ! mxFileDlg.is() || ! xNotifier.is() )
                 [ #  # ]
     954                 :            :     {
     955                 :          0 :         mnError = ERRCODE_ABORT;
     956                 :          0 :         return;
     957                 :            :     }
     958                 :            : 
     959                 :            : 
     960         [ #  # ]:          0 :     if ( xInit.is() )
     961                 :            :     {
     962                 :          0 :         sal_Int16 nTemplateDescription = TemplateDescription::FILEOPEN_SIMPLE;
     963                 :            : 
     964   [ #  #  #  #  :          0 :         switch ( m_nDialogType )
          #  #  #  #  #  
                #  #  # ]
     965                 :            :         {
     966                 :            :             case FILEOPEN_SIMPLE:
     967                 :          0 :                 nTemplateDescription = TemplateDescription::FILEOPEN_SIMPLE;
     968                 :          0 :                 break;
     969                 :            : 
     970                 :            :             case FILESAVE_SIMPLE:
     971                 :          0 :                 nTemplateDescription = TemplateDescription::FILESAVE_SIMPLE;
     972                 :          0 :                 mbIsSaveDlg = sal_True;
     973                 :          0 :                 break;
     974                 :            : 
     975                 :            :             case FILESAVE_AUTOEXTENSION_PASSWORD:
     976                 :          0 :                 nTemplateDescription = TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD;
     977                 :          0 :                 mbHasPassword = sal_True;
     978                 :          0 :                 mbHasAutoExt = sal_True;
     979                 :          0 :                 mbIsSaveDlg = sal_True;
     980                 :          0 :                 break;
     981                 :            : 
     982                 :            :             case FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS:
     983                 :          0 :                 nTemplateDescription = TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS;
     984                 :          0 :                 mbHasPassword = sal_True;
     985                 :            : 
     986                 :          0 :                 m_bHaveFilterOptions = sal_True;
     987         [ #  # ]:          0 :                 if( xFactory.is() )
     988                 :            :                 {
     989                 :            :                     mxFilterCFG = uno::Reference< XNameAccess >(
     990         [ #  # ]:          0 :                         xFactory->createInstance( DEFINE_CONST_OUSTRING( "com.sun.star.document.FilterFactory" ) ),
     991 [ #  # ][ #  # ]:          0 :                         UNO_QUERY );
         [ #  # ][ #  # ]
     992                 :            :                 }
     993                 :            : 
     994                 :          0 :                 mbHasAutoExt = sal_True;
     995                 :          0 :                 mbIsSaveDlg = sal_True;
     996                 :          0 :                 break;
     997                 :            : 
     998                 :            :             case FILESAVE_AUTOEXTENSION_SELECTION:
     999                 :          0 :                 nTemplateDescription = TemplateDescription::FILESAVE_AUTOEXTENSION_SELECTION;
    1000                 :          0 :                 mbHasAutoExt = sal_True;
    1001                 :          0 :                 mbIsSaveDlg = sal_True;
    1002                 :          0 :                 mbHasSelectionBox = sal_True;
    1003 [ #  # ][ #  # ]:          0 :                 if ( mbExport && !mxFilterCFG.is() && xFactory.is() )
         [ #  # ][ #  # ]
    1004                 :            :                 {
    1005                 :            :                     mxFilterCFG = uno::Reference< XNameAccess >(
    1006         [ #  # ]:          0 :                         xFactory->createInstance( DEFINE_CONST_OUSTRING( "com.sun.star.document.FilterFactory" ) ),
    1007 [ #  # ][ #  # ]:          0 :                         UNO_QUERY );
         [ #  # ][ #  # ]
    1008                 :            :                 }
    1009                 :          0 :                 break;
    1010                 :            : 
    1011                 :            :             case FILESAVE_AUTOEXTENSION_TEMPLATE:
    1012                 :          0 :                 nTemplateDescription = TemplateDescription::FILESAVE_AUTOEXTENSION_TEMPLATE;
    1013                 :          0 :                 mbHasAutoExt = sal_True;
    1014                 :          0 :                 mbIsSaveDlg = sal_True;
    1015                 :          0 :                 break;
    1016                 :            : 
    1017                 :            :             case FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE:
    1018                 :          0 :                 nTemplateDescription = TemplateDescription::FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE;
    1019                 :          0 :                 mbHasPreview = sal_True;
    1020                 :            : 
    1021                 :            :                 // aPreviewTimer
    1022         [ #  # ]:          0 :                 maPreViewTimer.SetTimeout( 500 );
    1023         [ #  # ]:          0 :                 maPreViewTimer.SetTimeoutHdl( LINK( this, FileDialogHelper_Impl, TimeOutHdl_Impl ) );
    1024                 :          0 :                 break;
    1025                 :            : 
    1026                 :            :             case FILEOPEN_PLAY:
    1027                 :          0 :                 nTemplateDescription = TemplateDescription::FILEOPEN_PLAY;
    1028                 :          0 :                 break;
    1029                 :            : 
    1030                 :            :             case FILEOPEN_READONLY_VERSION:
    1031                 :          0 :                 nTemplateDescription = TemplateDescription::FILEOPEN_READONLY_VERSION;
    1032                 :          0 :                 mbHasVersions = sal_True;
    1033                 :          0 :                 break;
    1034                 :            : 
    1035                 :            :             case FILEOPEN_LINK_PREVIEW:
    1036                 :          0 :                 nTemplateDescription = TemplateDescription::FILEOPEN_LINK_PREVIEW;
    1037                 :          0 :                 mbHasPreview = sal_True;
    1038                 :            :                 // aPreviewTimer
    1039         [ #  # ]:          0 :                 maPreViewTimer.SetTimeout( 500 );
    1040         [ #  # ]:          0 :                 maPreViewTimer.SetTimeoutHdl( LINK( this, FileDialogHelper_Impl, TimeOutHdl_Impl ) );
    1041                 :          0 :                 break;
    1042                 :            : 
    1043                 :            :             case FILESAVE_AUTOEXTENSION:
    1044                 :          0 :                 nTemplateDescription = TemplateDescription::FILESAVE_AUTOEXTENSION;
    1045                 :          0 :                 mbHasAutoExt = sal_True;
    1046                 :          0 :                 mbIsSaveDlg = sal_True;
    1047                 :          0 :                 break;
    1048                 :            : 
    1049                 :            :             default:
    1050                 :            :                 SAL_WARN( "sfx2.dialog", "FileDialogHelper::ctor with unknown type" );
    1051                 :          0 :                 break;
    1052                 :            :         }
    1053                 :            : 
    1054 [ #  # ][ #  # ]:          0 :         Sequence < Any > aInitArguments( !mpPreferredParentWindow ? 3 : 4 );
    1055                 :            : 
    1056                 :            :         // This is a hack. We currently know that the internal file picker implementation
    1057                 :            :         // supports the extended arguments as specified below.
    1058                 :            :         // TODO:
    1059                 :            :         // a) adjust the service description so that it includes the TemplateDescription and ParentWindow args
    1060                 :            :         // b) adjust the implementation of the system file picker to that it recognizes it
    1061         [ #  # ]:          0 :         if ( mbSystemPicker )
    1062                 :            :         {
    1063 [ #  # ][ #  # ]:          0 :             aInitArguments[0] <<= nTemplateDescription;
    1064                 :            :         }
    1065                 :            :         else
    1066                 :            :         {
    1067         [ #  # ]:          0 :             aInitArguments[0] <<= NamedValue(
    1068                 :            :                                     ::rtl::OUString( "TemplateDescription"  ),
    1069                 :            :                                     makeAny( nTemplateDescription )
    1070 [ #  # ][ #  # ]:          0 :                                 );
    1071                 :            : 
    1072         [ #  # ]:          0 :             ::rtl::OUString sStandardDirTemp = ::rtl::OUString( sStandardDir );
    1073                 :            : 
    1074         [ #  # ]:          0 :             aInitArguments[1] <<= NamedValue(
    1075                 :            :                                     ::rtl::OUString( "StandardDir"  ),
    1076                 :            :                                     makeAny( sStandardDirTemp )
    1077 [ #  # ][ #  # ]:          0 :                                 );
    1078                 :            : 
    1079         [ #  # ]:          0 :             aInitArguments[2] <<= NamedValue(
    1080                 :            :                                     ::rtl::OUString( "BlackList"  ),
    1081                 :            :                                     makeAny( rBlackList )
    1082 [ #  # ][ #  # ]:          0 :                                 );
    1083                 :            : 
    1084                 :            : 
    1085         [ #  # ]:          0 :             if ( mpPreferredParentWindow )
    1086         [ #  # ]:          0 :                 aInitArguments[3] <<= NamedValue(
    1087                 :            :                                         ::rtl::OUString( "ParentWindow"  ),
    1088                 :            :                                         makeAny( VCLUnoHelper::GetInterface( mpPreferredParentWindow ) )
    1089 [ #  # ][ #  # ]:          0 :                                     );
         [ #  # ][ #  # ]
    1090                 :            :         }
    1091                 :            : 
    1092                 :            :         try
    1093                 :            :         {
    1094 [ #  # ][ #  # ]:          0 :             xInit->initialize( aInitArguments );
    1095                 :            :         }
    1096         [ #  # ]:          0 :         catch( const Exception& )
    1097                 :            :         {
    1098                 :            :             OSL_FAIL( "FileDialogHelper_Impl::FileDialogHelper_Impl: could not initialize the picker!" );
    1099         [ #  # ]:          0 :         }
    1100                 :            :     }
    1101                 :            : 
    1102                 :            : 
    1103                 :            :     // set multiselection mode
    1104         [ #  # ]:          0 :     if ( nFlags & SFXWB_MULTISELECTION )
    1105 [ #  # ][ #  # ]:          0 :         mxFileDlg->setMultiSelectionMode( sal_True );
    1106                 :            : 
    1107         [ #  # ]:          0 :     if (mbAddGraphicFilter) // generate graphic filter only on demand
    1108                 :            :     {
    1109         [ #  # ]:          0 :         addGraphicFilter();
    1110                 :            :     }
    1111                 :            : 
    1112                 :            :     // Export dialog
    1113         [ #  # ]:          0 :     if ( mbExport )
    1114                 :            :     {
    1115 [ #  # ][ #  # ]:          0 :         mxFileDlg->setTitle( SfxResId( STR_SFX_EXPLORERFILE_EXPORT ).toString() );
         [ #  # ][ #  # ]
    1116                 :            :         try {
    1117         [ #  # ]:          0 :                 com::sun::star::uno::Reference < XFilePickerControlAccess > xCtrlAccess( mxFileDlg, UNO_QUERY_THROW );
    1118 [ #  # ][ #  # ]:          0 :                 xCtrlAccess->enableControl( ExtendedFilePickerElementIds::LISTBOX_FILTER_SELECTOR, sal_True );
                 [ #  # ]
    1119                 :            :         }
    1120         [ #  # ]:          0 :         catch( const Exception & ) { }
    1121                 :            :     }
    1122                 :            : 
    1123                 :            :     // the "insert file" dialog needs another title
    1124         [ #  # ]:          0 :     if ( mbInsert )
    1125                 :            :     {
    1126 [ #  # ][ #  # ]:          0 :         mxFileDlg->setTitle( SfxResId( STR_SFX_EXPLORERFILE_INSERT ).toString() );
         [ #  # ][ #  # ]
    1127         [ #  # ]:          0 :         uno::Reference < XFilePickerControlAccess > xExtDlg( mxFileDlg, UNO_QUERY );
    1128         [ #  # ]:          0 :         if ( xExtDlg.is() )
    1129                 :            :         {
    1130                 :            :             try
    1131                 :            :             {
    1132         [ #  # ]:          0 :                 xExtDlg->setLabel( CommonFilePickerElementIds::PUSHBUTTON_OK,
    1133 [ #  # ][ #  # ]:          0 :                                    SfxResId( STR_SFX_EXPLORERFILE_BUTTONINSERT ).toString() );
         [ #  # ][ #  # ]
    1134                 :            :             }
    1135         [ #  # ]:          0 :             catch( const IllegalArgumentException& ){}
    1136                 :          0 :         }
    1137                 :            :     }
    1138                 :            : 
    1139                 :            :     // add the event listener
    1140 [ #  # ][ #  # ]:          0 :     xNotifier->addFilePickerListener( this );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1141                 :            : }
    1142                 :            : 
    1143                 :            : // ------------------------------------------------------------------------
    1144 [ #  # ][ #  # ]:          0 : FileDialogHelper_Impl::~FileDialogHelper_Impl()
    1145                 :            : {
    1146                 :            :     // Remove user event if we haven't received it yet
    1147         [ #  # ]:          0 :     if ( mnPostUserEventId )
    1148         [ #  # ]:          0 :         Application::RemoveUserEvent( mnPostUserEventId );
    1149                 :          0 :     mnPostUserEventId = 0;
    1150                 :            : 
    1151 [ #  # ][ #  # ]:          0 :     delete mpGraphicFilter;
    1152                 :            : 
    1153         [ #  # ]:          0 :     if ( mbDeleteMatcher )
    1154 [ #  # ][ #  # ]:          0 :         delete mpMatcher;
    1155                 :            : 
    1156         [ #  # ]:          0 :     maPreViewTimer.SetTimeoutHdl( Link() );
    1157                 :            : 
    1158         [ #  # ]:          0 :     ::comphelper::disposeComponent( mxFileDlg );
    1159         [ #  # ]:          0 : }
    1160                 :            : 
    1161                 :            : #define nMagic -1
    1162                 :            : 
    1163 [ #  # ][ #  # ]:          0 : class PickerThread_Impl : public ::osl::Thread
    1164                 :            : {
    1165                 :            :     uno::Reference < XFilePicker > mxPicker;
    1166                 :            :     ::osl::Mutex            maMutex;
    1167                 :            :     virtual void SAL_CALL   run();
    1168                 :            :     sal_Int16               mnRet;
    1169                 :            : public:
    1170                 :            :                             PickerThread_Impl( const uno::Reference < XFilePicker >& rPicker )
    1171                 :            :                             : mxPicker( rPicker ), mnRet(nMagic) {}
    1172                 :            : 
    1173                 :            :     sal_Int16               GetReturnValue()
    1174                 :            :                             { ::osl::MutexGuard aGuard( maMutex ); return mnRet; }
    1175                 :            : 
    1176                 :          0 :     void                    SetReturnValue( sal_Int16 aRetValue )
    1177 [ #  # ][ #  # ]:          0 :                             { ::osl::MutexGuard aGuard( maMutex ); mnRet = aRetValue; }
    1178                 :            : };
    1179                 :            : 
    1180                 :          0 : void SAL_CALL PickerThread_Impl::run()
    1181                 :            : {
    1182                 :            :     try
    1183                 :            :     {
    1184 [ #  # ][ #  # ]:          0 :         sal_Int16 n = mxPicker->execute();
    1185         [ #  # ]:          0 :         SetReturnValue( n );
    1186                 :            :     }
    1187         [ #  # ]:          0 :     catch( const RuntimeException& )
    1188                 :            :     {
    1189         [ #  # ]:          0 :         SetReturnValue( ExecutableDialogResults::CANCEL );
    1190                 :            :         SAL_WARN( "sfx2.dialog", "RuntimeException caught" );
    1191                 :            :     }
    1192                 :          0 : }
    1193                 :            : 
    1194                 :            : // ------------------------------------------------------------------------
    1195                 :          0 : void FileDialogHelper_Impl::setControlHelpIds( const sal_Int16* _pControlId, const char** _pHelpId )
    1196                 :            : {
    1197                 :            :     DBG_ASSERT( _pControlId && _pHelpId, "FileDialogHelper_Impl::setControlHelpIds: invalid array pointers!" );
    1198 [ #  # ][ #  # ]:          0 :     if ( !_pControlId || !_pHelpId )
    1199                 :          0 :         return;
    1200                 :            : 
    1201                 :            :     // forward these ids to the file picker
    1202                 :            :     try
    1203                 :            :     {
    1204                 :          0 :         const ::rtl::OUString sHelpIdPrefix( INET_HID_SCHEME  );
    1205                 :            :         // the ids for the single controls
    1206         [ #  # ]:          0 :         uno::Reference< XFilePickerControlAccess > xControlAccess( mxFileDlg, UNO_QUERY );
    1207         [ #  # ]:          0 :         if ( xControlAccess.is() )
    1208                 :            :         {
    1209         [ #  # ]:          0 :             while ( *_pControlId )
    1210                 :            :             {
    1211                 :            :                 DBG_ASSERT( INetURLObject( rtl::OStringToOUString( *_pHelpId, RTL_TEXTENCODING_UTF8 ) ).GetProtocol() == INET_PROT_NOT_VALID, "Wrong HelpId!" );
    1212                 :          0 :                 ::rtl::OUString sId( sHelpIdPrefix );
    1213         [ #  # ]:          0 :                 sId += ::rtl::OUString( *_pHelpId, strlen( *_pHelpId ), RTL_TEXTENCODING_UTF8 );
    1214 [ #  # ][ #  # ]:          0 :                 xControlAccess->setValue( *_pControlId, ControlActions::SET_HELP_URL, makeAny( sId ) );
                 [ #  # ]
    1215                 :            : 
    1216                 :          0 :                 ++_pControlId; ++_pHelpId;
    1217                 :          0 :             }
    1218         [ #  # ]:          0 :         }
    1219                 :            :     }
    1220                 :          0 :     catch( const Exception& )
    1221                 :            :     {
    1222                 :            :         OSL_FAIL( "FileDialogHelper_Impl::setControlHelpIds: caught an exception while setting the help ids!" );
    1223                 :            :     }
    1224                 :            : }
    1225                 :            : 
    1226                 :            : // ------------------------------------------------------------------------
    1227                 :          0 : IMPL_LINK( FileDialogHelper_Impl, InitControls, void*, NOTINTERESTEDIN )
    1228                 :            : {
    1229                 :            :     (void)NOTINTERESTEDIN;
    1230                 :          0 :     mnPostUserEventId = 0;
    1231                 :          0 :     enablePasswordBox( sal_True );
    1232                 :          0 :     updateFilterOptionsBox( );
    1233                 :          0 :     updateSelectionBox( );
    1234                 :            : 
    1235                 :          0 :     return 0L;
    1236                 :            : }
    1237                 :            : 
    1238                 :            : // ------------------------------------------------------------------------
    1239                 :          0 : void FileDialogHelper_Impl::preExecute()
    1240                 :            : {
    1241                 :          0 :     loadConfig( );
    1242                 :          0 :     setDefaultValues( );
    1243                 :          0 :     updatePreviewState( sal_False );
    1244                 :            : 
    1245                 :          0 :     implInitializeFileName( );
    1246                 :            : 
    1247                 :            : #if !(defined(MACOSX) && defined(QUARTZ)) && !defined(WNT)
    1248                 :            :     // allow for dialog implementations which need to be executed before they return valid values for
    1249                 :            :     // current filter and such
    1250                 :            : 
    1251                 :            :     // On Vista (at least SP1) it's the same as on MacOSX, the modal dialog won't let message pass
    1252                 :            :     // through before it returns from execution
    1253         [ #  # ]:          0 :     mnPostUserEventId = Application::PostUserEvent( LINK( this, FileDialogHelper_Impl, InitControls ) );
    1254                 :            : #else
    1255                 :            :     // However, the Mac OS X implementation's pickers run modally in execute and so the event doesn't
    1256                 :            :     // get through in time... so we call the methods directly
    1257                 :            :     enablePasswordBox( sal_True );
    1258                 :            :     updateFilterOptionsBox( );
    1259                 :            :     updateSelectionBox( );
    1260                 :            : #endif
    1261                 :          0 : }
    1262                 :            : 
    1263                 :            : // ------------------------------------------------------------------------
    1264                 :          0 : void FileDialogHelper_Impl::postExecute( sal_Int16 _nResult )
    1265                 :            : {
    1266         [ #  # ]:          0 :     if ( ExecutableDialogResults::CANCEL != _nResult )
    1267                 :          0 :         saveConfig();
    1268                 :          0 : }
    1269                 :            : 
    1270                 :            : // ------------------------------------------------------------------------
    1271                 :          0 : void FileDialogHelper_Impl::implInitializeFileName( )
    1272                 :            : {
    1273         [ #  # ]:          0 :     if ( !maFileName.isEmpty() )
    1274                 :            :     {
    1275         [ #  # ]:          0 :         INetURLObject aObj( maPath );
    1276         [ #  # ]:          0 :         aObj.Append( maFileName );
    1277                 :            : 
    1278                 :            :         // in case we're operating as save dialog, and "auto extension" is checked,
    1279                 :            :         // cut the extension from the name
    1280 [ #  # ][ #  # ]:          0 :         if ( mbIsSaveDlg && mbHasAutoExt )
    1281                 :            :         {
    1282                 :            :             try
    1283                 :            :             {
    1284                 :          0 :                 sal_Bool bAutoExtChecked = sal_False;
    1285                 :            : 
    1286         [ #  # ]:          0 :                 uno::Reference < XFilePickerControlAccess > xControlAccess( mxFileDlg, UNO_QUERY );
    1287   [ #  #  #  # ]:          0 :                 if  (   xControlAccess.is()
                 [ #  # ]
    1288         [ #  # ]:          0 :                     &&  (   xControlAccess->getValue( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0 )
    1289 [ #  # ][ #  # ]:          0 :                         >>= bAutoExtChecked
                 [ #  # ]
    1290                 :            :                         )
    1291                 :            :                     )
    1292                 :            :                 {
    1293         [ #  # ]:          0 :                     if ( bAutoExtChecked )
    1294                 :            :                     {   // cut the extension
    1295         [ #  # ]:          0 :                         aObj.removeExtension( );
    1296 [ #  # ][ #  # ]:          0 :                         mxFileDlg->setDefaultName( aObj.GetName( INetURLObject::DECODE_WITH_CHARSET ) );
                 [ #  # ]
    1297                 :            :                     }
    1298         [ #  # ]:          0 :                 }
    1299                 :            :             }
    1300         [ #  # ]:          0 :             catch( const Exception& )
    1301                 :            :             {
    1302                 :            :                 OSL_FAIL( "FileDialogHelper_Impl::implInitializeFileName: could not ask for the auto-extension current-value!" );
    1303                 :            :             }
    1304         [ #  # ]:          0 :         }
    1305                 :            :     }
    1306                 :          0 : }
    1307                 :            : 
    1308                 :            : // ------------------------------------------------------------------------
    1309                 :          0 : sal_Int16 FileDialogHelper_Impl::implDoExecute()
    1310                 :            : {
    1311                 :          0 :     preExecute();
    1312                 :            : 
    1313                 :          0 :     sal_Int16 nRet = ExecutableDialogResults::CANCEL;
    1314                 :            : 
    1315                 :            : //On MacOSX the native file picker has to run in the primordial thread because of drawing issues
    1316                 :            : //On Linux the native gtk file picker, when backed by gnome-vfs2, needs to be run in the same
    1317                 :            : //primordial thread as the ucb gnome-vfs2 provider was initialized in.
    1318                 :            : 
    1319                 :            :     {
    1320                 :            :         try
    1321                 :            :         {
    1322                 :            : #ifdef WNT
    1323                 :            :             if ( mbSystemPicker )
    1324                 :            :             {
    1325                 :            :                 SolarMutexReleaser aSolarMutex;
    1326                 :            :                 nRet = mxFileDlg->execute();
    1327                 :            :             }
    1328                 :            :             else
    1329                 :            : #endif
    1330 [ #  # ][ #  # ]:          0 :             nRet = mxFileDlg->execute();
    1331                 :            :         }
    1332                 :          0 :         catch( const Exception& )
    1333                 :            :         {
    1334                 :            :             SAL_WARN( "sfx2.dialog", "FileDialogHelper_Impl::implDoExecute: caught an exception!" );
    1335                 :            :         }
    1336                 :            :     }
    1337                 :            : 
    1338                 :          0 :     postExecute( nRet );
    1339                 :            : 
    1340         [ #  # ]:          0 :     return nRet;
    1341                 :            : }
    1342                 :            : 
    1343                 :            : // ------------------------------------------------------------------------
    1344                 :          0 : void FileDialogHelper_Impl::implStartExecute()
    1345                 :            : {
    1346                 :            :     DBG_ASSERT( mxFileDlg.is(), "invalid file dialog" );
    1347                 :            : 
    1348                 :          0 :     preExecute();
    1349                 :            : 
    1350         [ #  # ]:          0 :     if ( mbSystemPicker )
    1351                 :            :     {
    1352                 :            :     }
    1353                 :            :     else
    1354                 :            :     {
    1355                 :            :         try
    1356                 :            :         {
    1357         [ #  # ]:          0 :             uno::Reference< XAsynchronousExecutableDialog > xAsyncDlg( mxFileDlg, UNO_QUERY );
    1358         [ #  # ]:          0 :             if ( xAsyncDlg.is() )
    1359 [ #  # ][ #  # ]:          0 :                 xAsyncDlg->startExecuteModal( this );
         [ #  # ][ #  # ]
    1360                 :            :         }
    1361                 :          0 :         catch( const Exception& )
    1362                 :            :         {
    1363                 :            :             SAL_WARN( "sfx2.dialog", "FileDialogHelper_Impl::implDoExecute: caught an exception!" );
    1364                 :            :         }
    1365                 :            :     }
    1366                 :          0 : }
    1367                 :            : 
    1368                 :            : // ------------------------------------------------------------------------
    1369                 :          0 : void lcl_saveLastURLs(std::vector<rtl::OUString>& rpURLList,
    1370                 :            :                       ::comphelper::SequenceAsVector< ::rtl::OUString >& lLastURLs )
    1371                 :            : {
    1372                 :          0 :     lLastURLs.clear();
    1373 [ #  # ][ #  # ]:          0 :     for(std::vector<rtl::OUString>::iterator i = rpURLList.begin(); i != rpURLList.end(); ++i)
    1374         [ #  # ]:          0 :         lLastURLs.push_back(*i);
    1375                 :          0 : }
    1376                 :            : 
    1377                 :            : // ------------------------------------------------------------------------
    1378                 :          0 : void FileDialogHelper_Impl::implGetAndCacheFiles(const uno::Reference< XInterface >& xPicker, std::vector<rtl::OUString>& rpURLList, const SfxFilter* pFilter)
    1379                 :            : {
    1380                 :          0 :     rpURLList.clear();
    1381                 :            : 
    1382                 :          0 :     rtl::OUString sExtension;
    1383         [ #  # ]:          0 :     if (pFilter)
    1384                 :            :     {
    1385 [ #  # ][ #  # ]:          0 :         sExtension = pFilter->GetDefaultExtension ();
                 [ #  # ]
    1386                 :          0 :         sExtension = comphelper::string::remove(sExtension, '*');
    1387                 :          0 :         sExtension = comphelper::string::remove(sExtension, '.');
    1388                 :            :     }
    1389                 :            : 
    1390                 :            :     // a) the new way (optional!)
    1391         [ #  # ]:          0 :     uno::Reference< XFilePicker2 > xPickNew(xPicker, UNO_QUERY);
    1392         [ #  # ]:          0 :     if (xPickNew.is())
    1393                 :            :     {
    1394 [ #  # ][ #  # ]:          0 :         Sequence< OUString > lFiles    = xPickNew->getSelectedFiles();
    1395                 :          0 :         ::sal_Int32          nFiles    = lFiles.getLength();
    1396         [ #  # ]:          0 :         for(sal_Int32 i = 0; i < nFiles; ++i)
    1397 [ #  # ][ #  # ]:          0 :             rpURLList.push_back(lFiles[i]);
                 [ #  # ]
    1398                 :            :     }
    1399                 :            : 
    1400                 :            :     // b) the olde way ... non optional.
    1401                 :            :     else
    1402                 :            :     {
    1403         [ #  # ]:          0 :         uno::Reference< XFilePicker > xPickOld(xPicker, UNO_QUERY_THROW);
    1404 [ #  # ][ #  # ]:          0 :         Sequence< OUString > lFiles = xPickOld->getFiles();
    1405                 :          0 :         ::sal_Int32          nFiles = lFiles.getLength();
    1406         [ #  # ]:          0 :         if ( nFiles == 1 )
    1407                 :            :         {
    1408 [ #  # ][ #  # ]:          0 :             rpURLList.push_back(lFiles[0]);
    1409                 :            :         }
    1410         [ #  # ]:          0 :         else if ( nFiles > 1 )
    1411                 :            :         {
    1412 [ #  # ][ #  # ]:          0 :             INetURLObject aPath( lFiles[0] );
    1413         [ #  # ]:          0 :             aPath.setFinalSlash();
    1414                 :            : 
    1415         [ #  # ]:          0 :             for (::sal_Int32 i = 1; i < nFiles; i++)
    1416                 :            :             {
    1417         [ #  # ]:          0 :                 if (i == 1)
    1418 [ #  # ][ #  # ]:          0 :                     aPath.Append( lFiles[i] );
    1419                 :            :                 else
    1420 [ #  # ][ #  # ]:          0 :                     aPath.setName( lFiles[i] );
    1421                 :            : 
    1422 [ #  # ][ #  # ]:          0 :                 rpURLList.push_back(aPath.GetMainURL(INetURLObject::NO_DECODE));
    1423         [ #  # ]:          0 :             }
    1424         [ #  # ]:          0 :         }
    1425                 :            :     }
    1426                 :            : 
    1427         [ #  # ]:          0 :     lcl_saveLastURLs(rpURLList, mlLastURLs);
    1428                 :          0 : }
    1429                 :            : 
    1430                 :            : // ------------------------------------------------------------------------
    1431                 :          0 : ErrCode FileDialogHelper_Impl::execute( std::vector<rtl::OUString>& rpURLList,
    1432                 :            :                                         SfxItemSet *&   rpSet,
    1433                 :            :                                         String&         rFilter )
    1434                 :            : {
    1435                 :            :     // rFilter is a pure output parameter, it shouldn't be used for anything else
    1436                 :            :     // changing this would surely break code
    1437                 :            :     // rpSet is in/out parameter, usually just a media-descriptor that can be changed by dialog
    1438                 :            : 
    1439         [ #  # ]:          0 :     uno::Reference< XFilePickerControlAccess > xCtrlAccess( mxFileDlg, UNO_QUERY );
    1440                 :            : 
    1441                 :            :     // retrieves parameters from rpSet
    1442                 :            :     // for now only Password is used
    1443         [ #  # ]:          0 :     if ( rpSet )
    1444                 :            :     {
    1445                 :            :         // check password checkbox if the document had password before
    1446         [ #  # ]:          0 :         if( mbHasPassword )
    1447                 :            :         {
    1448 [ #  # ][ #  # ]:          0 :             SFX_ITEMSET_ARG( rpSet, pPassItem, SfxBoolItem, SID_PASSWORDINTERACTION, sal_False );
    1449 [ #  # ][ #  # ]:          0 :             mbPwdCheckBoxState = ( pPassItem != NULL && pPassItem->GetValue() );
    1450                 :            : 
    1451                 :            :             // in case the document has password to modify, the dialog should be shown
    1452 [ #  # ][ #  # ]:          0 :             SFX_ITEMSET_ARG( rpSet, pPassToModifyItem, SfxUnoAnyItem, SID_MODIFYPASSWORDINFO, sal_False );
    1453 [ #  # ][ #  # ]:          0 :             mbPwdCheckBoxState |= ( pPassToModifyItem && pPassToModifyItem->GetValue().hasValue() );
                 [ #  # ]
    1454                 :            :         }
    1455                 :            : 
    1456 [ #  # ][ #  # ]:          0 :         SFX_ITEMSET_ARG( rpSet, pSelectItem, SfxBoolItem, SID_SELECTION, sal_False );
    1457         [ #  # ]:          0 :         if ( pSelectItem )
    1458                 :          0 :             mbSelection = pSelectItem->GetValue();
    1459                 :            :         else
    1460                 :          0 :             mbSelectionEnabled = sal_False;
    1461                 :            : 
    1462                 :            :         // the password will be set in case user decide so
    1463         [ #  # ]:          0 :         rpSet->ClearItem( SID_PASSWORDINTERACTION );
    1464         [ #  # ]:          0 :         rpSet->ClearItem( SID_PASSWORD );
    1465         [ #  # ]:          0 :         rpSet->ClearItem( SID_ENCRYPTIONDATA );
    1466         [ #  # ]:          0 :         rpSet->ClearItem( SID_RECOMMENDREADONLY );
    1467         [ #  # ]:          0 :         rpSet->ClearItem( SID_MODIFYPASSWORDINFO );
    1468                 :            : 
    1469                 :            :     }
    1470                 :            : 
    1471 [ #  # ][ #  # ]:          0 :     if ( mbHasPassword && !mbPwdCheckBoxState )
    1472                 :            :     {
    1473         [ #  # ]:          0 :         SvtSecurityOptions aSecOpt;
    1474                 :            :         mbPwdCheckBoxState = (
    1475 [ #  # ][ #  # ]:          0 :             aSecOpt.IsOptionSet( SvtSecurityOptions::E_DOCWARN_RECOMMENDPASSWORD ) );
    1476                 :            :     }
    1477                 :            : 
    1478                 :          0 :     rpURLList.clear();
    1479                 :            : 
    1480         [ #  # ]:          0 :     if ( ! mxFileDlg.is() )
    1481                 :          0 :         return ERRCODE_ABORT;
    1482                 :            : 
    1483 [ #  # ][ #  # ]:          0 :     if ( ExecutableDialogResults::CANCEL != implDoExecute() )
    1484                 :            :     {
    1485                 :            :         // create an itemset if there is no
    1486         [ #  # ]:          0 :         if( !rpSet )
    1487 [ #  # ][ #  # ]:          0 :             rpSet = new SfxAllItemSet( SFX_APP()->GetPool() );
                 [ #  # ]
    1488                 :            : 
    1489                 :            :         // the item should remain only if it was set by the dialog
    1490         [ #  # ]:          0 :         rpSet->ClearItem( SID_SELECTION );
    1491                 :            : 
    1492 [ #  # ][ #  # ]:          0 :         if( mbExport && mbHasSelectionBox )
    1493                 :            :         {
    1494                 :            :             try
    1495                 :            :             {
    1496 [ #  # ][ #  # ]:          0 :                 Any aValue = xCtrlAccess->getValue( ExtendedFilePickerElementIds::CHECKBOX_SELECTION, 0 );
    1497                 :          0 :                 sal_Bool bSelection = sal_False;
    1498         [ #  # ]:          0 :                 if ( aValue >>= bSelection )
    1499 [ #  # ][ #  # ]:          0 :                     rpSet->Put( SfxBoolItem( SID_SELECTION, bSelection ) );
         [ #  # ][ #  # ]
    1500                 :            :             }
    1501         [ #  # ]:          0 :             catch( const IllegalArgumentException& )
    1502                 :            :             {
    1503                 :            :                 OSL_FAIL( "FileDialogHelper_Impl::execute: caught an IllegalArgumentException!" );
    1504                 :            :             }
    1505                 :            :         }
    1506                 :            : 
    1507                 :            : 
    1508                 :            :         // set the read-only flag. When inserting a file, this flag is always set
    1509         [ #  # ]:          0 :         if ( mbInsert )
    1510 [ #  # ][ #  # ]:          0 :             rpSet->Put( SfxBoolItem( SID_DOC_READONLY, sal_True ) );
                 [ #  # ]
    1511                 :            :         else
    1512                 :            :         {
    1513 [ #  # ][ #  # ]:          0 :             if ( ( FILEOPEN_READONLY_VERSION == m_nDialogType ) && xCtrlAccess.is() )
                 [ #  # ]
    1514                 :            :             {
    1515                 :            :                 try
    1516                 :            :                 {
    1517 [ #  # ][ #  # ]:          0 :                     Any aValue = xCtrlAccess->getValue( ExtendedFilePickerElementIds::CHECKBOX_READONLY, 0 );
    1518                 :          0 :                     sal_Bool bReadOnly = sal_False;
    1519 [ #  # ][ #  # ]:          0 :                     if ( ( aValue >>= bReadOnly ) && bReadOnly )
                 [ #  # ]
    1520 [ #  # ][ #  # ]:          0 :                         rpSet->Put( SfxBoolItem( SID_DOC_READONLY, bReadOnly ) );
         [ #  # ][ #  # ]
    1521                 :            :                 }
    1522         [ #  # ]:          0 :                 catch( const IllegalArgumentException& )
    1523                 :            :                 {
    1524                 :            :                     OSL_FAIL( "FileDialogHelper_Impl::execute: caught an IllegalArgumentException!" );
    1525                 :            :                 }
    1526                 :            :             }
    1527                 :            :         }
    1528 [ #  # ][ #  # ]:          0 :         if ( mbHasVersions && xCtrlAccess.is() )
                 [ #  # ]
    1529                 :            :         {
    1530                 :            :             try
    1531                 :            :             {
    1532         [ #  # ]:          0 :                 Any aValue = xCtrlAccess->getValue( ExtendedFilePickerElementIds::LISTBOX_VERSION,
    1533         [ #  # ]:          0 :                                                     ControlActions::GET_SELECTED_ITEM_INDEX );
    1534                 :          0 :                 sal_Int32 nVersion = 0;
    1535 [ #  # ][ #  # ]:          0 :                 if ( ( aValue >>= nVersion ) && nVersion > 0 )
                 [ #  # ]
    1536                 :            :                     // open a special version; 0 == current version
    1537 [ #  # ][ #  # ]:          0 :                     rpSet->Put( SfxInt16Item( SID_VERSION, (short)nVersion ) );
         [ #  # ][ #  # ]
    1538                 :            :             }
    1539         [ #  # ]:          0 :             catch( const IllegalArgumentException& ){}
    1540                 :            :         }
    1541                 :            : 
    1542                 :            :         // set the filter
    1543         [ #  # ]:          0 :         getRealFilter( rFilter );
    1544                 :            : 
    1545         [ #  # ]:          0 :         const SfxFilter* pCurrentFilter = getCurentSfxFilter();
    1546                 :            : 
    1547                 :            :         // fill the rpURLList
    1548         [ #  # ]:          0 :         implGetAndCacheFiles( mxFileDlg, rpURLList, pCurrentFilter );
    1549         [ #  # ]:          0 :         if ( rpURLList.empty() )
    1550                 :          0 :             return ERRCODE_ABORT;
    1551                 :            : 
    1552                 :            :         // check, whether or not we have to display a password box
    1553 [ #  # ][ #  # ]:          0 :         if ( pCurrentFilter && mbHasPassword && mbIsPwdEnabled && xCtrlAccess.is() )
         [ #  # ][ #  # ]
                 [ #  # ]
    1554                 :            :         {
    1555                 :            :             try
    1556                 :            :             {
    1557 [ #  # ][ #  # ]:          0 :                 Any aValue = xCtrlAccess->getValue( ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, 0 );
    1558                 :          0 :                 sal_Bool bPassWord = sal_False;
    1559 [ #  # ][ #  # ]:          0 :                 if ( ( aValue >>= bPassWord ) && bPassWord )
                 [ #  # ]
    1560                 :            :                 {
    1561                 :            :                     // ask for a password
    1562                 :          0 :                     rtl::OUString aDocName(rpURLList[0]);
    1563         [ #  # ]:          0 :                     ErrCode errCode = RequestPassword(pCurrentFilter, aDocName, rpSet);
    1564         [ #  # ]:          0 :                     if (errCode != ERRCODE_NONE)
    1565         [ #  # ]:          0 :                         return errCode;
    1566 [ #  # ][ #  # ]:          0 :                 }
    1567                 :            :             }
    1568         [ #  # ]:          0 :             catch( const IllegalArgumentException& ){}
    1569                 :            :         }
    1570                 :            : 
    1571         [ #  # ]:          0 :         SaveLastUsedFilter();
    1572                 :          0 :         return ERRCODE_NONE;
    1573                 :            :     }
    1574                 :            :     else
    1575                 :          0 :         return ERRCODE_ABORT;
    1576                 :            : }
    1577                 :            : 
    1578                 :            : // ------------------------------------------------------------------------
    1579                 :          0 : ErrCode FileDialogHelper_Impl::execute()
    1580                 :            : {
    1581         [ #  # ]:          0 :     if ( ! mxFileDlg.is() )
    1582                 :          0 :         return ERRCODE_ABORT;
    1583                 :            : 
    1584                 :          0 :     sal_Int16 nRet = implDoExecute();
    1585                 :            : 
    1586                 :          0 :     maPath = mxFileDlg->getDisplayDirectory();
    1587                 :            : 
    1588         [ #  # ]:          0 :     if ( ExecutableDialogResults::CANCEL == nRet )
    1589                 :          0 :         return ERRCODE_ABORT;
    1590                 :            :     else
    1591                 :            :     {
    1592                 :          0 :         return ERRCODE_NONE;
    1593                 :            :     }
    1594                 :            : }
    1595                 :            : 
    1596                 :            : // ------------------------------------------------------------------------
    1597                 :          0 : OUString FileDialogHelper_Impl::getPath() const
    1598                 :            : {
    1599                 :          0 :     OUString aPath;
    1600                 :            : 
    1601         [ #  # ]:          0 :     if ( mxFileDlg.is() )
    1602 [ #  # ][ #  # ]:          0 :         aPath = mxFileDlg->getDisplayDirectory();
    1603                 :            : 
    1604         [ #  # ]:          0 :     if ( aPath.isEmpty() )
    1605                 :          0 :         aPath = maPath;
    1606                 :            : 
    1607                 :          0 :     return aPath;
    1608                 :            : }
    1609                 :            : 
    1610                 :            : // ------------------------------------------------------------------------
    1611                 :          0 : OUString FileDialogHelper_Impl::getFilter() const
    1612                 :            : {
    1613         [ #  # ]:          0 :     String aFilter = getCurrentFilterUIName();
    1614                 :            : 
    1615         [ #  # ]:          0 :     if( !aFilter.Len() )
    1616         [ #  # ]:          0 :         aFilter = maCurFilter;
    1617                 :            : 
    1618 [ #  # ][ #  # ]:          0 :     return aFilter;
    1619                 :            : }
    1620                 :            : 
    1621                 :            : // ------------------------------------------------------------------------
    1622                 :          0 : void FileDialogHelper_Impl::getRealFilter( String& _rFilter ) const
    1623                 :            : {
    1624         [ #  # ]:          0 :     _rFilter = getCurrentFilterUIName();
    1625                 :            : 
    1626         [ #  # ]:          0 :     if ( !_rFilter.Len() )
    1627                 :          0 :         _rFilter = maCurFilter;
    1628                 :            : 
    1629 [ #  # ][ #  # ]:          0 :     if ( _rFilter.Len() && mpMatcher )
                 [ #  # ]
    1630                 :            :     {
    1631                 :            :         const SfxFilter* pFilter =
    1632                 :          0 :             mpMatcher->GetFilter4UIName( _rFilter, m_nMustFlags, m_nDontFlags );
    1633         [ #  # ]:          0 :         _rFilter = pFilter ? pFilter->GetFilterName() : _rFilter.Erase();
    1634                 :            :     }
    1635                 :          0 : }
    1636                 :            : 
    1637                 :          0 : void FileDialogHelper_Impl::verifyPath()
    1638                 :            : {
    1639                 :            : #ifdef UNX
    1640                 :            :     // lp#905355, fdo#43895
    1641                 :            :     // Check that the file has read only permission and is in /tmp -- this is
    1642                 :            :     //  the case if we have opened the file from the web with firefox only.
    1643         [ #  # ]:          0 :     if (maFileName.isEmpty()) {
    1644                 :            :         return;
    1645                 :            :     }
    1646         [ #  # ]:          0 :     INetURLObject url(maPath);
    1647   [ #  #  #  # ]:          0 :     if (url.GetProtocol() != INET_PROT_FILE
                 [ #  # ]
    1648 [ #  # ][ #  # ]:          0 :         || url.getName(0, true, INetURLObject::DECODE_WITH_CHARSET) != "tmp")
                 [ #  # ]
    1649                 :            :     {
    1650                 :            :         return;
    1651                 :            :     }
    1652         [ #  # ]:          0 :     if (maFileName.indexOf('/') != -1) {
    1653                 :            :         SAL_WARN("sfx2", maFileName << " contains /");
    1654                 :            :         return;
    1655                 :            :     }
    1656                 :            :     url.insertName(
    1657                 :            :         maFileName, false, INetURLObject::LAST_SEGMENT, true,
    1658         [ #  # ]:          0 :         INetURLObject::ENCODE_ALL);
    1659                 :          0 :     rtl::OUString sysPathU;
    1660                 :            :     osl::FileBase::RC e = osl::FileBase::getSystemPathFromFileURL(
    1661 [ #  # ][ #  # ]:          0 :         url.GetMainURL(INetURLObject::NO_DECODE), sysPathU);
    1662         [ #  # ]:          0 :     if (e != osl::FileBase::E_None) {
    1663                 :            :         SAL_WARN(
    1664                 :            :             "sfx2",
    1665                 :            :             "getSystemPathFromFileURL("
    1666                 :            :                 << url.GetMainURL(INetURLObject::NO_DECODE) << ") failed with "
    1667                 :            :                 << +e);
    1668                 :            :         return;
    1669                 :            :     }
    1670                 :          0 :     rtl::OString sysPathC;
    1671         [ #  # ]:          0 :     if (!sysPathU.convertToString(
    1672         [ #  # ]:          0 :             &sysPathC, osl_getThreadTextEncoding(),
    1673                 :            :             (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR
    1674                 :          0 :              | RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR)))
    1675                 :            :     {
    1676                 :            :         SAL_WARN(
    1677                 :            :             "sfx2",
    1678                 :            :             "convertToString(" << sysPathU << ") failed for encoding "
    1679                 :            :                 << +osl_getThreadTextEncoding());
    1680                 :            :         return;
    1681                 :            :     }
    1682                 :            :     struct stat aFileStat;
    1683         [ #  # ]:          0 :     if (stat(sysPathC.getStr(), &aFileStat) == -1) {
    1684                 :            :         SAL_WARN(
    1685                 :            :             "sfx2",
    1686                 :            :             "stat(" << sysPathC.getStr() << ") failed with errno " << errno);
    1687                 :            :         return;
    1688                 :            :     }
    1689         [ #  # ]:          0 :     if ((aFileStat.st_mode & (S_IRWXO | S_IRWXG | S_IRWXU)) == S_IRUSR) {
    1690 [ #  # ][ #  # ]:          0 :         maPath = SvtPathOptions().GetWorkPath();
         [ #  # ][ #  # ]
    1691 [ #  # ][ #  # ]:          0 :         mxFileDlg->setDisplayDirectory( maPath );
    1692 [ #  # ][ #  # ]:          0 :     }
         [ #  # ][ #  # ]
    1693                 :            : #endif
    1694                 :            : }
    1695                 :            : 
    1696                 :            : // ------------------------------------------------------------------------
    1697                 :          0 : void FileDialogHelper_Impl::displayFolder( const ::rtl::OUString& _rPath )
    1698                 :            : {
    1699         [ #  # ]:          0 :     if ( _rPath.isEmpty() )
    1700                 :            :         // nothing to do
    1701         [ #  # ]:          0 :         return;
    1702                 :            : 
    1703                 :          0 :     maPath = _rPath;
    1704         [ #  # ]:          0 :     if ( mxFileDlg.is() )
    1705                 :            :     {
    1706                 :            :         try
    1707                 :            :         {
    1708 [ #  # ][ #  # ]:          0 :             mxFileDlg->setDisplayDirectory( maPath );
    1709         [ #  # ]:          0 :             verifyPath();
    1710                 :            :         }
    1711                 :          0 :         catch( const IllegalArgumentException& )
    1712                 :            :         {
    1713                 :            :             OSL_FAIL( "FileDialogHelper_Impl::displayFolder: caught an exception!" );
    1714                 :            :         }
    1715                 :            :     }
    1716                 :            : }
    1717                 :            : 
    1718                 :            : // ------------------------------------------------------------------------
    1719                 :          0 : void FileDialogHelper_Impl::setFileName( const ::rtl::OUString& _rFile )
    1720                 :            : {
    1721                 :          0 :     maFileName = _rFile;
    1722         [ #  # ]:          0 :     if ( mxFileDlg.is() )
    1723                 :            :     {
    1724                 :            :         try
    1725                 :            :         {
    1726 [ #  # ][ #  # ]:          0 :             mxFileDlg->setDefaultName( maFileName );
    1727         [ #  # ]:          0 :             verifyPath();
    1728                 :            :         }
    1729                 :          0 :         catch( const IllegalArgumentException& )
    1730                 :            :         {
    1731                 :            :             OSL_FAIL( "FileDialogHelper_Impl::setFileName: caught an exception!" );
    1732                 :            :         }
    1733                 :            :     }
    1734         [ #  # ]:          0 : }
    1735                 :            : 
    1736                 :            : // ------------------------------------------------------------------------
    1737                 :          0 : void FileDialogHelper_Impl::setFilter( const OUString& rFilter )
    1738                 :            : {
    1739                 :            :     DBG_ASSERT( rFilter.indexOf(':') == -1, "Old filter name used!");
    1740                 :            : 
    1741                 :          0 :     maCurFilter = rFilter;
    1742                 :            : 
    1743 [ #  # ][ #  # ]:          0 :     if ( !rFilter.isEmpty() && mpMatcher )
                 [ #  # ]
    1744                 :            :     {
    1745                 :            :         const SfxFilter* pFilter = mpMatcher->GetFilter4FilterName(
    1746 [ #  # ][ #  # ]:          0 :                                         rFilter, m_nMustFlags, m_nDontFlags );
           [ #  #  #  # ]
    1747         [ #  # ]:          0 :         if ( pFilter )
    1748         [ #  # ]:          0 :             maCurFilter = pFilter->GetUIName();
    1749                 :            :     }
    1750                 :            : 
    1751         [ #  # ]:          0 :     uno::Reference< XFilterManager > xFltMgr( mxFileDlg, UNO_QUERY );
    1752                 :            : 
    1753 [ #  # ][ #  # ]:          0 :     if ( !maCurFilter.isEmpty() && xFltMgr.is() )
                 [ #  # ]
    1754                 :            :     {
    1755                 :            :         try
    1756                 :            :         {
    1757 [ #  # ][ #  # ]:          0 :             xFltMgr->setCurrentFilter( maCurFilter );
    1758                 :            :         }
    1759         [ #  # ]:          0 :         catch( const IllegalArgumentException& ){}
    1760                 :          0 :     }
    1761                 :          0 : }
    1762                 :            : 
    1763                 :            : // ------------------------------------------------------------------------
    1764                 :          0 : void FileDialogHelper_Impl::createMatcher( const String& rFactory )
    1765                 :            : {
    1766 [ #  # ][ #  # ]:          0 :     mpMatcher = new SfxFilterMatcher( SfxObjectShell::GetServiceNameFromFactory(rFactory) );
    1767                 :          0 :     mbDeleteMatcher = sal_True;
    1768                 :          0 : }
    1769                 :            : 
    1770                 :            : // ------------------------------------------------------------------------
    1771                 :          0 : void FileDialogHelper_Impl::addFilters( const String& rFactory,
    1772                 :            :                                         SfxFilterFlags nMust,
    1773                 :            :                                         SfxFilterFlags nDont )
    1774                 :            : {
    1775         [ #  # ]:          0 :     uno::Reference< XFilterManager > xFltMgr( mxFileDlg, UNO_QUERY );
    1776                 :            : 
    1777         [ #  # ]:          0 :     if ( ! xFltMgr.is() )
    1778                 :            :         return;
    1779                 :            : 
    1780                 :            :     // we still need a matcher to convert UI names to filter names
    1781         [ #  # ]:          0 :     if ( !rFactory.Len() )
    1782                 :            :     {
    1783         [ #  # ]:          0 :         SfxApplication *pSfxApp = SFX_APP();
    1784         [ #  # ]:          0 :         mpMatcher = &pSfxApp->GetFilterMatcher();
    1785                 :          0 :         mbDeleteMatcher = sal_False;
    1786                 :            :     }
    1787                 :            :     else
    1788                 :            :     {
    1789 [ #  # ][ #  # ]:          0 :         mpMatcher = new SfxFilterMatcher( rFactory );
    1790                 :          0 :         mbDeleteMatcher = sal_True;
    1791                 :            :     }
    1792                 :            : 
    1793         [ #  # ]:          0 :     uno::Reference< XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory();
    1794                 :            :     uno::Reference< XContainerQuery > xFilterCont(
    1795         [ #  # ]:          0 :         xSMGR->createInstance(::rtl::OUString("com.sun.star.document.FilterFactory")),
    1796 [ #  # ][ #  # ]:          0 :         UNO_QUERY);
    1797         [ #  # ]:          0 :     if ( ! xFilterCont.is() )
    1798                 :            :         return;
    1799                 :            : 
    1800                 :          0 :     m_nMustFlags |= nMust;
    1801                 :          0 :     m_nDontFlags |= nDont;
    1802                 :            : 
    1803                 :            :     // create the list of filters
    1804                 :          0 :     ::rtl::OUStringBuffer sQuery(256);
    1805         [ #  # ]:          0 :     sQuery.appendAscii(RTL_CONSTASCII_STRINGPARAM("getSortedFilterList()"));
    1806         [ #  # ]:          0 :     sQuery.appendAscii(RTL_CONSTASCII_STRINGPARAM(":module="));
    1807 [ #  # ][ #  # ]:          0 :     sQuery.append(rFactory); // use long name here !
    1808         [ #  # ]:          0 :     sQuery.appendAscii(RTL_CONSTASCII_STRINGPARAM(":iflags="));
    1809         [ #  # ]:          0 :     sQuery.append(::rtl::OUString::valueOf((sal_Int32)m_nMustFlags));
    1810         [ #  # ]:          0 :     sQuery.appendAscii(RTL_CONSTASCII_STRINGPARAM(":eflags="));
    1811         [ #  # ]:          0 :     sQuery.append(::rtl::OUString::valueOf((sal_Int32)m_nDontFlags));
    1812                 :            : 
    1813                 :          0 :     uno::Reference< XEnumeration > xResult;
    1814                 :            :     try
    1815                 :            :     {
    1816 [ #  # ][ #  # ]:          0 :         xResult = xFilterCont->createSubSetEnumerationByQuery(sQuery.makeStringAndClear());
         [ #  # ][ #  # ]
                 [ #  # ]
    1817                 :            :     }
    1818         [ #  # ]:          0 :     catch( const uno::Exception& )
    1819                 :            :     {
    1820                 :            :         SAL_WARN( "sfx2.dialog", "Could not get filters from the configuration!" );
    1821                 :            :     }
    1822                 :            : 
    1823         [ #  # ]:          0 :     TSortedFilterList         aIter   (xResult);
    1824                 :            : 
    1825                 :            :     // no matcher any longer used ...
    1826                 :          0 :     mbDeleteMatcher = sal_False;
    1827                 :            : 
    1828                 :            :     // append the filters
    1829                 :          0 :     ::rtl::OUString sFirstFilter;
    1830         [ #  # ]:          0 :     if (OPEN == lcl_OpenOrSave(m_nDialogType))
    1831         [ #  # ]:          0 :         ::sfx2::appendFiltersForOpen( aIter, xFltMgr, sFirstFilter, *this );
    1832         [ #  # ]:          0 :     else if ( mbExport )
    1833         [ #  # ]:          0 :         ::sfx2::appendExportFilters( aIter, xFltMgr, sFirstFilter, *this );
    1834                 :            :     else
    1835 [ #  # ][ #  # ]:          0 :         ::sfx2::appendFiltersForSave( aIter, xFltMgr, sFirstFilter, *this, rFactory );
    1836                 :            : 
    1837                 :            :     // set our initial selected filter (if we do not already have one)
    1838         [ #  # ]:          0 :     if ( maSelectFilter.isEmpty() )
    1839 [ #  # ][ #  # ]:          0 :         maSelectFilter = sFirstFilter;
                 [ #  # ]
    1840                 :            : }
    1841                 :            : 
    1842                 :            : // ------------------------------------------------------------------------
    1843                 :          0 : void FileDialogHelper_Impl::addFilter( const OUString& rFilterName,
    1844                 :            :                                        const OUString& rExtension )
    1845                 :            : {
    1846         [ #  # ]:          0 :     uno::Reference< XFilterManager > xFltMgr( mxFileDlg, UNO_QUERY );
    1847                 :            : 
    1848         [ #  # ]:          0 :     if ( ! xFltMgr.is() )
    1849         [ #  # ]:          0 :         return;
    1850                 :            : 
    1851                 :            :     try
    1852                 :            :     {
    1853 [ #  # ][ #  # ]:          0 :         xFltMgr->appendFilter( rFilterName, rExtension );
    1854                 :            : 
    1855         [ #  # ]:          0 :         if ( maSelectFilter.isEmpty() )
    1856                 :          0 :             maSelectFilter = rFilterName;
    1857                 :            :     }
    1858         [ #  # ]:          0 :     catch( const IllegalArgumentException& )
    1859                 :            :     {
    1860                 :            :         SAL_WARN( "sfx2.dialog", "Could not append Filter" << rFilterName );
    1861         [ #  # ]:          0 :     }
    1862                 :            : }
    1863                 :            : 
    1864                 :            : // ------------------------------------------------------------------------
    1865                 :          0 : void FileDialogHelper_Impl::addGraphicFilter()
    1866                 :            : {
    1867         [ #  # ]:          0 :     uno::Reference< XFilterManager > xFltMgr( mxFileDlg, UNO_QUERY );
    1868                 :            : 
    1869         [ #  # ]:          0 :     if ( ! xFltMgr.is() )
    1870                 :          0 :         return;
    1871                 :            : 
    1872                 :            :     // create the list of filters
    1873 [ #  # ][ #  # ]:          0 :     mpGraphicFilter = new GraphicFilter;
    1874         [ #  # ]:          0 :     sal_uInt16 i, j, nCount = mpGraphicFilter->GetImportFormatCount();
    1875                 :            : 
    1876                 :            :     // compute the extension string for all known import filters
    1877         [ #  # ]:          0 :     String aExtensions;
    1878                 :            : 
    1879         [ #  # ]:          0 :     for ( i = 0; i < nCount; i++ )
    1880                 :            :     {
    1881                 :          0 :         j = 0;
    1882         [ #  # ]:          0 :         String sWildcard;
    1883                 :          0 :         while( sal_True )
    1884                 :            :         {
    1885 [ #  # ][ #  # ]:          0 :             sWildcard = mpGraphicFilter->GetImportWildcard( i, j++ );
                 [ #  # ]
    1886         [ #  # ]:          0 :             if ( !sWildcard.Len() )
    1887                 :          0 :                 break;
    1888 [ #  # ][ #  # ]:          0 :             if ( aExtensions.Search( sWildcard ) == STRING_NOTFOUND )
    1889                 :            :             {
    1890         [ #  # ]:          0 :                 if ( aExtensions.Len() )
    1891         [ #  # ]:          0 :                     aExtensions += sal_Unicode(';');
    1892         [ #  # ]:          0 :                 aExtensions += sWildcard;
    1893                 :            :             }
    1894                 :            :         }
    1895         [ #  # ]:          0 :     }
    1896                 :            : 
    1897                 :            : #if defined(WNT)
    1898                 :            :     if ( aExtensions.Len() > 240 )
    1899                 :            :         aExtensions = DEFINE_CONST_UNICODE( FILEDIALOG_FILTER_ALL );
    1900                 :            : #endif
    1901                 :          0 :     sal_Bool bIsInOpenMode = isInOpenMode();
    1902                 :            : 
    1903                 :            :     try
    1904                 :            :     {
    1905 [ #  # ][ #  # ]:          0 :         OUString aAllFilterName = SfxResId( STR_SFX_IMPORT_ALL ).toString();
    1906 [ #  # ][ #  # ]:          0 :         aAllFilterName = ::sfx2::addExtension( aAllFilterName, aExtensions, bIsInOpenMode, *this );
    1907                 :            : 
    1908 [ #  # ][ #  # ]:          0 :         xFltMgr->appendFilter( aAllFilterName, aExtensions );
                 [ #  # ]
    1909         [ #  # ]:          0 :         maSelectFilter = aAllFilterName;
    1910                 :            :     }
    1911         [ #  # ]:          0 :     catch( const IllegalArgumentException& )
    1912                 :            :     {
    1913                 :            :         SAL_WARN( "sfx2.dialog", "Could not append Filter" );
    1914                 :            :     }
    1915                 :            : 
    1916                 :            :     // Now add the filter
    1917         [ #  # ]:          0 :     for ( i = 0; i < nCount; i++ )
    1918                 :            :     {
    1919         [ #  # ]:          0 :         String aName = mpGraphicFilter->GetImportFormatName( i );
    1920         [ #  # ]:          0 :         String aExt;
    1921                 :          0 :         j = 0;
    1922         [ #  # ]:          0 :         String sWildcard;
    1923                 :          0 :         while( sal_True )
    1924                 :            :         {
    1925 [ #  # ][ #  # ]:          0 :             sWildcard = mpGraphicFilter->GetImportWildcard( i, j++ );
                 [ #  # ]
    1926         [ #  # ]:          0 :             if ( !sWildcard.Len() )
    1927                 :          0 :                 break;
    1928 [ #  # ][ #  # ]:          0 :             if ( aExt.Search( sWildcard ) == STRING_NOTFOUND )
    1929                 :            :             {
    1930         [ #  # ]:          0 :                 if ( aExt.Len() )
    1931         [ #  # ]:          0 :                     aExt += sal_Unicode(';');
    1932         [ #  # ]:          0 :                 aExt += sWildcard;
    1933                 :            :             }
    1934                 :            :         }
    1935 [ #  # ][ #  # ]:          0 :         aName = ::sfx2::addExtension( aName, aExt, bIsInOpenMode, *this );
         [ #  # ][ #  # ]
    1936                 :            :         try
    1937                 :            :         {
    1938 [ #  # ][ #  # ]:          0 :             xFltMgr->appendFilter( aName, aExt );
         [ #  # ][ #  # ]
                 [ #  # ]
    1939                 :            :         }
    1940         [ #  # ]:          0 :         catch( const IllegalArgumentException& )
    1941                 :            :         {
    1942                 :            :             SAL_WARN( "sfx2.dialog", "Could not append Filter" );
    1943                 :            :         }
    1944 [ #  # ][ #  # ]:          0 :     }
         [ #  # ][ #  # ]
                 [ #  # ]
    1945                 :            : }
    1946                 :            : 
    1947                 :            : // ------------------------------------------------------------------------
    1948                 :            : #define GRF_CONFIG_STR      "   "
    1949                 :            : #define STD_CONFIG_STR      "1 "
    1950                 :            : 
    1951                 :          0 : void FileDialogHelper_Impl::saveConfig()
    1952                 :            : {
    1953         [ #  # ]:          0 :     uno::Reference < XFilePickerControlAccess > xDlg( mxFileDlg, UNO_QUERY );
    1954                 :          0 :     Any aValue;
    1955                 :            : 
    1956         [ #  # ]:          0 :     if ( ! xDlg.is() )
    1957                 :          0 :         return;
    1958                 :            : 
    1959         [ #  # ]:          0 :     if ( mbHasPreview )
    1960                 :            :     {
    1961 [ #  # ][ #  # ]:          0 :         SvtViewOptions aDlgOpt( E_DIALOG, IMPGRF_CONFIGNAME );
         [ #  # ][ #  # ]
    1962         [ #  # ]:          0 :         String aUserData = DEFINE_CONST_UNICODE( GRF_CONFIG_STR );
    1963                 :            : 
    1964                 :            :         try
    1965                 :            :         {
    1966                 :          0 :             sal_Bool bValue = sal_False;
    1967 [ #  # ][ #  # ]:          0 :             aValue = xDlg->getValue( ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, 0 );
    1968                 :          0 :             bValue = sal_False;
    1969                 :          0 :             aValue >>= bValue;
    1970 [ #  # ][ #  # ]:          0 :             aUserData.SetToken( 1, ' ', String::CreateFromInt32( (sal_Int32) bValue ) );
                 [ #  # ]
    1971                 :            : 
    1972 [ #  # ][ #  # ]:          0 :             INetURLObject aObj( getPath() );
    1973                 :            : 
    1974         [ #  # ]:          0 :             if ( aObj.GetProtocol() == INET_PROT_FILE )
    1975 [ #  # ][ #  # ]:          0 :                 aUserData.SetToken( 2, ' ', aObj.GetMainURL( INetURLObject::NO_DECODE ) );
         [ #  # ][ #  # ]
    1976                 :            : 
    1977 [ #  # ][ #  # ]:          0 :             String aFilter = getFilter();
    1978 [ #  # ][ #  # ]:          0 :             aFilter = EncodeSpaces_Impl( aFilter );
                 [ #  # ]
    1979         [ #  # ]:          0 :             aUserData.SetToken( 3, ' ', aFilter );
    1980                 :            : 
    1981 [ #  # ][ #  # ]:          0 :             aDlgOpt.SetUserItem( USERITEM_NAME, makeAny( OUString( aUserData ) ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1982                 :            :         }
    1983 [ #  # ][ #  # ]:          0 :         catch( const IllegalArgumentException& ){}
                 [ #  # ]
    1984                 :            :     }
    1985                 :            :     else
    1986                 :            :     {
    1987                 :          0 :         sal_Bool bWriteConfig = sal_False;
    1988 [ #  # ][ #  # ]:          0 :         SvtViewOptions aDlgOpt( E_DIALOG, IODLG_CONFIGNAME );
         [ #  # ][ #  # ]
    1989         [ #  # ]:          0 :         String aUserData = DEFINE_CONST_UNICODE( STD_CONFIG_STR );
    1990                 :            : 
    1991 [ #  # ][ #  # ]:          0 :         if ( aDlgOpt.Exists() )
    1992                 :            :         {
    1993         [ #  # ]:          0 :             Any aUserItem = aDlgOpt.GetUserItem( USERITEM_NAME );
    1994                 :          0 :             OUString aTemp;
    1995         [ #  # ]:          0 :             if ( aUserItem >>= aTemp )
    1996 [ #  # ][ #  # ]:          0 :                 aUserData = String( aTemp );
                 [ #  # ]
    1997                 :            :         }
    1998                 :            : 
    1999         [ #  # ]:          0 :         if ( mbHasAutoExt )
    2000                 :            :         {
    2001                 :            :             try
    2002                 :            :             {
    2003 [ #  # ][ #  # ]:          0 :                 aValue = xDlg->getValue( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0 );
    2004                 :          0 :                 sal_Bool bAutoExt = sal_True;
    2005                 :          0 :                 aValue >>= bAutoExt;
    2006         [ #  # ]:          0 :                 aUserData.SetToken( 0, ' ', String::CreateFromInt32( (sal_Int32) bAutoExt ) );
           [ #  #  #  # ]
                 [ #  # ]
    2007                 :          0 :                 bWriteConfig = sal_True;
    2008                 :            :             }
    2009         [ #  # ]:          0 :             catch( const IllegalArgumentException& ){}
    2010                 :            :         }
    2011                 :            : 
    2012         [ #  # ]:          0 :         if ( ! mbIsSaveDlg )
    2013                 :            :         {
    2014         [ #  # ]:          0 :             OUString aPath = getPath();
    2015 [ #  # ][ #  # ]:          0 :             if ( !aPath.isEmpty() &&
                 [ #  # ]
    2016         [ #  # ]:          0 :                  utl::LocalFileHelper::IsLocalFile( aPath ) )
    2017                 :            :             {
    2018 [ #  # ][ #  # ]:          0 :                 aUserData.SetToken( 1, ' ', aPath );
                 [ #  # ]
    2019                 :          0 :                 bWriteConfig = sal_True;
    2020                 :          0 :             }
    2021                 :            :         }
    2022                 :            : 
    2023 [ #  # ][ #  # ]:          0 :         if( mbHasSelectionBox && mbSelectionFltrEnabled )
    2024                 :            :         {
    2025                 :            :             try
    2026                 :            :             {
    2027 [ #  # ][ #  # ]:          0 :                 aValue = xDlg->getValue( ExtendedFilePickerElementIds::CHECKBOX_SELECTION, 0 );
    2028                 :          0 :                 sal_Bool bSelection = sal_True;
    2029                 :          0 :                 aValue >>= bSelection;
    2030 [ #  # ][ #  # ]:          0 :                 if ( comphelper::string::getTokenCount(aUserData, ' ') < 3 )
                 [ #  # ]
    2031         [ #  # ]:          0 :                     aUserData.Append(' ');
    2032 [ #  # ][ #  # ]:          0 :                 aUserData.SetToken( 2, ' ', String::CreateFromInt32( (sal_Int32) bSelection ) );
           [ #  #  #  # ]
    2033                 :          0 :                 bWriteConfig = sal_True;
    2034                 :            :             }
    2035         [ #  # ]:          0 :             catch( const IllegalArgumentException& ){}
    2036                 :            :         }
    2037                 :            : 
    2038         [ #  # ]:          0 :         if ( bWriteConfig )
    2039 [ #  # ][ #  # ]:          0 :             aDlgOpt.SetUserItem( USERITEM_NAME, makeAny( OUString( aUserData ) ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    2040                 :            :     }
    2041                 :            : 
    2042         [ #  # ]:          0 :     SfxApplication *pSfxApp = SFX_APP();
    2043 [ #  # ][ #  # ]:          0 :     pSfxApp->SetLastDir_Impl( getPath() );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2044                 :            : }
    2045                 :            : 
    2046                 :            : // ------------------------------------------------------------------------
    2047                 :            : namespace
    2048                 :            : {
    2049                 :          0 :     static ::rtl::OUString getInitPath( const String& _rFallback, const xub_StrLen _nFallbackToken )
    2050                 :            :     {
    2051         [ #  # ]:          0 :         SfxApplication *pSfxApp = SFX_APP();
    2052 [ #  # ][ #  # ]:          0 :         String sPath = pSfxApp->GetLastDir_Impl();
    2053                 :            : 
    2054         [ #  # ]:          0 :         if ( !sPath.Len() )
    2055 [ #  # ][ #  # ]:          0 :             sPath = _rFallback.GetToken( _nFallbackToken, ' ' );
                 [ #  # ]
    2056                 :            : 
    2057                 :            :         // check if the path points to a valid (accessible) directory
    2058                 :          0 :         sal_Bool bValid = sal_False;
    2059         [ #  # ]:          0 :         if ( sPath.Len() )
    2060                 :            :         {
    2061         [ #  # ]:          0 :             String sPathCheck( sPath );
    2062         [ #  # ]:          0 :             if ( sPathCheck.GetBuffer()[ sPathCheck.Len() - 1 ] != '/' )
    2063         [ #  # ]:          0 :                 sPathCheck += '/';
    2064         [ #  # ]:          0 :             sPathCheck += '.';
    2065                 :            :             try
    2066                 :            :             {
    2067 [ #  # ][ #  # ]:          0 :                 ::ucbhelper::Content aContent( sPathCheck, uno::Reference< ucb::XCommandEnvironment >() );
    2068 [ #  # ][ #  # ]:          0 :                 bValid = aContent.isFolder();
                 [ #  # ]
    2069                 :            :             }
    2070 [ #  # ][ #  # ]:          0 :             catch( const Exception& ) {}
    2071                 :            :         }
    2072                 :            : 
    2073         [ #  # ]:          0 :         if ( !bValid )
    2074         [ #  # ]:          0 :             sPath.Erase();
    2075                 :            : 
    2076 [ #  # ][ #  # ]:          0 :         return sPath;
    2077                 :            :     }
    2078                 :            : }
    2079                 :            : 
    2080                 :            : // ------------------------------------------------------------------------
    2081                 :          0 : void FileDialogHelper_Impl::loadConfig()
    2082                 :            : {
    2083         [ #  # ]:          0 :     uno::Reference < XFilePickerControlAccess > xDlg( mxFileDlg, UNO_QUERY );
    2084                 :          0 :     Any aValue;
    2085                 :            : 
    2086         [ #  # ]:          0 :     if ( ! xDlg.is() )
    2087                 :          0 :         return;
    2088                 :            : 
    2089         [ #  # ]:          0 :     if ( mbHasPreview )
    2090                 :            :     {
    2091 [ #  # ][ #  # ]:          0 :         SvtViewOptions aViewOpt( E_DIALOG, IMPGRF_CONFIGNAME );
         [ #  # ][ #  # ]
    2092         [ #  # ]:          0 :         String aUserData;
    2093                 :            : 
    2094 [ #  # ][ #  # ]:          0 :         if ( aViewOpt.Exists() )
    2095                 :            :         {
    2096         [ #  # ]:          0 :             Any aUserItem = aViewOpt.GetUserItem( USERITEM_NAME );
    2097                 :          0 :             OUString aTemp;
    2098         [ #  # ]:          0 :             if ( aUserItem >>= aTemp )
    2099 [ #  # ][ #  # ]:          0 :                 aUserData = String( aTemp );
                 [ #  # ]
    2100                 :            :         }
    2101                 :            : 
    2102         [ #  # ]:          0 :         if ( aUserData.Len() > 0 )
    2103                 :            :         {
    2104                 :            :             try
    2105                 :            :             {
    2106                 :            :                 // respect the last "insert as link" state
    2107 [ #  # ][ #  # ]:          0 :                 sal_Bool bLink = (sal_Bool) aUserData.GetToken( 0, ' ' ).ToInt32();
                 [ #  # ]
    2108         [ #  # ]:          0 :                 aValue <<= bLink;
    2109 [ #  # ][ #  # ]:          0 :                 xDlg->setValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, aValue );
    2110                 :            : 
    2111                 :            :                 // respect the last "show preview" state
    2112 [ #  # ][ #  # ]:          0 :                 sal_Bool bShowPreview = (sal_Bool) aUserData.GetToken( 1, ' ' ).ToInt32();
                 [ #  # ]
    2113         [ #  # ]:          0 :                 aValue <<= bShowPreview;
    2114 [ #  # ][ #  # ]:          0 :                 xDlg->setValue( ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, 0, aValue );
    2115                 :            : 
    2116         [ #  # ]:          0 :                 if ( maPath.isEmpty() )
    2117 [ #  # ][ #  # ]:          0 :                     displayFolder( getInitPath( aUserData, 2 ) );
    2118                 :            : 
    2119         [ #  # ]:          0 :                 if ( maCurFilter.isEmpty() )
    2120                 :            :                 {
    2121         [ #  # ]:          0 :                     String aFilter = aUserData.GetToken( 3, ' ' );
    2122 [ #  # ][ #  # ]:          0 :                     aFilter = DecodeSpaces_Impl( aFilter );
                 [ #  # ]
    2123 [ #  # ][ #  # ]:          0 :                     setFilter( aFilter );
         [ #  # ][ #  # ]
    2124                 :            :                 }
    2125                 :            : 
    2126                 :            :                 // set the member so we know that we have to show the preview
    2127                 :          0 :                 mbShowPreview = bShowPreview;
    2128                 :            :             }
    2129         [ #  # ]:          0 :             catch( const IllegalArgumentException& ){}
    2130                 :            :         }
    2131                 :            : 
    2132         [ #  # ]:          0 :         if ( maPath.isEmpty() )
    2133 [ #  # ][ #  # ]:          0 :             displayFolder( SvtPathOptions().GetGraphicPath() );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    2134                 :            :     }
    2135                 :            :     else
    2136                 :            :     {
    2137 [ #  # ][ #  # ]:          0 :         SvtViewOptions aViewOpt( E_DIALOG, IODLG_CONFIGNAME );
         [ #  # ][ #  # ]
    2138         [ #  # ]:          0 :         String aUserData;
    2139                 :            : 
    2140 [ #  # ][ #  # ]:          0 :         if ( aViewOpt.Exists() )
    2141                 :            :         {
    2142         [ #  # ]:          0 :             Any aUserItem = aViewOpt.GetUserItem( USERITEM_NAME );
    2143                 :          0 :             OUString aTemp;
    2144         [ #  # ]:          0 :             if ( aUserItem >>= aTemp )
    2145 [ #  # ][ #  # ]:          0 :                 aUserData = String( aTemp );
                 [ #  # ]
    2146                 :            :         }
    2147                 :            : 
    2148         [ #  # ]:          0 :         if ( ! aUserData.Len() )
    2149 [ #  # ][ #  # ]:          0 :             aUserData = DEFINE_CONST_UNICODE( STD_CONFIG_STR );
                 [ #  # ]
    2150                 :            : 
    2151         [ #  # ]:          0 :         if ( maPath.isEmpty() )
    2152 [ #  # ][ #  # ]:          0 :             displayFolder( getInitPath( aUserData, 1 ) );
    2153                 :            : 
    2154         [ #  # ]:          0 :         if ( mbHasAutoExt )
    2155                 :            :         {
    2156 [ #  # ][ #  # ]:          0 :             sal_Int32 nFlag = aUserData.GetToken( 0, ' ' ).ToInt32();
                 [ #  # ]
    2157   [ #  #  #  # ]:          0 :             aValue <<= (sal_Bool) nFlag;
    2158                 :            :             try
    2159                 :            :             {
    2160 [ #  # ][ #  # ]:          0 :                 xDlg->setValue( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0, aValue );
    2161                 :            :             }
    2162         [ #  # ]:          0 :             catch( const IllegalArgumentException& ){}
    2163                 :            :         }
    2164                 :            : 
    2165         [ #  # ]:          0 :         if( mbHasSelectionBox )
    2166                 :            :         {
    2167 [ #  # ][ #  # ]:          0 :             sal_Int32 nFlag = aUserData.GetToken( 2, ' ' ).ToInt32();
                 [ #  # ]
    2168   [ #  #  #  # ]:          0 :             aValue <<= (sal_Bool) nFlag;
    2169                 :            :             try
    2170                 :            :             {
    2171 [ #  # ][ #  # ]:          0 :                 xDlg->setValue( ExtendedFilePickerElementIds::CHECKBOX_SELECTION, 0, aValue );
    2172                 :            :             }
    2173         [ #  # ]:          0 :             catch( const IllegalArgumentException& ){}
    2174                 :            :         }
    2175                 :            : 
    2176         [ #  # ]:          0 :         if ( maPath.isEmpty() )
    2177 [ #  # ][ #  # ]:          0 :             displayFolder( SvtPathOptions().GetWorkPath() );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    2178 [ #  # ][ #  # ]:          0 :     }
    2179                 :            : }
    2180                 :            : 
    2181                 :            : // ------------------------------------------------------------------------
    2182                 :          0 : void FileDialogHelper_Impl::setDefaultValues()
    2183                 :            : {
    2184                 :            :     // when no filter is set, we set the curentFilter to <all>
    2185 [ #  # ][ #  # ]:          0 :     if ( maCurFilter.isEmpty() && !maSelectFilter.isEmpty() )
                 [ #  # ]
    2186                 :            :     {
    2187         [ #  # ]:          0 :         uno::Reference< XFilterManager > xFltMgr( mxFileDlg, UNO_QUERY );
    2188                 :            :         try
    2189                 :            :         {
    2190 [ #  # ][ #  # ]:          0 :             xFltMgr->setCurrentFilter( maSelectFilter );
    2191                 :            :         }
    2192         [ #  # ]:          0 :         catch( const IllegalArgumentException& )
    2193                 :          0 :         {}
    2194                 :            :     }
    2195                 :            : 
    2196                 :            :     // when no path is set, we use the standard 'work' folder
    2197         [ #  # ]:          0 :     if ( maPath.isEmpty() )
    2198                 :            :     {
    2199 [ #  # ][ #  # ]:          0 :         OUString aWorkFolder = SvtPathOptions().GetWorkPath();
                 [ #  # ]
           [ #  #  #  # ]
    2200                 :            :         try
    2201                 :            :         {
    2202 [ #  # ][ #  # ]:          0 :             mxFileDlg->setDisplayDirectory( aWorkFolder );
    2203                 :            :         }
    2204         [ #  # ]:          0 :         catch( const Exception& )
    2205                 :            :         {
    2206                 :            :             OSL_FAIL( "FileDialogHelper_Impl::setDefaultValues: caught an exception while setting the display directory!" );
    2207                 :          0 :         }
    2208                 :            :     }
    2209         [ #  # ]:          0 : }
    2210                 :            : 
    2211                 :          0 : sal_Bool FileDialogHelper_Impl::isShowFilterExtensionEnabled() const
    2212                 :            : {
    2213                 :          0 :     return !maFilters.empty();
    2214                 :            : }
    2215                 :            : 
    2216                 :          0 : void FileDialogHelper_Impl::addFilterPair( const OUString& rFilter,
    2217                 :            :                                            const OUString& rFilterWithExtension )
    2218                 :            : {
    2219         [ #  # ]:          0 :     maFilters.push_back( FilterPair( rFilter, rFilterWithExtension ) );
    2220                 :            : 
    2221                 :          0 : }
    2222                 :            : 
    2223                 :          0 : OUString FileDialogHelper_Impl::getFilterName( const OUString& rFilterWithExtension ) const
    2224                 :            : {
    2225                 :          0 :     OUString sRet;
    2226 [ #  # ][ #  # ]:          0 :     for( ::std::vector< FilterPair >::const_iterator pIter = maFilters.begin(); pIter != maFilters.end(); ++pIter )
    2227                 :            :     {
    2228         [ #  # ]:          0 :         if ( (*pIter).Second == rFilterWithExtension )
    2229                 :            :         {
    2230                 :          0 :             sRet = (*pIter).First;
    2231                 :          0 :             break;
    2232                 :            :         }
    2233                 :            :     }
    2234                 :          0 :     return sRet;
    2235                 :            : }
    2236                 :            : 
    2237                 :          0 : OUString FileDialogHelper_Impl::getFilterWithExtension( const OUString& rFilter ) const
    2238                 :            : {
    2239                 :          0 :     OUString sRet;
    2240 [ #  # ][ #  # ]:          0 :     for( ::std::vector< FilterPair >::const_iterator pIter = maFilters.begin(); pIter != maFilters.end(); ++pIter )
    2241                 :            :     {
    2242         [ #  # ]:          0 :         if ( (*pIter).First == rFilter )
    2243                 :            :         {
    2244                 :          0 :             sRet = (*pIter).Second;
    2245                 :          0 :             break;
    2246                 :            :         }
    2247                 :            :     }
    2248                 :          0 :     return sRet;
    2249                 :            : }
    2250                 :            : 
    2251                 :          0 : void FileDialogHelper_Impl::SetContext( FileDialogHelper::Context _eNewContext )
    2252                 :            : {
    2253                 :          0 :     meContext = _eNewContext;
    2254                 :            : 
    2255                 :          0 :     const OUString* pConfigId = GetLastFilterConfigId( _eNewContext );
    2256         [ #  # ]:          0 :     if( pConfigId )
    2257                 :          0 :         LoadLastUsedFilter( *pConfigId );
    2258                 :          0 : }
    2259                 :            : 
    2260                 :            : // ------------------------------------------------------------------------
    2261                 :            : // -----------          FileDialogHelper        ---------------------------
    2262                 :            : // ------------------------------------------------------------------------
    2263                 :            : 
    2264                 :          0 : FileDialogHelper::FileDialogHelper(
    2265                 :            :     sal_Int16 nDialogType,
    2266                 :            :     sal_Int64 nFlags,
    2267                 :            :     const String& rFact,
    2268                 :            :     SfxFilterFlags nMust,
    2269                 :          0 :     SfxFilterFlags nDont )
    2270                 :            : {
    2271 [ #  # ][ #  # ]:          0 :     mpImp = new FileDialogHelper_Impl( this, nDialogType, nFlags );
         [ #  # ][ #  # ]
                 [ #  # ]
    2272 [ #  # ][ #  # ]:          0 :     mxImp = mpImp;
    2273                 :            : 
    2274                 :            :     // create the list of filters
    2275                 :            :     mpImp->addFilters(
    2276 [ #  # ][ #  # ]:          0 :             SfxObjectShell::GetServiceNameFromFactory(rFact), nMust, nDont );
                 [ #  # ]
    2277                 :          0 : }
    2278                 :            : 
    2279                 :            : // ------------------------------------------------------------------------
    2280                 :          0 : FileDialogHelper::FileDialogHelper(
    2281                 :            :     sal_Int16 nDialogType,
    2282                 :            :     sal_Int64 nFlags,
    2283                 :            :     const String& rFact,
    2284                 :            :     sal_Int16 nDialog,
    2285                 :            :     SfxFilterFlags nMust,
    2286                 :            :     SfxFilterFlags nDont,
    2287                 :            :     const String& rStandardDir,
    2288                 :          0 :     const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList)
    2289                 :            : {
    2290         [ #  # ]:          0 :     mpImp = new FileDialogHelper_Impl( this, nDialogType, nFlags, nDialog, NULL, rStandardDir, rBlackList );
    2291 [ #  # ][ #  # ]:          0 :     mxImp = mpImp;
    2292                 :            : 
    2293                 :            :     // create the list of filters
    2294                 :            :     mpImp->addFilters(
    2295 [ #  # ][ #  # ]:          0 :             SfxObjectShell::GetServiceNameFromFactory(rFact), nMust, nDont );
                 [ #  # ]
    2296                 :          0 : }
    2297                 :            : 
    2298                 :            : // ------------------------------------------------------------------------
    2299                 :          0 : FileDialogHelper::FileDialogHelper(
    2300                 :            :     sal_Int16 nDialogType,
    2301                 :            :     sal_Int64 nFlags,
    2302                 :          0 :     Window* _pPreferredParent )
    2303                 :            : {
    2304 [ #  # ][ #  # ]:          0 :     mpImp = new FileDialogHelper_Impl( this, nDialogType, nFlags, SFX2_IMPL_DIALOG_CONFIG, _pPreferredParent );
         [ #  # ][ #  # ]
                 [ #  # ]
    2305 [ #  # ][ #  # ]:          0 :     mxImp = mpImp;
    2306                 :          0 : }
    2307                 :            : 
    2308                 :            : // ------------------------------------------------------------------------
    2309                 :          0 : FileDialogHelper::FileDialogHelper(
    2310                 :            :     sal_Int16 nDialogType,
    2311                 :            :     sal_Int64 nFlags,
    2312                 :            :     const ::rtl::OUString& aFilterUIName,
    2313                 :            :     const ::rtl::OUString& aExtName,
    2314                 :            :     const ::rtl::OUString& rStandardDir,
    2315                 :            :     const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList,
    2316                 :          0 :     Window* _pPreferredParent )
    2317                 :            : {
    2318 [ #  # ][ #  # ]:          0 :     mpImp = new FileDialogHelper_Impl( this, nDialogType, nFlags, SFX2_IMPL_DIALOG_CONFIG, _pPreferredParent,rStandardDir, rBlackList );
                 [ #  # ]
    2319 [ #  # ][ #  # ]:          0 :     mxImp = mpImp;
    2320                 :            : 
    2321                 :            :     // the wildcard here is expected in form "*.extension"
    2322                 :          0 :     ::rtl::OUString aWildcard;
    2323         [ #  # ]:          0 :     if ( aExtName.indexOf( (sal_Unicode)'*' ) != 0 )
    2324                 :            :     {
    2325 [ #  # ][ #  # ]:          0 :         if ( !aExtName.isEmpty() && aExtName.indexOf( (sal_Unicode)'.' ) != 0 )
                 [ #  # ]
    2326                 :          0 :             aWildcard = ::rtl::OUString( "*."  );
    2327                 :            :         else
    2328                 :          0 :             aWildcard = ::rtl::OUString( "*"  );
    2329                 :            :     }
    2330                 :            : 
    2331                 :          0 :     aWildcard += aExtName;
    2332                 :            : 
    2333                 :            :     ::rtl::OUString const aUIString = ::sfx2::addExtension( aFilterUIName,
    2334         [ #  # ]:          0 :             aWildcard, (OPEN == lcl_OpenOrSave(mpImp->m_nDialogType)), *mpImp);
    2335 [ #  # ][ #  # ]:          0 :     AddFilter( aUIString, aWildcard );
         [ #  # ][ #  # ]
                 [ #  # ]
    2336                 :          0 : }
    2337                 :            : 
    2338                 :            : // ------------------------------------------------------------------------
    2339                 :          0 : FileDialogHelper::~FileDialogHelper()
    2340                 :            : {
    2341         [ #  # ]:          0 :     mpImp->dispose();
    2342                 :          0 :     mxImp.clear();
    2343         [ #  # ]:          0 : }
    2344                 :            : 
    2345                 :            : // ------------------------------------------------------------------------
    2346                 :          0 : void FileDialogHelper::CreateMatcher( const String& rFactory )
    2347                 :            : {
    2348         [ #  # ]:          0 :     mpImp->createMatcher( SfxObjectShell::GetServiceNameFromFactory(rFactory) );
    2349                 :          0 : }
    2350                 :            : 
    2351                 :            : // ------------------------------------------------------------------------
    2352                 :          0 : void FileDialogHelper::SetControlHelpIds( const sal_Int16* _pControlId, const char** _pHelpId )
    2353                 :            : {
    2354                 :          0 :     mpImp->setControlHelpIds( _pControlId, _pHelpId );
    2355                 :          0 : }
    2356                 :            : 
    2357                 :          0 : void FileDialogHelper::SetContext( Context _eNewContext )
    2358                 :            : {
    2359                 :          0 :     mpImp->SetContext( _eNewContext );
    2360                 :          0 : }
    2361                 :            : 
    2362                 :            : // ------------------------------------------------------------------------
    2363                 :          0 : IMPL_LINK_NOARG(FileDialogHelper, ExecuteSystemFilePicker)
    2364                 :            : {
    2365                 :          0 :     m_nError = mpImp->execute();
    2366         [ #  # ]:          0 :     if ( m_aDialogClosedLink.IsSet() )
    2367                 :          0 :         m_aDialogClosedLink.Call( this );
    2368                 :            : 
    2369                 :          0 :     return 0L;
    2370                 :            : }
    2371                 :            : 
    2372                 :            : // ------------------------------------------------------------------------
    2373                 :            : // rDirPath has to be a directory
    2374                 :          0 : ErrCode FileDialogHelper::Execute( std::vector<rtl::OUString>& rpURLList,
    2375                 :            :                                    SfxItemSet *&   rpSet,
    2376                 :            :                                    String&         rFilter,
    2377                 :            :                                    const String&   rDirPath )
    2378                 :            : {
    2379                 :          0 :     SetDisplayFolder( rDirPath );
    2380                 :          0 :     return mpImp->execute( rpURLList, rpSet, rFilter );
    2381                 :            : }
    2382                 :            : 
    2383                 :            : 
    2384                 :            : // ------------------------------------------------------------------------
    2385                 :          0 : ErrCode FileDialogHelper::Execute()
    2386                 :            : {
    2387                 :          0 :     return mpImp->execute();
    2388                 :            : }
    2389                 :            : 
    2390                 :            : // ------------------------------------------------------------------------
    2391                 :          0 : ErrCode FileDialogHelper::Execute( SfxItemSet *&   rpSet,
    2392                 :            :                                    String&         rFilter )
    2393                 :            : {
    2394                 :            :     ErrCode nRet;
    2395         [ #  # ]:          0 :     std::vector<rtl::OUString> rURLList;
    2396         [ #  # ]:          0 :     nRet = mpImp->execute(rURLList, rpSet, rFilter);
    2397                 :          0 :     return nRet;
    2398                 :            : }
    2399                 :            : 
    2400                 :          0 : void FileDialogHelper::StartExecuteModal( const Link& rEndDialogHdl )
    2401                 :            : {
    2402                 :          0 :     m_aDialogClosedLink = rEndDialogHdl;
    2403                 :          0 :     m_nError = ERRCODE_NONE;
    2404         [ #  # ]:          0 :     if ( mpImp->isSystemFilePicker() )
    2405         [ #  # ]:          0 :         Application::PostUserEvent( LINK( this, FileDialogHelper, ExecuteSystemFilePicker ) );
    2406                 :            :     else
    2407                 :          0 :         mpImp->implStartExecute();
    2408                 :          0 : }
    2409                 :            : 
    2410                 :            : // ------------------------------------------------------------------------
    2411                 :            : 
    2412                 :          0 : short FileDialogHelper::GetDialogType() const
    2413                 :            : {
    2414         [ #  # ]:          0 :     return mpImp ? mpImp->m_nDialogType : 0;
    2415                 :            : }
    2416                 :            : 
    2417                 :            : // ------------------------------------------------------------------------
    2418                 :            : 
    2419                 :          0 : sal_Bool FileDialogHelper::IsPasswordEnabled() const
    2420                 :            : {
    2421         [ #  # ]:          0 :     return mpImp ? mpImp->isPasswordEnabled() : sal_False;
    2422                 :            : }
    2423                 :            : 
    2424                 :            : // ------------------------------------------------------------------------
    2425                 :            : 
    2426                 :          0 : String FileDialogHelper::GetRealFilter() const
    2427                 :            : {
    2428                 :          0 :     String sFilter;
    2429         [ #  # ]:          0 :     if ( mpImp )
    2430         [ #  # ]:          0 :         mpImp->getRealFilter( sFilter );
    2431                 :          0 :     return sFilter;
    2432                 :            : }
    2433                 :            : 
    2434                 :            : // ------------------------------------------------------------------------
    2435                 :          0 : void FileDialogHelper::SetTitle( const String& rNewTitle )
    2436                 :            : {
    2437         [ #  # ]:          0 :     if ( mpImp->mxFileDlg.is() )
    2438         [ #  # ]:          0 :         mpImp->mxFileDlg->setTitle( rNewTitle );
    2439                 :          0 : }
    2440                 :            : 
    2441                 :            : // ------------------------------------------------------------------------
    2442                 :          0 : String FileDialogHelper::GetPath() const
    2443                 :            : {
    2444                 :          0 :     OUString aPath;
    2445                 :            : 
    2446         [ #  # ]:          0 :     if ( mpImp->mlLastURLs.size() > 0)
    2447         [ #  # ]:          0 :         return mpImp->mlLastURLs[0];
    2448                 :            : 
    2449         [ #  # ]:          0 :     if ( mpImp->mxFileDlg.is() )
    2450                 :            :     {
    2451 [ #  # ][ #  # ]:          0 :         Sequence < OUString > aPathSeq = mpImp->mxFileDlg->getFiles();
    2452                 :            : 
    2453         [ #  # ]:          0 :         if ( aPathSeq.getLength() == 1 )
    2454                 :            :         {
    2455         [ #  # ]:          0 :             aPath = aPathSeq[0];
    2456         [ #  # ]:          0 :         }
    2457                 :            :     }
    2458                 :            : 
    2459         [ #  # ]:          0 :     return aPath;
    2460                 :            : }
    2461                 :            : 
    2462                 :            : // ------------------------------------------------------------------------
    2463                 :          0 : Sequence < OUString > FileDialogHelper::GetMPath() const
    2464                 :            : {
    2465         [ #  # ]:          0 :     if ( mpImp->mlLastURLs.size() > 0)
    2466                 :          0 :         return mpImp->mlLastURLs.getAsConstList();
    2467                 :            : 
    2468         [ #  # ]:          0 :     if ( mpImp->mxFileDlg.is() )
    2469                 :          0 :         return mpImp->mxFileDlg->getFiles();
    2470                 :            :     else
    2471                 :            :     {
    2472         [ #  # ]:          0 :         Sequence < OUString > aEmpty;
    2473 [ #  # ][ #  # ]:          0 :         return aEmpty;
    2474                 :            :     }
    2475                 :            : }
    2476                 :            : 
    2477                 :            : // ------------------------------------------------------------------------
    2478                 :          0 : Sequence< ::rtl::OUString > FileDialogHelper::GetSelectedFiles() const
    2479                 :            : {
    2480                 :            :     // a) the new way (optional!)
    2481         [ #  # ]:          0 :     uno::Sequence< ::rtl::OUString > aResultSeq;
    2482         [ #  # ]:          0 :     uno::Reference< XFilePicker2 > xPickNew(mpImp->mxFileDlg, UNO_QUERY);
    2483         [ #  # ]:          0 :     if (xPickNew.is())
    2484                 :            :     {
    2485 [ #  # ][ #  # ]:          0 :         aResultSeq = xPickNew->getSelectedFiles();
         [ #  # ][ #  # ]
    2486                 :            :     }
    2487                 :            :     // b) the olde way ... non optional.
    2488                 :            :     else
    2489                 :            :     {
    2490         [ #  # ]:          0 :         uno::Reference< XFilePicker > xPickOld(mpImp->mxFileDlg, UNO_QUERY_THROW);
    2491 [ #  # ][ #  # ]:          0 :         Sequence< OUString > lFiles = xPickOld->getFiles();
    2492                 :          0 :         ::sal_Int32          nFiles = lFiles.getLength();
    2493         [ #  # ]:          0 :         if ( nFiles > 1 )
    2494                 :            :         {
    2495 [ #  # ][ #  # ]:          0 :             aResultSeq = Sequence< ::rtl::OUString >( nFiles-1 );
                 [ #  # ]
    2496                 :            : 
    2497 [ #  # ][ #  # ]:          0 :             INetURLObject aPath( lFiles[0] );
    2498         [ #  # ]:          0 :             aPath.setFinalSlash();
    2499                 :            : 
    2500         [ #  # ]:          0 :             for (::sal_Int32 i = 1; i < nFiles; i++)
    2501                 :            :             {
    2502         [ #  # ]:          0 :                 if (i == 1)
    2503 [ #  # ][ #  # ]:          0 :                     aPath.Append( lFiles[i] );
    2504                 :            :                 else
    2505 [ #  # ][ #  # ]:          0 :                     aPath.setName( lFiles[i] );
    2506                 :            : 
    2507 [ #  # ][ #  # ]:          0 :                 aResultSeq[i-1] = ::rtl::OUString(aPath.GetMainURL( INetURLObject::NO_DECODE ));
    2508         [ #  # ]:          0 :             }
    2509                 :            :         }
    2510                 :            :         else
    2511 [ #  # ][ #  # ]:          0 :             aResultSeq = lFiles;
    2512                 :            :     }
    2513                 :            : 
    2514                 :          0 :     return aResultSeq;
    2515                 :            : }
    2516                 :            : 
    2517                 :            : // ------------------------------------------------------------------------
    2518                 :          0 : String FileDialogHelper::GetDisplayDirectory() const
    2519                 :            : {
    2520         [ #  # ]:          0 :     return mpImp->getPath();
    2521                 :            : }
    2522                 :            : 
    2523                 :            : // ------------------------------------------------------------------------
    2524                 :          0 : String FileDialogHelper::GetCurrentFilter() const
    2525                 :            : {
    2526         [ #  # ]:          0 :     return mpImp->getFilter();
    2527                 :            : }
    2528                 :            : 
    2529                 :            : // ------------------------------------------------------------------------
    2530                 :          0 : ErrCode FileDialogHelper::GetGraphic( Graphic& rGraphic ) const
    2531                 :            : {
    2532                 :          0 :     return mpImp->getGraphic( rGraphic );
    2533                 :            : }
    2534                 :            : 
    2535                 :            : // ------------------------------------------------------------------------
    2536                 :          0 : static int impl_isFolder( const OUString& rPath )
    2537                 :            : {
    2538                 :            :     try
    2539                 :            :     {
    2540                 :            :         ::ucbhelper::Content aContent(
    2541         [ #  # ]:          0 :             rPath, uno::Reference< ucb::XCommandEnvironment > () );
    2542 [ #  # ][ #  # ]:          0 :         if ( aContent.isFolder() )
    2543                 :          0 :             return 1;
    2544                 :            : 
    2545 [ #  # ][ #  # ]:          0 :         return 0;
    2546                 :            :     }
    2547                 :          0 :     catch ( const Exception & )
    2548                 :            :     {
    2549                 :            :     }
    2550                 :            : 
    2551                 :          0 :     return -1;
    2552                 :            : }
    2553                 :            : 
    2554                 :          0 : void FileDialogHelper::SetDisplayDirectory( const String& _rPath )
    2555                 :            : {
    2556         [ #  # ]:          0 :     if ( !_rPath.Len() )
    2557                 :          0 :         return;
    2558                 :            : 
    2559                 :            :     // if the given path isn't a folder, we cut off the last part
    2560                 :            :     // and take it as filename and the rest of the path should be
    2561                 :            :     // the folder
    2562                 :            : 
    2563 [ #  # ][ #  # ]:          0 :     INetURLObject aObj( _rPath );
    2564                 :            : 
    2565         [ #  # ]:          0 :     ::rtl::OUString sFileName = aObj.GetName( INetURLObject::DECODE_WITH_CHARSET );
    2566         [ #  # ]:          0 :     aObj.removeSegment();
    2567         [ #  # ]:          0 :     ::rtl::OUString sPath = aObj.GetMainURL( INetURLObject::NO_DECODE );
    2568                 :            : 
    2569 [ #  # ][ #  # ]:          0 :     int nIsFolder = impl_isFolder( _rPath );
    2570 [ #  # ][ #  # ]:          0 :     if ( nIsFolder == 0 ||
         [ #  # ][ #  # ]
    2571         [ #  # ]:          0 :          ( nIsFolder == -1 && impl_isFolder( sPath ) == 1 ) )
    2572                 :            :     {
    2573         [ #  # ]:          0 :         mpImp->setFileName( sFileName );
    2574         [ #  # ]:          0 :         mpImp->displayFolder( sPath );
    2575                 :            :     }
    2576                 :            :     else
    2577                 :            :     {
    2578 [ #  # ][ #  # ]:          0 :         INetURLObject aObjPathName( _rPath );
    2579         [ #  # ]:          0 :         ::rtl::OUString sFolder( aObjPathName.GetMainURL( INetURLObject::NO_DECODE ) );
    2580         [ #  # ]:          0 :         if ( sFolder.isEmpty() )
    2581                 :            :         {
    2582                 :            :             // _rPath is not a valid path -> fallback to home directory
    2583         [ #  # ]:          0 :             osl::Security aSecurity;
    2584 [ #  # ][ #  # ]:          0 :             aSecurity.getHomeDir( sFolder );
    2585                 :            :         }
    2586 [ #  # ][ #  # ]:          0 :         mpImp->displayFolder( sFolder );
    2587         [ #  # ]:          0 :     }
    2588                 :            : }
    2589                 :            : 
    2590                 :            : // ------------------------------------------------------------------------
    2591                 :          0 : void FileDialogHelper::SetDisplayFolder( const String& _rURL )
    2592                 :            : {
    2593         [ #  # ]:          0 :     mpImp->displayFolder( _rURL );
    2594                 :          0 : }
    2595                 :            : 
    2596                 :            : // ------------------------------------------------------------------------
    2597                 :          0 : void FileDialogHelper::SetFileName( const String& _rFileName )
    2598                 :            : {
    2599         [ #  # ]:          0 :     mpImp->setFileName( _rFileName );
    2600                 :          0 : }
    2601                 :            : 
    2602                 :            : // ------------------------------------------------------------------------
    2603                 :          0 : void FileDialogHelper::AddFilter( const String& rFilterName,
    2604                 :            :                                   const String& rExtension )
    2605                 :            : {
    2606 [ #  # ][ #  # ]:          0 :     mpImp->addFilter( rFilterName, rExtension );
    2607                 :          0 : }
    2608                 :            : 
    2609                 :            : // ------------------------------------------------------------------------
    2610                 :          0 : void FileDialogHelper::SetCurrentFilter( const String& rFilter )
    2611                 :            : {
    2612         [ #  # ]:          0 :     String sFilter( rFilter );
    2613         [ #  # ]:          0 :     if ( mpImp->isShowFilterExtensionEnabled() )
    2614 [ #  # ][ #  # ]:          0 :         sFilter = mpImp->getFilterWithExtension( rFilter );
                 [ #  # ]
    2615 [ #  # ][ #  # ]:          0 :     mpImp->setFilter( sFilter );
                 [ #  # ]
    2616                 :          0 : }
    2617                 :            : 
    2618                 :            : // ------------------------------------------------------------------------
    2619                 :          0 : uno::Reference < XFilePicker > FileDialogHelper::GetFilePicker() const
    2620                 :            : {
    2621                 :          0 :     return mpImp->mxFileDlg;
    2622                 :            : }
    2623                 :            : 
    2624                 :            : // ------------------------------------------------------------------------
    2625                 :            : // XFilePickerListener Methods
    2626                 :            : // ------------------------------------------------------------------------
    2627                 :          0 : void SAL_CALL FileDialogHelper::FileSelectionChanged( const FilePickerEvent& aEvent )
    2628                 :            : {
    2629                 :          0 :     mpImp->handleFileSelectionChanged( aEvent );
    2630                 :          0 : }
    2631                 :            : 
    2632                 :            : // ------------------------------------------------------------------------
    2633                 :          0 : void SAL_CALL FileDialogHelper::DirectoryChanged( const FilePickerEvent& aEvent )
    2634                 :            : {
    2635                 :          0 :     mpImp->handleDirectoryChanged( aEvent );
    2636                 :          0 : }
    2637                 :            : 
    2638                 :            : // ------------------------------------------------------------------------
    2639                 :          0 : OUString SAL_CALL FileDialogHelper::HelpRequested( const FilePickerEvent& aEvent )
    2640                 :            : {
    2641                 :          0 :     return mpImp->handleHelpRequested( aEvent );
    2642                 :            : }
    2643                 :            : 
    2644                 :            : // ------------------------------------------------------------------------
    2645                 :          0 : void SAL_CALL FileDialogHelper::ControlStateChanged( const FilePickerEvent& aEvent )
    2646                 :            : {
    2647                 :          0 :     mpImp->handleControlStateChanged( aEvent );
    2648                 :          0 : }
    2649                 :            : 
    2650                 :            : // ------------------------------------------------------------------------
    2651                 :          0 : void SAL_CALL FileDialogHelper::DialogSizeChanged()
    2652                 :            : {
    2653                 :          0 :     mpImp->handleDialogSizeChanged();
    2654                 :          0 : }
    2655                 :            : 
    2656                 :            : // ------------------------------------------------------------------------
    2657                 :          0 : void SAL_CALL FileDialogHelper::DialogClosed( const DialogClosedEvent& _rEvent )
    2658                 :            : {
    2659         [ #  # ]:          0 :     m_nError = ( RET_OK == _rEvent.DialogResult ) ? ERRCODE_NONE : ERRCODE_ABORT;
    2660         [ #  # ]:          0 :     if ( m_aDialogClosedLink.IsSet() )
    2661                 :          0 :         m_aDialogClosedLink.Call( this );
    2662                 :          0 : }
    2663                 :            : 
    2664                 :            : // ------------------------------------------------------------------------
    2665                 :            : 
    2666                 :          0 : ErrCode FileOpenDialog_Impl( sal_Int16 nDialogType,
    2667                 :            :                              sal_Int64 nFlags,
    2668                 :            :                              const String& rFact,
    2669                 :            :                              std::vector<rtl::OUString>& rpURLList,
    2670                 :            :                              String& rFilter,
    2671                 :            :                              SfxItemSet *& rpSet,
    2672                 :            :                              const String* pPath,
    2673                 :            :                              sal_Int16 nDialog,
    2674                 :            :                              const String& rStandardDir,
    2675                 :            :                              const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList )
    2676                 :            : {
    2677                 :            :     ErrCode nRet;
    2678                 :            :     FileDialogHelper aDialog( nDialogType, nFlags,
    2679         [ #  # ]:          0 :             rFact, nDialog, 0, 0, rStandardDir, rBlackList );
    2680                 :            : 
    2681         [ #  # ]:          0 :     String aPath;
    2682         [ #  # ]:          0 :     if ( pPath )
    2683         [ #  # ]:          0 :         aPath = *pPath;
    2684                 :            : 
    2685         [ #  # ]:          0 :     nRet = aDialog.Execute( rpURLList, rpSet, rFilter, aPath );
    2686                 :            :     DBG_ASSERT( rFilter.SearchAscii(": ") == STRING_NOTFOUND, "Old filter name used!");
    2687                 :            : 
    2688 [ #  # ][ #  # ]:          0 :     return nRet;
    2689                 :            : }
    2690                 :            : 
    2691                 :          0 : ErrCode RequestPassword(const SfxFilter* pCurrentFilter, rtl::OUString& aURL, SfxItemSet* pSet)
    2692                 :            : {
    2693 [ #  # ][ #  # ]:          0 :     uno::Reference < ::com::sun::star::task::XInteractionHandler > xInteractionHandler( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString("com.sun.star.comp.uui.UUIInteractionHandler")), UNO_QUERY );
         [ #  # ][ #  # ]
    2694         [ #  # ]:          0 :     if( xInteractionHandler.is() )
    2695                 :            :     {
    2696                 :            :         // TODO: need a save way to distinguish MS filters from other filters
    2697                 :            :         // for now MS-filters are the only alien filters that support encryption
    2698                 :          0 :         sal_Bool bMSType = !pCurrentFilter->IsOwnFormat();
    2699                 :            :         ::comphelper::DocPasswordRequestType eType = bMSType ?
    2700                 :            :             ::comphelper::DocPasswordRequestType_MS :
    2701         [ #  # ]:          0 :             ::comphelper::DocPasswordRequestType_STANDARD;
    2702                 :            : 
    2703         [ #  # ]:          0 :         ::rtl::Reference< ::comphelper::DocPasswordRequest > pPasswordRequest( new ::comphelper::DocPasswordRequest( eType, ::com::sun::star::task::PasswordRequestMode_PASSWORD_CREATE, aURL, ( pCurrentFilter->GetFilterFlags() & SFX_FILTER_PASSWORDTOMODIFY ) != 0 ) );
    2704                 :            : 
    2705         [ #  # ]:          0 :         uno::Reference< com::sun::star::task::XInteractionRequest > rRequest( pPasswordRequest.get() );
    2706 [ #  # ][ #  # ]:          0 :         xInteractionHandler->handle( rRequest );
    2707 [ #  # ][ #  # ]:          0 :         if ( pPasswordRequest->isPassword() )
    2708                 :            :         {
    2709 [ #  # ][ #  # ]:          0 :             if ( pPasswordRequest->getPassword().getLength() )
    2710                 :            :             {
    2711                 :            :                 // TODO/LATER: The filters should show the password dialog themself in future
    2712         [ #  # ]:          0 :                 if ( bMSType )
    2713                 :            :                 {
    2714                 :            :                     // all the current MS-filters use MSCodec_Std97 implementation
    2715         [ #  # ]:          0 :                     uno::Sequence< sal_Int8 > aUniqueID = ::comphelper::DocPasswordHelper::GenerateRandomByteSequence( 16 );
    2716 [ #  # ][ #  # ]:          0 :                     uno::Sequence< sal_Int8 > aEncryptionKey = ::comphelper::DocPasswordHelper::GenerateStd97Key( pPasswordRequest->getPassword(), aUniqueID );
    2717                 :            : 
    2718         [ #  # ]:          0 :                     if ( aEncryptionKey.getLength() )
    2719                 :            :                     {
    2720         [ #  # ]:          0 :                         ::comphelper::SequenceAsHashMap aHashData;
    2721 [ #  # ][ #  # ]:          0 :                         aHashData[ ::rtl::OUString( "STD97EncryptionKey"  ) ] <<= aEncryptionKey;
    2722 [ #  # ][ #  # ]:          0 :                         aHashData[ ::rtl::OUString( "STD97UniqueID"  ) ] <<= aUniqueID;
    2723                 :            : 
    2724 [ #  # ][ #  # ]:          0 :                         pSet->Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, uno::makeAny( aHashData.getAsConstNamedValueList() ) ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    2725                 :            :                     }
    2726                 :            :                     else
    2727 [ #  # ][ #  # ]:          0 :                         return ERRCODE_IO_NOTSUPPORTED;
         [ #  # ][ #  # ]
    2728                 :            :                 }
    2729                 :            :                 else
    2730                 :            :                 {
    2731 [ #  # ][ #  # ]:          0 :                     pSet->Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, uno::makeAny( ::comphelper::OStorageHelper::CreatePackageEncryptionData( pPasswordRequest->getPassword() ) ) ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    2732                 :            :                 }
    2733                 :            :             }
    2734                 :            : 
    2735 [ #  # ][ #  # ]:          0 :             if ( pPasswordRequest->getRecommendReadOnly() )
    2736 [ #  # ][ #  # ]:          0 :                 pSet->Put( SfxBoolItem( SID_RECOMMENDREADONLY, sal_True ) );
                 [ #  # ]
    2737                 :            : 
    2738         [ #  # ]:          0 :             if ( bMSType )
    2739                 :            :             {
    2740                 :            :                 // the empty password has 0 as Hash
    2741 [ #  # ][ #  # ]:          0 :                 sal_Int32 nHash = SfxMedium::CreatePasswordToModifyHash( pPasswordRequest->getPasswordToModify(), ::rtl::OUString( "com.sun.star.text.TextDocument"  ).equals( pCurrentFilter->GetServiceName() ) );
    2742         [ #  # ]:          0 :                 if ( nHash )
    2743 [ #  # ][ #  # ]:          0 :                     pSet->Put( SfxUnoAnyItem( SID_MODIFYPASSWORDINFO, uno::makeAny( nHash ) ) );
         [ #  # ][ #  # ]
    2744                 :            :             }
    2745                 :            :             else
    2746                 :            :             {
    2747 [ #  # ][ #  # ]:          0 :                 uno::Sequence< beans::PropertyValue > aModifyPasswordInfo = ::comphelper::DocPasswordHelper::GenerateNewModifyPasswordInfo( pPasswordRequest->getPasswordToModify() );
    2748         [ #  # ]:          0 :                 if ( aModifyPasswordInfo.getLength() )
    2749 [ #  # ][ #  # ]:          0 :                     pSet->Put( SfxUnoAnyItem( SID_MODIFYPASSWORDINFO, uno::makeAny( aModifyPasswordInfo ) ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    2750                 :            :             }
    2751                 :            :         }
    2752                 :            :         else
    2753 [ #  # ][ #  # ]:          0 :             return ERRCODE_ABORT;
    2754                 :            :     }
    2755                 :          0 :     return ERRCODE_NONE;
    2756                 :            : }
    2757                 :            : 
    2758                 :            : // ------------------------------------------------------------------------
    2759                 :          0 : String EncodeSpaces_Impl( const String& rSource )
    2760                 :            : {
    2761                 :          0 :     String sRet( rSource );
    2762 [ #  # ][ #  # ]:          0 :     sRet.SearchAndReplaceAll( DEFINE_CONST_UNICODE( " " ), DEFINE_CONST_UNICODE( "%20" ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    2763                 :          0 :     return sRet;
    2764                 :            : }
    2765                 :            : 
    2766                 :            : // ------------------------------------------------------------------------
    2767                 :          0 : String DecodeSpaces_Impl( const String& rSource )
    2768                 :            : {
    2769                 :          0 :     String sRet( rSource );
    2770 [ #  # ][ #  # ]:          0 :     sRet.SearchAndReplaceAll( DEFINE_CONST_UNICODE( "%20" ), DEFINE_CONST_UNICODE( " " ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    2771                 :          0 :     return sRet;
    2772                 :            : }
    2773                 :            : 
    2774                 :            : // ------------------------------------------------------------------------
    2775                 :            : 
    2776                 :            : }   // end of namespace sfx2
    2777                 :            : 
    2778                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10