From fa38daf5036fbcf32d3c561840b8e249faba02f2 Mon Sep 17 00:00:00 2001 From: Gülşah Köse Date: Wed, 31 Mar 2021 22:48:03 +0300 Subject: tdf#139906 Prevent to use the Mail Merge wizard without data source. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the file has a data source but that data source is not available in LibreOffice we shouldn't let user continue mail merging. Change-Id: Ic28101a12b2e33e78fd9b478fc41707786344e52 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113432 Tested-by: Jenkins Reviewed-by: Gülşah Köse Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113702 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna --- solenv/sanitizers/ui/modules/swriter.suppr | 1 + sw/source/ui/dbui/mailmergewizard.cxx | 9 +++++++++ sw/source/ui/dbui/mmdocselectpage.cxx | 17 +++++++++++++++-- sw/source/ui/dbui/mmdocselectpage.hxx | 1 + sw/uiconfig/swriter/ui/mmselectpage.ui | 17 ++++++++++++++++- 5 files changed, 42 insertions(+), 3 deletions(-) diff --git a/solenv/sanitizers/ui/modules/swriter.suppr b/solenv/sanitizers/ui/modules/swriter.suppr index 43134e801be7..3bce4efa1af8 100644 --- a/solenv/sanitizers/ui/modules/swriter.suppr +++ b/solenv/sanitizers/ui/modules/swriter.suppr @@ -166,6 +166,7 @@ sw/uiconfig/swriter/ui/mmsendmails.ui://GtkProgressBar[@id='progress'] no-labell sw/uiconfig/swriter/ui/mmsendmails.ui://GtkLabel[@id='errorstatus'] orphan-label sw/uiconfig/swriter/ui/mmsalutationpage.ui://GtkLabel[@id='documentindex'] orphan-label sw/uiconfig/swriter/ui/mmsalutationpage.ui://GtkLabel[@id='femalefi'] orphan-label +sw/uiconfig/swriter/ui/mmselectpage.ui://GtkComboBoxText[@id='recentdoclb'] no-labelled-by sw/uiconfig/swriter/ui/notebookbar_groups.ui://GtkLabel[@id='filegrouplabel'] orphan-label sw/uiconfig/swriter/ui/notebookbar_groups.ui://GtkLabel[@id='clipboardgrouplabel'] orphan-label sw/uiconfig/swriter/ui/notebookbar_groups.ui://svtlo-FontNameBox[@id='fontnamelist'] no-labelled-by diff --git a/sw/source/ui/dbui/mailmergewizard.cxx b/sw/source/ui/dbui/mailmergewizard.cxx index aa18828648fc..50c42b40e7ca 100644 --- a/sw/source/ui/dbui/mailmergewizard.cxx +++ b/sw/source/ui/dbui/mailmergewizard.cxx @@ -147,7 +147,16 @@ void SwMailMergeWizard::enterState( WizardState _nState ) switch(_nState) { case MM_DOCUMENTSELECTPAGE: + { bEnablePrev = false; // the first page + + OUString sDataSourceName = GetSwView()->GetDataSourceName(); + if(!sDataSourceName.isEmpty() && + !SwView::IsDataSourceAvailable(sDataSourceName)) + { + bEnableNext = false; + } + } break; case MM_ADDRESSBLOCKPAGE : bEnableNext = m_xConfigItem->GetResultSet().is(); diff --git a/sw/source/ui/dbui/mmdocselectpage.cxx b/sw/source/ui/dbui/mmdocselectpage.cxx index 21d0f96d74f9..58151d969acf 100644 --- a/sw/source/ui/dbui/mmdocselectpage.cxx +++ b/sw/source/ui/dbui/mmdocselectpage.cxx @@ -53,6 +53,7 @@ SwMailMergeDocSelectPage::SwMailMergeDocSelectPage(weld::Container* pPage, SwMai , m_xBrowseDocPB(m_xBuilder->weld_button("browsedoc")) , m_xBrowseTemplatePB(m_xBuilder->weld_button("browsetemplate")) , m_xRecentDocLB(m_xBuilder->weld_combo_box("recentdoclb")) + , m_xDataSourceWarningFT(m_xBuilder->weld_label("datasourcewarning")) { m_xCurrentDocRB->set_active(true); DocSelectHdl(*m_xNewDocRB); @@ -89,9 +90,21 @@ SwMailMergeDocSelectPage::~SwMailMergeDocSelectPage() IMPL_LINK_NOARG(SwMailMergeDocSelectPage, DocSelectHdl, weld::ToggleButton&, void) { m_xRecentDocLB->set_sensitive(m_xRecentDocRB->get_active()); - m_pWizard->UpdateRoadmap(); - m_pWizard->enableButtons(WizardButtonFlags::NEXT, m_pWizard->isStateEnabled(MM_OUTPUTTYPETPAGE)); + OUString sDataSourceName = m_pWizard->GetSwView()->GetDataSourceName(); + + if(m_xCurrentDocRB->get_active() && + !sDataSourceName.isEmpty() && + !SwView::IsDataSourceAvailable(sDataSourceName)) + { + m_xDataSourceWarningFT->show(); + m_pWizard->enableButtons(WizardButtonFlags::NEXT, false); + } + else + { + m_xDataSourceWarningFT->hide(); + m_pWizard->enableButtons(WizardButtonFlags::NEXT, m_pWizard->isStateEnabled(MM_OUTPUTTYPETPAGE)); + } } IMPL_LINK(SwMailMergeDocSelectPage, FileSelectHdl, weld::Button&, rButton, void) diff --git a/sw/source/ui/dbui/mmdocselectpage.hxx b/sw/source/ui/dbui/mmdocselectpage.hxx index 0930caf03982..eccb3ffdda15 100644 --- a/sw/source/ui/dbui/mmdocselectpage.hxx +++ b/sw/source/ui/dbui/mmdocselectpage.hxx @@ -39,6 +39,7 @@ class SwMailMergeDocSelectPage : public vcl::OWizardPage std::unique_ptr m_xBrowseDocPB; std::unique_ptr m_xBrowseTemplatePB; std::unique_ptr m_xRecentDocLB; + std::unique_ptr m_xDataSourceWarningFT; DECL_LINK(DocSelectHdl, weld::ToggleButton&, void); DECL_LINK(FileSelectHdl, weld::Button&, void); diff --git a/sw/uiconfig/swriter/ui/mmselectpage.ui b/sw/uiconfig/swriter/ui/mmselectpage.ui index 414cb0455ec5..4f5da744c05c 100644 --- a/sw/uiconfig/swriter/ui/mmselectpage.ui +++ b/sw/uiconfig/swriter/ui/mmselectpage.ui @@ -1,5 +1,5 @@ - + @@ -149,6 +149,21 @@ 5 + + + True + False + start + Data source of the current document is not registered. + + + + + + 0 + 8 + + -- cgit