diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-10-06 17:57:35 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-10-06 20:55:30 +0200 |
commit | 692c4f4d2c5995660baf747f2d15929896f6e992 (patch) | |
tree | 9ca59a05b3c3816efb6075db10ef7d9393c02825 /sw/source | |
parent | 1dc6a3aeec6d0f67990c2e18c31f094fc3edeba7 (diff) |
weld SwSelGlossaryDlg
Change-Id: I8d8b4a3b7ed461275eb4af86f3fd7709bab30586
Reviewed-on: https://gerrit.libreoffice.org/61476
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/ui/dialog/swdlgfact.cxx | 16 | ||||
-rw-r--r-- | sw/source/ui/dialog/swdlgfact.hxx | 13 | ||||
-rw-r--r-- | sw/source/ui/dochdl/selglos.cxx | 29 | ||||
-rw-r--r-- | sw/source/uibase/dochdl/gloshdl.cxx | 10 | ||||
-rw-r--r-- | sw/source/uibase/inc/gloshdl.hxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/inc/selglos.hxx | 23 | ||||
-rw-r--r-- | sw/source/uibase/shells/textglos.cxx | 2 |
7 files changed, 45 insertions, 52 deletions
diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx index 4ad47f91a41b..e8eb7119af93 100644 --- a/sw/source/ui/dialog/swdlgfact.cxx +++ b/sw/source/ui/dialog/swdlgfact.cxx @@ -172,7 +172,10 @@ short AbstractSwLabDlg_Impl::Execute() return m_xDlg->execute(); } -IMPL_ABSTDLG_BASE(AbstractSwSelGlossaryDlg_Impl); +short AbstractSwSelGlossaryDlg_Impl::Execute() +{ + return m_xDlg->run(); +} short AbstractSwAutoFormatDlg_Impl::Execute() { @@ -415,17 +418,17 @@ Printer * AbstractSwLabDlg_Impl::GetPrt() void AbstractSwSelGlossaryDlg_Impl::InsertGlos(const OUString &rRegion, const OUString &rGlosName) { - pDlg->InsertGlos( rRegion, rGlosName ); + m_xDlg->InsertGlos( rRegion, rGlosName ); } sal_Int32 AbstractSwSelGlossaryDlg_Impl::GetSelectedIdx() const { - return pDlg->GetSelectedIdx(); + return m_xDlg->GetSelectedIdx(); } void AbstractSwSelGlossaryDlg_Impl::SelectEntryPos(sal_Int32 nIdx) { - pDlg->SelectEntryPos( nIdx ); + m_xDlg->SelectEntryPos( nIdx ); } SwTableAutoFormat* AbstractSwAutoFormatDlg_Impl::FillAutoFormatOfIndex() const @@ -889,10 +892,9 @@ VclPtr<AbstractSplitTableDialog> SwAbstractDialogFactory_Impl::CreateSplitTableD return VclPtr<AbstractSplitTableDialog_Impl>::Create(o3tl::make_unique<SwSplitTableDlg>(pParent, rSh)); } -VclPtr<AbstractSwSelGlossaryDlg> SwAbstractDialogFactory_Impl::CreateSwSelGlossaryDlg(const OUString &rShortName) +VclPtr<AbstractSwSelGlossaryDlg> SwAbstractDialogFactory_Impl::CreateSwSelGlossaryDlg(weld::Window *pParent, const OUString &rShortName) { - VclPtr<SwSelGlossaryDlg> pDlg = VclPtr<SwSelGlossaryDlg>::Create(nullptr, rShortName); - return VclPtr<AbstractSwSelGlossaryDlg_Impl>::Create(pDlg); + return VclPtr<AbstractSwSelGlossaryDlg_Impl>::Create(o3tl::make_unique<SwSelGlossaryDlg>(pParent, rShortName)); } VclPtr<AbstractSwAutoFormatDlg> SwAbstractDialogFactory_Impl::CreateSwAutoFormatDlg(weld::Window* pParent, diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx index 208d423fc3c7..6471d1864c4c 100644 --- a/sw/source/ui/dialog/swdlgfact.hxx +++ b/sw/source/ui/dialog/swdlgfact.hxx @@ -342,7 +342,14 @@ public: class AbstractSwSelGlossaryDlg_Impl : public AbstractSwSelGlossaryDlg { - DECL_ABSTDLG_BASE(AbstractSwSelGlossaryDlg_Impl,SwSelGlossaryDlg) +protected: + std::unique_ptr<SwSelGlossaryDlg> m_xDlg; +public: + explicit AbstractSwSelGlossaryDlg_Impl(std::unique_ptr<SwSelGlossaryDlg> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; virtual void InsertGlos(const OUString &rRegion, const OUString &rGlosName) override; // inline virtual sal_Int32 GetSelectedIdx() const override; // inline virtual void SelectEntryPos(sal_Int32 nIdx) override; // inline @@ -609,8 +616,8 @@ public: const OString& sDefPage = OString()) override; virtual VclPtr<VclAbstractDialog> CreateSwAutoMarkDialog(vcl::Window *pParent, SwWrtShell &rSh) override; - virtual VclPtr<AbstractSwSelGlossaryDlg> CreateSwSelGlossaryDlg(const OUString &rShortName) override; - virtual VclPtr<VclAbstractDialog> CreateSwSortingDialog(weld::Window * pParent, SwWrtShell &rSh) override; + virtual VclPtr<AbstractSwSelGlossaryDlg> CreateSwSelGlossaryDlg(weld::Window *pParent, const OUString &rShortName) override; + virtual VclPtr<VclAbstractDialog> CreateSwSortingDialog(weld::Window *pParent, SwWrtShell &rSh) override; virtual VclPtr<VclAbstractDialog> CreateSwTableHeightDialog(weld::Window *pParent, SwWrtShell &rSh) override; virtual VclPtr<VclAbstractDialog> CreateSwColumnDialog(weld::Window *pParent, SwWrtShell &rSh) override; virtual VclPtr<AbstractSplitTableDialog> CreateSplitTableDialog(weld::Window* pParent, SwWrtShell &rSh) override; diff --git a/sw/source/ui/dochdl/selglos.cxx b/sw/source/ui/dochdl/selglos.cxx index 3646e18b7c3c..21f22690bbc2 100644 --- a/sw/source/ui/dochdl/selglos.cxx +++ b/sw/source/ui/dochdl/selglos.cxx @@ -18,36 +18,25 @@ */ #include <swtypes.hxx> - #include <selglos.hxx> -#include <vcl/layout.hxx> - -SwSelGlossaryDlg::SwSelGlossaryDlg(vcl::Window * pParent, const OUString &rShortName) - : ModalDialog(pParent, "InsertAutoTextDialog", - "modules/swriter/ui/insertautotextdialog.ui") +SwSelGlossaryDlg::SwSelGlossaryDlg(weld::Window * pParent, const OUString &rShortName) + : GenericDialogController(pParent, "modules/swriter/ui/insertautotextdialog.ui", "InsertAutoTextDialog") + , m_xFrame(m_xBuilder->weld_frame("frame")) + , m_xGlosBox(m_xBuilder->weld_tree_view("treeview")) { - VclFrame *pFrame(get<VclFrame>("frame")); - pFrame->set_label(pFrame->get_label() + rShortName); - get(m_pGlosBox, "treeview"); - m_pGlosBox->set_height_request(m_pGlosBox->GetTextHeight() * 10); - m_pGlosBox->SetDoubleClickHdl(LINK(this, SwSelGlossaryDlg, DoubleClickHdl)); + m_xFrame->set_label(m_xFrame->get_label() + rShortName); + m_xGlosBox->set_size_request(-1, m_xGlosBox->get_height_rows(10)); + m_xGlosBox->connect_row_activated(LINK(this, SwSelGlossaryDlg, DoubleClickHdl)); } SwSelGlossaryDlg::~SwSelGlossaryDlg() { - disposeOnce(); -} - -void SwSelGlossaryDlg::dispose() -{ - m_pGlosBox.clear(); - ModalDialog::dispose(); } -IMPL_LINK_NOARG(SwSelGlossaryDlg, DoubleClickHdl, ListBox&, void) +IMPL_LINK_NOARG(SwSelGlossaryDlg, DoubleClickHdl, weld::TreeView&, void) { - EndDialog(RET_OK); + m_xDialog->response(RET_OK); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/dochdl/gloshdl.cxx b/sw/source/uibase/dochdl/gloshdl.cxx index 8bf13f421310..115f3e8d959c 100644 --- a/sw/source/uibase/dochdl/gloshdl.cxx +++ b/sw/source/uibase/dochdl/gloshdl.cxx @@ -352,7 +352,7 @@ bool SwGlossaryHdl::DelGlossary(const OUString &rShortName) } // expand short name -bool SwGlossaryHdl::ExpandGlossary() +bool SwGlossaryHdl::ExpandGlossary(weld::Window* pParent) { OSL_ENSURE(pWrtShell->CanInsert(), "illegal"); SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); @@ -383,12 +383,12 @@ bool SwGlossaryHdl::ExpandGlossary() if(pWrtShell->IsSelection()) aShortName = pWrtShell->GetSelText(); } - return pGlossary && Expand( aShortName, &rStatGlossaries, std::move(pGlossary) ); + return pGlossary && Expand(pParent, aShortName, &rStatGlossaries, std::move(pGlossary)); } -bool SwGlossaryHdl::Expand( const OUString& rShortName, +bool SwGlossaryHdl::Expand(weld::Window* pParent, const OUString& rShortName, SwGlossaries *pGlossaries, - std::unique_ptr<SwTextBlocks> pGlossary ) + std::unique_ptr<SwTextBlocks> pGlossary) { std::vector<TextBlockInfo_Impl> aFoundArr; OUString aShortName( rShortName ); @@ -436,7 +436,7 @@ bool SwGlossaryHdl::Expand( const OUString& rShortName, else { SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); - ScopedVclPtr<AbstractSwSelGlossaryDlg> pDlg(pFact->CreateSwSelGlossaryDlg(aShortName)); + ScopedVclPtr<AbstractSwSelGlossaryDlg> pDlg(pFact->CreateSwSelGlossaryDlg(pParent, aShortName)); for(TextBlockInfo_Impl & i : aFoundArr) { pDlg->InsertGlos(i.sTitle, i.sLongName); diff --git a/sw/source/uibase/inc/gloshdl.hxx b/sw/source/uibase/inc/gloshdl.hxx index 34bd0f719c65..d065aa9302a5 100644 --- a/sw/source/uibase/inc/gloshdl.hxx +++ b/sw/source/uibase/inc/gloshdl.hxx @@ -39,7 +39,7 @@ class SW_DLLPUBLIC SwGlossaryHdl std::unique_ptr<SwTextBlocks> pCurGrp; - SAL_DLLPRIVATE bool Expand( const OUString& rShortName, + SAL_DLLPRIVATE bool Expand(weld::Window* pParent, const OUString& rShortName, SwGlossaries* pGlossaries, std::unique_ptr<SwTextBlocks> pGlossary ); @@ -70,7 +70,7 @@ public: bool DelGlossary(const OUString&); bool CopyToClipboard(SwWrtShell& rSh, const OUString& rShortName); - bool ExpandGlossary(); + bool ExpandGlossary(weld::Window* pParent); bool InsertGlossary(const OUString &rName); void SetMacros(const OUString& rName, diff --git a/sw/source/uibase/inc/selglos.hxx b/sw/source/uibase/inc/selglos.hxx index a8a0f00c7ff2..28a7821e3c96 100644 --- a/sw/source/uibase/inc/selglos.hxx +++ b/sw/source/uibase/inc/selglos.hxx @@ -19,35 +19,30 @@ #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_SELGLOS_HXX #define INCLUDED_SW_SOURCE_UIBASE_INC_SELGLOS_HXX -#include <vcl/dialog.hxx> +#include <vcl/weld.hxx> -#include <vcl/lstbox.hxx> -#include <vcl/fixed.hxx> - -#include <vcl/button.hxx> - -class SwSelGlossaryDlg final : public ModalDialog +class SwSelGlossaryDlg final : public weld::GenericDialogController { - VclPtr<ListBox> m_pGlosBox; + std::unique_ptr<weld::Frame> m_xFrame; + std::unique_ptr<weld::TreeView> m_xGlosBox; - DECL_LINK(DoubleClickHdl, ListBox&, void); + DECL_LINK(DoubleClickHdl, weld::TreeView&, void); public: - SwSelGlossaryDlg(vcl::Window * pParent, const OUString &rShortName); + SwSelGlossaryDlg(weld::Window * pParent, const OUString &rShortName); virtual ~SwSelGlossaryDlg() override; - virtual void dispose() override; void InsertGlos(const OUString &rRegion, const OUString &rGlosName) { const OUString aTmp = rRegion + ":" + rGlosName; - m_pGlosBox->InsertEntry(aTmp); + m_xGlosBox->append_text(aTmp); } sal_Int32 GetSelectedIdx() const { - return m_pGlosBox->GetSelectedEntryPos(); + return m_xGlosBox->get_selected_index(); } void SelectEntryPos(sal_Int32 nIdx) { - m_pGlosBox->SelectEntryPos(nIdx); + m_xGlosBox->select(nIdx); } }; diff --git a/sw/source/uibase/shells/textglos.cxx b/sw/source/uibase/shells/textglos.cxx index af486517671b..b6aee47f7c55 100644 --- a/sw/source/uibase/shells/textglos.cxx +++ b/sw/source/uibase/shells/textglos.cxx @@ -54,7 +54,7 @@ void SwTextShell::ExecGlossary(SfxRequest &rReq) case FN_EXPAND_GLOSSARY: { bool bReturn; - bReturn = pGlosHdl->ExpandGlossary(); + bReturn = pGlosHdl->ExpandGlossary(rReq.GetFrameWeld()); rReq.SetReturnValue( SfxBoolItem( nSlot, bReturn ) ); rReq.Done(); } |