sfx2/source/doc/objstor.cxx | 28 +++++++++ sw/source/ui/dbui/mmresultdialogs.cxx | 77 ++++++++++++++++++++++++-- sw/source/ui/inc/mmresultdialogs.hxx | 4 + sw/uiconfig/swriter/ui/mmresultemaildialog.ui | 45 +++++++++++++++ 4 files changed, 149 insertions(+), 5 deletions(-)
New commits: commit 32eb3a73843ef2eb46e88a71e8864f48fde05790 Author: Gülşah Köse <gulsah.k...@collabora.com> AuthorDate: Sun Jun 14 19:21:22 2020 +0300 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Wed Jun 17 18:05:11 2020 +0200 Add an option to send email encrypted PDF files via mailmerge. Change-Id: I002e054b685bd3367c4183014adc1dbd0843a365 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96303 Reviewed-by: Gülşah Köse <gulsah.k...@collabora.com> Tested-by: Gülşah Köse <gulsah.k...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96535 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Andras Timar <andras.ti...@collabora.com> diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 1ec0039c2a7c..66ec9a8d16f6 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -2816,7 +2816,35 @@ bool SfxObjectShell::PreDoSaveAs_Impl(const OUString& rFileName, const OUString& // set filter; if no filter is given, take the default filter of the factory if ( !aFilterName.isEmpty() ) + { pNewFile->SetFilter( GetFactory().GetFilterContainer()->GetFilter4FilterName( aFilterName ) ); + + if(aFilterName == "writer_pdf_Export" && pNewFile->GetItemSet()) + { + uno::Sequence< beans::PropertyValue > aSaveToFilterDataOptions(2); + bool bRet = false; + + for(int i = 0 ; i< rArgs.getLength() ; ++i) + { + auto aProp = rArgs[i]; + if(aProp.Name == "EncryptFile") + { + aSaveToFilterDataOptions[0].Name = aProp.Name; + aSaveToFilterDataOptions[0].Value = aProp.Value; + bRet = true; + } + if(aProp.Name == "DocumentOpenPassword") + { + aSaveToFilterDataOptions[1].Name = aProp.Name; + aSaveToFilterDataOptions[1].Value = aProp.Value; + bRet = true; + } + } + + if( bRet ) + pNewFile->GetItemSet()->Put( SfxUnoAnyItem(SID_FILTER_DATA, uno::makeAny(aSaveToFilterDataOptions))); + } + } else pNewFile->SetFilter( GetFactory().GetFilterContainer()->GetAnyFilter( SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT ) ); diff --git a/sw/source/ui/dbui/mmresultdialogs.cxx b/sw/source/ui/dbui/mmresultdialogs.cxx index d102faec4103..adc586132f0c 100644 --- a/sw/source/ui/dbui/mmresultdialogs.cxx +++ b/sw/source/ui/dbui/mmresultdialogs.cxx @@ -289,6 +289,9 @@ SwMMResultEmailDialog::SwMMResultEmailDialog(weld::Window* pParent) , m_xSendAsPB(m_xBuilder->weld_button("sendassettings")) , m_xAttachmentGroup(m_xBuilder->weld_widget("attachgroup")) , m_xAttachmentED(m_xBuilder->weld_entry("attach")) + , m_xPasswordFT(m_xBuilder->weld_label("passwordft")) + , m_xPasswordLB(m_xBuilder->weld_combo_box("password")) + , m_xPasswordCB(m_xBuilder->weld_check_button("passwordcb")) , m_xSendAllRB(m_xBuilder->weld_radio_button("sendallrb")) , m_xFromRB(m_xBuilder->weld_radio_button("fromrb")) , m_xFromNF(m_xBuilder->weld_spin_button("from")) @@ -299,6 +302,7 @@ SwMMResultEmailDialog::SwMMResultEmailDialog(weld::Window* pParent) m_xCopyToPB->connect_clicked(LINK(this, SwMMResultEmailDialog, CopyToHdl_Impl)); m_xSendAsPB->connect_clicked(LINK(this, SwMMResultEmailDialog, SendAsHdl_Impl)); m_xSendAsLB->connect_changed(LINK(this, SwMMResultEmailDialog, SendTypeHdl_Impl)); + m_xPasswordCB->connect_toggled( LINK( this, SwMMResultEmailDialog, CheckHdl )); Link<weld::ToggleButton&,void> aLink = LINK(this, SwMMResultEmailDialog, DocumentSelectionHdl_Impl); m_xSendAllRB->connect_toggled(aLink); @@ -308,6 +312,10 @@ SwMMResultEmailDialog::SwMMResultEmailDialog(weld::Window* pParent) m_xOKButton->connect_clicked(LINK(this, SwMMResultEmailDialog, SendDocumentsHdl_Impl)); + m_xPasswordCB->hide(); + m_xPasswordFT->hide(); + m_xPasswordLB->hide(); + FillInEmailSettings(); } @@ -387,9 +395,14 @@ void SwMMResultEmailDialog::FillInEmailSettings() aFields = xColAccess->getElementNames(); const OUString* pFields = aFields.getConstArray(); for (sal_Int32 nField = 0; nField < aFields.getLength(); ++nField) + { m_xMailToLB->append_text(pFields[nField]); + m_xPasswordLB->append_text(pFields[nField]); + } m_xMailToLB->set_active(0); + m_xPasswordLB->set_active(0); + // then select the right one - may not be available const std::vector<std::pair<OUString, int>>& rHeaders = xConfigItem->GetDefaultAddressHeaders(); OUString sEMailColumn = rHeaders[MM_PART_E_MAIL].first; @@ -412,6 +425,14 @@ IMPL_LINK_NOARG(SwMMResultSaveDialog, DocumentSelectionHdl_Impl, weld::ToggleBut m_xToNF->set_sensitive(bEnableFromTo); } +IMPL_LINK_NOARG(SwMMResultEmailDialog, CheckHdl, weld::ToggleButton&, void) +{ + bool bEnable = m_xPasswordCB->get_active(); + + m_xPasswordFT->set_sensitive(bEnable); + m_xPasswordLB->set_sensitive(bEnable); +} + IMPL_LINK_NOARG(SwMMResultPrintDialog, DocumentSelectionHdl_Impl, weld::ToggleButton&, void) { bool bEnableFromTo = m_xFromRB->get_active(); @@ -791,6 +812,7 @@ IMPL_LINK(SwMMResultEmailDialog, SendTypeHdl_Impl, weld::ComboBox&, rBox, void) { auto nDocType = rBox.get_active_id().toUInt32(); bool bEnable = MM_DOCTYPE_HTML != nDocType && MM_DOCTYPE_TEXT != nDocType; + bool bIsPDF = nDocType == MM_DOCTYPE_PDF; m_xSendAsPB->set_sensitive(bEnable); m_xAttachmentGroup->set_sensitive(bEnable); if(bEnable) @@ -810,6 +832,21 @@ IMPL_LINK(SwMMResultEmailDialog, SendTypeHdl_Impl, weld::ComboBox&, rBox, void) m_xAttachmentED->set_text(sAttach); } } + + if(bIsPDF) + { + m_xPasswordCB->show(); + m_xPasswordFT->show(); + m_xPasswordLB->show(); + CheckHdl(*m_xPasswordCB); + } + else + { + m_xPasswordCB->hide(); + m_xPasswordFT->hide(); + m_xPasswordLB->hide(); + + } } IMPL_LINK_NOARG(SwMMResultEmailDialog, SendAsHdl_Impl, weld::Button&, void) @@ -972,6 +1009,7 @@ IMPL_LINK_NOARG(SwMMResultEmailDialog, SendDocumentsHdl_Impl, weld::Button&, voi else return; // back to the dialog } + OUString sEMailColumn = m_xMailToLB->get_active_text(); OSL_ENSURE( !sEMailColumn.isEmpty(), "No email column selected"); Reference< sdbcx::XColumnsSupplier > xColsSupp( xConfigItem->GetResultSet(), UNO_QUERY); @@ -982,6 +1020,14 @@ IMPL_LINK_NOARG(SwMMResultEmailDialog, SendDocumentsHdl_Impl, weld::Button&, voi return; } + OUString sPasswordColumn = m_xPasswordLB->get_active_text(); + OSL_ENSURE( !sPasswordColumn.isEmpty(), "No password column selected"); + if(sPasswordColumn.isEmpty() || !xColAccess.is() || !xColAccess->hasByName(sPasswordColumn)) + { + m_xDialog->response(RET_OK); + return; + } + OUString sFilterOptions; if(MM_DOCTYPE_TEXT == nDocType) { @@ -1057,14 +1103,35 @@ IMPL_LINK_NOARG(SwMMResultEmailDialog, SendDocumentsHdl_Impl, weld::Button&, voi { bool withFilterOptions = MM_DOCTYPE_TEXT == nDocType || MM_DOCTYPE_HTML == nDocType; - uno::Sequence< beans::PropertyValue > aFilterValues(withFilterOptions ? 2 : 1); + bool withPasswordOptions = m_xPasswordCB->get_active(); + + sal_Int32 nTarget = xConfigItem->MoveResultSet(rInfo.nDBRow); + OSL_ENSURE( nTarget == rInfo.nDBRow, "row of current document could not be selected"); + OUString sPassword = lcl_GetColumnValueOf(sPasswordColumn, xColAccess); + + sal_Int32 nOptionCount = (withFilterOptions && withPasswordOptions) ? 4 : withPasswordOptions ? 3 : withFilterOptions ? 2 : 1; + sal_Int32 nOpt = 0; + uno::Sequence< beans::PropertyValue > aFilterValues(nOptionCount); beans::PropertyValue* pFilterValues = aFilterValues.getArray(); - pFilterValues[0].Name = "FilterName"; - pFilterValues[0].Value <<= pSfxFlt->GetFilterName(); + + pFilterValues[nOpt].Name = "FilterName"; + pFilterValues[nOpt].Value <<= pSfxFlt->GetFilterName(); + if(withFilterOptions) { - pFilterValues[1].Name = "FilterOptions"; - pFilterValues[1].Value <<= sFilterOptions; + nOpt++; + pFilterValues[nOpt].Name = "FilterOptions"; + pFilterValues[nOpt].Value <<= sFilterOptions; + } + + if(withPasswordOptions) + { + nOpt++; + pFilterValues[nOpt].Name = "EncryptFile"; + pFilterValues[nOpt].Value <<= true; + nOpt++; + pFilterValues[nOpt].Name = "DocumentOpenPassword"; + pFilterValues[nOpt].Value <<= sPassword; } uno::Reference< frame::XStorable > xTempStore( pTempView->GetDocShell()->GetModel(), uno::UNO_QUERY); diff --git a/sw/source/ui/inc/mmresultdialogs.hxx b/sw/source/ui/inc/mmresultdialogs.hxx index 01709ead04f2..3e65f303449c 100644 --- a/sw/source/ui/inc/mmresultdialogs.hxx +++ b/sw/source/ui/inc/mmresultdialogs.hxx @@ -109,6 +109,9 @@ class SwMMResultEmailDialog : public SfxDialogController std::unique_ptr<weld::Button> m_xSendAsPB; std::unique_ptr<weld::Widget> m_xAttachmentGroup; std::unique_ptr<weld::Entry> m_xAttachmentED; + std::unique_ptr<weld::Label> m_xPasswordFT; + std::unique_ptr<weld::ComboBox> m_xPasswordLB; + std::unique_ptr<weld::CheckButton> m_xPasswordCB; std::unique_ptr<weld::RadioButton> m_xSendAllRB; std::unique_ptr<weld::RadioButton> m_xFromRB; std::unique_ptr<weld::SpinButton> m_xFromNF; @@ -121,6 +124,7 @@ class SwMMResultEmailDialog : public SfxDialogController DECL_LINK(SendAsHdl_Impl, weld::Button&, void); DECL_LINK(SendDocumentsHdl_Impl, weld::Button&, void); DECL_LINK(DocumentSelectionHdl_Impl, weld::ToggleButton&, void); + DECL_LINK(CheckHdl, weld::ToggleButton&, void ); void FillInEmailSettings(); diff --git a/sw/uiconfig/swriter/ui/mmresultemaildialog.ui b/sw/uiconfig/swriter/ui/mmresultemaildialog.ui index 5f10bf7dd4aa..2928b97cd207 100644 --- a/sw/uiconfig/swriter/ui/mmresultemaildialog.ui +++ b/sw/uiconfig/swriter/ui/mmresultemaildialog.ui @@ -220,6 +220,51 @@ <property name="top_attach">2</property> </packing> </child> + <child> + <object class="GtkLabel" id="passwordft"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes" context="mmresultemaildialog|passwordft">Password</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">password</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">4</property> + </packing> + </child> + <child> + <object class="GtkComboBoxText" id="password"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">4</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="passwordcb"> + <property name="label" translatable="yes" context="mmresultemaildialog|passwordcb" >Save with password</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">3</property> + <property name="width">2</property> + </packing> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> <child> <placeholder/> </child> _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits