Kaydet (Commit) 4a1cdfef authored tarafından Caolán McNamara's avatar Caolán McNamara

weld SwMMResultSaveDialog

and set a proper parent for it

Change-Id: Ia03e549e9fdde5925d85af3332d63253d9fbe911
Reviewed-on: https://gerrit.libreoffice.org/54199Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 9f55cc13
......@@ -498,7 +498,7 @@ public:
// for tabpage
virtual CreateTabPage GetTabPageCreatorFunc( sal_uInt16 nId ) = 0;
virtual void ExecuteMMResultSaveDialog() = 0;
virtual void ExecuteMMResultSaveDialog(weld::Window* pParent) = 0;
virtual void ExecuteMMResultPrintDialog(weld::Window* pParent) = 0;
virtual void ExecuteMMResultEmailDialog() = 0;
......
......@@ -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)
......
......@@ -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)
......
......@@ -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;
};
......
......@@ -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.
......
......@@ -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;
}
......
<?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="GtkAdjustment" id="adjustment1">
<property name="lower">1</property>
<property name="upper">100</property>
<property name="value">1</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment2">
<property name="lower">1</property>
<property name="upper">100</property>
<property name="value">1</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkDialog" id="MMResultSaveDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="mmresultsavedialog|MMResultSaveDialog">Save merged document</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>
......@@ -57,6 +77,7 @@
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="secondary">True</property>
</packing>
</child>
</object>
......@@ -99,7 +120,6 @@
<property name="xalign">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">individualrb</property>
</object>
<packing>
<property name="left_attach">0</property>
......@@ -115,7 +135,7 @@
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
<property name="group">fromrb</property>
<property name="group">singlerb</property>
</object>
<packing>
<property name="left_attach">0</property>
......@@ -138,7 +158,7 @@
<property name="draw_indicator">True</property>
<property name="group">singlerb</property>
<accessibility>
<relation type="label-for" target="from-nospin"/>
<relation type="label-for" target="from"/>
</accessibility>
</object>
<packing>
......@@ -152,7 +172,7 @@
<property name="can_focus">False</property>
<property name="label" translatable="yes" context="mmresultsavedialog|toft">_To</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">to-nospin</property>
<property name="mnemonic_widget">to</property>
</object>
<packing>
<property name="left_attach">2</property>
......@@ -160,10 +180,12 @@
</packing>
</child>
<child>
<object class="GtkSpinButton" id="from-nospin">
<object class="GtkSpinButton" id="from">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="text" translatable="no">1</property>
<property name="activates_default">True</property>
<property name="text">1</property>
<property name="adjustment">adjustment1</property>
<accessibility>
<relation type="labelled-by" target="fromrb"/>
</accessibility>
......@@ -174,10 +196,12 @@
</packing>
</child>
<child>
<object class="GtkSpinButton" id="to-nospin">
<object class="GtkSpinButton" id="to">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="activates_default">True</property>
<property name="text">1</property>
<property name="adjustment">adjustment2</property>
</object>
<packing>
<property name="left_attach">3</property>
......
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