1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
12 #include <sal/types.h>
13 #include <sal/log.hxx>
14 #include <vcl/dllapi.h>
20 #include <vcl/filter/pdfdocument.hxx>
21 #include <vcl/BinaryDataContainer.hxx>
25 // A external PDF stream, which stores the PDF stream data as byte array.
26 // This struct is also responsible to parsing the stream as a PDFDocument,
27 // and store its instance for the life-cycle of the struct, so that it
28 // reused to avoid unnecessary parsing.
29 struct VCL_DLLPUBLIC ExternalPDFStream
31 BinaryDataContainer maDataContainer
;
32 std::shared_ptr
<filter::PDFDocument
> mpPDFDocument
;
33 std::map
<sal_Int32
, sal_Int32
> maCopiedResources
;
35 std::map
<sal_Int32
, sal_Int32
>& getCopiedResources() { return maCopiedResources
; }
37 std::shared_ptr
<filter::PDFDocument
>& getPDFDocument()
41 std::shared_ptr
<SvStream
> aPDFStream
= maDataContainer
.getAsStream();
42 auto pPDFDocument
= std::make_shared
<filter::PDFDocument
>();
43 if (!pPDFDocument
->ReadWithPossibleFixup(*aPDFStream
))
45 SAL_WARN("vcl.pdfwriter",
46 "PDFWriterImpl::writeReferenceXObject: reading the PDF document failed");
50 mpPDFDocument
= std::move(pPDFDocument
);
57 // Class to manage external PDF streams, for the de-duplication purpose.
58 class ExternalPDFStreams
61 std::map
<std::vector
<sal_uInt8
>, sal_Int32
> maStreamIndexMap
;
62 std::vector
<ExternalPDFStream
> maStreamList
;
65 ExternalPDFStreams() {}
67 sal_Int32
store(BinaryDataContainer
const& rDataContainer
);
69 ExternalPDFStream
& get(sal_uInt32 nIndex
);
73 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */