Chromium Code Reviews| 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..29d15d1848497014a2f92c2215988ef268bf59f1 |
| --- /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_dictionary.h" |
|
Lei Zhang
2016/11/01 00:29:53
nit: alphabetical order
snake
2016/11/01 14:39:24
Done.
|
| +#include "core/fpdfapi/parser/cpdf_array.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)); |
|
Lei Zhang
2016/11/01 00:29:53
We have MakeUnique() in PDFium too.
snake
2016/11/01 14:39:24
I can not use pdfium::MakeUnique in this case, bec
Lei Zhang
2016/11/01 22:51:28
Yes, I'm being silly.
|
| +} |
| + |
| +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; |
| +} |