bump product version to 4.1.6.2
[LibreOffice.git] / dbaccess / source / ui / dlg / ConnectionHelper.cxx
blobcd284defa94ad057df43a20cc23ab9e2635f0052
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "dsnItem.hxx"
22 #include "ConnectionHelper.hxx"
23 #include "AutoControls.hrc"
24 #include "dbu_dlg.hrc"
25 #include "dbu_misc.hrc"
26 #include <svl/itemset.hxx>
27 #include <unotools/moduleoptions.hxx>
28 #include <sfx2/fcontnr.hxx>
29 #include <unotools/pathoptions.hxx>
30 #include <svl/stritem.hxx>
31 #include <svl/eitem.hxx>
32 #include <svl/intitem.hxx>
33 #include "dsitems.hxx"
34 #include "dbaccess_helpid.hrc"
35 #include "localresaccess.hxx"
36 #include <osl/process.h>
37 #include <osl/diagnose.h>
38 #include <vcl/msgbox.hxx>
39 #include <sfx2/filedlghelper.hxx>
40 #include "dbadmin.hxx"
41 #include <comphelper/types.hxx>
42 #include <vcl/stdtext.hxx>
43 #include "sqlmessage.hxx"
44 #include "odbcconfig.hxx"
45 #include "dsselect.hxx"
46 #include <svl/filenotation.hxx>
47 #include "dbustrings.hrc"
48 #include <com/sun/star/ui/dialogs/FolderPicker.hpp>
49 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
50 #include <com/sun/star/sdbc/XRow.hpp>
51 #include <com/sun/star/awt/XWindow.hpp>
52 #include <com/sun/star/mozilla/MozillaBootstrap.hpp>
53 #include <com/sun/star/task/InteractionHandler.hpp>
54 #include <com/sun/star/ucb/XProgressHandler.hpp>
55 #include "UITools.hxx"
56 #include <unotools/localfilehelper.hxx>
57 #include <unotools/ucbhelper.hxx>
58 #include <ucbhelper/commandenvironment.hxx>
59 #include "finteraction.hxx"
60 #include <connectivity/CommonTools.hxx>
61 #include <tools/urlobj.hxx>
62 #include <tools/diagnose_ex.h>
63 #include <sfx2/docfilt.hxx>
65 #if defined(WNT)
66 #define _ADO_DATALINK_BROWSE_
67 #endif
69 #ifdef _ADO_DATALINK_BROWSE_
70 #include <vcl/sysdata.hxx>
71 #include "adodatalinks.hxx"
72 #endif //_ADO_DATALINK_BROWSE_
74 #include <com/sun/star/mozilla/XMozillaBootstrap.hpp>
75 #include <comphelper/processfactory.hxx>
76 #include <comphelper/string.hxx>
80 //.........................................................................
81 namespace dbaui
83 //.........................................................................
84 using namespace ::com::sun::star;
85 using namespace ::com::sun::star::uno;
86 using namespace ::com::sun::star::ucb;
87 using namespace ::com::sun::star::ui::dialogs;
88 using namespace ::com::sun::star::sdbc;
89 using namespace ::com::sun::star::beans;
90 using namespace ::com::sun::star::lang;
91 using namespace ::com::sun::star::container;
92 using namespace ::com::sun::star::mozilla;
93 using namespace ::dbtools;
94 using namespace ::svt;
97 DBG_NAME(OConnectionHelper)
99 OConnectionHelper::OConnectionHelper( Window* pParent, const ResId& _rId, const SfxItemSet& _rCoreAttrs)
100 :OGenericAdministrationPage(pParent, _rId, _rCoreAttrs)
101 ,m_aFT_Connection ( this, ResId( FT_AUTOBROWSEURL, *_rId.GetResMgr() ) )
102 ,m_aConnectionURL ( this, ResId( ET_AUTOBROWSEURL, *_rId.GetResMgr() ) )
103 ,m_aPB_Connection ( this, ResId( PB_AUTOBROWSEURL, *_rId.GetResMgr() ) )
105 DBG_CTOR(OConnectionHelper,NULL);
107 // extract the datasource type collection from the item set
108 DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, _rCoreAttrs.GetItem(DSID_TYPECOLLECTION));
109 if (pCollectionItem)
110 m_pCollection = pCollectionItem->getCollection();
111 m_aPB_Connection.SetClickHdl(LINK(this, OConnectionHelper, OnBrowseConnections));
112 OSL_ENSURE(m_pCollection, "OConnectionHelper::OConnectionHelper : really need a DSN type collection !");
113 m_aConnectionURL.SetTypeCollection(m_pCollection);
117 OConnectionHelper::~OConnectionHelper()
120 DBG_DTOR(OConnectionHelper,NULL);
124 // -----------------------------------------------------------------------
125 void OConnectionHelper::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
127 // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
128 sal_Bool bValid, bReadonly;
129 getFlags(_rSet, bValid, bReadonly);
131 m_aFT_Connection.Show();
132 m_aConnectionURL.Show();
133 m_aConnectionURL.ShowPrefix( ::dbaccess::DST_JDBC == m_pCollection->determineType(m_eType) );
135 sal_Bool bEnableBrowseButton = m_pCollection->supportsBrowsing( m_eType );
136 m_aPB_Connection.Show( bEnableBrowseButton );
138 SFX_ITEMSET_GET(_rSet, pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True);
140 // forward the values to the controls
141 if ( bValid )
143 String sUrl = pUrlItem->GetValue();
144 setURL( sUrl );
146 checkTestConnection();
147 m_aConnectionURL.ClearModifyFlag();
150 OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue);
153 // -----------------------------------------------------------------------
154 void OConnectionHelper::implUpdateURLDependentStates() const
156 OSL_PRECOND( m_pAdminDialog, "OConnectionHelper::implUpdateURLDependentStates: no admin dialog!" );
157 if ( !m_pAdminDialog )
158 return;
160 if ( m_pCollection->isFileSystemBased(m_eType) )
161 m_pAdminDialog->enableConfirmSettings( getURLNoPrefix().Len() > 0 );
164 // -----------------------------------------------------------------------
165 IMPL_LINK(OConnectionHelper, OnBrowseConnections, PushButton*, /*_pButton*/)
167 OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF");
168 const ::dbaccess::DATASOURCE_TYPE eType = m_pCollection->determineType(m_eType);
169 switch ( eType )
171 case ::dbaccess::DST_DBASE:
172 case ::dbaccess::DST_FLAT:
176 Reference< XFolderPicker2 > xFolderPicker = FolderPicker::create(m_xORB);
178 sal_Bool bDoBrowse = sal_False;
179 String sOldPath = getURLNoPrefix();
182 if (sOldPath.Len())
183 xFolderPicker->setDisplayDirectory(sOldPath);
184 if (0 == xFolderPicker->execute())
185 // cancelled by the user
186 return 0L;
188 sOldPath = xFolderPicker->getDirectory();
189 switch (checkPathExistence(sOldPath))
191 case RET_RETRY:
192 bDoBrowse = sal_True;
193 break;
194 case RET_CANCEL:
195 return 0L;
196 default:
197 break;
200 while (bDoBrowse);
202 String sSelectedDirectory = xFolderPicker->getDirectory();
203 INetURLObject aSelectedDirectory( sSelectedDirectory, INetURLObject::WAS_ENCODED, RTL_TEXTENCODING_UTF8 );
205 // for UI purpose, we don't want to have the path encoded
206 sSelectedDirectory = aSelectedDirectory.GetMainURL( INetURLObject::DECODE_WITH_CHARSET, RTL_TEXTENCODING_UTF8 );
208 setURLNoPrefix( sSelectedDirectory );
209 SetRoadmapStateValue(sal_True);
210 callModifiedHdl();
212 catch( const Exception& )
214 DBG_UNHANDLED_EXCEPTION();
217 break;
218 case ::dbaccess::DST_CALC:
220 SvtModuleOptions aModule;
221 ::sfx2::FileDialogHelper aFileDlg(
222 ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION,
224 aModule.GetFactoryEmptyDocumentURL(SvtModuleOptions::E_CALC)
225 ,SFX_FILTER_IMPORT);
226 askForFileName(aFileDlg);
228 break;
229 case ::dbaccess::DST_MSACCESS:
231 const OUString sExt("*.mdb");
232 String sFilterName(ModuleRes (STR_MSACCESS_FILTERNAME));
233 ::sfx2::FileDialogHelper aFileDlg(
234 ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION,
236 aFileDlg.AddFilter(sFilterName,sExt);
237 aFileDlg.SetCurrentFilter(sFilterName);
238 askForFileName(aFileDlg);
240 break;
241 case ::dbaccess::DST_MSACCESS_2007:
243 const OUString sAccdb("*.accdb");
244 String sFilterName2(ModuleRes (STR_MSACCESS_2007_FILTERNAME));
245 ::sfx2::FileDialogHelper aFileDlg(
246 ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION,
248 aFileDlg.AddFilter(sFilterName2,sAccdb);
249 aFileDlg.SetCurrentFilter(sFilterName2);
250 askForFileName(aFileDlg);
252 break;
253 case ::dbaccess::DST_MYSQL_ODBC:
254 case ::dbaccess::DST_ODBC:
256 // collect all ODBC data source names
257 OUString sCurrDatasource = getURLNoPrefix();
258 OUString sDataSource;
259 if ( getSelectedDataSource(sDataSource,sCurrDatasource) && !sDataSource.isEmpty() )
261 setURLNoPrefix(sDataSource);
262 SetRoadmapStateValue(sal_True);
263 callModifiedHdl();
265 else
266 return 1L;
268 break;
269 #ifdef _ADO_DATALINK_BROWSE_
270 case ::dbaccess::DST_ADO:
272 OUString sOldDataSource=getURLNoPrefix();
273 OUString sNewDataSource;
274 HWND hWnd = GetParent()->GetSystemData()->hWnd;
275 sNewDataSource = getAdoDatalink((long)hWnd,sOldDataSource);
276 if ( !sNewDataSource.isEmpty() )
278 setURLNoPrefix(sNewDataSource);
279 SetRoadmapStateValue(sal_True);
280 callModifiedHdl();
282 else
283 return 1L;
285 break;
286 #endif
287 case ::dbaccess::DST_MOZILLA:
288 case ::dbaccess::DST_THUNDERBIRD:
290 MozillaProductType profileType = MozillaProductType_Mozilla;
291 if (eType == ::dbaccess::DST_THUNDERBIRD)
292 profileType = MozillaProductType_Thunderbird;
294 Reference<XComponentContext> xContext = ::comphelper::getProcessComponentContext();
295 Reference<XMozillaBootstrap> xMozillaBootstrap = MozillaBootstrap::create(xContext);
297 // collect all Mozilla Profiles
298 ::com::sun::star::uno::Sequence< OUString > list;
300 xMozillaBootstrap->getProfileList( profileType, list );
301 const OUString * pArray = list.getConstArray();
303 sal_Int32 count = list.getLength();
305 StringBag aProfiles;
306 for (sal_Int32 index=0; index < count; index++)
307 aProfiles.insert(pArray[index]);
310 // execute the select dialog
311 ODatasourceSelectDialog aSelector(GetParent(), aProfiles);
312 OUString sOldProfile=getURLNoPrefix();
314 if (!sOldProfile.isEmpty())
315 aSelector.Select(sOldProfile);
316 else
317 aSelector.Select(xMozillaBootstrap->getDefaultProfile(profileType));
319 if ( RET_OK == aSelector.Execute() )
320 setURLNoPrefix(aSelector.GetSelected());
321 break;
323 default:
324 break;
327 checkTestConnection();
329 return 0L;
332 //-------------------------------------------------------------------------
334 bool OConnectionHelper::checkTestConnection()
336 return true;
339 //-------------------------------------------------------------------------
340 void OConnectionHelper::impl_setURL( const String& _rURL, sal_Bool _bPrefix )
342 String sURL( comphelper::string::stripEnd(_rURL, '*') );
343 OSL_ENSURE( m_pCollection, "OConnectionHelper::impl_setURL: have no interpreter for the URLs!" );
345 if ( m_pCollection && sURL.Len() )
347 if ( m_pCollection->isFileSystemBased( m_eType ) )
349 // get the two parts: prefix and file URL
350 String sTypePrefix, sFileURLEncoded;
351 if ( _bPrefix )
353 sTypePrefix = m_pCollection->getPrefix( m_eType );
354 sFileURLEncoded = m_pCollection->cutPrefix( sURL );
356 else
358 sFileURLEncoded = sURL;
361 // substitute any variables
362 sFileURLEncoded = SvtPathOptions().SubstituteVariable( sFileURLEncoded );
364 // decode the URL
365 sURL = sTypePrefix;
366 if ( sFileURLEncoded.Len() )
368 OFileNotation aFileNotation(sFileURLEncoded);
369 // set this decoded URL as text
370 sURL += String(aFileNotation.get(OFileNotation::N_SYSTEM));
375 if ( _bPrefix )
376 m_aConnectionURL.SetText( sURL );
377 else
378 m_aConnectionURL.SetTextNoPrefix( sURL );
380 implUpdateURLDependentStates();
383 //-------------------------------------------------------------------------
384 String OConnectionHelper::impl_getURL( sal_Bool _bPrefix ) const
386 // get the pure text
387 OUString sURL = _bPrefix ? m_aConnectionURL.GetText() : OUString(m_aConnectionURL.GetTextNoPrefix());
389 OSL_ENSURE( m_pCollection, "OConnectionHelper::impl_getURL: have no interpreter for the URLs!" );
391 if ( m_pCollection && !sURL.isEmpty() )
393 if ( m_pCollection->isFileSystemBased( m_eType ) )
395 // get the two parts: prefix and file URL
396 OUString sTypePrefix, sFileURLDecoded;
397 if ( _bPrefix )
399 sTypePrefix = m_pCollection->getPrefix( m_eType );
400 sFileURLDecoded = m_pCollection->cutPrefix( sURL );
402 else
404 sFileURLDecoded = sURL;
407 sURL = sTypePrefix;
408 if ( !sFileURLDecoded.isEmpty() )
410 OFileNotation aFileNotation( sFileURLDecoded, OFileNotation::N_SYSTEM );
411 sURL += String( aFileNotation.get( OFileNotation::N_URL ) );
414 // encode the URL
415 INetURLObject aFileURL( sFileURLDecoded, INetURLObject::ENCODE_ALL, RTL_TEXTENCODING_UTF8 );
416 sFileURLDecoded = aFileURL.GetMainURL( INetURLObject::NO_DECODE );
419 return sURL;
422 //-------------------------------------------------------------------------
423 void OConnectionHelper::setURL( const String& _rURL )
425 impl_setURL( _rURL, sal_True );
428 //-------------------------------------------------------------------------
429 String OConnectionHelper::getURLNoPrefix( ) const
431 return impl_getURL( sal_False );
434 //-------------------------------------------------------------------------
435 void OConnectionHelper::setURLNoPrefix( const String& _rURL )
437 impl_setURL( _rURL, sal_False );
440 //-------------------------------------------------------------------------
441 sal_Int32 OConnectionHelper::checkPathExistence(const String& _rURL)
443 IS_PATH_EXIST e_exists = pathExists(_rURL, sal_False);
444 if (( e_exists == PATH_NOT_EXIST) || ( e_exists == PATH_NOT_KNOWN))
446 String sQuery(ModuleRes(STR_ASK_FOR_DIRECTORY_CREATION));
447 OFileNotation aTransformer(_rURL);
448 sQuery.SearchAndReplaceAscii("$path$", aTransformer.get(OFileNotation::N_SYSTEM));
450 m_bUserGrabFocus = sal_False;
451 QueryBox aQuery(GetParent(), WB_YES_NO | WB_DEF_YES, sQuery);
452 sal_Int32 nQueryResult = aQuery.Execute();
453 m_bUserGrabFocus = sal_True;
455 switch (nQueryResult)
457 case RET_YES:
459 sal_Bool bTryCreate = sal_False;
462 if ( !createDirectoryDeep(_rURL) )
463 { // could not create the directory
464 sQuery = String(ModuleRes(STR_COULD_NOT_CREATE_DIRECTORY));
465 sQuery.SearchAndReplaceAscii("$name$", aTransformer.get(OFileNotation::N_SYSTEM));
467 m_bUserGrabFocus = sal_False;
468 QueryBox aWhatToDo(GetParent(), WB_RETRY_CANCEL | WB_DEF_RETRY, sQuery);
469 nQueryResult = aWhatToDo.Execute();
470 m_bUserGrabFocus = sal_True;
472 if (RET_RETRY == nQueryResult)
473 bTryCreate = sal_True;
474 else
476 SetRoadmapStateValue(sal_False);
477 callModifiedHdl();
478 return RET_RETRY;
482 while (bTryCreate);
484 break;
486 case RET_NO:
487 callModifiedHdl();
488 return RET_OK;
490 default:
491 // cancelled
492 SetRoadmapStateValue(sal_False);
493 callModifiedHdl();
494 return RET_CANCEL;
497 /* else
499 // TODO: error msg
500 return RET_CANCEL;
501 } */
502 SetRoadmapStateValue(sal_True);
503 callModifiedHdl();
504 return RET_OK;
507 // -----------------------------------------------------------------------------
508 IS_PATH_EXIST OConnectionHelper::pathExists(const OUString& _rURL, sal_Bool bIsFile) const
510 ::ucbhelper::Content aCheckExistence;
511 sal_Bool bExists = sal_False;
512 IS_PATH_EXIST eExists = PATH_NOT_EXIST;
513 Reference< ::com::sun::star::task::XInteractionHandler > xInteractionHandler(
514 task::InteractionHandler::createWithParent(m_xORB, 0), UNO_QUERY );
515 OFilePickerInteractionHandler* pHandler = new OFilePickerInteractionHandler(xInteractionHandler);
516 xInteractionHandler = pHandler;
518 Reference< XCommandEnvironment > xCmdEnv = new ::ucbhelper::CommandEnvironment( xInteractionHandler, Reference< XProgressHandler >() );
521 aCheckExistence = ::ucbhelper::Content(_rURL, xCmdEnv, comphelper::getProcessComponentContext());
522 bExists = bIsFile? aCheckExistence.isDocument(): aCheckExistence.isFolder();
523 eExists = bExists? PATH_EXIST: PATH_NOT_EXIST;
525 catch(const Exception&)
527 eExists = ( pHandler && pHandler->isDoesNotExist() ) ? PATH_NOT_EXIST: (bIsFile ? PATH_NOT_EXIST : PATH_NOT_KNOWN);
529 return eExists;
531 //-------------------------------------------------------------------------
532 long OConnectionHelper::PreNotify( NotifyEvent& _rNEvt )
534 if ( m_pCollection->isFileSystemBased(m_eType) )
536 switch (_rNEvt.GetType())
538 case EVENT_GETFOCUS:
539 if (m_aConnectionURL.IsWindowOrChild(_rNEvt.GetWindow()) && m_bUserGrabFocus)
540 { // a descendant of the URL edit field got the focus
541 m_aConnectionURL.SaveValueNoPrefix();
543 break;
545 case EVENT_LOSEFOCUS:
546 if (m_aConnectionURL.IsWindowOrChild(_rNEvt.GetWindow()) && m_bUserGrabFocus)
547 { // a descendant of the URL edit field lost the focus
548 if (!commitURL())
549 return 1L; // handled
551 break;
555 return OGenericAdministrationPage::PreNotify( _rNEvt );
558 //-------------------------------------------------------------------------
560 sal_Bool OConnectionHelper::createDirectoryDeep(const String& _rPathURL)
562 // get an URL object analyzing the URL for us ...
563 INetURLObject aParser;
564 aParser.SetURL(_rPathURL);
566 INetProtocol eProtocol = aParser.GetProtocol();
568 ::std::vector< OUString > aToBeCreated; // the to-be-created levels
570 // search a level which exists
571 IS_PATH_EXIST eParentExists = PATH_NOT_EXIST;
572 while ( eParentExists == PATH_NOT_EXIST && aParser.getSegmentCount())
574 aToBeCreated.push_back(aParser.getName()); // remember the local name for creation
575 aParser.removeSegment(); // cut the local name
576 eParentExists = pathExists(aParser.GetMainURL(INetURLObject::NO_DECODE), sal_False);
579 if (!aParser.getSegmentCount())
580 return sal_False;
582 // create all the missing levels
585 // the parent content
586 Reference< XCommandEnvironment > xEmptyEnv;
587 ::ucbhelper::Content aParent(aParser.GetMainURL(INetURLObject::NO_DECODE), xEmptyEnv, comphelper::getProcessComponentContext());
589 OUString sContentType;
590 if ( INET_PROT_FILE == eProtocol )
592 sContentType = OUString("application/vnd.sun.staroffice.fsys-folder");
593 // the file UCP currently does not support the ContentType property
595 else
597 Any aContentType = aParent.getPropertyValue( OUString("ContentType") );
598 aContentType >>= sContentType;
601 // the properties which need to be set on the new content
602 Sequence< OUString > aNewDirectoryProperties(1);
603 aNewDirectoryProperties[0] = OUString("Title");
605 // the values to be set
606 Sequence< Any > aNewDirectoryAttributes(1);
608 // loop
609 for ( ::std::vector< OUString >::reverse_iterator aLocalName = aToBeCreated.rbegin();
610 aLocalName != aToBeCreated.rend();
611 ++aLocalName
614 aNewDirectoryAttributes[0] <<= *aLocalName;
615 if (!aParent.insertNewContent(sContentType, aNewDirectoryProperties, aNewDirectoryAttributes, aParent))
616 return sal_False;
619 catch ( const Exception& )
621 DBG_UNHANDLED_EXCEPTION();
622 return sal_False;
625 return sal_True;
629 // -----------------------------------------------------------------------
630 void OConnectionHelper::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
632 _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFT_Connection));
633 _rControlList.push_back(new ODisableWrapper<PushButton>(&m_aPB_Connection));
637 // -----------------------------------------------------------------------
638 void OConnectionHelper::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
640 _rControlList.push_back( new OSaveValueWrapper<Edit>( &m_aConnectionURL ) );
643 //-------------------------------------------------------------------------
644 sal_Bool OConnectionHelper::commitURL()
646 String sURL;
647 String sOldPath;
648 sOldPath = m_aConnectionURL.GetSavedValueNoPrefix();
649 sURL = m_aConnectionURL.GetTextNoPrefix();
651 if ( m_pCollection->isFileSystemBased(m_eType) )
653 if ( ( sURL != sOldPath ) && ( 0 != sURL.Len() ) )
654 { // the text changed since entering the control
656 // the path may be in system notation ....
657 OFileNotation aTransformer(sURL);
658 sURL = aTransformer.get(OFileNotation::N_URL);
660 const ::dbaccess::DATASOURCE_TYPE eType = m_pCollection->determineType(m_eType);
662 if ( ( ::dbaccess::DST_CALC == eType) || ( ::dbaccess::DST_MSACCESS == eType) || ( ::dbaccess::DST_MSACCESS_2007 == eType) )
664 if( pathExists(sURL, sal_True) == PATH_NOT_EXIST )
666 String sFile = String( ModuleRes( STR_FILE_DOES_NOT_EXIST ) );
667 sFile.SearchAndReplaceAscii("$file$", aTransformer.get(OFileNotation::N_SYSTEM));
668 OSQLWarningBox( this, sFile ).Execute();
669 setURLNoPrefix(sOldPath);
670 SetRoadmapStateValue(sal_False);
671 callModifiedHdl();
672 return sal_False;
675 else
677 switch (checkPathExistence(sURL))
679 case RET_RETRY:
680 m_bUserGrabFocus = sal_False;
681 m_aConnectionURL.GrabFocus();
682 m_bUserGrabFocus = sal_True;
683 return sal_False;
685 case RET_CANCEL:
686 setURLNoPrefix(sOldPath);
687 return sal_False;
693 setURLNoPrefix(sURL);
694 m_aConnectionURL.SaveValueNoPrefix();
695 return sal_True;
697 //-------------------------------------------------------------------------
698 void OConnectionHelper::askForFileName(::sfx2::FileDialogHelper& _aFileOpen)
700 String sOldPath = getURLNoPrefix();
701 if ( sOldPath.Len() )
702 _aFileOpen.SetDisplayDirectory(sOldPath);
703 else
704 _aFileOpen.SetDisplayDirectory( SvtPathOptions().GetWorkPath() );
705 if (0 == _aFileOpen.Execute())
707 setURLNoPrefix(_aFileOpen.GetPath());
708 SetRoadmapStateValue(checkTestConnection());
709 callModifiedHdl();
713 //.........................................................................
714 } // namespace dbaui
715 //.........................................................................
717 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */