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