Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | |
| 6 | |
| 7 #include "core/fpdfapi/parser/cpdf_linearized.h" | |
| 8 | |
| 9 #include "core/fpdfapi/parser/cpdf_array.h" | |
| 10 #include "core/fpdfapi/parser/cpdf_dictionary.h" | |
| 11 #include "third_party/base/ptr_util.h" | |
| 12 | |
| 13 // static | |
| 14 std::unique_ptr<CPDF_Linearized> CPDF_Linearized::CreateForObject( | |
| 15 std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pObj) { | |
| 16 CPDF_Dictionary* pDict = ToDictionary(pObj.get()); | |
| 17 if (!pDict || !pDict->GetObjectFor("Linearized")) | |
| 18 return nullptr; | |
| 19 return pdfium::WrapUnique(new CPDF_Linearized(pDict)); | |
| 20 } | |
| 21 | |
| 22 CPDF_Linearized::CPDF_Linearized(const CPDF_Dictionary* pDict) { | |
| 23 m_szFileSize = pDict->GetIntegerFor("L"); | |
| 24 m_dwFirstPageNo = pDict->GetIntegerFor("P"); | |
|
Lei Zhang
2016/11/03 00:46:26
I'm still worried about some of these signed/unsig
snake
2016/11/03 01:39:27
If it contains "-1" , that pdf file is corruped.
Lei Zhang
2016/11/03 01:59:31
Oh, but I worry about this a lot. If you look at P
snake
2016/11/03 02:36:52
"N"
1) It is already casted to unsigned. Check, th
| |
| 25 m_szLastXRefOffset = pDict->GetIntegerFor("T"); | |
| 26 m_PageCount = pDict->GetIntegerFor("N"); | |
| 27 m_szFirstPageEndOffset = pDict->GetIntegerFor("E"); | |
| 28 m_FirstPageObjNum = pDict->GetIntegerFor("O"); | |
| 29 CPDF_Array* pHintStreamRange = pDict->GetArrayFor("H"); | |
| 30 size_t nHintStreamSize = pHintStreamRange ? pHintStreamRange->GetCount() : 0; | |
| 31 if (nHintStreamSize == 2 || nHintStreamSize == 4) { | |
| 32 m_szHintStart = pHintStreamRange->GetIntegerAt(0); | |
| 33 m_szHintLength = pHintStreamRange->GetIntegerAt(1); | |
| 34 } | |
| 35 } | |
| 36 | |
| 37 CPDF_Linearized::~CPDF_Linearized() {} | |
| 38 | |
| 39 bool CPDF_Linearized::IsValid() const { | |
| 40 return GetFileSize() > 0 && GetFirstPageEndOffset() > 0 && | |
| 41 GetPageCount() > 0 && (GetPageCount() == 1 || GetLastXRefOffset() > 0); | |
| 42 } | |
| 43 | |
| 44 bool CPDF_Linearized::HasHintTable() const { | |
| 45 return GetPageCount() > 1 && GetHintStart() > 0 && GetHintLength() > 0; | |
| 46 } | |
| OLD | NEW |