diff options
author | Gülşah Köse <gulsah.kose@collabora.com> | 2021-04-13 08:48:32 +0300 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2021-05-01 21:32:49 +0200 |
commit | 2d68d93114a5773168c55157fc4348568fb16439 (patch) | |
tree | 935bf5b97dcfc216b8ae87c6fc3524f8a4563f69 | |
parent | 6d03ab40de87ae533caf01a670929d5de7e025cd (diff) |
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.kose@collabora.com>
-rw-r--r-- | sw/source/ui/dbui/mmdocselectpage.cxx | 29 | ||||
-rw-r--r-- | sw/source/ui/dbui/mmdocselectpage.hxx | 2 | ||||
-rw-r--r-- | sw/uiconfig/swriter/ui/mmselectpage.ui | 319 |
3 files changed, 192 insertions, 158 deletions
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 dd2f71529348..cb8b5dae430c 100644 --- a/sw/uiconfig/swriter/ui/mmselectpage.ui +++ b/sw/uiconfig/swriter/ui/mmselectpage.ui @@ -15,196 +15,201 @@ <property name="label_xalign">0</property> <property name="shadow_type">none</property> <child> - <object class="GtkAlignment" id="alignment1"> + <!-- n-columns=1 n-rows=1 --> + <object class="GtkGrid" id="grid1"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="top_padding">6</property> - <property name="left_padding">12</property> + <property name="hexpand">True</property> + <property name="row_spacing">6</property> + <property name="margin-start">12</property> + <property name="margin-top">6</property> + <child> - <!-- n-columns=1 n-rows=1 --> - <object class="GtkGrid" id="grid1"> + <object class="GtkRadioButton" id="currentdoc"> + <property name="label" translatable="yes" context="mmselectpage|currentdoc">Use the current _document</property> <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="hexpand">True</property> - <property name="row_spacing">6</property> - <child> - <object class="GtkRadioButton" id="currentdoc"> - <property name="label" translatable="yes" context="mmselectpage|currentdoc">Use the current _document</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_underline">True</property> - <property name="xalign">0</property> - <property name="active">True</property> - <property name="draw_indicator">True</property> - <child internal-child="accessible"> - <object class="AtkObject" id="currentdoc-atkobject"> - <property name="AtkObject::accessible-description" translatable="yes" context="mmselectpage|extended_tip|currentdoc">Uses the current Writer document as the base for the mail merge document.</property> - </object> - </child> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_underline">True</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + <child internal-child="accessible"> + <object class="AtkObject" id="currentdoc-atkobject"> + <property name="AtkObject::accessible-description" translatable="yes" context="mmselectpage|extended_tip|currentdoc">Uses the current Writer document as the base for the mail merge document.</property> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - </packing> </child> - <child> - <object class="GtkRadioButton" id="newdoc"> - <property name="label" translatable="yes" context="mmselectpage|newdoc">Create a ne_w document</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_underline">True</property> - <property name="xalign">0</property> - <property name="draw_indicator">True</property> - <property name="group">currentdoc</property> - <child internal-child="accessible"> - <object class="AtkObject" id="newdoc-atkobject"> - <property name="AtkObject::accessible-description" translatable="yes" context="mmselectpage|extended_tip|newdoc">Creates a new Writer document to use for the mail merge.</property> - </object> - </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkRadioButton" id="newdoc"> + <property name="label" translatable="yes" context="mmselectpage|newdoc">Create a ne_w document</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_underline">True</property> + <property name="draw_indicator">True</property> + <property name="group">currentdoc</property> + <child internal-child="accessible"> + <object class="AtkObject" id="newdoc-atkobject"> + <property name="AtkObject::accessible-description" translatable="yes" context="mmselectpage|extended_tip|newdoc">Creates a new Writer document to use for the mail merge.</property> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - </packing> </child> - <child> - <object class="GtkRadioButton" id="loaddoc"> - <property name="label" translatable="yes" context="mmselectpage|loaddoc">Start from _existing document</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="hexpand">True</property> - <property name="use_underline">True</property> - <property name="xalign">0</property> - <property name="draw_indicator">True</property> - <property name="group">currentdoc</property> - <child internal-child="accessible"> - <object class="AtkObject" id="loaddoc-atkobject"> - <property name="AtkObject::accessible-description" translatable="yes" context="mmselectpage|extended_tip|loaddoc">Select an existing Writer document to use as the base for the mail merge document.</property> - </object> - </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">3</property> + </packing> + </child> + <child> + <object class="GtkRadioButton" id="loaddoc"> + <property name="label" translatable="yes" context="mmselectpage|loaddoc">Start from _existing document</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="hexpand">True</property> + <property name="use_underline">True</property> + <property name="draw_indicator">True</property> + <property name="group">currentdoc</property> + <child internal-child="accessible"> + <object class="AtkObject" id="loaddoc-atkobject"> + <property name="AtkObject::accessible-description" translatable="yes" context="mmselectpage|extended_tip|loaddoc">Select an existing Writer document to use as the base for the mail merge document.</property> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">2</property> - </packing> </child> - <child> - <object class="GtkRadioButton" id="template"> - <property name="label" translatable="yes" context="mmselectpage|template">Start from a t_emplate</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="hexpand">True</property> - <property name="use_underline">True</property> - <property name="xalign">0</property> - <property name="draw_indicator">True</property> - <property name="group">currentdoc</property> - <child internal-child="accessible"> - <object class="AtkObject" id="template-atkobject"> - <property name="AtkObject::accessible-description" translatable="yes" context="mmselectpage|extended_tip|template">Select the template that you want to create your mail merge document with.</property> - </object> - </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">4</property> + </packing> + </child> + <child> + <object class="GtkRadioButton" id="template"> + <property name="label" translatable="yes" context="mmselectpage|template">Start from a t_emplate</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="hexpand">True</property> + <property name="use_underline">True</property> + <property name="draw_indicator">True</property> + <property name="group">currentdoc</property> + <child internal-child="accessible"> + <object class="AtkObject" id="template-atkobject"> + <property name="AtkObject::accessible-description" translatable="yes" context="mmselectpage|extended_tip|template">Select the template that you want to create your mail merge document with.</property> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">4</property> - </packing> </child> - <child> - <object class="GtkRadioButton" id="recentdoc"> - <property name="label" translatable="yes" context="mmselectpage|recentdoc">Start fro_m a recently saved starting document</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_underline">True</property> - <property name="xalign">0</property> - <property name="draw_indicator">True</property> - <property name="group">currentdoc</property> - <child internal-child="accessible"> - <object class="AtkObject" id="recentdoc-atkobject"> - <property name="AtkObject::accessible-description" translatable="yes" context="mmselectpage|extended_tip|recentdoc">Use an existing mail merge document as the base for a new mail merge document.</property> - </object> - </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">6</property> + </packing> + </child> + <child> + <object class="GtkRadioButton" id="recentdoc"> + <property name="label" translatable="yes" context="mmselectpage|recentdoc">Start fro_m a recently saved starting document</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_underline">True</property> + <property name="draw_indicator">True</property> + <property name="group">currentdoc</property> + <child internal-child="accessible"> + <object class="AtkObject" id="recentdoc-atkobject"> + <property name="AtkObject::accessible-description" translatable="yes" context="mmselectpage|extended_tip|recentdoc">Use an existing mail merge document as the base for a new mail merge document.</property> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">6</property> - </packing> </child> - <child> - <object class="GtkComboBoxText" id="recentdoclb"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="margin_left">18</property> - <child internal-child="accessible"> - <object class="AtkObject" id="recentdoclb-atkobject"> - <property name="AtkObject::accessible-description" translatable="yes" context="mmselectpage|extended_tip|recentdoclb">Select the document.</property> - </object> - </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">8</property> + </packing> + </child> + <child> + <object class="GtkComboBoxText" id="recentdoclb"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin-start">18</property> + <child internal-child="accessible"> + <object class="AtkObject" id="recentdoclb-atkobject"> + <property name="AtkObject::accessible-description" translatable="yes" context="mmselectpage|extended_tip|recentdoclb">Select the document.</property> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">7</property> - </packing> </child> - <child> - <object class="GtkButton" id="browsedoc"> - <property name="label" translatable="yes" context="mmselectpage|browsedoc">B_rowse...</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_left">18</property> - <property name="use_underline">True</property> - <child internal-child="accessible"> - <object class="AtkObject" id="browsedoc-atkobject"> - <property name="AtkObject::accessible-description" translatable="yes" context="mmselectpage|extended_tip|browsedoc">Locate the Writer document that you want to use, and then click Open.</property> - </object> - </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">9</property> + </packing> + </child> + <child> + <object class="GtkButton" id="browsedoc"> + <property name="label" translatable="yes" context="mmselectpage|browsedoc">B_rowse...</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> + <property name="use_underline">True</property> + <child internal-child="accessible"> + <object class="AtkObject" id="browsedoc-atkobject"> + <property name="AtkObject::accessible-description" translatable="yes" context="mmselectpage|extended_tip|browsedoc">Locate the Writer document that you want to use, and then click Open.</property> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">3</property> - </packing> </child> - <child> - <object class="GtkButton" id="browsetemplate"> - <property name="label" translatable="yes" context="mmselectpage|browsetemplate">B_rowse...</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_left">18</property> - <property name="use_underline">True</property> - <child internal-child="accessible"> - <object class="AtkObject" id="browsetemplate-atkobject"> - <property name="AtkObject::accessible-description" translatable="yes" context="mmselectpage|extended_tip|browsetemplate">Opens a template selector dialog.</property> - </object> - </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">5</property> + </packing> + </child> + <child> + <object class="GtkButton" id="browsetemplate"> + <property name="label" translatable="yes" context="mmselectpage|browsetemplate">B_rowse...</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> + <property name="use_underline">True</property> + <child internal-child="accessible"> + <object class="AtkObject" id="browsetemplate-atkobject"> + <property name="AtkObject::accessible-description" translatable="yes" context="mmselectpage|extended_tip|browsetemplate">Opens a template selector dialog.</property> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">5</property> - </packing> </child> </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">7</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> + <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> |