diff options
author | Artem Strygin <art-snake@yandex-team.ru> | 2017-08-29 00:26:42 +0300 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-08-29 22:59:01 +0000 |
commit | 304eefb58759e56be3fb357c78204accd4fa98fc (patch) | |
tree | d7640b3ba8a473856457feba0f41da2453ef6b16 /core/fpdfapi/parser/cpdf_object_avail.h | |
parent | 3fab4e35539e29c4ded08a424db3b1c7fbfa03fc (diff) | |
download | pdfium-304eefb58759e56be3fb357c78204accd4fa98fc.tar.xz |
Implement CPDF_ObjectAvail.
This is non recursive replacement for CPDF_DataAvail::AreObjectsAvailable.
Also added tests.
Change-Id: I546289fc0963d2343253755850f55af8c0bd8e4c
Reviewed-on: https://pdfium-review.googlesource.com/11430
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Art Snake <art-snake@yandex-team.ru>
Diffstat (limited to 'core/fpdfapi/parser/cpdf_object_avail.h')
-rw-r--r-- | core/fpdfapi/parser/cpdf_object_avail.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/core/fpdfapi/parser/cpdf_object_avail.h b/core/fpdfapi/parser/cpdf_object_avail.h new file mode 100644 index 0000000000..233d180c94 --- /dev/null +++ b/core/fpdfapi/parser/cpdf_object_avail.h @@ -0,0 +1,52 @@ +// Copyright 2017 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_AVAIL_H_ +#define CORE_FPDFAPI_PARSER_CPDF_OBJECT_AVAIL_H_ + +#include <memory> +#include <set> +#include <stack> + +#include "core/fpdfapi/parser/cpdf_data_avail.h" +#include "core/fxcrt/cfx_maybe_owned.h" +#include "core/fxcrt/cfx_unowned_ptr.h" + +class CPDF_Object; +class CPDF_Reference; +class CPDF_IndirectObjectHolder; +class CPDF_ReadValidator; + +// Helper for check availability of object tree. +class CPDF_ObjectAvail { + public: + CPDF_ObjectAvail(CPDF_ReadValidator* validator, + CPDF_IndirectObjectHolder* holder, + const CPDF_Object* root); + CPDF_ObjectAvail(CPDF_ReadValidator* validator, + CPDF_IndirectObjectHolder* holder, + uint32_t obj_num); + virtual ~CPDF_ObjectAvail(); + + CPDF_DataAvail::DocAvailStatus CheckAvail(); + + protected: + virtual bool ExcludeObject(const CPDF_Object* object) const; + + private: + bool LoadRootObject(); + bool CheckObjects(); + bool AppendObjectSubRefs(const CPDF_Object* object, + std::stack<uint32_t>* refs) const; + void CleanMemory(); + bool HasObjectParsed(uint32_t obj_num) const; + + CFX_UnownedPtr<CPDF_ReadValidator> validator_; + CFX_UnownedPtr<CPDF_IndirectObjectHolder> holder_; + CFX_MaybeOwned<const CPDF_Object> root_; + std::set<uint32_t> parsed_objnums_; + std::stack<uint32_t> non_parsed_objects_; +}; + +#endif // CORE_FPDFAPI_PARSER_CPDF_OBJECT_AVAIL_H_ |