From b54046188c48b7031d0460ebab74125adc97f874 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 28 Feb 2018 17:04:46 +0000 Subject: weld ScStringInputDlg to native dialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ScStringInputDlg and SwStringInputDlg do the same thing, but one uses the old name as the label and leaves the new name blank in the entry. The other puts the old name into the entry and autoselects it and uses a normal label. Both are used from the rename button of the shared autoformat dialog. Change-Id: I2ebf09a79f92c3f9020304e23e8907b67c06cd35 Reviewed-on: https://gerrit.libreoffice.org/50525 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- sc/inc/scabstdlg.hxx | 11 ++++---- sc/qa/unit/screenshots/screenshots.cxx | 4 ++- sc/source/ui/attrdlg/scdlgfact.cxx | 20 ++++++++------- sc/source/ui/attrdlg/scdlgfact.hxx | 20 ++++++++++----- sc/source/ui/inc/strindlg.hxx | 25 +++++++++--------- sc/source/ui/miscdlgs/scuiautofmt.cxx | 22 ++++++---------- sc/source/ui/miscdlgs/strindlg.cxx | 42 ++++++++++++------------------- sc/source/ui/view/tabvwshf.cxx | 4 +-- sc/uiconfig/scalc/ui/inputstringdialog.ui | 15 ++++++++--- 9 files changed, 85 insertions(+), 78 deletions(-) (limited to 'sc') diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx index 32757d2c9f2e..d90cc4ed9810 100644 --- a/sc/inc/scabstdlg.hxx +++ b/sc/inc/scabstdlg.hxx @@ -503,11 +503,12 @@ public: bool bEdit, bool bSheetProtected ) = 0; virtual VclPtr CreateScShowTabDlg(vcl::Window* pParent) = 0; - virtual VclPtr CreateScStringInputDlg ( vcl::Window* pParent, - const OUString& rTitle, - const OUString& rEditTitle, - const OUString& rDefault, - const OString& sHelpId, const OString& sEditHelpId ) = 0; + virtual VclPtr CreateScStringInputDlg(weld::Window* pParent, + const OUString& rTitle, + const OUString& rEditTitle, + const OUString& rDefault, + const OString& rHelpId, + const OString& rEditHelpId) = 0; virtual VclPtr CreateScTabBgColorDlg ( vcl::Window* pParent, const OUString& rTitle, //Dialog Title diff --git a/sc/qa/unit/screenshots/screenshots.cxx b/sc/qa/unit/screenshots/screenshots.cxx index 2c32d2c75874..8d01ad5c9cfa 100644 --- a/sc/qa/unit/screenshots/screenshots.cxx +++ b/sc/qa/unit/screenshots/screenshots.cxx @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -207,7 +208,8 @@ VclPtr ScScreenshotTest::createDialogByID(sal_uInt32 nID) case 8: // "modules/scalc/ui/inputstringdialog.ui" { const OString aEmpty(""); - pReturnDialog = mpFact->CreateScStringInputDlg(mpViewShell->GetDialogParent(), + vcl::Window* pWindow = mpViewShell->GetDialogParent(); + pReturnDialog = mpFact->CreateScStringInputDlg(pWindow ? pWindow->GetFrameWeld() : nullptr, ScResId(SCSTR_APDTABLE), ScResId(SCSTR_NAME), aDefaultSheetName, aEmpty, aEmpty ); break; diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx index f1cb49ae299d..b263ca09cc94 100644 --- a/sc/source/ui/attrdlg/scdlgfact.cxx +++ b/sc/source/ui/attrdlg/scdlgfact.cxx @@ -105,7 +105,6 @@ IMPL_ABSTDLG_BASE(AbstractScDPShowDetailDlg_Impl); IMPL_ABSTDLG_BASE(AbstractScNewScenarioDlg_Impl); IMPL_ABSTDLG_BASE(AbstractScShowTabDlg_Impl); IMPL_ABSTDLG_BASE(AbstractScSortWarningDlg_Impl); -IMPL_ABSTDLG_BASE(AbstractScStringInputDlg_Impl); IMPL_ABSTDLG_BASE(AbstractScTabBgColorDlg_Impl); IMPL_ABSTDLG_BASE(AbstractScImportOptionsDlg_Impl); IMPL_ABSTDLG_BASE(AbstractScTextImportOptionsDlg_Impl); @@ -576,9 +575,14 @@ OUString AbstractScShowTabDlg_Impl::GetSelectedEntry(sal_Int32 nPos) const return pDlg->GetSelectedEntry(nPos); } +short AbstractScStringInputDlg_Impl::Execute() +{ + return m_xDlg->run(); +} + OUString AbstractScStringInputDlg_Impl::GetInputString() const { - return pDlg->GetInputString(); + return m_xDlg->GetInputString(); } void AbstractScTabBgColorDlg_Impl::GetSelectedColor( Color& rColor ) const @@ -835,14 +839,12 @@ VclPtr ScAbstractDialogFactory_Impl::CreateScShowTabDlg(vc return VclPtr::Create( pDlg ); } -VclPtr ScAbstractDialogFactory_Impl::CreateScStringInputDlg ( vcl::Window* pParent, - const OUString& rTitle, - const OUString& rEditTitle, - const OUString& rDefault, - const OString& sHelpId, const OString& sEditHelpId ) +VclPtr ScAbstractDialogFactory_Impl::CreateScStringInputDlg(weld::Window* pParent, + const OUString& rTitle, const OUString& rEditTitle, const OUString& rDefault, const OString& rHelpId, + const OString& rEditHelpId) { - VclPtr pDlg = VclPtr::Create( pParent, rTitle, rEditTitle, rDefault, sHelpId, sEditHelpId ); - return VclPtr::Create( pDlg ); + return VclPtr::Create(new ScStringInputDlg(pParent, rTitle, rEditTitle, + rDefault, rHelpId, rEditHelpId)); } VclPtr ScAbstractDialogFactory_Impl::CreateScTabBgColorDlg( diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx index a139d7fd70aa..33d471fec7af 100644 --- a/sc/source/ui/attrdlg/scdlgfact.hxx +++ b/sc/source/ui/attrdlg/scdlgfact.hxx @@ -352,7 +352,14 @@ class AbstractScSortWarningDlg_Impl : public AbstractScSortWarningDlg class AbstractScStringInputDlg_Impl : public AbstractScStringInputDlg { - DECL_ABSTDLG_BASE( AbstractScStringInputDlg_Impl, ScStringInputDlg ) +protected: + std::unique_ptr m_xDlg; +public: + explicit AbstractScStringInputDlg_Impl(ScStringInputDlg* p) + : m_xDlg(p) + { + } + virtual short Execute() override; virtual OUString GetInputString() const override; }; @@ -501,11 +508,12 @@ public: bool bEdit, bool bSheetProtected ) override; virtual VclPtr CreateScShowTabDlg(vcl::Window* pParent) override; - virtual VclPtr CreateScStringInputDlg ( vcl::Window* pParent, - const OUString& rTitle, - const OUString& rEditTitle, - const OUString& rDefault, - const OString& sHelpId, const OString& sEditHelpId ) override; + virtual VclPtr CreateScStringInputDlg(weld::Window* pParent, + const OUString& rTitle, + const OUString& rEditTitle, + const OUString& rDefault, + const OString& rHelpId, + const OString& rEditHelpId) override; virtual VclPtr CreateScTabBgColorDlg ( vcl::Window* pParent, const OUString& rTitle, //Dialog Title diff --git a/sc/source/ui/inc/strindlg.hxx b/sc/source/ui/inc/strindlg.hxx index 94268fb4c3c5..22dd85049f47 100644 --- a/sc/source/ui/inc/strindlg.hxx +++ b/sc/source/ui/inc/strindlg.hxx @@ -20,28 +20,29 @@ #ifndef INCLUDED_SC_SOURCE_UI_INC_STRINDLG_HXX #define INCLUDED_SC_SOURCE_UI_INC_STRINDLG_HXX -#include -#include -#include +#include -class ScStringInputDlg : public ModalDialog +class ScStringInputDlg { +private: + std::unique_ptr m_xBuilder; + std::unique_ptr m_xDialog; + std::unique_ptr m_xLabel; + std::unique_ptr m_xEdInput; + public: - ScStringInputDlg(vcl::Window* pParent, + ScStringInputDlg(weld::Window* pParent, const OUString& rTitle, const OUString& rEditTitle, const OUString& rDefault, const OString& sHelpId, const OString& sEditHelpId); - virtual ~ScStringInputDlg() override; - virtual void dispose() override; + + short run() { return m_xDialog->run(); } + OUString GetInputString() const { - return m_pEdInput->GetText(); + return m_xEdInput->get_text(); } - -private: - VclPtr m_pFtEditTitle; - VclPtr m_pEdInput; }; #endif // INCLUDED_SC_SOURCE_UI_INC_STRINDLG_HXX diff --git a/sc/source/ui/miscdlgs/scuiautofmt.cxx b/sc/source/ui/miscdlgs/scuiautofmt.cxx index 57579606eaa0..6682fe385e16 100644 --- a/sc/source/ui/miscdlgs/scuiautofmt.cxx +++ b/sc/source/ui/miscdlgs/scuiautofmt.cxx @@ -220,15 +220,12 @@ IMPL_LINK_NOARG(ScAutoFormatDlg, AddHdl, Button*, void) while ( !bOk ) { - VclPtrInstance pDlg( this, - aStrTitle, - aStrLabel, - aFormatName, - HID_SC_ADD_AUTOFMT, HID_SC_AUTOFMT_NAME ); + ScStringInputDlg aDlg(GetFrameWeld(), aStrTitle, aStrLabel, aFormatName, + HID_SC_ADD_AUTOFMT, HID_SC_AUTOFMT_NAME); - if ( pDlg->Execute() == RET_OK ) + if (aDlg.run() == RET_OK) { - aFormatName = pDlg->GetInputString(); + aFormatName = aDlg.GetInputString(); if ( !aFormatName.isEmpty() && aFormatName != aStrStandard && pFormat->find(aFormatName) == pFormat->end() ) { @@ -326,15 +323,12 @@ IMPL_LINK_NOARG(ScAutoFormatDlg, RenameHdl, Button*, void) OUString aFormatName = m_pLbFormat->GetSelectedEntry(); OUString aEntry; - VclPtrInstance pDlg( this, - aStrRename, - aStrLabel, - aFormatName, - HID_SC_REN_AFMT_DLG, HID_SC_REN_AFMT_NAME ); - if( pDlg->Execute() == RET_OK ) + ScStringInputDlg aDlg(GetFrameWeld(), aStrRename, aStrLabel, aFormatName, + HID_SC_REN_AFMT_DLG, HID_SC_REN_AFMT_NAME); + if (aDlg.run() == RET_OK) { bool bFmtRenamed = false; - aFormatName = pDlg->GetInputString(); + aFormatName = aDlg.GetInputString(); if (!aFormatName.isEmpty()) { diff --git a/sc/source/ui/miscdlgs/strindlg.cxx b/sc/source/ui/miscdlgs/strindlg.cxx index 145517ec599a..da9da0387e9a 100644 --- a/sc/source/ui/miscdlgs/strindlg.cxx +++ b/sc/source/ui/miscdlgs/strindlg.cxx @@ -21,34 +21,24 @@ #include #include +#include -ScStringInputDlg::ScStringInputDlg( vcl::Window* pParent, - const OUString& rTitle, - const OUString& rEditTitle, - const OUString& rDefault, - const OString& sHelpId, const OString& sEditHelpId ) - : ModalDialog(pParent, "InputStringDialog", "modules/scalc/ui/inputstringdialog.ui") +ScStringInputDlg::ScStringInputDlg(weld::Window* pParent, + const OUString& rTitle, + const OUString& rEditTitle, + const OUString& rDefault, + const OString& rHelpId, const OString& rEditHelpId) + : m_xBuilder(Application::CreateBuilder(pParent, "modules/scalc/ui/inputstringdialog.ui")) + , m_xDialog(m_xBuilder->weld_dialog("InputStringDialog")) + , m_xLabel(m_xBuilder->weld_label("description_label")) + , m_xEdInput(m_xBuilder->weld_entry("name_entry")) { - SetHelpId( sHelpId ); - SetText( rTitle ); - get(m_pFtEditTitle, "description_label"); - m_pFtEditTitle->SetText(rEditTitle); - get(m_pEdInput, "name_entry"); - m_pEdInput->SetText( rDefault ); - m_pEdInput->SetSelection(Selection(SELECTION_MIN, SELECTION_MAX)); - m_pEdInput->SetHelpId( sEditHelpId ); -} - -ScStringInputDlg::~ScStringInputDlg() -{ - disposeOnce(); -} - -void ScStringInputDlg::dispose() -{ - m_pFtEditTitle.clear(); - m_pEdInput.clear(); - ModalDialog::dispose(); + m_xLabel->set_label(rEditTitle); + m_xDialog->set_title(rTitle); + m_xDialog->set_help_id(rHelpId); + m_xEdInput->set_text(rDefault); + m_xEdInput->set_help_id(rEditHelpId); + m_xEdInput->select_region(0, -1); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/view/tabvwshf.cxx b/sc/source/ui/view/tabvwshf.cxx index 2549dbc8caad..ae3a8bc6ac88 100644 --- a/sc/source/ui/view/tabvwshf.cxx +++ b/sc/source/ui/view/tabvwshf.cxx @@ -389,8 +389,9 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq ) ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); OSL_ENSURE(pFact, "ScAbstractFactory create fail!"); + vcl::Window* pWin = GetDialogParent(); ScopedVclPtr pDlg(pFact->CreateScStringInputDlg( - GetDialogParent(), aDlgTitle, ScResId(SCSTR_NAME), + pWin ? pWin->GetFrameWeld() : nullptr, aDlgTitle, ScResId(SCSTR_NAME), aName, GetStaticInterface()->GetSlot(nSlot)->GetCommand(), pHelpId)); @@ -429,7 +430,6 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq ) } else { - vcl::Window* pWin = GetDialogParent(); std::unique_ptr xBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, VclMessageType::Warning, VclButtonsType::Ok, aErrMsg)); nRet = xBox->run(); diff --git a/sc/uiconfig/scalc/ui/inputstringdialog.ui b/sc/uiconfig/scalc/ui/inputstringdialog.ui index c4356e9a1535..65cd93061b4f 100644 --- a/sc/uiconfig/scalc/ui/inputstringdialog.ui +++ b/sc/uiconfig/scalc/ui/inputstringdialog.ui @@ -1,10 +1,13 @@ - + False 6 + True + 0 + 0 dialog @@ -79,10 +82,13 @@ True False - 0 True True name_entry + 0 + + + False @@ -95,7 +101,7 @@ True True - 24 + 30 False @@ -117,5 +123,8 @@ cancel help + + + -- cgit