summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-04-17 09:51:26 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-04-17 18:05:34 +0200
commit9a360f993d7a791c548801779d7f444f87541489 (patch)
tree5e18e3fc390c0719a7bbf39d64fa8e298069aefb /sw/source
parent73a7c7ddbc52ed3fe512d4c5206e90810f14b50c (diff)
weld DropDownFieldDialog
Change-Id: I58ceb44f96d8ae3e3732b85eafd44c4d6eab42aa Reviewed-on: https://gerrit.libreoffice.org/53035 Tested-by: Jenkins <ci@libreoffice.org> 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.cxx16
-rw-r--r--sw/source/ui/dialog/swdlgfact.hxx11
-rw-r--r--sw/source/ui/fldui/DropDownFieldDialog.cxx125
-rw-r--r--sw/source/uibase/inc/DropDownFieldDialog.hxx48
-rw-r--r--sw/source/uibase/inc/wrtsh.hxx2
-rw-r--r--sw/source/uibase/wrtsh/wrtsh2.cxx9
6 files changed, 105 insertions, 106 deletions
diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx
index cf431989c93f..fd0e2009e953 100644
--- a/sw/source/ui/dialog/swdlgfact.cxx
+++ b/sw/source/ui/dialog/swdlgfact.cxx
@@ -133,7 +133,12 @@ short AbstractSwConvertTableDlg_Impl::Execute()
return m_xDlg->run();
}
IMPL_ABSTDLG_BASE(AbstractSwInsertDBColAutoPilot_Impl);
-IMPL_ABSTDLG_BASE(AbstractDropDownFieldDialog_Impl);
+
+short AbstractDropDownFieldDialog_Impl::Execute()
+{
+ return m_xDlg->execute();
+}
+
IMPL_ABSTDLG_BASE(AbstractSwLabDlg_Impl);
IMPL_ABSTDLG_BASE(AbstractSwSelGlossaryDlg_Impl);
short AbstractSwAutoFormatDlg_Impl::Execute()
@@ -281,12 +286,12 @@ void AbstractSwInsertDBColAutoPilot_Impl::DataToDoc( const uno::Sequence< uno::A
bool AbstractDropDownFieldDialog_Impl::PrevButtonPressed() const
{
- return pDlg->PrevButtonPressed();
+ return m_xDlg->PrevButtonPressed();
}
bool AbstractDropDownFieldDialog_Impl::NextButtonPressed() const
{
- return pDlg->NextButtonPressed();
+ return m_xDlg->NextButtonPressed();
}
void AbstractSwLabDlg_Impl::SetCurPageId( sal_uInt16 nId )
@@ -758,11 +763,10 @@ VclPtr<SfxAbstractTabDialog> SwAbstractDialogFactory_Impl::CreateSwFootNoteOptio
return VclPtr<AbstractTabDialog_Impl>::Create( pDlg );
}
-VclPtr<AbstractDropDownFieldDialog> SwAbstractDialogFactory_Impl::CreateDropDownFieldDialog(
+VclPtr<AbstractDropDownFieldDialog> SwAbstractDialogFactory_Impl::CreateDropDownFieldDialog(weld::Window *pParent,
SwWrtShell &rSh, SwField* pField, bool bPrevButton, bool bNextButton)
{
- VclPtr<sw::DropDownFieldDialog> pDlg = VclPtr<sw::DropDownFieldDialog>::Create(nullptr, rSh, pField, bPrevButton, bNextButton);
- return VclPtr<AbstractDropDownFieldDialog_Impl>::Create( pDlg );
+ return VclPtr<AbstractDropDownFieldDialog_Impl>::Create(new sw::DropDownFieldDialog(pParent, rSh, pField, bPrevButton, bNextButton));
}
VclPtr<SfxAbstractTabDialog> SwAbstractDialogFactory_Impl::CreateSwEnvDlg ( vcl::Window* pParent, const SfxItemSet& rSet,
diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx
index b708efc4098c..48fd7f95c91f 100644
--- a/sw/source/ui/dialog/swdlgfact.hxx
+++ b/sw/source/ui/dialog/swdlgfact.hxx
@@ -262,7 +262,14 @@ class AbstractSwInsertDBColAutoPilot_Impl : public AbstractSwInsertDBColAutoPil
class AbstractDropDownFieldDialog_Impl : public AbstractDropDownFieldDialog
{
- DECL_ABSTDLG_BASE(AbstractDropDownFieldDialog_Impl, sw::DropDownFieldDialog)
+protected:
+ std::unique_ptr<sw::DropDownFieldDialog> m_xDlg;
+public:
+ explicit AbstractDropDownFieldDialog_Impl(sw::DropDownFieldDialog* p)
+ : m_xDlg(p)
+ {
+ }
+ virtual short Execute() override;
virtual bool PrevButtonPressed() const override;
virtual bool NextButtonPressed() const override;
};
@@ -537,7 +544,7 @@ public:
const SwDBData& rData) override;
virtual VclPtr<SfxAbstractTabDialog> CreateSwFootNoteOptionDlg(vcl::Window *pParent, SwWrtShell &rSh) override;
- virtual VclPtr<AbstractDropDownFieldDialog> CreateDropDownFieldDialog(SwWrtShell &rSh,
+ virtual VclPtr<AbstractDropDownFieldDialog> CreateDropDownFieldDialog(weld::Window* pParent, SwWrtShell &rSh,
SwField* pField, bool bPrevButton, bool bNextButton) override;
virtual VclPtr<SfxAbstractTabDialog> CreateSwEnvDlg ( vcl::Window* pParent, const SfxItemSet& rSet, SwWrtShell* pWrtSh, Printer* pPrt, bool bInsert ) override;
virtual VclPtr<AbstractSwLabDlg> CreateSwLabDlg(const SfxItemSet& rSet,
diff --git a/sw/source/ui/fldui/DropDownFieldDialog.cxx b/sw/source/ui/fldui/DropDownFieldDialog.cxx
index 8de7bd7c32d8..d21758e062dc 100644
--- a/sw/source/ui/fldui/DropDownFieldDialog.cxx
+++ b/sw/source/ui/fldui/DropDownFieldDialog.cxx
@@ -28,126 +28,113 @@
using namespace ::com::sun::star;
// edit insert-field
-sw::DropDownFieldDialog::DropDownFieldDialog(vcl::Window *pParent, SwWrtShell &rS,
+sw::DropDownFieldDialog::DropDownFieldDialog(weld::Window *pParent, SwWrtShell &rS,
SwField* pField, bool bPrevButton, bool bNextButton)
- : SvxStandardDialog(pParent, "DropdownFieldDialog",
- "modules/swriter/ui/dropdownfielddialog.ui")
- , rSh( rS )
- , pDropField(nullptr)
+ : GenericDialogController(pParent, "modules/swriter/ui/dropdownfielddialog.ui", "DropdownFieldDialog")
+ , m_rSh( rS )
+ , m_pDropField(nullptr)
, m_pPressedButton(nullptr)
+ , m_xListItemsLB(m_xBuilder->weld_tree_view("list"))
+ , m_xOKPB(m_xBuilder->weld_button("ok"))
+ , m_xPrevPB(m_xBuilder->weld_button("prev"))
+ , m_xNextPB(m_xBuilder->weld_button("next"))
+ , m_xEditPB(m_xBuilder->weld_button("edit"))
{
- get(m_pListItemsLB, "list");
- m_pListItemsLB->SetDropDownLineCount(12);
- m_pListItemsLB->set_width_request(m_pListItemsLB->approximate_char_width()*32);
- get(m_pOKPB, "ok");
- get(m_pPrevPB, "prev");
- get(m_pNextPB, "next");
- get(m_pEditPB, "edit");
- Link<ListBox&, void> aDoubleLk = LINK(this, DropDownFieldDialog, DoubleClickHdl);
- m_pListItemsLB->SetDoubleClickHdl( aDoubleLk );
-
- Link<Button*, void> aEditButtonLk = LINK(this, DropDownFieldDialog, EditHdl);
- Link<Button*,void> aPrevButtonLk = LINK(this, DropDownFieldDialog, PrevHdl);
- Link<Button*, void> aNextButtonLk = LINK(this, DropDownFieldDialog, NextHdl);
- m_pEditPB->SetClickHdl(aEditButtonLk);
+ m_xListItemsLB->set_size_request(m_xListItemsLB->get_approximate_digit_width() * 24,
+ m_xListItemsLB->get_height_rows(12));
+ Link<weld::TreeView&, void> aDoubleLk = LINK(this, DropDownFieldDialog, DoubleClickHdl);
+ m_xListItemsLB->connect_row_activated( aDoubleLk );
+
+ Link<weld::Button&, void> aEditButtonLk = LINK(this, DropDownFieldDialog, EditHdl);
+ Link<weld::Button&,void> aPrevButtonLk = LINK(this, DropDownFieldDialog, PrevHdl);
+ Link<weld::Button&, void> aNextButtonLk = LINK(this, DropDownFieldDialog, NextHdl);
+ m_xEditPB->connect_clicked(aEditButtonLk);
if( bPrevButton || bNextButton )
{
- m_pPrevPB->Show();
- m_pPrevPB->SetClickHdl(aPrevButtonLk);
- m_pPrevPB->Enable(bPrevButton);
+ m_xPrevPB->show();
+ m_xPrevPB->connect_clicked(aPrevButtonLk);
+ m_xPrevPB->set_sensitive(bPrevButton);
- m_pNextPB->Show();
- m_pNextPB->SetClickHdl(aNextButtonLk);
- m_pNextPB->Enable(bNextButton);
+ m_xNextPB->show();
+ m_xNextPB->connect_clicked(aNextButtonLk);
+ m_xNextPB->set_sensitive(bNextButton);
}
if( SwFieldIds::Dropdown == pField->GetTyp()->Which() )
{
- pDropField = static_cast<SwDropDownField*>(pField);
- OUString sTitle = GetText();
- sTitle += pDropField->GetPar2();
- SetText(sTitle);
- uno::Sequence< OUString > aItems = pDropField->GetItemSequence();
+ m_pDropField = static_cast<SwDropDownField*>(pField);
+ OUString sTitle = m_xDialog->get_title();
+ sTitle += m_pDropField->GetPar2();
+ m_xDialog->set_title(sTitle);
+ uno::Sequence< OUString > aItems = m_pDropField->GetItemSequence();
const OUString* pArray = aItems.getConstArray();
- for(sal_Int32 i = 0; i < aItems.getLength(); i++)
- m_pListItemsLB->InsertEntry(pArray[i]);
- m_pListItemsLB->SelectEntry(pDropField->GetSelectedItem());
+ for (sal_Int32 i = 0; i < aItems.getLength(); ++i)
+ m_xListItemsLB->append_text(pArray[i]);
+ m_xListItemsLB->select(m_pDropField->GetSelectedItem());
}
- bool bEnable = !rSh.IsCursorReadonly();
- m_pOKPB->Enable( bEnable );
+ bool bEnable = !m_rSh.IsCursorReadonly();
+ m_xOKPB->set_sensitive(bEnable);
- m_pListItemsLB->GrabFocus();
+ m_xListItemsLB->grab_focus();
}
sw::DropDownFieldDialog::~DropDownFieldDialog()
{
- disposeOnce();
-}
-
-void sw::DropDownFieldDialog::dispose()
-{
- m_pListItemsLB.clear();
- m_pOKPB.clear();
- m_pPrevPB.clear();
- m_pNextPB.clear();
- m_pEditPB.clear();
- m_pPressedButton.clear();
- SvxStandardDialog::dispose();
}
void sw::DropDownFieldDialog::Apply()
{
- if(pDropField)
+ if (m_pDropField)
{
- OUString sSelect = m_pListItemsLB->GetSelectedEntry();
- if(pDropField->GetPar1() != sSelect)
+ OUString sSelect = m_xListItemsLB->get_selected();
+ if (m_pDropField->GetPar1() != sSelect)
{
- rSh.StartAllAction();
+ m_rSh.StartAllAction();
std::unique_ptr<SwDropDownField> const pCopy(
- static_cast<SwDropDownField *>( pDropField->CopyField() ) );
+ static_cast<SwDropDownField*>(m_pDropField->CopyField()));
pCopy->SetPar1(sSelect);
- rSh.SwEditShell::UpdateFields(*pCopy);
+ m_rSh.SwEditShell::UpdateFields(*pCopy);
- rSh.SetUndoNoResetModified();
- rSh.EndAllAction();
+ m_rSh.SetUndoNoResetModified();
+ m_rSh.EndAllAction();
}
}
}
bool sw::DropDownFieldDialog::PrevButtonPressed() const
{
- return m_pPressedButton == m_pPrevPB;
+ return m_pPressedButton == m_xPrevPB.get();
}
bool sw::DropDownFieldDialog::NextButtonPressed() const
{
- return m_pPressedButton == m_pNextPB;
+ return m_pPressedButton == m_xNextPB.get();
}
-IMPL_LINK_NOARG(sw::DropDownFieldDialog, EditHdl, Button*, void)
+IMPL_LINK_NOARG(sw::DropDownFieldDialog, EditHdl, weld::Button&, void)
{
- m_pPressedButton = m_pEditPB;
- EndDialog(RET_OK);
+ m_pPressedButton = m_xEditPB.get();
+ m_xDialog->response(RET_OK);
}
-IMPL_LINK_NOARG(sw::DropDownFieldDialog, PrevHdl, Button*, void)
+IMPL_LINK_NOARG(sw::DropDownFieldDialog, PrevHdl, weld::Button&, void)
{
- m_pPressedButton = m_pPrevPB;
- EndDialog(RET_OK);
+ m_pPressedButton = m_xPrevPB.get();
+ m_xDialog->response(RET_OK);
}
-IMPL_LINK_NOARG(sw::DropDownFieldDialog, NextHdl, Button*, void)
+IMPL_LINK_NOARG(sw::DropDownFieldDialog, NextHdl, weld::Button&, void)
{
- m_pPressedButton = m_pNextPB;
- EndDialog(RET_OK);
+ m_pPressedButton = m_xNextPB.get();
+ m_xDialog->response(RET_OK);
}
-IMPL_LINK_NOARG(sw::DropDownFieldDialog, DoubleClickHdl, ListBox&, void)
+IMPL_LINK_NOARG(sw::DropDownFieldDialog, 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/inc/DropDownFieldDialog.hxx b/sw/source/uibase/inc/DropDownFieldDialog.hxx
index b2dbffaefa2c..13f3946a4679 100644
--- a/sw/source/uibase/inc/DropDownFieldDialog.hxx
+++ b/sw/source/uibase/inc/DropDownFieldDialog.hxx
@@ -19,10 +19,7 @@
#ifndef INCLUDED_SW_SOURCE_UIBASE_INC_DROPDOWNFIELDDIALOG_HXX
#define INCLUDED_SW_SOURCE_UIBASE_INC_DROPDOWNFIELDDIALOG_HXX
-#include <svx/stddlg.hxx>
-#include <vcl/fixed.hxx>
-#include <vcl/lstbox.hxx>
-#include <vcl/button.hxx>
+#include <vcl/weld.hxx>
class SwDropDownField;
class SwField;
@@ -31,33 +28,36 @@ class SwWrtShell;
// Dialog to edit drop down field selection
namespace sw
{
-class DropDownFieldDialog : public SvxStandardDialog
+class DropDownFieldDialog : public weld::GenericDialogController
{
- VclPtr<ListBox> m_pListItemsLB;
+ SwWrtShell &m_rSh;
+ SwDropDownField* m_pDropField;
- VclPtr<OKButton> m_pOKPB;
- VclPtr<PushButton> m_pPrevPB;
- VclPtr<PushButton> m_pNextPB;
+ weld::Button* m_pPressedButton;
+ std::unique_ptr<weld::TreeView> m_xListItemsLB;
+ std::unique_ptr<weld::Button> m_xOKPB;
+ std::unique_ptr<weld::Button> m_xPrevPB;
+ std::unique_ptr<weld::Button> m_xNextPB;
+ std::unique_ptr<weld::Button> m_xEditPB;
- VclPtr<PushButton> m_pEditPB;
-
- SwWrtShell &rSh;
- SwDropDownField* pDropField;
-
- VclPtr<PushButton> m_pPressedButton;
-
- DECL_LINK(EditHdl, Button*, void);
- DECL_LINK(PrevHdl, Button*, void);
- DECL_LINK(NextHdl, Button*, void);
- virtual void Apply() override;
- DECL_LINK(DoubleClickHdl, ListBox&, void);
+ DECL_LINK(EditHdl, weld::Button&, void);
+ DECL_LINK(PrevHdl, weld::Button&, void);
+ DECL_LINK(NextHdl, weld::Button&, void);
+ void Apply();
+ DECL_LINK(DoubleClickHdl, weld::TreeView&, void);
public:
- DropDownFieldDialog( vcl::Window *pParent, SwWrtShell &rSh,
- SwField* pField, bool bPrevButton, bool bNextButton );
+ DropDownFieldDialog(weld::Window *pParent, SwWrtShell &rSh,
+ SwField* pField, bool bPrevButton, bool bNextButton);
virtual ~DropDownFieldDialog() override;
- virtual void dispose() override;
bool PrevButtonPressed() const;
bool NextButtonPressed() const;
+ short execute()
+ {
+ short nRet = run();
+ if (nRet == RET_OK)
+ Apply();
+ return nRet;
+ }
};
} //namespace sw
diff --git a/sw/source/uibase/inc/wrtsh.hxx b/sw/source/uibase/inc/wrtsh.hxx
index e9ba09ceafb1..3b593928cc9b 100644
--- a/sw/source/uibase/inc/wrtsh.hxx
+++ b/sw/source/uibase/inc/wrtsh.hxx
@@ -396,7 +396,7 @@ typedef bool (SwWrtShell:: *FNSimpleMove)();
// update input fields
bool StartInputFieldDlg(SwField*, bool bPrevButton, bool bNextButton, weld::Window* pParentWin, FieldDialogPressedButton* pPressedButton = nullptr);
// update DropDown fields
- bool StartDropDownFieldDlg(SwField*, bool bPrevButton, bool bNextButton, FieldDialogPressedButton* pPressedButton = nullptr);
+ bool StartDropDownFieldDlg(SwField*, bool bPrevButton, bool bNextButton, weld::Window* pParentWin, FieldDialogPressedButton* pPressedButton = nullptr);
//"Handler" for changes at DrawView - for controls.
virtual void DrawSelChanged( ) override;
diff --git a/sw/source/uibase/wrtsh/wrtsh2.cxx b/sw/source/uibase/wrtsh/wrtsh2.cxx
index 0a5525bbce97..fd1b177a7322 100644
--- a/sw/source/uibase/wrtsh/wrtsh2.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh2.cxx
@@ -168,7 +168,7 @@ void SwWrtShell::UpdateInputFields( SwInputFieldList* pLst )
pField = pTmp->GetField(nIndex);
if (pField->GetTyp()->Which() == SwFieldIds::Dropdown)
{
- bCancel = StartDropDownFieldDlg(pField, bPrev, bNext, &ePressedButton);
+ bCancel = StartDropDownFieldDlg(pField, bPrev, bNext, GetView().GetFrameWeld(), &ePressedButton);
}
else
bCancel = StartInputFieldDlg(pField, bPrev, bNext, GetView().GetFrameWeld(), &ePressedButton);
@@ -279,12 +279,13 @@ bool SwWrtShell::StartInputFieldDlg(SwField* pField, bool bPrevButton, bool bNex
return bRet;
}
-bool SwWrtShell::StartDropDownFieldDlg(SwField* pField, bool bPrevButton, bool bNextButton, SwWrtShell::FieldDialogPressedButton* pPressedButton)
+bool SwWrtShell::StartDropDownFieldDlg(SwField* pField, bool bPrevButton, bool bNextButton,
+ weld::Window* pParentWin, SwWrtShell::FieldDialogPressedButton* pPressedButton)
{
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
- ScopedVclPtr<AbstractDropDownFieldDialog> pDlg(pFact->CreateDropDownFieldDialog(*this, pField, bPrevButton, bNextButton));
+ ScopedVclPtr<AbstractDropDownFieldDialog> pDlg(pFact->CreateDropDownFieldDialog(pParentWin, *this, pField, bPrevButton, bNextButton));
OSL_ENSURE(pDlg, "Dialog creation failed!");
const short nRet = pDlg->Execute();
@@ -430,7 +431,7 @@ void SwWrtShell::ClickToField( const SwField& rField )
StartInputFieldDlg(const_cast<SwField*>(&rField), false, false, GetView().GetFrameWeld());
break;
case SwFieldIds::Dropdown :
- StartDropDownFieldDlg( const_cast<SwField*>(&rField), false, false );
+ StartDropDownFieldDlg(const_cast<SwField*>(&rField), false, false, GetView().GetFrameWeld());
break;
default:
SAL_WARN_IF(rField.IsClickable(), "sw", "unhandled clickable field!");