Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: core/fpdfapi/parser/cpdf_linearized.cpp

Issue 2466023002: Unify some code (Closed)
Patch Set: Fix review issues. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
12 // static
13 std::unique_ptr<CPDF_Linearized> CPDF_Linearized::CreateForObject(
14 std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pObj) {
15 if (!pObj)
Lei Zhang 2016/11/02 21:34:22 You can write this as: UniqueDictionary pDict = T
snake 2016/11/02 22:04:29 Done.
snake 2016/11/02 22:35:16 Do not compile with "UniqueDictionary pDict = ToD
Lei Zhang 2016/11/03 00:46:26 Err, UniqueDictionary pDict = ToDictionary(std::mo
snake 2016/11/03 01:39:27 Done.
16 return std::unique_ptr<CPDF_Linearized>();
Lei Zhang 2016/11/02 21:34:22 In https://codereview.chromium.org/2453163002 we c
snake 2016/11/02 22:04:28 Done.
17 CPDF_Dictionary* pDict = pObj->GetDict();
18 if (!pDict || !pDict->GetObjectFor("Linearized"))
19 return std::unique_ptr<CPDF_Linearized>();
20 return std::unique_ptr<CPDF_Linearized>(new CPDF_Linearized(pDict));
21 }
22
23 CPDF_Linearized::CPDF_Linearized(CPDF_Dictionary* pDict) {
24 m_szFileSize = pDict->GetIntegerFor("L");
25 m_dwFirstPageNo = pDict->GetIntegerFor("P");
26 m_szLastXRefOffset = pDict->GetIntegerFor("T");
27 m_PageCount = pDict->GetIntegerFor("N");
28 m_szFirstPageEndOffset = pDict->GetIntegerFor("E");
29 m_FirstPageObjNum = pDict->GetIntegerFor("O");
30 CPDF_Array* pHintStreamRange = pDict->GetArrayFor("H");
31 size_t nHintStreamSize = pHintStreamRange ? pHintStreamRange->GetCount() : 0;
32 if (nHintStreamSize == 2 || nHintStreamSize == 4) {
33 m_szHintStart = pHintStreamRange->GetIntegerAt(0);
34 m_szHintLength = pHintStreamRange->GetIntegerAt(1);
35 }
36 }
37
38 CPDF_Linearized::~CPDF_Linearized() {}
39
40 bool CPDF_Linearized::HasHintTable() const {
41 return GetPageCount() > 1 && GetHintStart() > 0 && GetHintLength() > 0;
42 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698