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