1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
20 #include <core_resource.hxx>
21 #include "dsnItem.hxx"
22 #include "ConnectionHelper.hxx"
23 #include <IItemSetHelper.hxx>
24 #include <strings.hrc>
25 #include <svl/itemset.hxx>
26 #include <unotools/moduleoptions.hxx>
27 #include <unotools/pathoptions.hxx>
28 #include <svl/stritem.hxx>
29 #include <dsitems.hxx>
30 #include <osl/diagnose.h>
31 #include <vcl/svapp.hxx>
32 #include <vcl/weld.hxx>
33 #include <sfx2/filedlghelper.hxx>
34 #include <vcl/stdtext.hxx>
35 #include <sqlmessage.hxx>
36 #include "dsselect.hxx"
37 #include <svl/filenotation.hxx>
38 #include <com/sun/star/awt/XSystemDependentWindowPeer.hpp>
39 #include <com/sun/star/ui/dialogs/XFolderPicker2.hpp>
40 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
41 #include <com/sun/star/lang/SystemDependent.hpp>
42 #include <com/sun/star/mozilla/MozillaBootstrap.hpp>
43 #include <com/sun/star/task/InteractionHandler.hpp>
44 #include <com/sun/star/ucb/XProgressHandler.hpp>
45 #include <ucbhelper/commandenvironment.hxx>
46 #include <ucbhelper/content.hxx>
47 #include "finteraction.hxx"
48 #include <tools/urlobj.hxx>
49 #include <comphelper/diagnose_ex.hxx>
52 #include <rtl/process.h>
53 #include <vcl/sysdata.hxx>
54 #include "adodatalinks.hxx"
57 #include <com/sun/star/mozilla/XMozillaBootstrap.hpp>
58 #include <comphelper/processfactory.hxx>
59 #include <comphelper/string.hxx>
63 using namespace ::com::sun::star
;
64 using namespace ::com::sun::star::uno
;
65 using namespace ::com::sun::star::ucb
;
66 using namespace ::com::sun::star::ui::dialogs
;
67 using namespace ::com::sun::star::sdbc
;
68 using namespace ::com::sun::star::mozilla
;
69 using namespace ::svt
;
71 OConnectionHelper::OConnectionHelper(weld::Container
* pPage
, weld::DialogController
* pController
, const OUString
& _rUIXMLDescription
, const OUString
& _rId
, const SfxItemSet
& _rCoreAttrs
)
72 : OGenericAdministrationPage(pPage
, pController
, _rUIXMLDescription
, _rId
, _rCoreAttrs
)
73 , m_bUserGrabFocus(false)
74 , m_pCollection(nullptr)
75 , m_xFT_Connection(m_xBuilder
->weld_label(u
"browseurllabel"_ustr
))
76 , m_xPB_Connection(m_xBuilder
->weld_button(u
"browse"_ustr
))
77 , m_xPB_CreateDB(m_xBuilder
->weld_button(u
"create"_ustr
))
78 , m_xConnectionURL(new OConnectionURLEdit(m_xBuilder
->weld_entry(u
"browseurl"_ustr
), m_xBuilder
->weld_label(u
"browselabel"_ustr
)))
80 // extract the datasource type collection from the item set
81 const DbuTypeCollectionItem
* pCollectionItem
= dynamic_cast<const DbuTypeCollectionItem
*>( _rCoreAttrs
.GetItem(DSID_TYPECOLLECTION
) );
83 m_pCollection
= pCollectionItem
->getCollection();
84 m_xPB_Connection
->connect_clicked(LINK(this, OConnectionHelper
, OnBrowseConnections
));
85 m_xPB_CreateDB
->connect_clicked(LINK(this, OConnectionHelper
, OnCreateDatabase
));
86 OSL_ENSURE(m_pCollection
, "OConnectionHelper::OConnectionHelper : really need a DSN type collection !");
87 m_xConnectionURL
->SetTypeCollection(m_pCollection
);
89 m_xConnectionURL
->connect_focus_in(LINK(this, OConnectionHelper
, GetFocusHdl
));
90 m_xConnectionURL
->connect_focus_out(LINK(this, OConnectionHelper
, LoseFocusHdl
));
93 OConnectionHelper::~OConnectionHelper()
95 m_xConnectionURL
.reset();
98 void OConnectionHelper::implInitControls(const SfxItemSet
& _rSet
, bool _bSaveValue
)
100 // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
101 bool bValid
, bReadonly
;
102 getFlags(_rSet
, bValid
, bReadonly
);
104 m_xFT_Connection
->show();
105 m_xConnectionURL
->show();
106 m_xConnectionURL
->ShowPrefix( ::dbaccess::DST_JDBC
== m_pCollection
->determineType(m_eType
) );
108 bool bEnableBrowseButton
= m_pCollection
->supportsBrowsing( m_eType
);
109 m_xPB_Connection
->set_visible( bEnableBrowseButton
);
111 bool bEnableCreateButton
= m_pCollection
->supportsDBCreation( m_eType
);
112 m_xPB_CreateDB
->set_visible( bEnableCreateButton
);
114 const SfxStringItem
* pUrlItem
= _rSet
.GetItem
<SfxStringItem
>(DSID_CONNECTURL
);
116 // forward the values to the controls
119 OUString sUrl
= pUrlItem
->GetValue();
122 checkTestConnection();
123 m_xConnectionURL
->save_value();
126 OGenericAdministrationPage::implInitControls(_rSet
, _bSaveValue
);
129 void OConnectionHelper::implUpdateURLDependentStates() const
131 OSL_PRECOND( m_pAdminDialog
&& m_pCollection
, "OConnectionHelper::implUpdateURLDependentStates: no admin dialog!" );
132 if ( !m_pAdminDialog
|| !m_pCollection
)
135 if ( m_pCollection
->isFileSystemBased(m_eType
) )
136 m_pAdminDialog
->enableConfirmSettings( !getURLNoPrefix().isEmpty() );
139 IMPL_LINK_NOARG(OConnectionHelper
, OnBrowseConnections
, weld::Button
&, void)
141 OSL_ENSURE(m_pAdminDialog
,"No Admin dialog set! ->GPF");
142 const ::dbaccess::DATASOURCE_TYPE eType
= m_pCollection
->determineType(m_eType
);
145 case ::dbaccess::DST_DBASE
:
146 case ::dbaccess::DST_FLAT
:
150 Reference
< XFolderPicker2
> xFolderPicker
= sfx2::createFolderPicker(m_xORB
, GetFrameWeld());
152 bool bDoBrowse
= false;
153 OUString sOldPath
= getURLNoPrefix();
156 if (!sOldPath
.isEmpty())
157 xFolderPicker
->setDisplayDirectory(sOldPath
);
158 if (0 == xFolderPicker
->execute())
159 // cancelled by the user
162 sOldPath
= xFolderPicker
->getDirectory();
163 switch (checkPathExistence(sOldPath
))
176 OUString sSelectedDirectory
= xFolderPicker
->getDirectory();
177 INetURLObject
aSelectedDirectory( sSelectedDirectory
, INetURLObject::EncodeMechanism::WasEncoded
, RTL_TEXTENCODING_UTF8
);
179 // for UI purpose, we don't want to have the path encoded
180 sSelectedDirectory
= aSelectedDirectory
.GetMainURL( INetURLObject::DecodeMechanism::WithCharset
);
182 setURLNoPrefix( sSelectedDirectory
);
183 SetRoadmapStateValue(true);
186 catch( const Exception
& )
188 DBG_UNHANDLED_EXCEPTION("dbaccess");
192 case ::dbaccess::DST_CALC
:
194 SvtModuleOptions aModule
;
195 ::sfx2::FileDialogHelper
aFileDlg(
196 ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION
,
197 FileDialogFlags::NONE
,
198 aModule
.GetFactoryEmptyDocumentURL(SvtModuleOptions::EFactory::CALC
)
199 ,SfxFilterFlags::IMPORT
, SfxFilterFlags::NONE
, GetFrameWeld());
200 askForFileName(aFileDlg
);
203 case ::dbaccess::DST_WRITER
:
205 SvtModuleOptions aModule
;
206 ::sfx2::FileDialogHelper
aFileDlg(
207 ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION
,
208 FileDialogFlags::NONE
,
209 aModule
.GetFactoryEmptyDocumentURL(SvtModuleOptions::EFactory::WRITER
),
210 SfxFilterFlags::IMPORT
, SfxFilterFlags::NONE
, GetFrameWeld());
211 askForFileName(aFileDlg
);
214 case ::dbaccess::DST_MSACCESS
:
216 OUString
sFilterName(DBA_RES (STR_MSACCESS_FILTERNAME
));
217 ::sfx2::FileDialogHelper
aFileDlg(
218 ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION
,
219 FileDialogFlags::NONE
, GetFrameWeld());
220 aFileDlg
.AddFilter(sFilterName
,u
"*.accdb;*.accde;*.mdb;*.mde"_ustr
);
221 aFileDlg
.SetCurrentFilter(sFilterName
);
222 askForFileName(aFileDlg
);
225 case ::dbaccess::DST_MYSQL_ODBC
:
226 case ::dbaccess::DST_ODBC
:
228 // collect all ODBC data source names
229 OUString sCurrDatasource
= getURLNoPrefix();
230 OUString sDataSource
;
231 if ( getSelectedDataSource(sDataSource
,sCurrDatasource
) && !sDataSource
.isEmpty() )
233 setURLNoPrefix(sDataSource
);
234 SetRoadmapStateValue(true);
242 case ::dbaccess::DST_ADO
:
244 OUString sOldDataSource
=getURLNoPrefix();
245 OUString sNewDataSource
;
248 weld::Window
* pDialog
= GetFrameWeld();
249 css::uno::Reference
<css::awt::XSystemDependentWindowPeer
> xSysDepWin(pDialog
->GetXWindow(), css::uno::UNO_QUERY
);
252 css::uno::Sequence
<sal_Int8
> aProcessIdent(16);
253 rtl_getGlobalProcessId(reinterpret_cast<sal_uInt8
*>(aProcessIdent
.getArray()));
254 css::uno::Any aAny
= xSysDepWin
->getWindowHandle(aProcessIdent
, css::lang::SystemDependent::SYSTEM_WIN32
);
257 hWnd
= reinterpret_cast<HWND
>(tmp
);
260 sNewDataSource
= getAdoDatalink(reinterpret_cast<sal_IntPtr
>(hWnd
),sOldDataSource
);
261 if ( !sNewDataSource
.isEmpty() )
263 setURLNoPrefix(sNewDataSource
);
264 SetRoadmapStateValue(true);
270 case ::dbaccess::DST_MOZILLA
:
271 case ::dbaccess::DST_THUNDERBIRD
:
273 MozillaProductType profileType
= MozillaProductType_Mozilla
;
274 if (eType
== ::dbaccess::DST_THUNDERBIRD
)
275 profileType
= MozillaProductType_Thunderbird
;
277 const Reference
<XComponentContext
>& xContext
= ::comphelper::getProcessComponentContext();
278 Reference
<XMozillaBootstrap
> xMozillaBootstrap
= MozillaBootstrap::create(xContext
);
280 // collect all Mozilla Profiles
281 css::uno::Sequence
< OUString
> list
;
283 xMozillaBootstrap
->getProfileList( profileType
, list
);
285 std::set
<OUString
> aProfiles(list
.begin(), list
.end());
287 // execute the select dialog
288 ODatasourceSelectDialog
aSelector(GetFrameWeld(), aProfiles
);
289 OUString sOldProfile
=getURLNoPrefix();
291 if (!sOldProfile
.isEmpty())
292 aSelector
.Select(sOldProfile
);
294 aSelector
.Select(xMozillaBootstrap
->getDefaultProfile(profileType
));
296 if (RET_OK
== aSelector
.run())
297 setURLNoPrefix(aSelector
.GetSelected());
300 case ::dbaccess::DST_FIREBIRD
:
302 OUString
sFilterName(DBA_RES (STR_FIREBIRD_FILTERNAME
));
303 ::sfx2::FileDialogHelper
aFileDlg(
304 ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE
,
305 FileDialogFlags::NONE
, GetFrameWeld());
306 aFileDlg
.AddFilter(sFilterName
,u
"*.fdb"_ustr
);
307 aFileDlg
.SetCurrentFilter(sFilterName
);
308 askForFileName(aFileDlg
);
315 checkTestConnection();
318 IMPL_LINK_NOARG(OConnectionHelper
, OnCreateDatabase
, weld::Button
&, void)
320 OSL_ENSURE(m_pAdminDialog
,"No Admin dialog set! ->GPF");
321 const ::dbaccess::DATASOURCE_TYPE eType
= m_pCollection
->determineType(m_eType
);
324 case ::dbaccess::DST_FIREBIRD
:
326 OUString
sFilterName(DBA_RES (STR_FIREBIRD_FILTERNAME
));
327 ::sfx2::FileDialogHelper
aFileDlg(
328 ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION
,
329 FileDialogFlags::NONE
, GetFrameWeld());
330 aFileDlg
.AddFilter(sFilterName
,u
"*.fdb"_ustr
);
331 aFileDlg
.SetCurrentFilter(sFilterName
);
332 askForFileName(aFileDlg
);
339 checkTestConnection();
342 bool OConnectionHelper::checkTestConnection()
347 void OConnectionHelper::impl_setURL( std::u16string_view _rURL
, bool _bPrefix
)
349 OUString
sURL( comphelper::string::stripEnd(_rURL
, '*') );
350 OSL_ENSURE( m_pCollection
, "OConnectionHelper::impl_setURL: have no interpreter for the URLs!" );
352 if ( m_pCollection
&& !sURL
.isEmpty() )
354 if ( m_pCollection
->isFileSystemBased( m_eType
) )
356 // get the two parts: prefix and file URL
357 OUString sTypePrefix
, sFileURLEncoded
;
360 sTypePrefix
= m_pCollection
->getPrefix( m_eType
);
361 sFileURLEncoded
= m_pCollection
->cutPrefix( sURL
);
365 sFileURLEncoded
= sURL
;
368 // substitute any variables
369 sFileURLEncoded
= SvtPathOptions().SubstituteVariable( sFileURLEncoded
);
373 if ( !sFileURLEncoded
.isEmpty() )
375 OFileNotation
aFileNotation(sFileURLEncoded
);
376 // set this decoded URL as text
377 sURL
+= aFileNotation
.get(OFileNotation::N_SYSTEM
);
383 m_xConnectionURL
->SetText( sURL
);
385 m_xConnectionURL
->SetTextNoPrefix( sURL
);
387 implUpdateURLDependentStates();
390 OUString
OConnectionHelper::impl_getURL() const
393 OUString sURL
= m_xConnectionURL
->GetTextNoPrefix();
395 OSL_ENSURE( m_pCollection
, "OConnectionHelper::impl_getURL: have no interpreter for the URLs!" );
397 if ( m_pCollection
&& !sURL
.isEmpty() )
399 if ( m_pCollection
->isFileSystemBased( m_eType
) )
401 // get the two parts: prefix and file URL
402 OUString sFileURLDecoded
= sURL
;
405 if ( !sFileURLDecoded
.isEmpty() )
407 OFileNotation
aFileNotation( sFileURLDecoded
, OFileNotation::N_SYSTEM
);
408 sURL
+= aFileNotation
.get( OFileNotation::N_URL
);
412 INetURLObject
aFileURL( sFileURLDecoded
, INetURLObject::EncodeMechanism::All
, RTL_TEXTENCODING_UTF8
);
413 sFileURLDecoded
= aFileURL
.GetMainURL( INetURLObject::DecodeMechanism::NONE
);
419 void OConnectionHelper::setURL( std::u16string_view _rURL
)
421 impl_setURL( _rURL
, true );
424 OUString
OConnectionHelper::getURLNoPrefix( ) const
426 return impl_getURL();
429 void OConnectionHelper::setURLNoPrefix( std::u16string_view _rURL
)
431 impl_setURL( _rURL
, false );
434 sal_Int32
OConnectionHelper::checkPathExistence(const OUString
& _rURL
)
436 IS_PATH_EXIST e_exists
= pathExists(_rURL
, false);
437 if (!m_pCollection
->supportsDBCreation(m_eType
) &&
438 (( e_exists
== PATH_NOT_EXIST
) || ( e_exists
== PATH_NOT_KNOWN
)))
440 OUString
sQuery(DBA_RES(STR_ASK_FOR_DIRECTORY_CREATION
));
441 OFileNotation
aTransformer(_rURL
);
442 sQuery
= sQuery
.replaceFirst("$path$", aTransformer
.get(OFileNotation::N_SYSTEM
));
444 m_bUserGrabFocus
= false;
445 std::unique_ptr
<weld::MessageDialog
> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(),
446 VclMessageType::Question
, VclButtonsType::YesNo
,
448 xQueryBox
->set_default_response(RET_YES
);
449 sal_Int32 nQueryResult
= xQueryBox
->run();
450 m_bUserGrabFocus
= true;
452 switch (nQueryResult
)
456 bool bTryCreate
= false;
459 if ( !createDirectoryDeep(_rURL
) )
460 { // could not create the directory
461 sQuery
= DBA_RES(STR_COULD_NOT_CREATE_DIRECTORY
);
462 sQuery
= sQuery
.replaceFirst("$name$", aTransformer
.get(OFileNotation::N_SYSTEM
));
464 m_bUserGrabFocus
= false;
466 std::unique_ptr
<weld::MessageDialog
> xWhatToDo(Application::CreateMessageDialog(GetFrameWeld(),
467 VclMessageType::Question
, VclButtonsType::NONE
,
469 xWhatToDo
->add_button(GetStandardText(StandardButtonType::Retry
), RET_RETRY
);
470 xWhatToDo
->add_button(GetStandardText(StandardButtonType::Cancel
), RET_CANCEL
);
471 xWhatToDo
->set_default_response(RET_RETRY
);
472 nQueryResult
= xWhatToDo
->run();
473 m_bUserGrabFocus
= true;
475 if (RET_RETRY
== nQueryResult
)
479 SetRoadmapStateValue(false);
495 SetRoadmapStateValue(false);
505 SetRoadmapStateValue(true);
510 IS_PATH_EXIST
OConnectionHelper::pathExists(const OUString
& _rURL
, bool bIsFile
) const
512 ::ucbhelper::Content aCheckExistence
;
513 IS_PATH_EXIST eExists
= PATH_NOT_EXIST
;
514 Reference
< css::task::XInteractionHandler
> xInteractionHandler
=
515 task::InteractionHandler::createWithParent(m_xORB
, nullptr);
516 rtl::Reference
<OFilePickerInteractionHandler
> pHandler
= new OFilePickerInteractionHandler(xInteractionHandler
);
517 xInteractionHandler
= pHandler
;
519 Reference
< XCommandEnvironment
> xCmdEnv
= new ::ucbhelper::CommandEnvironment( xInteractionHandler
, Reference
< XProgressHandler
>() );
522 aCheckExistence
= ::ucbhelper::Content(_rURL
, xCmdEnv
, comphelper::getProcessComponentContext());
523 const bool bExists
= bIsFile
? aCheckExistence
.isDocument(): aCheckExistence
.isFolder();
524 eExists
= bExists
? PATH_EXIST
: PATH_NOT_EXIST
;
526 catch (const Exception
&)
528 eExists
= pHandler
->isDoesNotExist() ? PATH_NOT_EXIST
: (bIsFile
? PATH_NOT_EXIST
: PATH_NOT_KNOWN
);
533 IMPL_LINK_NOARG(OConnectionHelper
, GetFocusHdl
, weld::Widget
&, void)
535 if (!m_pCollection
->isFileSystemBased(m_eType
))
537 if (!m_bUserGrabFocus
)
539 // URL edit field got the focus
540 m_xConnectionURL
->SaveValueNoPrefix();
543 IMPL_LINK_NOARG(OConnectionHelper
, LoseFocusHdl
, weld::Widget
&, void)
545 if (!m_pCollection
->isFileSystemBased(m_eType
))
547 if (!m_bUserGrabFocus
)
549 // URL edit field lost the focus
553 bool OConnectionHelper::createDirectoryDeep(std::u16string_view _rPathURL
)
555 // get a URL object analyzing the URL for us ...
556 INetURLObject aParser
;
557 aParser
.SetURL(_rPathURL
);
559 INetProtocol eProtocol
= aParser
.GetProtocol();
561 std::vector
< OUString
> aToBeCreated
; // the to-be-created levels
563 // search a level which exists
564 IS_PATH_EXIST eParentExists
= PATH_NOT_EXIST
;
565 while ( eParentExists
== PATH_NOT_EXIST
&& aParser
.getSegmentCount())
567 aToBeCreated
.push_back(aParser
.getName()); // remember the local name for creation
568 aParser
.removeSegment(); // cut the local name
569 eParentExists
= pathExists(aParser
.GetMainURL(INetURLObject::DecodeMechanism::NONE
), false);
572 if (!aParser
.getSegmentCount())
575 // create all the missing levels
578 // the parent content
579 Reference
< XCommandEnvironment
> xEmptyEnv
;
580 ::ucbhelper::Content
aParent(aParser
.GetMainURL(INetURLObject::DecodeMechanism::NONE
), xEmptyEnv
, comphelper::getProcessComponentContext());
582 OUString sContentType
;
583 if ( INetProtocol::File
== eProtocol
)
585 sContentType
= "application/vnd.sun.staroffice.fsys-folder";
586 // the file UCP currently does not support the ContentType property
590 Any aContentType
= aParent
.getPropertyValue(u
"ContentType"_ustr
);
591 aContentType
>>= sContentType
;
594 // the properties which need to be set on the new content
595 Sequence
< OUString
> aNewDirectoryProperties
{ u
"Title"_ustr
};
598 for ( std::vector
< OUString
>::const_reverse_iterator aLocalName
= aToBeCreated
.rbegin();
599 aLocalName
!= aToBeCreated
.rend();
603 // the values to be set
604 Sequence
< Any
> aNewDirectoryAttributes
{ Any(* aLocalName
) };
605 if (!aParent
.insertNewContent(sContentType
, aNewDirectoryProperties
, aNewDirectoryAttributes
, aParent
))
609 catch ( const Exception
& )
611 DBG_UNHANDLED_EXCEPTION("dbaccess");
618 void OConnectionHelper::fillWindows(std::vector
< std::unique_ptr
<ISaveValueWrapper
> >& _rControlList
)
620 _rControlList
.emplace_back(new ODisableWidgetWrapper
<weld::Label
>(m_xFT_Connection
.get()));
621 _rControlList
.emplace_back(new ODisableWidgetWrapper
<weld::Button
>(m_xPB_Connection
.get()));
622 _rControlList
.emplace_back(new ODisableWidgetWrapper
<weld::Button
>(m_xPB_CreateDB
.get()));
625 void OConnectionHelper::fillControls(std::vector
< std::unique_ptr
<ISaveValueWrapper
> >& _rControlList
)
627 _rControlList
.emplace_back( new OSaveValueWidgetWrapper
<OConnectionURLEdit
>( m_xConnectionURL
.get() ) );
630 bool OConnectionHelper::commitURL()
632 OUString sOldPath
= m_xConnectionURL
->GetSavedValueNoPrefix();
633 OUString sURL
= m_xConnectionURL
->GetTextNoPrefix();
635 if ( m_pCollection
->isFileSystemBased(m_eType
) )
637 if ( ( sURL
!= sOldPath
) && !sURL
.isEmpty() )
638 { // the text changed since entering the control
640 // the path may be in system notation...
641 OFileNotation
aTransformer(sURL
);
642 sURL
= aTransformer
.get(OFileNotation::N_URL
);
644 const ::dbaccess::DATASOURCE_TYPE eType
= m_pCollection
->determineType(m_eType
);
646 if ( ( ::dbaccess::DST_CALC
== eType
) || ( ::dbaccess::DST_WRITER
== eType
) || ( ::dbaccess::DST_MSACCESS
== eType
) )
648 if( pathExists(sURL
, true) == PATH_NOT_EXIST
)
650 OUString sFile
= DBA_RES( STR_FILE_DOES_NOT_EXIST
);
651 sFile
= sFile
.replaceFirst("$file$", aTransformer
.get(OFileNotation::N_SYSTEM
));
652 OSQLWarningBox
aWarning(GetFrameWeld(), sFile
);
654 setURLNoPrefix(sOldPath
);
655 SetRoadmapStateValue(false);
662 switch (checkPathExistence(sURL
))
665 m_bUserGrabFocus
= false;
666 m_xConnectionURL
->grab_focus();
667 m_bUserGrabFocus
= true;
671 setURLNoPrefix(sOldPath
);
678 setURLNoPrefix(sURL
);
679 m_xConnectionURL
->SaveValueNoPrefix();
683 void OConnectionHelper::askForFileName(::sfx2::FileDialogHelper
& _aFileOpen
)
685 OUString sOldPath
= getURLNoPrefix();
686 if ( !sOldPath
.isEmpty() )
687 _aFileOpen
.SetDisplayDirectory(sOldPath
);
689 _aFileOpen
.SetDisplayDirectory( SvtPathOptions().GetWorkPath() );
690 if (ERRCODE_NONE
== _aFileOpen
.Execute())
692 setURLNoPrefix(_aFileOpen
.GetPath());
693 SetRoadmapStateValue(checkTestConnection());
700 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */