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

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

Issue 2466023002: Unify some code (Closed)
Patch Set: Rebase 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
« no previous file with comments | « core/fpdfapi/parser/cpdf_document.h ('k') | core/fpdfapi/parser/cpdf_document_unittest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "core/fpdfapi/parser/cpdf_document.h" 7 #include "core/fpdfapi/parser/cpdf_document.h"
8 8
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
11 #include <vector> 11 #include <vector>
12 12
13 #include "core/fpdfapi/cpdf_modulemgr.h" 13 #include "core/fpdfapi/cpdf_modulemgr.h"
14 #include "core/fpdfapi/font/cpdf_fontencoding.h" 14 #include "core/fpdfapi/font/cpdf_fontencoding.h"
15 #include "core/fpdfapi/page/cpdf_docpagedata.h" 15 #include "core/fpdfapi/page/cpdf_docpagedata.h"
16 #include "core/fpdfapi/page/cpdf_pagemodule.h" 16 #include "core/fpdfapi/page/cpdf_pagemodule.h"
17 #include "core/fpdfapi/page/pageint.h" 17 #include "core/fpdfapi/page/pageint.h"
18 #include "core/fpdfapi/parser/cpdf_array.h" 18 #include "core/fpdfapi/parser/cpdf_array.h"
19 #include "core/fpdfapi/parser/cpdf_dictionary.h" 19 #include "core/fpdfapi/parser/cpdf_dictionary.h"
20 #include "core/fpdfapi/parser/cpdf_linearized.h"
20 #include "core/fpdfapi/parser/cpdf_number.h" 21 #include "core/fpdfapi/parser/cpdf_number.h"
21 #include "core/fpdfapi/parser/cpdf_parser.h" 22 #include "core/fpdfapi/parser/cpdf_parser.h"
22 #include "core/fpdfapi/parser/cpdf_reference.h" 23 #include "core/fpdfapi/parser/cpdf_reference.h"
23 #include "core/fpdfapi/parser/cpdf_stream.h" 24 #include "core/fpdfapi/parser/cpdf_stream.h"
24 #include "core/fpdfapi/render/render_int.h" 25 #include "core/fpdfapi/render/render_int.h"
25 #include "core/fxcodec/JBig2_DocumentContext.h" 26 #include "core/fxcodec/JBig2_DocumentContext.h"
26 #include "core/fxge/cfx_unicodeencoding.h" 27 #include "core/fxge/cfx_unicodeencoding.h"
27 #include "core/fxge/fx_font.h" 28 #include "core/fxge/fx_font.h"
28 #include "third_party/base/ptr_util.h" 29 #include "third_party/base/ptr_util.h"
29 #include "third_party/base/stl_util.h" 30 #include "third_party/base/stl_util.h"
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 CPDF_Object* pInfoObj = GetOrParseIndirectObject(m_pParser->GetInfoObjNum()); 372 CPDF_Object* pInfoObj = GetOrParseIndirectObject(m_pParser->GetInfoObjNum());
372 if (pInfoObj) 373 if (pInfoObj)
373 m_pInfoDict = pInfoObj->GetDict(); 374 m_pInfoDict = pInfoObj->GetDict();
374 } 375 }
375 376
376 void CPDF_Document::LoadDoc() { 377 void CPDF_Document::LoadDoc() {
377 LoadDocInternal(); 378 LoadDocInternal();
378 m_PageList.SetSize(RetrievePageCount()); 379 m_PageList.SetSize(RetrievePageCount());
379 } 380 }
380 381
381 void CPDF_Document::LoadLinearizedDoc(CPDF_Dictionary* pLinearizationParams) { 382 void CPDF_Document::LoadLinearizedDoc(
383 const CPDF_Linearized* pLinearizationParams) {
382 m_bLinearized = true; 384 m_bLinearized = true;
383 LoadDocInternal(); 385 LoadDocInternal();
384 386 m_PageList.SetSize(pLinearizationParams->GetPageCount());
385 uint32_t dwPageCount = 0; 387 m_iFirstPageNo = pLinearizationParams->GetFirstPageNo();
386 CPDF_Object* pCount = pLinearizationParams->GetObjectFor("N"); 388 m_dwFirstPageObjNum = pLinearizationParams->GetFirstPageObjNum();
387 if (ToNumber(pCount))
388 dwPageCount = pCount->GetInteger();
389 m_PageList.SetSize(dwPageCount);
390
391 CPDF_Object* pNo = pLinearizationParams->GetObjectFor("P");
392 if (ToNumber(pNo))
393 m_iFirstPageNo = pNo->GetInteger();
394
395 CPDF_Object* pObjNum = pLinearizationParams->GetObjectFor("O");
396 if (ToNumber(pObjNum))
397 m_dwFirstPageObjNum = pObjNum->GetInteger();
398 } 389 }
399 390
400 void CPDF_Document::LoadPages() { 391 void CPDF_Document::LoadPages() {
401 m_PageList.SetSize(RetrievePageCount()); 392 m_PageList.SetSize(RetrievePageCount());
402 } 393 }
403 394
404 CPDF_Dictionary* CPDF_Document::TraversePDFPages(int iPage, 395 CPDF_Dictionary* CPDF_Document::TraversePDFPages(int iPage,
405 int* nPagesToGo, 396 int* nPagesToGo,
406 size_t level) { 397 size_t level) {
407 if (*nPagesToGo < 0) 398 if (*nPagesToGo < 0)
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 pBBox, pLogFont->lfWeight / 5); 1036 pBBox, pLogFont->lfWeight / 5);
1046 pFontDesc->SetIntegerFor("CapHeight", capheight); 1037 pFontDesc->SetIntegerFor("CapHeight", capheight);
1047 pFontDict->SetReferenceFor("FontDescriptor", this, 1038 pFontDict->SetReferenceFor("FontDescriptor", this,
1048 AddIndirectObject(pFontDesc)); 1039 AddIndirectObject(pFontDesc));
1049 hFont = SelectObject(hDC, hFont); 1040 hFont = SelectObject(hDC, hFont);
1050 DeleteObject(hFont); 1041 DeleteObject(hFont);
1051 DeleteDC(hDC); 1042 DeleteDC(hDC);
1052 return LoadFont(pBaseDict); 1043 return LoadFont(pBaseDict);
1053 } 1044 }
1054 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 1045 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
OLDNEW
« no previous file with comments | « core/fpdfapi/parser/cpdf_document.h ('k') | core/fpdfapi/parser/cpdf_document_unittest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698