summaryrefslogtreecommitdiff
path: root/core/fpdfapi/parser/cpdf_linearized.cpp
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-11-04 21:06:05 -0700
committerCommit bot <commit-bot@chromium.org>2016-11-04 21:06:05 -0700
commit19cd7cc42700b844e6d9fc170a65bf7122d468b8 (patch)
tree127477b084005457579c599b2ec9eef0668a1479 /core/fpdfapi/parser/cpdf_linearized.cpp
parent71333dc57ac7e4cf7963c83333730b3882ab371f (diff)
downloadpdfium-19cd7cc42700b844e6d9fc170a65bf7122d468b8.tar.xz
Revert of Unify some code (patchset #14 id:260001 of https://codereview.chromium.org/2466023002/ )chromium/2912chromium/2911
Reason for revert: Breaking the chrome roll. See https://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_rel_ng/builds/331856 Original issue's description: > Unify some code > > Move parsing of linearized header into separate CPDF_Linearized class. > > Committed: https://pdfium.googlesource.com/pdfium/+/71333dc57ac7e4cf7963c83333730b3882ab371f TBR=thestig@chromium.org,brucedawson@chromium.org,art-snake@yandex-team.ru # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review-Url: https://codereview.chromium.org/2474283005
Diffstat (limited to 'core/fpdfapi/parser/cpdf_linearized.cpp')
-rw-r--r--core/fpdfapi/parser/cpdf_linearized.cpp69
1 files changed, 0 insertions, 69 deletions
diff --git a/core/fpdfapi/parser/cpdf_linearized.cpp b/core/fpdfapi/parser/cpdf_linearized.cpp
deleted file mode 100644
index aa0ef45bcc..0000000000
--- a/core/fpdfapi/parser/cpdf_linearized.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright 2016 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.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "core/fpdfapi/parser/cpdf_linearized.h"
-
-#include "core/fpdfapi/parser/cpdf_array.h"
-#include "core/fpdfapi/parser/cpdf_dictionary.h"
-#include "core/fpdfapi/parser/cpdf_number.h"
-#include "third_party/base/ptr_util.h"
-
-namespace {
-
-template <class T>
-bool IsValidNumericDictionaryValue(const CPDF_Dictionary* pDict,
- const char* key,
- T min_value,
- bool must_exist = true) {
- if (!pDict->KeyExist(key))
- return !must_exist;
- const CPDF_Number* pNum = ToNumber(pDict->GetObjectFor(key));
- if (!pNum || !pNum->IsInteger())
- return false;
- const int raw_value = pNum->GetInteger();
- if (!pdfium::base::IsValueInRangeForNumericType<T>(raw_value))
- return false;
- return static_cast<T>(raw_value) >= min_value;
-}
-
-} // namespace
-
-// static
-std::unique_ptr<CPDF_Linearized> CPDF_Linearized::CreateForObject(
- std::unique_ptr<CPDF_Object> pObj) {
- auto pDict = ToDictionary(std::move(pObj));
- if (!pDict || !pDict->KeyExist("Linearized") ||
- !IsValidNumericDictionaryValue<FX_FILESIZE>(pDict.get(), "L", 1) ||
- !IsValidNumericDictionaryValue<uint32_t>(pDict.get(), "P", 0, false) ||
- !IsValidNumericDictionaryValue<FX_FILESIZE>(pDict.get(), "T", 1) ||
- !IsValidNumericDictionaryValue<uint32_t>(pDict.get(), "N", 0) ||
- !IsValidNumericDictionaryValue<FX_FILESIZE>(pDict.get(), "E", 1) ||
- !IsValidNumericDictionaryValue<uint32_t>(pDict.get(), "O", 1))
- return nullptr;
- return pdfium::WrapUnique(new CPDF_Linearized(pDict.get()));
-}
-
-CPDF_Linearized::CPDF_Linearized(const CPDF_Dictionary* pDict) {
- m_szFileSize = pDict->GetIntegerFor("L");
- m_dwFirstPageNo = pDict->GetIntegerFor("P");
- m_szLastXRefOffset = pDict->GetIntegerFor("T");
- m_PageCount = pDict->GetIntegerFor("N");
- m_szFirstPageEndOffset = pDict->GetIntegerFor("E");
- m_FirstPageObjNum = pDict->GetIntegerFor("O");
- const CPDF_Array* pHintStreamRange = pDict->GetArrayFor("H");
- const size_t nHintStreamSize =
- pHintStreamRange ? pHintStreamRange->GetCount() : 0;
- if (nHintStreamSize == 2 || nHintStreamSize == 4) {
- m_szHintStart = std::max(pHintStreamRange->GetIntegerAt(0), 0);
- m_szHintLength = std::max(pHintStreamRange->GetIntegerAt(1), 0);
- }
-}
-
-CPDF_Linearized::~CPDF_Linearized() {}
-
-bool CPDF_Linearized::HasHintTable() const {
- return GetPageCount() > 1 && GetHintStart() > 0 && GetHintLength() > 0;
-}