diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-04-17 09:51:26 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-04-17 18:05:34 +0200 |
commit | 9a360f993d7a791c548801779d7f444f87541489 (patch) | |
tree | 5e18e3fc390c0719a7bbf39d64fa8e298069aefb /sw/source/ui | |
parent | 73a7c7ddbc52ed3fe512d4c5206e90810f14b50c (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/ui')
-rw-r--r-- | sw/source/ui/dialog/swdlgfact.cxx | 16 | ||||
-rw-r--r-- | sw/source/ui/dialog/swdlgfact.hxx | 11 | ||||
-rw-r--r-- | sw/source/ui/fldui/DropDownFieldDialog.cxx | 125 |
3 files changed, 75 insertions, 77 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: */ |