[Libreoffice-commits] core.git: sw/source sw/uiconfig

Gülşah Köse (via logerrit) logerrit at kemper.freedesktop.org
Fri Apr 2 12:11:19 UTC 2021


 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 ++++++++++++++++-
 4 files changed, 41 insertions(+), 3 deletions(-)

New commits:
commit d7d487875246ba00d5be7e4fb0fd82b78fea5205
Author:     Gülşah Köse <gulsah.kose at collabora.com>
AuthorDate: Wed Mar 31 22:48:03 2021 +0300
Commit:     Gülşah Köse <gulsah.kose at collabora.com>
CommitDate: Fri Apr 2 14:10:39 2021 +0200

    tdf#139906 Prevent to use the Mail Merge wizard without data source.
    
    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 <gulsah.kose at collabora.com>

diff --git a/sw/source/ui/dbui/mailmergewizard.cxx b/sw/source/ui/dbui/mailmergewizard.cxx
index bb10a2a9a0da..87116262facf 100644
--- a/sw/source/ui/dbui/mailmergewizard.cxx
+++ b/sw/source/ui/dbui/mailmergewizard.cxx
@@ -142,7 +142,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 f19089126a03..a83a7e727f7b 100644
--- a/sw/source/ui/dbui/mmdocselectpage.cxx
+++ b/sw/source/ui/dbui/mmdocselectpage.cxx
@@ -49,6 +49,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);
@@ -84,9 +85,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 88ac9e40dc8d..67cea59b6450 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<weld::Button> m_xBrowseDocPB;
     std::unique_ptr<weld::Button> m_xBrowseTemplatePB;
     std::unique_ptr<weld::ComboBox> m_xRecentDocLB;
+    std::unique_ptr<weld::Label> 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 eba9c227e7c3..ee125d0e4af6 100644
--- a/sw/uiconfig/swriter/ui/mmselectpage.ui
+++ b/sw/uiconfig/swriter/ui/mmselectpage.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.36.0 -->
+<!-- Generated with glade 3.22.2 -->
 <interface domain="sw">
   <requires lib="gtk+" version="3.20"/>
   <object class="GtkBox" id="MMSelectPage">
@@ -181,6 +181,21 @@
                 <property name="top_attach">5</property>
               </packing>
             </child>
+            <child>
+              <object class="GtkLabel" id="datasourcewarning">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="halign">start</property>
+                <property name="label" translatable="yes" context="mmselectpage|extended_tip|datasourcewarning">Data source of the current document is not registered.</property>
+                <attributes>
+                  <attribute name="foreground" value="#cccc00000000"/>
+                </attributes>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">8</property>
+              </packing>
+            </child>
           </object>
         </child>
         <child type="label">


More information about the Libreoffice-commits mailing list