LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/fpicker/source/office - iodlg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 1533 0.0 %
Date: 2013-07-09 Functions: 0 119 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <sal/macros.h>
      21             : #include "iodlg.hxx"
      22             : #include <svtools/PlaceEditDialog.hxx>
      23             : #include "PlacesListBox.hxx"
      24             : #include "fpsofficeResMgr.hxx"
      25             : #include <tools/stream.hxx>
      26             : #include <tools/urlobj.hxx>
      27             : #include <vcl/fixed.hxx>
      28             : #include <vcl/lstbox.hxx>
      29             : #include <vcl/msgbox.hxx>
      30             : #include <vcl/svapp.hxx>
      31             : #include <vcl/timer.hxx>
      32             : #include <unotools/ucbhelper.hxx>
      33             : #include "svtools/ehdl.hxx"
      34             : #include "svl/urihelper.hxx"
      35             : #include "unotools/pathoptions.hxx"
      36             : #include "unotools/viewoptions.hxx"
      37             : #include "svtools/fileview.hxx"
      38             : #include "svtools/sfxecode.hxx"
      39             : #include "svtools/svtabbx.hxx"
      40             : #include "svtools/treelistentry.hxx"
      41             : #include <toolkit/helper/vclunohelper.hxx>
      42             : #include <unotools/localfilehelper.hxx>
      43             : 
      44             : #include "svtools/helpid.hrc"
      45             : #include <svtools/svtools.hrc>
      46             : #include "OfficeFilePicker.hrc"
      47             : #include "iodlg.hrc"
      48             : #include "asyncfilepicker.hxx"
      49             : #include "iodlgimp.hxx"
      50             : #include "svtools/inettbc.hxx"
      51             : #include "unotools/syslocale.hxx"
      52             : #include "svtools/QueryFolderName.hxx"
      53             : #include <rtl/ustring.hxx>
      54             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      55             : #include <com/sun/star/ucb/UniversalContentBroker.hpp>
      56             : #include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
      57             : #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
      58             : #include <com/sun/star/ui/dialogs/ControlActions.hpp>
      59             : #include <com/sun/star/beans/PropertyValue.hpp>
      60             : #include <com/sun/star/sdbc/XResultSet.hpp>
      61             : #include <com/sun/star/sdbc/XRow.hpp>
      62             : #include <com/sun/star/util/URL.hpp>
      63             : #include <com/sun/star/uno/Exception.hpp>
      64             : #include <com/sun/star/uno/Reference.hxx>
      65             : #include <com/sun/star/util/XURLTransformer.hpp>
      66             : #include <com/sun/star/uno/RuntimeException.hpp>
      67             : #include <com/sun/star/beans/XPropertySet.hpp>
      68             : 
      69             : #include <comphelper/interaction.hxx>
      70             : #include <comphelper/processfactory.hxx>
      71             : #include <comphelper/string.hxx>
      72             : 
      73             : #include <osl/file.h>
      74             : #include <vcl/dibtools.hxx>
      75             : #include <vcl/waitobj.hxx>
      76             : 
      77             : #include <com/sun/star/task/InteractionHandler.hpp>
      78             : #include "com/sun/star/ucb/InteractiveAugmentedIOException.hpp"
      79             : #include "fpinteraction.hxx"
      80             : #include <osl/process.h>
      81             : 
      82             : #include <officecfg/Office/Common.hxx>
      83             : 
      84             : #include <algorithm>
      85             : #include <functional>
      86             : #include <vector>
      87             : 
      88             : //#define AUTOSELECT_USERFILTER
      89             :     // define this for the experimental feature of user-filter auto selection
      90             :     // means if the user enters e.g. *.doc<enter>, and there is a filter which is responsible for *.doc files (only),
      91             :     // then this filter is selected automatically
      92             : 
      93             : using namespace ::com::sun::star::beans;
      94             : using namespace ::com::sun::star::frame;
      95             : using namespace ::com::sun::star::ui::dialogs;
      96             : using namespace ::com::sun::star::uno;
      97             : using namespace ::com::sun::star::lang;
      98             : using namespace ::com::sun::star::ucb;
      99             : using namespace ::com::sun::star::container;
     100             : using namespace ::com::sun::star::task;
     101             : using namespace ::com::sun::star::sdbc;
     102             : using namespace ::utl;
     103             : using namespace ::svt;
     104             : 
     105             : using namespace ExtendedFilePickerElementIds;
     106             : using namespace CommonFilePickerElementIds;
     107             : using namespace InternalFilePickerElementIds;
     108             : 
     109             : #define IODLG_CONFIGNAME        OUString("FileDialog")
     110             : #define IMPGRF_CONFIGNAME       OUString("ImportGraphicDialog")
     111             : 
     112             : #define GET_DECODED_NAME(aObj) \
     113             :     aObj.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET )
     114             : 
     115             : // Time to wait while traveling in the filterbox until
     116             : // the browsebox gets filtered ( in ms).
     117             : #define TRAVELFILTER_TIMEOUT    750
     118             : 
     119             : #define WIDTH_ADDITION  15
     120             : 
     121             : // functions -------------------------------------------------------------
     122             : 
     123             : namespace
     124             : {
     125             : 
     126             :     //-----------------------------------------------------------------------------
     127           0 :     String getMostCurrentFilter( SvtExpFileDlg_Impl* pImpl )
     128             :     {
     129             :         DBG_ASSERT( pImpl, "invalid impl pointer" );
     130           0 :         const SvtFileDialogFilter_Impl* pFilter = pImpl->_pUserFilter;
     131             : 
     132           0 :         if ( !pFilter )
     133           0 :             pFilter = pImpl->GetCurFilter();
     134             : 
     135           0 :         if ( !pFilter )
     136           0 :             return String();
     137             : 
     138           0 :         return pFilter->GetType();
     139             :     }
     140             : 
     141             :     //-----------------------------------------------------------------------------
     142           0 :     sal_Bool restoreCurrentFilter( SvtExpFileDlg_Impl* _pImpl )
     143             :     {
     144             :         DBG_ASSERT( _pImpl->GetCurFilter(), "restoreCurrentFilter: no current filter!" );
     145             :         DBG_ASSERT( _pImpl->GetCurFilterDisplayName().Len(), "restoreCurrentFilter: no current filter (no display name)!" );
     146             : 
     147           0 :         _pImpl->SelectFilterListEntry( _pImpl->GetCurFilterDisplayName() );
     148             : 
     149             : #ifdef DBG_UTIL
     150             :         String sSelectedDisplayName;
     151             :         DBG_ASSERT( ( _pImpl->GetSelectedFilterEntry( sSelectedDisplayName ) == _pImpl->GetCurFilter() )
     152             :                 &&  ( sSelectedDisplayName == _pImpl->GetCurFilterDisplayName() ),
     153             :             "restoreCurrentFilter: inconsistence!" );
     154             : #endif
     155           0 :         return _pImpl->m_bNeedDelayedFilterExecute;
     156             :     }
     157             : 
     158             :     //-----------------------------------------------------------------------------
     159           0 :     String GetFsysExtension_Impl( const String& rFile, const String& rLastFilterExt )
     160             :     {
     161           0 :         xub_StrLen nDotPos = rFile.SearchBackward( '.' );
     162           0 :         if ( nDotPos != STRING_NOTFOUND )
     163             :         {
     164           0 :             if ( rLastFilterExt.Len() )
     165             :             {
     166           0 :                 if ( rFile.Copy( nDotPos + 1 ).EqualsIgnoreCaseAscii( rLastFilterExt ) )
     167           0 :                     return String( rLastFilterExt );
     168             :             }
     169             :             else
     170           0 :                 return String( rFile.Copy( nDotPos ) );
     171             :         }
     172           0 :         return String();
     173             :     }
     174             : 
     175             :     //-----------------------------------------------------------------------------
     176           0 :     void SetFsysExtension_Impl( String& rFile, const String& rExtension )
     177             :     {
     178           0 :         const sal_Unicode* p0 = rFile.GetBuffer();
     179           0 :         const sal_Unicode* p1 = p0 + rFile.Len() - 1;
     180           0 :         while ( p1 >= p0 && *p1 != sal_Unicode( '.' ) )
     181           0 :             p1--;
     182           0 :         if ( p1 >= p0 )
     183             :             // remove old extension
     184             :             rFile.Erase(
     185             :                 sal::static_int_cast< xub_StrLen >(
     186           0 :                     p1 - p0 + 1 - ( rExtension.Len() > 0 ? 0 : 1 ) ) );
     187           0 :         else if ( rExtension.Len() )
     188             :             // no old extension
     189           0 :             rFile += sal_Unicode( '.' );
     190           0 :         rFile += rExtension;
     191           0 :     }
     192             : 
     193             :     //-----------------------------------------------------------------------------
     194             :     // move the control with the given offset
     195           0 :     void lcl_MoveControl( Control* _pControl, sal_Int32 _nDeltaX, sal_Int32 _nDeltaY, sal_Int32* _pMaxY = NULL )
     196             :     {
     197           0 :         if ( _pControl )
     198             :         {
     199           0 :             Point aNewPos = _pControl->GetPosPixel();
     200             : 
     201             :             // adjust the vertical position
     202           0 :             aNewPos.Y() += _nDeltaY;
     203           0 :             if ( _pMaxY && ( aNewPos.Y() > *_pMaxY ) )
     204           0 :                 *_pMaxY = aNewPos.Y();
     205             : 
     206             :             // adjust the horizontal position
     207           0 :             aNewPos.X() += _nDeltaX;
     208             : 
     209           0 :             _pControl->SetPosPixel( aNewPos );
     210             :         }
     211           0 :     }
     212             : 
     213             :     //-------------------------------------------------------------------------
     214           0 :     void lcl_autoUpdateFileExtension( SvtFileDialog* _pDialog, const String& _rLastFilterExt )
     215             :     {
     216             :         // if auto extension is enabled ....
     217           0 :         if ( _pDialog->isAutoExtensionEnabled() )
     218             :         {
     219             :             // automatically switch to the extension of the (maybe just newly selected) extension
     220           0 :             String aNewFile = _pDialog->getCurrentFileText( );
     221           0 :             String aExt = GetFsysExtension_Impl( aNewFile, _rLastFilterExt );
     222             : 
     223             :             // but only if there already is an extension
     224           0 :             if ( aExt.Len() )
     225             :             {
     226             :                 // check if it is a real file extension, and not only the "post-dot" part in
     227             :                 // a directory name
     228           0 :                 sal_Bool bRealExtensions = sal_True;
     229           0 :                 if ( STRING_NOTFOUND != aExt.Search( '/' ) )
     230           0 :                     bRealExtensions = sal_False;
     231           0 :                 else if ( STRING_NOTFOUND != aExt.Search( '\\' ) )
     232           0 :                     bRealExtensions = sal_False;
     233             :                 else
     234             :                 {
     235             :                     // no easy way to tell, because the part containing the dot already is the last
     236             :                     // segment of the complete file name
     237             :                     // So we have to check if the file name denotes a folder or a file.
     238             :                     // For performance reasons, we do this for file urls only
     239           0 :                     INetURLObject aURL( aNewFile );
     240           0 :                     if ( INET_PROT_NOT_VALID == aURL.GetProtocol() )
     241             :                     {
     242           0 :                         OUString sURL;
     243           0 :                         if ( ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aNewFile, sURL ) )
     244           0 :                             aURL = INetURLObject( sURL );
     245             :                     }
     246           0 :                     if ( INET_PROT_FILE == aURL.GetProtocol() )
     247             :                     {
     248             :                         try
     249             :                         {
     250           0 :                             bRealExtensions = !_pDialog->ContentIsFolder( aURL.GetMainURL( INetURLObject::NO_DECODE ) );
     251             :                         }
     252           0 :                         catch( const ::com::sun::star::uno::Exception& )
     253             :                         {
     254             :                             DBG_WARNING( "Exception in lcl_autoUpdateFileExtension" );
     255             :                         }
     256           0 :                     }
     257             :                 }
     258             : 
     259           0 :                 if ( bRealExtensions )
     260             :                 {
     261           0 :                     SetFsysExtension_Impl( aNewFile, _pDialog->GetDefaultExt() );
     262           0 :                     _pDialog->setCurrentFileText( aNewFile );
     263             :                 }
     264           0 :             }
     265             :         }
     266           0 :     }
     267             : 
     268             :     //-------------------------------------------------------------------------
     269           0 :     sal_Bool lcl_getHomeDirectory( const String& _rForURL, String& /* [out] */ _rHomeDir )
     270             :     {
     271           0 :         _rHomeDir.Erase();
     272             : 
     273             :         // now ask the content broker for a provider for this scheme
     274             :         //=================================================================
     275             :         try
     276             :         {
     277             :             // get the provider for the current scheme
     278             :             Reference< XContentProvider > xProvider(
     279             :                 UniversalContentBroker::create(
     280           0 :                     comphelper::getProcessComponentContext() )->
     281           0 :                 queryContentProvider( _rForURL ) );
     282             : 
     283             :             DBG_ASSERT( xProvider.is(), "lcl_getHomeDirectory: could not find a (valid) content provider for the current URL!" );
     284           0 :             Reference< XPropertySet > xProviderProps( xProvider, UNO_QUERY );
     285           0 :             if ( xProviderProps.is() )
     286             :             {
     287           0 :                 Reference< XPropertySetInfo > xPropInfo = xProviderProps->getPropertySetInfo();
     288           0 :                 const OUString sHomeDirPropertyName( "HomeDirectory" );
     289           0 :                 if ( !xPropInfo.is() || xPropInfo->hasPropertyByName( sHomeDirPropertyName ) )
     290             :                 {
     291           0 :                     OUString sHomeDirectory;
     292           0 :                     xProviderProps->getPropertyValue( sHomeDirPropertyName ) >>= sHomeDirectory;
     293           0 :                     _rHomeDir = sHomeDirectory;
     294           0 :                 }
     295           0 :             }
     296             :         }
     297           0 :         catch( const Exception& )
     298             :         {
     299             :             OSL_FAIL( "lcl_getHomeDirectory: caught an exception!" );
     300             :         }
     301           0 :         return 0 < _rHomeDir.Len();
     302             :     }
     303             : 
     304             :     //---------------------------------------------------------------------
     305           0 :     static String lcl_ensureFinalSlash( const String& _rDir )
     306             :     {
     307           0 :         INetURLObject aWorkPathObj( _rDir, INET_PROT_FILE );
     308           0 :         aWorkPathObj.setFinalSlash();
     309           0 :         return  aWorkPathObj.GetMainURL( INetURLObject::NO_DECODE );
     310             :     }
     311             : 
     312             :     //---------------------------------------------------------------------
     313             :     struct RemoveFinalSlash : public ::std::unary_function< String, void >
     314             :     {
     315             :         void operator()( String& _rURL )
     316             :         {
     317             :             INetURLObject aURL( _rURL );
     318             : #if defined(WNT)
     319             :             if ( aURL.getSegmentCount() > 1 )
     320             : #endif
     321             :                 aURL.removeFinalSlash( );
     322             :             _rURL = aURL.GetMainURL( INetURLObject::NO_DECODE );
     323             :         }
     324             :     };
     325             : 
     326             :     // -----------------------------------------------------------------------
     327             :     /** retrieves the value of an environment variable
     328             :         @return <TRUE/> if and only if the retrieved string value is not empty
     329             :     */
     330           0 :     bool getEnvironmentValue( const sal_Char* _pAsciiEnvName, OUString& _rValue )
     331             :     {
     332           0 :         _rValue = OUString();
     333           0 :         OUString sEnvName = OUString::createFromAscii( _pAsciiEnvName );
     334           0 :         osl_getEnvironment( sEnvName.pData, &_rValue.pData );
     335           0 :         return !_rValue.isEmpty();
     336             :     }
     337             : }
     338             : 
     339             : //***************************************************************************
     340             : // ControlChain_Impl
     341             : //***************************************************************************
     342             : 
     343             : struct ControlChain_Impl
     344             : {
     345             :     Window*            _pControl;
     346             :     ControlChain_Impl* _pNext;
     347             :     sal_Bool               _bHasOwnership;
     348             : 
     349             :     ControlChain_Impl( Window* pControl, ControlChain_Impl* pNext );
     350             :     ~ControlChain_Impl();
     351             : };
     352             : 
     353             : //***************************************************************************
     354             : 
     355           0 : ControlChain_Impl::ControlChain_Impl
     356             : (
     357             :     Window* pControl,
     358             :     ControlChain_Impl* pNext
     359             : )
     360             :     : _pControl( pControl ),
     361             :       _pNext( pNext ),
     362           0 :       _bHasOwnership( sal_True )
     363             : {
     364           0 : }
     365             : 
     366             : //***************************************************************************
     367             : 
     368           0 : ControlChain_Impl::~ControlChain_Impl()
     369             : {
     370           0 :     if ( _bHasOwnership )
     371             :     {
     372           0 :         delete _pControl;
     373             :     }
     374           0 :     delete _pNext;
     375           0 : }
     376             : 
     377             : //*****************************************************************************
     378             : // SvtFileDialog
     379             : //*****************************************************************************
     380           0 : SvtFileDialog::SvtFileDialog
     381             : (
     382             :     Window* _pParent,
     383             :     WinBits nBits,
     384             :     WinBits nExtraBits
     385             : ) :
     386             :     ModalDialog( _pParent, SvtResId( DLG_FPICKER_EXPLORERFILE ) )
     387             : 
     388             :     ,_pUserControls( NULL )
     389             :     ,_pCbReadOnly( NULL )
     390             :     ,_pCbLinkBox( NULL)
     391             :     ,_pCbPreviewBox( NULL )
     392             :     ,_pCbSelection( NULL )
     393             :     ,_pPbPlay( NULL )
     394             :     ,_pPrevWin( NULL )
     395             :     ,_pPrevBmp( NULL )
     396             :     ,_pFileView( NULL )
     397             :     ,_pFileNotifier( NULL )
     398           0 :     ,_pImp( new SvtExpFileDlg_Impl( nBits ) )
     399             :     ,_nExtraBits( nExtraBits )
     400             :     ,_bIsInExecute( sal_False )
     401             :     ,m_bInExecuteAsync( false )
     402             :     ,m_bHasFilename( false )
     403           0 :     ,m_context(comphelper::getProcessComponentContext())
     404             : {
     405           0 :     Init_Impl( nBits );
     406           0 : }
     407             : 
     408             : //*****************************************************************************
     409             : 
     410           0 : SvtFileDialog::SvtFileDialog ( Window* _pParent, WinBits nBits )
     411             :     :ModalDialog( _pParent, SvtResId( DLG_FPICKER_EXPLORERFILE ) )
     412             :     ,_pUserControls( NULL )
     413             :     ,_pCbReadOnly( NULL )
     414             :     ,_pCbLinkBox( NULL)
     415             :     ,_pCbPreviewBox( NULL )
     416             :     ,_pCbSelection( NULL )
     417             :     ,_pPbPlay( NULL )
     418             :     ,_pPrevWin( NULL )
     419             :     ,_pPrevBmp( NULL )
     420             :     ,_pFileView( NULL )
     421             :     ,_pFileNotifier( NULL )
     422           0 :     ,_pImp( new SvtExpFileDlg_Impl( nBits ) )
     423             :     ,_nExtraBits( 0L )
     424             :     ,_bIsInExecute( sal_False )
     425           0 :     ,m_bHasFilename( false )
     426             : {
     427           0 :     Init_Impl( nBits );
     428           0 : }
     429             : 
     430             : //*****************************************************************************
     431             : 
     432           0 : SvtFileDialog::~SvtFileDialog()
     433             : {
     434           0 :     if ( _pImp->_aIniKey.Len() )
     435             :     {
     436             :         // save window state
     437           0 :         SvtViewOptions aDlgOpt( E_DIALOG, _pImp->_aIniKey );
     438           0 :         aDlgOpt.SetWindowState(OStringToOUString(GetWindowState(), osl_getThreadTextEncoding()));
     439           0 :         String sUserData = _pFileView->GetConfigString();
     440             :         aDlgOpt.SetUserItem( OUString( "UserData" ),
     441           0 :                              makeAny( OUString( sUserData ) ) );
     442             :     }
     443             : 
     444           0 :     _pFileView->SetSelectHdl( Link() );
     445             : 
     446             :     // Save bookmarked places
     447           0 :     if(_pImp->_pPlaces->IsUpdated()) {
     448           0 :         const std::vector<PlacePtr> aPlaces = _pImp->_pPlaces->GetPlaces();
     449           0 :         Sequence< OUString > placesUrlsList(_pImp->_pPlaces->GetNbEditablePlaces());
     450           0 :         Sequence< OUString > placesNamesList(_pImp->_pPlaces->GetNbEditablePlaces());
     451           0 :         int i(0);
     452           0 :         for(std::vector<PlacePtr>::const_iterator it = aPlaces.begin(); it != aPlaces.end(); ++it) {
     453           0 :             if((*it)->IsEditable()) {
     454           0 :                 placesUrlsList[i] = (*it)->GetUrl();
     455           0 :                 placesNamesList[i] = (*it)->GetName();
     456           0 :                 ++i;
     457             :             }
     458             :         }
     459             : 
     460           0 :         boost::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create(m_context));
     461           0 :         officecfg::Office::Common::Misc::FilePickerPlacesUrls::set(placesUrlsList, batch, m_context);
     462           0 :         officecfg::Office::Common::Misc::FilePickerPlacesNames::set(placesNamesList, batch, m_context);
     463           0 :         batch->commit();
     464             :     }
     465             : 
     466           0 :     delete _pImp;
     467           0 :     delete _pFileView;
     468           0 :     delete _pSplitter;
     469             : 
     470           0 :     delete _pCbReadOnly;
     471           0 :     delete _pCbLinkBox;
     472           0 :     delete _pCbPreviewBox;
     473           0 :     delete _pCbSelection;
     474           0 :     delete _pPbPlay;
     475           0 :     delete _pPrevWin;
     476           0 :     delete _pPrevBmp;
     477             : 
     478           0 :     delete _pUserControls;
     479           0 : }
     480             : 
     481             : //*****************************************************************************
     482             : 
     483           0 : void SvtFileDialog::Init_Impl
     484             : (
     485             :     WinBits nStyle
     486             : )
     487             : {
     488           0 :     m_aImages = ImageList( SvtResId( RID_FILEPICKER_IMAGES ) );
     489             : 
     490           0 :     _pImp->_nStyle = nStyle;
     491           0 :     _pImp->_a6Size = LogicToPixel( Size( 6, 6 ), MAP_APPFONT );
     492           0 :     _pImp->_eMode = ( nStyle & WB_SAVEAS ) ? FILEDLG_MODE_SAVE : FILEDLG_MODE_OPEN;
     493           0 :     _pImp->_eDlgType = FILEDLG_TYPE_FILEDLG;
     494             : 
     495           0 :     if ( ( nStyle & SFXWB_PATHDIALOG ) == SFXWB_PATHDIALOG )
     496           0 :         _pImp->_eDlgType = FILEDLG_TYPE_PATHDLG;
     497             : 
     498             :     // Set the directory for the "back to the default dir" button
     499           0 :     INetURLObject aStdDirObj( SvtPathOptions().GetWorkPath() );
     500           0 :     SetStandardDir( aStdDirObj.GetMainURL( INetURLObject::NO_DECODE ) );
     501             : 
     502             :     // determine range
     503           0 :     if ( !( nStyle & SFXWB_NOREMOTE ) )
     504             :     {
     505           0 :         _pImp->_nState |= FILEDLG_STATE_REMOTE;
     506             :     }
     507             : 
     508             :     // Create control element, the order defines the tab control.
     509           0 :     _pImp->_pFtFileName = new FixedText( this, SvtResId( FT_EXPLORERFILE_FILENAME ) );
     510             : 
     511           0 :     SvtURLBox* pURLBox = new SvtURLBox( this, SvtResId( ED_EXPLORERFILE_FILENAME ) );
     512           0 :     _pImp->_pEdFileName = pURLBox;
     513           0 :     _pImp->_pEdFileName->Show();
     514           0 :     pURLBox->SetSelectHdl( LINK( this, SvtFileDialog, EntrySelectHdl_Impl ) );
     515           0 :     pURLBox->SetOpenHdl( STATIC_LINK( this, SvtFileDialog, OpenHdl_Impl ) );
     516             : 
     517             :     // in folder picker mode, only auto-complete directories (no files)
     518           0 :     bool bIsFolderPicker = ( _pImp->_eDlgType == FILEDLG_TYPE_PATHDLG );
     519           0 :     pURLBox->SetOnlyDirectories( bIsFolderPicker );
     520             : 
     521             :     // in save mode, don't use the autocompletion as selection in the edit part
     522           0 :     bool bSaveMode = ( FILEDLG_MODE_SAVE == _pImp->_eMode );
     523           0 :     pURLBox->SetNoURLSelection( bSaveMode );
     524             : 
     525           0 :     _pImp->_pEdFileName->SetHelpId( HID_FILEDLG_AUTOCOMPLETEBOX );
     526             : 
     527           0 :     _pImp->_pFtFileType = new FixedText( this, SvtResId( FT_EXPLORERFILE_FILETYPE ) );
     528           0 :     _pImp->CreateFilterListControl( this, SvtResId( LB_EXPLORERFILE_FILETYPE ) );
     529             : 
     530             :     // move the filter listbox to the space occupied by the version listbox
     531             :     // if that box isn't needed
     532           0 :     if ( !( _nExtraBits & SFX_EXTRA_SHOWVERSIONS ) &&
     533           0 :          !( _nExtraBits & SFX_EXTRA_TEMPLATES ) &&
     534           0 :          !( _nExtraBits & SFX_EXTRA_IMAGE_TEMPLATE ) )
     535             :     {
     536             :         {
     537           0 :             FixedText aSharedListBoxLabel( this, SvtResId( FT_EXPLORERFILE_SHARED_LISTBOX ) );
     538           0 :             _pImp->_pFtFileType->SetPosPixel( aSharedListBoxLabel.GetPosPixel() );
     539             :         }
     540             : 
     541             :         {
     542           0 :             ListBox aSharedListBox( this, SvtResId( LB_EXPLORERFILE_SHARED_LISTBOX ) );
     543           0 :             _pImp->GetFilterListControl()->SetPosPixel( aSharedListBox.GetPosPixel() );
     544             :         }
     545             :     }
     546             : 
     547           0 :     _pImp->_pEdCurrentPath = new SvtURLBox( this, SvtResId(ED_EXPLORERFILE_CURRENTPATH) );
     548           0 :     _pImp->_pEdCurrentPath->Show();
     549             : 
     550           0 :     _pImp->_pBtnFileOpen = new PushButton( this, SvtResId( BTN_EXPLORERFILE_OPEN ) );
     551           0 :     _pImp->_pBtnCancel = new CancelButton( this, SvtResId( BTN_EXPLORERFILE_CANCEL ) );
     552           0 :     _pImp->_pBtnHelp = new HelpButton( this, SvtResId( BTN_EXPLORERFILE_HELP ) );
     553             : 
     554           0 :     _pImp->_pBtnConnectToServer = new PushButton ( this, SvtResId ( BTN_EXPLORERFILE_CONNECT_TO_SERVER ) );
     555           0 :     _pImp->_pBtnConnectToServer->SetAccessibleName( _pImp->_pBtnConnectToServer->GetQuickHelpText() );
     556             : 
     557           0 :     _pImp->_pBtnUp = new SvtUpButton_Impl( this, SvtResId( BTN_EXPLORERFILE_UP ) );
     558           0 :     _pImp->_pBtnNewFolder = new ImageButton( this, SvtResId( BTN_EXPLORERFILE_NEWFOLDER ) );
     559           0 :     _pImp->_pBtnNewFolder->SetStyle( _pImp->_pBtnNewFolder->GetStyle() | WB_NOPOINTERFOCUS );
     560             : 
     561           0 :     _pImp->_pBtnUp->SetAccessibleName( _pImp->_pBtnUp->GetQuickHelpText() );
     562           0 :     _pImp->_pBtnNewFolder->SetAccessibleName( _pImp->_pBtnNewFolder->GetQuickHelpText() );
     563             : 
     564           0 :     if ( ( nStyle & SFXWB_MULTISELECTION ) == SFXWB_MULTISELECTION )
     565           0 :         _pImp->_bMultiSelection = sal_True;
     566             : 
     567             :     _pFileView = new SvtFileView( this, SvtResId( CTL_EXPLORERFILE_FILELIST ),
     568             :                                        FILEDLG_TYPE_PATHDLG == _pImp->_eDlgType,
     569           0 :                                        _pImp->_bMultiSelection );
     570           0 :     _pFileView->EnableAutoResize();
     571             : 
     572           0 :     _pFileView->SetHelpId( HID_FILEDLG_STANDARD );
     573           0 :     _pFileView->SetStyle( _pFileView->GetStyle() | WB_TABSTOP );
     574             : 
     575           0 :     _pSplitter = new Splitter( this, SvtResId( EXPLORERFILE_SPLITTER ) );
     576           0 :     _pSplitter->SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetFaceColor() ));
     577           0 :     _pSplitter->SetSplitHdl( LINK( this, SvtFileDialog, Split_Hdl ) );
     578             : 
     579             :     // determine the size of the buttons
     580           0 :     Size aSize = _pImp->_pBtnNewFolder->GetSizePixel();
     581           0 :     Image aNewFolderImg( GetButtonImage( IMG_FILEDLG_CREATEFOLDER ) );
     582           0 :     _pImp->_pBtnNewFolder->SetModeImage( aNewFolderImg );
     583             : 
     584             :     // set position of the buttons
     585           0 :     Size aDlgSize = GetOutputSizePixel();
     586             :     long n6AppFontInPixel =
     587           0 :             LogicToPixel( Size( 6, 0 ), MAP_APPFONT ).Width();
     588             :     long n3AppFontInPixel =
     589           0 :             LogicToPixel( Size( 3, 0 ), MAP_APPFONT ).Width();
     590           0 :     long nHalf3AppFontInPixel = n3AppFontInPixel/2;
     591             : 
     592             :     // nDelta is the space between the right border and the left border of the
     593             :     // component currently positioned
     594           0 :     long nDelta = n6AppFontInPixel;
     595             : 
     596             :     // New folder
     597             :     Point aPos(
     598           0 :         aDlgSize.Width() - nDelta,
     599           0 :         _pImp->_pBtnNewFolder->GetPosPixel().Y()
     600           0 :     );
     601           0 :     nDelta += aSize.Width() + nHalf3AppFontInPixel;
     602           0 :     aPos.X() = aDlgSize.Width() - nDelta;
     603           0 :     _pImp->_pBtnNewFolder->SetPosPixel(aPos);
     604             : 
     605             :     // Previous level (up)
     606           0 :     nDelta += aSize.Width() + nHalf3AppFontInPixel;
     607           0 :     aPos.X() = aDlgSize.Width() - nDelta;
     608           0 :     _pImp->_pBtnUp->SetPosPixel(aPos);
     609             : 
     610             :     // Connect to server ("...")
     611           0 :     nDelta += _pImp->_pBtnConnectToServer->GetSizePixel().Width() + nHalf3AppFontInPixel;
     612           0 :     aPos.X() = aDlgSize.Width() - nDelta;
     613           0 :     _pImp->_pBtnConnectToServer->SetPosPixel(aPos);
     614             : 
     615             :     // Set the size of the URL bar
     616           0 :     nDelta += nHalf3AppFontInPixel; // right margin of the URL bar
     617           0 :     aSize.Width() = aDlgSize.Width()
     618           0 :         - _pImp->_pEdCurrentPath->GetPosPixel().X()
     619           0 :         - nDelta;
     620           0 :     _pImp->_pEdCurrentPath->SetOutputSizePixel(aSize);
     621             : 
     622           0 :     aPos.X() = _pImp->_pEdCurrentPath->GetPosPixel().X();
     623           0 :     _pImp->_pEdCurrentPath->SetPosPixel(aPos);
     624             : 
     625           0 :     if ( nStyle & SFXWB_READONLY )
     626             :     {
     627           0 :         _pCbReadOnly = new CheckBox( this, SvtResId( CB_EXPLORERFILE_READONLY ) );
     628           0 :         _pCbReadOnly->SetHelpId( HID_FILEOPEN_READONLY );
     629           0 :         _pCbReadOnly->SetText( SvtResId( STR_SVT_FILEPICKER_READONLY ) );
     630           0 :         AddControl( _pCbReadOnly );
     631           0 :         ReleaseOwnership( _pCbReadOnly );
     632           0 :         _pCbReadOnly->SetClickHdl( LINK( this, SvtFileDialog, ClickHdl_Impl ) );
     633             :     }
     634             : 
     635           0 :     if ( nStyle & SFXWB_PASSWORD )
     636             :     {
     637           0 :         _pImp->_pCbPassword = new CheckBox( this, SvtResId( CB_EXPLORERFILE_PASSWORD ) );
     638           0 :         _pImp->_pCbPassword->SetText( SvtResId( STR_SVT_FILEPICKER_PASSWORD ) );
     639           0 :         AddControl( _pImp->_pCbPassword );
     640           0 :         ReleaseOwnership( _pImp->_pCbPassword );
     641           0 :         _pImp->_pCbPassword->SetClickHdl( LINK( this, SvtFileDialog, ClickHdl_Impl ) );
     642             :     }
     643             : 
     644             :     // set the ini file for extracting the size
     645           0 :     _pImp->_aIniKey = IODLG_CONFIGNAME;
     646             : 
     647           0 :     AddControls_Impl( );
     648             : 
     649             :     // Determine the amount of pixel the other elements have to be adjusted in their position.
     650           0 :     aPos.Y() += aSize.Height();
     651           0 :     aPos.Y() += LogicToPixel( Size( 0, 6 ), MAP_APPFONT ).Height();
     652           0 :     long nYOffset = aPos.Y();
     653           0 :     aPos = _pFileView->GetPosPixel();
     654             : 
     655           0 :     aPos.Y() = nYOffset;
     656           0 :     nYOffset -= aPos.Y();
     657             : 
     658             :     // Adjust the position of the other elements.
     659           0 :     _pFileView->SetPosPixel( aPos );
     660             : 
     661           0 :     aPos.X() = _pSplitter->GetPosPixel().X();
     662           0 :     _pSplitter->SetPosPixel( aPos );
     663             : 
     664           0 :     aPos.X() = _pImp->_pPlaces->GetPosPixel().X();
     665           0 :     _pImp->_pPlaces->SetPosPixel( aPos );
     666             : 
     667             : 
     668           0 :     lcl_MoveControl( _pImp->_pFtFileName, 0, nYOffset );
     669           0 :     lcl_MoveControl( _pImp->_pEdFileName, 0, nYOffset );
     670             : 
     671           0 :     lcl_MoveControl( _pImp->_pFtFileVersion, 0, nYOffset );
     672           0 :     lcl_MoveControl( _pImp->_pLbFileVersion, 0, nYOffset );
     673             : 
     674           0 :     lcl_MoveControl( _pImp->_pFtTemplates, 0, nYOffset );
     675           0 :     lcl_MoveControl( _pImp->_pLbTemplates, 0, nYOffset );
     676             : 
     677           0 :     lcl_MoveControl( _pImp->_pFtImageTemplates, 0, nYOffset );
     678           0 :     lcl_MoveControl( _pImp->_pLbImageTemplates, 0, nYOffset );
     679             : 
     680           0 :     lcl_MoveControl( _pImp->_pFtFileType, 0, nYOffset );
     681           0 :     lcl_MoveControl( _pImp->GetFilterListControl(), 0, nYOffset );
     682             : 
     683           0 :     lcl_MoveControl( _pImp->_pBtnFileOpen, 0, nYOffset );
     684           0 :     lcl_MoveControl( _pImp->_pBtnCancel, 0, nYOffset );
     685             : 
     686           0 :     lcl_MoveControl( _pImp->_pBtnHelp, 0, nYOffset + 3 );
     687             :         // a little more spacing between Cancel- and HelpButton
     688             : 
     689             :     // adjust size of the dialog
     690           0 :     aSize = GetSizePixel();
     691           0 :     aSize.Height() += nYOffset;
     692           0 :     SetSizePixel( aSize );
     693             : 
     694             :     // adjust the labels to the mode
     695           0 :     sal_uInt16 nResId = STR_EXPLORERFILE_OPEN;
     696           0 :     sal_uInt16 nButtonResId = 0;
     697             : 
     698           0 :     if ( nStyle & WB_SAVEAS )
     699             :     {
     700           0 :         nResId = STR_EXPLORERFILE_SAVE;
     701           0 :         nButtonResId = STR_EXPLORERFILE_BUTTONSAVE;
     702             :     }
     703             : 
     704           0 :     if ( ( nStyle & SFXWB_PATHDIALOG ) == SFXWB_PATHDIALOG )
     705             :     {
     706           0 :         _pImp->_pFtFileName->SetText( SvtResId( STR_PATHNAME ) );
     707           0 :         nResId = STR_PATHSELECT;
     708           0 :         nButtonResId = STR_BUTTONSELECT;
     709             :     }
     710             : 
     711           0 :     SetText( SvtResId( nResId ) );
     712             : 
     713           0 :     if ( nButtonResId )
     714           0 :         _pImp->_pBtnFileOpen->SetText( SvtResId( nButtonResId ) );
     715             : 
     716           0 :     if ( FILEDLG_TYPE_FILEDLG != _pImp->_eDlgType )
     717             :     {
     718           0 :         _pImp->_pFtFileType->Hide();
     719           0 :         _pImp->GetFilterListControl()->Hide();
     720             :     }
     721             : 
     722             :     // Setting preferences of the control elements.
     723           0 :     _pImp->_pBtnNewFolder->SetClickHdl( STATIC_LINK( this, SvtFileDialog, NewFolderHdl_Impl ) );
     724           0 :     _pImp->_pBtnFileOpen->SetClickHdl( STATIC_LINK( this, SvtFileDialog, OpenHdl_Impl ) );
     725           0 :     _pImp->_pBtnCancel->SetClickHdl( LINK( this, SvtFileDialog, CancelHdl_Impl ) );
     726           0 :     _pImp->SetFilterListSelectHdl( STATIC_LINK( this, SvtFileDialog, FilterSelectHdl_Impl ) );
     727           0 :     _pImp->_pEdFileName->SetGetFocusHdl( STATIC_LINK( this, SvtFileDialog, FileNameGetFocusHdl_Impl ) );
     728           0 :     _pImp->_pEdFileName->SetModifyHdl( STATIC_LINK( this, SvtFileDialog, FileNameModifiedHdl_Impl ) );
     729           0 :     _pImp->_pEdCurrentPath->SetOpenHdl ( STATIC_LINK( this, SvtFileDialog, URLBoxModifiedHdl_Impl ) );
     730           0 :     _pImp->_pBtnConnectToServer->SetClickHdl( STATIC_LINK ( this, SvtFileDialog, ConnectToServerPressed_Hdl ) );
     731             : 
     732             : 
     733           0 :     _pFileView->SetSelectHdl( LINK( this, SvtFileDialog, SelectHdl_Impl ) );
     734           0 :     _pFileView->SetDoubleClickHdl( LINK( this, SvtFileDialog, DblClickHdl_Impl ) );
     735           0 :     _pFileView->SetOpenDoneHdl( LINK( this, SvtFileDialog, OpenDoneHdl_Impl ) );
     736             : 
     737           0 :     FreeResource();
     738             : 
     739             :     // set timer for the filterbox travel
     740           0 :     _pImp->_aFilterTimer.SetTimeout( TRAVELFILTER_TIMEOUT );
     741           0 :     _pImp->_aFilterTimer.SetTimeoutHdl( STATIC_LINK( this, SvtFileDialog, FilterSelectHdl_Impl ) );
     742             : 
     743           0 :     if ( WB_SAVEAS & nStyle )
     744             :     {
     745             :         // different help ids if in save-as mode
     746           0 :         SetHelpId( HID_FILESAVE_DIALOG );
     747             : 
     748           0 :         _pImp->_pEdFileName->SetHelpId( HID_FILESAVE_FILEURL );
     749           0 :         _pImp->_pBtnFileOpen->SetHelpId( HID_FILESAVE_DOSAVE );
     750           0 :         _pImp->_pBtnNewFolder->SetHelpId( HID_FILESAVE_CREATEDIRECTORY );
     751           0 :         _pImp->_pBtnUp->SetHelpId( HID_FILESAVE_LEVELUP );
     752           0 :         _pImp->GetFilterListControl()->SetHelpId( HID_FILESAVE_FILETYPE );
     753           0 :         _pFileView->SetHelpId( HID_FILESAVE_FILEVIEW );
     754             : 
     755             :         // formerly, there was only _pLbFileVersion, which was used for 3 different
     756             :         // use cases. For reasons of maintainability, I introduced extra members (_pLbTemplates, _pLbImageTemplates)
     757             :         // for the extra use cases, and separated _pLbFileVersion
     758             :         // I did not find out in which cases the help ID is really needed HID_FILESAVE_TEMPLATE - all
     759             :         // tests I made lead to a dialog where _no_ of the three list boxes was present.
     760           0 :         if ( _pImp->_pLbFileVersion )
     761           0 :             _pImp->_pLbFileVersion->SetHelpId( HID_FILESAVE_TEMPLATE );
     762           0 :         if ( _pImp->_pLbTemplates )
     763           0 :             _pImp->_pLbTemplates->SetHelpId( HID_FILESAVE_TEMPLATE );
     764           0 :         if ( _pImp->_pLbImageTemplates )
     765           0 :             _pImp->_pLbImageTemplates->SetHelpId( HID_FILESAVE_TEMPLATE );
     766             : 
     767           0 :         if ( _pImp->_pCbPassword ) _pImp->_pCbPassword->SetHelpId( HID_FILESAVE_SAVEWITHPASSWORD );
     768           0 :         if ( _pImp->_pCbAutoExtension ) _pImp->_pCbAutoExtension->SetHelpId( HID_FILESAVE_AUTOEXTENSION );
     769           0 :         if ( _pImp->_pCbOptions ) _pImp->_pCbOptions->SetHelpId( HID_FILESAVE_CUSTOMIZEFILTER );
     770           0 :         if ( _pCbSelection ) _pCbSelection->SetHelpId( HID_FILESAVE_SELECTION );
     771             :     }
     772             : 
     773             :     // correct the z-order of the controls
     774           0 :     implArrangeControls();
     775             : 
     776             :     /// read our settings from the configuration
     777           0 :     m_aConfiguration = OConfigurationTreeRoot::createWithComponentContext(
     778             :         ::comphelper::getProcessComponentContext(),
     779             :         OUString( "/org.openoffice.Office.UI/FilePicker" )
     780           0 :     );
     781           0 : }
     782             : 
     783             : //*****************************************************************************
     784             : 
     785           0 : IMPL_STATIC_LINK( SvtFileDialog, NewFolderHdl_Impl, PushButton*, EMPTYARG )
     786             : {
     787           0 :     pThis->_pFileView->EndInplaceEditing( false );
     788             : 
     789           0 :     SmartContent aContent( pThis->_pFileView->GetViewURL( ) );
     790           0 :     OUString aTitle;
     791           0 :     aContent.getTitle( aTitle );
     792           0 :     svtools::QueryFolderNameDialog aDlg( pThis, aTitle, String( SvtResId( STR_SVT_NEW_FOLDER ) ) );
     793           0 :     sal_Bool bHandled = sal_False;
     794             : 
     795           0 :     while ( !bHandled )
     796             :     {
     797           0 :         if ( aDlg.Execute() == RET_OK )
     798             :         {
     799           0 :             OUString aUrl = aContent.createFolder( aDlg.GetName( ) );
     800           0 :             if ( !aUrl.isEmpty( ) )
     801             :             {
     802           0 :                 pThis->_pFileView->CreatedFolder( aUrl, aDlg.GetName() );
     803           0 :                 bHandled = sal_True;
     804           0 :             }
     805             :         }
     806             :         else
     807           0 :             bHandled = sal_True;
     808             :     }
     809             : 
     810           0 :     return 0;
     811             : }
     812             : 
     813             : //*****************************************************************************
     814             : 
     815           0 : IMPL_STATIC_LINK_NOINSTANCE( SvtFileDialog, ViewHdl_Impl, ImageButton*, EMPTYARG )
     816             : {
     817           0 :     return 0;
     818             : }
     819             : 
     820             : //-----------------------------------------------------------------------------
     821           0 : sal_Bool SvtFileDialog::createNewUserFilter( const String& _rNewFilter, sal_Bool _bAllowUserDefExt )
     822             : {
     823             :     // delete the old user filter and create a new one
     824           0 :     DELETEZ( _pImp->_pUserFilter );
     825           0 :     _pImp->_pUserFilter = new SvtFileDialogFilter_Impl( _rNewFilter, _rNewFilter );
     826             : 
     827             :     // remember the extension
     828           0 :     sal_Bool bIsAllFiles = _rNewFilter.EqualsAscii( FILEDIALOG_FILTER_ALL );
     829           0 :     if ( bIsAllFiles )
     830           0 :         EraseDefaultExt();
     831             :     else
     832           0 :         SetDefaultExt( _rNewFilter.Copy( 2 ) );
     833             :         // TODO: this is nonsense. In the whole file there are a lotta places where we assume that a user filter
     834             :         // is always "*.<something>". But changing this would take some more time than I have now ...
     835             : 
     836             :     // now, the default extension is set to the one of the user filter (or empty)
     837             :     // if the former is not allowed (_bAllowUserDefExt = <FALSE/>), we have to use the ext of the current filter
     838             :     // (if possible)
     839           0 :     sal_Bool bUseCurFilterExt = sal_True;
     840           0 :     String sUserFilter = _pImp->_pUserFilter->GetType();
     841           0 :     xub_StrLen nSepPos = sUserFilter.SearchBackward( '.' );
     842           0 :     if ( STRING_NOTFOUND != nSepPos )
     843             :     {
     844           0 :         String sUserExt = sUserFilter.Copy( nSepPos + 1 );
     845           0 :         if  (   ( STRING_NOTFOUND == sUserExt.Search( '*' ) )
     846           0 :             &&  ( STRING_NOTFOUND == sUserExt.Search( '?' ) )
     847             :             )
     848           0 :             bUseCurFilterExt = sal_False;
     849             :     }
     850             : 
     851           0 :     if ( !_bAllowUserDefExt || bUseCurFilterExt )
     852             :     {
     853           0 :         if ( _pImp->GetCurFilter( ) )
     854           0 :             SetDefaultExt( _pImp->GetCurFilter( )->GetExtension() );
     855             :         else
     856           0 :             EraseDefaultExt();
     857             :     }
     858             : 
     859             :     // outta here
     860           0 :     return bIsAllFiles;
     861             : }
     862             : 
     863             : //-----------------------------------------------------------------------------
     864             : #define FLT_NONEMPTY        0x0001
     865             : #define FLT_CHANGED         0x0002
     866             : #define FLT_USERFILTER      0x0004
     867             : #define FLT_ALLFILESFILTER  0x0008
     868             : 
     869             : //-----------------------------------------------------------------------------
     870           0 : sal_uInt16 SvtFileDialog::adjustFilter( const String& _rFilter )
     871             : {
     872           0 :     sal_uInt16 nReturn = 0;
     873             : 
     874           0 :     const sal_Bool bNonEmpty = ( _rFilter.Len() != 0 );
     875           0 :     if ( bNonEmpty )
     876             :     {
     877           0 :         nReturn |= FLT_NONEMPTY;
     878             : 
     879           0 :         sal_Bool bFilterChanged = sal_True;
     880             : 
     881             :         // search for a corresponding filter
     882           0 :         SvtFileDialogFilter_Impl* pFilter = FindFilter_Impl( _rFilter, sal_False, bFilterChanged );
     883             : 
     884             : #ifdef AUTOSELECT_USERFILTER
     885             :         // if we found a filter which without allowing multi-extensions -> select it
     886             :         if ( pFilter )
     887             :         {
     888             :             _pImp->SelectFilterListEntry( pFilter->GetName() );
     889             :             _pImp->SetCurFilter( pFilter );
     890             :         }
     891             : #endif // AUTOSELECT_USERFILTER
     892             : 
     893             :         // look for multi-ext filters if necessary
     894           0 :         if ( !pFilter )
     895           0 :             pFilter = FindFilter_Impl( _rFilter, sal_True, bFilterChanged );
     896             : 
     897           0 :         if ( bFilterChanged )
     898           0 :             nReturn |= FLT_CHANGED;
     899             : 
     900           0 :         if ( !pFilter )
     901             :         {
     902           0 :             nReturn |= FLT_USERFILTER;
     903             :             // no filter found : use it as user defined filter
     904             : #ifdef AUTOSELECT_USERFILTER
     905             :             if ( createNewUserFilter( _rFilter, sal_True ) )
     906             : #else
     907           0 :             if ( createNewUserFilter( _rFilter, sal_False ) )
     908             : #endif
     909             :             {   // it's the "all files" filter
     910           0 :                 nReturn |= FLT_ALLFILESFILTER;
     911             : 
     912             : #ifdef AUTOSELECT_USERFILTER
     913             :                 // select the "all files" entry
     914             :                 String sAllFilesFilter( SvtResId( STR_FILTERNAME_ALL ) );
     915             :                 if ( _pImp->HasFilterListEntry( sAllFilesFilter ) )
     916             :                 {
     917             :                     _pImp->SelectFilterListEntry( sAllFilesFilter );
     918             :                     _pImp->SetCurFilter( _pImp->GetSelectedFilterEntry( sAllFilesFilter ) );
     919             :                 }
     920             :                 else
     921             :                     _pImp->SetNoFilterListSelection( ); // there is no "all files" entry
     922             : #endif // AUTOSELECT_USERFILTER
     923             :             }
     924             : #ifdef AUTOSELECT_USERFILTER
     925             :             else
     926             :                 _pImp->SetNoFilterListSelection( );
     927             : #endif // AUTOSELECT_USERFILTER
     928             :         }
     929             :     }
     930             : 
     931           0 :     return nReturn;
     932             : }
     933             : 
     934             : //-----------------------------------------------------------------------------
     935           0 : IMPL_LINK_NOARG(SvtFileDialog, CancelHdl_Impl)
     936             : {
     937           0 :     if ( m_pCurrentAsyncAction.is() )
     938             :     {
     939           0 :         m_pCurrentAsyncAction->cancel();
     940           0 :         onAsyncOperationFinished();
     941             :     }
     942             :     else
     943             :     {
     944           0 :         EndDialog( sal_False );
     945             :     }
     946           0 :     return 1L;
     947             : }
     948             : 
     949             : //-----------------------------------------------------------------------------
     950           0 : IMPL_STATIC_LINK( SvtFileDialog, OpenHdl_Impl, void*, pVoid )
     951             : {
     952           0 :     if ( pThis->_pImp->_bMultiSelection && pThis->_pFileView->GetSelectionCount() > 1 )
     953             :     {
     954             :         // special open in case of multiselection
     955           0 :         pThis->OpenMultiSelection_Impl();
     956           0 :         return 0;
     957             :     }
     958             : 
     959           0 :     String aFileName;
     960           0 :     String aOldPath( pThis->_pFileView->GetViewURL() );
     961           0 :     if ( pThis->_pImp->_bDoubleClick || pThis->_pFileView->HasChildPathFocus() )
     962             :         // Selection done by doubleclicking in the view, get filename from the view
     963           0 :         aFileName = pThis->_pFileView->GetCurrentURL();
     964             : 
     965           0 :     if ( !aFileName.Len() )
     966             :     {
     967             :         // if an entry is selected in the view ....
     968           0 :         if ( pThis->_pFileView->GetSelectionCount() )
     969             :         {   // -> use this one. This will allow us to step down this folder
     970           0 :             aFileName = pThis->_pFileView->GetCurrentURL();
     971             :         }
     972             :     }
     973             : 
     974           0 :     if ( !aFileName.Len() )
     975             :     {
     976           0 :         if ( pThis->_pImp->_eMode == FILEDLG_MODE_OPEN && pThis->_pImp->_pEdFileName->IsTravelSelect() )
     977             :             // OpenHdl called from URLBox; travelling through the list of URLs should not cause an opening
     978           0 :             return 0;                   // MBA->PB: seems to be called never ?!
     979             : 
     980             :         // get the URL from from the edit field ( if not empty )
     981           0 :         if ( !pThis->_pImp->_pEdFileName->GetText().isEmpty() )
     982             :         {
     983           0 :             String aText = pThis->_pImp->_pEdFileName->GetText();
     984             : 
     985             :             // did we reach the root?
     986           0 :             if ( !INetURLObject( aOldPath ).getSegmentCount() )
     987             :             {
     988           0 :                 if ( ( aText.Len() == 2 && aText.EqualsAscii( ".." ) ) ||
     989           0 :                      ( aText.Len() == 3 && ( aText.EqualsAscii( "..\\" ) || aText.EqualsAscii( "../" ) ) ) )
     990             :                     // don't go higher than the root
     991           0 :                     return 0;
     992             :             }
     993             : 
     994             : #if defined( UNX )
     995           0 :             if ( ( 1 == aText.Len() ) && ( '~' == aText.GetBuffer()[0] ) )
     996             :             {
     997             :                 // go to the home directory
     998           0 :                 if ( lcl_getHomeDirectory( pThis->_pFileView->GetViewURL(), aFileName ) )
     999             :                     // in case we got a home dir, reset the text of the edit
    1000           0 :                     pThis->_pImp->_pEdFileName->SetText( String() );
    1001             :             }
    1002           0 :             if ( !aFileName.Len() )
    1003             : #endif
    1004             :             {
    1005             :                 // get url from autocomplete edit
    1006           0 :                 aFileName = pThis->_pImp->_pEdFileName->GetURL();
    1007           0 :             }
    1008             :         }
    1009           0 :         else if ( pVoid == pThis->_pImp->_pBtnFileOpen )
    1010             :             // OpenHdl was called for the "Open" Button; if edit field is empty, use selected element in the view
    1011           0 :             aFileName = pThis->_pFileView->GetCurrentURL();
    1012             :     }
    1013             : 
    1014             :     // MBA->PB: ?!
    1015           0 :     if ( !aFileName.Len() && pVoid == pThis->_pImp->_pEdFileName && pThis->_pImp->_pUserFilter )
    1016             :     {
    1017           0 :         DELETEZ( pThis->_pImp->_pUserFilter );
    1018           0 :         return 0;
    1019             :     }
    1020             : 
    1021           0 :     sal_uInt16 nLen = aFileName.Len();
    1022           0 :     if ( !nLen )
    1023             :     {
    1024             :         // if the dialog was opened to select a folder, the last selected folder should be selected
    1025           0 :         if( pThis->_pImp->_eDlgType == FILEDLG_TYPE_PATHDLG )
    1026             :         {
    1027           0 :             aFileName = pThis->_pImp->_pEdCurrentPath->GetText();
    1028           0 :             nLen = aFileName.Len();
    1029             :         }
    1030             :         else
    1031             :             // no file selected !
    1032           0 :             return 0;
    1033             :     }
    1034             : 
    1035             :     // mark input as selected
    1036           0 :     pThis->_pImp->_pEdFileName->SetSelection( Selection( 0, nLen ) );
    1037             : 
    1038             :     // if a path with wildcards is given, divide the string into path and wildcards
    1039           0 :     String aFilter;
    1040           0 :     if ( !pThis->IsolateFilterFromPath_Impl( aFileName, aFilter ) )
    1041           0 :         return 0;
    1042             : 
    1043             :     // if a filter was retrieved, there were wildcards !
    1044           0 :     sal_uInt16 nNewFilterFlags = pThis->adjustFilter( aFilter );
    1045           0 :     if ( nNewFilterFlags & FLT_CHANGED )
    1046             :     {
    1047             :         // cut off all text before wildcard in edit and select wildcard
    1048           0 :         pThis->_pImp->_pEdFileName->SetText( aFilter );
    1049           0 :         pThis->_pImp->_pEdFileName->SetSelection( Selection( 0, aFilter.Len() ) );
    1050             :     }
    1051             : 
    1052             :     {
    1053           0 :         INetURLObject aFileObject( aFileName );
    1054           0 :         if ( ( aFileObject.GetProtocol() == INET_PROT_NOT_VALID ) && aFileName.Len() )
    1055             :         {
    1056           0 :             String sCompleted = SvtURLBox::ParseSmart( aFileName, pThis->_pFileView->GetViewURL(), SvtPathOptions().GetWorkPath() );
    1057           0 :             if ( sCompleted.Len() )
    1058           0 :                 aFileName = sCompleted;
    1059           0 :         }
    1060             :     }
    1061             : 
    1062             :     // check if it is a folder
    1063           0 :     sal_Bool bIsFolder = sal_False;
    1064             : 
    1065             :     // first thing before doing anyhing with the content: Reset it. When the user presses "open" (or "save" or "export",
    1066             :     // for that matter), s/he wants the complete handling, including all possible error messages, even if s/he
    1067             :     // does the same thing for the same content twice, s/he wants both fails to be displayed.
    1068             :     // Without the reset, it could be that the content cached all relevant information, and will not display any
    1069             :     // error messages for the same content a second time ....
    1070           0 :     pThis->m_aContent.bindTo( OUString( ) );
    1071             : 
    1072           0 :     if ( aFileName.Len() )
    1073             :     {
    1074             :         // Make sure we have own Interaction Handler in place. We do not need
    1075             :         // to intercept interactions here, but to record the fact that there
    1076             :         // was an interaction.
    1077             :         SmartContent::InteractionHandlerType eInterActionHandlerType
    1078           0 :             = pThis->m_aContent.queryCurrentInteractionHandler();
    1079           0 :         if ( ( eInterActionHandlerType == SmartContent::IHT_NONE ) ||
    1080             :              ( eInterActionHandlerType == SmartContent::IHT_DEFAULT ) )
    1081             :             pThis->m_aContent.enableOwnInteractionHandler(
    1082           0 :                 OFilePickerInteractionHandler::E_NOINTERCEPTION );
    1083             : 
    1084           0 :         bIsFolder = pThis->m_aContent.isFolder( aFileName );
    1085             : 
    1086             :         // access denied to the given resource - and interaction was already
    1087             :         // used => break following operations
    1088             :         OFilePickerInteractionHandler* pHandler
    1089           0 :             = pThis->m_aContent.getOwnInteractionHandler();
    1090             : 
    1091             :         OSL_ENSURE( pHandler, "Got no Interaction Handler!!!" );
    1092             : 
    1093           0 :         if ( pHandler->wasAccessDenied() )
    1094           0 :             return 0;
    1095             : 
    1096           0 :         if ( pThis->m_aContent.isInvalid() &&
    1097           0 :              ( pThis->_pImp->_eMode == FILEDLG_MODE_OPEN ) )
    1098             :         {
    1099           0 :             if ( !pHandler->wasUsed() )
    1100           0 :                 ErrorHandler::HandleError( ERRCODE_IO_NOTEXISTS );
    1101             : 
    1102           0 :             return 0;
    1103             :         }
    1104             : 
    1105             :         // restore previous Interaction Handler
    1106           0 :         if ( eInterActionHandlerType == SmartContent::IHT_NONE )
    1107           0 :             pThis->m_aContent.disableInteractionHandler();
    1108           0 :         else if ( eInterActionHandlerType == SmartContent::IHT_DEFAULT )
    1109           0 :             pThis->m_aContent.enableDefaultInteractionHandler();
    1110             :      }
    1111             : 
    1112           0 :     if  (   !bIsFolder                                      // no existent folder
    1113           0 :         &&  pThis->_pImp->_pCbAutoExtension                 // auto extension is enabled in general
    1114           0 :         &&  pThis->_pImp->_pCbAutoExtension->IsChecked()    // auto extension is really to be used
    1115           0 :         &&  pThis->GetDefaultExt().Len()                    // there is a default extension
    1116           0 :         &&  !comphelper::string::equals(pThis->GetDefaultExt(), '*') // the default extension is not "all"
    1117           0 :         && !(   FILEDLG_MODE_SAVE == pThis->_pImp->_eMode       // we're saving a file
    1118           0 :             &&  pThis->_pFileView->GetSelectionCount()          // there is a selected file in the file view -> it will later on
    1119           0 :             )                                                   //    (in SvtFileDialog::GetPathList) be taken as file to save to
    1120             : 
    1121           0 :         && FILEDLG_MODE_OPEN != pThis->_pImp->_eMode // #i83408# don't append extension on open
    1122             :         )
    1123             :     {
    1124             :         // check extension and append the default extension if necessary
    1125             :         appendDefaultExtension(aFileName,
    1126           0 :                                pThis->GetDefaultExt(),
    1127           0 :                                pThis->_pImp->GetCurFilter()->GetType());
    1128             :     }
    1129             : 
    1130           0 :     sal_Bool bOpenFolder = ( FILEDLG_TYPE_PATHDLG == pThis->_pImp->_eDlgType ) &&
    1131           0 :                        !pThis->_pImp->_bDoubleClick && pVoid != pThis->_pImp->_pEdFileName;
    1132           0 :     if ( bIsFolder )
    1133             :     {
    1134           0 :         if ( bOpenFolder )
    1135             :         {
    1136           0 :             pThis->_aPath = aFileName;
    1137             :         }
    1138             :         else
    1139             :         {
    1140           0 :             if ( aFileName != pThis->_pFileView->GetViewURL() )
    1141             :             {
    1142           0 :                 pThis->OpenURL_Impl( aFileName );
    1143             :             }
    1144             :             else
    1145             :             {
    1146           0 :                 if ( nNewFilterFlags & FLT_CHANGED )
    1147           0 :                     pThis->ExecuteFilter();
    1148             :             }
    1149             : 
    1150           0 :             return 0;
    1151             :         }
    1152             :     }
    1153           0 :     else if ( !( nNewFilterFlags & FLT_NONEMPTY ) )
    1154             :     {
    1155             :         // if applicable save URL
    1156           0 :         pThis->_aPath = aFileName;
    1157             :     }
    1158             :     else
    1159             :     {
    1160             :         // if applicable filter again
    1161           0 :         if ( nNewFilterFlags & FLT_CHANGED )
    1162           0 :             pThis->ExecuteFilter();
    1163           0 :         return 0;
    1164             :     }
    1165             : 
    1166           0 :     INetURLObject aFileObj( aFileName );
    1167           0 :     if ( aFileObj.HasError() )
    1168             :     {
    1169           0 :         ErrorHandler::HandleError( ERRCODE_IO_GENERAL );
    1170           0 :         return 0;
    1171             :     }
    1172             : 
    1173           0 :     switch ( pThis->_pImp->_eMode )
    1174             :     {
    1175             :         case FILEDLG_MODE_SAVE:
    1176             :         {
    1177           0 :             if ( ::utl::UCBContentHelper::Exists( aFileObj.GetMainURL( INetURLObject::NO_DECODE ) ) )
    1178             :             {
    1179           0 :                 String aMsg = SvtResId( STR_SVT_ALREADYEXISTOVERWRITE );
    1180             :                 aMsg.SearchAndReplace(
    1181             :                     String( RTL_CONSTASCII_USTRINGPARAM( "$filename$" ) ),
    1182             :                     aFileObj.getName(INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET)
    1183           0 :                 );
    1184           0 :                 QueryBox aBox( pThis, WB_YES_NO, aMsg );
    1185           0 :                 if ( aBox.Execute() != RET_YES )
    1186           0 :                     return 0;
    1187             :             }
    1188             :             else
    1189             :             {
    1190           0 :                 OUString aCurPath;
    1191           0 :                 if ( ::utl::LocalFileHelper::ConvertURLToSystemPath( aFileName, aCurPath ) )
    1192             :                 {
    1193             :                     // if content does not exist: at least its path must exist
    1194           0 :                     INetURLObject aPathObj = aFileObj;
    1195           0 :                     aPathObj.removeSegment();
    1196           0 :                     sal_Bool bFolder = pThis->m_aContent.isFolder( aPathObj.GetMainURL( INetURLObject::NO_DECODE ) );
    1197           0 :                     if ( !bFolder )
    1198             :                     {
    1199           0 :                         ErrorHandler::HandleError( ERRCODE_IO_NOTEXISTSPATH );
    1200           0 :                         return 0;
    1201           0 :                     }
    1202           0 :                 }
    1203             :             }
    1204             :         }
    1205           0 :         break;
    1206             : 
    1207             :         case FILEDLG_MODE_OPEN:
    1208             :         {
    1209             :             // do an existence check herein, again
    1210             : 
    1211           0 :             if ( INET_PROT_FILE == aFileObj.GetProtocol( ) )
    1212             :             {
    1213           0 :                 sal_Bool bExists = sal_False;
    1214           0 :                 bExists = pThis->m_aContent.is( aFileObj.GetMainURL( INetURLObject::NO_DECODE ) );
    1215             : 
    1216             : 
    1217           0 :                 if ( !bExists )
    1218             :                 {
    1219           0 :                     String sError( SvtResId( RID_FILEOPEN_NOTEXISTENTFILE ) );
    1220             : 
    1221           0 :                     String sInvalidFile( aFileObj.GetMainURL( INetURLObject::DECODE_TO_IURI ) );
    1222           0 :                     if ( INET_PROT_FILE == aFileObj.GetProtocol() )
    1223             :                     {   // if it's a file URL, transform the URL into system notation
    1224           0 :                         OUString sURL( sInvalidFile );
    1225           0 :                         OUString sSystem;
    1226           0 :                         osl_getSystemPathFromFileURL( sURL.pData, &sSystem.pData );
    1227           0 :                         sInvalidFile = sSystem;
    1228             :                     }
    1229           0 :                     sError.SearchAndReplaceAscii( "$name$", sInvalidFile );
    1230             : 
    1231           0 :                     ErrorBox aError( pThis, WB_OK, sError );
    1232           0 :                     aError.Execute();
    1233           0 :                     return 0;
    1234             :                 }
    1235             :             }
    1236             :         }
    1237           0 :         break;
    1238             : 
    1239             :         default:
    1240             :             OSL_FAIL("SvtFileDialog, OpenHdl_Impl: invalid mode!");
    1241             :     }
    1242             : 
    1243             :     // notify interested parties
    1244             :     long nRet;
    1245             : 
    1246           0 :     if ( pThis->_aOKHdl.IsSet() )
    1247           0 :         nRet = pThis->_aOKHdl.Call( pThis );
    1248             :     else
    1249           0 :         nRet = pThis->OK();
    1250             : 
    1251           0 :     if ( nRet )
    1252             :     {
    1253           0 :         pThis->EndDialog( sal_True );
    1254             :     }
    1255             : 
    1256           0 :     return nRet;
    1257             : }
    1258             : 
    1259             : //*****************************************************************************
    1260             : 
    1261           0 : void SvtFileDialog::EnableAutocompletion( sal_Bool _bEnable )
    1262             : {
    1263           0 :     _pImp->_pEdFileName->EnableAutocompletion( _bEnable );
    1264           0 : }
    1265             : 
    1266             : //*****************************************************************************
    1267             : 
    1268           0 : IMPL_STATIC_LINK( SvtFileDialog, FilterSelectHdl_Impl, ListBox*, pBox )
    1269             : {
    1270             :     DBG_ASSERT( pBox, "SvtFileDialog:keine Instanz" );
    1271             : 
    1272             :     // was the handler executed by the travel timer?
    1273           0 :     if ( pBox == (ListBox*)&pThis->_pImp->_aFilterTimer )
    1274             :     {
    1275             :         // filter the view again
    1276           0 :         pThis->ExecuteFilter();
    1277           0 :         return 0;
    1278             :     }
    1279             : 
    1280           0 :     String sSelectedFilterDisplayName;
    1281           0 :     SvtFileDialogFilter_Impl* pSelectedFilter = pThis->_pImp->GetSelectedFilterEntry( sSelectedFilterDisplayName );
    1282           0 :     if ( !pSelectedFilter )
    1283             :     {   // there is no current selection. This happens if for instance the user selects a group separator using
    1284             :         // the keyboard, and then presses enter: When the selection happens, we immediately deselect the entry,
    1285             :         // so in this situation there is no current selection.
    1286           0 :         if ( restoreCurrentFilter( pThis->_pImp ) )
    1287           0 :             pThis->ExecuteFilter();
    1288             :     }
    1289             :     else
    1290             :     {
    1291           0 :         if ( pSelectedFilter->isGroupSeparator() )
    1292             :         {   // group separators can't be selected
    1293             :             // return to the previously selected entry
    1294           0 :             if ( pThis->_pImp->IsFilterListTravelSelect() )
    1295             :             {
    1296           0 :                 pThis->_pImp->SetNoFilterListSelection( );
    1297             : 
    1298             :                 // stop the timer for executing the filter
    1299           0 :                 if ( pThis->_pImp->_aFilterTimer.IsActive() )
    1300           0 :                     pThis->_pImp->m_bNeedDelayedFilterExecute = sal_True;
    1301           0 :                 pThis->_pImp->_aFilterTimer.Stop();
    1302             :             }
    1303             :             else
    1304             :             {
    1305           0 :                 if ( restoreCurrentFilter( pThis->_pImp ) )
    1306           0 :                     pThis->ExecuteFilter();
    1307             :             }
    1308             :         }
    1309           0 :         else if (   ( pSelectedFilter != pThis->_pImp->GetCurFilter() )
    1310           0 :                 ||  pThis->_pImp->_pUserFilter
    1311             :                 )
    1312             :         {
    1313             :             // Store the old filter for the auto extension handling
    1314           0 :             String sLastFilterExt = pThis->_pImp->GetCurFilter()->GetExtension();
    1315           0 :             DELETEZ( pThis->_pImp->_pUserFilter );
    1316             : 
    1317             :             // if applicable remove filter of the user
    1318           0 :             pThis->_pImp->SetCurFilter( pSelectedFilter, sSelectedFilterDisplayName );
    1319             : 
    1320             :             // if applicable show extension
    1321           0 :             pThis->SetDefaultExt( pSelectedFilter->GetExtension() );
    1322           0 :             sal_uInt16 nSepPos = pThis->GetDefaultExt().Search( FILEDIALOG_DEF_EXTSEP );
    1323             : 
    1324           0 :             if ( nSepPos != STRING_NOTFOUND )
    1325           0 :                 pThis->EraseDefaultExt( nSepPos );
    1326             : 
    1327             :             // update the extension of the current file if necessary
    1328           0 :             lcl_autoUpdateFileExtension( pThis, sLastFilterExt );
    1329             : 
    1330             :             // if the user is traveling fast through the filterbox
    1331             :             // do not filter instantly
    1332           0 :             if ( pThis->_pImp->IsFilterListTravelSelect() )
    1333             :             {
    1334             :                 // FilterSelectHdl_Impl should be started again in
    1335             :                 // TRAVELFILTER_TIMEOUT ms
    1336           0 :                 pThis->_pImp->_aFilterTimer.Start();
    1337             :             }
    1338             :             else
    1339             :             {
    1340             :                 // stop previously started timer
    1341           0 :                 pThis->_pImp->_aFilterTimer.Stop();
    1342             : 
    1343             :                 // filter the view again
    1344           0 :                 pThis->ExecuteFilter();
    1345           0 :             }
    1346             :         }
    1347             :     }
    1348             : 
    1349           0 :     return 0;
    1350             : }
    1351             : 
    1352             : //*****************************************************************************
    1353             : 
    1354           0 : IMPL_STATIC_LINK( SvtFileDialog, FileNameGetFocusHdl_Impl, void*, EMPTYARG )
    1355             : {
    1356           0 :     pThis->_pFileView->SetNoSelection();
    1357           0 :     pThis->_pFileView->Update();
    1358           0 :     return 0;
    1359             : }
    1360             : 
    1361             : //*****************************************************************************
    1362             : 
    1363           0 : IMPL_STATIC_LINK( SvtFileDialog, FileNameModifiedHdl_Impl, void*, EMPTYARG )
    1364             : {
    1365           0 :     FileNameGetFocusHdl_Impl( pThis, NULL );
    1366           0 :     return 0;
    1367             : }
    1368             : 
    1369             : //*****************************************************************************
    1370             : 
    1371           0 : IMPL_STATIC_LINK ( SvtFileDialog, URLBoxModifiedHdl_Impl, void*, EMPTYARG )
    1372             : {
    1373           0 :     String _aPath = pThis->_pImp->_pEdCurrentPath->GetURL();
    1374           0 :     pThis->OpenURL_Impl(_aPath);
    1375           0 :     return 0;
    1376             : }
    1377             : 
    1378             : //*****************************************************************************
    1379             : 
    1380           0 : IMPL_STATIC_LINK ( SvtFileDialog, ConnectToServerPressed_Hdl, void*, EMPTYARG )
    1381             : {
    1382           0 :     pThis->_pFileView->EndInplaceEditing( false );
    1383             : 
    1384           0 :     PlaceEditDialog aDlg( pThis );
    1385           0 :     short aRetCode = aDlg.Execute();
    1386             : 
    1387           0 :     switch (aRetCode) {
    1388             :         case RET_OK :
    1389             :         {
    1390           0 :             PlacePtr newPlace = aDlg.GetPlace();
    1391           0 :             pThis->_pImp->_pPlaces->AppendPlace(newPlace);
    1392             : 
    1393           0 :       break;
    1394             :         }
    1395             :         case RET_CANCEL :
    1396             :         default :
    1397             :             // Do Nothing
    1398           0 :             break;
    1399             :     };
    1400             : 
    1401           0 :     return 0;
    1402             : }
    1403             : 
    1404             : //*****************************************************************************
    1405             : 
    1406           0 : IMPL_LINK_NOARG ( SvtFileDialog, AddPlacePressed_Hdl )
    1407             : {
    1408             :     // Maybe open the PlacesDialog would have been a better idea
    1409             :     // there is an ux choice to make we did not make...
    1410           0 :     INetURLObject aURLObj( _pFileView->GetViewURL() );
    1411             :     PlacePtr newPlace(
    1412             :         new Place( aURLObj.GetLastName(INetURLObject::DECODE_WITH_CHARSET),
    1413           0 :                 OUString(_pFileView->GetViewURL()), true));
    1414           0 :     _pImp->_pPlaces->AppendPlace(newPlace);
    1415           0 :     return 0;
    1416             : }
    1417             : 
    1418             : //*****************************************************************************
    1419             : 
    1420           0 : IMPL_LINK_NOARG ( SvtFileDialog, RemovePlacePressed_Hdl )
    1421             : {
    1422           0 :     _pImp->_pPlaces->RemoveSelectedPlace();
    1423           0 :     return 0;
    1424             : }
    1425             : 
    1426             : //*****************************************************************************
    1427             : 
    1428           0 : SvtFileDialogFilter_Impl* SvtFileDialog::FindFilter_Impl
    1429             : (
    1430             :     const String& _rFilter,
    1431             :     sal_Bool _bMultiExt,/*  TRUE - regard filter with several extensions
    1432             :                             FALSE - do not ...
    1433             :                         */
    1434             :     sal_Bool& _rFilterChanged
    1435             : )
    1436             : 
    1437             : /*  [Description]
    1438             : 
    1439             :     This method looks for the specified extension in the included filters.
    1440             : */
    1441             : 
    1442             : {
    1443           0 :     SvtFileDialogFilter_Impl* pFoundFilter = NULL;
    1444           0 :     SvtFileDialogFilterList_Impl* pList = _pImp->_pFilter;
    1445           0 :     sal_uInt16 nFilter = pList->size();
    1446             : 
    1447           0 :     while ( nFilter-- )
    1448             :     {
    1449           0 :         SvtFileDialogFilter_Impl* pFilter = &(*pList)[ nFilter ];
    1450           0 :         const String& rType = pFilter->GetType();
    1451           0 :         String aSingleType = rType;
    1452             : 
    1453           0 :         if ( _bMultiExt )
    1454             :         {
    1455           0 :             sal_Int32 nIdx = 0;
    1456           0 :             while ( !pFoundFilter && nIdx != -1 )
    1457             :             {
    1458           0 :                 aSingleType = rType.GetToken( 0, FILEDIALOG_DEF_EXTSEP, nIdx );
    1459             : #ifdef UNX
    1460           0 :                 if ( aSingleType == _rFilter )
    1461             : #else
    1462             :                 if ( aSingleType.CompareIgnoreCaseToAscii( _rFilter ) == COMPARE_EQUAL )
    1463             : #endif
    1464           0 :                     pFoundFilter = pFilter;
    1465             :             }
    1466             :         }
    1467             : #ifdef UNX
    1468           0 :         else if ( rType == _rFilter )
    1469             : #else
    1470             :         else if ( rType.CompareIgnoreCaseToAscii( _rFilter ) == COMPARE_EQUAL )
    1471             : #endif
    1472           0 :             pFoundFilter = pFilter;
    1473             : 
    1474           0 :         if ( pFoundFilter )
    1475             :         {
    1476             :             // activate filter
    1477           0 :             _rFilterChanged = _pImp->_pUserFilter || ( _pImp->GetCurFilter() != pFilter );
    1478             : 
    1479           0 :             createNewUserFilter( _rFilter, sal_False );
    1480             : 
    1481           0 :             break;
    1482             :         }
    1483           0 :     }
    1484           0 :     return pFoundFilter;
    1485             : }
    1486             : 
    1487             : //*****************************************************************************
    1488             : 
    1489           0 : void SvtFileDialog::ExecuteFilter()
    1490             : {
    1491           0 :     _pImp->m_bNeedDelayedFilterExecute = sal_False;
    1492           0 :     executeAsync( AsyncPickerAction::eExecuteFilter, String(), getMostCurrentFilter( _pImp ) );
    1493           0 : }
    1494             : 
    1495             : //*****************************************************************************
    1496             : 
    1497           0 : void SvtFileDialog::OpenMultiSelection_Impl()
    1498             : 
    1499             : /*  [Description]
    1500             : 
    1501             :     OpenHandler for MultiSelection
    1502             : */
    1503             : 
    1504             : {
    1505           0 :     sal_uLong nCount = _pFileView->GetSelectionCount();
    1506           0 :     SvTreeListEntry* pEntry = nCount ? _pFileView->FirstSelected() : NULL;
    1507             : 
    1508           0 :     if ( nCount && pEntry )
    1509           0 :         _aPath = _pFileView->GetURL( pEntry );
    1510             : 
    1511             :     // notify interested parties
    1512             :     long nRet;
    1513             : 
    1514           0 :     if ( _aOKHdl.IsSet() )
    1515           0 :         nRet = _aOKHdl.Call( this );
    1516             :     else
    1517           0 :         nRet = OK();
    1518             : 
    1519           0 :     if ( nRet )
    1520           0 :         EndDialog( sal_True );
    1521           0 : }
    1522             : 
    1523             : //*****************************************************************************
    1524             : 
    1525           0 : void SvtFileDialog::UpdateControls( const String& rURL )
    1526             : {
    1527           0 :        _pImp->_pEdFileName->SetBaseURL( rURL );
    1528             : 
    1529           0 :     INetURLObject aObj( rURL );
    1530             : 
    1531             :     //=========================================================================
    1532             :     {
    1533           0 :         OUString sText;
    1534             :         DBG_ASSERT( INET_PROT_NOT_VALID != aObj.GetProtocol(), "SvtFileDialog::UpdateControls: Invalid URL!" );
    1535             : 
    1536           0 :         if ( aObj.getSegmentCount() )
    1537             :         {
    1538           0 :             ::utl::LocalFileHelper::ConvertURLToSystemPath( rURL, sText );
    1539           0 :             if ( !sText.isEmpty() )
    1540             :             {
    1541             :                 // no Fsys path for server file system ( only UCB has mountpoints! )
    1542           0 :                 if ( INET_PROT_FILE != aObj.GetProtocol() )
    1543           0 :                     sText = rURL.Copy( static_cast< sal_uInt16 >(
    1544           0 :                         INetURLObject::GetScheme( aObj.GetProtocol() ).getLength() ) );
    1545             :             }
    1546             : 
    1547           0 :             if ( sText.isEmpty() && aObj.getSegmentCount() )
    1548           0 :                 sText = rURL;
    1549             :         }
    1550             : 
    1551             :         // path mode ?
    1552           0 :         if ( FILEDLG_TYPE_PATHDLG == _pImp->_eDlgType )
    1553             :             // -> set new path in the edit field
    1554           0 :             _pImp->_pEdFileName->SetText( sText );
    1555             : 
    1556             :         // in the "current path" field, truncate the trailing slash
    1557           0 :         if ( aObj.hasFinalSlash() )
    1558             :         {
    1559           0 :             aObj.removeFinalSlash();
    1560           0 :             String sURL( aObj.GetMainURL( INetURLObject::NO_DECODE ) );
    1561           0 :             if ( !::utl::LocalFileHelper::ConvertURLToSystemPath( sURL, sText ) )
    1562           0 :                 sText = sURL;
    1563             :         }
    1564             : 
    1565           0 :         if ( sText.isEmpty() && rURL.Len() )
    1566             :             // happens, for instance, for URLs which the INetURLObject does not know to belong to a hierarchical scheme
    1567           0 :             sText = rURL;
    1568           0 :         _pImp->_pEdCurrentPath->SetText( sText );
    1569             :     }
    1570             : 
    1571             :     //=========================================================================
    1572           0 :     _aPath = rURL;
    1573           0 :     if ( _pFileNotifier )
    1574           0 :         _pFileNotifier->notify( DIRECTORY_CHANGED, 0 );
    1575           0 : }
    1576             : 
    1577             : //*****************************************************************************
    1578             : 
    1579           0 : IMPL_LINK( SvtFileDialog, SelectHdl_Impl, SvTabListBox*, pBox )
    1580             : {
    1581           0 :     SvTreeListEntry* pEntry = pBox->FirstSelected();
    1582             :     DBG_ASSERT( pEntry, "SelectHandler without selected entry" );
    1583           0 :     SvtContentEntry* pUserData = (SvtContentEntry*)pEntry->GetUserData();
    1584             : 
    1585           0 :     if ( pUserData )
    1586             :     {
    1587           0 :         INetURLObject aObj( pUserData->maURL );
    1588           0 :         if ( FILEDLG_TYPE_PATHDLG == _pImp->_eDlgType )
    1589             :         {
    1590           0 :             if ( aObj.GetProtocol() == INET_PROT_FILE )
    1591             :             {
    1592           0 :                 if ( !pUserData->mbIsFolder )
    1593           0 :                     aObj.removeSegment();
    1594           0 :                 String aName = aObj.getFSysPath( (INetURLObject::FSysStyle)(INetURLObject::FSYS_DETECT & ~INetURLObject::FSYS_VOS) );
    1595           0 :                 _pImp->_pEdFileName->SetText( aName );
    1596           0 :                 _pImp->_pEdFileName->SetSelection( Selection( 0, aName.Len() ) );
    1597           0 :                 _aPath = pUserData->maURL;
    1598             :             }
    1599           0 :             else if ( !pUserData->mbIsFolder )
    1600             :             {
    1601           0 :                 _pImp->_pEdFileName->SetText( pUserData->maURL );
    1602           0 :                 _pImp->_pEdFileName->SetSelection( Selection( 0, pUserData->maURL.getLength() ) );
    1603           0 :                 _aPath = pUserData->maURL;
    1604             :             }
    1605             :             else
    1606           0 :                 _pImp->_pEdFileName->SetText( OUString() );
    1607             :         }
    1608             :         else
    1609             :         {
    1610           0 :             if ( !pUserData->mbIsFolder )
    1611             :             {
    1612           0 :                 String aName = pBox->GetEntryText( pEntry, 0 );
    1613           0 :                 _pImp->_pEdFileName->SetText( aName );
    1614           0 :                 _pImp->_pEdFileName->SetSelection( Selection( 0, aName.Len() ) );
    1615           0 :                 _aPath = pUserData->maURL;
    1616             :             }
    1617           0 :         }
    1618             :     }
    1619             : 
    1620           0 :     if ( _pImp->_bMultiSelection && _pFileView->GetSelectionCount() > 1 )
    1621             :     {
    1622             :         // clear the file edit for multiselection
    1623           0 :         _pImp->_pEdFileName->SetText( String() );
    1624             :     }
    1625             : 
    1626           0 :     FileSelect();
    1627             : 
    1628           0 :     return 0;
    1629             : }
    1630             : 
    1631             : //*****************************************************************************
    1632             : 
    1633           0 : IMPL_LINK_NOARG(SvtFileDialog, DblClickHdl_Impl)
    1634             : {
    1635           0 :     _pImp->_bDoubleClick = sal_True;
    1636           0 :     OpenHdl_Impl( this, NULL );
    1637           0 :     _pImp->_bDoubleClick = sal_False;
    1638             : 
    1639           0 :     return 0;
    1640             : }
    1641             : 
    1642             : //*****************************************************************************
    1643             : 
    1644           0 : IMPL_LINK_NOARG(SvtFileDialog, EntrySelectHdl_Impl)
    1645             : {
    1646           0 :     FileSelect();
    1647             : 
    1648           0 :     return 0;
    1649             : }
    1650             : 
    1651             : //*****************************************************************************
    1652             : 
    1653           0 : IMPL_LINK( SvtFileDialog, OpenDoneHdl_Impl, SvtFileView*, pView )
    1654             : {
    1655           0 :     String sCurrentFolder( pView->GetViewURL() );
    1656             :     // check if we can create new folders
    1657           0 :     EnableControl( _pImp->_pBtnNewFolder, ContentCanMakeFolder( sCurrentFolder ) );
    1658             : 
    1659             :     // check if we can travel one level up
    1660           0 :     bool bCanTravelUp = ContentHasParentFolder( pView->GetViewURL() );
    1661           0 :     if ( bCanTravelUp )
    1662             :     {
    1663             :         // additional check: the parent folder should not be prohibited
    1664           0 :         INetURLObject aCurrentFolder( sCurrentFolder );
    1665             :         DBG_ASSERT( INET_PROT_NOT_VALID != aCurrentFolder.GetProtocol(),
    1666             :             "SvtFileDialog::OpenDoneHdl_Impl: invalid current URL!" );
    1667             : 
    1668           0 :         aCurrentFolder.removeSegment();
    1669             :     }
    1670           0 :     EnableControl( _pImp->_pBtnUp, bCanTravelUp );
    1671             : 
    1672           0 :     return 0;
    1673             : }
    1674             : 
    1675             : //*****************************************************************************
    1676             : 
    1677           0 : IMPL_LINK_NOARG(SvtFileDialog, AutoExtensionHdl_Impl)
    1678             : {
    1679           0 :     if ( _pFileNotifier )
    1680             :         _pFileNotifier->notify( CTRL_STATE_CHANGED,
    1681           0 :                                 CHECKBOX_AUTOEXTENSION );
    1682             : 
    1683             :     // update the extension of the current file if necessary
    1684           0 :     lcl_autoUpdateFileExtension( this, _pImp->GetCurFilter()->GetExtension() );
    1685             : 
    1686           0 :     return 0;
    1687             : }
    1688             : 
    1689             : //*****************************************************************************
    1690             : 
    1691           0 : IMPL_LINK( SvtFileDialog, ClickHdl_Impl, CheckBox*, pCheckBox )
    1692             : {
    1693           0 :     if ( ! _pFileNotifier )
    1694           0 :         return 0;
    1695             : 
    1696           0 :     sal_Int16 nId = -1;
    1697             : 
    1698           0 :     if ( pCheckBox == _pImp->_pCbOptions )
    1699           0 :         nId = CHECKBOX_FILTEROPTIONS;
    1700           0 :     else if ( pCheckBox == _pCbSelection )
    1701           0 :         nId = CHECKBOX_SELECTION;
    1702           0 :     else if ( pCheckBox == _pCbReadOnly )
    1703           0 :         nId = CHECKBOX_READONLY;
    1704           0 :     else if ( pCheckBox == _pImp->_pCbPassword )
    1705           0 :         nId = CHECKBOX_PASSWORD;
    1706           0 :     else if ( pCheckBox == _pCbLinkBox )
    1707           0 :         nId = CHECKBOX_LINK;
    1708           0 :     else if ( pCheckBox == _pCbPreviewBox )
    1709           0 :         nId = CHECKBOX_PREVIEW;
    1710             : 
    1711           0 :     if ( nId != -1 )
    1712           0 :         _pFileNotifier->notify( CTRL_STATE_CHANGED, nId );
    1713             : 
    1714           0 :     return 0;
    1715             : }
    1716             : 
    1717             : //*****************************************************************************
    1718             : 
    1719           0 : IMPL_LINK_NOARG(SvtFileDialog, PlayButtonHdl_Impl)
    1720             : {
    1721           0 :     if ( _pFileNotifier )
    1722             :         _pFileNotifier->notify( CTRL_STATE_CHANGED,
    1723           0 :                                 PUSHBUTTON_PLAY );
    1724             : 
    1725           0 :     return 0;
    1726             : }
    1727             : 
    1728             : //*****************************************************************************
    1729             : 
    1730           0 : long SvtFileDialog::Notify( NotifyEvent& rNEvt )
    1731             : 
    1732             : /*  [Description]
    1733             : 
    1734             :     This method gets called to catch <BACKSPACE>.
    1735             : */
    1736             : 
    1737             : {
    1738           0 :     sal_uInt16 nType = rNEvt.GetType();
    1739           0 :     long nRet = 0;
    1740             : 
    1741           0 :     if ( EVENT_KEYINPUT == nType && rNEvt.GetKeyEvent() )
    1742             :     {
    1743           0 :         const KeyCode& rKeyCode = rNEvt.GetKeyEvent()->GetKeyCode();
    1744           0 :         sal_uInt16 nCode = rKeyCode.GetCode();
    1745             : 
    1746           0 :         if ( !rKeyCode.GetModifier() &&
    1747           0 :              KEY_BACKSPACE == nCode && !_pImp->_pEdFileName->HasChildPathFocus() )
    1748             :         {
    1749           0 :             nRet = 0;
    1750             : 
    1751           0 :             if ( !nRet && _pImp->_pBtnUp->IsEnabled() )
    1752             :             {
    1753           0 :                 PrevLevel_Impl();
    1754           0 :                 nRet = 1;
    1755             :             }
    1756             :         }
    1757             :     }
    1758           0 :     return nRet ? nRet : ModalDialog::Notify( rNEvt );
    1759             : }
    1760             : 
    1761             : //*****************************************************************************
    1762             : 
    1763           0 : long SvtFileDialog::OK()
    1764             : {
    1765           0 :     return sal_True;
    1766             : }
    1767             : 
    1768             : //*****************************************************************************
    1769             : 
    1770             : class SvtDefModalDialogParent_Impl
    1771             : {
    1772             : private:
    1773             :     Window* _pOld;
    1774             : 
    1775             : public:
    1776           0 :     SvtDefModalDialogParent_Impl( Window *pNew ) :
    1777           0 :         _pOld( Application::GetDefDialogParent() )
    1778           0 :         { Application::SetDefDialogParent( pNew ); }
    1779             : 
    1780           0 :     ~SvtDefModalDialogParent_Impl() { Application::SetDefDialogParent( _pOld ); }
    1781             : };
    1782             : 
    1783             : //*****************************************************************************
    1784             : 
    1785             : //---------------------------------------------------------------------
    1786           0 : void SvtFileDialog::updateListboxLabelSizes()
    1787             : {
    1788             :     sal_Int16 nLineControlId[5] = {
    1789             :         LISTBOX_VERSION, LISTBOX_TEMPLATE, LISTBOX_IMAGE_TEMPLATE, LISTBOX_FILTER, EDIT_FILEURL
    1790           0 :     };
    1791             : 
    1792             :     // determine the maximum width needed for the listbox labels
    1793           0 :     long nMaxWidth = 0;
    1794           0 :     for ( sal_Int32 i=0; i<5; ++i )
    1795             :     {
    1796           0 :         FixedText* pLabel = static_cast< FixedText* >( getControl( nLineControlId[i], sal_True ) );
    1797           0 :         if ( !pLabel )
    1798           0 :             continue;
    1799           0 :         nMaxWidth = ::std::max( pLabel->GetTextWidth( pLabel->GetText() ), nMaxWidth );
    1800             :     }
    1801             : 
    1802             :     // ensure that all labels are wide enough
    1803           0 :     for ( sal_Int32 i=0; i<5; ++i )
    1804             :     {
    1805           0 :         FixedText* pLabel = static_cast< FixedText* >( getControl( nLineControlId[i], sal_True ) );
    1806           0 :         ListBox* pListbox = static_cast< ListBox* >( getControl( nLineControlId[i], sal_False ) );
    1807           0 :         if ( !pLabel || !pListbox )
    1808           0 :             continue;
    1809           0 :         Size aCurrentSize( pLabel->GetSizePixel() );
    1810           0 :         if ( aCurrentSize.Width() >= nMaxWidth )
    1811           0 :             continue;
    1812             : 
    1813           0 :         long nChange = nMaxWidth - aCurrentSize.Width();
    1814           0 :         pLabel->SetSizePixel( Size( nMaxWidth, aCurrentSize.Height() ) );
    1815             : 
    1816           0 :         aCurrentSize = pListbox->GetSizePixel();
    1817           0 :         pListbox->SetSizePixel( Size( aCurrentSize.Width() - nChange, aCurrentSize.Height() ) );
    1818           0 :         lcl_MoveControl( pListbox, nChange, 0 );
    1819             :     }
    1820           0 : }
    1821             : 
    1822             : namespace
    1823             : {
    1824             : 
    1825           0 : bool implIsInvalid( const String & rURL )
    1826             : {
    1827           0 :     SmartContent aContent( rURL );
    1828           0 :     aContent.enableOwnInteractionHandler( ::svt::OFilePickerInteractionHandler::E_DOESNOTEXIST );
    1829           0 :     aContent.isFolder();    // do this _before_ asking isInvalid! Otherwise result might be wrong.
    1830           0 :     return aContent.isInvalid();
    1831             : }
    1832             : 
    1833             : }
    1834             : 
    1835             : //---------------------------------------------------------------------
    1836           0 : String SvtFileDialog::implGetInitialURL( const String& _rPath, const String& _rFallback )
    1837             : {
    1838             :     // an URL parser for the fallback
    1839           0 :     INetURLObject aURLParser;
    1840             : 
    1841             :     // set the path
    1842           0 :     bool bWasAbsolute = sal_False;
    1843           0 :     aURLParser = aURLParser.smartRel2Abs( _rPath, bWasAbsolute );
    1844             : 
    1845             :     // is it a valid folder?
    1846           0 :     m_aContent.bindTo( aURLParser.GetMainURL( INetURLObject::NO_DECODE ) );
    1847           0 :     sal_Bool bIsFolder = m_aContent.isFolder( );    // do this _before_ asking isInvalid!
    1848           0 :     sal_Bool bIsInvalid = m_aContent.isInvalid();
    1849             : 
    1850           0 :     if ( bIsInvalid && m_bHasFilename && !aURLParser.hasFinalSlash() )
    1851             :     {   // check if the parent folder exists
    1852           0 :         INetURLObject aParent( aURLParser );
    1853           0 :         aParent.removeSegment( );
    1854           0 :         aParent.setFinalSlash( );
    1855           0 :         bIsInvalid = implIsInvalid( aParent.GetMainURL( INetURLObject::NO_DECODE ) );
    1856             :     }
    1857             : 
    1858           0 :     if ( bIsInvalid )
    1859             :     {
    1860           0 :         INetURLObject aFallback( _rFallback );
    1861           0 :         bIsInvalid = implIsInvalid( aFallback.GetMainURL( INetURLObject::NO_DECODE ) );
    1862             : 
    1863           0 :         if ( !bIsInvalid )
    1864           0 :             aURLParser = aFallback;
    1865             :     }
    1866             : 
    1867           0 :     if ( bIsInvalid )
    1868             :     {
    1869           0 :         INetURLObject aParent( aURLParser );
    1870           0 :         while ( bIsInvalid && aParent.removeSegment() )
    1871             :         {
    1872           0 :             aParent.setFinalSlash( );
    1873           0 :             bIsInvalid = implIsInvalid( aParent.GetMainURL( INetURLObject::NO_DECODE ) );
    1874             :         }
    1875             : 
    1876           0 :         if ( !bIsInvalid )
    1877           0 :             aURLParser = aParent;
    1878             :     }
    1879             : 
    1880           0 :     if ( !bIsInvalid && bIsFolder )
    1881             :     {
    1882           0 :         aURLParser.setFinalSlash();
    1883             :     }
    1884           0 :     return aURLParser.GetMainURL( INetURLObject::NO_DECODE );
    1885             : }
    1886             : 
    1887             : //---------------------------------------------------------------------
    1888           0 : short SvtFileDialog::Execute()
    1889             : {
    1890           0 :     if ( !PrepareExecute() )
    1891           0 :         return 0;
    1892             : 
    1893             :     // start the dialog
    1894           0 :     _bIsInExecute = sal_True;
    1895           0 :     short nResult = ModalDialog::Execute();
    1896           0 :     _bIsInExecute = sal_False;
    1897             : 
    1898             :     DBG_ASSERT( !m_pCurrentAsyncAction.is(), "SvtFilePicker::Execute: still running an async action!" );
    1899             :         // the dialog should not be cancellable while an async action is running - first, the action
    1900             :         // needs to be cancelled
    1901             : 
    1902             :     // remember last directory
    1903           0 :     if ( RET_OK == nResult )
    1904             :     {
    1905           0 :         INetURLObject aURL( _aPath );
    1906           0 :         if ( aURL.GetProtocol() == INET_PROT_FILE )
    1907             :         {
    1908             :             // remember the selected directory only for file URLs not for virtual folders
    1909           0 :             sal_Int32 nLevel = aURL.getSegmentCount();
    1910           0 :             sal_Bool bDir = m_aContent.isFolder( aURL.GetMainURL( INetURLObject::NO_DECODE ) );
    1911           0 :             if ( nLevel > 1 && ( FILEDLG_TYPE_FILEDLG == _pImp->_eDlgType || !bDir ) )
    1912           0 :                 aURL.removeSegment();
    1913           0 :         }
    1914             :     }
    1915             : 
    1916           0 :     return nResult;
    1917             : }
    1918             : 
    1919             : //---------------------------------------------------------------------
    1920           0 : void SvtFileDialog::StartExecuteModal( const Link& rEndDialogHdl )
    1921             : {
    1922           0 :     PrepareExecute();
    1923             : 
    1924             :     // start of the dialog
    1925           0 :     ModalDialog::StartExecuteModal( rEndDialogHdl );
    1926           0 : }
    1927             : 
    1928             : //-----------------------------------------------------------------------------
    1929           0 : void SvtFileDialog::onAsyncOperationStarted()
    1930             : {
    1931           0 :     EnableUI( sal_False );
    1932             :     // the cancel button must be always enabled
    1933           0 :     _pImp->_pBtnCancel->Enable( sal_True );
    1934           0 :     _pImp->_pBtnCancel->GrabFocus();
    1935           0 : }
    1936             : 
    1937             : //-----------------------------------------------------------------------------
    1938           0 : void SvtFileDialog::onAsyncOperationFinished()
    1939             : {
    1940           0 :     EnableUI( sal_True );
    1941           0 :     m_pCurrentAsyncAction = NULL;
    1942           0 :     if ( !m_bInExecuteAsync )
    1943           0 :         _pImp->_pEdFileName->GrabFocus();
    1944             :         // (if m_bInExecuteAsync is true, then the operation was finished within the minium wait time,
    1945             :         // and to the user, the operation appears to be synchronous)
    1946           0 : }
    1947             : 
    1948             : //-----------------------------------------------------------------------------
    1949           0 : void SvtFileDialog::RemovablePlaceSelected(bool enable)
    1950             : {
    1951           0 :     _pImp->_pPlaces->SetDelEnabled( enable );
    1952           0 : }
    1953             : 
    1954             : //-------------------------------------------------------------------------
    1955           0 : void SvtFileDialog::displayIOException( const String& _rURL, IOErrorCode _eCode )
    1956             : {
    1957             :     try
    1958             :     {
    1959             :         // create make a human-readable string from the URL
    1960           0 :         OUString sDisplayPath( _rURL );
    1961           0 :         ::utl::LocalFileHelper::ConvertURLToSystemPath( _rURL, sDisplayPath );
    1962             : 
    1963             :         // build an own exception which tells "access denied"
    1964           0 :         InteractiveAugmentedIOException aException;
    1965           0 :         aException.Arguments.realloc( 2 );
    1966           0 :         aException.Arguments[ 0 ] <<= sDisplayPath;
    1967           0 :         aException.Arguments[ 1 ] <<= PropertyValue(
    1968             :             OUString( "Uri" ),
    1969           0 :             -1, aException.Arguments[ 0 ], PropertyState_DIRECT_VALUE
    1970           0 :         );
    1971             :             // (formerly, it was sufficient to put the URL first parameter. Nowadays,
    1972             :             // the services expects the URL in a PropertyValue named "Uri" ...)
    1973           0 :         aException.Code = _eCode;
    1974           0 :         aException.Classification = InteractionClassification_ERROR;
    1975             : 
    1976             :         // let and interaction handler handle this exception
    1977           0 :         ::comphelper::OInteractionRequest* pRequest = NULL;
    1978             :         Reference< ::com::sun::star::task::XInteractionRequest > xRequest = pRequest =
    1979           0 :             new ::comphelper::OInteractionRequest( makeAny( aException ) );
    1980           0 :         pRequest->addContinuation( new ::comphelper::OInteractionAbort( ) );
    1981             : 
    1982             :         Reference< XInteractionHandler2 > xHandler(
    1983           0 :             InteractionHandler::createWithParent( ::comphelper::getProcessComponentContext(), 0 ) );
    1984           0 :         xHandler->handle( xRequest );
    1985             :     }
    1986           0 :     catch( const Exception& )
    1987             :     {
    1988             :         OSL_FAIL( "iodlg::displayIOException: caught an exception!" );
    1989             :     }
    1990           0 : }
    1991             : 
    1992             : //-----------------------------------------------------------------------------
    1993           0 : void SvtFileDialog::EnableUI( sal_Bool _bEnable )
    1994             : {
    1995           0 :     Enable( _bEnable );
    1996             : 
    1997           0 :     if ( _bEnable )
    1998             :     {
    1999           0 :         for ( ::std::set< Control* >::iterator aLoop = m_aDisabledControls.begin();
    2000           0 :               aLoop != m_aDisabledControls.end();
    2001             :               ++aLoop
    2002             :             )
    2003             :         {
    2004           0 :             (*aLoop)->Enable( sal_False );
    2005             :         }
    2006             :     }
    2007           0 : }
    2008             : 
    2009             : //-----------------------------------------------------------------------------
    2010           0 : void SvtFileDialog::EnableControl( Control* _pControl, sal_Bool _bEnable )
    2011             : {
    2012           0 :     if ( !_pControl )
    2013             :     {
    2014             :         SAL_WARN( "fpicker.office", "SvtFileDialog::EnableControl: invalid control!" );
    2015           0 :         return;
    2016             :     }
    2017             : 
    2018           0 :     _pControl->Enable( _bEnable );
    2019             : 
    2020           0 :     if ( _bEnable )
    2021             :     {
    2022           0 :         ::std::set< Control* >::iterator aPos = m_aDisabledControls.find( _pControl );
    2023           0 :         if ( m_aDisabledControls.end() != aPos )
    2024           0 :             m_aDisabledControls.erase( aPos );
    2025             :     }
    2026             :     else
    2027           0 :         m_aDisabledControls.insert( _pControl );
    2028             : }
    2029             : 
    2030             : //----------------------------------------------------------------------------
    2031             : 
    2032           0 : short SvtFileDialog::PrepareExecute()
    2033             : {
    2034           0 :     OUString aEnvValue;
    2035           0 :     if ( getEnvironmentValue( "WorkDirMustContainRemovableMedia", aEnvValue ) && aEnvValue == "1" )
    2036             :     {
    2037             :         try
    2038             :         {
    2039           0 :             INetURLObject aStdDir( GetStandardDir() );
    2040             :             ::ucbhelper::Content aCnt( OUString( aStdDir.GetMainURL(
    2041             :                                                     INetURLObject::NO_DECODE ) ),
    2042             :                                  Reference< XCommandEnvironment >(),
    2043           0 :                                  comphelper::getProcessComponentContext() );
    2044           0 :             Sequence< OUString > aProps(2);
    2045           0 :             aProps[0] = OUString( "IsVolume" );
    2046           0 :             aProps[1] = OUString( "IsRemoveable" );
    2047             : 
    2048             :             Reference< XResultSet > xResultSet
    2049           0 :                 = aCnt.createCursor( aProps, ::ucbhelper::INCLUDE_FOLDERS_ONLY );
    2050           0 :             if ( xResultSet.is() )
    2051             :             {
    2052           0 :                 Reference< XRow > xRow( xResultSet, UNO_QUERY );
    2053             : 
    2054           0 :                 bool bEmpty = true;
    2055           0 :                 if ( !xResultSet->next() )
    2056             :                 {
    2057             :                     // folder is empty
    2058           0 :                     bEmpty = true;
    2059             :                 }
    2060             :                 else
    2061             :                 {
    2062           0 :                                 bEmpty = false;
    2063             :                 }
    2064             : 
    2065           0 :                 if ( bEmpty )
    2066             :                 {
    2067           0 :                     ErrorBox aBox( this, WB_OK, SvtResId( STR_SVT_NOREMOVABLEDEVICE ) );
    2068           0 :                     aBox.Execute();
    2069           0 :                     return 0;
    2070           0 :                 }
    2071           0 :             }
    2072             :         }
    2073           0 :         catch ( ContentCreationException const & )
    2074             :         {
    2075             :         }
    2076           0 :         catch ( CommandAbortedException const & )
    2077             :         {
    2078             :         }
    2079             :     }
    2080             : 
    2081           0 :     if ( ( _pImp->_nStyle & WB_SAVEAS ) && m_bHasFilename )
    2082             :         // when doing a save-as, we do not want the handler to handle "this file does not exist" messages
    2083             :         // - finally we're going to save that file, aren't we?
    2084           0 :         m_aContent.enableOwnInteractionHandler(::svt::OFilePickerInteractionHandler::E_DOESNOTEXIST);
    2085             :     else
    2086           0 :         m_aContent.enableDefaultInteractionHandler();
    2087             : 
    2088             :     // possibly just a filename without a path
    2089           0 :     String aFileNameOnly;
    2090           0 :     if( _aPath.Len() && (_pImp->_eMode == FILEDLG_MODE_SAVE)
    2091           0 :                      && (_aPath.Search(':') == STRING_NOTFOUND)
    2092           0 :                      && (_aPath.Search('\\') == STRING_NOTFOUND)
    2093           0 :                      && (_aPath.Search('/') == STRING_NOTFOUND))
    2094             :     {
    2095           0 :         aFileNameOnly = _aPath;
    2096           0 :         _aPath.Erase();
    2097             :     }
    2098             : 
    2099             :     // no starting path specified?
    2100           0 :     if ( !_aPath.Len() )
    2101             :     {
    2102             :         // then use the standard directory
    2103           0 :         _aPath = lcl_ensureFinalSlash( _pImp->GetStandardDir() );
    2104             : 
    2105             :         // attach given filename to path
    2106           0 :         if ( aFileNameOnly.Len() )
    2107           0 :             _aPath += aFileNameOnly;
    2108             :     }
    2109             : 
    2110             :     //.....................................................................
    2111           0 :     _aPath = implGetInitialURL( _aPath, GetStandardDir() );
    2112             : 
    2113           0 :     if ( _pImp->_nStyle & WB_SAVEAS && !m_bHasFilename )
    2114             :         // when doing a save-as, we do not want the handler to handle "this file does not exist" messages
    2115             :         // - finally we're going to save that file, aren't we?
    2116           0 :         m_aContent.enableOwnInteractionHandler(::svt::OFilePickerInteractionHandler::E_DOESNOTEXIST);
    2117             : 
    2118             :     // if applicable show filter
    2119           0 :     _pImp->InitFilterList();
    2120             : 
    2121             :     // set up initial filter
    2122           0 :     sal_uInt16 nFilterCount = GetFilterCount();
    2123           0 :     OUString aAll = SvtResId( STR_FILTERNAME_ALL ).toString();
    2124           0 :     sal_Bool bHasAll = _pImp->HasFilterListEntry( aAll );
    2125           0 :     if ( _pImp->GetCurFilter() || nFilterCount == 1 || ( nFilterCount == 2 && bHasAll ) )
    2126             :     {
    2127             :         // if applicable set the only filter or the only filter that
    2128             :         // does not refer to all files, as the current one
    2129           0 :         if ( !_pImp->GetCurFilter() )
    2130             :         {
    2131           0 :             sal_uInt16 nPos = 0;
    2132           0 :             if ( 2 == nFilterCount && bHasAll )
    2133             :             {
    2134           0 :                 nPos = nFilterCount;
    2135           0 :                 while ( nPos-- )
    2136             :                 {
    2137           0 :                     if ( aAll != OUString( GetFilterName( nPos ) ) )
    2138           0 :                         break;
    2139             :                 }
    2140             :             }
    2141           0 :             SvtFileDialogFilter_Impl* pNewCurFilter = &(*_pImp->_pFilter)[ nPos ];
    2142             :             DBG_ASSERT( pNewCurFilter, "SvtFileDialog::Execute: invalid filter pos!" );
    2143           0 :             _pImp->SetCurFilter( pNewCurFilter, pNewCurFilter->GetName() );
    2144             :         }
    2145             : 
    2146             :         // adjust view
    2147           0 :         _pImp->SelectFilterListEntry( _pImp->GetCurFilter()->GetName() );
    2148           0 :         SetDefaultExt( _pImp->GetCurFilter()->GetExtension() );
    2149           0 :         sal_uInt16 nSepPos = GetDefaultExt().Search( FILEDIALOG_DEF_EXTSEP );
    2150           0 :         if ( nSepPos != STRING_NOTFOUND )
    2151           0 :             EraseDefaultExt( nSepPos );
    2152             :     }
    2153             :     else
    2154             :     {
    2155             :         // if applicable set respectively create filter for all files
    2156           0 :         if ( !bHasAll )
    2157             :         {
    2158           0 :             SvtFileDialogFilter_Impl* pAllFilter = implAddFilter( aAll, OUString(FILEDIALOG_FILTER_ALL) );
    2159           0 :             _pImp->InsertFilterListEntry( pAllFilter );
    2160           0 :             _pImp->SetCurFilter( pAllFilter, aAll );
    2161             :         }
    2162           0 :         _pImp->SelectFilterListEntry( aAll );
    2163             :     }
    2164             : 
    2165           0 :     _pImp->_pDefaultFilter = _pImp->GetCurFilter();
    2166             : 
    2167             :     // if applicable isolate filter
    2168           0 :     String aFilter;
    2169             : 
    2170           0 :     if ( !IsolateFilterFromPath_Impl( _aPath, aFilter ) )
    2171           0 :         return 0;
    2172             : 
    2173           0 :     sal_uInt16 nNewFilterFlags = adjustFilter( aFilter );
    2174           0 :     if ( nNewFilterFlags & ( FLT_NONEMPTY | FLT_USERFILTER ) )
    2175             :     {
    2176           0 :         _pImp->_pEdFileName->SetText( aFilter );
    2177             :     }
    2178             : 
    2179             :     // create and show instance for set path
    2180           0 :     INetURLObject aFolderURL( _aPath );
    2181           0 :     String aFileName( aFolderURL.getName( INetURLObject::LAST_SEGMENT, false ) );
    2182           0 :     xub_StrLen nFileNameLen = aFileName.Len();
    2183           0 :     bool bFileToSelect = nFileNameLen != 0;
    2184           0 :     if ( bFileToSelect && aFileName.GetChar( nFileNameLen - 1 ) != INET_PATH_TOKEN )
    2185             :     {
    2186           0 :         _pImp->_pEdFileName->SetText( GET_DECODED_NAME( aFolderURL ) );
    2187           0 :         aFolderURL.removeSegment();
    2188             :     }
    2189             : 
    2190           0 :     INetURLObject aObj = aFolderURL;
    2191           0 :     if ( aObj.GetProtocol() == INET_PROT_FILE )
    2192             :     {
    2193             :         // set folder as current directory
    2194           0 :         aObj.setFinalSlash();
    2195             :     }
    2196             : 
    2197           0 :     UpdateControls( aObj.GetMainURL( INetURLObject::NO_DECODE ) );
    2198             : 
    2199             :     // Somebody might want to enable some controls acording to the current filter
    2200           0 :     FilterSelect();
    2201             : 
    2202           0 :     ViewHdl_Impl( this, NULL );
    2203           0 :     OpenURL_Impl( aObj.GetMainURL( INetURLObject::NO_DECODE ) );
    2204             : 
    2205           0 :     _pFileView->Show();
    2206           0 :     _pSplitter->Show();
    2207           0 :     SvtDefModalDialogParent_Impl aDefParent( this );
    2208             : 
    2209             :     // if applicable read and set size from ini
    2210           0 :     InitSize();
    2211             : 
    2212           0 :     return 1;
    2213             : }
    2214             : 
    2215             : //-----------------------------------------------------------------------------
    2216           0 : void SvtFileDialog::executeAsync( ::svt::AsyncPickerAction::Action _eAction,
    2217             :                                     const String& _rURL, const String& _rFilter )
    2218             : {
    2219             :     DBG_ASSERT( !m_pCurrentAsyncAction.is(), "SvtFileDialog::executeAsync: previous async action not yet finished!" );
    2220             : 
    2221           0 :     m_pCurrentAsyncAction = new AsyncPickerAction( this, _pFileView, _eAction );
    2222             : 
    2223           0 :     bool bReallyAsync = true;
    2224           0 :     m_aConfiguration.getNodeValue( OUString( "FillAsynchronously" ) ) >>= bReallyAsync;
    2225             : 
    2226           0 :     sal_Int32 nMinTimeout = 0;
    2227           0 :     m_aConfiguration.getNodeValue( OUString( "Timeout/Min" ) ) >>= nMinTimeout;
    2228           0 :     sal_Int32 nMaxTimeout = 0;
    2229           0 :     m_aConfiguration.getNodeValue( OUString( "Timeout/Max" ) ) >>= nMaxTimeout;
    2230             : 
    2231           0 :     m_bInExecuteAsync = true;
    2232           0 :     m_pCurrentAsyncAction->execute( _rURL, _rFilter, bReallyAsync ? nMinTimeout : -1, nMaxTimeout, GetBlackList() );
    2233           0 :     m_bInExecuteAsync = false;
    2234           0 : }
    2235             : 
    2236             : //*****************************************************************************
    2237             : 
    2238           0 : void SvtFileDialog::FileSelect()
    2239             : {
    2240           0 :     if ( _pFileNotifier )
    2241           0 :         _pFileNotifier->notify( FILE_SELECTION_CHANGED, 0 );
    2242           0 : }
    2243             : 
    2244             : //*****************************************************************************
    2245             : 
    2246           0 : void SvtFileDialog::FilterSelect()
    2247             : {
    2248           0 :     if ( _pFileNotifier )
    2249             :         _pFileNotifier->notify( CTRL_STATE_CHANGED,
    2250           0 :                                 LISTBOX_FILTER );
    2251           0 : }
    2252             : 
    2253             : //*****************************************************************************
    2254             : 
    2255           0 : void SvtFileDialog::SetStandardDir( const String& rStdDir )
    2256             : 
    2257             : /*  [Description]
    2258             : 
    2259             :    This method sets the path for the default button.
    2260             : */
    2261             : 
    2262             : {
    2263           0 :     INetURLObject aObj( rStdDir );
    2264             :     DBG_ASSERT( aObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid protocol!" );
    2265           0 :     aObj.setFinalSlash();
    2266           0 :     _pImp->SetStandardDir( aObj.GetMainURL( INetURLObject::NO_DECODE ) );
    2267           0 : }
    2268             : 
    2269           0 : void SvtFileDialog::SetBlackList( const ::com::sun::star::uno::Sequence< OUString >& rBlackList )
    2270             : {
    2271           0 :     _pImp->SetBlackList( rBlackList );
    2272           0 : }
    2273             : 
    2274             : //*****************************************************************************
    2275             : 
    2276           0 : const ::com::sun::star::uno::Sequence< OUString >& SvtFileDialog::GetBlackList() const
    2277             : {
    2278           0 :     return _pImp->GetBlackList();
    2279             : }
    2280             : //*****************************************************************************
    2281             : 
    2282           0 : const String& SvtFileDialog::GetStandardDir() const
    2283             : 
    2284             : /*  [Description]
    2285             : 
    2286             :     This method returns the standard path.
    2287             : */
    2288             : 
    2289             : {
    2290           0 :     return _pImp->GetStandardDir();
    2291             : }
    2292             : 
    2293             : //*****************************************************************************
    2294             : 
    2295           0 : void SvtFileDialog::PrevLevel_Impl()
    2296             : {
    2297           0 :     _pFileView->EndInplaceEditing( false );
    2298             : 
    2299           0 :     String sDummy;
    2300           0 :     executeAsync( AsyncPickerAction::ePrevLevel, sDummy, sDummy );
    2301           0 : }
    2302             : 
    2303             : //*****************************************************************************
    2304             : 
    2305           0 : void SvtFileDialog::OpenURL_Impl( const String& _rURL )
    2306             : {
    2307           0 :     _pFileView->EndInplaceEditing( false );
    2308             : 
    2309           0 :     executeAsync( AsyncPickerAction::eOpenURL, _rURL, getMostCurrentFilter( _pImp ) );
    2310           0 : }
    2311             : 
    2312             : //*****************************************************************************
    2313           0 : SvtFileDialogFilter_Impl* SvtFileDialog::implAddFilter( const String& _rFilter, const String& _rType )
    2314             : {
    2315           0 :     SvtFileDialogFilter_Impl* pNewFilter = new SvtFileDialogFilter_Impl( _rFilter, _rType );
    2316           0 :     _pImp->_pFilter->push_front( pNewFilter );
    2317             : 
    2318           0 :     if ( !_pImp->GetCurFilter() )
    2319           0 :         _pImp->SetCurFilter( pNewFilter, _rFilter );
    2320             : 
    2321           0 :     return pNewFilter;
    2322             : }
    2323             : 
    2324             : //*****************************************************************************
    2325             : 
    2326           0 : void SvtFileDialog::AddFilter( const String& _rFilter, const String& _rType )
    2327             : {
    2328             :     DBG_ASSERT( !IsInExecute(), "SvtFileDialog::AddFilter: currently executing!" );
    2329           0 :     implAddFilter ( _rFilter, _rType );
    2330           0 : }
    2331             : 
    2332             : //*****************************************************************************
    2333           0 : void SvtFileDialog::AddFilterGroup( const String& _rFilter, const Sequence< StringPair >& _rFilters )
    2334             : {
    2335             :     DBG_ASSERT( !IsInExecute(), "SvtFileDialog::AddFilter: currently executing!" );
    2336             : 
    2337           0 :     implAddFilter( _rFilter, String() );
    2338           0 :     const StringPair* pSubFilters       =               _rFilters.getConstArray();
    2339           0 :     const StringPair* pSubFiltersEnd    = pSubFilters + _rFilters.getLength();
    2340           0 :     for ( ; pSubFilters != pSubFiltersEnd; ++pSubFilters )
    2341           0 :         implAddFilter( pSubFilters->First, pSubFilters->Second );
    2342           0 : }
    2343             : 
    2344             : //-----------------------------------------------------------------------------
    2345           0 : void SvtFileDialog::SetCurFilter( const String& rFilter )
    2346             : {
    2347             :     DBG_ASSERT( !IsInExecute(), "SvtFileDialog::SetCurFilter: currently executing!" );
    2348             : 
    2349             :     // look for corresponding filter
    2350           0 :     sal_uInt16 nPos = _pImp->_pFilter->size();
    2351             : 
    2352           0 :     while ( nPos-- )
    2353             :     {
    2354           0 :         SvtFileDialogFilter_Impl* pFilter = &(*_pImp->_pFilter)[ nPos ];
    2355           0 :         if ( pFilter->GetName() == rFilter )
    2356             :         {
    2357           0 :             _pImp->SetCurFilter( pFilter, rFilter );
    2358           0 :             break;
    2359             :         }
    2360             :     }
    2361           0 : }
    2362             : 
    2363             : //*****************************************************************************
    2364             : 
    2365           0 : String SvtFileDialog::GetCurFilter() const
    2366             : {
    2367           0 :     String aFilter;
    2368             : 
    2369           0 :     const SvtFileDialogFilter_Impl* pCurrentFilter = _pImp->GetCurFilter();
    2370           0 :     if ( pCurrentFilter )
    2371           0 :         aFilter = pCurrentFilter->GetName();
    2372             : 
    2373           0 :     return aFilter;
    2374             : }
    2375             : 
    2376           0 : String SvtFileDialog::getCurFilter( ) const
    2377             : {
    2378           0 :     return GetCurFilter();
    2379             : }
    2380             : 
    2381             : //*****************************************************************************
    2382             : 
    2383           0 : sal_uInt16 SvtFileDialog::GetFilterCount() const
    2384             : {
    2385           0 :     return _pImp->_pFilter->size();
    2386             : }
    2387             : 
    2388             : //*****************************************************************************
    2389             : 
    2390           0 : const String& SvtFileDialog::GetFilterName( sal_uInt16 nPos ) const
    2391             : {
    2392             :     DBG_ASSERT( nPos < GetFilterCount(), "invalid index" );
    2393           0 :     return (*_pImp->_pFilter)[ nPos ].GetName();
    2394             : }
    2395             : 
    2396             : //*****************************************************************************
    2397             : 
    2398           0 : void SvtFileDialog::InitSize()
    2399             : {
    2400           0 :     if ( ! _pImp->_aIniKey.Len() )
    2401           0 :         return;
    2402             : 
    2403           0 :     Size aDlgSize = GetResizeOutputSizePixel();
    2404           0 :     SetMinOutputSizePixel( aDlgSize );
    2405             : 
    2406           0 :     if ( !_pImp->_nFixDeltaHeight )
    2407             :     {
    2408             :         // calculate and save fixsize
    2409           0 :         long nBoxH = _pFileView->GetSizePixel().Height();
    2410           0 :         long nH = GetSizePixel().Height();
    2411           0 :         _pImp->_nFixDeltaHeight = nH - nBoxH;
    2412             :     }
    2413             : 
    2414             :     // initialize from config
    2415           0 :     SvtViewOptions aDlgOpt( E_DIALOG, _pImp->_aIniKey );
    2416             : 
    2417           0 :     if ( aDlgOpt.Exists() )
    2418             :     {
    2419           0 :         SetWindowState(OUStringToOString(aDlgOpt.GetWindowState(), osl_getThreadTextEncoding()));
    2420             : 
    2421           0 :         Any aUserData = aDlgOpt.GetUserItem( OUString( "UserData" ));
    2422           0 :         OUString sCfgStr;
    2423           0 :         if ( aUserData >>= sCfgStr )
    2424           0 :             _pFileView->SetConfigString( String( sCfgStr ) );
    2425           0 :     }
    2426             : }
    2427             : 
    2428             : //*****************************************************************************
    2429             : 
    2430           0 : std::vector<OUString> SvtFileDialog::GetPathList() const
    2431             : {
    2432           0 :     std::vector<OUString> aList;
    2433           0 :     sal_uLong           nCount = _pFileView->GetSelectionCount();
    2434           0 :     SvTreeListEntry*    pEntry = nCount ? _pFileView->FirstSelected() : NULL;
    2435             : 
    2436           0 :     if ( ! pEntry )
    2437             :     {
    2438           0 :         if ( !_pImp->_pEdFileName->GetText().isEmpty() && _bIsInExecute )
    2439           0 :             aList.push_back(_pImp->_pEdFileName->GetURL());
    2440             :         else
    2441           0 :             aList.push_back(_aPath);
    2442             :     }
    2443             :     else
    2444             :     {
    2445           0 :         while ( pEntry )
    2446             :         {
    2447           0 :             aList.push_back(_pFileView->GetURL(pEntry));
    2448           0 :             pEntry = _pFileView->NextSelected( pEntry );
    2449             :         }
    2450             :     }
    2451             : 
    2452           0 :     return aList;
    2453             : }
    2454             : 
    2455             : //*****************************************************************************
    2456             : 
    2457           0 : void SvtFileDialog::implArrangeControls()
    2458             : {
    2459             :     // this is the list of controls in the order they should be tabbed
    2460             :     // from topleft to bottomright
    2461             :     // pb: #136070# new order so all LabeledBy relations are correct now
    2462             :     Control* pControls[] =
    2463             :     {
    2464             :         _pImp->_pEdCurrentPath, _pImp->_pBtnConnectToServer,
    2465             :         _pImp->_pBtnUp, _pImp->_pBtnNewFolder,                              // image buttons
    2466             :         _pImp->_pPlaces,                                                    // list of places
    2467             :         _pFileView,                                                         // the file view
    2468             :         _pImp->_pFtFileName, _pImp->_pEdFileName,
    2469             :         _pImp->_pFtFileVersion, _pImp->_pLbFileVersion,
    2470             :         _pImp->_pFtTemplates, _pImp->_pLbTemplates,
    2471             :         _pImp->_pFtImageTemplates, _pImp->_pLbImageTemplates,
    2472           0 :         _pImp->_pFtFileType, _pImp->GetFilterListControl(),                 // edit fields/list boxes
    2473             :         _pImp->_pCbPassword, _pImp->_pCbAutoExtension, _pImp->_pCbOptions,  // checkboxes
    2474             :         _pCbReadOnly, _pCbLinkBox, _pCbPreviewBox, _pCbSelection, _pPbPlay, // check boxes (continued)
    2475             :         _pImp->_pBtnFileOpen, _pImp->_pBtnCancel, _pImp->_pBtnHelp          // buttons
    2476             : 
    2477             :         // (including the FixedTexts is important - not for tabbing order (they're irrelevant there),
    2478             :         // but for working keyboard shortcuts)
    2479           0 :     };
    2480             : 
    2481             :     // loop through all these controls and adjust the z-order
    2482           0 :     Window* pPreviousWin = NULL;
    2483           0 :     Control** pCurrent = pControls;
    2484           0 :     for ( sal_Int32 i = 0; i < sal_Int32(sizeof( pControls ) / sizeof( pControls[ 0 ] )); ++i, ++pCurrent )
    2485             :     {
    2486           0 :         if ( !*pCurrent )
    2487             :             // this control is not available in the current operation mode -> skip
    2488           0 :             continue;
    2489             : 
    2490           0 :         if ( pPreviousWin )
    2491           0 :             (*pCurrent)->SetZOrder( pPreviousWin, WINDOW_ZORDER_BEHIND );
    2492             :         else
    2493           0 :             (*pCurrent)->SetZOrder( NULL, WINDOW_ZORDER_FIRST );
    2494             : 
    2495           0 :         pPreviousWin = *pCurrent;
    2496             :     }
    2497             : 
    2498             :     // FileName edit not the first control but it should have the focus initially
    2499           0 :     _pImp->_pEdFileName->GrabFocus();
    2500           0 : }
    2501             : 
    2502             : //*****************************************************************************
    2503             : 
    2504           0 : sal_Bool SvtFileDialog::IsolateFilterFromPath_Impl( String& rPath, String& rFilter )
    2505             : {
    2506           0 :     String aEmpty;
    2507           0 :     String aReversePath = comphelper::string::reverseString(rPath);
    2508           0 :     sal_uInt16 nQuestionMarkPos = rPath.Search( '?' );
    2509             : 
    2510           0 :     if ( nQuestionMarkPos != STRING_NOTFOUND )
    2511             :     {
    2512             :         // use question mark as wildcard only for files
    2513           0 :         INetProtocol eProt = INetURLObject::CompareProtocolScheme( rPath );
    2514             : 
    2515           0 :         if ( INET_PROT_NOT_VALID != eProt && INET_PROT_FILE != eProt )
    2516           0 :             nQuestionMarkPos = STRING_NOTFOUND;
    2517             :     }
    2518           0 :     sal_uInt16 nWildCardPos = std::min( rPath.Search( FILEDIALOG_DEF_WILDCARD ), nQuestionMarkPos );
    2519           0 :     rFilter = aEmpty;
    2520             : 
    2521           0 :     if ( nWildCardPos != STRING_NOTFOUND )
    2522             :     {
    2523           0 :         sal_uInt16 nPathTokenPos = aReversePath.Search( INET_PATH_TOKEN );
    2524             : 
    2525           0 :         if ( nPathTokenPos == STRING_NOTFOUND )
    2526             :         {
    2527             :             OUString aDelim(
    2528             : #if defined(WNT)
    2529             :                     '\\'
    2530             : #else
    2531             :                     '/'
    2532             : #endif
    2533           0 :             );
    2534             : 
    2535           0 :             nPathTokenPos = aReversePath.Search( aDelim );
    2536             : #if !defined( UNX )
    2537             :             if ( nPathTokenPos == STRING_NOTFOUND )
    2538             :             {
    2539             :                 nPathTokenPos = aReversePath.Search( ':' );
    2540             :             }
    2541             : #endif
    2542             :         }
    2543             : 
    2544             :         // check syntax
    2545           0 :         if ( nPathTokenPos != STRING_NOTFOUND )
    2546             :         {
    2547           0 :             if ( nPathTokenPos < (rPath.Len() - nWildCardPos - 1) )
    2548             :             {
    2549           0 :                 ErrorHandler::HandleError( ERRCODE_SFX_INVALIDSYNTAX );
    2550           0 :                 return sal_False;
    2551             :             }
    2552             : 
    2553             :             // cut off filter
    2554           0 :             rFilter = aReversePath;
    2555           0 :             rFilter.Erase( nPathTokenPos );
    2556           0 :             rFilter = comphelper::string::reverseString(rFilter);
    2557             : 
    2558             :             // determine folder
    2559           0 :             rPath = aReversePath;
    2560           0 :             rPath.Erase( 0, nPathTokenPos );
    2561           0 :             rPath = comphelper::string::reverseString(rPath);
    2562             :         }
    2563             :         else
    2564             :         {
    2565           0 :             rFilter = rPath;
    2566           0 :             rPath = aEmpty;
    2567             :         }
    2568             :     }
    2569             : 
    2570           0 :     return sal_True;
    2571             : }
    2572             : 
    2573             : //-----------------------------------------------------------------------------
    2574           0 : void SvtFileDialog::implUpdateImages( )
    2575             : {
    2576           0 :     m_aImages = ImageList( SvtResId( RID_FILEPICKER_IMAGES ) );
    2577             : 
    2578             :     // set the appropriate images on the buttons
    2579           0 :     if ( _pImp->_pBtnUp )
    2580           0 :         _pImp->_pBtnUp->SetModeImage( GetButtonImage( IMG_FILEDLG_BTN_UP ) );
    2581             : 
    2582           0 :     if ( _pImp->_pBtnNewFolder )
    2583           0 :         _pImp->_pBtnNewFolder->SetModeImage( GetButtonImage( IMG_FILEDLG_CREATEFOLDER ) );
    2584           0 : }
    2585             : 
    2586             : //-----------------------------------------------------------------------------
    2587           0 : void SvtFileDialog::DataChanged( const DataChangedEvent& _rDCEvt )
    2588             : {
    2589           0 :     if ( DATACHANGED_SETTINGS == _rDCEvt.GetType() )
    2590           0 :         implUpdateImages( );
    2591             : 
    2592           0 :     ModalDialog::DataChanged( _rDCEvt );
    2593           0 : }
    2594             : 
    2595             : //-----------------------------------------------------------------------------
    2596           0 : void SvtFileDialog::Resize()
    2597             : {
    2598           0 :     if ( IsRollUp() )
    2599           0 :         return;
    2600             : 
    2601           0 :     Size aDlgSize = GetResizeOutputSizePixel();
    2602           0 :     Size aOldSize = _pImp->_aDlgSize;
    2603           0 :     _pImp->_aDlgSize = aDlgSize;
    2604           0 :     long nWinDeltaW = 0;
    2605             : 
    2606           0 :     if ( _pPrevWin &&
    2607           0 :          _pPrevWin->GetPosPixel().X() > _pFileView->GetPosPixel().X() )
    2608             :     {
    2609           0 :         nWinDeltaW = _pPrevWin->GetOutputSizePixel().Width() + _pImp->_a6Size.Width();
    2610             :     }
    2611             : 
    2612           0 :     Size aNewSize = _pFileView->GetSizePixel();
    2613           0 :     Point aBoxPos( _pFileView->GetPosPixel() );
    2614           0 :     long nDeltaY = aNewSize.Height();
    2615           0 :     long nDeltaX = aNewSize.Width();
    2616           0 :     aNewSize.Height() = aDlgSize.Height() - _pImp->_nFixDeltaHeight;
    2617           0 :     aNewSize.Width() = aDlgSize.Width() - aBoxPos.X() - _pImp->_a6Size.Width() - nWinDeltaW;
    2618           0 :     if ( aOldSize.Height() )
    2619           0 :         nDeltaY = _pImp->_aDlgSize.Height() - aOldSize.Height();
    2620             :     else
    2621           0 :         nDeltaY = aNewSize.Height() - nDeltaY;
    2622           0 :     nDeltaX = aNewSize.Width() - nDeltaX;
    2623             : 
    2624           0 :     if ( nWinDeltaW )
    2625           0 :         nWinDeltaW = nDeltaX * 2 / 3;
    2626           0 :     aNewSize.Width() -= nWinDeltaW;
    2627           0 :     nDeltaX -= nWinDeltaW;
    2628             : 
    2629           0 :     _pFileView->SetSizePixel( aNewSize );
    2630             : 
    2631             :     // Resize the Splitter to fit the height
    2632           0 :     Size splitterNewSize = _pSplitter->GetSizePixel( );
    2633           0 :     splitterNewSize.Height() += nDeltaY;
    2634           0 :     _pSplitter->SetSizePixel( splitterNewSize );
    2635           0 :     sal_Int32 nMinX = _pImp->_pPlaces->GetPosPixel( ).X( );
    2636           0 :     sal_Int32 nMaxX = _pFileView->GetPosPixel( ).X( ) + _pFileView->GetSizePixel( ).Width() - nMinX;
    2637           0 :     _pSplitter->SetDragRectPixel( Rectangle( Point( nMinX, 0 ), Size( nMaxX, aDlgSize.Width() ) ) );
    2638             : 
    2639             :     // Resize the places list box to fit the height of the FileView
    2640           0 :     Size placesNewSize(_pImp->_pPlaces->GetSizePixel());
    2641           0 :     placesNewSize.Height() += nDeltaY;
    2642           0 :     _pImp->_pPlaces->SetSizePixel( placesNewSize );
    2643             : 
    2644           0 :     if ( !nDeltaY && !nDeltaX )
    2645             :         // This resize was only called to show or hide the indicator.
    2646           0 :         return;
    2647             : 
    2648             :     // -------------
    2649             :     // move controls
    2650             : 
    2651             :     // controls to move vertically
    2652             :     {
    2653             :         Control* aMoveControlsVert[] =
    2654             :         {
    2655             :             _pImp->_pFtFileName, _pImp->_pEdFileName, _pImp->_pFtFileVersion, _pImp->_pLbFileVersion,
    2656             :             _pImp->_pFtTemplates, _pImp->_pLbTemplates, _pImp->_pFtImageTemplates, _pImp->_pLbImageTemplates,
    2657           0 :             _pImp->_pFtFileType, _pImp->GetFilterListControl(), _pCbReadOnly, _pCbLinkBox, _pCbPreviewBox,
    2658             :             _pPbPlay, _pImp->_pCbPassword, _pImp->_pCbAutoExtension, _pImp->_pCbOptions, _pCbSelection
    2659           0 :         };
    2660           0 :         Control** ppMoveControls = aMoveControlsVert;
    2661           0 :         Control** ppMoveControlsEnd = ppMoveControls + sizeof( aMoveControlsVert ) / sizeof( aMoveControlsVert[0] );
    2662           0 :         for ( ; ppMoveControls != ppMoveControlsEnd; ++ppMoveControls )
    2663           0 :             lcl_MoveControl( *ppMoveControls, 0, nDeltaY );
    2664             :     }
    2665             : 
    2666             :     // controls to move vertically and horizontally
    2667             :     {
    2668             :         Control* aMoveControlsBoth[] =
    2669             :         {
    2670             :             _pImp->_pBtnFileOpen, _pImp->_pBtnCancel, _pImp->_pBtnHelp
    2671           0 :         };
    2672           0 :         Control** ppMoveControls = aMoveControlsBoth;
    2673           0 :         Control** ppMoveControlsEnd = ppMoveControls + sizeof( aMoveControlsBoth ) / sizeof( aMoveControlsBoth[0] );
    2674           0 :         for ( ; ppMoveControls != ppMoveControlsEnd; ++ppMoveControls )
    2675           0 :             lcl_MoveControl( *ppMoveControls, nDeltaX, nDeltaY );
    2676             :     }
    2677             : 
    2678             :     // controls to move horizontally
    2679             :     {
    2680             :         Control* aMoveControlsHor[] =
    2681             :         {
    2682             :             _pImp->_pBtnConnectToServer,
    2683             :             _pImp->_pBtnUp, _pImp->_pBtnNewFolder
    2684           0 :         };
    2685           0 :         Control** ppMoveControls = aMoveControlsHor;
    2686           0 :         Control** ppMoveControlsEnd = ppMoveControls + sizeof( aMoveControlsHor ) / sizeof( aMoveControlsHor[0] );
    2687           0 :         for ( ; ppMoveControls != ppMoveControlsEnd; ++ppMoveControls )
    2688           0 :             lcl_MoveControl( *ppMoveControls, nDeltaX, 0 );
    2689             :     }
    2690             : 
    2691             :     // ---------------
    2692             :     // resize controls
    2693             :     {
    2694             :         Control* aSizeControls[] =
    2695             :         {
    2696             :             _pImp->_pEdFileName, _pImp->_pLbFileVersion, _pImp->_pLbTemplates, _pImp->_pLbImageTemplates,
    2697           0 :             _pImp->GetFilterListControl(), _pImp->_pEdCurrentPath,
    2698           0 :         };
    2699           0 :         sal_Int32 nSizeControls = sizeof( aSizeControls ) / sizeof( aSizeControls[0] );
    2700           0 :         Control** ppSizeControls = aSizeControls;
    2701           0 :         for ( sal_Int32 j=0; j<nSizeControls; ++j, ++ppSizeControls )
    2702             :         {
    2703           0 :             if ( *ppSizeControls )
    2704             :             {
    2705           0 :                 aNewSize = (*ppSizeControls)->GetSizePixel();
    2706           0 :                 aNewSize.Width() += nDeltaX;
    2707           0 :                 (*ppSizeControls)->SetSizePixel( aNewSize );
    2708             :             }
    2709             :         }
    2710             :     }
    2711             : 
    2712             :     // align additional controls
    2713           0 :     if ( _pPrevWin &&
    2714           0 :          _pPrevWin->GetPosPixel().X() > _pFileView->GetPosPixel().X() )
    2715             :     {
    2716             :         // special alignment for controls of the type window
    2717             :         // also adjust the size
    2718           0 :         Point aNewPos = _pPrevWin->GetPosPixel();
    2719           0 :         aNewPos.X() += nDeltaX;
    2720           0 :         _pPrevWin->SetPosPixel( aNewPos );
    2721           0 :         _pPrevBmp->SetPosPixel( aNewPos );
    2722           0 :         aNewSize = _pPrevWin->GetOutputSizePixel();
    2723           0 :         aNewSize.Width() += nWinDeltaW;
    2724           0 :         aNewSize.Height() += nDeltaY;
    2725           0 :         if ( !aOldSize.Height() )
    2726           0 :             aNewSize.Height() -= ( _pImp->_a6Size.Height() / 2 );
    2727           0 :         _pPrevWin->SetOutputSizePixel( aNewSize );
    2728           0 :         _pPrevBmp->SetOutputSizePixel( aNewSize );
    2729           0 :         _pPrevBmp->Invalidate();
    2730             :     }
    2731             : 
    2732           0 :     if ( _pFileNotifier )
    2733           0 :         _pFileNotifier->notify( DIALOG_SIZE_CHANGED, 0 );
    2734             : }
    2735             : 
    2736             : //-----------------------------------------------------------------------------
    2737           0 : Control* SvtFileDialog::getControl( sal_Int16 _nControlId, sal_Bool _bLabelControl ) const
    2738             : {
    2739           0 :     Control* pReturn = NULL;
    2740             : 
    2741           0 :     switch ( _nControlId )
    2742             :     {
    2743             :         case CONTROL_FILEVIEW:
    2744           0 :             pReturn = _bLabelControl ? NULL : static_cast< Control* >( _pFileView );
    2745           0 :             break;
    2746             : 
    2747             :         case EDIT_FILEURL:
    2748             :             pReturn =   _bLabelControl
    2749             :                     ?   static_cast< Control* >( _pImp->_pFtFileName )
    2750           0 :                     :   static_cast< Control* >( _pImp->_pEdFileName );
    2751           0 :             break;
    2752             : 
    2753             :         case EDIT_FILEURL_LABEL:
    2754           0 :             pReturn = static_cast< Control* >( _pImp->_pFtFileName );
    2755           0 :             break;
    2756             : 
    2757             :         case CHECKBOX_AUTOEXTENSION:
    2758           0 :             pReturn = _pImp->_pCbAutoExtension;
    2759           0 :             break;
    2760             : 
    2761             :         case CHECKBOX_PASSWORD:
    2762           0 :             pReturn = _pImp->_pCbPassword;
    2763           0 :             break;
    2764             : 
    2765             :         case CHECKBOX_FILTEROPTIONS:
    2766           0 :             pReturn = _pImp->_pCbOptions;
    2767           0 :             break;
    2768             : 
    2769             :         case CHECKBOX_READONLY:
    2770           0 :             pReturn = _pCbReadOnly;
    2771           0 :             break;
    2772             : 
    2773             :         case CHECKBOX_LINK:
    2774           0 :             pReturn = _pCbLinkBox;
    2775           0 :             break;
    2776             : 
    2777             :         case CHECKBOX_PREVIEW:
    2778           0 :             pReturn = _pCbPreviewBox;
    2779           0 :             break;
    2780             : 
    2781             :         case CHECKBOX_SELECTION:
    2782           0 :             pReturn = _pCbSelection;
    2783           0 :             break;
    2784             : 
    2785             :         case LISTBOX_FILTER:
    2786           0 :             pReturn = _bLabelControl ? _pImp->_pFtFileType : _pImp->GetFilterListControl();
    2787           0 :             break;
    2788             : 
    2789             :         case LISTBOX_FILTER_LABEL:
    2790           0 :             pReturn = _pImp->_pFtFileType;
    2791           0 :             break;
    2792             : 
    2793             :         case FIXEDTEXT_CURRENTFOLDER:
    2794           0 :             pReturn = _pImp->_pEdCurrentPath;
    2795           0 :             break;
    2796             : 
    2797             :         case LISTBOX_VERSION:
    2798             :             pReturn =   _bLabelControl
    2799             :                     ?   static_cast< Control* >( _pImp->_pFtFileVersion )
    2800           0 :                     :   static_cast< Control* >( _pImp->_pLbFileVersion );
    2801           0 :             break;
    2802             : 
    2803             :         case LISTBOX_TEMPLATE:
    2804             :             pReturn =   _bLabelControl
    2805             :                     ?   static_cast< Control* >( _pImp->_pFtTemplates )
    2806           0 :                     :   static_cast< Control* >( _pImp->_pLbTemplates );
    2807           0 :             break;
    2808             : 
    2809             :         case LISTBOX_IMAGE_TEMPLATE:
    2810             :             pReturn =   _bLabelControl
    2811             :                     ?   static_cast< Control* >( _pImp->_pFtImageTemplates )
    2812           0 :                     :   static_cast< Control* >( _pImp->_pLbImageTemplates );
    2813           0 :             break;
    2814             : 
    2815             :         case LISTBOX_VERSION_LABEL:
    2816           0 :             pReturn = _pImp->_pFtFileVersion;
    2817           0 :             break;
    2818             : 
    2819             :         case LISTBOX_TEMPLATE_LABEL:
    2820           0 :             pReturn = _pImp->_pFtTemplates;
    2821           0 :             break;
    2822             : 
    2823             :         case LISTBOX_IMAGE_TEMPLATE_LABEL:
    2824           0 :             pReturn = _pImp->_pFtImageTemplates;
    2825           0 :             break;
    2826             : 
    2827             :         case PUSHBUTTON_OK:
    2828           0 :             pReturn = _pImp->_pBtnFileOpen;
    2829           0 :             break;
    2830             : 
    2831             :         case PUSHBUTTON_CANCEL:
    2832           0 :             pReturn = _pImp->_pBtnCancel;
    2833           0 :             break;
    2834             : 
    2835             :         case PUSHBUTTON_PLAY:
    2836           0 :             pReturn = _pPbPlay;
    2837           0 :             break;
    2838             : 
    2839             :         case PUSHBUTTON_HELP:
    2840           0 :             pReturn = _pImp->_pBtnHelp;
    2841           0 :             break;
    2842             : 
    2843             :         case TOOLBOXBUTOON_LEVEL_UP:
    2844           0 :             pReturn = _pImp->_pBtnUp;
    2845           0 :             break;
    2846             : 
    2847             :         case TOOLBOXBUTOON_NEW_FOLDER:
    2848           0 :             pReturn = _pImp->_pBtnNewFolder;
    2849           0 :             break;
    2850             : 
    2851             :         case LISTBOX_FILTER_SELECTOR:
    2852             :             // only exists on SalGtkFilePicker
    2853           0 :             break;
    2854             : 
    2855             :         default:
    2856             :             SAL_WARN( "fpicker.office", "SvtFileDialog::getControl: invalid id!" );
    2857             :     }
    2858           0 :     return pReturn;
    2859             : }
    2860             : 
    2861             : // -----------------------------------------------------------------------
    2862           0 : void SvtFileDialog::enableControl( sal_Int16 _nControlId, sal_Bool _bEnable )
    2863             : {
    2864           0 :     Control* pControl = getControl( _nControlId, sal_False );
    2865           0 :     if ( pControl )
    2866           0 :         EnableControl( pControl, _bEnable );
    2867           0 :     Control* pLabel = getControl( _nControlId, sal_True );
    2868           0 :     if ( pLabel )
    2869           0 :         EnableControl( pLabel, _bEnable );
    2870           0 : }
    2871             : 
    2872             : // -----------------------------------------------------------------------
    2873           0 : void SvtFileDialog::AddControls_Impl( )
    2874             : {
    2875             :     // create the "insert as link" checkbox, if needed
    2876           0 :     if ( _nExtraBits & SFX_EXTRA_INSERTASLINK )
    2877             :     {
    2878           0 :         _pCbLinkBox = new CheckBox( this );
    2879           0 :         _pCbLinkBox ->SetText( SvtResId( STR_SVT_FILEPICKER_INSERT_AS_LINK ) );
    2880           0 :         _pCbLinkBox ->SetHelpId( HID_FILEDLG_LINK_CB );
    2881           0 :         AddControl( _pCbLinkBox  );
    2882           0 :         ReleaseOwnership( _pCbLinkBox );
    2883           0 :         _pCbLinkBox->SetClickHdl( LINK( this, SvtFileDialog, ClickHdl_Impl ) );
    2884             :     }
    2885             : 
    2886             :     // create the "show preview" checkbox ( and the preview window, too ), if needed
    2887           0 :     if ( _nExtraBits & SFX_EXTRA_SHOWPREVIEW  )
    2888             :     {
    2889           0 :         _pImp->_aIniKey = IMPGRF_CONFIGNAME;
    2890             :         // because the "<All Formats> (*.bmp,*...)" entry is to wide,
    2891             :         // we need to disable the auto width feature of the filter box
    2892           0 :         _pImp->DisableFilterBoxAutoWidth();
    2893             : 
    2894             :         // "preview"
    2895           0 :         _pCbPreviewBox = new CheckBox( this );
    2896           0 :         _pCbPreviewBox->SetText( SvtResId( STR_SVT_FILEPICKER_SHOW_PREVIEW ) );
    2897           0 :         _pCbPreviewBox->SetHelpId( HID_FILEDLG_PREVIEW_CB );
    2898           0 :         AddControl( _pCbPreviewBox );
    2899           0 :         ReleaseOwnership( _pCbPreviewBox );
    2900           0 :         _pCbPreviewBox->SetClickHdl( LINK( this, SvtFileDialog, ClickHdl_Impl ) );
    2901             : 
    2902             :         // generate preview window just here
    2903           0 :         _pPrevWin = new Window( this, WinBits( WB_BORDER ) );
    2904           0 :         AddControl( _pPrevWin );
    2905           0 :         ReleaseOwnership( _pPrevWin );
    2906           0 :         _pPrevWin->Hide();
    2907             : 
    2908           0 :         _pPrevBmp = new FixedBitmap( this, WinBits( WB_BORDER ) );
    2909           0 :         _pPrevBmp->SetBackground( Wallpaper( Color( COL_WHITE ) ) );
    2910           0 :         _pPrevBmp->Show();
    2911           0 :         _pPrevBmp->SetAccessibleName(SvtResId(STR_PREVIEW));
    2912             :     }
    2913             : 
    2914           0 :     if ( _nExtraBits & SFX_EXTRA_AUTOEXTENSION )
    2915             :     {
    2916           0 :         _pImp->_pCbAutoExtension = new CheckBox( this, SvtResId( CB_AUTO_EXTENSION ) );
    2917           0 :         _pImp->_pCbAutoExtension->SetText( SvtResId( STR_SVT_FILEPICKER_AUTO_EXTENSION ) );
    2918           0 :         _pImp->_pCbAutoExtension->Check( sal_True );
    2919           0 :         AddControl( _pImp->_pCbAutoExtension );
    2920           0 :         ReleaseOwnership( _pImp->_pCbAutoExtension );
    2921           0 :         _pImp->_pCbAutoExtension->SetClickHdl( LINK( this, SvtFileDialog, AutoExtensionHdl_Impl ) );
    2922             :     }
    2923             : 
    2924           0 :     if ( _nExtraBits & SFX_EXTRA_FILTEROPTIONS )
    2925             :     {
    2926           0 :         _pImp->_pCbOptions = new CheckBox( this, SvtResId( CB_OPTIONS ) );
    2927           0 :         _pImp->_pCbOptions->SetText( SvtResId( STR_SVT_FILEPICKER_FILTER_OPTIONS ) );
    2928           0 :         AddControl( _pImp->_pCbOptions );
    2929           0 :         ReleaseOwnership( _pImp->_pCbOptions );
    2930           0 :         _pImp->_pCbOptions->SetClickHdl( LINK( this, SvtFileDialog, ClickHdl_Impl ) );
    2931             :     }
    2932             : 
    2933           0 :     if ( _nExtraBits & SFX_EXTRA_SELECTION )
    2934             :     {
    2935           0 :         _pCbSelection = new CheckBox( this, SvtResId( CB_OPTIONS ) );
    2936           0 :         _pCbSelection->SetText( SvtResId( STR_SVT_FILEPICKER_SELECTION ) );
    2937           0 :         AddControl( _pCbSelection );
    2938           0 :         ReleaseOwnership( _pCbSelection );
    2939           0 :         _pCbSelection->SetClickHdl( LINK( this, SvtFileDialog, ClickHdl_Impl ) );
    2940             :     }
    2941             : 
    2942           0 :     if ( _nExtraBits & SFX_EXTRA_PLAYBUTTON )
    2943             :     {
    2944           0 :         _pPbPlay = new PushButton( this );
    2945           0 :         _pPbPlay->SetText( SvtResId( STR_SVT_FILEPICKER_PLAY ) );
    2946           0 :         _pPbPlay->SetHelpId( HID_FILESAVE_DOPLAY );
    2947           0 :         AddControl( _pPbPlay );
    2948           0 :         ReleaseOwnership( _pPbPlay );
    2949           0 :         _pPbPlay->SetClickHdl( LINK( this, SvtFileDialog, PlayButtonHdl_Impl ) );
    2950             :     }
    2951             : 
    2952           0 :     if ( _nExtraBits & SFX_EXTRA_SHOWVERSIONS )
    2953             :     {
    2954           0 :         _pImp->_pFtFileVersion = new FixedText( this, SvtResId( FT_EXPLORERFILE_SHARED_LISTBOX ) );
    2955           0 :         _pImp->_pFtFileVersion->SetText( SvtResId( STR_SVT_FILEPICKER_VERSION ) );
    2956             : 
    2957           0 :         _pImp->_pLbFileVersion = new ListBox( this, SvtResId( LB_EXPLORERFILE_SHARED_LISTBOX ) );
    2958           0 :         _pImp->_pLbFileVersion->SetHelpId( HID_FILEOPEN_VERSION );
    2959             :     }
    2960           0 :     else if ( _nExtraBits & SFX_EXTRA_TEMPLATES )
    2961             :     {
    2962           0 :         _pImp->_pFtTemplates = new FixedText( this, SvtResId( FT_EXPLORERFILE_SHARED_LISTBOX ) );
    2963           0 :         _pImp->_pFtTemplates->SetText( SvtResId( STR_SVT_FILEPICKER_TEMPLATES ) );
    2964             : 
    2965           0 :         _pImp->_pLbTemplates = new ListBox( this, SvtResId( LB_EXPLORERFILE_SHARED_LISTBOX ) );
    2966           0 :         _pImp->_pLbTemplates->SetHelpId( HID_FILEOPEN_VERSION );
    2967             :             // This is strange. During the re-factoring during 96930, I discovered that this help id
    2968             :             // is set in the "Templates mode". This was hidden in the previous implementation.
    2969             :             // Shouldn't this be a more meaningfull help id.
    2970             :     }
    2971           0 :     else if ( _nExtraBits & SFX_EXTRA_IMAGE_TEMPLATE )
    2972             :     {
    2973           0 :         _pImp->_pFtImageTemplates = new FixedText( this, SvtResId( FT_EXPLORERFILE_SHARED_LISTBOX ) );
    2974           0 :         _pImp->_pFtImageTemplates->SetText( SvtResId( STR_SVT_FILEPICKER_IMAGE_TEMPLATE ) );
    2975             : 
    2976           0 :         _pImp->_pLbImageTemplates = new ListBox( this, SvtResId( LB_EXPLORERFILE_SHARED_LISTBOX ) );
    2977           0 :         _pImp->_pLbImageTemplates->SetHelpId( HID_FILEOPEN_IMAGE_TEMPLATE );
    2978             :     }
    2979             : 
    2980           0 :     _pImp->_pPlaces = new PlacesListBox( this, SVT_RESSTR(STR_PLACES_TITLE), SvtResId(LB_EXPLORERFILE_PLACES_LISTBOX) );
    2981           0 :     _pImp->_pPlaces->SetAddHdl( LINK ( this, SvtFileDialog, AddPlacePressed_Hdl ) );
    2982           0 :     _pImp->_pPlaces->SetDelHdl( LINK ( this, SvtFileDialog, RemovePlacePressed_Hdl ) );
    2983             : 
    2984           0 :     initDefaultPlaces();
    2985           0 : }
    2986             : 
    2987             : // -----------------------------------------------------------------------
    2988           0 : sal_Int32 SvtFileDialog::getTargetColorDepth()
    2989             : {
    2990           0 :     if ( _pPrevBmp )
    2991           0 :         return _pPrevBmp->GetBitCount();
    2992             :     else
    2993           0 :         return 0;
    2994             : }
    2995             : 
    2996             : // -----------------------------------------------------------------------
    2997           0 : sal_Int32 SvtFileDialog::getAvailableWidth()
    2998             : {
    2999           0 :     if ( _pPrevBmp )
    3000           0 :         return _pPrevBmp->GetOutputSizePixel().Width();
    3001             :     else
    3002           0 :         return 0;
    3003             : }
    3004             : 
    3005             : // -----------------------------------------------------------------------
    3006           0 : sal_Int32 SvtFileDialog::getAvailableHeight()
    3007             : {
    3008           0 :     if ( _pPrevBmp )
    3009           0 :         return _pPrevBmp->GetOutputSizePixel().Height();
    3010             :     else
    3011           0 :         return 0;
    3012             : }
    3013             : 
    3014             : // -----------------------------------------------------------------------
    3015           0 : void SvtFileDialog::setImage( sal_Int16 /*aImageFormat*/, const Any& rImage )
    3016             : {
    3017           0 :     if ( ! _pPrevBmp || ! _pPrevBmp->IsVisible() )
    3018           0 :         return;
    3019             : 
    3020           0 :     Sequence < sal_Int8 > aBmpSequence;
    3021             : 
    3022           0 :     if ( rImage >>= aBmpSequence )
    3023             :     {
    3024           0 :         Bitmap          aBmp;
    3025           0 :         SvMemoryStream  aData( aBmpSequence.getArray(),
    3026           0 :                                aBmpSequence.getLength(),
    3027           0 :                                STREAM_READ );
    3028           0 :         ReadDIB(aBmp, aData, true);
    3029             : 
    3030           0 :         _pPrevBmp->SetBitmap( aBmp );
    3031             :     }
    3032             :     else
    3033             :     {
    3034           0 :         Bitmap aEmpty;
    3035           0 :         _pPrevBmp->SetBitmap( aEmpty );
    3036           0 :     }
    3037             : }
    3038             : 
    3039             : // -----------------------------------------------------------------------
    3040           0 : sal_Bool SvtFileDialog::setShowState( sal_Bool /*bShowState*/ )
    3041             : {
    3042             :     // #97633 for the system filedialog it's
    3043             :     // useful to make the preview switchable
    3044             :     // because the preview occupies
    3045             :     // half of the size of the file listbox
    3046             :     // which is not the case here,
    3047             :     // so we (TRA/FS) decided not to make
    3048             :     // the preview window switchable because
    3049             :     // else we would have to change the layout
    3050             :     // of the file dialog dynamically
    3051             :     // support for set/getShowState is opionally
    3052             :     // see com::sun::star::ui::dialogs::XFilePreview
    3053             : 
    3054           0 :     return sal_False;
    3055             : }
    3056             : 
    3057             : // -----------------------------------------------------------------------
    3058           0 : String SvtFileDialog::getCurrentFileText( ) const
    3059             : {
    3060           0 :     String sReturn;
    3061           0 :     if ( _pImp && _pImp->_pEdFileName )
    3062           0 :         sReturn = _pImp->_pEdFileName->GetText();
    3063           0 :     return sReturn;
    3064             : }
    3065             : 
    3066             : // -----------------------------------------------------------------------
    3067           0 : void SvtFileDialog::setCurrentFileText( const String& _rText, bool _bSelectAll )
    3068             : {
    3069           0 :     if ( _pImp && _pImp->_pEdFileName )
    3070             :     {
    3071           0 :         _pImp->_pEdFileName->SetText( _rText );
    3072           0 :         if ( _bSelectAll )
    3073           0 :             _pImp->_pEdFileName->SetSelection( Selection( 0, _rText.Len() ) );
    3074             :     }
    3075           0 : }
    3076             : 
    3077             : // -----------------------------------------------------------------------
    3078           0 : sal_Bool SvtFileDialog::isAutoExtensionEnabled()
    3079             : {
    3080           0 :     return _pImp->_pCbAutoExtension && _pImp->_pCbAutoExtension->IsChecked();
    3081             : }
    3082             : 
    3083             : // -----------------------------------------------------------------------
    3084           0 : sal_Bool SvtFileDialog::getShowState()
    3085             : {
    3086           0 :     if ( _pPrevBmp )
    3087           0 :         return _pPrevBmp->IsVisible();
    3088             :     else
    3089           0 :         return sal_False;
    3090             : }
    3091             : 
    3092             : // -----------------------------------------------------------------------
    3093           0 : void SvtFileDialog::ReleaseOwnership( Window* pUserControl )
    3094             : 
    3095             : /*
    3096             :   [Description]
    3097             :   This method ensures that the specified element is no longer in possession
    3098             :   of the instance.
    3099             : */
    3100             : 
    3101             : {
    3102           0 :     ControlChain_Impl* pElement = _pUserControls;
    3103           0 :     while ( pElement )
    3104             :     {
    3105           0 :         if ( pElement->_pControl == pUserControl )
    3106             :         {
    3107           0 :             pElement->_bHasOwnership = sal_False;
    3108           0 :             break;
    3109             :         }
    3110           0 :         pElement = pElement->_pNext;
    3111             :     }
    3112           0 : }
    3113             : 
    3114             : //***************************************************************************
    3115             : 
    3116           0 : sal_Bool SvtFileDialog::AddControl( Window* pControl, sal_Bool bNewLine )
    3117             : {
    3118             :     // control already exists
    3119           0 :     ControlChain_Impl* pElement = _pUserControls;
    3120           0 :     while ( pElement )
    3121             :     {
    3122           0 :         if ( pElement->_pControl == pControl )
    3123           0 :             return sal_False;
    3124           0 :         pElement = pElement->_pNext;
    3125             :     }
    3126             : 
    3127             :     // Check if controls have already been added.
    3128           0 :     Size aNewControlSize( pControl->GetOutputSizePixel() );
    3129           0 :     Size aDlgSize( GetOutputSizePixel() );
    3130           0 :     WindowType nType = pControl->GetType();
    3131           0 :     if ( !aNewControlSize.Height() )
    3132             :     {
    3133             :         // Detect a size.
    3134           0 :         Size aSize( 0, 10 );
    3135           0 :         if ( nType == WINDOW_PUSHBUTTON )
    3136             :         {
    3137           0 :             Size aDefSiz = LogicToPixel( Size( 50, 14 ), MAP_APPFONT );
    3138           0 :             long nTextWidth = pControl->GetTextWidth( pControl->GetText() );
    3139           0 :             aSize.Width() = nTextWidth + WIDTH_ADDITION;
    3140             : 
    3141             :             // PushButton:  Minimum width 50 logical units,
    3142             :             //              height always 14 logical units.
    3143           0 :             if ( aDefSiz.Width() > aSize.Width() )
    3144           0 :                 aSize.Width() = aDefSiz.Width();
    3145           0 :             aSize.Height() = aDefSiz.Height();
    3146           0 :             aNewControlSize = aSize;
    3147             :         }
    3148             :         else
    3149           0 :             aNewControlSize = LogicToPixel( aSize, MAP_APPFONT );
    3150           0 :         if ( nType != WINDOW_PUSHBUTTON )
    3151           0 :             aNewControlSize.Width() = pControl->GetTextWidth( pControl->GetText() ) + WIDTH_ADDITION;
    3152           0 :         if ( nType == WINDOW_CHECKBOX )
    3153           0 :             aNewControlSize.Width() += WIDTH_ADDITION;
    3154           0 :         if ( nType == WINDOW_WINDOW )
    3155             :         {
    3156           0 :             aNewControlSize.Height() = GetOutputSizePixel().Height() - 18;
    3157           0 :             aNewControlSize.Width() = 200;
    3158           0 :             aDlgSize.Width() += 210;
    3159           0 :             SetOutputSizePixel( aDlgSize );
    3160             :         }
    3161           0 :         pControl->SetOutputSizePixel( aNewControlSize );
    3162             :     }
    3163           0 :     Point aNewControlPos;
    3164           0 :     Size* pNewDlgSize = NULL;
    3165           0 :     sal_Bool bNewRow = bNewLine;
    3166             : 
    3167           0 :     if ( nType == WINDOW_WINDOW )
    3168             :     {
    3169           0 :         aNewControlPos.X() = aDlgSize.Width() - 210;
    3170           0 :         aNewControlPos.Y() = 8;
    3171             :     }
    3172           0 :     else if ( _pUserControls )
    3173             :     {
    3174           0 :         Point aNewControlRange( _pUserControls->_pControl->GetPosPixel() );
    3175           0 :         long nPrevControlHeight = _pUserControls->_pControl->GetSizePixel().Height();
    3176           0 :         aNewControlRange +=
    3177           0 :             Point( _pUserControls->_pControl->GetOutputSizePixel().Width(), 0 );
    3178           0 :         aNewControlPos = aNewControlRange;
    3179           0 :         if ( nPrevControlHeight > aNewControlSize.Height() )
    3180             :         {
    3181           0 :             long nY = nPrevControlHeight;
    3182           0 :             nY -= aNewControlSize.Height();
    3183           0 :             nY /= 2;
    3184           0 :             aNewControlPos.Y() += nY;
    3185             :         }
    3186           0 :         aNewControlPos += LogicToPixel( Point( 3, 0 ), MAP_APPFONT );
    3187           0 :         aNewControlRange += LogicToPixel( Point( 9, 0 ), MAP_APPFONT );
    3188           0 :         aNewControlRange += Point( aNewControlSize.Width(), 0 );
    3189             : 
    3190             :         // Check if a new row has to be created.
    3191           0 :         if ( aNewControlRange.X() > aDlgSize.Width() )
    3192           0 :             bNewRow = sal_True;
    3193             :     }
    3194             :     else
    3195             :     {
    3196             :         // Create a new row if there was no usercontrol before.
    3197           0 :         bNewRow = sal_True;
    3198             :     }
    3199             : 
    3200             :     // Check if a new row has to be created.
    3201           0 :     Size aBorderSize = LogicToPixel( Size( 6, 6 ), MAP_APPFONT );
    3202           0 :     long nLeftBorder = aBorderSize.Width();
    3203           0 :     long nLowerBorder = aBorderSize.Height();
    3204           0 :     if ( bNewRow )
    3205             :     {
    3206             :         // Set control at the beginning of a new line.
    3207           0 :         long nSmallBorderHeight = nLowerBorder / 2;
    3208           0 :         aNewControlPos = Point( nLeftBorder, 0 );
    3209           0 :         aNewControlPos += Point( 0, aDlgSize.Height() );
    3210           0 :         aNewControlPos.Y() -= nSmallBorderHeight;
    3211             :         // Set new size.
    3212           0 :         pNewDlgSize = new Size( aDlgSize );
    3213           0 :         pNewDlgSize->Height() -= nSmallBorderHeight;
    3214           0 :         pNewDlgSize->Height() += aNewControlSize.Height();
    3215           0 :         pNewDlgSize->Height() += nLowerBorder;
    3216             :     }
    3217             :     else
    3218             :     {
    3219             :         // Check if the window has to be resized.
    3220           0 :         Size aNewControlRange( 0, aNewControlPos.Y() );
    3221           0 :         aNewControlRange.Height() += aNewControlSize.Height();
    3222           0 :         aNewControlRange.Height() += nLowerBorder;
    3223           0 :         if ( aNewControlRange.Height() > aDlgSize.Height() )
    3224           0 :             pNewDlgSize = new Size( aDlgSize.Width(), aNewControlRange.Height() );
    3225             :     }
    3226             : 
    3227             :     // Update view.
    3228           0 :     if ( pNewDlgSize )
    3229             :     {
    3230           0 :         SetOutputSizePixel( *pNewDlgSize );
    3231           0 :         delete pNewDlgSize;
    3232             :     }
    3233           0 :     pControl->SetPosPixel( aNewControlPos );
    3234           0 :     pControl->Show();
    3235           0 :     _pUserControls = new ControlChain_Impl( pControl, _pUserControls );
    3236             : 
    3237           0 :     return sal_True;
    3238             : }
    3239             : 
    3240           0 : sal_Bool SvtFileDialog::ContentHasParentFolder( const OUString& rURL )
    3241             : {
    3242           0 :     m_aContent.bindTo( rURL );
    3243             : 
    3244           0 :     if ( m_aContent.isInvalid() )
    3245           0 :         return sal_False;
    3246             : 
    3247           0 :     return m_aContent.hasParentFolder( ) && m_aContent.isValid();
    3248             : }
    3249             : 
    3250           0 : sal_Bool SvtFileDialog::ContentCanMakeFolder( const OUString& rURL )
    3251             : {
    3252           0 :     m_aContent.bindTo( rURL );
    3253             : 
    3254           0 :     if ( m_aContent.isInvalid() )
    3255           0 :         return sal_False;
    3256             : 
    3257           0 :     return m_aContent.canCreateFolder( ) && m_aContent.isValid();
    3258             : }
    3259             : 
    3260           0 : sal_Bool SvtFileDialog::ContentGetTitle( const OUString& rURL, String& rTitle )
    3261             : {
    3262           0 :     m_aContent.bindTo( rURL );
    3263             : 
    3264           0 :     if ( m_aContent.isInvalid() )
    3265           0 :         return sal_False;
    3266             : 
    3267           0 :     OUString sTitle;
    3268           0 :     m_aContent.getTitle( sTitle );
    3269           0 :     rTitle = sTitle;
    3270             : 
    3271           0 :     return m_aContent.isValid();
    3272             : }
    3273             : 
    3274           0 : void SvtFileDialog::appendDefaultExtension(String& _rFileName,
    3275             :                                            const String& _rFilterDefaultExtension,
    3276             :                                            const String& _rFilterExtensions)
    3277             : {
    3278           0 :     String aTemp(_rFileName);
    3279           0 :     aTemp.ToLowerAscii();
    3280           0 :     String aType(_rFilterExtensions);
    3281           0 :     aType.ToLowerAscii();
    3282             : 
    3283           0 :     if ( ! aType.EqualsAscii(FILEDIALOG_FILTER_ALL) )
    3284             :     {
    3285           0 :         sal_uInt16 nWildCard = comphelper::string::getTokenCount(aType, FILEDIALOG_DEF_EXTSEP);
    3286             :         sal_uInt16 nIndex;
    3287           0 :         sal_Int32 nPos = 0;
    3288             : 
    3289           0 :         for ( nIndex = 0; nIndex < nWildCard; nIndex++ )
    3290             :         {
    3291           0 :             String aExt(aType.GetToken( 0, FILEDIALOG_DEF_EXTSEP, nPos ));
    3292             :             // take care of a leading *
    3293           0 :             sal_uInt16 nExtOffset = (aExt.GetBuffer()[0] == '*' ? 1 : 0);
    3294           0 :             sal_Unicode* pExt = aExt.GetBufferAccess() + nExtOffset;
    3295           0 :             xub_StrLen nExtLen = aExt.Len() - nExtOffset;
    3296           0 :             xub_StrLen nOffset = aTemp.Len() - nExtLen;
    3297             :             // minimize search by starting at last possible index
    3298           0 :             if ( aTemp.Search(pExt, nOffset) == nOffset )
    3299           0 :                 break;
    3300           0 :         }
    3301             : 
    3302           0 :         if ( nIndex >= nWildCard )
    3303             :         {
    3304           0 :             _rFileName += '.';
    3305           0 :             _rFileName += _rFilterDefaultExtension;
    3306             :         }
    3307           0 :     }
    3308           0 : }
    3309             : 
    3310           0 : void SvtFileDialog::initDefaultPlaces( )
    3311             : {
    3312           0 :     PlacePtr pRootPlace( new Place( SVT_RESSTR(STR_DEFAULT_DIRECTORY), GetStandardDir() ) );
    3313           0 :     _pImp->_pPlaces->AppendPlace( pRootPlace );
    3314             : 
    3315             :     // Load from user settings
    3316           0 :     Sequence< OUString > placesUrlsList(officecfg::Office::Common::Misc::FilePickerPlacesUrls::get(m_context));
    3317           0 :     Sequence< OUString > placesNamesList(officecfg::Office::Common::Misc::FilePickerPlacesNames::get(m_context));
    3318             : 
    3319           0 :     for(sal_Int32 nPlace = 0; nPlace < placesUrlsList.getLength() && nPlace < placesNamesList.getLength(); ++nPlace)
    3320             :     {
    3321           0 :         PlacePtr pPlace(new Place(placesNamesList[nPlace], placesUrlsList[nPlace], true));
    3322           0 :         _pImp->_pPlaces->AppendPlace(pPlace);
    3323           0 :     }
    3324             : 
    3325             :     // Reset the placesList "updated" state
    3326           0 :     _pImp->_pPlaces->IsUpdated();
    3327           0 : }
    3328             : 
    3329           0 : IMPL_LINK_NOARG( SvtFileDialog, Split_Hdl )
    3330             : {
    3331           0 :     sal_Int32 nSplitPos = _pSplitter->GetSplitPosPixel();
    3332             : 
    3333             :     // Resize the places list
    3334           0 :     sal_Int32 nPlaceX = _pImp->_pPlaces->GetPosPixel( ).X();
    3335           0 :     Size placeSize = _pImp->_pPlaces->GetSizePixel( );
    3336           0 :     placeSize.Width() = nSplitPos - nPlaceX;
    3337           0 :     _pImp->_pPlaces->SetSizePixel( placeSize );
    3338             : 
    3339             :     // Change Pos and size of the fileview
    3340           0 :     Point fileViewPos = _pFileView->GetPosPixel();
    3341           0 :     sal_Int32 nOldX = fileViewPos.X();
    3342           0 :     sal_Int32 nNewX = nSplitPos + _pSplitter->GetSizePixel().Width();
    3343           0 :     fileViewPos.X() = nNewX;
    3344           0 :     Size fileViewSize = _pFileView->GetSizePixel();
    3345           0 :     fileViewSize.Width() -= ( nNewX - nOldX );
    3346           0 :     _pFileView->SetPosSizePixel( fileViewPos, fileViewSize );
    3347             : 
    3348           0 :     _pSplitter->SetPosPixel( Point( nSplitPos, _pSplitter->GetPosPixel().Y() ) );
    3349           0 :     return 0;
    3350             : }
    3351             : 
    3352             : // QueryFolderNameDialog -------------------------------------------------------
    3353             : 
    3354             : namespace svtools {
    3355             : 
    3356           0 : QueryFolderNameDialog::QueryFolderNameDialog
    3357             : (
    3358             :     Window* _pParent,
    3359             :     const String& rTitle,
    3360             :     const String& rDefaultText,
    3361             :     String* pGroupName
    3362             : ) :
    3363             :     ModalDialog( _pParent, SvtResId( DLG_FPICKER_QUERYFOLDERNAME ) ),
    3364             : 
    3365             :     aNameText   ( this, SvtResId( FT_SVT_QUERYFOLDERNAME_DLG_NAME ) ),
    3366             :     aNameEdit   ( this, SvtResId( ED_SVT_QUERYFOLDERNAME_DLG_NAME ) ),
    3367             :     aNameLine   ( this, SvtResId( FL_SVT_QUERYFOLDERNAME_DLG_NAME ) ),
    3368             :     aOKBtn      ( this, SvtResId( BT_SVT_QUERYFOLDERNAME_DLG_OK ) ),
    3369           0 :     aCancelBtn  ( this, SvtResId( BT_SVT_QUERYFOLDERNAME_DLG_CANCEL ) )
    3370             : {
    3371           0 :     FreeResource();
    3372           0 :     SetText( rTitle );
    3373           0 :     aNameEdit.SetText( rDefaultText );
    3374           0 :     aNameEdit.SetSelection( Selection( 0, rDefaultText.Len() ) );
    3375           0 :     aOKBtn.SetClickHdl( LINK( this, QueryFolderNameDialog, OKHdl ) );
    3376           0 :     aNameEdit.SetModifyHdl( LINK( this, QueryFolderNameDialog, NameHdl ) );
    3377             : 
    3378           0 :     if ( pGroupName )
    3379           0 :         aNameLine.SetText( *pGroupName );
    3380           0 : };
    3381             : 
    3382             : // -----------------------------------------------------------------------
    3383           0 : IMPL_LINK_NOARG(QueryFolderNameDialog, OKHdl)
    3384             : {
    3385             :     // trim the strings
    3386           0 :     aNameEdit.SetText(comphelper::string::strip(aNameEdit.GetText(), ' '));
    3387           0 :     EndDialog( RET_OK );
    3388           0 :     return 1;
    3389             : }
    3390             : 
    3391             : // -----------------------------------------------------------------------
    3392           0 : IMPL_LINK_NOARG(QueryFolderNameDialog, NameHdl)
    3393             : {
    3394             :     // trim the strings
    3395           0 :     String aName = comphelper::string::strip(aNameEdit.GetText(), ' ');
    3396           0 :     if ( aName.Len() )
    3397             :     {
    3398           0 :         if ( !aOKBtn.IsEnabled() )
    3399           0 :             aOKBtn.Enable( sal_True );
    3400             :     }
    3401             :     else
    3402             :     {
    3403           0 :         if ( aOKBtn.IsEnabled() )
    3404           0 :             aOKBtn.Enable( sal_False );
    3405             :     }
    3406             : 
    3407           0 :     return 0;
    3408             : }
    3409             : 
    3410           0 : }
    3411             : 
    3412             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10