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

Side by Side Diff: core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp

Issue 1289703003: FX_CMapDwordToDword considered harmful. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase, remove if(). Created 5 years, 4 months 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/src/fpdfapi/fpdf_font/ttgsubtable.cpp ('k') | core/src/fxcrt/fx_basic_maps.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 <set>
7 #include <utility> 8 #include <utility>
8 #include <vector> 9 #include <vector>
9 10
10 #include "../../../include/fpdfapi/fpdf_module.h" 11 #include "../../../include/fpdfapi/fpdf_module.h"
11 #include "../../../include/fpdfapi/fpdf_page.h" 12 #include "../../../include/fpdfapi/fpdf_page.h"
12 #include "../../../include/fpdfapi/fpdf_parser.h" 13 #include "../../../include/fpdfapi/fpdf_parser.h"
13 #include "../../../include/fxcrt/fx_safe_types.h" 14 #include "../../../include/fxcrt/fx_safe_types.h"
14 #include "../fpdf_page/pageint.h" 15 #include "../fpdf_page/pageint.h"
15 16
16 FX_BOOL IsSignatureDict(const CPDF_Dictionary* pDict) { 17 FX_BOOL IsSignatureDict(const CPDF_Dictionary* pDict) {
(...skipping 2979 matching lines...) Expand 10 before | Expand all | Expand 10 after
2996 FX_DWORD m_dwEncryptObjNum; 2997 FX_DWORD m_dwEncryptObjNum;
2997 2998
2998 FX_FILESIZE m_dwPrevXRefOffset; 2999 FX_FILESIZE m_dwPrevXRefOffset;
2999 3000
3000 FX_BOOL m_bTotalLoadPageTree; 3001 FX_BOOL m_bTotalLoadPageTree;
3001 3002
3002 FX_BOOL m_bCurPageDictLoadOK; 3003 FX_BOOL m_bCurPageDictLoadOK;
3003 3004
3004 CPDF_PageNode m_pageNodes; 3005 CPDF_PageNode m_pageNodes;
3005 3006
3006 CFX_CMapDWordToDWord* m_pageMapCheckState; 3007 std::set<FX_DWORD> m_pageMapCheckState;
3007 3008 std::set<FX_DWORD> m_pagesLoadState;
3008 CFX_CMapDWordToDWord* m_pagesLoadState;
3009 }; 3009 };
3010 3010
3011 IPDF_DataAvail::IPDF_DataAvail(IFX_FileAvail* pFileAvail, 3011 IPDF_DataAvail::IPDF_DataAvail(IFX_FileAvail* pFileAvail,
3012 IFX_FileRead* pFileRead) 3012 IFX_FileRead* pFileRead)
3013 : m_pFileAvail(pFileAvail), m_pFileRead(pFileRead) {} 3013 : m_pFileAvail(pFileAvail), m_pFileRead(pFileRead) {}
3014 3014
3015 // static 3015 // static
3016 IPDF_DataAvail* IPDF_DataAvail::Create(IFX_FileAvail* pFileAvail, 3016 IPDF_DataAvail* IPDF_DataAvail::Create(IFX_FileAvail* pFileAvail,
3017 IFX_FileRead* pFileRead) { 3017 IFX_FileRead* pFileRead) {
3018 return new CPDF_DataAvail(pFileAvail, pFileRead); 3018 return new CPDF_DataAvail(pFileAvail, pFileRead);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
3056 m_bPageLoadedOK = FALSE; 3056 m_bPageLoadedOK = FALSE;
3057 m_bNeedDownLoadResource = FALSE; 3057 m_bNeedDownLoadResource = FALSE;
3058 m_bLinearizedFormParamLoad = FALSE; 3058 m_bLinearizedFormParamLoad = FALSE;
3059 m_pLinearized = NULL; 3059 m_pLinearized = NULL;
3060 m_pRoot = NULL; 3060 m_pRoot = NULL;
3061 m_pTrailer = NULL; 3061 m_pTrailer = NULL;
3062 m_pCurrentParser = NULL; 3062 m_pCurrentParser = NULL;
3063 m_pAcroForm = NULL; 3063 m_pAcroForm = NULL;
3064 m_pPageDict = NULL; 3064 m_pPageDict = NULL;
3065 m_pPageResource = NULL; 3065 m_pPageResource = NULL;
3066 m_pageMapCheckState = NULL;
3067 m_docStatus = PDF_DATAAVAIL_HEADER; 3066 m_docStatus = PDF_DATAAVAIL_HEADER;
3068 m_parser.m_bOwnFileRead = FALSE; 3067 m_parser.m_bOwnFileRead = FALSE;
3069 m_bTotalLoadPageTree = FALSE; 3068 m_bTotalLoadPageTree = FALSE;
3070 m_bCurPageDictLoadOK = FALSE; 3069 m_bCurPageDictLoadOK = FALSE;
3071 m_bLinearedDataOK = FALSE; 3070 m_bLinearedDataOK = FALSE;
3072 m_pagesLoadState = NULL;
3073 } 3071 }
3074 CPDF_DataAvail::~CPDF_DataAvail() { 3072 CPDF_DataAvail::~CPDF_DataAvail() {
3075 if (m_pLinearized) { 3073 if (m_pLinearized) {
3076 m_pLinearized->Release(); 3074 m_pLinearized->Release();
3077 } 3075 }
3078 if (m_pRoot) { 3076 if (m_pRoot) {
3079 m_pRoot->Release(); 3077 m_pRoot->Release();
3080 } 3078 }
3081 if (m_pTrailer) { 3079 if (m_pTrailer) {
3082 m_pTrailer->Release(); 3080 m_pTrailer->Release();
3083 } 3081 }
3084 delete m_pageMapCheckState;
3085 delete m_pagesLoadState;
3086 int32_t i = 0; 3082 int32_t i = 0;
3087 int32_t iSize = m_arrayAcroforms.GetSize(); 3083 int32_t iSize = m_arrayAcroforms.GetSize();
3088 for (i = 0; i < iSize; ++i) { 3084 for (i = 0; i < iSize; ++i) {
3089 ((CPDF_Object*)m_arrayAcroforms.GetAt(i))->Release(); 3085 ((CPDF_Object*)m_arrayAcroforms.GetAt(i))->Release();
3090 } 3086 }
3091 } 3087 }
3092 void CPDF_DataAvail::SetDocument(CPDF_Document* pDoc) { 3088 void CPDF_DataAvail::SetDocument(CPDF_Document* pDoc) {
3093 m_pDocument = pDoc; 3089 m_pDocument = pDoc;
3094 } 3090 }
3095 FX_DWORD CPDF_DataAvail::GetObjectSize(FX_DWORD objnum, FX_FILESIZE& offset) { 3091 FX_DWORD CPDF_DataAvail::GetObjectSize(FX_DWORD objnum, FX_FILESIZE& offset) {
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
3510 if (pRef == NULL || pRef->GetType() != PDFOBJ_REFERENCE) { 3506 if (pRef == NULL || pRef->GetType() != PDFOBJ_REFERENCE) {
3511 m_docStatus = PDF_DATAAVAIL_ERROR; 3507 m_docStatus = PDF_DATAAVAIL_ERROR;
3512 return FALSE; 3508 return FALSE;
3513 } 3509 }
3514 m_PagesObjNum = pRef->GetRefObjNum(); 3510 m_PagesObjNum = pRef->GetRefObjNum();
3515 m_pCurrentParser = (CPDF_Parser*)m_pDocument->GetParser(); 3511 m_pCurrentParser = (CPDF_Parser*)m_pDocument->GetParser();
3516 m_docStatus = PDF_DATAAVAIL_PAGETREE; 3512 m_docStatus = PDF_DATAAVAIL_PAGETREE;
3517 return TRUE; 3513 return TRUE;
3518 } 3514 }
3519 FX_BOOL CPDF_DataAvail::IsFirstCheck(int iPage) { 3515 FX_BOOL CPDF_DataAvail::IsFirstCheck(int iPage) {
3520 if (NULL == m_pageMapCheckState) { 3516 if (m_pageMapCheckState.find(iPage) != m_pageMapCheckState.end())
3521 m_pageMapCheckState = new CFX_CMapDWordToDWord();
3522 }
3523 FX_DWORD dwValue = 0;
3524 if (!m_pageMapCheckState->Lookup(iPage, dwValue)) {
3525 m_pageMapCheckState->SetAt(iPage, 1);
3526 return TRUE;
3527 }
3528 if (dwValue != 0) {
3529 return FALSE; 3517 return FALSE;
3530 } 3518
3531 m_pageMapCheckState->SetAt(iPage, 1); 3519 m_pageMapCheckState.insert(iPage);
3532 return TRUE; 3520 return TRUE;
3533 } 3521 }
3534 void CPDF_DataAvail::ResetFirstCheck(int iPage) { 3522 void CPDF_DataAvail::ResetFirstCheck(int iPage) {
3535 if (NULL == m_pageMapCheckState) { 3523 m_pageMapCheckState.erase(iPage);
3536 m_pageMapCheckState = new CFX_CMapDWordToDWord();
3537 }
3538 FX_DWORD dwValue = 1;
3539 if (!m_pageMapCheckState->Lookup(iPage, dwValue)) {
3540 return;
3541 }
3542 m_pageMapCheckState->SetAt(iPage, 0);
3543 } 3524 }
3544 FX_BOOL CPDF_DataAvail::CheckPage(IFX_DownloadHints* pHints) { 3525 FX_BOOL CPDF_DataAvail::CheckPage(IFX_DownloadHints* pHints) {
3545 FX_DWORD iPageObjs = m_PageObjList.GetSize(); 3526 FX_DWORD iPageObjs = m_PageObjList.GetSize();
3546 CFX_DWordArray UnavailObjList; 3527 CFX_DWordArray UnavailObjList;
3547 for (FX_DWORD i = 0; i < iPageObjs; ++i) { 3528 for (FX_DWORD i = 0; i < iPageObjs; ++i) {
3548 FX_DWORD dwPageObjNum = m_PageObjList.GetAt(i); 3529 FX_DWORD dwPageObjNum = m_PageObjList.GetAt(i);
3549 FX_BOOL bExist = FALSE; 3530 FX_BOOL bExist = FALSE;
3550 CPDF_Object* pObj = GetObject(dwPageObjNum, pHints, &bExist); 3531 CPDF_Object* pObj = GetObject(dwPageObjNum, pHints, &bExist);
3551 if (!pObj) { 3532 if (!pObj) {
3552 if (bExist) { 3533 if (bExist) {
(...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after
4506 return FALSE; 4487 return FALSE;
4507 } 4488 }
4508 if (IsFirstCheck(iPage)) { 4489 if (IsFirstCheck(iPage)) {
4509 m_bCurPageDictLoadOK = FALSE; 4490 m_bCurPageDictLoadOK = FALSE;
4510 m_bPageLoadedOK = FALSE; 4491 m_bPageLoadedOK = FALSE;
4511 m_bAnnotsLoad = FALSE; 4492 m_bAnnotsLoad = FALSE;
4512 m_bNeedDownLoadResource = FALSE; 4493 m_bNeedDownLoadResource = FALSE;
4513 m_objs_array.RemoveAll(); 4494 m_objs_array.RemoveAll();
4514 m_objnum_array.RemoveAll(); 4495 m_objnum_array.RemoveAll();
4515 } 4496 }
4516 if (m_pagesLoadState == NULL) { 4497 if (m_pagesLoadState.find(iPage) != m_pagesLoadState.end()) {
4517 m_pagesLoadState = new CFX_CMapDWordToDWord();
4518 }
4519 FX_DWORD dwPageLoad = 0;
4520 if (m_pagesLoadState->Lookup(iPage, dwPageLoad) && dwPageLoad != 0) {
4521 return TRUE; 4498 return TRUE;
4522 } 4499 }
4523 if (m_bLinearized) { 4500 if (m_bLinearized) {
4524 if ((FX_DWORD)iPage == m_dwFirstPageNo) { 4501 if ((FX_DWORD)iPage == m_dwFirstPageNo) {
4525 m_pagesLoadState->SetAt(iPage, TRUE); 4502 m_pagesLoadState.insert(iPage);
4526 return TRUE; 4503 return TRUE;
4527 } 4504 }
4528 if (!CheckLinearizedData(pHints)) { 4505 if (!CheckLinearizedData(pHints)) {
4529 return FALSE; 4506 return FALSE;
4530 } 4507 }
4531 if (m_bMainXRefLoadedOK) { 4508 if (m_bMainXRefLoadedOK) {
4532 if (m_bTotalLoadPageTree) { 4509 if (m_bTotalLoadPageTree) {
4533 if (!LoadPages(pHints)) { 4510 if (!LoadPages(pHints)) {
4534 return FALSE; 4511 return FALSE;
4535 } 4512 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
4610 FX_BOOL bRet = CheckResources(pHints); 4587 FX_BOOL bRet = CheckResources(pHints);
4611 if (!bRet) { 4588 if (!bRet) {
4612 return FALSE; 4589 return FALSE;
4613 } 4590 }
4614 m_bNeedDownLoadResource = FALSE; 4591 m_bNeedDownLoadResource = FALSE;
4615 } 4592 }
4616 m_bPageLoadedOK = FALSE; 4593 m_bPageLoadedOK = FALSE;
4617 m_bAnnotsLoad = FALSE; 4594 m_bAnnotsLoad = FALSE;
4618 m_bCurPageDictLoadOK = FALSE; 4595 m_bCurPageDictLoadOK = FALSE;
4619 ResetFirstCheck(iPage); 4596 ResetFirstCheck(iPage);
4620 m_pagesLoadState->SetAt(iPage, TRUE); 4597 m_pagesLoadState.insert(iPage);
4621 return TRUE; 4598 return TRUE;
4622 } 4599 }
4623 FX_BOOL CPDF_DataAvail::CheckResources(IFX_DownloadHints* pHints) { 4600 FX_BOOL CPDF_DataAvail::CheckResources(IFX_DownloadHints* pHints) {
4624 if (!m_objs_array.GetSize()) { 4601 if (!m_objs_array.GetSize()) {
4625 m_objs_array.RemoveAll(); 4602 m_objs_array.RemoveAll();
4626 CFX_PtrArray obj_array; 4603 CFX_PtrArray obj_array;
4627 obj_array.Add(m_pPageResource); 4604 obj_array.Add(m_pPageResource);
4628 FX_BOOL bRet = IsObjectsAvail(obj_array, TRUE, pHints, m_objs_array); 4605 FX_BOOL bRet = IsObjectsAvail(obj_array, TRUE, pHints, m_objs_array);
4629 if (bRet) { 4606 if (bRet) {
4630 m_objs_array.RemoveAll(); 4607 m_objs_array.RemoveAll();
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
4708 return FALSE; 4685 return FALSE;
4709 } 4686 }
4710 CPDF_PageNode::~CPDF_PageNode() { 4687 CPDF_PageNode::~CPDF_PageNode() {
4711 int32_t iSize = m_childNode.GetSize(); 4688 int32_t iSize = m_childNode.GetSize();
4712 for (int32_t i = 0; i < iSize; ++i) { 4689 for (int32_t i = 0; i < iSize; ++i) {
4713 CPDF_PageNode* pNode = (CPDF_PageNode*)m_childNode[i]; 4690 CPDF_PageNode* pNode = (CPDF_PageNode*)m_childNode[i];
4714 delete pNode; 4691 delete pNode;
4715 } 4692 }
4716 m_childNode.RemoveAll(); 4693 m_childNode.RemoveAll();
4717 } 4694 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_font/ttgsubtable.cpp ('k') | core/src/fxcrt/fx_basic_maps.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698