20#include <config_features.h>
21#include <core_resource.hxx>
33#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
35#include <officecfg/Office/Common.hxx>
39#include <osl/diagnose.h>
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)
64 SAL_WARN_IF(!
m_pCollection,
"dbaccess.ui.generalpage",
"OGeneralPage::OGeneralPage : really need a DSN type collection !");
81 DisplayedType( OUString _eType, OUString _sDisplayName ) :
eType(
std::move( _eType )),
sDisplayName(
std::move( _sDisplayName )) { }
83 typedef std::vector< DisplayedType > DisplayedTypes;
85 struct DisplayedTypeLess
87 bool operator() (
const DisplayedType& _rLHS,
const DisplayedType& _rRHS )
89 return _rLHS.eType < _rRHS.eType;
105 DisplayedTypes aDisplayedTypes;
113 const OUString& sURLPrefix = aTypeLoop.getURLPrefix();
114 if ( !sURLPrefix.isEmpty() )
117 if(sURLPrefix.startsWith(
"sdbc:mysql:") && !sURLPrefix.startsWith(
"sdbc:mysql:jdbc:"))
124 aDisplayedTypes.emplace_back( sURLPrefix,
sDisplayName );
128 std::sort( aDisplayedTypes.begin(), aDisplayedTypes.end(), DisplayedTypeLess() );
129 for (
const auto& rDisplayedType : aDisplayedTypes )
144 DisplayedTypes aDisplayedTypes;
152 const OUString& sURLPrefix = aTypeLoop.getURLPrefix();
153 if ( !sURLPrefix.isEmpty() )
159#if !HAVE_FEATURE_MACOSX_SANDBOX
160 if( !officecfg::Office::Common::Misc::ExperimentalMode::get()
161 && sURLPrefix.startsWith(
"sdbc:embedded:firebird") )
164 aDisplayedTypes.emplace_back( sURLPrefix,
sDisplayName );
169 std::sort( aDisplayedTypes.begin(), aDisplayedTypes.end(), DisplayedTypeLess() );
170 for (
auto const& displayedType : aDisplayedTypes)
181 if ( _sURLPrefix.empty() )
190 pResId = STR_UNSUPPORTED_DATASOURCE_TYPE;
230 bool bValid, bReadonly;
231 getFlags( _rSet, bValid, bReadonly );
262 bool bValid, bReadonly;
263 getFlags( _rSet, bValid, bReadonly );
266 OUString sConnectURL;
316 _inout_rDisplayName.clear();
321 _inout_rDisplayName.clear();
323 return _inout_rDisplayName.getLength() > 0;
370 const sal_Int32 nSelected = _rBox.get_active();
373 SAL_WARN(
"dbaccess.ui.generalpage",
"Got out-of-range value '" << nSelected <<
"' from the DatasourceType selection ListBox's GetSelectedEntryPos(): no corresponding URL prefix");
376 const OUString sURLPrefix = m_aEmbeddedURLPrefixes[ nSelected ];
378 setParentTitle( sURLPrefix );
380 onTypeSelected( sURLPrefix );
388 const sal_Int32 nSelected = _rBox.get_active();
393 SAL_WARN(
"dbaccess.ui.generalpage",
"Got out-of-range value '" << nSelected <<
"' from the DatasourceType selection ListBox's GetSelectedEntryPos(): no corresponding URL prefix");
396 const OUString sURLPrefix = m_aURLPrefixes[ nSelected ];
398 setParentTitle( sURLPrefix );
400 onTypeSelected( sURLPrefix );
407 :
OGeneralPage(pPage, pController,
"dbaccess/ui/generalpagedialog.ui", _rItems)
426 bool bValid, bReadonly;
427 getFlags(_rSet, bValid, bReadonly );
434 bool bChangedSomething =
false;
442 bChangedSomething =
true;
445 return bChangedSomething;
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)
466 if ( nCreateNewDBIndex == -1 )
468 bool bHideCreateNew = ( nCreateNewDBIndex == -1 );
472 ::comphelper::getProcessComponentContext(),
473 "/org.openoffice.Office.DataAccess/Policies/Features/Base"
475 bool bAllowCreateLocalDatabase(
true );
476 OSL_VERIFY( aConfig.
getNodeValue(
"CreateLocalDatabase" ) >>= bAllowCreateLocalDatabase );
477 if ( !bAllowCreateLocalDatabase )
478 bHideCreateNew =
true;
480 if ( bHideCreateNew )
530 bool bValid, bReadonly;
531 getFlags( _rSet, bValid, bReadonly );
533 SetPageTitle(OUString());
535 if ( !bValid || bReadonly )
570 _inout_rDisplayName =
"MySQL/MariaDB";
581 bool bChangedSomething =
false;
583 bool bCommitTypeSelection =
true;
588 bChangedSomething =
true;
589 bCommitTypeSelection =
false;
594 bChangedSomething =
true;
597 bCommitTypeSelection =
false;
600 if ( bCommitTypeSelection )
610 bChangedSomething =
true;
615 return bChangedSomething;
628 bool bValid, bReadonly;
630 if ( bValid && !bReadonly )
655 if (!rButton.get_active())
662 m_aDocumentSelectionHandler.Call( *
this );
668 ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION,
669 FileDialogFlags::NONE,
"sdatabase", SfxFilterFlags::NONE, SfxFilterFlags::NONE,
GetFrameWeld());
679 OUString sPath = aFileDlg.
GetPath();
683 if (pFilter && !pFilter->GetWildcard().Matches(sPath))
687 VclMessageType::Info, VclButtonsType::Ok,
690 m_xRB_ConnectDatabase->set_active(
true);
691 OnSetupModeSelected( *m_xRB_ConnectDatabase );
694 m_aBrowsedDocumentURL = sPath;
695 m_aChooseDocumentHandler.Call( *
this );
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
TypeIterator end() const
get access to the (last + 1st) element of the types collection
static OUString getEmbeddedDatabase()
bool hasDriver(const char *_pAsciiPattern) const
determines whether there is a driver for the given URL prefix/pattern
static bool isEmbeddedDatabase(std::u16string_view _sURL)
checks if the given data source type embeds its data into the database document
OUString getPrefix(std::u16string_view _sURL) const
on a given string, return the type prefix
TypeIterator begin() const
get access to the first element of the types collection
OUString getTypeDisplayName(std::u16string_view _sURL) const
get the datasource type display name from a DSN string
sal_Int32 getIndexOf(std::u16string_view _sURL) const
TypeIterator(const TypeIterator &_rSource)
allows an ODsnTypeCollection to be transported in an SfxItemSet
::dbaccess::ODsnTypeCollection * getCollection() const
virtual void setTitle(const OUString &_sTitle)=0
void SetGeneralPage(OGeneralPageWizard *pPage)
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
bool m_bIsDisplayedTypesEmpty
virtual bool FillItemSet(SfxItemSet *_rCoreAttrs) override
std::unique_ptr< OpenDocumentListBox > m_xLB_DocumentList
void initializeEmbeddedDBList()
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
OUString m_aBrowsedDocumentURL
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
OGeneralPage(weld::Container *pPage, weld::DialogController *pController, const OUString &_rUIXMLDescription, const SfxItemSet &_rItems)
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
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
void insertDatasourceTypeEntryData(const OUString &_sType, const OUString &sDisplayName)
SPECIAL_MESSAGE m_eLastMessage
std::unique_ptr< weld::ComboBox > m_xDatasourceType
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
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
void switchMessage(std::u16string_view _sURLPrefix)
Link< OGeneralPage &, void > m_aTypeSelectHandler
void initializeTypeList()
Initializes the listbox, which contains entries each representing a connection to an existing databas...
OUString m_eCurrentSelection
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
virtual void Reset(const SfxItemSet *_rCoreAttrs) override
default implementation: call implInitControls with the given item set and _bSaveValue = sal_False
IDatabaseSettingsDialog * m_pAdminDialog
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...
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)
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
#define DSID_TYPECOLLECTION
#define LINK(Instance, Class, Member)
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
DATASOURCE_TYPE
known datasource types
@ DST_MYSQL_NATIVE_DIRECT
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
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)