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

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

Issue 2466023002: Unify some code (Closed)
Patch Set: Add missing changes 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_dictionary.h"
Lei Zhang 2016/11/01 00:29:53 nit: alphabetical order
snake 2016/11/01 14:39:24 Done.
10 #include "core/fpdfapi/parser/cpdf_array.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)
16 return std::unique_ptr<CPDF_Linearized>();
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));
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.
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