diff options
author | Andrzej J.R. Hunt <andrzej@ahunt.org> | 2013-09-20 14:36:18 +0100 |
---|---|---|
committer | Andrzej J.R. Hunt <andrzej@ahunt.org> | 2013-11-07 08:15:27 +0000 |
commit | 117b24dbbd627def07e3fe06438f54172d20618c (patch) | |
tree | 882cd7cfe0d98b889aa2c16832cfcc70b5b36114 /dbaccess/source/ui/dlg/ConnectionHelper.cxx | |
parent | ee9bee5d4622e3fd2f0d112a15df35565809eb32 (diff) |
Add "New Database" button for Firebird file driver dialog.
Firebird is able to create new databases from within LO hence we need
to add a new property to database configration files.
This allows use of a db creation dialog (which is opened
by using the "New Database" button) in order to allow creating new
dialogs (in addition to being able to open existing databases using
the "Browse" button).
Conflicts:
dbaccess/source/ui/dlg/ConnectionHelper.hxx
Change-Id: I6174f3b7d9032c48286b49b5ddf125cd3b428303
Diffstat (limited to 'dbaccess/source/ui/dlg/ConnectionHelper.cxx')
-rw-r--r-- | dbaccess/source/ui/dlg/ConnectionHelper.cxx | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/dbaccess/source/ui/dlg/ConnectionHelper.cxx b/dbaccess/source/ui/dlg/ConnectionHelper.cxx index 23da1dbbf26b..a0effcb51ceb 100644 --- a/dbaccess/source/ui/dlg/ConnectionHelper.cxx +++ b/dbaccess/source/ui/dlg/ConnectionHelper.cxx @@ -95,6 +95,7 @@ DBG_NAME(OConnectionHelper) ,m_aFT_Connection ( this, ResId( FT_AUTOBROWSEURL, *_rId.GetResMgr() ) ) ,m_aConnectionURL ( this, ResId( ET_AUTOBROWSEURL, *_rId.GetResMgr() ) ) ,m_aPB_Connection ( this, ResId( PB_AUTOBROWSEURL, *_rId.GetResMgr() ) ) + ,m_aPB_CreateDB ( this, ResId( PB_CREATEDB, *_rId.GetResMgr() ) ) { DBG_CTOR(OConnectionHelper,NULL); @@ -103,6 +104,7 @@ DBG_NAME(OConnectionHelper) if (pCollectionItem) m_pCollection = pCollectionItem->getCollection(); m_aPB_Connection.SetClickHdl(LINK(this, OConnectionHelper, OnBrowseConnections)); + m_aPB_CreateDB.SetClickHdl(LINK(this, OConnectionHelper, OnCreateDatabase)); OSL_ENSURE(m_pCollection, "OConnectionHelper::OConnectionHelper : really need a DSN type collection !"); m_aConnectionURL.SetTypeCollection(m_pCollection); } @@ -126,6 +128,9 @@ DBG_NAME(OConnectionHelper) sal_Bool bEnableBrowseButton = m_pCollection->supportsBrowsing( m_eType ); m_aPB_Connection.Show( bEnableBrowseButton ); + sal_Bool bEnableCreateButton = m_pCollection->supportsDBCreation( m_eType ); + m_aPB_CreateDB.Show( bEnableCreateButton ); + SFX_ITEMSET_GET(_rSet, pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True); // forward the values to the controls @@ -308,6 +313,43 @@ DBG_NAME(OConnectionHelper) setURLNoPrefix(aSelector.GetSelected()); break; } + case ::dbaccess::DST_FIREBIRD: + { + const OUString sExt("*.fdb"); + OUString sFilterName(ModuleRes (STR_FIREBIRD_FILTERNAME)); + ::sfx2::FileDialogHelper aFileDlg( + ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, + 0); + aFileDlg.AddFilter(sFilterName,sExt); + aFileDlg.SetCurrentFilter(sFilterName); + askForFileName(aFileDlg); + } + default: + break; + } + + checkTestConnection(); + + return 0L; + } + + IMPL_LINK(OConnectionHelper, OnCreateDatabase, PushButton*, /*_pButton*/) + { + OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF"); + const ::dbaccess::DATASOURCE_TYPE eType = m_pCollection->determineType(m_eType); + switch ( eType ) + { + case ::dbaccess::DST_FIREBIRD: + { + const OUString sExt("*.fdb"); + OUString sFilterName(ModuleRes (STR_FIREBIRD_FILTERNAME)); + ::sfx2::FileDialogHelper aFileDlg( + ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION, + 0); + aFileDlg.AddFilter(sFilterName,sExt); + aFileDlg.SetCurrentFilter(sFilterName); + askForFileName(aFileDlg); + } default: break; } @@ -421,7 +463,8 @@ DBG_NAME(OConnectionHelper) sal_Int32 OConnectionHelper::checkPathExistence(const OUString& _rURL) { IS_PATH_EXIST e_exists = pathExists(_rURL, sal_False); - if (( e_exists == PATH_NOT_EXIST) || ( e_exists == PATH_NOT_KNOWN)) + if (!m_pCollection->supportsDBCreation(m_eType) && + (( e_exists == PATH_NOT_EXIST) || ( e_exists == PATH_NOT_KNOWN))) { OUString sQuery(ModuleRes(STR_ASK_FOR_DIRECTORY_CREATION)); OFileNotation aTransformer(_rURL); @@ -605,6 +648,7 @@ DBG_NAME(OConnectionHelper) { _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFT_Connection)); _rControlList.push_back(new ODisableWrapper<PushButton>(&m_aPB_Connection)); + _rControlList.push_back(new ODisableWrapper<PushButton>(&m_aPB_CreateDB)); } void OConnectionHelper::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) |