summaryrefslogtreecommitdiff
path: root/vcl/inc/pdf
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-06-18 12:12:52 +0200
committerMiklos Vajna <vmiklos@collabora.com>2020-06-18 14:36:29 +0200
commit8277073ce3e33788d93b3df490a8f03d1814863b (patch)
tree51094d52c1a629ddbb6d3e24d9b583ba74e5f042 /vcl/inc/pdf
parenta60a5e769a407fa13b087a111123ceff5a96bc03 (diff)
sd signature line: extract copyExternalResources() from the pdf export code
Because I would like to reuse this in the "sign existing pdf" code, in vcl::filter::PDFDocument::WriteAppearanceObject(). Change-Id: Ia5e5c1e452bb0d0486bde2a082375b5131eea8c7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96595 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'vcl/inc/pdf')
-rw-r--r--vcl/inc/pdf/objectcontainer.hxx36
-rw-r--r--vcl/inc/pdf/objectcopier.hxx48
2 files changed, 84 insertions, 0 deletions
diff --git a/vcl/inc/pdf/objectcontainer.hxx b/vcl/inc/pdf/objectcontainer.hxx
new file mode 100644
index 000000000000..ca4898737e10
--- /dev/null
+++ b/vcl/inc/pdf/objectcontainer.hxx
@@ -0,0 +1,36 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#pragma once
+
+#include <sal/types.h>
+
+namespace vcl
+{
+/// Allows creating, updating and writing PDF objects in a container.
+class SAL_NO_VTABLE SAL_DLLPUBLIC_RTTI PDFObjectContainer
+{
+public:
+ /* adds an entry to m_aObjects and returns its index+1,
+ * sets the offset to ~0
+ */
+ virtual sal_Int32 createObject() = 0;
+ /* sets the offset of object n to the current position of output file+1
+ */
+ virtual bool updateObject(sal_Int32 n) = 0;
+
+ // Write pBuffer to the end of the output.
+ virtual bool writeBuffer(const void* pBuffer, sal_uInt64 nBytes) = 0;
+
+protected:
+ ~PDFObjectContainer() noexcept = default;
+};
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/pdf/objectcopier.hxx b/vcl/inc/pdf/objectcopier.hxx
new file mode 100644
index 000000000000..b99fbb4886b3
--- /dev/null
+++ b/vcl/inc/pdf/objectcopier.hxx
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#pragma once
+
+#include <map>
+
+#include <rtl/string.hxx>
+#include <sal/types.h>
+#include <vcl/dllapi.h>
+
+class SvMemoryStream;
+
+namespace vcl
+{
+class PDFObjectContainer;
+namespace filter
+{
+class PDFObjectElement;
+}
+
+/// Copies objects from one PDF file into an other one.
+class VCL_DLLPUBLIC PDFObjectCopier
+{
+ PDFObjectContainer& m_rContainer;
+
+public:
+ PDFObjectCopier(PDFObjectContainer& rContainer);
+
+ /// Copies resources of a given kind from an external page to the output,
+ /// returning what has to be included in the new resource dictionary.
+ OString copyExternalResources(filter::PDFObjectElement& rPage, const OString& rKind,
+ std::map<sal_Int32, sal_Int32>& rCopiedResources);
+
+ /// Copies a single resource from an external document, returns the new
+ /// object ID in our document.
+ sal_Int32 copyExternalResource(SvMemoryStream& rDocBuffer, filter::PDFObjectElement& rObject,
+ std::map<sal_Int32, sal_Int32>& rCopiedResources);
+};
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */