diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-02-13 17:41:03 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-02-16 00:35:34 +0100 |
commit | 6a3f9de585fc0e8e6191db5210729ae6b3730e7d (patch) | |
tree | 5d053ebe13d08608812c2321dd60a6c9c23ffc70 /sw/source/ui | |
parent | 7faa218231b7a807412feada3aa1223b43b5626e (diff) |
native dialog initial basis
Change-Id: I392be563e38257390f748c70bb71c67a66778ddd
Reviewed-on: https://gerrit.libreoffice.org/49677
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/chrdlg/break.cxx | 168 | ||||
-rw-r--r-- | sw/source/ui/dialog/swdlgfact.cxx | 17 | ||||
-rw-r--r-- | sw/source/ui/dialog/swdlgfact.hxx | 13 |
3 files changed, 97 insertions, 101 deletions
diff --git a/sw/source/ui/chrdlg/break.cxx b/sw/source/ui/chrdlg/break.cxx index 0e2386f64dc6..c6b61d34acce 100644 --- a/sw/source/ui/chrdlg/break.cxx +++ b/sw/source/ui/chrdlg/break.cxx @@ -36,52 +36,52 @@ #include <strings.hrc> #include <SwStyleNameMapper.hxx> -void SwBreakDlg::Apply() +short SwBreakDlg::Execute() { - nKind = 0; - if(m_pLineBtn->IsChecked()) - nKind = 1; - else if(m_pColumnBtn->IsChecked()) - nKind = 2; - else if(m_pPageBtn->IsChecked()) + short nRet = m_xDialog->run(); + if (nRet == RET_OK) { - nKind = 3; - const sal_Int32 nPos = m_pPageCollBox->GetSelectedEntryPos(); - if(0 != nPos && LISTBOX_ENTRY_NOTFOUND != nPos) + nKind = 0; + if (m_xLineBtn->get_active()) + nKind = 1; + else if(m_xColumnBtn->get_active()) + nKind = 2; + else if(m_xPageBtn->get_active()) { - aTemplate = m_pPageCollBox->GetSelectedEntry(); - oPgNum = boost::none; - if (m_pPageNumBox->IsChecked()) + nKind = 3; + const int nPos = m_xPageCollBox->get_active(); + if (nPos != 0 && nPos != -1) { - oPgNum = static_cast<sal_uInt16>(m_pPageNumEdit->GetValue()); + oPgNum = static_cast<sal_uInt16>(m_xPageNumEdit->get_value()); } } } + return nRet; } -IMPL_LINK_NOARG(SwBreakDlg, ClickHdl, Button*, void) +IMPL_LINK_NOARG(SwBreakDlg, ToggleHdl, weld::ToggleButton&, void) { CheckEnable(); } -IMPL_LINK_NOARG(SwBreakDlg, SelectHdl, ListBox&, void) +IMPL_LINK_NOARG(SwBreakDlg, ChangeHdl, weld::ComboBoxText&, void) { CheckEnable(); } // Handler for Change Page Number -IMPL_LINK( SwBreakDlg, PageNumHdl, Button*, pBox, void ) +IMPL_LINK(SwBreakDlg, PageNumHdl, weld::ToggleButton&, rBox, void) { - if(static_cast<CheckBox*>(pBox)->IsChecked()) - m_pPageNumEdit->SetValue(1); + if (rBox.get_active()) + m_xPageNumEdit->set_value(1); else - m_pPageNumEdit->SetText(OUString()); + m_xPageNumEdit->set_text(OUString()); } // By changing the Page number the checkbox is checked. -IMPL_LINK_NOARG(SwBreakDlg, PageNumModifyHdl, Edit&, void) +IMPL_LINK_NOARG(SwBreakDlg, PageNumModifyHdl, weld::SpinButton&, void) { - m_pPageNumBox->Check(); + m_xPageNumBox->set_active(true); } /* @@ -89,21 +89,21 @@ IMPL_LINK_NOARG(SwBreakDlg, PageNumModifyHdl, Edit&, void) * checks whether pagenumber nPage is a legal pagenumber (left pages with even * numbers etc. for a page template with alternating pages) */ -IMPL_LINK_NOARG(SwBreakDlg, OkHdl, Button*, void) +IMPL_LINK_NOARG(SwBreakDlg, OkHdl, weld::Button&, void) { - if(m_pPageNumBox->IsChecked()) { + if (m_xPageNumBox->get_active()) + { // In case of differing page descriptions, test validity - const sal_Int32 nPos = m_pPageCollBox->GetSelectedEntryPos(); + const int nPos = m_xPageCollBox->get_active(); // position 0 says 'Without'. const SwPageDesc *pPageDesc; - if ( 0 != nPos && LISTBOX_ENTRY_NOTFOUND != nPos ) - pPageDesc = rSh.FindPageDescByName( m_pPageCollBox->GetSelectedEntry(), - true ); + if (nPos != 0 && nPos != -1) + pPageDesc = rSh.FindPageDescByName(m_xPageCollBox->get_active_text(), true); else pPageDesc = &rSh.GetPageDesc(rSh.GetCurPageDesc()); OSL_ENSURE(pPageDesc, "Page description not found."); - const sal_uInt16 nUserPage = sal_uInt16(m_pPageNumEdit->GetValue()); + const sal_uInt16 nUserPage = sal_uInt16(m_xPageNumEdit->get_value()); bool bOk = true; switch(pPageDesc->GetUseOn()) { @@ -113,77 +113,65 @@ IMPL_LINK_NOARG(SwBreakDlg, OkHdl, Button*, void) case UseOnPage::Right: bOk = 1 == nUserPage % 2; break; default:; //prevent warning } - if(!bOk) { - ScopedVclPtrInstance<MessageDialog>(this, SwResId(STR_ILLEGAL_PAGENUM), VclMessageType::Info)->Execute(); - m_pPageNumEdit->GrabFocus(); + if(!bOk) + { + std::unique_ptr<weld::Dialog> xDialog(Application::CreateMessageDialog(m_xPageNumEdit.get(), VclMessageType::Info, + VclButtonsType::Ok, SwResId(STR_ILLEGAL_PAGENUM))); + xDialog->run(); + m_xPageNumEdit->grab_focus(); return; } } - EndDialog(RET_OK); + m_xDialog->response(RET_OK); } -SwBreakDlg::SwBreakDlg( vcl::Window *pParent, SwWrtShell &rS ) - : SvxStandardDialog(pParent, "BreakDialog", "modules/swriter/ui/insertbreak.ui") - , rSh(rS) +SwBreakDlg::SwBreakDlg(weld::Window *pParent, SwWrtShell &rS) + : rSh(rS) + , m_xBuilder(Application::CreateBuilder(pParent, "modules/swriter/ui/insertbreak.ui")) , nKind(0) , bHtmlMode(0 != ::GetHtmlMode(rS.GetView().GetDocShell())) { - get(m_pLineBtn, "linerb"); - get(m_pColumnBtn, "columnrb"); - get(m_pPageBtn, "pagerb"); - get(m_pPageCollText, "styleft"); - get(m_pPageCollBox, "stylelb"); - get(m_pPageNumBox, "pagenumcb"); - get(m_pPageNumEdit, "pagenumsb"); - - Link<Button*,void> aLk = LINK(this,SwBreakDlg,ClickHdl); - m_pPageBtn->SetClickHdl( aLk ); - m_pLineBtn->SetClickHdl( aLk ); - m_pColumnBtn->SetClickHdl( aLk ); - m_pPageCollBox->SetSelectHdl( LINK(this,SwBreakDlg,SelectHdl) ); - - get<OKButton>("ok")->SetClickHdl(LINK(this,SwBreakDlg,OkHdl)); - m_pPageNumBox->SetClickHdl(LINK(this,SwBreakDlg,PageNumHdl)); - m_pPageNumEdit->SetModifyHdl(LINK(this,SwBreakDlg,PageNumModifyHdl)); + m_xDialog.reset(m_xBuilder->weld_dialog("BreakDialog")); + m_xLineBtn.reset(m_xBuilder->weld_radio_button("linerb")); + m_xColumnBtn.reset(m_xBuilder->weld_radio_button("columnrb")); + m_xPageBtn.reset(m_xBuilder->weld_radio_button("pagerb")); + m_xPageCollBox.reset(m_xBuilder->weld_combo_box_text("stylelb")); + m_xPageNumBox.reset(m_xBuilder->weld_check_button("pagenumcb")); + m_xPageNumEdit.reset(m_xBuilder->weld_spin_button("pagenumsb")); + m_xPageCollText.reset(m_xBuilder->weld_label("styleft")); + m_xOkBtn.reset(m_xBuilder->weld_button("ok")); + + Link<weld::ToggleButton&,void> aLk = LINK(this, SwBreakDlg, ToggleHdl); + m_xPageBtn->connect_toggled(aLk); + m_xLineBtn->connect_toggled(aLk); + m_xColumnBtn->connect_toggled(aLk); + m_xPageCollBox->connect_changed(LINK(this, SwBreakDlg, ChangeHdl)); + + m_xOkBtn->connect_clicked(LINK(this, SwBreakDlg, OkHdl)); + m_xPageNumBox->connect_toggled(LINK(this, SwBreakDlg, PageNumHdl)); + m_xPageNumEdit->connect_value_changed(LINK(this, SwBreakDlg, PageNumModifyHdl)); // Insert page description to Listbox const size_t nCount = rSh.GetPageDescCnt(); - for( size_t i = 0; i < nCount; ++i) + for (size_t i = 0; i < nCount; ++i) { const SwPageDesc &rPageDesc = rSh.GetPageDesc(i); - ::InsertStringSorted(rPageDesc.GetName(), *m_pPageCollBox, 1 ); + ::InsertStringSorted(rPageDesc.GetName(), *m_xPageCollBox, 1 ); } OUString aFormatName; - for(sal_uInt16 i = RES_POOLPAGE_BEGIN; i < RES_POOLPAGE_END; ++i) + for (sal_uInt16 i = RES_POOLPAGE_BEGIN; i < RES_POOLPAGE_END; ++i) { aFormatName = SwStyleNameMapper::GetUIName( i, aFormatName ); - if(LISTBOX_ENTRY_NOTFOUND == m_pPageCollBox->GetEntryPos(aFormatName)) - ::InsertStringSorted(aFormatName, *m_pPageCollBox, 1 ); + if (m_xPageCollBox->find_text(aFormatName) == -1) + ::InsertStringSorted(aFormatName, *m_xPageCollBox, 1 ); } //add landscape page aFormatName = SwStyleNameMapper::GetUIName( RES_POOLPAGE_LANDSCAPE, aFormatName ); - if(LISTBOX_ENTRY_NOTFOUND == m_pPageCollBox->GetEntryPos(aFormatName)) - ::InsertStringSorted(aFormatName, *m_pPageCollBox, 1 ); + if (m_xPageCollBox->find_text(aFormatName) == -1) + ::InsertStringSorted(aFormatName, *m_xPageCollBox, 1); CheckEnable(); - m_pPageNumEdit->SetText(OUString()); -} - -SwBreakDlg::~SwBreakDlg() -{ - disposeOnce(); -} - -void SwBreakDlg::dispose() -{ - m_pLineBtn.clear(); - m_pColumnBtn.clear(); - m_pPageBtn.clear(); - m_pPageCollText.clear(); - m_pPageCollBox.clear(); - m_pPageNumBox.clear(); - m_pPageNumEdit.clear(); - SvxStandardDialog::dispose(); + m_xPageNumEdit->set_text(OUString()); } void SwBreakDlg::CheckEnable() @@ -191,32 +179,32 @@ void SwBreakDlg::CheckEnable() bool bEnable = true; if ( bHtmlMode ) { - m_pColumnBtn->Enable(false); - m_pPageCollBox->Enable(false); + m_xColumnBtn->set_sensitive(false); + m_xPageCollBox->set_sensitive(false); bEnable = false; } else if(rSh.GetFrameType(nullptr,true) & (FrameTypeFlags::FLY_ANY | FrameTypeFlags::HEADER | FrameTypeFlags::FOOTER | FrameTypeFlags::FOOTNOTE)) { - m_pPageBtn->Enable(false); - if(m_pPageBtn->IsChecked()) - m_pLineBtn->Check(); + m_xPageBtn->set_sensitive(false); + if (m_xPageBtn->get_active()) + m_xLineBtn->set_active(true); bEnable = false; } - const bool bPage = m_pPageBtn->IsChecked(); - m_pPageCollText->Enable( bPage ); - m_pPageCollBox->Enable ( bPage ); + const bool bPage = m_xPageBtn->get_active(); + m_xPageCollText->set_sensitive(bPage); + m_xPageCollBox->set_sensitive(bPage); bEnable &= bPage; if ( bEnable ) { // position 0 says 'Without' page template. - const sal_Int32 nPos = m_pPageCollBox->GetSelectedEntryPos(); - if ( 0 == nPos || LISTBOX_ENTRY_NOTFOUND == nPos ) + const int nPos = m_xPageCollBox->get_active(); + if (nPos == 0 || nPos == -1) bEnable = false; } - m_pPageNumBox->Enable(bEnable); - m_pPageNumEdit->Enable(bEnable); + m_xPageNumBox->set_sensitive(bEnable); + m_xPageNumEdit->set_sensitive(bEnable); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx index 031efef1198e..95f0e34a99bc 100644 --- a/sw/source/ui/dialog/swdlgfact.cxx +++ b/sw/source/ui/dialog/swdlgfact.cxx @@ -93,7 +93,10 @@ IMPL_ABSTDLG_BASE(SwAbstractSfxDialog_Impl); IMPL_ABSTDLG_BASE(AbstractSwAsciiFilterDlg_Impl); IMPL_ABSTDLG_BASE(VclAbstractDialog_Impl); IMPL_ABSTDLG_BASE(AbstractSplitTableDialog_Impl); -IMPL_ABSTDLG_BASE(AbstractSwBreakDlg_Impl); +short AbstractSwBreakDlg_Impl::Execute() +{ + return m_xDlg->Execute(); +} IMPL_ABSTDLG_BASE(AbstractTabDialog_Impl); IMPL_ABSTDLG_BASE(AbstractSwConvertTableDlg_Impl); IMPL_ABSTDLG_BASE(AbstractSwInsertDBColAutoPilot_Impl); @@ -193,17 +196,17 @@ SplitTable_HeadlineOption AbstractSplitTableDialog_Impl::GetSplitMode() OUString AbstractSwBreakDlg_Impl::GetTemplateName() { - return pDlg->GetTemplateName(); + return m_xDlg->GetTemplateName(); } sal_uInt16 AbstractSwBreakDlg_Impl:: GetKind() { - return pDlg->GetKind(); + return m_xDlg->GetKind(); } ::boost::optional<sal_uInt16> AbstractSwBreakDlg_Impl:: GetPageNumber() { - return pDlg->GetPageNumber(); + return m_xDlg->GetPageNumber(); } void AbstractSwConvertTableDlg_Impl::GetValues( sal_Unicode& rDelim,SwInsertTableOptions& rInsTableFlags, @@ -676,11 +679,9 @@ VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwInsertBookmarkDl return VclPtr<VclAbstractDialog_Impl>::Create( pDlg ); } -VclPtr<AbstractSwBreakDlg> SwAbstractDialogFactory_Impl::CreateSwBreakDlg(vcl::Window *pParent, - SwWrtShell &rSh) +VclPtr<AbstractSwBreakDlg> SwAbstractDialogFactory_Impl::CreateSwBreakDlg(weld::Window* pParent, SwWrtShell &rSh) { - VclPtr<SwBreakDlg> pDlg = VclPtr<SwBreakDlg>::Create(pParent, rSh); - return VclPtr<AbstractSwBreakDlg_Impl>::Create(pDlg); + return VclPtr<AbstractSwBreakDlg_Impl>::Create(new SwBreakDlg(pParent, rSh)); } VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwChangeDBDlg(SwView& rVw) diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx index 2eeca35fa7f8..dbc95b9c31e9 100644 --- a/sw/source/ui/dialog/swdlgfact.hxx +++ b/sw/source/ui/dialog/swdlgfact.hxx @@ -103,12 +103,19 @@ class VclAbstractDialog_Impl : public VclAbstractDialog class AbstractSwBreakDlg_Impl : public AbstractSwBreakDlg { - DECL_ABSTDLG_BASE(AbstractSwBreakDlg_Impl,SwBreakDlg) +protected: + std::unique_ptr<SwBreakDlg> m_xDlg; +public: + explicit AbstractSwBreakDlg_Impl(SwBreakDlg* p) + : m_xDlg(p) + { + } + virtual short Execute() override; virtual OUString GetTemplateName() override; virtual sal_uInt16 GetKind() override; virtual ::boost::optional<sal_uInt16> GetPageNumber() override; - }; + class AbstractSplitTableDialog_Impl : public AbstractSplitTableDialog // add for { DECL_ABSTDLG_BASE(AbstractSplitTableDialog_Impl, SwSplitTableDlg) @@ -384,7 +391,7 @@ public: virtual VclPtr<AbstractSwAsciiFilterDlg> CreateSwAsciiFilterDlg ( SwDocShell& rDocSh, SvStream* pStream ) override; virtual VclPtr<VclAbstractDialog> CreateSwInsertBookmarkDlg( vcl::Window *pParent, SwWrtShell &rSh, SfxRequest& rReq ) override; - virtual VclPtr<AbstractSwBreakDlg> CreateSwBreakDlg(vcl::Window *pParent, SwWrtShell &rSh) override; + virtual VclPtr<AbstractSwBreakDlg> CreateSwBreakDlg(weld::Window *pParent, SwWrtShell &rSh) override; virtual VclPtr<VclAbstractDialog> CreateSwChangeDBDlg(SwView& rVw) override; virtual VclPtr<SfxAbstractTabDialog> CreateSwCharDlg(vcl::Window* pParent, SwView& pVw, const SfxItemSet& rCoreSet, SwCharDlgMode nDialogMode, const OUString* pFormatStr = nullptr) override; |