From 69fbf74d5bf9c474a6ec04101426dfe79b4ad9bf Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 29 Aug 2019 20:17:53 +0100 Subject: weld addressbook wizard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I118ed34ddaf7d62e5bb15497399cd10533339328 Reviewed-on: https://gerrit.libreoffice.org/78287 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- .../ext/macromigration/macromigrationpages.cxx | 2 +- .../ext/macromigration/macromigrationpages.hxx | 2 +- extensions/source/abpilot/abpfinalpage.cxx | 115 +++++---- extensions/source/abpilot/abpfinalpage.hxx | 35 ++- extensions/source/abpilot/abspage.cxx | 29 +-- extensions/source/abpilot/abspage.hxx | 7 +- extensions/source/abpilot/abspilot.cxx | 92 +++----- extensions/source/abpilot/abspilot.hxx | 10 +- extensions/source/abpilot/admininvokationimpl.cxx | 10 +- extensions/source/abpilot/admininvokationimpl.hxx | 7 +- extensions/source/abpilot/admininvokationpage.cxx | 30 +-- extensions/source/abpilot/admininvokationpage.hxx | 11 +- extensions/source/abpilot/fieldmappingimpl.cxx | 9 +- extensions/source/abpilot/fieldmappingimpl.hxx | 5 +- extensions/source/abpilot/fieldmappingpage.cxx | 33 +-- extensions/source/abpilot/fieldmappingpage.hxx | 16 +- extensions/source/abpilot/tableselectionpage.cxx | 43 ++-- extensions/source/abpilot/tableselectionpage.hxx | 16 +- extensions/source/abpilot/typeselectionpage.cxx | 77 +++--- extensions/source/abpilot/typeselectionpage.hxx | 28 ++- extensions/source/abpilot/unodialogabp.cxx | 7 +- extensions/uiconfig/sabpilot/ui/datasourcepage.ui | 65 ++---- extensions/uiconfig/sabpilot/ui/fieldassignpage.ui | 35 ++- extensions/uiconfig/sabpilot/ui/invokeadminpage.ui | 38 +-- extensions/uiconfig/sabpilot/ui/selecttablepage.ui | 63 +++-- extensions/uiconfig/sabpilot/ui/selecttypepage.ui | 32 +-- include/svtools/inettbc.hxx | 1 + include/svx/databaselocationinput.hxx | 53 ++++- svx/source/form/databaselocationinput.cxx | 259 +++++++++++++++++---- 29 files changed, 638 insertions(+), 492 deletions(-) diff --git a/dbaccess/source/ext/macromigration/macromigrationpages.cxx b/dbaccess/source/ext/macromigration/macromigrationpages.cxx index 3820a688ba1e..6c49497934de 100644 --- a/dbaccess/source/ext/macromigration/macromigrationpages.cxx +++ b/dbaccess/source/ext/macromigration/macromigrationpages.cxx @@ -81,7 +81,7 @@ namespace dbmm get(m_pStartMigration, "startmigrate"); get(m_pBrowseSaveAsLocation, "browse"); get(m_pSaveAsLocation, "location"); - m_pLocationController.reset( new svx::DatabaseLocationInputController( + m_pLocationController.reset( new svx::SvxDatabaseLocationInputController( _rParentDialog.getComponentContext(), *m_pSaveAsLocation, *m_pBrowseSaveAsLocation) ); m_pSaveAsLocation->SetModifyHdl( LINK( this, SaveDBDocPage, OnLocationModified ) ); diff --git a/dbaccess/source/ext/macromigration/macromigrationpages.hxx b/dbaccess/source/ext/macromigration/macromigrationpages.hxx index 171f1d8cad61..f04b41fa6a70 100644 --- a/dbaccess/source/ext/macromigration/macromigrationpages.hxx +++ b/dbaccess/source/ext/macromigration/macromigrationpages.hxx @@ -83,7 +83,7 @@ namespace dbmm VclPtr< ::svt::OFileURLControl> m_pSaveAsLocation; VclPtr m_pBrowseSaveAsLocation; VclPtr m_pStartMigration; - std::unique_ptr m_pLocationController; + std::unique_ptr m_pLocationController; // IWizardPageController overridables virtual void initializePage() override; diff --git a/extensions/source/abpilot/abpfinalpage.cxx b/extensions/source/abpilot/abpfinalpage.cxx index e32374b7ed43..730b669e4062 100644 --- a/extensions/source/abpilot/abpfinalpage.cxx +++ b/extensions/source/abpilot/abpfinalpage.cxx @@ -42,28 +42,30 @@ namespace abp return pFilter; } - FinalPage::FinalPage( OAddressBookSourcePilot* _pParent ) - : AddressBookSourcePage(_pParent, "DataSourcePage", - "modules/sabpilot/ui/datasourcepage.ui") - { - get(m_pLocation, "location"); - get(m_pBrowse, "browse"); - get(m_pRegisterName, "available"); - get(m_pEmbed, "embed"); - get(m_pNameLabel, "nameft"); - get(m_pLocationLabel, "locationft"); - get(m_pName, "name"); - get(m_pDuplicateNameError, "warning"); - m_pLocationController.reset( new svx::DatabaseLocationInputController(_pParent->getORB(), - *m_pLocation, *m_pBrowse) ); - - m_pName->SetModifyHdl( LINK(this, FinalPage, OnNameModified) ); - m_pLocation->SetModifyHdl( LINK(this, FinalPage, OnNameModified) ); - m_pRegisterName->SetClickHdl( LINK( this, FinalPage, OnRegister ) ); - m_pRegisterName->Check(); - m_pEmbed->SetClickHdl( LINK( this, FinalPage, OnEmbed ) ); - m_pEmbed->Check(); - OnEmbed(m_pEmbed); + FinalPage::FinalPage(OAddressBookSourcePilot* pDialog, TabPageParent pPageParent) + : AddressBookSourcePage(pDialog, pPageParent, "modules/sabpilot/ui/datasourcepage.ui", + "DataSourcePage") + , m_xLocation(new URLBox(m_xBuilder->weld_combo_box("location"))) + , m_xBrowse(m_xBuilder->weld_button("browse")) + , m_xRegisterName(m_xBuilder->weld_check_button("available")) + , m_xEmbed(m_xBuilder->weld_check_button("embed")) + , m_xNameLabel(m_xBuilder->weld_label("nameft")) + , m_xLocationLabel(m_xBuilder->weld_label("locationft")) + , m_xName(m_xBuilder->weld_entry("name")) + , m_xDuplicateNameError(m_xBuilder->weld_label("warning")) + { + m_xLocation->SetSmartProtocol(INetProtocol::File); + m_xLocation->DisableHistory(); + + m_xLocationController.reset( new svx::DatabaseLocationInputController(pDialog->getORB(), + *m_xLocation, *m_xBrowse, *pPageParent.GetFrameWeld()) ); + + m_xName->connect_changed( LINK(this, FinalPage, OnEntryNameModified) ); + m_xLocation->connect_changed( LINK(this, FinalPage, OnComboNameModified) ); + m_xRegisterName->connect_clicked( LINK( this, FinalPage, OnRegister ) ); + m_xRegisterName->set_active(true); + m_xEmbed->connect_clicked( LINK( this, FinalPage, OnEmbed ) ); + m_xEmbed->set_active(true); } FinalPage::~FinalPage() @@ -73,21 +75,13 @@ namespace abp void FinalPage::dispose() { - m_pLocationController.reset(); - m_pLocation.clear(); - m_pBrowse.clear(); - m_pRegisterName.clear(); - m_pEmbed.clear(); - m_pNameLabel.clear(); - m_pLocationLabel.clear(); - m_pName.clear(); - m_pDuplicateNameError.clear(); + m_xLocationController.reset(); AddressBookSourcePage::dispose(); } bool FinalPage::isValidName() const { - OUString sCurrentName(m_pName->GetText()); + OUString sCurrentName(m_xName->get_text()); if (sCurrentName.isEmpty()) // the name must not be empty @@ -122,16 +116,16 @@ namespace abp } OSL_ENSURE( aURL.GetProtocol() != INetProtocol::NotValid ,"No valid file name!"); rSettings.sDataSourceName = aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ); - m_pLocationController->setURL( rSettings.sDataSourceName ); + m_xLocationController->setURL( rSettings.sDataSourceName ); OUString sName = aURL.getName( ); sal_Int32 nPos = sName.indexOf(aURL.GetFileExtension()); if ( nPos != -1 ) { sName = sName.replaceAt(nPos-1, 4, ""); } - m_pName->SetText(sName); + m_xName->set_text(sName); - OnRegister(m_pRegisterName); + OnRegister(*m_xRegisterName); } @@ -142,28 +136,26 @@ namespace abp setFields(); } - bool FinalPage::commitPage( ::vcl::WizardTypes::CommitPageReason _eReason ) { if (!AddressBookSourcePage::commitPage(_eReason)) return false; if ( ( ::vcl::WizardTypes::eTravelBackward != _eReason ) - && ( !m_pLocationController->prepareCommit() ) + && ( !m_xLocationController->prepareCommit() ) ) return false; AddressSettings& rSettings = getSettings(); - rSettings.sDataSourceName = m_pLocationController->getURL(); - rSettings.bRegisterDataSource = m_pRegisterName->IsChecked(); + rSettings.sDataSourceName = m_xLocationController->getURL(); + rSettings.bRegisterDataSource = m_xRegisterName->get_active(); if ( rSettings.bRegisterDataSource ) - rSettings.sRegisteredDataSourceName = m_pName->GetText(); - rSettings.bEmbedDataSource = m_pEmbed->IsChecked(); + rSettings.sRegisteredDataSourceName = m_xName->get_text(); + rSettings.bEmbedDataSource = m_xEmbed->get_active(); return true; } - void FinalPage::ActivatePage() { AddressBookSourcePage::ActivatePage(); @@ -173,12 +165,13 @@ namespace abp aContext.getDataSourceNames( m_aInvalidDataSourceNames ); // give the name edit the focus - m_pLocation->GrabFocus(); + m_xLocation->grab_focus(); // default the finish button getDialog()->defaultButton( WizardButtonFlags::FINISH ); - } + OnEmbed(*m_xEmbed); + } void FinalPage::DeactivatePage() { @@ -196,41 +189,43 @@ namespace abp return false; } - void FinalPage::implCheckName() { bool bValidName = isValidName(); - bool bEmptyName = m_pName->GetText().isEmpty(); - bool bEmptyLocation = m_pLocation->GetText().isEmpty(); + bool bEmptyName = m_xName->get_text().isEmpty(); + bool bEmptyLocation = m_xLocation->get_active_text().isEmpty(); // enable or disable the finish button - getDialog()->enableButtons( WizardButtonFlags::FINISH, !bEmptyLocation && (!m_pRegisterName->IsChecked() || bValidName) ); + getDialog()->enableButtons( WizardButtonFlags::FINISH, !bEmptyLocation && (!m_xRegisterName->get_active() || bValidName) ); // show the error message for an invalid name - m_pDuplicateNameError->Show( !bValidName && !bEmptyName ); + m_xDuplicateNameError->set_visible(!bValidName && !bEmptyName); } - - IMPL_LINK_NOARG( FinalPage, OnNameModified, Edit&, void ) + IMPL_LINK_NOARG( FinalPage, OnEntryNameModified, weld::Entry&, void ) { implCheckName(); } + IMPL_LINK_NOARG( FinalPage, OnComboNameModified, weld::ComboBox&, void ) + { + implCheckName(); + } - IMPL_LINK_NOARG(FinalPage, OnRegister, Button*, void) + IMPL_LINK_NOARG(FinalPage, OnRegister, weld::Button&, void) { - bool bEnable = m_pRegisterName->IsChecked(); - m_pNameLabel->Enable(bEnable); - m_pName->Enable(bEnable); + bool bEnable = m_xRegisterName->get_active(); + m_xNameLabel->set_sensitive(bEnable); + m_xName->set_sensitive(bEnable); implCheckName(); } - IMPL_LINK_NOARG(FinalPage, OnEmbed, Button*, void) + IMPL_LINK_NOARG(FinalPage, OnEmbed, weld::Button&, void) { - bool bEmbed = m_pEmbed->IsChecked(); - m_pLocationLabel->Enable(!bEmbed); - m_pLocation->Enable(!bEmbed); - m_pBrowse->Enable(!bEmbed); + bool bEmbed = m_xEmbed->get_active(); + m_xLocationLabel->set_sensitive(!bEmbed); + m_xLocation->set_sensitive(!bEmbed); + m_xBrowse->set_sensitive(!bEmbed); } } // namespace abp diff --git a/extensions/source/abpilot/abpfinalpage.hxx b/extensions/source/abpilot/abpfinalpage.hxx index 719d894be872..c44f6659e3ca 100644 --- a/extensions/source/abpilot/abpfinalpage.hxx +++ b/extensions/source/abpilot/abpfinalpage.hxx @@ -34,22 +34,22 @@ namespace abp class FinalPage final : public AddressBookSourcePage { - VclPtr< ::svt::OFileURLControl> m_pLocation; - VclPtr m_pBrowse; - VclPtr m_pRegisterName; - VclPtr m_pEmbed; - VclPtr m_pNameLabel; - VclPtr m_pLocationLabel; - VclPtr m_pName; - VclPtr m_pDuplicateNameError; + std::unique_ptr m_xLocation; + std::unique_ptr m_xBrowse; + std::unique_ptr m_xRegisterName; + std::unique_ptr m_xEmbed; + std::unique_ptr m_xNameLabel; + std::unique_ptr m_xLocationLabel; + std::unique_ptr m_xName; + std::unique_ptr m_xDuplicateNameError; std::unique_ptr - m_pLocationController; + m_xLocationController; StringBag m_aInvalidDataSourceNames; public: - explicit FinalPage(OAddressBookSourcePilot* _pParent); + explicit FinalPage(OAddressBookSourcePilot* pDialog, TabPageParent pPageParent); virtual ~FinalPage() override; virtual void dispose() override; @@ -65,19 +65,18 @@ namespace abp // OImportPage overridables virtual bool canAdvance() const override; - DECL_LINK( OnNameModified, Edit&, void ); - DECL_LINK(OnRegister, Button*, void); - DECL_LINK(OnEmbed, Button*, void); + DECL_LINK(OnEntryNameModified, weld::Entry&, void); + DECL_LINK(OnComboNameModified, weld::ComboBox&, void); + DECL_LINK(OnRegister, weld::Button&, void); + DECL_LINK(OnEmbed, weld::Button&, void); - bool isValidName() const; - void implCheckName(); - void setFields(); + bool isValidName() const; + void implCheckName(); + void setFields(); }; - } // namespace abp - #endif // INCLUDED_EXTENSIONS_SOURCE_ABPILOT_ABPFINALPAGE_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/abpilot/abspage.cxx b/extensions/source/abpilot/abspage.cxx index b62d13f52b17..33770402a664 100644 --- a/extensions/source/abpilot/abspage.cxx +++ b/extensions/source/abpilot/abspage.cxx @@ -29,48 +29,49 @@ namespace abp using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; - AddressBookSourcePage::AddressBookSourcePage(OAddressBookSourcePilot* _pParent, const OString& rID, const OUString& rUIXMLDescription) - :AddressBookSourcePage_Base(_pParent, rID, rUIXMLDescription) + AddressBookSourcePage::AddressBookSourcePage(OAddressBookSourcePilot* pParent, TabPageParent pPageParent, const OUString& rUIXMLDescription, const OString& rID) + : AddressBookSourcePage_Base(pPageParent, rUIXMLDescription, rID) + , m_pDialog(pParent) { } + void AddressBookSourcePage::ActivatePage() + { + AddressBookSourcePage_Base::ActivatePage(); + m_pDialog->updateTravelUI(); + } + void AddressBookSourcePage::DeactivatePage() { AddressBookSourcePage_Base::DeactivatePage(); - getDialog()->enableButtons(WizardButtonFlags::NEXT, true); + m_pDialog->enableButtons(WizardButtonFlags::NEXT, true); } - OAddressBookSourcePilot* AddressBookSourcePage::getDialog() { - return static_cast(GetParent()); + return m_pDialog; } - const OAddressBookSourcePilot* AddressBookSourcePage::getDialog() const { - return static_cast(GetParent()); + return m_pDialog; } - AddressSettings& AddressBookSourcePage::getSettings() { - return getDialog()->getSettings(); + return m_pDialog->getSettings(); } - const AddressSettings& AddressBookSourcePage::getSettings() const { - return getDialog()->getSettings(); + return m_pDialog->getSettings(); } - const Reference< XComponentContext > & AddressBookSourcePage::getORB() { - return getDialog()->getORB(); + return m_pDialog->getORB(); } - } // namespace abp diff --git a/extensions/source/abpilot/abspage.hxx b/extensions/source/abpilot/abspage.hxx index 257e9735b858..89f50fbd2112 100644 --- a/extensions/source/abpilot/abspage.hxx +++ b/extensions/source/abpilot/abspage.hxx @@ -38,19 +38,22 @@ namespace abp /// the base class for all tab pages in the address book source wizard class AddressBookSourcePage : public AddressBookSourcePage_Base { + OAddressBookSourcePilot* m_pDialog; + protected: - AddressBookSourcePage(OAddressBookSourcePilot *pParent, const OString& rID, const OUString& rUIXMLDescription); + AddressBookSourcePage(OAddressBookSourcePilot *pParent, TabPageParent pPageParent, const OUString& rUIXMLDescription, const OString& rID); protected: // helper OAddressBookSourcePilot* getDialog(); - const OAddressBookSourcePilot* getDialog() const; + const OAddressBookSourcePilot* getDialog() const; const css::uno::Reference< css::uno::XComponentContext > & getORB(); AddressSettings& getSettings(); const AddressSettings& getSettings() const; // TabDialog overridables + virtual void ActivatePage() override; virtual void DeactivatePage() override; }; diff --git a/extensions/source/abpilot/abspilot.cxx b/extensions/source/abpilot/abspilot.cxx index faf99e5184da..e7d929a8dd98 100644 --- a/extensions/source/abpilot/abspilot.cxx +++ b/extensions/source/abpilot/abspilot.cxx @@ -50,21 +50,16 @@ namespace abp #define PATH_NO_FIELDS 3 #define PATH_NO_SETTINGS_NO_FIELDS 4 -#define WINDOW_SIZE_X 240 -#define WINDOW_SIZE_Y 185 - using namespace ::svt; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; - OAddressBookSourcePilot::OAddressBookSourcePilot(vcl::Window* _pParent, const Reference< XComponentContext >& _rxORB) + OAddressBookSourcePilot::OAddressBookSourcePilot(weld::Window* _pParent, const Reference< XComponentContext >& _rxORB) :OAddressBookSourcePilot_Base( _pParent ) ,m_xORB(_rxORB) ,m_aNewDataSource(_rxORB) ,m_eNewDataSourceType( AST_INVALID ) { - SetPageSizePixel(LogicToPixel(Size(WINDOW_SIZE_X, WINDOW_SIZE_Y), MapMode(MapUnit::MapAppFont))); - declarePath( PATH_COMPLETE, {STATE_SELECT_ABTYPE, STATE_INVOKE_ADMIN_DIALOG, @@ -90,13 +85,11 @@ namespace abp STATE_FINAL_CONFIRM} ); - m_pPrevPage->SetHelpId(HID_ABSPILOT_PREVIOUS); - m_pNextPage->SetHelpId(HID_ABSPILOT_NEXT); - m_pCancel->SetHelpId(HID_ABSPILOT_CANCEL); - m_pFinish->SetHelpId(HID_ABSPILOT_FINISH); - m_pHelp->SetHelpId(UID_ABSPILOT_HELP); - - m_pCancel->SetClickHdl( LINK( this, OAddressBookSourcePilot, OnCancelClicked) ); + m_xPrevPage->set_help_id(HID_ABSPILOT_PREVIOUS); + m_xNextPage->set_help_id(HID_ABSPILOT_NEXT); + m_xCancel->set_help_id(HID_ABSPILOT_CANCEL); + m_xFinish->set_help_id(HID_ABSPILOT_FINISH); + m_xHelp->set_help_id(UID_ABSPILOT_HELP); // some initial settings #ifdef UNX @@ -117,12 +110,13 @@ namespace abp defaultButton(WizardButtonFlags::NEXT); enableButtons(WizardButtonFlags::FINISH, false); ActivatePage(); + m_xAssistant->set_current_page(0); typeSelectionChanged( m_aSettings.eType ); OUString sDialogTitle = compmodule::ModuleRes(RID_STR_ABSOURCEDIALOGTITLE); setTitleBase(sDialogTitle); - SetHelpId(HID_ABSPILOT); + m_xAssistant->set_help_id(HID_ABSPILOT); } OUString OAddressBookSourcePilot::getStateDisplayName( WizardState _nState ) const @@ -147,7 +141,6 @@ namespace abp return sDisplayName; } - void OAddressBookSourcePilot::implCommitAll() { // in real, the data source already exists in the data source context @@ -169,34 +162,21 @@ namespace abp fieldmapping::writeTemplateAddressFieldMapping( getORB(), m_aSettings.aFieldMapping ); } - void OAddressBookSourcePilot::implCleanup() { if ( m_aNewDataSource.isValid() ) m_aNewDataSource.remove(); } - - IMPL_LINK_NOARG( OAddressBookSourcePilot, OnCancelClicked, Button*, void ) + short OAddressBookSourcePilot::run() { - // do cleanups - implCleanup(); - - // reset the click hdl - m_pCancel->SetClickHdl( Link() ); - // simulate the click again - this time, the default handling of the button will strike .... - m_pCancel->Click(); - } + short nRet = OAddressBookSourcePilot_Base::run(); - - bool OAddressBookSourcePilot::Close() - { implCleanup(); - return OAddressBookSourcePilot_Base::Close(); + return nRet; } - bool OAddressBookSourcePilot::onFinish() { if ( !OAddressBookSourcePilot_Base::onFinish() ) @@ -209,7 +189,6 @@ namespace abp return true; } - void OAddressBookSourcePilot::enterState( WizardState _nState ) { switch ( _nState ) @@ -264,7 +243,7 @@ namespace abp if ( aTables.empty() ) { - std::unique_ptr xBox(Application::CreateMessageDialog(GetFrameWeld(), + std::unique_ptr xBox(Application::CreateMessageDialog(m_xAssistant.get(), VclMessageType::Question, VclButtonsType::YesNo, compmodule::ModuleRes(getSettings().eType == AST_EVOLUTION_GROUPWISE ? RID_STR_QRY_NO_EVO_GW : RID_STR_QRY_NOTABLES))); @@ -289,7 +268,6 @@ namespace abp return bAllow; } - void OAddressBookSourcePilot::implDefaultTableName() { const StringBag& rTableNames = getDataSource().getTableNames(); @@ -314,7 +292,6 @@ namespace abp getSettings().sSelectedTable = sGuess; } - void OAddressBookSourcePilot::implDoAutoFieldMapping() { DBG_ASSERT( !needManualFieldMapping( ), "OAddressBookSourcePilot::implDoAutoFieldMapping: invalid call!" ); @@ -322,7 +299,6 @@ namespace abp fieldmapping::defaultMapping( getORB(), m_aSettings.aFieldMapping ); } - void OAddressBookSourcePilot::implCreateDataSource() { if (m_aNewDataSource.isValid()) @@ -379,44 +355,52 @@ namespace abp m_eNewDataSourceType = m_aSettings.eType; } - bool OAddressBookSourcePilot::connectToDataSource( bool _bForceReConnect ) { DBG_ASSERT( m_aNewDataSource.isValid(), "OAddressBookSourcePilot::implConnect: invalid current data source!" ); - WaitObject aWaitCursor( this ); + weld::WaitObject aWaitCursor(m_xAssistant.get()); if ( _bForceReConnect && m_aNewDataSource.isConnected( ) ) m_aNewDataSource.disconnect( ); - return m_aNewDataSource.connect(GetFrameWeld()); + return m_aNewDataSource.connect(m_xAssistant.get()); } - VclPtr OAddressBookSourcePilot::createPage(WizardState _nState) { + OString sIdent(OString::number(_nState)); + weld::Container* pPageContainer = m_xAssistant->append_page(sIdent); + // TODO eventually pass DialogController as distinct argument instead of bundling into TabPageParent + TabPageParent aParent(pPageContainer, this); + + VclPtr pRet; + switch (_nState) { case STATE_SELECT_ABTYPE: - return VclPtr::Create( this ); - + pRet = VclPtr::Create( this, aParent ); + break; case STATE_INVOKE_ADMIN_DIALOG: - return VclPtr::Create( this ); - + pRet = VclPtr::Create( this, aParent ); + break; case STATE_TABLE_SELECTION: - return VclPtr::Create( this ); - + pRet = VclPtr::Create( this, aParent ); + break; case STATE_MANUAL_FIELD_MAPPING: - return VclPtr::Create( this ); - + pRet = VclPtr::Create( this, aParent ); + break; case STATE_FINAL_CONFIRM: - return VclPtr::Create( this ); - + pRet = VclPtr::Create( this, aParent ); + break; default: - OSL_FAIL("OAddressBookSourcePilot::createPage: invalid state!"); - return nullptr; + assert(false && "OAddressBookSourcePilot::createPage: invalid state!"); + break; } - } + m_xAssistant->set_page_title(sIdent, getStateDisplayName(_nState)); + + return pRet; + } void OAddressBookSourcePilot::impl_updateRoadmap( AddressSourceType _eType ) { @@ -446,7 +430,6 @@ namespace abp ); } - void OAddressBookSourcePilot::typeSelectionChanged( AddressSourceType _eType ) { PathId nCurrentPathID( PATH_COMPLETE ); @@ -469,7 +452,6 @@ namespace abp impl_updateRoadmap( _eType ); } - } // namespace abp diff --git a/extensions/source/abpilot/abspilot.hxx b/extensions/source/abpilot/abspilot.hxx index a161181e2518..2ad80c3cdc77 100644 --- a/extensions/source/abpilot/abspilot.hxx +++ b/extensions/source/abpilot/abspilot.hxx @@ -29,7 +29,7 @@ namespace abp { - typedef ::vcl::RoadmapWizard OAddressBookSourcePilot_Base; + typedef ::vcl::RoadmapWizardMachine OAddressBookSourcePilot_Base; class OAddressBookSourcePilot final : public OAddressBookSourcePilot_Base { css::uno::Reference< css::uno::XComponentContext > @@ -42,9 +42,11 @@ namespace abp public: /// ctor OAddressBookSourcePilot( - vcl::Window* _pParent, + weld::Window* _pParent, const css::uno::Reference< css::uno::XComponentContext >& _rxORB); + virtual short run() override; + /// get the service factory which was used to create the dialog const css::uno::Reference< css::uno::XComponentContext >& getORB() { return m_xORB; } @@ -70,10 +72,6 @@ namespace abp // RoadmapWizard virtual OUString getStateDisplayName( WizardState _nState ) const override; - virtual bool Close() override; - - DECL_LINK( OnCancelClicked, Button*, void ); - /** creates a new data source of the type indicated by m_aSettings

