summaryrefslogtreecommitdiff
path: root/sw/source/uibase/dbui
diff options
context:
space:
mode:
authorGülşah Köse <gulsah.kose@collabora.com>2020-05-22 11:51:33 +0300
committerGülşah Köse <gulsah.kose@collabora.com>2020-05-26 09:42:22 +0200
commit983db96a17630be906b868d2be811663f0d846f6 (patch)
tree274b334e55fb5516944971fa18544f1878f1cc2c /sw/source/uibase/dbui
parent46695f3d66cc77b38865c1817b09d95e9c4b6683 (diff)
Add an option to create encyrpted PDF files with mailmerge.
With that option user can create encyrpted pdf files with a password column in database via mailmerge. Change-Id: I081ef050bc269b1fec24fd01ecc812acd7b857ec Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94709 Tested-by: Jenkins Reviewed-by: Gülşah Köse <gulsah.kose@collabora.com>
Diffstat (limited to 'sw/source/uibase/dbui')
-rw-r--r--sw/source/uibase/dbui/dbmgr.cxx53
1 files changed, 50 insertions, 3 deletions
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index 01da353a78a3..3bfb4e101a29 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -936,6 +936,30 @@ static void lcl_PreparePrinterOptions(
}
}
+static void lcl_PrepareSaveFilterDataOptions(
+ const uno::Sequence< beans::PropertyValue >& rInSaveFilterDataptions,
+ uno::Sequence< beans::PropertyValue >& rOutSaveFilterDataOptions,
+ const OUString& sPassword)
+{
+ const sal_Int32 nOffset = 2;
+ rOutSaveFilterDataOptions.realloc( nOffset );
+ rOutSaveFilterDataOptions[ 0 ].Name = "EncryptFile";
+ rOutSaveFilterDataOptions[ 0 ].Value <<= true;
+ rOutSaveFilterDataOptions[ 1 ].Name = "DocumentOpenPassword";
+ rOutSaveFilterDataOptions[ 1 ].Value <<= sPassword;
+
+ // copy other options
+ sal_Int32 nIndex = nOffset;
+ for( const beans::PropertyValue& rOption : rInSaveFilterDataptions)
+ {
+ rOutSaveFilterDataOptions.realloc( nIndex + 1 );
+ rOutSaveFilterDataOptions[ nIndex ].Name = rOption.Name;
+ rOutSaveFilterDataOptions[ nIndex++ ].Value = rOption.Value ;
+ }
+
+}
+
+
static SfxObjectShell* lcl_CreateWorkingDocument(
// input
const WorkingDocType aType, const SwWrtShell &rSourceWrtShell,
@@ -1135,10 +1159,13 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
rtl_TextEncoding sMailEncoding = ::osl_getThreadTextEncoding();
uno::Reference< beans::XPropertySet > xColumnProp;
+ uno::Reference< beans::XPropertySet > xPasswordColumnProp;
// Check for (mandatory) email or (optional) filename column
SwDBFormatData aColumnDBFormat;
bool bColumnName = !rMergeDescriptor.sDBcolumn.isEmpty();
+ bool bPasswordColumnName = !rMergeDescriptor.sDBPasswordColumn.isEmpty();
+
if( ! bColumnName )
{
if( bMT_EMAIL )
@@ -1153,6 +1180,12 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
uno::Any aCol = xCols->getByName( rMergeDescriptor.sDBcolumn );
aCol >>= xColumnProp;
+ if(bPasswordColumnName)
+ {
+ aCol = xCols->getByName( rMergeDescriptor.sDBPasswordColumn );
+ aCol >>= xPasswordColumnProp;
+ }
+
aColumnDBFormat.xFormatter = m_pImpl->pMergeData->xFormatter;
aColumnDBFormat.aNullDate = m_pImpl->pMergeData->aNullDate;
@@ -1363,6 +1396,15 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
}
}
+ OUString sPasswordColumnData;
+ uno::Sequence< beans::PropertyValue > aSaveToFilterDataOptions( rMergeDescriptor.aSaveToFilterData );
+
+ if( bMT_EMAIL || bPasswordColumnName )
+ {
+ sPasswordColumnData = GetDBField( xPasswordColumnProp, aColumnDBFormat );
+ lcl_PrepareSaveFilterDataOptions( rMergeDescriptor.aSaveToFilterData, aSaveToFilterDataOptions, sPasswordColumnData );
+ }
+
if( IsMergeOk() )
{
std::unique_ptr< INetURLObject > aTempFileURL;
@@ -1489,7 +1531,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
// save merged document
OUString sFileURL;
if( !lcl_SaveDoc( aTempFileURL.get(), pStoreToFilter, pStoreToFilterOptions,
- &rMergeDescriptor.aSaveToFilterData, bIsPDFexport,
+ &aSaveToFilterDataOptions, bIsPDFexport,
xWorkDocSh, *pWorkShell, &sFileURL ) )
{
m_aMergeStatus = MergeStatus::Error;
@@ -3011,9 +3053,14 @@ void SwDBManager::ExecuteFormLetter( SwWrtShell& rSh,
aMergeDesc.bCreateSingleFile = m_pImpl->pMergeDialog->IsSaveSingleDoc();
aMergeDesc.bPrefixIsFilename = aMergeDesc.bCreateSingleFile;
aMergeDesc.sPrefix = m_pImpl->pMergeDialog->GetTargetURL();
- if( !aMergeDesc.bCreateSingleFile && m_pImpl->pMergeDialog->IsGenerateFromDataBase() )
+
+ if(!aMergeDesc.bCreateSingleFile)
{
- aMergeDesc.sDBcolumn = m_pImpl->pMergeDialog->GetColumnName();
+ if(m_pImpl->pMergeDialog->IsGenerateFromDataBase())
+ aMergeDesc.sDBcolumn = m_pImpl->pMergeDialog->GetColumnName();
+
+ if(m_pImpl->pMergeDialog->IsFileEncyrptedFromDataBase())
+ aMergeDesc.sDBPasswordColumn = m_pImpl->pMergeDialog->GetPasswordColumnName();
}
Merge( aMergeDesc );