Clean up CPDF_ObjectStream.
- Remove `obj_num_` and `extends_obj_num_`, which are not used anywhere.
`extends_obj_num_` may be restored at some point in the future, once
the need for it comes up.
- Move IsObjectsStreamObject() to an anonymous namespace and shorten it
to IsObjectStream(). It is only used within the .cpp file.
- Make the protected section private, as the class is not being
subclassed.
Change-Id: Ia1204673855546547b1332177c3399aa8f58e63e
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/85991
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfapi/parser/cpdf_object_stream.cpp b/core/fpdfapi/parser/cpdf_object_stream.cpp
index 0f78a5d..b6646f9 100644
--- a/core/fpdfapi/parser/cpdf_object_stream.cpp
+++ b/core/fpdfapi/parser/cpdf_object_stream.cpp
@@ -19,8 +19,9 @@
#include "third_party/base/containers/contains.h"
#include "third_party/base/ptr_util.h"
-// static
-bool CPDF_ObjectStream::IsObjectsStreamObject(const CPDF_Object* object) {
+namespace {
+
+bool IsObjectStream(const CPDF_Object* object) {
const CPDF_Stream* stream = ToStream(object);
if (!stream)
return false;
@@ -51,10 +52,12 @@
return true;
}
+} // namespace
+
// static
std::unique_ptr<CPDF_ObjectStream> CPDF_ObjectStream::Create(
const CPDF_Stream* stream) {
- if (!IsObjectsStreamObject(stream))
+ if (!IsObjectStream(stream))
return nullptr;
// Protected constructor.
@@ -62,13 +65,8 @@
}
CPDF_ObjectStream::CPDF_ObjectStream(const CPDF_Stream* obj_stream)
- : obj_num_(obj_stream->GetObjNum()),
- first_object_offset_(obj_stream->GetDict()->GetIntegerFor("First")) {
- DCHECK(IsObjectsStreamObject(obj_stream));
- if (const auto* extends_ref =
- ToReference(obj_stream->GetDict()->GetObjectFor("Extends"))) {
- extends_obj_num_ = extends_ref->GetRefObjNum();
- }
+ : first_object_offset_(obj_stream->GetDict()->GetIntegerFor("First")) {
+ DCHECK(IsObjectStream(obj_stream));
Init(obj_stream);
}
diff --git a/core/fpdfapi/parser/cpdf_object_stream.h b/core/fpdfapi/parser/cpdf_object_stream.h
index ebc4bf5..394fd53 100644
--- a/core/fpdfapi/parser/cpdf_object_stream.h
+++ b/core/fpdfapi/parser/cpdf_object_stream.h
@@ -19,15 +19,10 @@
// See ISO 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;
RetainPtr<CPDF_Object> ParseObject(CPDF_IndirectObjectHolder* pObjList,
uint32_t obj_number) const;
@@ -35,7 +30,7 @@
return objects_offsets_;
}
- protected:
+ private:
explicit CPDF_ObjectStream(const CPDF_Stream* stream);
void Init(const CPDF_Stream* stream);
@@ -43,9 +38,6 @@
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_;