LibreOffice Module dbaccess (master) 1
generalpage.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 <config_features.h>
21#include <core_resource.hxx>
22#include "dsnItem.hxx"
23#include "generalpage.hxx"
25#include <strings.hrc>
26#include <dsitems.hxx>
28#include <sfx2/docfilt.hxx>
29#include <utility>
30#include <vcl/svapp.hxx>
31#include <vcl/weld.hxx>
32#include <svl/stritem.hxx>
33#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
34#include <UITools.hxx>
35#include <officecfg/Office/Common.hxx>
38#include <o3tl/safeint.hxx>
39#include <osl/diagnose.h>
40#include <sal/log.hxx>
41#include <dbwizsetup.hxx>
42
43namespace dbaui
44{
45 using namespace ::com::sun::star;
46 using namespace ::com::sun::star::uno;
47 using namespace ::com::sun::star::sdbc;
48 using namespace ::com::sun::star::beans;
49 using namespace ::com::sun::star::container;
50
51 // OGeneralPage
52 OGeneralPage::OGeneralPage(weld::Container* pPage, weld::DialogController* pController, const OUString& _rUIXMLDescription, const SfxItemSet& _rItems)
53 : OGenericAdministrationPage(pPage, pController, _rUIXMLDescription, "PageGeneral", _rItems)
54 , m_xSpecialMessage(m_xBuilder->weld_label("specialMessage"))
55 , m_eLastMessage(smNone)
56 , m_bInitTypeList(true)
57 , m_xDatasourceType(m_xBuilder->weld_combo_box("datasourceType"))
58 , m_pCollection(nullptr)
59 {
60 // extract the datasource type collection from the item set
61 const DbuTypeCollectionItem* pCollectionItem = dynamic_cast<const DbuTypeCollectionItem*>( _rItems.GetItem(DSID_TYPECOLLECTION) );
62 if (pCollectionItem)
63 m_pCollection = pCollectionItem->getCollection();
64 SAL_WARN_IF(!m_pCollection, "dbaccess.ui.generalpage", "OGeneralPage::OGeneralPage : really need a DSN type collection !");
65
66 // do some knittings
67 m_xDatasourceType->connect_changed(LINK(this, OGeneralPage, OnDatasourceTypeSelected));
68 }
69
71 {
72 }
73
74 namespace
75 {
76 struct DisplayedType
77 {
78 OUString eType;
79 OUString sDisplayName;
80
81 DisplayedType( OUString _eType, OUString _sDisplayName ) : eType(std::move( _eType )), sDisplayName(std::move( _sDisplayName )) { }
82 };
83 typedef std::vector< DisplayedType > DisplayedTypes;
84
85 struct DisplayedTypeLess
86 {
87 bool operator() ( const DisplayedType& _rLHS, const DisplayedType& _rRHS )
88 {
89 return _rLHS.eType < _rRHS.eType;
90 }
91 };
92 }
93
95 {
96 if ( !m_bInitTypeList )
97 return;
98
99 m_bInitTypeList = false;
100 m_xDatasourceType->clear();
101
102 if ( !m_pCollection )
103 return;
104
105 DisplayedTypes aDisplayedTypes;
106
109 aTypeLoop != aEnd;
110 ++aTypeLoop
111 )
112 {
113 const OUString& sURLPrefix = aTypeLoop.getURLPrefix();
114 if ( !sURLPrefix.isEmpty() )
115 {
116 // skip mysql connection variations. It is handled in another window.
117 if(sURLPrefix.startsWith("sdbc:mysql:") && !sURLPrefix.startsWith("sdbc:mysql:jdbc:"))
118 continue;
119
120 OUString sDisplayName = aTypeLoop.getDisplayName();
121 if (m_xDatasourceType->find_text(sDisplayName) == -1 &&
123 {
124 aDisplayedTypes.emplace_back( sURLPrefix, sDisplayName );
125 }
126 }
127 }
128 std::sort( aDisplayedTypes.begin(), aDisplayedTypes.end(), DisplayedTypeLess() );
129 for ( const auto& rDisplayedType : aDisplayedTypes )
130 insertDatasourceTypeEntryData( rDisplayedType.eType, rDisplayedType.sDisplayName );
131 }
132
134 {
136 return;
137
138 m_bInitEmbeddedDBList = false;
139 m_xEmbeddedDBType->clear();
140
141 if ( !m_pCollection )
142 return;
143
144 DisplayedTypes aDisplayedTypes;
145
148 aTypeLoop != aEnd;
149 ++aTypeLoop
150 )
151 {
152 const OUString& sURLPrefix = aTypeLoop.getURLPrefix();
153 if ( !sURLPrefix.isEmpty() )
154 {
155 OUString sDisplayName = aTypeLoop.getDisplayName();
156 if (m_xEmbeddedDBType->find_text(sDisplayName) == -1 &&
158 {
159#if !HAVE_FEATURE_MACOSX_SANDBOX
160 if( !officecfg::Office::Common::Misc::ExperimentalMode::get()
161 && sURLPrefix.startsWith("sdbc:embedded:firebird") )
162 continue;
163#endif
164 aDisplayedTypes.emplace_back( sURLPrefix, sDisplayName );
166 }
167 }
168 }
169 std::sort( aDisplayedTypes.begin(), aDisplayedTypes.end(), DisplayedTypeLess() );
170 for (auto const& displayedType : aDisplayedTypes)
171 insertEmbeddedDBTypeEntryData( displayedType.eType, displayedType.sDisplayName );
172 }
173
174 void OGeneralPage::setParentTitle(const OUString&)
175 {
176 }
177
178 void OGeneralPage::switchMessage(std::u16string_view _sURLPrefix)
179 {
180 SPECIAL_MESSAGE eMessage = smNone;
181 if ( _sURLPrefix.empty()/*_eType == m_eNotSupportedKnownType*/ )
182 {
183 eMessage = smUnsupportedType;
184 }
185
186 if ( eMessage != m_eLastMessage )
187 {
188 TranslateId pResId;
189 if ( smUnsupportedType == eMessage )
190 pResId = STR_UNSUPPORTED_DATASOURCE_TYPE;
191 OUString sMessage;
192 if ( pResId )
193 sMessage = DBA_RES(pResId);
194
195 m_xSpecialMessage->set_label( sMessage );
196 m_eLastMessage = eMessage;
197 }
198 }
199
200 void OGeneralPage::onTypeSelected(const OUString& _sURLPrefix)
201 {
202 // the new URL text as indicated by the selection history
203 implSetCurrentType( _sURLPrefix );
204
205 switchMessage(_sURLPrefix);
206
207 m_aTypeSelectHandler.Call(*this);
208 }
209
210 void OGeneralPage::implInitControls( const SfxItemSet& _rSet, bool _bSaveValue )
211 {
213
214 m_xDatasourceType->set_active_text(getDatasourceName(_rSet));
215
216 // notify our listener that our type selection has changed (if so)
217 // FIXME: how to detect that it did not changed? (fdo#62937)
220
221 // a special message for the current page state
223
225 }
226
228 {
229 // first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
230 bool bValid, bReadonly;
231 getFlags( _rSet, bValid, bReadonly );
232
233 // if the selection is invalid, disable everything
234
235 implSetCurrentType( OUString() );
236
237 // compare the DSN prefix with the registered ones
238 OUString sDisplayName;
239
240 if (m_pCollection && bValid)
241 {
245 }
246
247 // select the correct datasource type
249 && m_xEmbeddedDBType->find_text(sDisplayName) == -1 )
250 { // this indicates it's really a type which is known in general, but not supported on the current platform
251 // show a message saying so
252 // eSpecialMessage = smUnsupportedType;
254 }
255
256 return sDisplayName;
257 }
258
260 {
261 // first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
262 bool bValid, bReadonly;
263 getFlags( _rSet, bValid, bReadonly );
264
265 // if the selection is invalid, disable everything
266 OUString sConnectURL;
267 if ( bValid )
268 {
269 // collect some items and some values
270 const SfxStringItem* pUrlItem = _rSet.GetItem<SfxStringItem>(DSID_CONNECTURL);
271 assert( pUrlItem );
272 sConnectURL = pUrlItem->GetValue();
273 }
274
275 implSetCurrentType( OUString() );
276
277 // compare the DSN prefix with the registered ones
278 OUString sDisplayName;
279
280 if (m_pCollection && bValid)
281 {
282 implSetCurrentType( m_pCollection->getPrefix( sConnectURL ) );
284 }
285
286 // select the correct datasource type
288 && m_xDatasourceType->find_text(sDisplayName) == -1 )
289 { // this indicates it's really a type which is known in general, but not supported on the current platform
290 // show a message saying so
291 // eSpecialMessage = smUnsupportedType;
293 }
294
295 return sDisplayName;
296 }
297
298 // For the databaseWizard we only have one entry for the MySQL Database,
299 // because we have a separate tabpage to retrieve the respective datasource type
300 // ( ::dbaccess::DST_MYSQL_ODBC || ::dbaccess::DST_MYSQL_JDBC). Therefore we use ::dbaccess::DST_MYSQL_JDBC as a temporary
301 // representative for all MySQl databases)
302 // Also, embedded databases (embedded HSQL, at the moment), are not to appear in the list of
303 // databases to connect to.
304 bool OGeneralPage::approveDatasourceType( std::u16string_view _sURLPrefix, OUString& _inout_rDisplayName )
305 {
306 return approveDatasourceType( m_pCollection->determineType(_sURLPrefix), _inout_rDisplayName );
307 }
308
310 {
312 {
313 // do not display the Connector/OOo driver itself, it is always wrapped via the MySQL-Driver, if
314 // this driver is installed
315 if ( m_pCollection->hasDriver( "sdbc:mysql:mysqlc:" ) )
316 _inout_rDisplayName.clear();
317 }
318
321 _inout_rDisplayName.clear();
322
323 return _inout_rDisplayName.getLength() > 0;
324 }
325
326 void OGeneralPage::insertDatasourceTypeEntryData(const OUString& _sType, const OUString& sDisplayName)
327 {
328 // insert a (temporary) entry
329 m_xDatasourceType->append_text(sDisplayName);
330 m_aURLPrefixes.push_back(_sType);
331 }
332
333 void OGeneralPageWizard::insertEmbeddedDBTypeEntryData(const OUString& _sType, const OUString& sDisplayName)
334 {
335 // insert a (temporary) entry
336 m_xEmbeddedDBType->append_text(sDisplayName);
337 m_aEmbeddedURLPrefixes.push_back(_sType);
338 }
339
340 void OGeneralPage::fillWindows(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList)
341 {
342 _rControlList.emplace_back(new ODisableWidgetWrapper<weld::Label>(m_xSpecialMessage.get()));
343 }
344
345 void OGeneralPage::fillControls(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList)
346 {
347 _rControlList.emplace_back(new OSaveValueWidgetWrapper<weld::ComboBox>(m_xDatasourceType.get()));
348 }
349
350 void OGeneralPage::implSetCurrentType( const OUString& _eType )
351 {
352 if ( _eType == m_eCurrentSelection )
353 return;
354
355 m_eCurrentSelection = _eType;
356 }
357
358 void OGeneralPage::Reset(const SfxItemSet* _rCoreAttrs)
359 {
360 // reset all locale data
361 implSetCurrentType( OUString() );
362 // this ensures that our type selection link will be called, even if the new one is the same as the
363 // current one
365 }
366
367 IMPL_LINK( OGeneralPageWizard, OnEmbeddedDBTypeSelected, weld::ComboBox&, _rBox, void )
368 {
369 // get the type from the entry data
370 const sal_Int32 nSelected = _rBox.get_active();
371 if (o3tl::make_unsigned(nSelected) >= m_aEmbeddedURLPrefixes.size() )
372 {
373 SAL_WARN("dbaccess.ui.generalpage", "Got out-of-range value '" << nSelected << "' from the DatasourceType selection ListBox's GetSelectedEntryPos(): no corresponding URL prefix");
374 return;
375 }
376 const OUString sURLPrefix = m_aEmbeddedURLPrefixes[ nSelected ];
377
378 setParentTitle( sURLPrefix );
379 // let the impl method do all the stuff
380 onTypeSelected( sURLPrefix );
381 // tell the listener we were modified
382 callModifiedHdl();
383 }
384
385 IMPL_LINK( OGeneralPage, OnDatasourceTypeSelected, weld::ComboBox&, _rBox, void )
386 {
387 // get the type from the entry data
388 const sal_Int32 nSelected = _rBox.get_active();
389 if (nSelected == -1)
390 return;
391 if (o3tl::make_unsigned(nSelected) >= m_aURLPrefixes.size() )
392 {
393 SAL_WARN("dbaccess.ui.generalpage", "Got out-of-range value '" << nSelected << "' from the DatasourceType selection ListBox's GetSelectedEntryPos(): no corresponding URL prefix");
394 return;
395 }
396 const OUString sURLPrefix = m_aURLPrefixes[ nSelected ];
397
398 setParentTitle( sURLPrefix );
399 // let the impl method do all the stuff
400 onTypeSelected( sURLPrefix );
401 // tell the listener we were modified
402 callModifiedHdl();
403 }
404
405 // OGeneralPageDialog
407 : OGeneralPage(pPage, pController, "dbaccess/ui/generalpagedialog.ui", _rItems)
408 {
409 }
410
411 void OGeneralPageDialog::setParentTitle( const OUString& _sURLPrefix )
412 {
413 const OUString sName = m_pCollection->getTypeDisplayName( _sURLPrefix );
414 if ( m_pAdminDialog )
415 {
416 OUString sMessage = DBA_RES(STR_PARENTTITLE_GENERAL);
417 m_pAdminDialog->setTitle( sMessage.replaceAll( "#", sName ) );
418 }
419 }
420
421 void OGeneralPageDialog::implInitControls( const SfxItemSet& _rSet, bool _bSaveValue )
422 {
423 OGeneralPage::implInitControls( _rSet, _bSaveValue );
424
425 // first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
426 bool bValid, bReadonly;
427 getFlags(_rSet, bValid, bReadonly );
428
429 m_xDatasourceType->set_sensitive( bValid );
430 }
431
433 {
434 bool bChangedSomething = false;
435
436 const sal_Int32 nEntry = m_xDatasourceType->get_active();
437 OUString sURLPrefix = m_aURLPrefixes[ nEntry ];
438
439 if (m_xDatasourceType->get_value_changed_from_saved())
440 {
441 _rCoreAttrs->Put( SfxStringItem( DSID_CONNECTURL, sURLPrefix ) );
442 bChangedSomething = true;
443 }
444
445 return bChangedSomething;
446 }
447
448 // OGeneralPageWizard
450 : OGeneralPage( pPage, pController, "dbaccess/ui/generalpagewizard.ui", _rItems )
451 , m_xRB_CreateDatabase(m_xBuilder->weld_radio_button("createDatabase"))
452 , m_xRB_OpenExistingDatabase(m_xBuilder->weld_radio_button("openExistingDatabase"))
453 , m_xRB_ConnectDatabase(m_xBuilder->weld_radio_button("connectDatabase"))
454 , m_xFT_EmbeddedDBLabel(m_xBuilder->weld_label("embeddeddbLabel"))
455 , m_xEmbeddedDBType(m_xBuilder->weld_combo_box("embeddeddbList"))
456 , m_xFT_DocListLabel(m_xBuilder->weld_label("docListLabel"))
457 , m_xLB_DocumentList(new OpenDocumentListBox(m_xBuilder->weld_combo_box("documentList"), "com.sun.star.sdb.OfficeDatabaseDocument"))
458 , m_xPB_OpenDatabase(new OpenDocumentButton(m_xBuilder->weld_button("openDatabase"), "com.sun.star.sdb.OfficeDatabaseDocument"))
459 , m_xFT_NoEmbeddedDBLabel(m_xBuilder->weld_label("noembeddeddbLabel"))
460 , m_eOriginalCreationMode(eCreateNew)
461 , m_bInitEmbeddedDBList(true)
462 , m_bIsDisplayedTypesEmpty(true)
463 {
464 // If no driver for embedded DBs is installed, and no dBase driver, then hide the "Create new database" option
466 if ( nCreateNewDBIndex == -1 )
467 nCreateNewDBIndex = m_pCollection->getIndexOf( u"sdbc:dbase:" );
468 bool bHideCreateNew = ( nCreateNewDBIndex == -1 );
469
470 // also, if our application policies tell us to hide the option, do it
472 ::comphelper::getProcessComponentContext(),
473 "/org.openoffice.Office.DataAccess/Policies/Features/Base"
474 ) );
475 bool bAllowCreateLocalDatabase( true );
476 OSL_VERIFY( aConfig.getNodeValue( "CreateLocalDatabase" ) >>= bAllowCreateLocalDatabase );
477 if ( !bAllowCreateLocalDatabase )
478 bHideCreateNew = true;
479
480 if ( bHideCreateNew )
481 {
482 m_xRB_CreateDatabase->hide();
483 m_xRB_ConnectDatabase->set_active(true);
484 }
485 else
486 m_xRB_CreateDatabase->set_active(true);
487
488 // do some knittings
489 m_xEmbeddedDBType->connect_changed(LINK(this, OGeneralPageWizard, OnEmbeddedDBTypeSelected));
490 m_xRB_CreateDatabase->connect_toggled( LINK( this, OGeneralPageWizard, OnSetupModeSelected ) );
491 m_xRB_ConnectDatabase->connect_toggled( LINK( this, OGeneralPageWizard, OnSetupModeSelected ) );
492 m_xRB_OpenExistingDatabase->connect_toggled( LINK( this, OGeneralPageWizard, OnSetupModeSelected ) );
493 m_xLB_DocumentList->connect_changed( LINK( this, OGeneralPageWizard, OnDocumentSelected ) );
494 m_xPB_OpenDatabase->connect_clicked( LINK( this, OGeneralPageWizard, OnOpenDocument ) );
496
497 pController->SetGeneralPage(this);
498 }
499
501 {
502 }
503
505 {
506 if ( m_xRB_CreateDatabase->get_active() )
507 return eCreateNew;
508 if ( m_xRB_ConnectDatabase->get_active() )
509 return eConnectExternal;
510 return eOpenExisting;
511 }
512
513 void OGeneralPageWizard::implInitControls( const SfxItemSet& _rSet, bool _bSaveValue )
514 {
515 OGeneralPage::implInitControls( _rSet, _bSaveValue );
516
518 m_xEmbeddedDBType->set_active_text(getEmbeddedDBName(_rSet));
519
521 {
522 m_xRB_CreateDatabase->set_sensitive(false);
523 m_xFT_EmbeddedDBLabel->hide();
524 m_xEmbeddedDBType->hide();
526 m_xRB_OpenExistingDatabase->set_active(true);
527 }
528
529 // first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
530 bool bValid, bReadonly;
531 getFlags( _rSet, bValid, bReadonly );
532
533 SetPageTitle(OUString());
534
535 if ( !bValid || bReadonly )
536 {
537 m_xFT_EmbeddedDBLabel->set_sensitive( false );
538 m_xDatasourceType->set_sensitive( false );
539 m_xPB_OpenDatabase->set_sensitive( false );
540 m_xFT_DocListLabel->set_sensitive( false );
541 m_xLB_DocumentList->set_sensitive( false );
542 }
543
544 if (m_xLB_DocumentList->get_count())
545 m_xLB_DocumentList->set_active(0);
546
548
550 }
551
553 {
554 // Sets the default selected database on startup.
555 if (m_xRB_CreateDatabase->get_active() )
556 {
557 return m_pCollection->getTypeDisplayName( u"sdbc:firebird:" );
558 }
559
560 return OGeneralPage::getDatasourceName( _rSet );
561 }
562
564 {
565 switch ( eType )
566 {
570 _inout_rDisplayName = "MySQL/MariaDB";
571 break;
572 default:
573 break;
574 }
575
576 return OGeneralPage::approveDatasourceType( eType, _inout_rDisplayName );
577 }
578
580 {
581 bool bChangedSomething = false;
582
583 bool bCommitTypeSelection = true;
584
585 if ( m_xRB_CreateDatabase->get_active() )
586 {
587 _rCoreAttrs->Put( SfxStringItem( DSID_CONNECTURL, "sdbc:dbase:" ) );
588 bChangedSomething = true;
589 bCommitTypeSelection = false;
590 }
591 else if ( m_xRB_OpenExistingDatabase->get_active() )
592 {
593 if ( m_xRB_OpenExistingDatabase->get_state_changed_from_saved() )
594 bChangedSomething = true;
595
596 // TODO
597 bCommitTypeSelection = false;
598 }
599
600 if ( bCommitTypeSelection )
601 {
602 const sal_Int32 nEntry = m_xDatasourceType->get_active();
603 OUString sURLPrefix = m_aURLPrefixes[nEntry];
604
605 if ( m_xDatasourceType->get_value_changed_from_saved()
607 )
608 {
609 _rCoreAttrs->Put( SfxStringItem( DSID_CONNECTURL,sURLPrefix ) );
610 bChangedSomething = true;
611 }
612 else
613 implSetCurrentType( sURLPrefix );
614 }
615 return bChangedSomething;
616 }
617
619 {
620 if ( !m_aBrowsedDocumentURL.isEmpty() )
622 else
623 return m_xLB_DocumentList->GetSelectedDocumentURL();
624 }
625
627 {
628 bool bValid, bReadonly;
629 getFlags( GetItemSet(), bValid, bReadonly );
630 if ( bValid && !bReadonly )
631 {
632 m_xEmbeddedDBType->set_sensitive(m_xRB_CreateDatabase->get_active());
633 m_xFT_EmbeddedDBLabel->set_sensitive(m_xRB_CreateDatabase->get_active());
634 m_xDatasourceType->set_sensitive(m_xRB_ConnectDatabase->get_active());
635 m_xPB_OpenDatabase->set_sensitive(m_xRB_OpenExistingDatabase->get_active());
636 m_xFT_DocListLabel->set_sensitive(m_xRB_OpenExistingDatabase->get_active());
637 m_xLB_DocumentList->set_sensitive(m_xRB_OpenExistingDatabase->get_active());
638 }
639 }
640
642 {
643 m_aCreationModeHandler.Call( *this );
644
645 if (m_xRB_CreateDatabase->get_active())
646 OnEmbeddedDBTypeSelected(*m_xEmbeddedDBType);
647 else
648 OnDatasourceTypeSelected(*m_xDatasourceType);
649
651 }
652
653 IMPL_LINK(OGeneralPageWizard, OnSetupModeSelected, weld::Toggleable&, rButton, void)
654 {
655 if (!rButton.get_active())
656 return;
657 SetupModeSelected();
658 }
659
660 IMPL_LINK_NOARG( OGeneralPageWizard, OnDocumentSelected, weld::ComboBox&, void )
661 {
662 m_aDocumentSelectionHandler.Call( *this );
663 }
664
666 {
668 ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION,
669 FileDialogFlags::NONE, "sdatabase", SfxFilterFlags::NONE, SfxFilterFlags::NONE, GetFrameWeld());
671 std::shared_ptr<const SfxFilter> pFilter = getStandardDatabaseFilter();
672 if ( pFilter )
673 {
674 aFileDlg.SetCurrentFilter(pFilter->GetUIName());
675 }
676 if ( aFileDlg.Execute() != ERRCODE_NONE )
677 return;
678
679 OUString sPath = aFileDlg.GetPath();
680 // check for aFileDlg.GetCurrentFilter used to be here but current fpicker filter
681 // can be set to anything, see tdf#125267 how this breaks if other value
682 // than 'ODF Database' is selected. Let's therefore check only if wildcard matches
683 if (pFilter && !pFilter->GetWildcard().Matches(sPath))
684 {
685 OUString sMessage(DBA_RES(STR_ERR_USE_CONNECT_TO));
686 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
687 VclMessageType::Info, VclButtonsType::Ok,
688 sMessage));
689 xInfoBox->run();
690 m_xRB_ConnectDatabase->set_active(true);
691 OnSetupModeSelected( *m_xRB_ConnectDatabase );
692 return;
693 }
694 m_aBrowsedDocumentURL = sPath;
695 m_aChooseDocumentHandler.Call( *this );
696 }
697
698} // namespace dbaui
699
700/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OptionalString sName
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
const OUString & GetValue() const
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxItemSet & GetItemSet() const
DATASOURCE_TYPE determineType(std::u16string_view _rDsn) const
Definition: dsntypes.cxx:299
TypeIterator end() const
get access to the (last + 1st) element of the types collection
Definition: dsntypes.hxx:217
static OUString getEmbeddedDatabase()
Definition: dsntypes.cxx:290
bool hasDriver(const char *_pAsciiPattern) const
determines whether there is a driver for the given URL prefix/pattern
Definition: dsntypes.cxx:131
static bool isEmbeddedDatabase(std::u16string_view _sURL)
checks if the given data source type embeds its data into the database document
Definition: dsntypes.cxx:285
OUString getPrefix(std::u16string_view _sURL) const
on a given string, return the type prefix
Definition: dsntypes.cxx:110
TypeIterator begin() const
get access to the first element of the types collection
Definition: dsntypes.hxx:216
OUString getTypeDisplayName(std::u16string_view _sURL) const
get the datasource type display name from a DSN string
Definition: dsntypes.cxx:79
sal_Int32 getIndexOf(std::u16string_view _sURL) const
Definition: dsntypes.cxx:495
TypeIterator(const TypeIterator &_rSource)
allows an ODsnTypeCollection to be transported in an SfxItemSet
Definition: dsnItem.hxx:34
::dbaccess::ODsnTypeCollection * getCollection() const
Definition: dsnItem.hxx:44
virtual void setTitle(const OUString &_sTitle)=0
void SetGeneralPage(OGeneralPageWizard *pPage)
Definition: dbwizsetup.cxx:449
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...
virtual bool FillItemSet(SfxItemSet *_rCoreAttrs) override
virtual void setParentTitle(const OUString &_sURLPrefix) override
sets the title of the parent dialog
OGeneralPageDialog(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &_rItems)
virtual bool approveDatasourceType(::dbaccess::DATASOURCE_TYPE eType, OUString &_inout_rDisplayName) override
virtual bool FillItemSet(SfxItemSet *_rCoreAttrs) override
std::unique_ptr< OpenDocumentListBox > m_xLB_DocumentList
virtual ~OGeneralPageWizard() override
std::unique_ptr< weld::Label > m_xFT_DocListLabel
CreationMode GetDatabaseCreationMode() const
CreationMode m_eOriginalCreationMode
OUString GetSelectedDocumentURL() const
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...
OUString getEmbeddedDBName(const SfxItemSet &_rSet)
bool m_bInitEmbeddedDBList
to be called when a recent document has been definitely chosen
OGeneralPageWizard(weld::Container *pPage, ODbTypeWizDialogSetup *pController, const SfxItemSet &_rItems)
std::unique_ptr< weld::RadioButton > m_xRB_OpenExistingDatabase
std::vector< OUString > m_aEmbeddedURLPrefixes
std::unique_ptr< weld::Label > m_xFT_NoEmbeddedDBLabel
void insertEmbeddedDBTypeEntryData(const OUString &_sType, const OUString &sDisplayName)
Link< OGeneralPageWizard &, void > m_aCreationModeHandler
std::unique_ptr< weld::RadioButton > m_xRB_ConnectDatabase
std::unique_ptr< weld::Label > m_xFT_EmbeddedDBLabel
virtual OUString getDatasourceName(const SfxItemSet &_rSet) override
std::unique_ptr< weld::ComboBox > m_xEmbeddedDBType
std::unique_ptr< OpenDocumentButton > m_xPB_OpenDatabase
std::unique_ptr< weld::RadioButton > m_xRB_CreateDatabase
virtual void fillControls(std::vector< std::unique_ptr< ISaveValueWrapper > > &_rControlList) override
will be called inside <method>implInitControls</method> to save the value if necessary
::dbaccess::ODsnTypeCollection * m_pCollection
Definition: generalpage.hxx:56
OGeneralPage(weld::Container *pPage, weld::DialogController *pController, const OUString &_rUIXMLDescription, const SfxItemSet &_rItems)
Definition: generalpage.cxx:52
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...
virtual ~OGeneralPage() override
Definition: generalpage.cxx:70
virtual void Reset(const SfxItemSet *_rCoreAttrs) override
default implementation: call implInitControls with the given item set and _bSaveValue = sal_False
bool approveDatasourceType(std::u16string_view _sURLPrefix, OUString &_inout_rDisplayName)
std::unique_ptr< weld::Label > m_xSpecialMessage
currently selected type
Definition: generalpage.hxx:38
void insertDatasourceTypeEntryData(const OUString &_sType, const OUString &sDisplayName)
SPECIAL_MESSAGE m_eLastMessage
Definition: generalpage.hxx:45
std::unique_ptr< weld::ComboBox > m_xDatasourceType
Definition: generalpage.hxx:53
void onTypeSelected(const OUString &_sURLPrefix)
void implSetCurrentType(const OUString &_eType)
virtual void setParentTitle(const OUString &_sURLPrefix)
sets the title of the parent dialog
bool m_bInitTypeList
to be called if a new type is selected
Definition: generalpage.hxx:48
virtual void fillWindows(std::vector< std::unique_ptr< ISaveValueWrapper > > &_rControlList) override
will be called inside <method>implInitControls</method> to disable if necessary
std::vector< OUString > m_aURLPrefixes
the DSN type collection instance
Definition: generalpage.hxx:59
void switchMessage(std::u16string_view _sURLPrefix)
Link< OGeneralPage &, void > m_aTypeSelectHandler
Definition: generalpage.hxx:47
void initializeTypeList()
Initializes the listbox, which contains entries each representing a connection to an existing databas...
Definition: generalpage.cxx:94
OUString m_eCurrentSelection
Definition: generalpage.hxx:35
virtual OUString getDatasourceName(const SfxItemSet &_rSet)
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
virtual void Reset(const SfxItemSet *_rCoreAttrs) override
default implementation: call implInitControls with the given item set and _bSaveValue = sal_False
Definition: adminpages.cxx:75
IDatabaseSettingsDialog * m_pAdminDialog
Definition: adminpages.hxx:94
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
a button which can be used to open a document
OUString GetPath() const
void SetCurrentFilter(const OUString &rFilter)
void SetContext(Context _eNewContext)
css::uno::Any getNodeValue(const OUString &_rPath) const noexcept
static OConfigurationTreeRoot createWithComponentContext(const css::uno::Reference< css::uno::XComponentContext > &_rxContext, const OUString &_rPath, sal_Int32 _nDepth=-1, CREATION_MODE _eMode=CM_UPDATABLE)
#define DBA_RES(id)
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
#define DSID_CONNECTURL
Definition: dsitems.hxx:36
#define DSID_TYPECOLLECTION
Definition: dsitems.hxx:38
float u
#define ERRCODE_NONE
OUString sDisplayName
Definition: generalpage.cxx:79
OUString eType
Definition: generalpage.cxx:78
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
DATASOURCE_TYPE
known datasource types
Definition: dsntypes.hxx:36
@ DST_MYSQL_JDBC
Definition: dsntypes.hxx:39
@ DST_MYSQL_ODBC
Definition: dsntypes.hxx:38
@ DST_MYSQL_NATIVE
Definition: dsntypes.hxx:60
@ DST_EMBEDDED_FIREBIRD
Definition: dsntypes.hxx:63
@ DST_EMBEDDED_HSQLDB
Definition: dsntypes.hxx:59
@ DST_MYSQL_NATIVE_DIRECT
Definition: dsntypes.hxx:61
IMPL_LINK_NOARG(OApplicationController, OnClipboardChanged, TransferableDataHelper *, void)
IMPL_LINK(OApplicationController, OnSelectContainer, void *, _pType, void)
std::shared_ptr< const SfxFilter > getStandardDatabaseFilter()
returns the standard database filter
Definition: UITools.cxx:861
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
OUString sMessage
Definition: sqlmessage.cxx:159