sw/source/ui/dbui/mmdocselectpage.cxx | 29 +++++++++++++++++++++++++++- sw/source/ui/dbui/mmdocselectpage.hxx | 2 + sw/uiconfig/swriter/ui/mmselectpage.ui | 34 ++++++++++++++++++++++++--------- 3 files changed, 55 insertions(+), 10 deletions(-)
New commits: commit a809b2ab2553e946431699d9d7ac3f6209cbdd6b Author: Gülşah Köse <gulsah.k...@collabora.com> AuthorDate: Tue Apr 13 08:48:32 2021 +0300 Commit: Gülşah Köse <gulsah.k...@collabora.com> CommitDate: Fri Apr 16 00:00:53 2021 +0200 tdf#139906 Add an option to change data source from mail merge wizard dialog. Change-Id: I52dfd9be82813a1b01c725eab97a7534ae9a05d2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114079 Tested-by: Jenkins Reviewed-by: Gülşah Köse <gulsah.k...@collabora.com> diff --git a/sw/source/ui/dbui/mmdocselectpage.cxx b/sw/source/ui/dbui/mmdocselectpage.cxx index a83a7e727f7b..26e3a34d3a84 100644 --- a/sw/source/ui/dbui/mmdocselectpage.cxx +++ b/sw/source/ui/dbui/mmdocselectpage.cxx @@ -29,7 +29,7 @@ #include <mailmergewizard.hxx> #include <swabstdlg.hxx> #include <mmconfigitem.hxx> - +#include <swuiexp.hxx> #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> #include <com/sun/star/ui/dialogs/XFilePicker3.hpp> @@ -50,6 +50,7 @@ SwMailMergeDocSelectPage::SwMailMergeDocSelectPage(weld::Container* pPage, SwMai , m_xBrowseTemplatePB(m_xBuilder->weld_button("browsetemplate")) , m_xRecentDocLB(m_xBuilder->weld_combo_box("recentdoclb")) , m_xDataSourceWarningFT(m_xBuilder->weld_label("datasourcewarning")) + , m_xExchangeDatabasePB(m_xBuilder->weld_button("exchangedatabase")) { m_xCurrentDocRB->set_active(true); DocSelectHdl(*m_xNewDocRB); @@ -65,6 +66,9 @@ SwMailMergeDocSelectPage::SwMailMergeDocSelectPage(weld::Container* pPage, SwMai m_xBrowseDocPB->connect_clicked(aFileSelectHdl); m_xBrowseTemplatePB->connect_clicked(aFileSelectHdl); + Link<weld::Button&,void> aExchangeDatabaseHdl = LINK(this, SwMailMergeDocSelectPage, ExchangeDatabaseHdl); + m_xExchangeDatabasePB->connect_clicked(aExchangeDatabaseHdl); + const uno::Sequence< OUString >& rDocs = m_pWizard->GetConfigItem().GetSavedDocuments(); for(const auto& rDoc : rDocs) @@ -100,6 +104,11 @@ IMPL_LINK_NOARG(SwMailMergeDocSelectPage, DocSelectHdl, weld::ToggleButton&, voi m_xDataSourceWarningFT->hide(); m_pWizard->enableButtons(WizardButtonFlags::NEXT, m_pWizard->isStateEnabled(MM_OUTPUTTYPETPAGE)); } + + if(m_xCurrentDocRB->get_active()) + m_xExchangeDatabasePB->set_sensitive(true); + else + m_xExchangeDatabasePB->set_sensitive(false); } IMPL_LINK(SwMailMergeDocSelectPage, FileSelectHdl, weld::Button&, rButton, void) @@ -155,6 +164,24 @@ IMPL_LINK(SwMailMergeDocSelectPage, FileSelectHdl, weld::Button&, rButton, void) m_pWizard->enableButtons(WizardButtonFlags::NEXT, m_pWizard->isStateEnabled(MM_OUTPUTTYPETPAGE)); } +IMPL_LINK_NOARG(SwMailMergeDocSelectPage, ExchangeDatabaseHdl, weld::Button&, void) +{ + + SwAbstractDialogFactory& rFact = ::swui::GetFactory(); + ScopedVclPtr<VclAbstractDialog> pDlg(rFact.CreateSwChangeDBDlg(*m_pWizard->GetSwView())); + pDlg->Execute(); + + OUString sDataSourceName = m_pWizard->GetSwView()->GetDataSourceName(); + + if(m_xCurrentDocRB->get_active() && + !sDataSourceName.isEmpty() && + SwView::IsDataSourceAvailable(sDataSourceName)) + { + m_xDataSourceWarningFT->hide(); + m_pWizard->enableButtons(WizardButtonFlags::NEXT, true); + } +} + bool SwMailMergeDocSelectPage::commitPage( ::vcl::WizardTypes::CommitPageReason _eReason ) { bool bReturn = false; diff --git a/sw/source/ui/dbui/mmdocselectpage.hxx b/sw/source/ui/dbui/mmdocselectpage.hxx index 67cea59b6450..5220c3fd7fe2 100644 --- a/sw/source/ui/dbui/mmdocselectpage.hxx +++ b/sw/source/ui/dbui/mmdocselectpage.hxx @@ -40,9 +40,11 @@ class SwMailMergeDocSelectPage : public vcl::OWizardPage std::unique_ptr<weld::Button> m_xBrowseTemplatePB; std::unique_ptr<weld::ComboBox> m_xRecentDocLB; std::unique_ptr<weld::Label> m_xDataSourceWarningFT; + std::unique_ptr<weld::Button> m_xExchangeDatabasePB; DECL_LINK(DocSelectHdl, weld::ToggleButton&, void); DECL_LINK(FileSelectHdl, weld::Button&, void); + DECL_LINK(ExchangeDatabaseHdl, weld::Button&, void); virtual bool commitPage(::vcl::WizardTypes::CommitPageReason _eReason) override; diff --git a/sw/uiconfig/swriter/ui/mmselectpage.ui b/sw/uiconfig/swriter/ui/mmselectpage.ui index ee125d0e4af6..cb8b5dae430c 100644 --- a/sw/uiconfig/swriter/ui/mmselectpage.ui +++ b/sw/uiconfig/swriter/ui/mmselectpage.ui @@ -23,6 +23,7 @@ <property name="row_spacing">6</property> <property name="margin-start">12</property> <property name="margin-top">6</property> + <child> <object class="GtkRadioButton" id="currentdoc"> <property name="label" translatable="yes" context="mmselectpage|currentdoc">Use the current _document</property> @@ -60,7 +61,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">1</property> + <property name="top_attach">3</property> </packing> </child> <child> @@ -81,7 +82,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">2</property> + <property name="top_attach">4</property> </packing> </child> <child> @@ -102,7 +103,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">4</property> + <property name="top_attach">6</property> </packing> </child> <child> @@ -122,7 +123,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">6</property> + <property name="top_attach">8</property> </packing> </child> <child> @@ -138,7 +139,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">7</property> + <property name="top_attach">9</property> </packing> </child> <child> @@ -158,7 +159,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">3</property> + <property name="top_attach">5</property> </packing> </child> <child> @@ -178,7 +179,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">5</property> + <property name="top_attach">7</property> </packing> </child> <child> @@ -186,14 +187,29 @@ <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> + <property name="margin-start">18</property> + <property name="label" translatable="yes" context="mmselectpage|extended_tip|datasourcewarning">Data source of the current document is not registered. Please exchange database.</property> <attributes> <attribute name="foreground" value="#cccc00000000"/> </attributes> </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">8</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkButton" id="exchangedatabase"> + <property name="label" translatable="yes" context="mmselectpage|extended_tip|exchangedatabase">Exchange Database...</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="halign">start</property> + <property name="margin-start">18</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> </packing> </child> </object> _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits