dbaccess/source/ui/dlg/ConnectionHelper.cxx | 10 + dbaccess/source/ui/dlg/ConnectionHelper.hxx | 2 dbaccess/source/ui/dlg/ConnectionPageSetup.cxx | 114 ++++++++++++++++++++++ dbaccess/source/ui/dlg/ConnectionPageSetup.hxx | 31 +++++ dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx | 49 ++++----- dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx | 12 +- 6 files changed, 181 insertions(+), 37 deletions(-)
New commits: commit 660cace2a15bd863e0c85d61533cc52e9fa07e27 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Wed Oct 24 13:34:39 2018 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Thu Oct 25 09:53:40 2018 +0200 weld OTextConnectionPageSetup Change-Id: Iaa4fdc97be23ccd50471c26923745fd565e10653 Reviewed-on: https://gerrit.libreoffice.org/62298 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/dbaccess/source/ui/dlg/ConnectionHelper.cxx b/dbaccess/source/ui/dlg/ConnectionHelper.cxx index 7642114af693..000daa908ede 100644 --- a/dbaccess/source/ui/dlg/ConnectionHelper.cxx +++ b/dbaccess/source/ui/dlg/ConnectionHelper.cxx @@ -1315,7 +1315,7 @@ namespace dbaui _rControlList.emplace_back( new OSaveValueWidgetWrapper<DBOConnectionURLEdit>( m_xConnectionURL.get() ) ); } - void DBOConnectionHelper::commitURL() + bool DBOConnectionHelper::commitURL() { OUString sURL; OUString sOldPath; @@ -1344,7 +1344,7 @@ namespace dbaui setURLNoPrefix(sOldPath); SetRoadmapStateValue(false); callModifiedHdl(); - return; + return false; } } else @@ -1355,10 +1355,11 @@ namespace dbaui m_bUserGrabFocus = false; m_xConnectionURL->grab_focus(); m_bUserGrabFocus = true; - return; + return false; + case RET_CANCEL: setURLNoPrefix(sOldPath); - return; + return false; } } } @@ -1366,6 +1367,7 @@ namespace dbaui setURLNoPrefix(sURL); m_xConnectionURL->SaveValueNoPrefix(); + return true; } void DBOConnectionHelper::askForFileName(::sfx2::FileDialogHelper& _aFileOpen) diff --git a/dbaccess/source/ui/dlg/ConnectionHelper.hxx b/dbaccess/source/ui/dlg/ConnectionHelper.hxx index 1aa51976663c..04bca0a082ab 100644 --- a/dbaccess/source/ui/dlg/ConnectionHelper.hxx +++ b/dbaccess/source/ui/dlg/ConnectionHelper.hxx @@ -141,7 +141,7 @@ namespace dbaui IS_PATH_EXIST pathExists(const OUString& _rURL, bool bIsFile) const; bool createDirectoryDeep(const OUString& _rPathNormalized); - void commitURL(); + bool commitURL(); /** opens the FileOpen dialog and asks for a FileName @param _aFileOpen diff --git a/dbaccess/source/ui/dlg/ConnectionPageSetup.cxx b/dbaccess/source/ui/dlg/ConnectionPageSetup.cxx index d9a96fa9b5cd..c98b80289240 100644 --- a/dbaccess/source/ui/dlg/ConnectionPageSetup.cxx +++ b/dbaccess/source/ui/dlg/ConnectionPageSetup.cxx @@ -179,6 +179,120 @@ namespace dbaui SetRoadmapStateValue(checkTestConnection()); callModifiedHdl(); } + + VclPtr<OGenericAdministrationPage> DBOConnectionTabPageSetup::CreateDbaseTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) + { + return VclPtr<OConnectionTabPageSetup>::Create ( pParent, "ConnectionPage", "dbaccess/ui/dbwizconnectionpage.ui", _rAttrSet, STR_DBASE_HELPTEXT, STR_DBASE_HEADERTEXT, STR_DBASE_PATH_OR_FILE ); + } + + VclPtr<OGenericAdministrationPage> DBOConnectionTabPageSetup::CreateMSAccessTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) + { + return VclPtr<OConnectionTabPageSetup>::Create( pParent, "ConnectionPage", "dbaccess/ui/dbwizconnectionpage.ui", _rAttrSet, STR_MSACCESS_HELPTEXT, STR_MSACCESS_HEADERTEXT, STR_MSACCESS_MDB_FILE ); + } + + VclPtr<OGenericAdministrationPage> DBOConnectionTabPageSetup::CreateADOTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) + { + return VclPtr<OConnectionTabPageSetup>::Create( pParent, "ConnectionPage", "dbaccess/ui/dbwizconnectionpage.ui", _rAttrSet, STR_ADO_HELPTEXT, STR_ADO_HEADERTEXT, STR_COMMONURL ); + } + + VclPtr<OGenericAdministrationPage> DBOConnectionTabPageSetup::CreateODBCTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) + { + return VclPtr<OConnectionTabPageSetup>::Create( pParent, "ConnectionPage", "dbaccess/ui/dbwizconnectionpage.ui", _rAttrSet, STR_ODBC_HELPTEXT, STR_ODBC_HEADERTEXT, STR_NAME_OF_ODBC_DATASOURCE ); + } + + VclPtr<OGenericAdministrationPage> DBOConnectionTabPageSetup::CreateUserDefinedTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) + { + return VclPtr<OConnectionTabPageSetup>::Create(pParent, "ConnectionPage", "dbaccess/ui/dbwizconnectionpage.ui", _rAttrSet, nullptr, nullptr, STR_COMMONURL); + } + + DBOConnectionTabPageSetup::DBOConnectionTabPageSetup(TabPageParent pParent, const OUString& _rUIXMLDescription, const OString& _rId, const SfxItemSet& _rCoreAttrs, const char* pHelpTextResId, const char* pHeaderResId, const char* pUrlResId) + : DBOConnectionHelper(pParent, _rUIXMLDescription, _rId, _rCoreAttrs) + , m_xHelpText(m_xBuilder->weld_label("helptext")) + , m_xHeaderText(m_xBuilder->weld_label("header")) + { + + if (pHelpTextResId != nullptr) + { + OUString sHelpText = DBA_RES(pHelpTextResId); + m_xHelpText->set_label(sHelpText); + } + else + m_xHelpText->hide(); + + if (pHeaderResId != nullptr) + m_xHeaderText->set_label(DBA_RES(pHeaderResId)); + + if (pUrlResId != nullptr) + { + OUString sLabelText = DBA_RES(pUrlResId); + m_xFT_Connection->set_label(sLabelText); + } + else + m_xFT_Connection->hide(); + + m_xConnectionURL->connect_changed(LINK(this, DBOConnectionTabPageSetup, OnEditModified)); + + SetRoadmapStateValue(false); + } + + DBOConnectionTabPageSetup::~DBOConnectionTabPageSetup() + { + disposeOnce(); + } + + void DBOConnectionTabPageSetup::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue) + { + m_eType = m_pAdminDialog->getDatasourceType(_rSet); + // special handling for oracle, this can only happen + // if the user enters the same url as used for Oracle and we are on the JDBC path + //! TODO + //if ( ::dbaccess::DST_ORACLE_JDBC == m_eType ) + // m_eType = ::dbaccess::DST_JDBC; + if(m_pCollection->determineType(m_eType) == ::dbaccess::DST_POSTGRES){ + SetRoadmapStateValue(true); + } + + DBOConnectionHelper::implInitControls(_rSet, _bSaveValue); + + //! TODO + //if ( m_eType >= ::dbaccess::DST_USERDEFINE1 ) + //{ + // OUString sDisplayName = m_pCollection->getTypeDisplayName(m_eType); + // FixedText* ppTextControls[] ={&m_aFT_Connection}; + // for (size_t i = 0; i < sizeof(ppTextControls)/sizeof(ppTextControls[0]); ++i) + // { + // ppTextControls[i]->SetText(sDisplayName); + // } + //} + + callModifiedHdl(); + } + + bool DBOConnectionTabPageSetup::commitPage( ::svt::WizardTypes::CommitPageReason /*_eReason*/ ) + { + return commitURL(); + } + + bool DBOConnectionTabPageSetup::FillItemSet(SfxItemSet* _rSet) + { + bool bChangedSomething = false; + fillString(*_rSet,m_xConnectionURL.get(), DSID_CONNECTURL, bChangedSomething); + return bChangedSomething; + } + + bool DBOConnectionTabPageSetup::checkTestConnection() + { + if ( m_pCollection->determineType(m_eType) == ::dbaccess::DST_POSTGRES ) + return true; + return !m_xConnectionURL->get_visible() || !m_xConnectionURL->GetTextNoPrefix().isEmpty(); + } + + IMPL_LINK_NOARG(DBOConnectionTabPageSetup, OnEditModified, weld::Entry&, void) + { + SetRoadmapStateValue(checkTestConnection()); + callModifiedHdl(); + } + } // namespace dbaui /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/ui/dlg/ConnectionPageSetup.hxx b/dbaccess/source/ui/dlg/ConnectionPageSetup.hxx index 515f7f1e8a73..8a5c5fdeb4ca 100644 --- a/dbaccess/source/ui/dlg/ConnectionPageSetup.hxx +++ b/dbaccess/source/ui/dlg/ConnectionPageSetup.hxx @@ -65,6 +65,37 @@ namespace dbaui // nControlFlags is a combination of the CBTP_xxx-constants }; + class DBOConnectionTabPageSetup : public DBOConnectionHelper + { + friend class VclPtr<DBOConnectionTabPageSetup>; + protected: + + std::unique_ptr<weld::Label> m_xHelpText; + std::unique_ptr<weld::Label> m_xHeaderText; + + // called when the test connection button was clicked + DECL_LINK(OnEditModified, weld::Entry&, void); + + public: + virtual ~DBOConnectionTabPageSetup() override; + static VclPtr<OGenericAdministrationPage> CreateDbaseTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ); + static VclPtr<OGenericAdministrationPage> CreateMSAccessTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ); + static VclPtr<OGenericAdministrationPage> CreateADOTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ); + static VclPtr<OGenericAdministrationPage> CreateODBCTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ); + static VclPtr<OGenericAdministrationPage> CreateUserDefinedTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ); + + virtual bool FillItemSet (SfxItemSet* _rCoreAttrs) override; + + virtual void implInitControls(const SfxItemSet& _rSet, bool _bSaveValue) override; + virtual bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason ) override; + + protected: + DBOConnectionTabPageSetup(TabPageParent pParent, const OUString& _rUIXMLDescription, const OString& _rId, const SfxItemSet& _rCoreAttrs, const char* pHelpTextResId, const char* pHeaderResId, const char* pUrlResId); + virtual bool checkTestConnection() override; + // nControlFlags is a combination of the CBTP_xxx-constants + }; + + } // namespace dbaui #endif diff --git a/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx b/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx index b8277d4a88d4..f93b3db9c6e2 100644 --- a/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx +++ b/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx @@ -59,18 +59,19 @@ namespace dbaui { using namespace ::com::sun::star; - VclPtr<OGenericAdministrationPage> OTextConnectionPageSetup::CreateTextTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) + VclPtr<OGenericAdministrationPage> OTextConnectionPageSetup::CreateTextTabPage(TabPageParent pParent, const SfxItemSet& _rAttrSet) { - return VclPtr<OTextConnectionPageSetup>::Create( pParent, _rAttrSet ); + return VclPtr<OTextConnectionPageSetup>::Create(pParent, _rAttrSet); } // OTextConnectionPageSetup - OTextConnectionPageSetup::OTextConnectionPageSetup( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs ) - :OConnectionTabPageSetup(pParent, "DBWizTextPage", "dbaccess/ui/dbwiztextpage.ui", _rCoreAttrs, STR_TEXT_HELPTEXT, STR_TEXT_HEADERTEXT, STR_TEXT_PATH_OR_FILE) + OTextConnectionPageSetup::OTextConnectionPageSetup(TabPageParent pParent, const SfxItemSet& rCoreAttrs) + : DBOConnectionTabPageSetup(pParent, "dbaccess/ui/dbwiztextpage.ui", "DBWizTextPage", + rCoreAttrs, STR_TEXT_HELPTEXT, STR_TEXT_HEADERTEXT, STR_TEXT_PATH_OR_FILE) + , m_xSubContainer(m_xBuilder->weld_widget("TextPageContainer")) + , m_aTextConnectionHelper(m_xSubContainer.get(), TC_EXTENSION | TC_SEPARATORS) { - - m_pTextConnectionHelper = VclPtr<OTextConnectionHelper>::Create( get<VclVBox>("TextPageContainer"), TC_EXTENSION | TC_SEPARATORS ); - m_pTextConnectionHelper->SetClickHandler(LINK( this, OTextConnectionPageSetup, ImplGetExtensionHdl ) ); + m_aTextConnectionHelper.SetClickHandler(LINK( this, OTextConnectionPageSetup, ImplGetExtensionHdl ) ); } OTextConnectionPageSetup::~OTextConnectionPageSetup() @@ -78,53 +79,49 @@ using namespace ::com::sun::star; disposeOnce(); } - void OTextConnectionPageSetup::dispose() - { - m_pTextConnectionHelper.disposeAndClear(); - OConnectionTabPageSetup::dispose(); - } - - IMPL_LINK_NOARG(OTextConnectionPageSetup, ImplGetExtensionHdl, OTextConnectionHelper*, void) + IMPL_LINK_NOARG(OTextConnectionPageSetup, ImplGetExtensionHdl, DBOTextConnectionHelper*, void) { - SetRoadmapStateValue(!m_pTextConnectionHelper->GetExtension().isEmpty() && OConnectionTabPageSetup::checkTestConnection()); + SetRoadmapStateValue(!m_aTextConnectionHelper.GetExtension().isEmpty() && DBOConnectionTabPageSetup::checkTestConnection()); callModifiedHdl(); } bool OTextConnectionPageSetup::checkTestConnection() { - bool bDoEnable = OConnectionTabPageSetup::checkTestConnection(); - bDoEnable = !m_pTextConnectionHelper->GetExtension().isEmpty() && bDoEnable; + bool bDoEnable = DBOConnectionTabPageSetup::checkTestConnection(); + bDoEnable = !m_aTextConnectionHelper.GetExtension().isEmpty() && bDoEnable; return bDoEnable; } void OTextConnectionPageSetup::fillControls(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList) { - OConnectionTabPageSetup::fillControls(_rControlList); - m_pTextConnectionHelper->fillControls(_rControlList); + DBOConnectionTabPageSetup::fillControls(_rControlList); + m_aTextConnectionHelper.fillControls(_rControlList); } + void OTextConnectionPageSetup::fillWindows(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList) { - OConnectionTabPageSetup::fillWindows(_rControlList); - m_pTextConnectionHelper->fillWindows(_rControlList); + DBOConnectionTabPageSetup::fillWindows(_rControlList); + m_aTextConnectionHelper.fillWindows(_rControlList); } + void OTextConnectionPageSetup::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue) { // first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa) bool bValid, bReadonly; getFlags(_rSet, bValid, bReadonly); - OConnectionTabPageSetup::implInitControls( _rSet, _bSaveValue); - m_pTextConnectionHelper->implInitControls(_rSet, bValid); + DBOConnectionTabPageSetup::implInitControls( _rSet, _bSaveValue); + m_aTextConnectionHelper.implInitControls(_rSet, bValid); } bool OTextConnectionPageSetup::FillItemSet( SfxItemSet* _rSet ) { - bool bChangedSomething = OConnectionTabPageSetup::FillItemSet(_rSet); - bChangedSomething = m_pTextConnectionHelper->FillItemSet(*_rSet, bChangedSomething); + bool bChangedSomething = DBOConnectionTabPageSetup::FillItemSet(_rSet); + bChangedSomething = m_aTextConnectionHelper.FillItemSet(*_rSet, bChangedSomething); return bChangedSomething; } bool OTextConnectionPageSetup::prepareLeave(){ - return m_pTextConnectionHelper->prepareLeave(); + return m_aTextConnectionHelper.prepareLeave(); } VclPtr<OGenericAdministrationPage> OLDAPConnectionPageSetup::CreateLDAPTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) diff --git a/dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx b/dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx index b769ccc4ac83..59545c74f096 100644 --- a/dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx +++ b/dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx @@ -53,16 +53,16 @@ namespace dbaui }; // OTextConnectionPage - class OTextConnectionPageSetup : public OConnectionTabPageSetup + class OTextConnectionPageSetup : public DBOConnectionTabPageSetup { public: - VclPtr<OTextConnectionHelper> m_pTextConnectionHelper; + std::unique_ptr<weld::Widget> m_xSubContainer; + DBOTextConnectionHelper m_aTextConnectionHelper; virtual bool FillItemSet ( SfxItemSet* _rCoreAttrs ) override; - static VclPtr<OGenericAdministrationPage> CreateTextTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ); - OTextConnectionPageSetup( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs ); + static VclPtr<OGenericAdministrationPage> CreateTextTabPage(TabPageParent pParent, const SfxItemSet& _rAttrSet ); + OTextConnectionPageSetup(TabPageParent pParent, const SfxItemSet& _rCoreAttrs); virtual ~OTextConnectionPageSetup() override; - virtual void dispose() override; protected: virtual bool prepareLeave() override; virtual void implInitControls(const SfxItemSet& _rSet, bool _bSaveValue) override; @@ -71,7 +71,7 @@ namespace dbaui bool checkTestConnection() override; private: - DECL_LINK(ImplGetExtensionHdl, OTextConnectionHelper*, void); + DECL_LINK(ImplGetExtensionHdl, DBOTextConnectionHelper*, void); }; // OLDAPConnectionPageSetup _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits