1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 19:57:45 +00:00

LibPDF: Move document-specific parsing functionality into its own class

The Parser class is now a generic PDF object parser, of which the new
DocumentParser class derives. DocumentParser now takes over all
functions relating to linearization, pages, xref and trailer handling.

This allows the use of multiple parsers in the same document's
context, which will be needed in order to handle PDF object streams.
This commit is contained in:
Julian Offenhäuser 2022-08-15 11:45:24 +02:00 committed by Sam Atkins
parent 9f4659cc63
commit 4887aacec7
7 changed files with 746 additions and 706 deletions

View file

@ -36,7 +36,7 @@ String OutlineItem::to_string(int indent) const
PDFErrorOr<NonnullRefPtr<Document>> Document::create(ReadonlyBytes bytes)
{
auto parser = adopt_ref(*new Parser({}, bytes));
auto parser = adopt_ref(*new DocumentParser({}, bytes));
auto document = adopt_ref(*new Document(parser));
TRY(parser->initialize());
@ -57,7 +57,7 @@ PDFErrorOr<NonnullRefPtr<Document>> Document::create(ReadonlyBytes bytes)
return document;
}
Document::Document(NonnullRefPtr<Parser> const& parser)
Document::Document(NonnullRefPtr<DocumentParser> const& parser)
: m_parser(parser)
{
m_parser->set_document(this);