summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorJaume Pujantell <jaume.pujantell@collabora.com>2023-07-14 09:11:07 +0200
committerCaolán McNamara <caolan.mcnamara@collabora.com>2023-07-28 10:05:03 +0200
commitb95739d70806c121cdc38e4e3eb86683e1581c57 (patch)
treeb4dc4821485a4e78bf5ed1d079210aba669513b3 /desktop
parentc5b28aa174883f5666613060e7e5b6142367f49f (diff)
Added possibility to set password on save throug arguments
Change-Id: I579ed7487f87515a21d83912d9c0d12e9edc5eea Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154433 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/lib/init.cxx21
1 files changed, 21 insertions, 0 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index c1ebf5d934ea..112b134b5e84 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3308,6 +3308,23 @@ static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* sUrl, const cha
bool bFullSheetPreview = sFullSheetPreview == u"true";
+ OUString filePassword;
+ if ((aIndex = aFilterOptions.indexOf(",Password=")) >= 0)
+ {
+ int bIndex = aFilterOptions.indexOf("PASSWORDEND");
+ filePassword = aFilterOptions.subView(aIndex + 10, bIndex - (aIndex + 10));
+ aFilterOptions = OUString::Concat(aFilterOptions.subView(0, aIndex))
+ + aFilterOptions.subView(bIndex + 11);
+ }
+ OUString filePasswordToModify;
+ if ((aIndex = aFilterOptions.indexOf(",PasswordToModify=")) >= 0)
+ {
+ int bIndex = aFilterOptions.indexOf("PASSWORDTOMODIFYEND");
+ filePassword = aFilterOptions.subView(aIndex + 18, bIndex - (aIndex + 18));
+ aFilterOptions = OUString::Concat(aFilterOptions.subView(0, aIndex))
+ + aFilterOptions.subView(bIndex + 19);
+ }
+
// Select a pdf version if specified a valid one. If not specified then ignore.
// If invalid then fail.
sal_Int32 pdfVer = 0;
@@ -3382,6 +3399,10 @@ static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* sUrl, const cha
{
aSaveMediaDescriptor["FilterData"] <<= aFilterDataMap.getAsConstPropertyValueList();
}
+ if (!filePassword.isEmpty())
+ aSaveMediaDescriptor["Password"] <<= filePassword;
+ if (!filePasswordToModify.isEmpty())
+ aSaveMediaDescriptor["PasswordToModify"] <<= filePasswordToModify;
// add interaction handler too
if (gImpl)