LibreOffice Module dbaccess (master) 1
ConnectionHelper.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <core_resource.hxx>
21#include "dsnItem.hxx"
22#include "ConnectionHelper.hxx"
23#include <IItemSetHelper.hxx>
24#include <strings.hrc>
25#include <svl/itemset.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>
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>
46#include <ucbhelper/content.hxx>
47#include "finteraction.hxx"
48#include <tools/urlobj.hxx>
50
51#if defined _WIN32
52#include <rtl/process.h>
53#include <vcl/sysdata.hxx>
54#include "adodatalinks.hxx"
55#endif
56
57#include <com/sun/star/mozilla/XMozillaBootstrap.hpp>
59#include <comphelper/string.hxx>
60
61namespace dbaui
62{
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::beans;
69 using namespace ::com::sun::star::lang;
70 using namespace ::com::sun::star::container;
71 using namespace ::com::sun::star::mozilla;
72 using namespace ::dbtools;
73 using namespace ::svt;
74
75 OConnectionHelper::OConnectionHelper(weld::Container* pPage, weld::DialogController* pController, const OUString& _rUIXMLDescription, const OUString& _rId, const SfxItemSet& _rCoreAttrs)
76 : OGenericAdministrationPage(pPage, pController, _rUIXMLDescription, _rId, _rCoreAttrs)
77 , m_bUserGrabFocus(false)
78 , m_pCollection(nullptr)
79 , m_xFT_Connection(m_xBuilder->weld_label("browseurllabel"))
80 , m_xPB_Connection(m_xBuilder->weld_button("browse"))
81 , m_xPB_CreateDB(m_xBuilder->weld_button("create"))
82 , m_xConnectionURL(new OConnectionURLEdit(m_xBuilder->weld_entry("browseurl"), m_xBuilder->weld_label("browselabel")))
83 {
84 // extract the datasource type collection from the item set
85 const DbuTypeCollectionItem* pCollectionItem = dynamic_cast<const DbuTypeCollectionItem*>( _rCoreAttrs.GetItem(DSID_TYPECOLLECTION) );
86 if (pCollectionItem)
87 m_pCollection = pCollectionItem->getCollection();
88 m_xPB_Connection->connect_clicked(LINK(this, OConnectionHelper, OnBrowseConnections));
89 m_xPB_CreateDB->connect_clicked(LINK(this, OConnectionHelper, OnCreateDatabase));
90 OSL_ENSURE(m_pCollection, "OConnectionHelper::OConnectionHelper : really need a DSN type collection !");
91 m_xConnectionURL->SetTypeCollection(m_pCollection);
92
93 m_xConnectionURL->connect_focus_in(LINK(this, OConnectionHelper, GetFocusHdl));
94 m_xConnectionURL->connect_focus_out(LINK(this, OConnectionHelper, LoseFocusHdl));
95 }
96
98 {
99 m_xConnectionURL.reset();
100 }
101
102 void OConnectionHelper::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
103 {
104 // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
105 bool bValid, bReadonly;
106 getFlags(_rSet, bValid, bReadonly);
107
108 m_xFT_Connection->show();
109 m_xConnectionURL->show();
111
112 bool bEnableBrowseButton = m_pCollection->supportsBrowsing( m_eType );
113 m_xPB_Connection->set_visible( bEnableBrowseButton );
114
115 bool bEnableCreateButton = m_pCollection->supportsDBCreation( m_eType );
116 m_xPB_CreateDB->set_visible( bEnableCreateButton );
117
118 const SfxStringItem* pUrlItem = _rSet.GetItem<SfxStringItem>(DSID_CONNECTURL);
119
120 // forward the values to the controls
121 if ( bValid )
122 {
123 OUString sUrl = pUrlItem->GetValue();
124 setURL( sUrl );
125
127 m_xConnectionURL->save_value();
128 }
129
131 }
132
134 {
135 OSL_PRECOND( m_pAdminDialog && m_pCollection, "OConnectionHelper::implUpdateURLDependentStates: no admin dialog!" );
136 if ( !m_pAdminDialog || !m_pCollection )
137 return;
138
141 }
142
143 IMPL_LINK_NOARG(OConnectionHelper, OnBrowseConnections, weld::Button&, void)
144 {
145 OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF");
146 const ::dbaccess::DATASOURCE_TYPE eType = m_pCollection->determineType(m_eType);
147 switch ( eType )
148 {
151 {
152 try
153 {
155
156 bool bDoBrowse = false;
157 OUString sOldPath = getURLNoPrefix();
158 do
159 {
160 if (!sOldPath.isEmpty())
161 xFolderPicker->setDisplayDirectory(sOldPath);
162 if (0 == xFolderPicker->execute())
163 // cancelled by the user
164 return;
165
166 sOldPath = xFolderPicker->getDirectory();
167 switch (checkPathExistence(sOldPath))
168 {
169 case RET_RETRY:
170 bDoBrowse = true;
171 break;
172 case RET_CANCEL:
173 return;
174 default:
175 break;
176 }
177 }
178 while (bDoBrowse);
179
180 OUString sSelectedDirectory = xFolderPicker->getDirectory();
181 INetURLObject aSelectedDirectory( sSelectedDirectory, INetURLObject::EncodeMechanism::WasEncoded, RTL_TEXTENCODING_UTF8 );
182
183 // for UI purpose, we don't want to have the path encoded
184 sSelectedDirectory = aSelectedDirectory.GetMainURL( INetURLObject::DecodeMechanism::WithCharset );
185
186 setURLNoPrefix( sSelectedDirectory );
187 SetRoadmapStateValue(true);
188 callModifiedHdl();
189 }
190 catch( const Exception& )
191 {
192 DBG_UNHANDLED_EXCEPTION("dbaccess");
193 }
194 }
195 break;
197 {
198 SvtModuleOptions aModule;
200 ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION,
201 FileDialogFlags::NONE,
203 ,SfxFilterFlags::IMPORT, SfxFilterFlags::NONE, GetFrameWeld());
204 askForFileName(aFileDlg);
205 }
206 break;
208 {
209 SvtModuleOptions aModule;
211 ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION,
212 FileDialogFlags::NONE,
214 SfxFilterFlags::IMPORT, SfxFilterFlags::NONE, GetFrameWeld());
215 askForFileName(aFileDlg);
216 }
217 break;
219 {
220 OUString sFilterName(DBA_RES (STR_MSACCESS_FILTERNAME));
222 ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION,
223 FileDialogFlags::NONE, GetFrameWeld());
224 aFileDlg.AddFilter(sFilterName,"*.mdb;*.mde");
225 aFileDlg.SetCurrentFilter(sFilterName);
226 askForFileName(aFileDlg);
227 }
228 break;
230 {
231 OUString sFilterName2(DBA_RES (STR_MSACCESS_2007_FILTERNAME));
233 ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION,
234 FileDialogFlags::NONE, GetFrameWeld());
235 aFileDlg.AddFilter(sFilterName2,"*.accdb;*.accde");
236 aFileDlg.SetCurrentFilter(sFilterName2);
237 askForFileName(aFileDlg);
238 }
239 break;
242 {
243 // collect all ODBC data source names
244 OUString sCurrDatasource = getURLNoPrefix();
245 OUString sDataSource;
246 if ( getSelectedDataSource(sDataSource,sCurrDatasource) && !sDataSource.isEmpty() )
247 {
248 setURLNoPrefix(sDataSource);
249 SetRoadmapStateValue(true);
250 callModifiedHdl();
251 }
252 else
253 return;
254 }
255 break;
256#if defined _WIN32
258 {
259 OUString sOldDataSource=getURLNoPrefix();
260 OUString sNewDataSource;
261 HWND hWnd = nullptr;
262
263 weld::Window* pDialog = GetFrameWeld();
264 css::uno::Reference<css::awt::XSystemDependentWindowPeer> xSysDepWin(pDialog->GetXWindow(), css::uno::UNO_QUERY);
265 if (xSysDepWin.is())
266 {
267 css::uno::Sequence<sal_Int8> aProcessIdent(16);
268 rtl_getGlobalProcessId(reinterpret_cast<sal_uInt8*>(aProcessIdent.getArray()));
269 css::uno::Any aAny = xSysDepWin->getWindowHandle(aProcessIdent, css::lang::SystemDependent::SYSTEM_WIN32);
270 sal_Int64 tmp(0);
271 aAny >>= tmp;
272 hWnd = reinterpret_cast<HWND>(tmp);
273 }
274
275 sNewDataSource = getAdoDatalink(reinterpret_cast<sal_IntPtr>(hWnd),sOldDataSource);
276 if ( !sNewDataSource.isEmpty() )
277 {
278 setURLNoPrefix(sNewDataSource);
279 SetRoadmapStateValue(true);
280 callModifiedHdl();
281 }
282 }
283 break;
284#endif
287 {
288 MozillaProductType profileType = MozillaProductType_Mozilla;
290 profileType = MozillaProductType_Thunderbird;
291
292 Reference<XComponentContext> xContext = ::comphelper::getProcessComponentContext();
293 Reference<XMozillaBootstrap> xMozillaBootstrap = MozillaBootstrap::create(xContext);
294
295 // collect all Mozilla Profiles
296 css::uno::Sequence< OUString > list;
297
298 xMozillaBootstrap->getProfileList( profileType, list );
299 const OUString * pArray = list.getConstArray();
300
301 sal_Int32 count = list.getLength();
302
303 std::set<OUString> aProfiles;
304 for (sal_Int32 index=0; index < count; index++)
305 aProfiles.insert(pArray[index]);
306
307 // execute the select dialog
308 ODatasourceSelectDialog aSelector(GetFrameWeld(), aProfiles);
309 OUString sOldProfile=getURLNoPrefix();
310
311 if (!sOldProfile.isEmpty())
312 aSelector.Select(sOldProfile);
313 else
314 aSelector.Select(xMozillaBootstrap->getDefaultProfile(profileType));
315
316 if (RET_OK == aSelector.run())
317 setURLNoPrefix(aSelector.GetSelected());
318 break;
319 }
321 {
322 OUString sFilterName(DBA_RES (STR_FIREBIRD_FILTERNAME));
324 ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
325 FileDialogFlags::NONE, GetFrameWeld());
326 aFileDlg.AddFilter(sFilterName,"*.fdb");
327 aFileDlg.SetCurrentFilter(sFilterName);
328 askForFileName(aFileDlg);
329 break;
330 }
331 default:
332 break;
333 }
334
335 checkTestConnection();
336 }
337
339 {
340 OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF");
341 const ::dbaccess::DATASOURCE_TYPE eType = m_pCollection->determineType(m_eType);
342 switch ( eType )
343 {
345 {
346 OUString sFilterName(DBA_RES (STR_FIREBIRD_FILTERNAME));
348 ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION,
349 FileDialogFlags::NONE, GetFrameWeld());
350 aFileDlg.AddFilter(sFilterName,"*.fdb");
351 aFileDlg.SetCurrentFilter(sFilterName);
352 askForFileName(aFileDlg);
353 break;
354 }
355 default:
356 break;
357 }
358
359 checkTestConnection();
360 }
361
363 {
364 return true;
365 }
366
367 void OConnectionHelper::impl_setURL( std::u16string_view _rURL, bool _bPrefix )
368 {
369 OUString sURL( comphelper::string::stripEnd(_rURL, '*') );
370 OSL_ENSURE( m_pCollection, "OConnectionHelper::impl_setURL: have no interpreter for the URLs!" );
371
372 if ( m_pCollection && !sURL.isEmpty() )
373 {
375 {
376 // get the two parts: prefix and file URL
377 OUString sTypePrefix, sFileURLEncoded;
378 if ( _bPrefix )
379 {
380 sTypePrefix = m_pCollection->getPrefix( m_eType );
381 sFileURLEncoded = m_pCollection->cutPrefix( sURL );
382 }
383 else
384 {
385 sFileURLEncoded = sURL;
386 }
387
388 // substitute any variables
389 sFileURLEncoded = SvtPathOptions().SubstituteVariable( sFileURLEncoded );
390
391 // decode the URL
392 sURL = sTypePrefix;
393 if ( !sFileURLEncoded.isEmpty() )
394 {
395 OFileNotation aFileNotation(sFileURLEncoded);
396 // set this decoded URL as text
397 sURL += aFileNotation.get(OFileNotation::N_SYSTEM);
398 }
399 }
400 }
401
402 if ( _bPrefix )
403 m_xConnectionURL->SetText( sURL );
404 else
405 m_xConnectionURL->SetTextNoPrefix( sURL );
406
408 }
409
411 {
412 // get the pure text
413 OUString sURL = m_xConnectionURL->GetTextNoPrefix();
414
415 OSL_ENSURE( m_pCollection, "OConnectionHelper::impl_getURL: have no interpreter for the URLs!" );
416
417 if ( m_pCollection && !sURL.isEmpty() )
418 {
420 {
421 // get the two parts: prefix and file URL
422 OUString sFileURLDecoded = sURL;
423
424 sURL = OUString();
425 if ( !sFileURLDecoded.isEmpty() )
426 {
427 OFileNotation aFileNotation( sFileURLDecoded, OFileNotation::N_SYSTEM );
428 sURL += aFileNotation.get( OFileNotation::N_URL );
429 }
430
431 // encode the URL
432 INetURLObject aFileURL( sFileURLDecoded, INetURLObject::EncodeMechanism::All, RTL_TEXTENCODING_UTF8 );
433 sFileURLDecoded = aFileURL.GetMainURL( INetURLObject::DecodeMechanism::NONE );
434 }
435 }
436 return sURL;
437 }
438
439 void OConnectionHelper::setURL( std::u16string_view _rURL )
440 {
441 impl_setURL( _rURL, true );
442 }
443
445 {
446 return impl_getURL();
447 }
448
449 void OConnectionHelper::setURLNoPrefix( std::u16string_view _rURL )
450 {
451 impl_setURL( _rURL, false );
452 }
453
454 sal_Int32 OConnectionHelper::checkPathExistence(const OUString& _rURL)
455 {
456 IS_PATH_EXIST e_exists = pathExists(_rURL, false);
458 (( e_exists == PATH_NOT_EXIST) || ( e_exists == PATH_NOT_KNOWN)))
459 {
460 OUString sQuery(DBA_RES(STR_ASK_FOR_DIRECTORY_CREATION));
461 OFileNotation aTransformer(_rURL);
462 sQuery = sQuery.replaceFirst("$path$", aTransformer.get(OFileNotation::N_SYSTEM));
463
464 m_bUserGrabFocus = false;
465 std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(),
466 VclMessageType::Question, VclButtonsType::YesNo,
467 sQuery));
468 xQueryBox->set_default_response(RET_YES);
469 sal_Int32 nQueryResult = xQueryBox->run();
470 m_bUserGrabFocus = true;
471
472 switch (nQueryResult)
473 {
474 case RET_YES:
475 {
476 bool bTryCreate = false;
477 do
478 {
479 if ( !createDirectoryDeep(_rURL) )
480 { // could not create the directory
481 sQuery = DBA_RES(STR_COULD_NOT_CREATE_DIRECTORY);
482 sQuery = sQuery.replaceFirst("$name$", aTransformer.get(OFileNotation::N_SYSTEM));
483
484 m_bUserGrabFocus = false;
485
486 std::unique_ptr<weld::MessageDialog> xWhatToDo(Application::CreateMessageDialog(GetFrameWeld(),
487 VclMessageType::Question, VclButtonsType::NONE,
488 sQuery));
489 xWhatToDo->add_button(GetStandardText(StandardButtonType::Retry), RET_RETRY);
490 xWhatToDo->add_button(GetStandardText(StandardButtonType::Cancel), RET_CANCEL);
491 xWhatToDo->set_default_response(RET_RETRY);
492 nQueryResult = xWhatToDo->run();
493 m_bUserGrabFocus = true;
494
495 if (RET_RETRY == nQueryResult)
496 bTryCreate = true;
497 else
498 {
501 return RET_RETRY;
502 }
503 }
504 }
505 while (bTryCreate);
506 }
507 break;
508
509 case RET_NO:
511 return RET_OK;
512
513 default:
514 // cancelled
517 return RET_CANCEL;
518 }
519 }
520/* else
521 {
522 // TODO: error msg
523 return RET_CANCEL;
524 } */
527 return RET_OK;
528 }
529
530 IS_PATH_EXIST OConnectionHelper::pathExists(const OUString& _rURL, bool bIsFile) const
531 {
532 ::ucbhelper::Content aCheckExistence;
535 task::InteractionHandler::createWithParent(m_xORB, nullptr);
537 xInteractionHandler = pHandler;
538
539 Reference< XCommandEnvironment > xCmdEnv = new ::ucbhelper::CommandEnvironment( xInteractionHandler, Reference< XProgressHandler >() );
540 try
541 {
542 aCheckExistence = ::ucbhelper::Content(_rURL, xCmdEnv, comphelper::getProcessComponentContext());
543 const bool bExists = bIsFile? aCheckExistence.isDocument(): aCheckExistence.isFolder();
544 eExists = bExists? PATH_EXIST: PATH_NOT_EXIST;
545 }
546 catch (const Exception&)
547 {
548 eExists = pHandler->isDoesNotExist() ? PATH_NOT_EXIST : (bIsFile ? PATH_NOT_EXIST : PATH_NOT_KNOWN);
549 }
550 return eExists;
551 }
552
554 {
555 if (!m_pCollection->isFileSystemBased(m_eType))
556 return;
557 if (!m_bUserGrabFocus)
558 return;
559 // URL edit field got the focus
560 m_xConnectionURL->SaveValueNoPrefix();
561 }
562
564 {
565 if (!m_pCollection->isFileSystemBased(m_eType))
566 return;
567 if (!m_bUserGrabFocus)
568 return;
569 // URL edit field lost the focus
570 commitURL();
571 }
572
573 bool OConnectionHelper::createDirectoryDeep(std::u16string_view _rPathURL)
574 {
575 // get a URL object analyzing the URL for us ...
576 INetURLObject aParser;
577 aParser.SetURL(_rPathURL);
578
579 INetProtocol eProtocol = aParser.GetProtocol();
580
581 std::vector< OUString > aToBeCreated; // the to-be-created levels
582
583 // search a level which exists
584 IS_PATH_EXIST eParentExists = PATH_NOT_EXIST;
585 while ( eParentExists == PATH_NOT_EXIST && aParser.getSegmentCount())
586 {
587 aToBeCreated.push_back(aParser.getName()); // remember the local name for creation
588 aParser.removeSegment(); // cut the local name
589 eParentExists = pathExists(aParser.GetMainURL(INetURLObject::DecodeMechanism::NONE), false);
590 }
591
592 if (!aParser.getSegmentCount())
593 return false;
594
595 // create all the missing levels
596 try
597 {
598 // the parent content
601
602 OUString sContentType;
603 if ( INetProtocol::File == eProtocol )
604 {
605 sContentType = "application/vnd.sun.staroffice.fsys-folder";
606 // the file UCP currently does not support the ContentType property
607 }
608 else
609 {
610 Any aContentType = aParent.getPropertyValue("ContentType");
611 aContentType >>= sContentType;
612 }
613
614 // the properties which need to be set on the new content
615 Sequence< OUString > aNewDirectoryProperties { "Title" };
616
617 // loop
618 for ( std::vector< OUString >::const_reverse_iterator aLocalName = aToBeCreated.rbegin();
619 aLocalName != aToBeCreated.rend();
620 ++aLocalName
621 )
622 {
623 // the values to be set
624 Sequence< Any > aNewDirectoryAttributes{ Any(* aLocalName) };
625 if (!aParent.insertNewContent(sContentType, aNewDirectoryProperties, aNewDirectoryAttributes, aParent))
626 return false;
627 }
628 }
629 catch ( const Exception& )
630 {
631 DBG_UNHANDLED_EXCEPTION("dbaccess");
632 return false;
633 }
634
635 return true;
636 }
637
638 void OConnectionHelper::fillWindows(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList)
639 {
640 _rControlList.emplace_back(new ODisableWidgetWrapper<weld::Label>(m_xFT_Connection.get()));
641 _rControlList.emplace_back(new ODisableWidgetWrapper<weld::Button>(m_xPB_Connection.get()));
642 _rControlList.emplace_back(new ODisableWidgetWrapper<weld::Button>(m_xPB_CreateDB.get()));
643 }
644
645 void OConnectionHelper::fillControls(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList)
646 {
647 _rControlList.emplace_back( new OSaveValueWidgetWrapper<OConnectionURLEdit>( m_xConnectionURL.get() ) );
648 }
649
651 {
652 OUString sOldPath = m_xConnectionURL->GetSavedValueNoPrefix();
653 OUString sURL = m_xConnectionURL->GetTextNoPrefix();
654
656 {
657 if ( ( sURL != sOldPath ) && !sURL.isEmpty() )
658 { // the text changed since entering the control
659
660 // the path may be in system notation...
661 OFileNotation aTransformer(sURL);
662 sURL = aTransformer.get(OFileNotation::N_URL);
663
665
667 {
668 if( pathExists(sURL, true) == PATH_NOT_EXIST )
669 {
670 OUString sFile = DBA_RES( STR_FILE_DOES_NOT_EXIST );
671 sFile = sFile.replaceFirst("$file$", aTransformer.get(OFileNotation::N_SYSTEM));
672 OSQLWarningBox aWarning(GetFrameWeld(), sFile);
673 aWarning.run();
674 setURLNoPrefix(sOldPath);
677 return false;
678 }
679 }
680 else
681 {
682 switch (checkPathExistence(sURL))
683 {
684 case RET_RETRY:
685 m_bUserGrabFocus = false;
686 m_xConnectionURL->grab_focus();
687 m_bUserGrabFocus = true;
688 return false;
689
690 case RET_CANCEL:
691 setURLNoPrefix(sOldPath);
692 return false;
693 }
694 }
695 }
696 }
697
698 setURLNoPrefix(sURL);
699 m_xConnectionURL->SaveValueNoPrefix();
700 return true;
701 }
702
704 {
705 OUString sOldPath = getURLNoPrefix();
706 if ( !sOldPath.isEmpty() )
707 _aFileOpen.SetDisplayDirectory(sOldPath);
708 else
709 _aFileOpen.SetDisplayDirectory( SvtPathOptions().GetWorkPath() );
710 if (ERRCODE_NONE == _aFileOpen.Execute())
711 {
712 setURLNoPrefix(_aFileOpen.GetPath());
715 }
716 }
717
718} // namespace dbaui
719
720/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
const OUString & GetValue() const
OUString getName(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
bool removeSegment(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true)
sal_Int32 getSegmentCount(bool bIgnoreFinalSlash=true) const
INetProtocol GetProtocol() const
bool SetURL(std::u16string_view rTheAbsURIRef, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
weld::Window * GetFrameWeld() const
OUString GetFactoryEmptyDocumentURL(EFactory eFactory) const
OUString SubstituteVariable(const OUString &rVar) const
DATASOURCE_TYPE determineType(std::u16string_view _rDsn) const
Definition: dsntypes.cxx:299
OUString cutPrefix(std::u16string_view _sURL) const
on a given string, cut the type prefix and return the result
Definition: dsntypes.cxx:84
bool isFileSystemBased(std::u16string_view _sURL) const
check if the given data source type is based on the file system - i.e. the URL is a prefix plus a fil...
Definition: dsntypes.cxx:249
OUString getPrefix(std::u16string_view _sURL) const
on a given string, return the type prefix
Definition: dsntypes.cxx:110
bool supportsDBCreation(std::u16string_view _sURL) const
Definition: dsntypes.cxx:273
bool supportsBrowsing(std::u16string_view _sURL) const
Definition: dsntypes.cxx:267
allows an ODsnTypeCollection to be transported in an SfxItemSet
Definition: dsnItem.hxx:34
::dbaccess::ODsnTypeCollection * getCollection() const
Definition: dsnItem.hxx:44
virtual void enableConfirmSettings(bool _bEnable)=0
enables or disables the user's possibility to confirm the settings
virtual void fillControls(std::vector< std::unique_ptr< ISaveValueWrapper > > &_rControlList) override
will be called inside <method>implInitControls</method> to save the value if necessary
virtual void fillWindows(std::vector< std::unique_ptr< ISaveValueWrapper > > &_rControlList) override
will be called inside <method>implInitControls</method> to disable if necessary
virtual void implInitControls(const SfxItemSet &_rSet, bool _bSaveValue) override
called from within Reset and ActivatePage, use to initialize the controls with the items from the giv...
IS_PATH_EXIST pathExists(const OUString &_rURL, bool bIsFile) const
virtual ~OConnectionHelper() override
std::unique_ptr< weld::Label > m_xFT_Connection
the DSN type collection instance
OUString getURLNoPrefix() const
std::unique_ptr< weld::Button > m_xPB_CreateDB
OConnectionHelper(weld::Container *pPage, weld::DialogController *pController, const OUString &_rUIXMLDescription, const OUString &_rId, const SfxItemSet &_rCoreAttrs)
void impl_setURL(std::u16string_view _rURL, bool _bPrefix)
virtual bool checkTestConnection()
void askForFileName(::sfx2::FileDialogHelper &_aFileOpen)
opens the FileOpen dialog and asks for a FileName
bool createDirectoryDeep(std::u16string_view _rPathNormalized)
std::unique_ptr< OConnectionURLEdit > m_xConnectionURL
void implUpdateURLDependentStates() const
void setURLNoPrefix(std::u16string_view _rURL)
::dbaccess::ODsnTypeCollection * m_pCollection
sal_Int32 checkPathExistence(const OUString &_rURL)
checks if the path is existence
std::unique_ptr< weld::Button > m_xPB_Connection
void setURL(std::u16string_view _rURL)
OUString GetSelected() const
Definition: dsselect.hxx:42
void Select(const OUString &_rEntry)
Definition: dsselect.hxx:43
virtual short run() override
Definition: dsselect.cxx:59
static void getFlags(const SfxItemSet &_rSet, bool &_rValid, bool &_rReadonly)
analyze the invalid and the readonly flag which may be present in the set
Definition: adminpages.cxx:93
IDatabaseSettingsDialog * m_pAdminDialog
Definition: adminpages.hxx:94
void SetRoadmapStateValue(bool _bDoEnable)
Definition: adminpages.hxx:142
css::uno::Reference< css::uno::XComponentContext > m_xORB
Definition: adminpages.hxx:98
virtual void callModifiedHdl(weld::Widget *=nullptr)
Definition: adminpages.hxx:157
virtual void implInitControls(const SfxItemSet &_rSet, bool _bSaveValue)
called from within Reset and ActivatePage, use to initialize the controls with the items from the giv...
Definition: adminpages.cxx:150
OUString GetPath() const
void AddFilter(const OUString &rFilterName, const OUString &rExtension)
void SetDisplayDirectory(const OUString &rPath)
void SetCurrentFilter(const OUString &rFilter)
OUString get(NOTATION _eOutputNotation) const
css::uno::Any getPropertyValue(const OUString &rPropertyName)
bool insertNewContent(const OUString &rContentType, const css::uno::Sequence< OUString > &rPropertyNames, const css::uno::Sequence< css::uno::Any > &rPropertyValues, Content &rNewContent)
virtual short run()
virtual css::uno::Reference< css::awt::XWindow > GetXWindow()=0
#define DBA_RES(id)
#define DBG_UNHANDLED_EXCEPTION(...)
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
#define DSID_CONNECTURL
Definition: dsitems.hxx:36
#define DSID_TYPECOLLECTION
Definition: dsitems.hxx:38
const EnumerationType m_eType
#define ERRCODE_NONE
OUString eType
Definition: generalpage.cxx:78
@ Exception
OString stripEnd(const OString &rIn, char c)
Reference< XComponentContext > getProcessComponentContext()
DATASOURCE_TYPE
known datasource types
Definition: dsntypes.hxx:36
@ DST_MSACCESS_2007
Definition: dsntypes.hxx:58
@ DST_CALC
Definition: dsntypes.hxx:42
@ DST_WRITER
Definition: dsntypes.hxx:65
@ DST_MOZILLA
Definition: dsntypes.hxx:48
@ DST_MSACCESS
Definition: dsntypes.hxx:37
@ DST_MYSQL_ODBC
Definition: dsntypes.hxx:38
@ DST_JDBC
Definition: dsntypes.hxx:45
@ DST_ODBC
Definition: dsntypes.hxx:46
@ DST_DBASE
Definition: dsntypes.hxx:43
@ DST_FLAT
Definition: dsntypes.hxx:44
@ DST_FIREBIRD
Definition: dsntypes.hxx:62
@ DST_THUNDERBIRD
Definition: dsntypes.hxx:49
IMPL_LINK_NOARG(OApplicationController, OnClipboardChanged, TransferableDataHelper *, void)
index
css::uno::Reference< css::ui::dialogs::XFolderPicker2 > createFolderPicker(const css::uno::Reference< css::uno::XComponentContext > &rContext, weld::Window *pPreferredParent)
OUString VCL_DLLPUBLIC GetStandardText(StandardButtonType eButton)
unsigned char sal_uInt8
INetProtocol
RET_OK
RET_CANCEL
RET_NO
RET_RETRY
RET_YES