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

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

Issue 2491583002: Fix receiving page, if it have not obj num. (Closed)
Patch Set: Fix signed/unsigned comparison 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>
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 if (objnum) { 485 if (objnum) {
486 if (CPDF_Dictionary* pDict = ToDictionary(GetOrParseIndirectObject(objnum))) 486 if (CPDF_Dictionary* pDict = ToDictionary(GetOrParseIndirectObject(objnum)))
487 return pDict; 487 return pDict;
488 return nullptr; 488 return nullptr;
489 } 489 }
490 490
491 CPDF_Dictionary* pPages = GetPagesDict(); 491 CPDF_Dictionary* pPages = GetPagesDict();
492 if (!pPages) 492 if (!pPages)
493 return nullptr; 493 return nullptr;
494 494
495 int nPagesToGo = iPage - m_iNextPageToTraverse + 1;
496 if (nPagesToGo <= 0) {
npm 2016/11/09 20:32:56 This could also happen in cases where we just skip
snake 2016/11/09 20:46:47 I see this before. I will check this case.
497 // This can be happened, when page have not objNum.
Lei Zhang 2016/11/09 20:19:41 Rephrase: "This can happen when the page does not
snake 2016/11/09 20:30:41 Done.
498 // And on call GetPage with page index, which was traversed before,
499 // nPagesToGo will be less or zero and TraversePDFPages returns nullptr;
500 // Example "testing\corpus\fx\other\jetman_std.pdf"
Lei Zhang 2016/11/09 20:19:41 I would prefer to use "/" for path separator, sinc
snake 2016/11/09 20:30:41 Done.
501 // We should restart traversing in this case.
502 // TODO(art-snake): optimize this.
npm 2016/11/09 20:32:56 To optimize, we could store the dict pointer when
snake 2016/11/09 20:46:47 I should think about this. May be more better gene
npm 2016/11/09 21:55:03 AFAIK objNum is 0 for CPDF_Object when its direct
snake 2016/11/09 22:39:47 Anyway, i will do this in other CL.
503 m_pTreeTraversal.clear();
npm 2016/11/09 20:32:56 nit: use ResetTraversal() instead.
snake 2016/11/09 20:46:47 Done.
504 m_iNextPageToTraverse = 0;
505 nPagesToGo = iPage - m_iNextPageToTraverse + 1;
Lei Zhang 2016/11/09 20:19:41 nit: You already know |m_iNextPageToTraverse| is 0
snake 2016/11/09 20:30:41 Done.
506 }
495 if (m_pTreeTraversal.empty()) 507 if (m_pTreeTraversal.empty())
496 m_pTreeTraversal.push_back(std::make_pair(pPages, 0)); 508 m_pTreeTraversal.push_back(std::make_pair(pPages, 0));
497 int nPagesToGo = iPage - m_iNextPageToTraverse + 1;
498 CPDF_Dictionary* pPage = TraversePDFPages(iPage, &nPagesToGo, 0); 509 CPDF_Dictionary* pPage = TraversePDFPages(iPage, &nPagesToGo, 0);
499 m_iNextPageToTraverse = iPage + 1; 510 m_iNextPageToTraverse = iPage + 1;
500 return pPage; 511 return pPage;
501 } 512 }
502 513
503 void CPDF_Document::SetPageObjNum(int iPage, uint32_t objNum) { 514 void CPDF_Document::SetPageObjNum(int iPage, uint32_t objNum) {
504 m_PageList.SetAt(iPage, objNum); 515 m_PageList.SetAt(iPage, objNum);
505 } 516 }
506 517
507 int CPDF_Document::FindPageIndex(CPDF_Dictionary* pNode, 518 int CPDF_Document::FindPageIndex(CPDF_Dictionary* pNode,
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 pBBox, pLogFont->lfWeight / 5); 1048 pBBox, pLogFont->lfWeight / 5);
1038 pFontDesc->SetIntegerFor("CapHeight", capheight); 1049 pFontDesc->SetIntegerFor("CapHeight", capheight);
1039 pFontDict->SetReferenceFor("FontDescriptor", this, 1050 pFontDict->SetReferenceFor("FontDescriptor", this,
1040 AddIndirectObject(pFontDesc)); 1051 AddIndirectObject(pFontDesc));
1041 hFont = SelectObject(hDC, hFont); 1052 hFont = SelectObject(hDC, hFont);
1042 DeleteObject(hFont); 1053 DeleteObject(hFont);
1043 DeleteDC(hDC); 1054 DeleteDC(hDC);
1044 return LoadFont(pBaseDict); 1055 return LoadFont(pBaseDict);
1045 } 1056 }
1046 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 1057 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
OLDNEW
« no previous file with comments | « no previous file | core/fpdfapi/parser/cpdf_document_unittest.cpp » ('j') | core/fpdfapi/parser/cpdf_document_unittest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698