2016-10-13 10:37:02 +02:00
|
|
|
/* -*- 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/.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef INCLUDED_XMLSECURITY_INC_PDFIO_PDFDOCUMENT_HXX
|
|
|
|
#define INCLUDED_XMLSECURITY_INC_PDFIO_PDFDOCUMENT_HXX
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <tools/stream.hxx>
|
|
|
|
|
|
|
|
#include <xmlsecuritydllapi.h>
|
2016-10-13 21:07:55 +02:00
|
|
|
#include <sigstruct.hxx>
|
2016-10-13 10:37:02 +02:00
|
|
|
|
|
|
|
namespace xmlsecurity
|
|
|
|
{
|
|
|
|
namespace pdfio
|
|
|
|
{
|
|
|
|
|
|
|
|
class PDFTrailerElement;
|
|
|
|
class PDFObjectElement;
|
2016-10-14 15:38:57 +02:00
|
|
|
class PDFHexStringElement;
|
2016-10-13 10:37:02 +02:00
|
|
|
|
|
|
|
/// A byte range in a PDF file.
|
|
|
|
class PDFElement
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual bool Read(SvStream& rStream) = 0;
|
|
|
|
virtual ~PDFElement() { }
|
|
|
|
};
|
|
|
|
|
|
|
|
/// In-memory representation of an on-disk PDF document.
|
|
|
|
class XMLSECURITY_DLLPUBLIC PDFDocument
|
|
|
|
{
|
|
|
|
/// This vector owns all elements.
|
|
|
|
std::vector< std::unique_ptr<PDFElement> > m_aElements;
|
|
|
|
// List of object offsets we know.
|
|
|
|
std::vector<size_t> m_aXRef;
|
|
|
|
PDFTrailerElement* m_pTrailer;
|
|
|
|
|
|
|
|
static int AsHex(char ch);
|
2016-10-14 15:38:57 +02:00
|
|
|
/// Decode a hex dump.
|
|
|
|
static std::vector<unsigned char> DecodeHexString(PDFHexStringElement* pElement);
|
2016-10-13 10:37:02 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
PDFDocument();
|
|
|
|
PDFDocument& operator=(const PDFDocument&) = delete;
|
|
|
|
PDFDocument(const PDFDocument&) = delete;
|
|
|
|
static OString ReadKeyword(SvStream& rStream);
|
|
|
|
static size_t FindStartXRef(SvStream& rStream);
|
|
|
|
void ReadXRef(SvStream& rStream);
|
|
|
|
static void SkipWhitespace(SvStream& rStream);
|
|
|
|
size_t GetObjectOffset(size_t nIndex) const;
|
|
|
|
const std::vector< std::unique_ptr<PDFElement> >& GetElements();
|
|
|
|
std::vector<PDFObjectElement*> GetPages();
|
|
|
|
|
|
|
|
bool Read(SvStream& rStream);
|
|
|
|
std::vector<PDFObjectElement*> GetSignatureWidgets();
|
2016-10-13 21:07:55 +02:00
|
|
|
/// Return value is about if we can determine a result, rInformation is about the actual result.
|
|
|
|
static bool ValidateSignature(SvStream& rStream, PDFObjectElement* pSignature, SignatureInformation& rInformation);
|
2016-10-13 10:37:02 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace pdfio
|
|
|
|
} // namespace xmlsecurity
|
|
|
|
|
|
|
|
#endif // INCLUDED_XMLSECURITY_INC_PDFIO_PDFDOCUMENT_HXX
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|