Index: core/fpdfapi/parser/cpdf_linearized.cpp |
diff --git a/core/fpdfapi/parser/cpdf_linearized.cpp b/core/fpdfapi/parser/cpdf_linearized.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3e371258ecbceb89b0f15332324c94a8bac43041 |
--- /dev/null |
+++ b/core/fpdfapi/parser/cpdf_linearized.cpp |
@@ -0,0 +1,42 @@ |
+// 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" |
+ |
+// static |
+std::unique_ptr<CPDF_Linearized> CPDF_Linearized::CreateForObject( |
+ std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pObj) { |
+ if (!pObj) |
+ return std::unique_ptr<CPDF_Linearized>(); |
+ CPDF_Dictionary* pDict = pObj->GetDict(); |
+ if (!pDict || !pDict->GetObjectFor("Linearized")) |
+ return std::unique_ptr<CPDF_Linearized>(); |
+ return std::unique_ptr<CPDF_Linearized>(new CPDF_Linearized(pDict)); |
+} |
+ |
+CPDF_Linearized::CPDF_Linearized(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"); |
+ CPDF_Array* pHintStreamRange = pDict->GetArrayFor("H"); |
+ size_t nHintStreamSize = pHintStreamRange ? pHintStreamRange->GetCount() : 0; |
+ if (nHintStreamSize == 2 || nHintStreamSize == 4) { |
+ m_szHintStart = pHintStreamRange->GetIntegerAt(0); |
+ m_szHintLength = pHintStreamRange->GetIntegerAt(1); |
+ } |
+} |
+ |
+CPDF_Linearized::~CPDF_Linearized() {} |
+ |
+bool CPDF_Linearized::HasHintTable() const { |
+ return GetPageCount() > 1 && GetHintStart() > 0 && GetHintLength() > 0; |
+} |