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

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

Issue 2466023002: Unify some code (Closed)
Patch Set: Fix compilation 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
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 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 CPDF_Object* pInfoObj = GetOrParseIndirectObject(m_pParser->GetInfoObjNum()); 448 CPDF_Object* pInfoObj = GetOrParseIndirectObject(m_pParser->GetInfoObjNum());
448 if (pInfoObj) 449 if (pInfoObj)
449 m_pInfoDict = pInfoObj->GetDict(); 450 m_pInfoDict = pInfoObj->GetDict();
450 } 451 }
451 452
452 void CPDF_Document::LoadDoc() { 453 void CPDF_Document::LoadDoc() {
453 LoadDocInternal(); 454 LoadDocInternal();
454 m_PageList.SetSize(RetrievePageCount()); 455 m_PageList.SetSize(RetrievePageCount());
455 } 456 }
456 457
457 void CPDF_Document::LoadLinearizedDoc(CPDF_Dictionary* pLinearizationParams) { 458 void CPDF_Document::LoadLinearizedDoc(
459 const CPDF_Linearized* pLinearizationParams) {
458 m_bLinearized = true; 460 m_bLinearized = true;
459 LoadDocInternal(); 461 LoadDocInternal();
460 462 m_PageList.SetSize(pLinearizationParams->GetPageCount());
461 uint32_t dwPageCount = 0; 463 m_iFirstPageNo = pLinearizationParams->GetFirstPageNo();
462 CPDF_Object* pCount = pLinearizationParams->GetObjectFor("N"); 464 m_dwFirstPageObjNum = pLinearizationParams->GetFirstPageObjNum();
463 if (ToNumber(pCount))
464 dwPageCount = pCount->GetInteger();
465 m_PageList.SetSize(dwPageCount);
466
467 CPDF_Object* pNo = pLinearizationParams->GetObjectFor("P");
468 if (ToNumber(pNo))
469 m_iFirstPageNo = pNo->GetInteger();
470
471 CPDF_Object* pObjNum = pLinearizationParams->GetObjectFor("O");
472 if (ToNumber(pObjNum))
473 m_dwFirstPageObjNum = pObjNum->GetInteger();
474 } 465 }
475 466
476 void CPDF_Document::LoadPages() { 467 void CPDF_Document::LoadPages() {
477 m_PageList.SetSize(RetrievePageCount()); 468 m_PageList.SetSize(RetrievePageCount());
478 } 469 }
479 470
480 CPDF_Dictionary* CPDF_Document::FindPDFPage(CPDF_Dictionary* pPages, 471 CPDF_Dictionary* CPDF_Document::FindPDFPage(CPDF_Dictionary* pPages,
481 int iPage, 472 int iPage,
482 int nPagesToGo, 473 int nPagesToGo,
483 int level) { 474 int level) {
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 pBBox, pLogFont->lfWeight / 5); 1004 pBBox, pLogFont->lfWeight / 5);
1014 pFontDesc->SetIntegerFor("CapHeight", capheight); 1005 pFontDesc->SetIntegerFor("CapHeight", capheight);
1015 pFontDict->SetReferenceFor("FontDescriptor", this, 1006 pFontDict->SetReferenceFor("FontDescriptor", this,
1016 AddIndirectObject(pFontDesc)); 1007 AddIndirectObject(pFontDesc));
1017 hFont = SelectObject(hDC, hFont); 1008 hFont = SelectObject(hDC, hFont);
1018 DeleteObject(hFont); 1009 DeleteObject(hFont);
1019 DeleteDC(hDC); 1010 DeleteDC(hDC);
1020 return LoadFont(pBaseDict); 1011 return LoadFont(pBaseDict);
1021 } 1012 }
1022 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 1013 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698