summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-07-20 08:16:57 +0200
committerMiklos Vajna <vmiklos@collabora.com>2022-07-20 12:54:45 +0200
commit7d56dae3375dc0180aa6d20983b3f5f962302588 (patch)
tree6068be7826ac24c4f5519545829f8db698a373d8 /sd
parent845393b9aa9057c5ace3c41ad5ac629b895d7f7f (diff)
tdf#127236 vcl: fix missing encryption of PDF images during export
Regression from commit 78e25558e86188314b9b72048b8ddca18697cb86 (tdf#106059 PDF export: create a reference XObject for JPG images with PDF data, 2017-02-23), once a PDF image was inserted to a document, an encrypted PDF export lost those images. The reason for this is that we started to preserve PDF images as vector data with the above commit, but this means we copied over PDF objects from PDF images to the export result as-is, so encryption was not performed for them. Fix this by separating the write of the PDF object headers, stream content and object footer and then calling checkAndEnableStreamEncryption() / disableStreamEncryption() for each object, even if it's not something our PDF export created but comes from a PDF image. Note that when existing PDF files are signed, PDF objects are also copied into a vcl::filter::PDFDocument, but such PDF images are never encrypted, so it's fine to have stub implementations in vcl::filter::PDFDocument. Change-Id: I2f74b9f51cd35b4319221532ca890e197bab9cf3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137242 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sd')
-rw-r--r--sd/qa/unit/SdrPdfImportTest.cxx5
1 files changed, 3 insertions, 2 deletions
diff --git a/sd/qa/unit/SdrPdfImportTest.cxx b/sd/qa/unit/SdrPdfImportTest.cxx
index e35b83b82373..ba3c42e92d46 100644
--- a/sd/qa/unit/SdrPdfImportTest.cxx
+++ b/sd/qa/unit/SdrPdfImportTest.cxx
@@ -216,7 +216,7 @@ CPPUNIT_TEST_FIXTURE(SdrPdfImportTest, testAnnotationsImportExport)
CPPUNIT_ASSERT_EQUAL(false, aContainer.isEmpty());
auto pPDFDocument
- = pPdfiumLibrary->openDocument(aContainer.getData(), aContainer.getSize());
+ = pPdfiumLibrary->openDocument(aContainer.getData(), aContainer.getSize(), OString());
auto pPDFPage = pPDFDocument->openPage(0);
CPPUNIT_ASSERT_EQUAL(2, pPDFPage->getAnnotationCount());
@@ -248,7 +248,8 @@ CPPUNIT_TEST_FIXTURE(SdrPdfImportTest, testAnnotationsImportExport)
aMemory.WriteStream(aFile);
// Check PDF for annotations
- auto pPDFDocument = pPdfiumLibrary->openDocument(aMemory.GetData(), aMemory.GetSize());
+ auto pPDFDocument
+ = pPdfiumLibrary->openDocument(aMemory.GetData(), aMemory.GetSize(), OString());
CPPUNIT_ASSERT(pPDFDocument);
CPPUNIT_ASSERT_EQUAL(1, pPDFDocument->getPageCount());