Kaydet (Commit) 692c4f4d authored tarafından Caolán McNamara's avatar Caolán McNamara

weld SwSelGlossaryDlg

Change-Id: I8d8b4a3b7ed461275eb4af86f3fd7709bab30586
Reviewed-on: https://gerrit.libreoffice.org/61476Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 1dc6a3ae
......@@ -402,9 +402,9 @@ public:
virtual VclPtr<VclAbstractDialog> CreateSwAutoMarkDialog(vcl::Window *pParent, SwWrtShell &rSh) = 0;
virtual VclPtr<AbstractSwSelGlossaryDlg> CreateSwSelGlossaryDlg(const OUString &rShortName) = 0;
virtual VclPtr<AbstractSwSelGlossaryDlg> CreateSwSelGlossaryDlg(weld::Window *pParent, const OUString &rShortName) = 0;
virtual VclPtr<VclAbstractDialog> CreateSwSortingDialog(weld::Window * pParent, SwWrtShell &rSh) = 0;
virtual VclPtr<VclAbstractDialog> CreateSwSortingDialog(weld::Window *pParent, SwWrtShell &rSh) = 0;
virtual VclPtr<VclAbstractDialog> CreateSwTableHeightDialog(weld::Window *pParent, SwWrtShell &rSh) = 0;
virtual VclPtr<VclAbstractDialog> CreateSwColumnDialog(weld::Window *pParent, SwWrtShell &rSh) = 0;
virtual VclPtr<AbstractSplitTableDialog> CreateSplitTableDialog(weld::Window* pParent, SwWrtShell &rSh) = 0;
......
......@@ -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,
......
......@@ -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;
......
......@@ -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: */
......@@ -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);
......
......@@ -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,
......
......@@ -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);
}
};
......
......@@ -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();
}
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.22.1 -->
<interface domain="sw">
<requires lib="gtk+" version="3.18"/>
<object class="GtkDialog" id="InsertAutoTextDialog">
......@@ -7,7 +7,13 @@
<property name="border_width">6</property>
<property name="title" translatable="yes" context="insertautotextdialog|InsertAutoTextDialog">Insert AutoText</property>
<property name="resizable">False</property>
<property name="modal">True</property>
<property name="default_width">0</property>
<property name="default_height">0</property>
<property name="type_hint">dialog</property>
<child>
<placeholder/>
</child>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
......@@ -85,13 +91,22 @@
<property name="top_padding">6</property>
<property name="left_padding">12</property>
<child>
<object class="GtkTreeView" id="treeview:border">
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection1"/>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="treeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection1"/>
</child>
</object>
</child>
</object>
</child>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment