LibreOffice Module vcl (master) 1
ExternalPDFStreams.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 */
9
10#pragma once
11
12#include <sal/types.h>
13#include <sal/log.hxx>
14#include <vcl/dllapi.h>
15
16#include <map>
17#include <vector>
18#include <memory>
19
22
23namespace vcl
24{
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.
30{
32 std::shared_ptr<filter::PDFDocument> mpPDFDocument;
33 std::map<sal_Int32, sal_Int32> maCopiedResources;
34
35 std::map<sal_Int32, sal_Int32>& getCopiedResources() { return maCopiedResources; }
36
37 std::shared_ptr<filter::PDFDocument>& getPDFDocument()
38 {
39 if (!mpPDFDocument)
40 {
41 std::shared_ptr<SvStream> aPDFStream = maDataContainer.getAsStream();
42 auto pPDFDocument = std::make_shared<filter::PDFDocument>();
43 if (!pPDFDocument->ReadWithPossibleFixup(*aPDFStream))
44 {
45 SAL_WARN("vcl.pdfwriter",
46 "PDFWriterImpl::writeReferenceXObject: reading the PDF document failed");
47 }
48 else
49 {
50 mpPDFDocument = pPDFDocument;
51 }
52 }
53 return mpPDFDocument;
54 }
55};
56
57// Class to manage external PDF streams, for the de-duplication purpose.
59{
60private:
61 std::map<std::vector<sal_uInt8>, sal_Int32> maStreamIndexMap;
62 std::vector<ExternalPDFStream> maStreamList;
63
64public:
66
67 sal_Int32 store(BinaryDataContainer const& rDataContainer);
68
69 ExternalPDFStream& get(sal_uInt32 nIndex);
70};
71}
72
73/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Container for the binary data, whose responsibility is to manage the make it as simple as possible to...
std::shared_ptr< SvStream > getAsStream()
ExternalPDFStream & get(sal_uInt32 nIndex)
std::vector< ExternalPDFStream > maStreamList
std::map< std::vector< sal_uInt8 >, sal_Int32 > maStreamIndexMap
sal_Int32 store(BinaryDataContainer const &rDataContainer)
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
#define SAL_WARN(area, stream)
std::map< sal_Int32, sal_Int32 > maCopiedResources
std::shared_ptr< filter::PDFDocument > mpPDFDocument
std::map< sal_Int32, sal_Int32 > & getCopiedResources()
std::shared_ptr< filter::PDFDocument > & getPDFDocument()
BinaryDataContainer maDataContainer