From 40ca52ee802ea3992caa82f811eab124381bc121 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 9 Apr 2018 13:03:02 +0100 Subject: weld SvxSearchSimilarityDialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ifff02a6e9a9b8ce78b1e7d15f5f9a73ec2574872 Reviewed-on: https://gerrit.libreoffice.org/52631 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- cui/source/dialogs/cuifmsearch.cxx | 2 +- cui/source/dialogs/srchxtra.cxx | 39 +++++++++---------------------- cui/source/factory/dlgfact.cxx | 20 +++++++++------- cui/source/factory/dlgfact.hxx | 11 +++++++-- cui/source/inc/srchxtra.hxx | 31 ++++++++++++------------ cui/uiconfig/ui/similaritysearchdialog.ui | 30 +++++++++++++++++++----- include/svx/svxdlg.hxx | 2 +- svx/source/dialog/srchdlg.cxx | 2 +- 8 files changed, 74 insertions(+), 63 deletions(-) diff --git a/cui/source/dialogs/cuifmsearch.cxx b/cui/source/dialogs/cuifmsearch.cxx index 69a867b4f036..cbca9ae7fa3a 100644 --- a/cui/source/dialogs/cuifmsearch.cxx +++ b/cui/source/dialogs/cuifmsearch.cxx @@ -356,7 +356,7 @@ IMPL_LINK(FmSearchDialog, OnClickedSpecialSettings, Button*, pButton, void ) SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); if (pFact) { - ScopedVclPtr pDlg(pFact->CreateSvxSearchSimilarityDialog( this, m_pSearchEngine->GetLevRelaxed(), m_pSearchEngine->GetLevOther(), + ScopedVclPtr pDlg(pFact->CreateSvxSearchSimilarityDialog(GetFrameWeld(), m_pSearchEngine->GetLevRelaxed(), m_pSearchEngine->GetLevOther(), m_pSearchEngine->GetLevShorter(), m_pSearchEngine->GetLevLonger() )); DBG_ASSERT( pDlg, "FmSearchDialog, OnClickedSpecialSettings: could not load the dialog!" ); if (pDlg && pDlg->Execute() == RET_OK) diff --git a/cui/source/dialogs/srchxtra.cxx b/cui/source/dialogs/srchxtra.cxx index 3e07eefc2847..beee5afea428 100644 --- a/cui/source/dialogs/srchxtra.cxx +++ b/cui/source/dialogs/srchxtra.cxx @@ -235,39 +235,22 @@ IMPL_LINK_NOARG(SvxSearchAttributeDialog, OKHdl, Button*, void) // class SvxSearchSimilarityDialog --------------------------------------- -SvxSearchSimilarityDialog::SvxSearchSimilarityDialog -( - vcl::Window* pParent, - bool bRelax, - sal_uInt16 nOther, - sal_uInt16 nShorter, - sal_uInt16 nLonger -) : - ModalDialog( pParent, "SimilaritySearchDialog", "cui/ui/similaritysearchdialog.ui" ) +SvxSearchSimilarityDialog::SvxSearchSimilarityDialog(weld::Window* pParent, bool bRelax, + sal_uInt16 nOther, sal_uInt16 nShorter, sal_uInt16 nLonger) + : GenericDialogController(pParent, "cui/ui/similaritysearchdialog.ui", "SimilaritySearchDialog") + , m_xOtherFld(m_xBuilder->weld_spin_button("otherfld")) + , m_xLongerFld(m_xBuilder->weld_spin_button("longerfld")) + , m_xShorterFld(m_xBuilder->weld_spin_button("shorterfld")) + , m_xRelaxBox(m_xBuilder->weld_check_button("relaxbox")) { - get( m_pOtherFld, "otherfld"); - get( m_pLongerFld, "longerfld"); - get( m_pShorterFld, "shorterfld"); - get( m_pRelaxBox, "relaxbox"); - - m_pOtherFld->SetValue( nOther ); - m_pShorterFld->SetValue( nShorter ); - m_pLongerFld->SetValue( nLonger ); - m_pRelaxBox->Check( bRelax ); + m_xOtherFld->set_value(nOther); + m_xShorterFld->set_value(nShorter); + m_xLongerFld->set_value(nLonger); + m_xRelaxBox->set_active(bRelax); } SvxSearchSimilarityDialog::~SvxSearchSimilarityDialog() { - disposeOnce(); -} - -void SvxSearchSimilarityDialog::dispose() -{ - m_pOtherFld.clear(); - m_pLongerFld.clear(); - m_pShorterFld.clear(); - m_pRelaxBox.clear(); - ModalDialog::dispose(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx index 091c920b9c5a..2002a4339183 100644 --- a/cui/source/factory/dlgfact.cxx +++ b/cui/source/factory/dlgfact.cxx @@ -113,7 +113,12 @@ IMPL_ABSTDLG_BASE(AbstractTitleDialog_Impl); IMPL_ABSTDLG_BASE(AbstractScriptSelectorDialog_Impl); IMPL_ABSTDLG_BASE(AbstractGalleryIdDialog_Impl); IMPL_ABSTDLG_BASE(AbstractURLDlg_Impl); -IMPL_ABSTDLG_BASE(AbstractSvxSearchSimilarityDialog_Impl); + +short AbstractSvxSearchSimilarityDialog_Impl::Execute() +{ + return m_xDlg->run(); +} + IMPL_ABSTDLG_BASE(AbstractSvxTransformTabDialog_Impl); IMPL_ABSTDLG_BASE(AbstractSvxCaptionDialog_Impl); IMPL_ABSTDLG_BASE(AbstractSvxJSearchOptionsDialog_Impl); @@ -498,22 +503,22 @@ OUString AbstractURLDlg_Impl::GetName() const sal_uInt16 AbstractSvxSearchSimilarityDialog_Impl::GetOther() { - return pDlg->GetOther(); + return m_xDlg->GetOther(); } sal_uInt16 AbstractSvxSearchSimilarityDialog_Impl::GetShorter() { - return pDlg->GetShorter(); + return m_xDlg->GetShorter(); } sal_uInt16 AbstractSvxSearchSimilarityDialog_Impl::GetLonger() { - return pDlg->GetLonger(); + return m_xDlg->GetLonger(); } bool AbstractSvxSearchSimilarityDialog_Impl::IsRelaxed() { - return pDlg->IsRelaxed(); + return m_xDlg->IsRelaxed(); } // AbstractSvxTransformTabDialog implementations just forwards everything to the dialog @@ -1074,14 +1079,13 @@ VclPtr AbstractDialogFactory_Impl::CreateSvxSearchAttributeDi return VclPtr::Create( pDlg ); } -VclPtr AbstractDialogFactory_Impl::CreateSvxSearchSimilarityDialog( vcl::Window* pParent, +VclPtr AbstractDialogFactory_Impl::CreateSvxSearchSimilarityDialog(weld::Window* pParent, bool bRelax, sal_uInt16 nOther, sal_uInt16 nShorter, sal_uInt16 nLonger) { - VclPtrInstance pDlg( pParent, bRelax, nOther, nShorter, nLonger ); - return VclPtr::Create( pDlg ); + return VclPtr::Create(new SvxSearchSimilarityDialog(pParent, bRelax, nOther, nShorter, nLonger)); } VclPtr AbstractDialogFactory_Impl::CreateSvxBorderBackgroundDlg( diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx index e9ea89b340e3..731b37a27530 100644 --- a/cui/source/factory/dlgfact.hxx +++ b/cui/source/factory/dlgfact.hxx @@ -251,7 +251,14 @@ class AbstractURLDlg_Impl :public AbstractURLDlg class SvxSearchSimilarityDialog; class AbstractSvxSearchSimilarityDialog_Impl :public AbstractSvxSearchSimilarityDialog { - DECL_ABSTDLG_BASE(AbstractSvxSearchSimilarityDialog_Impl,SvxSearchSimilarityDialog) +protected: + std::unique_ptr m_xDlg; +public: + explicit AbstractSvxSearchSimilarityDialog_Impl(SvxSearchSimilarityDialog* p) + : m_xDlg(p) + { + } + virtual short Execute() override; virtual sal_uInt16 GetOther() override; virtual sal_uInt16 GetShorter() override; virtual sal_uInt16 GetLonger() override; @@ -618,7 +625,7 @@ public: virtual VclPtr CreateSvxSearchAttributeDialog( vcl::Window* pParent, SearchAttrItemList& rLst, const sal_uInt16* pWhRanges) override; - virtual VclPtr CreateSvxSearchSimilarityDialog( vcl::Window* pParent, + virtual VclPtr CreateSvxSearchSimilarityDialog( weld::Window* pParent, bool bRelax, sal_uInt16 nOther, sal_uInt16 nShorter, diff --git a/cui/source/inc/srchxtra.hxx b/cui/source/inc/srchxtra.hxx index 1c0656f6574b..0e8442d39c71 100644 --- a/cui/source/inc/srchxtra.hxx +++ b/cui/source/inc/srchxtra.hxx @@ -20,6 +20,7 @@ #define INCLUDED_CUI_SOURCE_INC_SRCHXTRA_HXX #include +#include #include #include @@ -65,30 +66,28 @@ private: // class SvxSearchSimilarityDialog --------------------------------------- -class SvxSearchSimilarityDialog : public ModalDialog +class SvxSearchSimilarityDialog : public weld::GenericDialogController { private: - VclPtr m_pOtherFld; - VclPtr m_pLongerFld; - VclPtr m_pShorterFld; - VclPtr m_pRelaxBox; + std::unique_ptr m_xOtherFld; + std::unique_ptr m_xLongerFld; + std::unique_ptr m_xShorterFld; + std::unique_ptr m_xRelaxBox; public: - SvxSearchSimilarityDialog( vcl::Window* pParent, - bool bRelax, - sal_uInt16 nOther, - sal_uInt16 nShorter, - sal_uInt16 nLonger ); + SvxSearchSimilarityDialog(weld::Window* pParent, + bool bRelax, + sal_uInt16 nOther, + sal_uInt16 nShorter, + sal_uInt16 nLonger); virtual ~SvxSearchSimilarityDialog() override; - virtual void dispose() override; - sal_uInt16 GetOther() { return static_cast(m_pOtherFld->GetValue()); } - sal_uInt16 GetShorter() { return static_cast(m_pShorterFld->GetValue()); } - sal_uInt16 GetLonger() { return static_cast(m_pLongerFld->GetValue()); } - bool IsRelaxed() { return m_pRelaxBox->IsChecked(); } + sal_uInt16 GetOther() { return static_cast(m_xOtherFld->get_value()); } + sal_uInt16 GetShorter() { return static_cast(m_xShorterFld->get_value()); } + sal_uInt16 GetLonger() { return static_cast(m_xLongerFld->get_value()); } + bool IsRelaxed() { return m_xRelaxBox->get_active(); } }; - #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/uiconfig/ui/similaritysearchdialog.ui b/cui/uiconfig/ui/similaritysearchdialog.ui index 883c1ffb454b..12bfab037b6b 100644 --- a/cui/uiconfig/ui/similaritysearchdialog.ui +++ b/cui/uiconfig/ui/similaritysearchdialog.ui @@ -1,5 +1,5 @@ - + @@ -8,11 +8,26 @@ 1 10 + + 30 + 1 + 1 + 10 + + + 30 + 1 + 1 + 10 + False 6 Similarity Search False + True + 0 + 0 dialog @@ -91,10 +106,10 @@ True False - 1 _Exchange characters: True otherfld + 1 0 @@ -105,10 +120,10 @@ True False - 1 _Add characters: True longerfld + 1 0 @@ -119,10 +134,10 @@ True False - 1 _Remove characters: True shorterfld + 1 0 @@ -160,7 +175,7 @@ True True - adjustment1 + adjustment2 1 @@ -171,7 +186,7 @@ True True - adjustment1 + adjustment3 1 @@ -192,5 +207,8 @@ cancel help + + + diff --git a/include/svx/svxdlg.hxx b/include/svx/svxdlg.hxx index ae84bb361a92..511677c923ba 100644 --- a/include/svx/svxdlg.hxx +++ b/include/svx/svxdlg.hxx @@ -370,7 +370,7 @@ public: virtual VclPtr CreateSvxSearchAttributeDialog( vcl::Window* pParent, SearchAttrItemList& rLst, const sal_uInt16* pWhRanges)=0; - virtual VclPtr CreateSvxSearchSimilarityDialog( vcl::Window* pParent, + virtual VclPtr CreateSvxSearchSimilarityDialog( weld::Window* pParent, bool bRelax, sal_uInt16 nOther, sal_uInt16 nShorter, diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx index eb5787575771..628d9c939e64 100644 --- a/svx/source/dialog/srchdlg.cxx +++ b/svx/source/dialog/srchdlg.cxx @@ -1396,7 +1396,7 @@ IMPL_LINK( SvxSearchDialog, CommandHdl_Impl, Button *, pBtn, void ) SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); if(pFact) { - ScopedVclPtr pDlg(pFact->CreateSvxSearchSimilarityDialog( this, + ScopedVclPtr pDlg(pFact->CreateSvxSearchSimilarityDialog(GetFrameWeld(), pSearchItem->IsLEVRelaxed(), pSearchItem->GetLEVOther(), pSearchItem->GetLEVShorter(), -- cgit