If another data source has been created before, this one is deleted.

*/ diff --git a/extensions/source/abpilot/admininvokationimpl.cxx b/extensions/source/abpilot/admininvokationimpl.cxx index 4795c05e6b95..6243acce482a 100644 --- a/extensions/source/abpilot/admininvokationimpl.cxx +++ b/extensions/source/abpilot/admininvokationimpl.cxx @@ -45,8 +45,8 @@ namespace abp using namespace ::com::sun::star::sdbc; OAdminDialogInvokation::OAdminDialogInvokation(const Reference< XComponentContext >& _rxContext, - const css::uno::Reference< css::beans::XPropertySet >& _rxDataSource - , vcl::Window* _pMessageParent) + const css::uno::Reference< css::beans::XPropertySet >& _rxDataSource, + weld::Window* _pMessageParent) :m_xContext(_rxContext) ,m_xDataSource(_rxDataSource) ,m_pMessageParent(_pMessageParent) @@ -71,7 +71,7 @@ namespace abp // the parameters for the call Sequence aArguments(comphelper::InitAnyPropertySequence( { - {"ParentWindow", Any(VCLUnoHelper::GetInterface(m_pMessageParent))}, + {"ParentWindow", Any(m_pMessageParent->GetXWindow())}, {"Title", Any(compmodule::ModuleRes(RID_STR_ADMINDIALOGTITLE))}, {"InitialSelection", Any(m_xDataSource)}, // the name of the new data source })); @@ -82,7 +82,7 @@ namespace abp { // creating the dialog service is potentially expensive (if all the libraries invoked need to be loaded) // so we display a wait cursor - WaitObject aWaitCursor(m_pMessageParent); + weld::WaitObject aWaitCursor(m_pMessageParent); Reference x = m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext(s_sDataSourceTypeChangeDialog, aArguments, m_xContext); xDialog.set( x, UNO_QUERY ); @@ -103,7 +103,7 @@ namespace abp return true; } else - ShowServiceNotAvailableError(m_pMessageParent->GetFrameWeld(), s_sAdministrationServiceName, true); + ShowServiceNotAvailableError(m_pMessageParent, s_sAdministrationServiceName, true); } catch(const Exception&) { diff --git a/extensions/source/abpilot/admininvokationimpl.hxx b/extensions/source/abpilot/admininvokationimpl.hxx index e0124a6ba4df..fb7642ded503 100644 --- a/extensions/source/abpilot/admininvokationimpl.hxx +++ b/extensions/source/abpilot/admininvokationimpl.hxx @@ -22,9 +22,8 @@ #include #include -#include -namespace vcl { class Window; } +namespace weld { class Window; } namespace abp { @@ -37,13 +36,13 @@ namespace abp css::uno::Reference< css::uno::XComponentContext > m_xContext; css::uno::Reference< css::beans::XPropertySet > m_xDataSource; - VclPtr m_pMessageParent; + weld::Window* m_pMessageParent; public: OAdminDialogInvokation( const css::uno::Reference< css::uno::XComponentContext >& _rxContext, const css::uno::Reference< css::beans::XPropertySet >& _rDataSource, - vcl::Window* _pMessageParent + weld::Window* _pMessageParent ); bool invokeAdministration(); diff --git a/extensions/source/abpilot/admininvokationpage.cxx b/extensions/source/abpilot/admininvokationpage.cxx index 4cd97989a108..5658677ef63d 100644 --- a/extensions/source/abpilot/admininvokationpage.cxx +++ b/extensions/source/abpilot/admininvokationpage.cxx @@ -23,40 +23,34 @@ namespace abp { - AdminDialogInvokationPage::AdminDialogInvokationPage( OAddressBookSourcePilot* _pParent ) - : AddressBookSourcePage(_pParent, "InvokeAdminPage", - "modules/sabpilot/ui/invokeadminpage.ui") + AdminDialogInvokationPage::AdminDialogInvokationPage(OAddressBookSourcePilot* pDialog, TabPageParent pPageParent) + : AddressBookSourcePage(pDialog, pPageParent, "modules/sabpilot/ui/invokeadminpage.ui", "InvokeAdminPage") + , m_xInvokeAdminDialog(m_xBuilder->weld_button("settings")) + , m_xErrorMessage(m_xBuilder->weld_label("warning")) { - get(m_pInvokeAdminDialog, "settings"); - get(m_pErrorMessage, "warning"); - m_pInvokeAdminDialog->SetClickHdl( LINK(this, AdminDialogInvokationPage, OnInvokeAdminDialog) ); + m_xInvokeAdminDialog->connect_clicked(LINK(this, AdminDialogInvokationPage, OnInvokeAdminDialog)); } + AdminDialogInvokationPage::~AdminDialogInvokationPage() { - disposeOnce(); - } - void AdminDialogInvokationPage::dispose() - { - m_pInvokeAdminDialog.clear(); - m_pErrorMessage.clear(); - AddressBookSourcePage::dispose(); } + void AdminDialogInvokationPage::ActivatePage() { AddressBookSourcePage::ActivatePage(); - m_pInvokeAdminDialog->GrabFocus(); + m_xInvokeAdminDialog->grab_focus(); } void AdminDialogInvokationPage::implUpdateErrorMessage() { const bool bIsConnected = getDialog()->getDataSource().isConnected(); - m_pErrorMessage->Show( !bIsConnected ); + m_xErrorMessage->set_visible( !bIsConnected ); } void AdminDialogInvokationPage::initializePage() { AddressBookSourcePage::initializePage(); - m_pErrorMessage->Hide(); + m_xErrorMessage->hide(); // if we're entering this page, we assume we had no connection trial with this data source } @@ -81,9 +75,9 @@ namespace abp } // davido: Do we need it? - IMPL_LINK_NOARG( AdminDialogInvokationPage, OnInvokeAdminDialog, Button*, void ) + IMPL_LINK_NOARG(AdminDialogInvokationPage, OnInvokeAdminDialog, weld::Button&, void) { - OAdminDialogInvokation aInvokation( getORB(), getDialog()->getDataSource().getDataSource(), getDialog() ); + OAdminDialogInvokation aInvokation(getORB(), getDialog()->getDataSource().getDataSource(), getDialog()->getDialog()); if ( aInvokation.invokeAdministration() ) { // try to connect to this data source diff --git a/extensions/source/abpilot/admininvokationpage.hxx b/extensions/source/abpilot/admininvokationpage.hxx index 22e8ac21cdb0..c29b3dad75a2 100644 --- a/extensions/source/abpilot/admininvokationpage.hxx +++ b/extensions/source/abpilot/admininvokationpage.hxx @@ -27,13 +27,12 @@ namespace abp { class AdminDialogInvokationPage final : public AddressBookSourcePage { - VclPtr m_pInvokeAdminDialog; - VclPtr m_pErrorMessage; + std::unique_ptr m_xInvokeAdminDialog; + std::unique_ptr m_xErrorMessage; public: - explicit AdminDialogInvokationPage(OAddressBookSourcePilot* _pParent); + explicit AdminDialogInvokationPage(OAddressBookSourcePilot* pDialog, TabPageParent pPageParent); virtual ~AdminDialogInvokationPage() override; - virtual void dispose() override; private: // TabDialog overridables virtual void ActivatePage() override; @@ -42,16 +41,14 @@ namespace abp // OImportPage overridables virtual bool canAdvance() const override; - DECL_LINK( OnInvokeAdminDialog, Button*, void ); + DECL_LINK( OnInvokeAdminDialog, weld::Button&, void ); void implTryConnect(); void implUpdateErrorMessage(); }; - } // namespace abp - #endif // INCLUDED_EXTENSIONS_SOURCE_ABPILOT_ADMININVOKATIONPAGE_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/abpilot/fieldmappingimpl.cxx b/extensions/source/abpilot/fieldmappingimpl.cxx index d1ed34353752..dc81dee64764 100644 --- a/extensions/source/abpilot/fieldmappingimpl.cxx +++ b/extensions/source/abpilot/fieldmappingimpl.cxx @@ -26,8 +26,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -55,12 +55,9 @@ namespace abp static const char sDriverSettingsNodeName[] = "/org.openoffice.Office.DataAccess/DriverSettings/com.sun.star.comp.sdbc.MozabDriver"; static const char sAddressBookNodeName[] = "/org.openoffice.Office.DataAccess/AddressBook"; - namespace fieldmapping { - - - bool invokeDialog( const Reference< XComponentContext >& _rxORB, class vcl::Window* _pParent, + bool invokeDialog( const Reference< XComponentContext >& _rxORB, class weld::Window* _pParent, const Reference< XPropertySet >& _rxDataSource, AddressSettings& _rSettings ) { _rSettings.aFieldMapping.clear(); @@ -74,7 +71,7 @@ namespace abp { // create an instance of the dialog service - Reference< XWindow > xDialogParent = VCLUnoHelper::GetInterface( _pParent ); + Reference< XWindow > xDialogParent = _pParent->GetXWindow(); OUString sTitle(compmodule::ModuleRes(RID_STR_FIELDDIALOGTITLE)); Reference< XExecutableDialog > xDialog = AddressBookSourceDialog::createWithDataSource(_rxORB, // the parent window diff --git a/extensions/source/abpilot/fieldmappingimpl.hxx b/extensions/source/abpilot/fieldmappingimpl.hxx index 3cbe2919bb3a..4d0b26e9c166 100644 --- a/extensions/source/abpilot/fieldmappingimpl.hxx +++ b/extensions/source/abpilot/fieldmappingimpl.hxx @@ -36,8 +36,7 @@ namespace com { namespace sun { namespace star { class XPropertySet; } } } } -namespace vcl { class Window; } - +namespace weld { class Window; } namespace abp { @@ -59,7 +58,7 @@ namespace abp */ bool invokeDialog( const css::uno::Reference< css::uno::XComponentContext >& _rxORB, - class vcl::Window* _pParent, + class weld::Window* _pParent, const css::uno::Reference< css::beans::XPropertySet >& _rxDataSource, AddressSettings& _rSettings ); diff --git a/extensions/source/abpilot/fieldmappingpage.cxx b/extensions/source/abpilot/fieldmappingpage.cxx index d0962e8f85c0..93a2ca733bda 100644 --- a/extensions/source/abpilot/fieldmappingpage.cxx +++ b/extensions/source/abpilot/fieldmappingpage.cxx @@ -25,58 +25,45 @@ namespace abp { - FieldMappingPage::FieldMappingPage( OAddressBookSourcePilot* _pParent ) - : AddressBookSourcePage(_pParent, "FieldAssignPage", - "modules/sabpilot/ui/fieldassignpage.ui") + FieldMappingPage::FieldMappingPage(OAddressBookSourcePilot* pDialog, TabPageParent pPageParent) + : AddressBookSourcePage(pDialog, pPageParent, "modules/sabpilot/ui/fieldassignpage.ui", "FieldAssignPage") + , m_xInvokeDialog(m_xBuilder->weld_button("assign")) + , m_xHint(m_xBuilder->weld_label("hint")) { - get(m_pInvokeDialog, "assign"); - get(m_pHint, "hint"); - - m_pInvokeDialog->SetClickHdl( LINK( this, FieldMappingPage, OnInvokeDialog ) ); + m_xInvokeDialog->connect_clicked(LINK(this, FieldMappingPage, OnInvokeDialog)); } FieldMappingPage::~FieldMappingPage() { - disposeOnce(); - } - - void FieldMappingPage::dispose() - { - m_pInvokeDialog.clear(); - m_pHint.clear(); - AddressBookSourcePage::dispose(); } void FieldMappingPage::ActivatePage() { AddressBookSourcePage::ActivatePage(); - m_pInvokeDialog->GrabFocus(); + m_xInvokeDialog->grab_focus(); } - void FieldMappingPage::initializePage() { AddressBookSourcePage::initializePage(); implUpdateHint(); } - void FieldMappingPage::implUpdateHint() { const AddressSettings& rSettings = getSettings(); OUString sHint; if ( rSettings.aFieldMapping.empty() ) sHint = compmodule::ModuleRes(RID_STR_NOFIELDSASSIGNED); - m_pHint->SetText( sHint ); + m_xHint->set_label(sHint); } - - IMPL_LINK_NOARG( FieldMappingPage, OnInvokeDialog, Button*, void ) + IMPL_LINK_NOARG( FieldMappingPage, OnInvokeDialog, weld::Button&, void ) { AddressSettings& rSettings = getSettings(); // invoke the dialog doing the mapping - if ( fieldmapping::invokeDialog( getORB(), this, getDialog()->getDataSource().getDataSource(), rSettings ) ) + if ( fieldmapping::invokeDialog( getORB(), getDialog()->getDialog(), getDialog()->getDataSource().getDataSource(), rSettings ) ) { if ( !rSettings.aFieldMapping.empty() ) getDialog()->travelNext(); @@ -85,8 +72,6 @@ namespace abp } } - } // namespace abp - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/abpilot/fieldmappingpage.hxx b/extensions/source/abpilot/fieldmappingpage.hxx index 8623b6d21220..8aaebbefbfee 100644 --- a/extensions/source/abpilot/fieldmappingpage.hxx +++ b/extensions/source/abpilot/fieldmappingpage.hxx @@ -21,21 +21,17 @@ #define INCLUDED_EXTENSIONS_SOURCE_ABPILOT_FIELDMAPPINGPAGE_HXX #include "abspage.hxx" -#include - +#include namespace abp { - class FieldMappingPage final : public AddressBookSourcePage { - VclPtr m_pInvokeDialog; - VclPtr m_pHint; - + std::unique_ptr m_xInvokeDialog; + std::unique_ptr m_xHint; public: - explicit FieldMappingPage(OAddressBookSourcePilot* _pParent); + explicit FieldMappingPage(OAddressBookSourcePilot* pDialog, TabPageParent pPageParent); virtual ~FieldMappingPage() override; - virtual void dispose() override; private: // OWizardPage overridables virtual void initializePage() override; @@ -43,12 +39,10 @@ namespace abp // TabDialog overridables virtual void ActivatePage() override; - DECL_LINK( OnInvokeDialog, Button*, void ); + DECL_LINK(OnInvokeDialog, weld::Button&, void); void implUpdateHint(); }; - - } // namespace abp diff --git a/extensions/source/abpilot/tableselectionpage.cxx b/extensions/source/abpilot/tableselectionpage.cxx index 7e68a65e88e9..3d56a33fb8bf 100644 --- a/extensions/source/abpilot/tableselectionpage.cxx +++ b/extensions/source/abpilot/tableselectionpage.cxx @@ -27,41 +27,32 @@ namespace abp { - TableSelectionPage::TableSelectionPage( OAddressBookSourcePilot* _pParent ) - :AddressBookSourcePage(_pParent, "SelectTablePage", - "modules/sabpilot/ui/selecttablepage.ui") + TableSelectionPage::TableSelectionPage(OAddressBookSourcePilot* pDialog, TabPageParent pPageParent) + : AddressBookSourcePage(pDialog, pPageParent, "modules/sabpilot/ui/selecttablepage.ui", "SelectTablePage") + , m_xTableList(m_xBuilder->weld_tree_view("table")) { - get(m_pTableList, "table"); - m_pTableList->SetSelectHdl( LINK( this, TableSelectionPage, OnTableSelected ) ); - m_pTableList->SetDoubleClickHdl( LINK( this, TableSelectionPage, OnTableDoubleClicked ) ); + m_xTableList->connect_changed( LINK( this, TableSelectionPage, OnTableSelected ) ); + m_xTableList->connect_row_activated( LINK( this, TableSelectionPage, OnTableDoubleClicked ) ); } TableSelectionPage::~TableSelectionPage() { - disposeOnce(); - } - - void TableSelectionPage::dispose() - { - m_pTableList.clear(); - AddressBookSourcePage::dispose(); } void TableSelectionPage::ActivatePage() { AddressBookSourcePage::ActivatePage(); - m_pTableList->GrabFocus(); + m_xTableList->grab_focus(); } - void TableSelectionPage::initializePage() { AddressBookSourcePage::initializePage(); const AddressSettings& rSettings = getSettings(); - m_pTableList->Clear(); + m_xTableList->clear(); // get the table names const StringBag& aTableNames = getDialog()->getDataSource().getTableNames(); @@ -70,46 +61,40 @@ namespace abp // fill the list for (auto const& tableName : aTableNames) - m_pTableList->InsertEntry(tableName); + m_xTableList->append_text(tableName); // initially select the proper table - m_pTableList->SelectEntry( rSettings.sSelectedTable ); + m_xTableList->select_text(rSettings.sSelectedTable); } - - IMPL_LINK_NOARG( TableSelectionPage, OnTableDoubleClicked, ListBox&, void ) + IMPL_LINK_NOARG( TableSelectionPage, OnTableDoubleClicked, weld::TreeView&, void ) { - if ( 1 == m_pTableList->GetSelectedEntryCount() ) + if (m_xTableList->count_selected_rows() == 1) getDialog()->travelNext(); } - - IMPL_LINK_NOARG( TableSelectionPage, OnTableSelected, ListBox&, void ) + IMPL_LINK_NOARG( TableSelectionPage, OnTableSelected, weld::TreeView&, void ) { updateDialogTravelUI(); } - bool TableSelectionPage::commitPage( ::vcl::WizardTypes::CommitPageReason _eReason ) { if (!AddressBookSourcePage::commitPage(_eReason)) return false; AddressSettings& rSettings = getSettings(); - rSettings.sSelectedTable = m_pTableList->GetSelectedEntry(); + rSettings.sSelectedTable = m_xTableList->get_selected_text(); return true; } - bool TableSelectionPage::canAdvance() const { return AddressBookSourcePage::canAdvance() - && ( 0 < m_pTableList->GetSelectedEntryCount() ); + && (m_xTableList->count_selected_rows() > 0); } - } // namespace abp - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/abpilot/tableselectionpage.hxx b/extensions/source/abpilot/tableselectionpage.hxx index 9f58ea945976..f25258bc894a 100644 --- a/extensions/source/abpilot/tableselectionpage.hxx +++ b/extensions/source/abpilot/tableselectionpage.hxx @@ -21,21 +21,17 @@ #define INCLUDED_EXTENSIONS_SOURCE_ABPILOT_TABLESELECTIONPAGE_HXX #include "abspage.hxx" -#include -#include - +#include namespace abp { - class TableSelectionPage final : public AddressBookSourcePage { - VclPtr m_pTableList; + std::unique_ptr m_xTableList; public: - explicit TableSelectionPage( OAddressBookSourcePilot* _pParent ); + explicit TableSelectionPage(OAddressBookSourcePilot* pDialog, TabPageParent pPageParent); virtual ~TableSelectionPage() override; - virtual void dispose() override; private: // OWizardPage overridables virtual void initializePage() override; @@ -47,14 +43,12 @@ namespace abp // OImportPage overridables virtual bool canAdvance() const override; - DECL_LINK( OnTableSelected, ListBox&, void ); - DECL_LINK( OnTableDoubleClicked, ListBox&, void ); + DECL_LINK(OnTableSelected, weld::TreeView&, void); + DECL_LINK(OnTableDoubleClicked, weld::TreeView&, void); }; - } // namespace abp - #endif // INCLUDED_EXTENSIONS_SOURCE_ABPILOT_TABLESELECTIONPAGE_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/abpilot/typeselectionpage.cxx b/extensions/source/abpilot/typeselectionpage.cxx index ae72d77a3ce1..a9f68fd1afd3 100644 --- a/extensions/source/abpilot/typeselectionpage.cxx +++ b/extensions/source/abpilot/typeselectionpage.cxx @@ -31,19 +31,17 @@ namespace abp using namespace ::com::sun::star::sdbc; // TypeSelectionPage - TypeSelectionPage::TypeSelectionPage( OAddressBookSourcePilot* _pParent ) - : AddressBookSourcePage(_pParent, "SelectTypePage", - "modules/sabpilot/ui/selecttypepage.ui") + TypeSelectionPage::TypeSelectionPage(OAddressBookSourcePilot* pDialog, TabPageParent pPageParent) + : AddressBookSourcePage(pDialog, pPageParent, "modules/sabpilot/ui/selecttypepage.ui", "SelectTypePage") + , m_xEvolution(m_xBuilder->weld_radio_button("evolution")) + , m_xEvolutionGroupwise(m_xBuilder->weld_radio_button("groupwise")) + , m_xEvolutionLdap(m_xBuilder->weld_radio_button("evoldap")) + , m_xMORK(m_xBuilder->weld_radio_button("firefox")) + , m_xThunderbird(m_xBuilder->weld_radio_button("thunderbird")) + , m_xKab(m_xBuilder->weld_radio_button("kde")) + , m_xMacab(m_xBuilder->weld_radio_button("macosx")) + , m_xOther(m_xBuilder->weld_radio_button("other")) { - get(m_pEvolution, "evolution"); - get(m_pEvolutionGroupwise, "groupwise"); - get(m_pEvolutionLdap, "evoldap"); - get(m_pMORK, "firefox"); - get(m_pThunderbird, "thunderbird"); - get(m_pKab, "kde"); - get(m_pMacab, "macosx"); - get(m_pOther, "other"); - //TODO: For now, try to keep offering the same choices like before the // Mozilla/MORK cleanup, even if the status of what driver actually // provides which functionality is somewhat unclear, see the discussions @@ -71,7 +69,7 @@ namespace abp bool bHaveKab = false; bool bHaveMacab = false; - Reference< XDriverManager2 > xManager = DriverManager::create( _pParent->getORB() ); + Reference< XDriverManager2 > xManager = DriverManager::create( pDialog->getORB() ); try { @@ -112,29 +110,28 @@ namespace abp #endif // Items are displayed in list order - m_aAllTypes.push_back( ButtonItem( m_pEvolution, AST_EVOLUTION, bHaveEvolution ) ); - m_aAllTypes.push_back( ButtonItem( m_pEvolutionGroupwise, AST_EVOLUTION_GROUPWISE, bHaveEvolution ) ); - m_aAllTypes.push_back( ButtonItem( m_pEvolutionLdap, AST_EVOLUTION_LDAP, bHaveEvolution ) ); - m_aAllTypes.push_back( ButtonItem( m_pMORK, AST_MORK, true ) ); - m_aAllTypes.push_back( ButtonItem( m_pThunderbird, AST_THUNDERBIRD, true ) ); - m_aAllTypes.push_back( ButtonItem( m_pKab, AST_KAB, bHaveKab ) ); - m_aAllTypes.push_back( ButtonItem( m_pMacab, AST_MACAB, bHaveMacab ) ); - m_aAllTypes.push_back( ButtonItem( m_pOther, AST_OTHER, true ) ); - - Link aTypeSelectionHandler = LINK(this, TypeSelectionPage, OnTypeSelected ); + m_aAllTypes.push_back( ButtonItem( m_xEvolution.get(), AST_EVOLUTION, bHaveEvolution ) ); + m_aAllTypes.push_back( ButtonItem( m_xEvolutionGroupwise.get(), AST_EVOLUTION_GROUPWISE, bHaveEvolution ) ); + m_aAllTypes.push_back( ButtonItem( m_xEvolutionLdap.get(), AST_EVOLUTION_LDAP, bHaveEvolution ) ); + m_aAllTypes.push_back( ButtonItem( m_xMORK.get(), AST_MORK, true ) ); + m_aAllTypes.push_back( ButtonItem( m_xThunderbird.get(), AST_THUNDERBIRD, true ) ); + m_aAllTypes.push_back( ButtonItem( m_xKab.get(), AST_KAB, bHaveKab ) ); + m_aAllTypes.push_back( ButtonItem( m_xMacab.get(), AST_MACAB, bHaveMacab ) ); + m_aAllTypes.push_back( ButtonItem( m_xOther.get(), AST_OTHER, true ) ); + + Link aTypeSelectionHandler = LINK(this, TypeSelectionPage, OnTypeSelected ); for (auto const& elem : m_aAllTypes) { if (!elem.m_bVisible) - elem.m_pItem->Hide(); + elem.m_pItem->hide(); else { - elem.m_pItem->SetClickHdl( aTypeSelectionHandler ); - elem.m_pItem->Show(); + elem.m_pItem->connect_clicked( aTypeSelectionHandler ); + elem.m_pItem->show(); } } } - TypeSelectionPage::~TypeSelectionPage() { disposeOnce(); @@ -146,27 +143,18 @@ namespace abp { elem.m_bVisible = false; } - m_pEvolution.clear(); - m_pEvolutionGroupwise.clear(); - m_pEvolutionLdap.clear(); - m_pMORK.clear(); - m_pThunderbird.clear(); - m_pKab.clear(); - m_pMacab.clear(); - m_pOther.clear(); AddressBookSourcePage::dispose(); } - void TypeSelectionPage::ActivatePage() { AddressBookSourcePage::ActivatePage(); for (auto const& elem : m_aAllTypes) { - if( elem.m_pItem->IsChecked() && elem.m_bVisible ) + if( elem.m_pItem->get_active() && elem.m_bVisible ) { - elem.m_pItem->GrabFocus(); + elem.m_pItem->grab_focus(); break; } } @@ -174,35 +162,31 @@ namespace abp getDialog()->enableButtons(WizardButtonFlags::PREVIOUS, false); } - void TypeSelectionPage::DeactivatePage() { AddressBookSourcePage::DeactivatePage(); getDialog()->enableButtons(WizardButtonFlags::PREVIOUS, true); } - void TypeSelectionPage::selectType( AddressSourceType _eType ) { for (auto const& elem : m_aAllTypes) { - elem.m_pItem->Check( _eType == elem.m_eType ); + elem.m_pItem->set_active( _eType == elem.m_eType ); } } - AddressSourceType TypeSelectionPage::getSelectedType() const { for (auto const& elem : m_aAllTypes) { - if ( elem.m_pItem->IsChecked() && elem.m_bVisible ) + if ( elem.m_pItem->get_active() && elem.m_bVisible ) return elem.m_eType; } return AST_INVALID; } - void TypeSelectionPage::initializePage() { AddressBookSourcePage::initializePage(); @@ -211,7 +195,6 @@ namespace abp selectType(rSettings.eType); } - bool TypeSelectionPage::commitPage( ::vcl::WizardTypes::CommitPageReason _eReason ) { if (!AddressBookSourcePage::commitPage(_eReason)) @@ -219,7 +202,7 @@ namespace abp if (AST_INVALID == getSelectedType( )) { - std::unique_ptr xBox(Application::CreateMessageDialog(GetFrameWeld(), + std::unique_ptr xBox(Application::CreateMessageDialog(m_xContainer.get(), VclMessageType::Warning, VclButtonsType::Ok, compmodule::ModuleRes(RID_STR_NEEDTYPESELECTION))); xBox->run(); @@ -240,7 +223,7 @@ namespace abp } - IMPL_LINK_NOARG( TypeSelectionPage, OnTypeSelected, Button*, void ) + IMPL_LINK_NOARG( TypeSelectionPage, OnTypeSelected, weld::Button&, void ) { getDialog()->typeSelectionChanged( getSelectedType() ); updateDialogTravelUI(); diff --git a/extensions/source/abpilot/typeselectionpage.hxx b/extensions/source/abpilot/typeselectionpage.hxx index 219afd059bf2..cf5c537b39f0 100644 --- a/extensions/source/abpilot/typeselectionpage.hxx +++ b/extensions/source/abpilot/typeselectionpage.hxx @@ -22,30 +22,28 @@ #include "abspage.hxx" #include "addresssettings.hxx" -#include -#include - +#include namespace abp { class TypeSelectionPage final : public AddressBookSourcePage { - VclPtr m_pEvolution; - VclPtr m_pEvolutionGroupwise; - VclPtr m_pEvolutionLdap; - VclPtr m_pMORK; - VclPtr m_pThunderbird; - VclPtr m_pKab; - VclPtr m_pMacab; - VclPtr m_pOther; + std::unique_ptr m_xEvolution; + std::unique_ptr m_xEvolutionGroupwise; + std::unique_ptr m_xEvolutionLdap; + std::unique_ptr m_xMORK; + std::unique_ptr m_xThunderbird; + std::unique_ptr m_xKab; + std::unique_ptr m_xMacab; + std::unique_ptr m_xOther; struct ButtonItem { - VclPtr m_pItem; + weld::RadioButton* m_pItem; AddressSourceType m_eType; bool m_bVisible; - ButtonItem( RadioButton *pItem, + ButtonItem( weld::RadioButton *pItem, AddressSourceType eType, bool bVisible ) : m_pItem( pItem ), @@ -57,7 +55,7 @@ namespace abp std::vector< ButtonItem > m_aAllTypes; public: - explicit TypeSelectionPage( OAddressBookSourcePilot* _pParent ); + explicit TypeSelectionPage(OAddressBookSourcePilot* pDialog, TabPageParent pPageParent); virtual ~TypeSelectionPage() override; virtual void dispose() override; @@ -76,7 +74,7 @@ namespace abp // OImportPage overridables virtual bool canAdvance() const override; - DECL_LINK( OnTypeSelected, Button*, void ); + DECL_LINK( OnTypeSelected, weld::Button&, void ); void selectType( AddressSourceType _eType ); }; diff --git a/extensions/source/abpilot/unodialogabp.cxx b/extensions/source/abpilot/unodialogabp.cxx index ded9cd8c3049..90320dff9fd7 100644 --- a/extensions/source/abpilot/unodialogabp.cxx +++ b/extensions/source/abpilot/unodialogabp.cxx @@ -21,7 +21,7 @@ #include #include "abspilot.hxx" #include -#include +#include #include #include #include @@ -116,10 +116,9 @@ namespace abp svt::OGenericUnoDialog::Dialog OABSPilotUno::createDialog(const css::uno::Reference& rParent) { - return svt::OGenericUnoDialog::Dialog(VclPtr::Create(VCLUnoHelper::GetWindow(rParent), m_aContext)); + return svt::OGenericUnoDialog::Dialog(std::make_unique(Application::GetFrameWeld(rParent), m_aContext)); } - Any SAL_CALL OABSPilotUno::execute( const Sequence< NamedValue >& /*lArgs*/ ) { // not interested in the context, not interested in the args @@ -139,7 +138,7 @@ namespace abp { if ( _nExecutionResult == RET_OK ) { - const AddressSettings& aSettings = static_cast(m_aDialog.m_xVclDialog.get())->getSettings(); + const AddressSettings& aSettings = static_cast(m_aDialog.m_xWeldDialog.get())->getSettings(); m_sDataSourceName = aSettings.bRegisterDataSource ? aSettings.sRegisteredDataSourceName : aSettings.sDataSourceName; } } diff --git a/extensions/uiconfig/sabpilot/ui/datasourcepage.ui b/extensions/uiconfig/sabpilot/ui/datasourcepage.ui index ac4a90acb281..0b1d770182bc 100644 --- a/extensions/uiconfig/sabpilot/ui/datasourcepage.ui +++ b/extensions/uiconfig/sabpilot/ui/datasourcepage.ui @@ -1,8 +1,7 @@ - + - True False @@ -12,22 +11,23 @@ True False - 0 - 0 That was all the information necessary to integrate your address data into %PRODUCTNAME. Now, just enter the name under which you want to register the data source in %PRODUCTNAME. True - 90 - - - + 70 + 70 + 0 + 0 + + + static + + 0 0 - 1 - 1 @@ -61,16 +61,14 @@ Now, just enter the name under which you want to register the data source in %PR True False - 0 Location True location + 0 0 0 - 1 - 1 @@ -84,12 +82,10 @@ Now, just enter the name under which you want to register the data source in %PR 2 0 - 1 - 1 - + True False True @@ -97,22 +93,19 @@ Now, just enter the name under which you want to register the data source in %PR True + True 1 0 - 1 - 1 0 1 - 1 - 1 @@ -128,8 +121,6 @@ Now, just enter the name under which you want to register the data source in %PR 0 2 - 1 - 1 @@ -154,16 +145,14 @@ Now, just enter the name under which you want to register the data source in %PR True False - 0 Address book name True name + 0 0 0 - 1 - 1 @@ -171,40 +160,38 @@ Now, just enter the name under which you want to register the data source in %PR True True True + True 1 0 - 1 - 1 0 0 - 1 - 1 False True - 0 - 0 Another data source already has this name. As data sources have to have globally unique names, you need to choose another one. True - 90 - - - + 70 + 70 + 0 + 0 + + + static + + 0 1 - 1 - 1 @@ -213,16 +200,12 @@ Now, just enter the name under which you want to register the data source in %PR 0 3 - 1 - 1 0 1 - 1 - 1 diff --git a/extensions/uiconfig/sabpilot/ui/fieldassignpage.ui b/extensions/uiconfig/sabpilot/ui/fieldassignpage.ui index d86802f8f4a4..410b95459179 100644 --- a/extensions/uiconfig/sabpilot/ui/fieldassignpage.ui +++ b/extensions/uiconfig/sabpilot/ui/fieldassignpage.ui @@ -1,5 +1,5 @@ - + @@ -11,24 +11,25 @@ True False - 0 - 0 To incorporate the address data in your templates, %PRODUCTNAME has to know which fields contain which data. For instance, you could have stored the e-mail addresses in a field named "email", or "E-mail" or "EM" - or something completely different. Click the button below to open another dialog where you can enter the settings for your data source. True - 90 - - - + 70 + 70 + 0 + 0 + + + static + + 0 0 - 1 - 1 @@ -43,8 +44,6 @@ Click the button below to open another dialog where you can enter the settings f 0 1 - 1 - 1 @@ -52,19 +51,19 @@ Click the button below to open another dialog where you can enter the settings f True False True + True + 70 0 0 - True - 90 - - - + + + static + + 0 2 - 1 - 1 diff --git a/extensions/uiconfig/sabpilot/ui/invokeadminpage.ui b/extensions/uiconfig/sabpilot/ui/invokeadminpage.ui index e8d97f137c06..d3c7a997c333 100644 --- a/extensions/uiconfig/sabpilot/ui/invokeadminpage.ui +++ b/extensions/uiconfig/sabpilot/ui/invokeadminpage.ui @@ -1,5 +1,5 @@ - + @@ -11,22 +11,23 @@ True False - 0 - 0 To set up the new data source, additional information is required. Click the following button to open another dialog in which you then enter the necessary information. - - - True - 90 + 70 + 70 + 0 + 0 + + + static + + 0 0 - 1 - 1 @@ -40,29 +41,28 @@ Click the following button to open another dialog in which you then enter the ne 0 1 - 1 - 1 False True - 0 - 0 The connection to the data source could not be established. Before you proceed, please check the settings made, or (on the previous page) choose another address data source type. True - 90 - - - + 70 + 70 + 0 + 0 + + + static + + 0 2 - 1 - 1 diff --git a/extensions/uiconfig/sabpilot/ui/selecttablepage.ui b/extensions/uiconfig/sabpilot/ui/selecttablepage.ui index a1c87bf94097..ce96a47e115e 100644 --- a/extensions/uiconfig/sabpilot/ui/selecttablepage.ui +++ b/extensions/uiconfig/sabpilot/ui/selecttablepage.ui @@ -1,7 +1,15 @@ - + + + + + + + + + True False @@ -11,39 +19,64 @@ True False - 0 - 0 The external data source you have chosen contains more than one address book. Please select the one you mainly want to work with: + True True - 90 - - - + table + 70 + 70 + 0 + 0 + + + static + + 0 0 - 1 - 1 - + True True True True - False - - + in + + + True + True + True + True + True + liststore1 + False + 0 + False + + + + + + 6 + + + + 0 + + + + + 0 1 - 1 - 1 diff --git a/extensions/uiconfig/sabpilot/ui/selecttypepage.ui b/extensions/uiconfig/sabpilot/ui/selecttypepage.ui index ea7fe130589b..82619b95bedc 100644 --- a/extensions/uiconfig/sabpilot/ui/selecttypepage.ui +++ b/extensions/uiconfig/sabpilot/ui/selecttypepage.ui @@ -15,12 +15,15 @@ This wizard helps you create the data source. True - 90 + 70 + 70 0 0 - - - + + + static + + 0 @@ -42,7 +45,6 @@ This wizard helps you create the data source. 0 True True - groupwise 0 @@ -58,7 +60,7 @@ This wizard helps you create the data source. True 0 True - evoldap + evolution 0 @@ -74,7 +76,7 @@ This wizard helps you create the data source. True 0 True - firefox + evolution 0 @@ -90,7 +92,7 @@ This wizard helps you create the data source. True 0 True - thunderbird + evolution 0 @@ -106,7 +108,7 @@ This wizard helps you create the data source. True 0 True - kde + evolution 0 @@ -122,7 +124,7 @@ This wizard helps you create the data source. True 0 True - macosx + evolution 0 @@ -138,7 +140,7 @@ This wizard helps you create the data source. True 0 True - other + evolution 0 @@ -166,9 +168,11 @@ This wizard helps you create the data source. True False Select the type of your external address book: - - - + + + static + + 0 diff --git a/include/svtools/inettbc.hxx b/include/svtools/inettbc.hxx index 13b9bed5cc67..bf61e0ddef2a 100644 --- a/include/svtools/inettbc.hxx +++ b/include/svtools/inettbc.hxx @@ -123,6 +123,7 @@ public: void clear() { m_xWidget->clear(); } void connect_entry_activate(const Link& rLink) { m_xWidget->connect_entry_activate(rLink); } void connect_changed(const Link& rLink) { aChangeHdl = rLink; } + void trigger_changed() { aChangeHdl.Call(*m_xWidget); } void connect_focus_out(const Link& rLink) { aFocusOutHdl = rLink; } void append_text(const OUString& rStr) { m_xWidget->append_text(rStr); } int find_text(const OUString& rStr) const { return m_xWidget->find_text(rStr); } diff --git a/include/svx/databaselocationinput.hxx b/include/svx/databaselocationinput.hxx index 8b84c7fe7f59..3608bc03e766 100644 --- a/include/svx/databaselocationinput.hxx +++ b/include/svx/databaselocationinput.hxx @@ -27,15 +27,15 @@ class PushButton; namespace svt { class OFileURLControl; } + +class URLBox; +namespace weld { class Button; class Window; } namespace com::sun::star::uno { class XComponentContext; } namespace com::sun::star::uno { template class Reference; } namespace svx { - - //= DatabaseLocationInputController - class DatabaseLocationInputController_Impl; /** helper class to control controls needed to input a database location @@ -50,8 +50,9 @@ namespace svx public: DatabaseLocationInputController( const css::uno::Reference& _rContext, - ::svt::OFileURLControl& _rLocationInput, - PushButton& _rBrowseButton + URLBox& _rLocationInput, + weld::Button& _rBrowseButton, + weld::Window& _rDialog ); ~DatabaseLocationInputController(); @@ -78,6 +79,48 @@ namespace svx m_pImpl; }; + //= SvxDatabaseLocationInputController + class SvxDatabaseLocationInputController_Impl; + /** helper class to control controls needed to input a database location + + If you allow, in your dialog, to save a database document, then you usually + have a OFileURLControl for inputting the actual location, and a push button + to browse for a location. + + This helper class controls such two UI elements. + */ + class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxDatabaseLocationInputController + { + public: + SvxDatabaseLocationInputController( + const css::uno::Reference& _rContext, + ::svt::OFileURLControl& _rLocationInput, + PushButton& _rBrowseButton + ); + ~SvxDatabaseLocationInputController(); + + /** sets the given URL at the input control, after translating it into a system path + */ + void setURL( const OUString& _rURL ); + + /** returns the current database location, in form of a URL (not a system path) + */ + OUString getURL() const; + + /** prepares committing the database location entered in the input field + + Effectively, this method checks whether the file in the location already + exists, and if so, it asks the user whether to overwrite it. + + If the method is called multiple times, this check only happens when the location + changed since the last call. + */ + bool prepareCommit(); + + private: + ::std::unique_ptr< SvxDatabaseLocationInputController_Impl > + m_pImpl; + }; } diff --git a/svx/source/form/databaselocationinput.cxx b/svx/source/form/databaselocationinput.cxx index 620ab6af29d9..8b90fb2cd7d9 100644 --- a/svx/source/form/databaselocationinput.cxx +++ b/svx/source/form/databaselocationinput.cxx @@ -54,11 +54,209 @@ namespace svx { public: DatabaseLocationInputController_Impl( + const Reference& _rContext, + URLBox& _rLocationInput, + weld::Button& _rBrowseButton, + weld::Window& _rDialog + ); + + bool prepareCommit(); + void setURL( const OUString& _rURL ); + OUString getURL() const; + + private: + void impl_initFilterProperties_nothrow(); + void impl_onBrowseButtonClicked(); + OUString impl_getCurrentURL() const; + + DECL_LINK( OnButtonAction, weld::Button&, void ); + + private: + const Reference m_xContext; + URLBox& m_rLocationInput; + weld::Button& m_rBrowseButton; + weld::Window& m_rDialog; + Sequence< OUString > m_aFilterExtensions; + OUString m_sFilterUIName; + bool m_bNeedExistenceCheck; + }; + + DatabaseLocationInputController_Impl::DatabaseLocationInputController_Impl(const Reference& _rContext, + URLBox& _rLocationInput, weld::Button& _rBrowseButton, weld::Window& _rDialog) + :m_xContext( _rContext ) + ,m_rLocationInput( _rLocationInput ) + ,m_rBrowseButton( _rBrowseButton ) + ,m_rDialog( _rDialog ) + ,m_aFilterExtensions() + ,m_sFilterUIName() + ,m_bNeedExistenceCheck( true ) + { + impl_initFilterProperties_nothrow(); + + // forward the allowed extensions to the input control + OUStringBuffer aExtensionList; + for ( auto const & extension : std::as_const(m_aFilterExtensions) ) + { + aExtensionList.append( extension ); + aExtensionList.append( ';' ); + } + m_rLocationInput.SetFilter( aExtensionList.makeStringAndClear() ); + m_rBrowseButton.connect_clicked(LINK(this, DatabaseLocationInputController_Impl, OnButtonAction)); + } + + bool DatabaseLocationInputController_Impl::prepareCommit() + { + OUString sURL( impl_getCurrentURL() ); + if ( sURL.isEmpty() ) + return false; + + // check if the name exists + if ( m_bNeedExistenceCheck ) + { + if ( ::utl::UCBContentHelper::Exists( sURL ) ) + { + std::unique_ptr xQueryBox(Application::CreateMessageDialog(m_rLocationInput.getWidget(), + VclMessageType::Question, VclButtonsType::YesNo, + SvxResId(RID_STR_ALREADYEXISTOVERWRITE))); + if (xQueryBox->run() != RET_YES) + return false; + } + } + + return true; + } + + void DatabaseLocationInputController_Impl::setURL( const OUString& _rURL ) + { + ::svt::OFileNotation aTransformer( _rURL ); + m_rLocationInput.set_entry_text( aTransformer.get( ::svt::OFileNotation::N_SYSTEM ) ); + } + + OUString DatabaseLocationInputController_Impl::getURL() const + { + return impl_getCurrentURL(); + } + + void DatabaseLocationInputController_Impl::impl_initFilterProperties_nothrow() + { + try + { + // get the name of the default filter for database documents + ::utl::OConfigurationTreeRoot aConfig( + ::utl::OConfigurationTreeRoot::createWithComponentContext( + m_xContext, + "/org.openoffice.Setup/Office/Factories/com.sun.star.sdb.OfficeDatabaseDocument" + ) ); + OUString sDatabaseFilter; + OSL_VERIFY( aConfig.getNodeValue( "ooSetupFactoryActualFilter" ) >>= sDatabaseFilter ); + + // get the type this filter is responsible for + Reference< XNameAccess > xFilterFactory( + m_xContext->getServiceManager()->createInstanceWithContext("com.sun.star.document.FilterFactory", m_xContext), + UNO_QUERY_THROW ); + ::comphelper::NamedValueCollection aFilterProperties( xFilterFactory->getByName( sDatabaseFilter ) ); + OUString sDocumentType = aFilterProperties.getOrDefault( "Type", OUString() ); + + // get the extension(s) for this type + Reference< XNameAccess > xTypeDetection( + m_xContext->getServiceManager()->createInstanceWithContext("com.sun.star.document.TypeDetection", m_xContext), + UNO_QUERY_THROW ); + + ::comphelper::NamedValueCollection aTypeProperties( xTypeDetection->getByName( sDocumentType ) ); + m_aFilterExtensions = aTypeProperties.getOrDefault( "Extensions", m_aFilterExtensions ); + m_sFilterUIName = aTypeProperties.getOrDefault( "UIName", m_sFilterUIName ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION("svx"); + } + + // ensure we have at least one extension + OSL_ENSURE( m_aFilterExtensions.hasElements(), + "DatabaseLocationInputController_Impl::impl_initFilterProperties_nothrow: unable to determine the file extension(s)!" ); + if ( !m_aFilterExtensions.hasElements() ) + { + m_aFilterExtensions.realloc(1); + m_aFilterExtensions[0] = "*.odb"; + } + } + + IMPL_LINK_NOARG(DatabaseLocationInputController_Impl, OnButtonAction, weld::Button&, void) + { + impl_onBrowseButtonClicked(); + } + + OUString DatabaseLocationInputController_Impl::impl_getCurrentURL() const + { + OUString sCurrentFile( m_rLocationInput.get_active_text() ); + if ( !sCurrentFile.isEmpty() ) + { + ::svt::OFileNotation aCurrentFile( sCurrentFile ); + sCurrentFile = aCurrentFile.get( ::svt::OFileNotation::N_URL ); + } + return sCurrentFile; + } + + void DatabaseLocationInputController_Impl::impl_onBrowseButtonClicked() + { + ::sfx2::FileDialogHelper aFileDlg( + TemplateDescription::FILESAVE_AUTOEXTENSION, + FileDialogFlags::NONE, + &m_rDialog + ); + aFileDlg.SetDisplayDirectory( impl_getCurrentURL() ); + + aFileDlg.AddFilter( m_sFilterUIName, "*." + m_aFilterExtensions[0] ); + aFileDlg.SetCurrentFilter( m_sFilterUIName ); + + if ( aFileDlg.Execute() == ERRCODE_NONE ) + { + INetURLObject aURL( aFileDlg.GetPath() ); + if( aURL.GetProtocol() != INetProtocol::NotValid ) + { + ::svt::OFileNotation aFileNotation( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); + m_rLocationInput.set_entry_text(aFileNotation.get(::svt::OFileNotation::N_SYSTEM)); + m_rLocationInput.trigger_changed(); + // the dialog already checked for the file's existence, so we don't need to, again + m_bNeedExistenceCheck = false; + } + } + } + + DatabaseLocationInputController::DatabaseLocationInputController( const Reference& _rContext, + URLBox& _rLocationInput, weld::Button& _rBrowseButton, weld::Window& _rDialog ) + :m_pImpl( new DatabaseLocationInputController_Impl( _rContext, _rLocationInput, _rBrowseButton, _rDialog ) ) + { + } + + DatabaseLocationInputController::~DatabaseLocationInputController() + { + } + + bool DatabaseLocationInputController::prepareCommit() + { + return m_pImpl->prepareCommit(); + } + + void DatabaseLocationInputController::setURL( const OUString& _rURL ) + { + m_pImpl->setURL( _rURL ); + } + + OUString DatabaseLocationInputController::getURL() const + { + return m_pImpl->getURL(); + } + + class SvxDatabaseLocationInputController_Impl + { + public: + SvxDatabaseLocationInputController_Impl( const Reference& _rContext, ::svt::OFileURLControl& _rLocationInput, PushButton& _rBrowseButton ); - ~DatabaseLocationInputController_Impl(); + ~SvxDatabaseLocationInputController_Impl(); bool prepareCommit(); void setURL( const OUString& _rURL ); @@ -80,9 +278,9 @@ namespace svx bool m_bNeedExistenceCheck; }; - - DatabaseLocationInputController_Impl::DatabaseLocationInputController_Impl( const Reference& _rContext, - ::svt::OFileURLControl& _rLocationInput, PushButton& _rBrowseButton ) + SvxDatabaseLocationInputController_Impl::SvxDatabaseLocationInputController_Impl(const Reference& _rContext, + ::svt::OFileURLControl& _rLocationInput, + PushButton& _rBrowseButton) :m_xContext( _rContext ) ,m_rLocationInput( _rLocationInput ) ,m_rBrowseButton( _rBrowseButton ) @@ -100,20 +298,17 @@ namespace svx aExtensionList.append( ';' ); } m_rLocationInput.SetFilter( aExtensionList.makeStringAndClear() ); - - m_rBrowseButton.AddEventListener( LINK( this, DatabaseLocationInputController_Impl, OnControlAction ) ); - m_rLocationInput.AddEventListener( LINK( this, DatabaseLocationInputController_Impl, OnControlAction ) ); + m_rBrowseButton.AddEventListener( LINK( this, SvxDatabaseLocationInputController_Impl, OnControlAction ) ); + m_rLocationInput.AddEventListener( LINK( this, SvxDatabaseLocationInputController_Impl, OnControlAction ) ); } - - DatabaseLocationInputController_Impl::~DatabaseLocationInputController_Impl() + SvxDatabaseLocationInputController_Impl::~SvxDatabaseLocationInputController_Impl() { - m_rBrowseButton.RemoveEventListener( LINK( this, DatabaseLocationInputController_Impl, OnControlAction ) ); - m_rLocationInput.RemoveEventListener( LINK( this, DatabaseLocationInputController_Impl, OnControlAction ) ); + m_rBrowseButton.RemoveEventListener( LINK( this, SvxDatabaseLocationInputController_Impl, OnControlAction ) ); + m_rLocationInput.RemoveEventListener( LINK( this, SvxDatabaseLocationInputController_Impl, OnControlAction ) ); } - - bool DatabaseLocationInputController_Impl::prepareCommit() + bool SvxDatabaseLocationInputController_Impl::prepareCommit() { OUString sURL( impl_getCurrentURL() ); if ( sURL.isEmpty() ) @@ -135,21 +330,18 @@ namespace svx return true; } - - void DatabaseLocationInputController_Impl::setURL( const OUString& _rURL ) + void SvxDatabaseLocationInputController_Impl::setURL( const OUString& _rURL ) { ::svt::OFileNotation aTransformer( _rURL ); m_rLocationInput.SetText( aTransformer.get( ::svt::OFileNotation::N_SYSTEM ) ); } - - OUString DatabaseLocationInputController_Impl::getURL() const + OUString SvxDatabaseLocationInputController_Impl::getURL() const { return impl_getCurrentURL(); } - - void DatabaseLocationInputController_Impl::impl_initFilterProperties_nothrow() + void SvxDatabaseLocationInputController_Impl::impl_initFilterProperties_nothrow() { try { @@ -193,8 +385,7 @@ namespace svx } } - - IMPL_LINK( DatabaseLocationInputController_Impl, OnControlAction, VclWindowEvent&, _rEvent, void ) + IMPL_LINK( SvxDatabaseLocationInputController_Impl, OnControlAction, VclWindowEvent&, _rEvent, void ) { if ( ( _rEvent.GetWindow() == &m_rBrowseButton ) && ( _rEvent.GetId() == VclEventId::ButtonClick ) @@ -211,8 +402,7 @@ namespace svx } } - - OUString DatabaseLocationInputController_Impl::impl_getCurrentURL() const + OUString SvxDatabaseLocationInputController_Impl::impl_getCurrentURL() const { OUString sCurrentFile( m_rLocationInput.GetText() ); if ( !sCurrentFile.isEmpty() ) @@ -223,8 +413,7 @@ namespace svx return sCurrentFile; } - - void DatabaseLocationInputController_Impl::impl_onBrowseButtonClicked() + void SvxDatabaseLocationInputController_Impl::impl_onBrowseButtonClicked() { ::sfx2::FileDialogHelper aFileDlg( TemplateDescription::FILESAVE_AUTOEXTENSION, @@ -249,39 +438,31 @@ namespace svx } } } - - - DatabaseLocationInputController::DatabaseLocationInputController( const Reference& _rContext, + SvxDatabaseLocationInputController::SvxDatabaseLocationInputController( const Reference& _rContext, ::svt::OFileURLControl& _rLocationInput, PushButton& _rBrowseButton ) - :m_pImpl( new DatabaseLocationInputController_Impl( _rContext, _rLocationInput, _rBrowseButton ) ) + :m_pImpl( new SvxDatabaseLocationInputController_Impl( _rContext, _rLocationInput, _rBrowseButton ) ) { } - - DatabaseLocationInputController::~DatabaseLocationInputController() + SvxDatabaseLocationInputController::~SvxDatabaseLocationInputController() { } - - bool DatabaseLocationInputController::prepareCommit() + bool SvxDatabaseLocationInputController::prepareCommit() { return m_pImpl->prepareCommit(); } - - void DatabaseLocationInputController::setURL( const OUString& _rURL ) + void SvxDatabaseLocationInputController::setURL( const OUString& _rURL ) { m_pImpl->setURL( _rURL ); } - - OUString DatabaseLocationInputController::getURL() const + OUString SvxDatabaseLocationInputController::getURL() const { return m_pImpl->getURL(); } - } - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit