tdf#154285 Check upper bound of arguments in SbRtl_Minute function
[LibreOffice.git] / vcl / inc / pdf / ExternalPDFStreams.hxx
blob67d12b556a5dd1af43fe86ec0ddfdf9894b11d8c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
10 #pragma once
12 #include <sal/types.h>
13 #include <sal/log.hxx>
14 #include <vcl/dllapi.h>
16 #include <map>
17 #include <vector>
18 #include <memory>
20 #include <vcl/filter/pdfdocument.hxx>
21 #include <vcl/BinaryDataContainer.hxx>
23 namespace vcl
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()
39 if (!mpPDFDocument)
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");
48 else
50 mpPDFDocument = std::move(pPDFDocument);
53 return mpPDFDocument;
57 // Class to manage external PDF streams, for the de-duplication purpose.
58 class ExternalPDFStreams
60 private:
61 std::map<std::vector<sal_uInt8>, sal_Int32> maStreamIndexMap;
62 std::vector<ExternalPDFStream> maStreamList;
64 public:
65 ExternalPDFStreams() {}
67 sal_Int32 store(BinaryDataContainer const& rDataContainer);
69 ExternalPDFStream& get(sal_uInt32 nIndex);
73 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */