summaryrefslogtreecommitdiff
path: root/core/fpdfapi/parser/cpdf_parser.h
diff options
context:
space:
mode:
authorArtem Strygin <art-snake@yandex-team.ru>2018-06-27 18:15:10 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-27 18:15:10 +0000
commit20eca1e383b7dce69cd791d42bda3558a3966301 (patch)
treed3fded7303e8326d3883ca51b6bed2ad2438b6da /core/fpdfapi/parser/cpdf_parser.h
parent00ba8bbea0ff57d6f11257736408e530e54ef642 (diff)
downloadpdfium-20eca1e383b7dce69cd791d42bda3558a3966301.tar.xz
Rework of loading of CPDF_Document.
Improve CPDF_Document interface. Fix relationship between CPDF_Document and CPDF_Parser. This CL changes CPDF_Document to internally create the CPDF_Parser and removes the need for the CPDF_Parser to know about the CPDF_Document. Change-Id: Iec7aef19575c90f30b9a6c919dfd4f4417e4caf2 Reviewed-on: https://pdfium-review.googlesource.com/35630 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fpdfapi/parser/cpdf_parser.h')
-rw-r--r--core/fpdfapi/parser/cpdf_parser.h29
1 files changed, 15 insertions, 14 deletions
diff --git a/core/fpdfapi/parser/cpdf_parser.h b/core/fpdfapi/parser/cpdf_parser.h
index f859db5d16..1a1f9b0de4 100644
--- a/core/fpdfapi/parser/cpdf_parser.h
+++ b/core/fpdfapi/parser/cpdf_parser.h
@@ -14,6 +14,7 @@
#include <vector>
#include "core/fpdfapi/parser/cpdf_cross_ref_table.h"
+#include "core/fpdfapi/parser/cpdf_indirect_object_holder.h"
#include "core/fpdfapi/parser/cpdf_syntax_parser.h"
#include "core/fxcrt/fx_string.h"
#include "core/fxcrt/fx_system.h"
@@ -23,8 +24,6 @@
class CPDF_Array;
class CPDF_CryptoHandler;
class CPDF_Dictionary;
-class CPDF_Document;
-class CPDF_IndirectObjectHolder;
class CPDF_LinearizedHeader;
class CPDF_Object;
class CPDF_ObjectStream;
@@ -35,6 +34,11 @@ class IFX_SeekableReadStream;
class CPDF_Parser {
public:
+ class ParsedObjectsHolder : public CPDF_IndirectObjectHolder {
+ public:
+ virtual bool TryInit() = 0;
+ };
+
enum Error {
SUCCESS = 0,
FILE_ERROR,
@@ -49,13 +53,14 @@ class CPDF_Parser {
static const size_t kInvalidPos = std::numeric_limits<size_t>::max();
+ explicit CPDF_Parser(ParsedObjectsHolder* holder);
CPDF_Parser();
~CPDF_Parser();
Error StartParse(const RetainPtr<IFX_SeekableReadStream>& pFile,
- CPDF_Document* pDocument);
+ const char* password);
Error StartLinearizedParse(const RetainPtr<CPDF_ReadValidator>& validator,
- CPDF_Document* pDocument);
+ const char* password);
void SetPassword(const char* password) { m_Password = password; }
ByteString GetPassword() const { return m_Password; }
@@ -72,12 +77,11 @@ class CPDF_Parser {
uint32_t GetRootObjNum() const;
uint32_t GetInfoObjNum() const;
const CPDF_Array* GetIDArray() const;
+ CPDF_Dictionary* GetRoot() const;
CPDF_Dictionary* GetEncryptDict() const { return m_pEncryptDict.Get(); }
- std::unique_ptr<CPDF_Object> ParseIndirectObject(
- CPDF_IndirectObjectHolder* pObjList,
- uint32_t objnum);
+ std::unique_ptr<CPDF_Object> ParseIndirectObject(uint32_t objnum);
uint32_t GetLastObjNum() const;
bool IsValidObjectNumber(uint32_t objnum) const;
@@ -96,12 +100,10 @@ class CPDF_Parser {
bool IsXRefStream() const { return m_bXRefStream; }
std::unique_ptr<CPDF_Object> ParseIndirectObjectAt(
- CPDF_IndirectObjectHolder* pObjList,
FX_FILESIZE pos,
uint32_t objnum);
std::unique_ptr<CPDF_Object> ParseIndirectObjectAtByStrict(
- CPDF_IndirectObjectHolder* pObjList,
FX_FILESIZE pos,
uint32_t objnum,
FX_FILESIZE* pResultPos);
@@ -150,7 +152,7 @@ class CPDF_Parser {
ObjectInfo info;
};
- Error StartParseInternal(CPDF_Document* pDocument);
+ Error StartParseInternal();
FX_FILESIZE ParseStartXRef();
bool LoadAllCrossRefV4(FX_FILESIZE pos);
bool LoadAllCrossRefV5(FX_FILESIZE pos);
@@ -161,8 +163,7 @@ class CPDF_Parser {
bool LoadLinearizedAllCrossRefV4(FX_FILESIZE pos);
bool LoadLinearizedAllCrossRefV5(FX_FILESIZE pos);
Error LoadLinearizedMainXRefTable();
- const CPDF_ObjectStream* GetObjectStream(CPDF_IndirectObjectHolder* pObjList,
- uint32_t object_number);
+ const CPDF_ObjectStream* GetObjectStream(uint32_t object_number);
std::unique_ptr<CPDF_LinearizedHeader> ParseLinearizedHeader();
void SetEncryptDictionary(CPDF_Dictionary* pDict);
void ShrinkObjectMap(uint32_t size);
@@ -180,7 +181,6 @@ class CPDF_Parser {
void MergeCrossRefObjectsData(const std::vector<CrossRefObjData>& objects);
std::unique_ptr<CPDF_Object> ParseIndirectObjectAtInternal(
- CPDF_IndirectObjectHolder* pObjList,
FX_FILESIZE pos,
uint32_t objnum,
CPDF_SyntaxParser::ParseType parse_type,
@@ -193,7 +193,8 @@ class CPDF_Parser {
ObjectType GetObjectTypeFromCrossRefStreamType(
int cross_ref_stream_type) const;
- UnownedPtr<CPDF_Document> m_pDocument;
+ std::unique_ptr<ParsedObjectsHolder> m_pOwnedObjectsHolder;
+ UnownedPtr<ParsedObjectsHolder> m_pObjectsHolder;
bool m_bHasParsed;
bool m_bXRefStream;