diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-05-13 19:33:11 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-05-13 21:49:09 +0200 |
commit | 4a1cdfef802deacf119c56ea51d5fddd59aeb17a (patch) | |
tree | 1f9b7857f8db89e61de5b2d09b1157b6e9888694 /sw/source | |
parent | 9f55cc13d64b4c8d60b1ff2e93ed854b0dccad46 (diff) |
weld SwMMResultSaveDialog
and set a proper parent for it
Change-Id: Ia03e549e9fdde5925d85af3332d63253d9fbe911
Reviewed-on: https://gerrit.libreoffice.org/54199
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/dbui/mmresultdialogs.cxx | 87 | ||||
-rw-r--r-- | sw/source/ui/dialog/swdlgfact.cxx | 6 | ||||
-rw-r--r-- | sw/source/ui/dialog/swdlgfact.hxx | 2 | ||||
-rw-r--r-- | sw/source/ui/inc/mmresultdialogs.hxx | 27 | ||||
-rw-r--r-- | sw/source/uibase/app/apphdl.cxx | 2 |
5 files changed, 54 insertions, 70 deletions
diff --git a/sw/source/ui/dbui/mmresultdialogs.cxx b/sw/source/ui/dbui/mmresultdialogs.cxx index b2f8cb2c3d7e..b0c82cbc2ac5 100644 --- a/sw/source/ui/dbui/mmresultdialogs.cxx +++ b/sw/source/ui/dbui/mmresultdialogs.cxx @@ -208,50 +208,36 @@ public: void SetBCC(const OUString& rSet) {m_xBCCED->set_text(rSet);} }; -SwMMResultSaveDialog::SwMMResultSaveDialog() - : SfxModalDialog(nullptr, "MMResultSaveDialog", "modules/swriter/ui/mmresultsavedialog.ui"), - m_bCancelSaving(false) +SwMMResultSaveDialog::SwMMResultSaveDialog(weld::Window* pParent) + : GenericDialogController(pParent, "modules/swriter/ui/mmresultsavedialog.ui", "MMResultSaveDialog") + , m_bCancelSaving(false) + , m_xSaveAsOneRB(m_xBuilder->weld_radio_button("singlerb")) + , m_xSaveIndividualRB(m_xBuilder->weld_radio_button("individualrb")) + , m_xFromRB(m_xBuilder->weld_radio_button("fromrb")) + , m_xFromNF(m_xBuilder->weld_spin_button("from")) + , m_xToFT(m_xBuilder->weld_label("toft")) + , m_xToNF(m_xBuilder->weld_spin_button("to")) + , m_xOKButton(m_xBuilder->weld_button("ok")) { - get(m_pSaveAsOneRB, "singlerb"); - get(m_pSaveIndividualRB, "individualrb"); - get(m_pFromRB, "fromrb"); - get(m_pFromNF, "from-nospin"); - get(m_pToFT, "toft"); - get(m_pToNF, "to-nospin"); - get(m_pOKButton, "ok"); - - Link<Button*,void> aLink = LINK(this, SwMMResultSaveDialog, DocumentSelectionHdl_Impl); - m_pSaveAsOneRB->SetClickHdl(aLink); - m_pSaveIndividualRB->SetClickHdl(aLink); - m_pFromRB->SetClickHdl(aLink); + Link<weld::ToggleButton&,void> aLink = LINK(this, SwMMResultSaveDialog, DocumentSelectionHdl_Impl); + m_xSaveAsOneRB->connect_toggled(aLink); + m_xSaveIndividualRB->connect_toggled(aLink); + m_xFromRB->connect_toggled(aLink); // m_pSaveAsOneRB is the default, so disable m_pFromNF and m_pToNF initially. - aLink.Call(m_pSaveAsOneRB); + aLink.Call(*m_xSaveAsOneRB); SwView* pView = ::GetActiveView(); std::shared_ptr<SwMailMergeConfigItem> xConfigItem = pView->GetMailMergeConfigItem(); assert(xConfigItem); sal_Int32 nCount = xConfigItem->GetMergedDocumentCount(); - m_pToNF->SetMax(nCount); - m_pToNF->SetValue(nCount); + m_xFromNF->set_max(nCount); + m_xToNF->set_max(nCount); + m_xToNF->set_value(nCount); - m_pOKButton->SetClickHdl(LINK(this, SwMMResultSaveDialog, SaveOutputHdl_Impl)); + m_xOKButton->connect_clicked(LINK(this, SwMMResultSaveDialog, SaveOutputHdl_Impl)); } SwMMResultSaveDialog::~SwMMResultSaveDialog() { - disposeOnce(); -} - -void SwMMResultSaveDialog::dispose() -{ - m_pSaveAsOneRB.clear(); - m_pSaveIndividualRB.clear(); - m_pFromRB.clear(); - m_pFromNF.clear(); - m_pToFT.clear(); - m_pToNF.clear(); - m_pOKButton.clear(); - - SfxModalDialog::dispose(); } SwMMResultPrintDialog::SwMMResultPrintDialog(weld::Window* pParent) @@ -440,12 +426,12 @@ void SwMMResultEmailDialog::FillInEmailSettings() } -IMPL_LINK(SwMMResultSaveDialog, DocumentSelectionHdl_Impl, Button*, pButton, void) +IMPL_LINK(SwMMResultSaveDialog, DocumentSelectionHdl_Impl, weld::ToggleButton&, rButton, void) { - bool bEnableFromTo = pButton == m_pFromRB; - m_pFromNF->Enable(bEnableFromTo); - m_pToFT->Enable(bEnableFromTo); - m_pToNF->Enable(bEnableFromTo); + bool bEnableFromTo = &rButton == m_xFromRB.get(); + m_xFromNF->set_sensitive(bEnableFromTo); + m_xToFT->set_sensitive(bEnableFromTo); + m_xToNF->set_sensitive(bEnableFromTo); } IMPL_LINK(SwMMResultPrintDialog, DocumentSelectionHdl_Impl, weld::ToggleButton&, rButton, void) @@ -536,7 +522,7 @@ void endDialog(Button* pButton) } // anonymous namespace -IMPL_LINK(SwMMResultSaveDialog, SaveOutputHdl_Impl, Button*, pButton, void) +IMPL_LINK_NOARG(SwMMResultSaveDialog, SaveOutputHdl_Impl, weld::Button&, void) { SwView* pView = ::GetActiveView(); std::shared_ptr<SwMailMergeConfigItem> xConfigItem = pView->GetMailMergeConfigItem(); @@ -547,10 +533,10 @@ IMPL_LINK(SwMMResultSaveDialog, SaveOutputHdl_Impl, Button*, pButton, void) SwView* pTargetView = xConfigItem->GetTargetView(); assert(pTargetView); - if(m_pSaveAsOneRB->IsChecked()) + if (m_xSaveAsOneRB->get_active()) { OUString sFilter; - const OUString sPath = SwMailMergeHelper::CallSaveAsDialog(GetFrameWeld(), sFilter); + const OUString sPath = SwMailMergeHelper::CallSaveAsDialog(m_xDialog.get(), sFilter); if (sPath.isEmpty()) { // just return back to the dialog @@ -587,20 +573,20 @@ IMPL_LINK(SwMMResultSaveDialog, SaveOutputHdl_Impl, Button*, pButton, void) sal_uInt32 nEnd = 0; sal_uInt32 documentCount = xConfigItem->GetMergedDocumentCount(); - if(m_pSaveIndividualRB->IsChecked()) + if (m_xSaveIndividualRB->get_active()) { nBegin = 0; nEnd = documentCount; } else { - nBegin = static_cast< sal_Int32 >(m_pFromNF->GetValue() - 1); - nEnd = static_cast< sal_Int32 >(m_pToNF->GetValue()); + nBegin = static_cast< sal_Int32 >(m_xFromNF->get_value() - 1); + nEnd = static_cast< sal_Int32 >(m_xToNF->get_value()); if(nEnd > documentCount) nEnd = documentCount; } OUString sFilter; - OUString sPath = SwMailMergeHelper::CallSaveAsDialog(GetFrameWeld(), sFilter); + OUString sPath = SwMailMergeHelper::CallSaveAsDialog(m_xDialog.get(), sFilter); if (sPath.isEmpty()) { // just return back to the dialog @@ -639,7 +625,8 @@ IMPL_LINK(SwMMResultSaveDialog, SaveOutputHdl_Impl, Button*, pButton, void) } SwView* pSourceView = xConfigItem->GetSourceView(); - ScopedVclPtrInstance< PrintMonitor > aSaveMonitor(this, false, PrintMonitor::MONITOR_TYPE_SAVE); +//TODO ScopedVclPtrInstance< PrintMonitor > aSaveMonitor(this, false, PrintMonitor::MONITOR_TYPE_SAVE); + ScopedVclPtrInstance< PrintMonitor > aSaveMonitor(nullptr, false, PrintMonitor::MONITOR_TYPE_SAVE); aSaveMonitor->m_pDocName->SetText(pSourceView->GetDocShell()->GetTitle(22)); aSaveMonitor->SetCancelHdl(LINK(this, SwMMResultSaveDialog, SaveCancelHdl_Impl)); aSaveMonitor->m_pPrinter->SetText( INetURLObject( sPath ).getFSysPath( FSysStyle::Detect ) ); @@ -703,20 +690,20 @@ IMPL_LINK(SwMMResultSaveDialog, SaveOutputHdl_Impl, Button*, pButton, void) if(bFailed) { - std::unique_ptr<SwSaveWarningBox_Impl> xWarning(new SwSaveWarningBox_Impl(pButton->GetFrameWeld(), sOutPath)); + std::unique_ptr<SwSaveWarningBox_Impl> xWarning(new SwSaveWarningBox_Impl(m_xDialog.get(), sOutPath)); if (RET_OK == xWarning->run()) sOutPath = xWarning->GetFileName(); else { xTempDocShell->DoClose(); - endDialog(pButton); + m_xDialog->response(RET_OK); return; } } else { xTempDocShell->DoClose(); - endDialog(pButton); + m_xDialog->response(RET_OK); break; } } @@ -724,7 +711,7 @@ IMPL_LINK(SwMMResultSaveDialog, SaveOutputHdl_Impl, Button*, pButton, void) ::osl::File::remove( sTargetTempURL ); } - endDialog(pButton); + m_xDialog->response(RET_OK); } IMPL_LINK(SwMMResultPrintDialog, PrinterChangeHdl_Impl, weld::ComboBoxText&, rBox, void) diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx index c569a59652c0..b623c5d81a87 100644 --- a/sw/source/ui/dialog/swdlgfact.cxx +++ b/sw/source/ui/dialog/swdlgfact.cxx @@ -1148,10 +1148,10 @@ CreateTabPage SwAbstractDialogFactory_Impl::GetTabPageCreatorFunc( sal_uInt16 nI return pRet; } -void SwAbstractDialogFactory_Impl::ExecuteMMResultSaveDialog() +void SwAbstractDialogFactory_Impl::ExecuteMMResultSaveDialog(weld::Window* pParent) { - ScopedVclPtrInstance<SwMMResultSaveDialog> pDialog; - pDialog->Execute(); + SwMMResultSaveDialog aDialog(pParent); + aDialog.run(); } void SwAbstractDialogFactory_Impl::ExecuteMMResultPrintDialog(weld::Window* pParent) diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx index dd6147e22c1c..60b7072bf4a1 100644 --- a/sw/source/ui/dialog/swdlgfact.hxx +++ b/sw/source/ui/dialog/swdlgfact.hxx @@ -670,7 +670,7 @@ public: // For TabPage virtual CreateTabPage GetTabPageCreatorFunc( sal_uInt16 nId ) override; - virtual void ExecuteMMResultSaveDialog() override; + virtual void ExecuteMMResultSaveDialog(weld::Window* pParent) override; virtual void ExecuteMMResultPrintDialog(weld::Window* pParent) override; virtual void ExecuteMMResultEmailDialog() override; }; diff --git a/sw/source/ui/inc/mmresultdialogs.hxx b/sw/source/ui/inc/mmresultdialogs.hxx index a63a6653c418..c08b9c067f30 100644 --- a/sw/source/ui/inc/mmresultdialogs.hxx +++ b/sw/source/ui/inc/mmresultdialogs.hxx @@ -44,28 +44,25 @@ namespace com{ namespace sun{ namespace star{ }}} /// Dialog implementing the saving as of the result document. -class SwMMResultSaveDialog : public SfxModalDialog +class SwMMResultSaveDialog : public weld::GenericDialogController { - VclPtr<RadioButton> m_pSaveAsOneRB; - VclPtr<RadioButton> m_pSaveIndividualRB; - VclPtr<RadioButton> m_pFromRB; - VclPtr<NumericField> m_pFromNF; - VclPtr<FixedText> m_pToFT; - VclPtr<NumericField> m_pToNF; - - VclPtr<Button> m_pOKButton; - bool m_bCancelSaving; - DECL_LINK(SaveOutputHdl_Impl, Button* , void); + std::unique_ptr<weld::RadioButton> m_xSaveAsOneRB; + std::unique_ptr<weld::RadioButton> m_xSaveIndividualRB; + std::unique_ptr<weld::RadioButton> m_xFromRB; + std::unique_ptr<weld::SpinButton> m_xFromNF; + std::unique_ptr<weld::Label> m_xToFT; + std::unique_ptr<weld::SpinButton> m_xToNF; + std::unique_ptr<weld::Button> m_xOKButton; + + DECL_LINK(SaveOutputHdl_Impl, weld::Button& , void); DECL_LINK(SaveCancelHdl_Impl, Button*, void); - DECL_LINK(DocumentSelectionHdl_Impl, Button*, void); + DECL_LINK(DocumentSelectionHdl_Impl, weld::ToggleButton&, void); public: - SwMMResultSaveDialog(); + SwMMResultSaveDialog(weld::Window* pParent); virtual ~SwMMResultSaveDialog() override; - - virtual void dispose() override; }; /// Dialog implementing the printing of the result document. diff --git a/sw/source/uibase/app/apphdl.cxx b/sw/source/uibase/app/apphdl.cxx index 6be30033a10f..90688e0648b9 100644 --- a/sw/source/uibase/app/apphdl.cxx +++ b/sw/source/uibase/app/apphdl.cxx @@ -815,7 +815,7 @@ void SwModule::ExecOther(SfxRequest& rReq) SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); switch (nWhich) { - case FN_MAILMERGE_SAVE_DOCUMENTS: pFact->ExecuteMMResultSaveDialog(); break; + case FN_MAILMERGE_SAVE_DOCUMENTS: pFact->ExecuteMMResultSaveDialog(rReq.GetFrameWeld()); break; case FN_MAILMERGE_PRINT_DOCUMENTS: pFact->ExecuteMMResultPrintDialog(rReq.GetFrameWeld()); break; case FN_MAILMERGE_EMAIL_DOCUMENTS: pFact->ExecuteMMResultEmailDialog(); break; } |