summaryrefslogtreecommitdiff
path: root/core/fpdfapi/parser/cpdf_object_stream.h
diff options
context:
space:
mode:
authorArtem Strygin <art-snake@yandex-team.ru>2018-06-26 16:01:38 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-26 16:01:38 +0000
commite3d3ce04e585c4a6c5596056bdf1ced639c763d7 (patch)
tree55ba6fde26546f818d8ffadc879087ada34502ab /core/fpdfapi/parser/cpdf_object_stream.h
parent08b6819660a69cdc83bd133d1074da5813d9e414 (diff)
downloadpdfium-e3d3ce04e585c4a6c5596056bdf1ced639c763d7.tar.xz
Implement CPDF_ObjStream.
It is allow do not store raw objects streams within CPDF_Document for reduce memory usage. Change-Id: I4377bd5119d87314e76f14255171618cf6ee533d Reviewed-on: https://pdfium-review.googlesource.com/35430 Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Art Snake <art-snake@yandex-team.ru>
Diffstat (limited to 'core/fpdfapi/parser/cpdf_object_stream.h')
-rw-r--r--core/fpdfapi/parser/cpdf_object_stream.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/core/fpdfapi/parser/cpdf_object_stream.h b/core/fpdfapi/parser/cpdf_object_stream.h
new file mode 100644
index 0000000000..816c1be77e
--- /dev/null
+++ b/core/fpdfapi/parser/cpdf_object_stream.h
@@ -0,0 +1,52 @@
+// Copyright 2018 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CORE_FPDFAPI_PARSER_CPDF_OBJECT_STREAM_H_
+#define CORE_FPDFAPI_PARSER_CPDF_OBJECT_STREAM_H_
+
+#include <map>
+#include <memory>
+#include <vector>
+
+#include "core/fpdfapi/parser/cpdf_object.h"
+#include "core/fxcrt/retain_ptr.h"
+
+class CPDF_IndirectObjectHolder;
+class CPDF_Stream;
+class CPDF_StreamAcc;
+class IFX_SeekableReadStream;
+
+// Implementation of logic of PDF "Object Streams".
+// See "PDF 32000-1:2008" Spec. section 7.5.7.
+class CPDF_ObjectStream {
+ public:
+ static bool IsObjectsStreamObject(const CPDF_Object* object);
+
+ static std::unique_ptr<CPDF_ObjectStream> Create(const CPDF_Stream* stream);
+
+ ~CPDF_ObjectStream();
+
+ uint32_t obj_num() const { return obj_num_; }
+ uint32_t extends_obj_num() const { return extends_obj_num_; }
+
+ bool HasObject(uint32_t obj_number) const;
+ std::unique_ptr<CPDF_Object> ParseObject(CPDF_IndirectObjectHolder* pObjList,
+ uint32_t obj_number) const;
+
+ protected:
+ explicit CPDF_ObjectStream(const CPDF_Stream* stream);
+
+ void Init(const CPDF_Stream* stream);
+ std::unique_ptr<CPDF_Object> ParseObjectAtOffset(
+ CPDF_IndirectObjectHolder* pObjList,
+ uint32_t object_offset) const;
+
+ uint32_t obj_num_ = CPDF_Object::kInvalidObjNum;
+ uint32_t extends_obj_num_ = CPDF_Object::kInvalidObjNum;
+ RetainPtr<IFX_SeekableReadStream> data_stream_;
+ int first_object_offset_ = 0;
+ std::map<uint32_t, uint32_t> objects_offsets_;
+};
+
+#endif // CORE_FPDFAPI_PARSER_CPDF_OBJECT_STREAM_H_