[Libreoffice-commits] core.git: sw/source sw/uiconfig
Alex McMurchy1917
mcmurchy1917-libreoffice at yahoo.co.uk
Tue Feb 13 13:59:14 UTC 2018
sw/source/ui/dbui/mmoutputtypepage.cxx | 44 ++++++++++++++++++---------------
sw/source/ui/dbui/mmresultdialogs.cxx | 8 +++---
sw/source/ui/inc/mmresultdialogs.hxx | 7 ++---
sw/uiconfig/swriter/ui/mmsendmails.ui | 4 +--
4 files changed, 35 insertions(+), 28 deletions(-)
New commits:
commit bfaa6e35ff09a0426d2c3c9c36f069fabc0c9489
Author: Alex McMurchy1917 <mcmurchy1917-libreoffice at yahoo.co.uk>
Date: Thu Aug 24 14:34:13 2017 +0100
tdf#103919 mailmerge: prevent premature end of emailing
...by changing the parent of SwSendMailDialog.
The destruction of the main dialog (SwMMResultEmailDialog) also
closes the progress dlg (SwSendMailDialog), which shuts down the
dispatcher stopping anymore messages from being sent. Have changed
the parent of progress dlg such that it will not close when the
main dialog is closed. This has allowed the main dialog to be
closed immediately after the progress dialog had been created
making for a cleaner ui.
There were problems with the timer causing LO to consistently crash
during the dispose of OutputDevice, but I could find no logical
reason for the crashes.
(It didn't crash if smtp authentication failed. It also didn't
crash when run in gdb...)
Moving the exit code from StateChanged to CloseHdl magically
fixed the crashing problem. I think it makes it a bit clearer
to end in closeHdl anyway, and start the timer only in case of
an early cancellation (before all the mail messages
have been queued up). This eliminates MOST of the use of the
timer - since the typical exit occurs after the email process
has finished.
Change-Id: Icd3af372772fab3e78eb0702b120d7a811baa6bd
Reviewed-on: https://gerrit.libreoffice.org/41519
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Justin Luth <justin_luth at sil.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
diff --git a/sw/source/ui/dbui/mmoutputtypepage.cxx b/sw/source/ui/dbui/mmoutputtypepage.cxx
index fa01025d3fdd..3adfa2970897 100644
--- a/sw/source/ui/dbui/mmoutputtypepage.cxx
+++ b/sw/source/ui/dbui/mmoutputtypepage.cxx
@@ -240,7 +240,7 @@ SwSendWarningBox_Impl::SwSendWarningBox_Impl(vcl::Window* pParent, const OUStrin
#define ITEMID_STATUS 2
SwSendMailDialog::SwSendMailDialog(vcl::Window *pParent, SwMailMergeConfigItem& rConfigItem) :
- ModelessDialog /*SfxModalDialog*/(pParent, "SendMailsDialog", "modules/swriter/ui/mmsendmails.ui"),
+ Dialog(pParent, "SendMailsDialog", "modules/swriter/ui/mmsendmails.ui"),
m_pTransferStatus(get<FixedText>("transferstatus")),
m_pPaused(get<FixedText>("paused")),
m_pProgressBar(get<ProgressBar>("progress")),
@@ -259,6 +259,7 @@ SwSendMailDialog::SwSendMailDialog(vcl::Window *pParent, SwMailMergeConfigItem&
m_bDestructionEnabled(false),
m_pImpl(new SwSendMailDialog_Impl),
m_pConfigItem(&rConfigItem),
+ m_nExpectedCount(0),
m_nSendCount(0),
m_nErrorCount(0)
{
@@ -289,6 +290,7 @@ SwSendMailDialog::SwSendMailDialog(vcl::Window *pParent, SwMailMergeConfigItem&
m_pStatus->SetTabs(&nTabs[0], MapUnit::MapPixel);
m_pStatus->SetSpaceBetweenEntries(3);
+ m_pPaused->Show(false);
UpdateTransferStatus();
}
@@ -330,7 +332,8 @@ void SwSendMailDialog::dispose()
m_pStatusHB.clear();
m_pStop.clear();
m_pClose.clear();
- ModelessDialog::dispose();
+
+ Dialog::dispose();
}
void SwSendMailDialog::AddDocument( SwMailDescriptor const & rDesc )
@@ -366,7 +369,15 @@ IMPL_LINK( SwSendMailDialog, StopHdl_Impl, Button*, pButton, void )
IMPL_LINK_NOARG(SwSendMailDialog, CloseHdl_Impl, Button*, void)
{
- ModelessDialog::Show( false );
+ Dialog::Show( false );
+
+ if ( m_bDestructionEnabled )
+ disposeOnce();
+ else
+ {
+ m_pImpl->aRemoveIdle.SetInvokeHandler( LINK( this, SwSendMailDialog, RemoveThis ) );
+ m_pImpl->aRemoveIdle.Start();
+ }
}
IMPL_STATIC_LINK( SwSendMailDialog, StartSendMails, void*, pDialog, void )
@@ -512,22 +523,12 @@ void SwSendMailDialog::IterateMails()
UpdateTransferStatus();
}
-void SwSendMailDialog::ShowDialog()
+void SwSendMailDialog::ShowDialog(sal_Int32 nExpectedCount)
{
Application::PostUserEvent( LINK( this, SwSendMailDialog,
StartSendMails ), this, true );
- ModelessDialog::Show();
-}
-
-void SwSendMailDialog::StateChanged( StateChangedType nStateChange )
-{
- ModelessDialog::StateChanged( nStateChange );
- if(StateChangedType::Visible == nStateChange && !IsVisible())
- {
- m_pImpl->aRemoveIdle.SetInvokeHandler( LINK( this, SwSendMailDialog,
- RemoveThis ) );
- m_pImpl->aRemoveIdle.Start();
- }
+ m_nExpectedCount = nExpectedCount > 0 ? nExpectedCount : 1;
+ Dialog::Show();
}
void SwSendMailDialog::DocumentSent( uno::Reference< mail::XMailMessage> const & xMessage,
@@ -565,21 +566,26 @@ void SwSendMailDialog::UpdateTransferStatus()
{
OUString sStatus( m_sTransferStatus );
sStatus = sStatus.replaceFirst("%1", OUString::number(m_nSendCount) );
- sStatus = sStatus.replaceFirst("%2", OUString::number(m_pImpl->aDescriptors.size()));
+ sStatus = sStatus.replaceFirst("%2", OUString::number(m_nExpectedCount));
m_pTransferStatus->SetText(sStatus);
sStatus = m_sErrorStatus.replaceFirst("%1", OUString::number(m_nErrorCount) );
m_pErrorStatus->SetText(sStatus);
if(m_pImpl->aDescriptors.size())
- m_pProgressBar->SetValue(static_cast<sal_uInt16>(m_nSendCount * 100 / m_pImpl->aDescriptors.size()));
+ m_pProgressBar->SetValue(static_cast<sal_uInt16>(m_nSendCount * 100 / m_nExpectedCount));
else
m_pProgressBar->SetValue(0);
}
void SwSendMailDialog::AllMailsSent()
{
- m_pStop->Enable(false);
+ // Leave open if some kind of error occurred
+ if ( m_nSendCount == m_nExpectedCount )
+ {
+ m_pStop->Enable( false );
+ Dialog::Show( false );
+ }
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/dbui/mmresultdialogs.cxx b/sw/source/ui/dbui/mmresultdialogs.cxx
index 61bd63b3efd1..25af6e39e51b 100644
--- a/sw/source/ui/dbui/mmresultdialogs.cxx
+++ b/sw/source/ui/dbui/mmresultdialogs.cxx
@@ -1080,12 +1080,15 @@ IMPL_LINK(SwMMResultEmailDialog, SendDocumentsHdl_Impl, Button*, pButton, void)
xStore->storeToURL( sTargetTempURL, aValues );
//create the send dialog
- VclPtr<SwSendMailDialog> pDlg = VclPtr<SwSendMailDialog>::Create(pButton, *xConfigItem);
- pDlg->ShowDialog();
+ vcl::Window* pParent = Application::GetDefDialogParent();
+ VclPtr<SwSendMailDialog> pDlg = VclPtr<SwSendMailDialog>::Create(pParent, *xConfigItem);
+
+ pDlg->ShowDialog(nEnd - nBegin);
//help to force painting the dialog
//TODO/CLEANUP
//predetermined breaking point
Application::Reschedule( true );
+ endDialog(pButton);
for(sal_uInt32 nDoc = nBegin; nDoc < nEnd; ++nDoc)
{
SwDocMergeInfo& rInfo = xConfigItem->GetDocumentMergeInfo(nDoc);
@@ -1237,7 +1240,6 @@ IMPL_LINK(SwMMResultEmailDialog, SendDocumentsHdl_Impl, Button*, pButton, void)
pDlg->EnableDestruction();
::osl::File::remove( sTargetTempURL );
- endDialog(pButton);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/inc/mmresultdialogs.hxx b/sw/source/ui/inc/mmresultdialogs.hxx
index d892c8a9244a..01e89826372c 100644
--- a/sw/source/ui/inc/mmresultdialogs.hxx
+++ b/sw/source/ui/inc/mmresultdialogs.hxx
@@ -162,7 +162,7 @@ struct SwMailDescriptor
};
struct SwSendMailDialog_Impl;
class SwMailMergeConfigItem;
-class SwSendMailDialog : public ModelessDialog //SfxModalDialog
+class SwSendMailDialog : public Dialog
{
VclPtr<FixedText> m_pTransferStatus;
VclPtr<FixedText> m_pPaused;
@@ -189,6 +189,7 @@ class SwSendMailDialog : public ModelessDialog //SfxModalDialog
SwSendMailDialog_Impl* m_pImpl;
SwMailMergeConfigItem* m_pConfigItem;
+ sal_Int32 m_nExpectedCount;
sal_Int32 m_nSendCount;
sal_Int32 m_nErrorCount;
@@ -202,8 +203,6 @@ class SwSendMailDialog : public ModelessDialog //SfxModalDialog
void SendMails();
void UpdateTransferStatus();
- virtual void StateChanged( StateChangedType nStateChange ) override;
-
public:
SwSendMailDialog( vcl::Window* pParent, SwMailMergeConfigItem& );
virtual ~SwSendMailDialog() override;
@@ -211,7 +210,7 @@ public:
void AddDocument( SwMailDescriptor const & rDesc );
void EnableDestruction() {m_bDestructionEnabled = true;}
- void ShowDialog();
+ void ShowDialog(sal_Int32 nExpectedCount);
void DocumentSent( css::uno::Reference< css::mail::XMailMessage> const & xMessage,
bool bResult,
diff --git a/sw/uiconfig/swriter/ui/mmsendmails.ui b/sw/uiconfig/swriter/ui/mmsendmails.ui
index d53421211188..b4c055f1a71f 100644
--- a/sw/uiconfig/swriter/ui/mmsendmails.ui
+++ b/sw/uiconfig/swriter/ui/mmsendmails.ui
@@ -23,7 +23,7 @@
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="stop">
- <property name="label" translatable="yes" context="mmsendmails|stop">_Stop</property>
+ <property name="label" translatable="yes" context="mmsendmails|stop">_Pause</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -38,7 +38,7 @@
</child>
<child>
<object class="GtkButton" id="close">
- <property name="label">gtk-close</property>
+ <property name="label">gtk-cancel</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
More information about the Libreoffice-commits
mailing list