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

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

Issue 889673003: Replace CFX_SmartPointer cast operator with Get() method. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Reduce changes to Get() method only. Created 5 years, 10 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/include/fxcrt/fx_basic.h ('k') | no next file » | 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 "../../../include/fpdfapi/fpdf_parser.h" 7 #include "../../../include/fpdfapi/fpdf_parser.h"
8 #include "../../../include/fpdfapi/fpdf_module.h" 8 #include "../../../include/fpdfapi/fpdf_module.h"
9 #include "../../../include/fpdfapi/fpdf_page.h" 9 #include "../../../include/fpdfapi/fpdf_page.h"
10 #include "../../../../third_party/numerics/safe_math.h" 10 #include "../../../../third_party/numerics/safe_math.h"
(...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 } 1202 }
1203 if (m_V5Type[objnum] == 2) { 1203 if (m_V5Type[objnum] == 2) {
1204 CPDF_StreamAcc* pObjStream = GetObjectStream((FX_DWORD)m_CrossRef[objnum ]); 1204 CPDF_StreamAcc* pObjStream = GetObjectStream((FX_DWORD)m_CrossRef[objnum ]);
1205 if (pObjStream == NULL) { 1205 if (pObjStream == NULL) {
1206 return NULL; 1206 return NULL;
1207 } 1207 }
1208 FX_INT32 n = pObjStream->GetDict()->GetInteger(FX_BSTRC("N")); 1208 FX_INT32 n = pObjStream->GetDict()->GetInteger(FX_BSTRC("N"));
1209 FX_INT32 offset = pObjStream->GetDict()->GetInteger(FX_BSTRC("First")); 1209 FX_INT32 offset = pObjStream->GetDict()->GetInteger(FX_BSTRC("First"));
1210 CPDF_SyntaxParser syntax; 1210 CPDF_SyntaxParser syntax;
1211 CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream((FX_LPBYTE)p ObjStream->GetData(), (size_t)pObjStream->GetSize(), FALSE)); 1211 CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream((FX_LPBYTE)p ObjStream->GetData(), (size_t)pObjStream->GetSize(), FALSE));
1212 syntax.InitParser((IFX_FileStream*)file, 0); 1212 syntax.InitParser(file.Get(), 0);
1213 CPDF_Object* pRet = NULL; 1213 CPDF_Object* pRet = NULL;
1214 while (n) { 1214 while (n) {
1215 FX_DWORD thisnum = syntax.GetDirectNum(); 1215 FX_DWORD thisnum = syntax.GetDirectNum();
1216 FX_DWORD thisoff = syntax.GetDirectNum(); 1216 FX_DWORD thisoff = syntax.GetDirectNum();
1217 if (thisnum == objnum) { 1217 if (thisnum == objnum) {
1218 syntax.RestorePos(offset + thisoff); 1218 syntax.RestorePos(offset + thisoff);
1219 pRet = syntax.GetObject(pObjList, 0, 0, pContext); 1219 pRet = syntax.GetObject(pObjList, 0, 0, pContext);
1220 break; 1220 break;
1221 } 1221 }
1222 n --; 1222 n --;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 CPDF_StreamAcc* pObjStream = GetObjectStream((FX_DWORD)m_CrossRef[objnum ]); 1275 CPDF_StreamAcc* pObjStream = GetObjectStream((FX_DWORD)m_CrossRef[objnum ]);
1276 if (pObjStream == NULL) { 1276 if (pObjStream == NULL) {
1277 return; 1277 return;
1278 } 1278 }
1279 FX_INT32 n = pObjStream->GetDict()->GetInteger(FX_BSTRC("N")); 1279 FX_INT32 n = pObjStream->GetDict()->GetInteger(FX_BSTRC("N"));
1280 FX_INT32 offset = pObjStream->GetDict()->GetInteger(FX_BSTRC("First")); 1280 FX_INT32 offset = pObjStream->GetDict()->GetInteger(FX_BSTRC("First"));
1281 CPDF_SyntaxParser syntax; 1281 CPDF_SyntaxParser syntax;
1282 FX_LPCBYTE pData = pObjStream->GetData(); 1282 FX_LPCBYTE pData = pObjStream->GetData();
1283 FX_DWORD totalsize = pObjStream->GetSize(); 1283 FX_DWORD totalsize = pObjStream->GetSize();
1284 CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream((FX_LPBYTE)p Data, (size_t)totalsize, FALSE)); 1284 CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream((FX_LPBYTE)p Data, (size_t)totalsize, FALSE));
1285 syntax.InitParser((IFX_FileStream*)file, 0); 1285 syntax.InitParser(file.Get(), 0);
1286 while (n) { 1286 while (n) {
1287 FX_DWORD thisnum = syntax.GetDirectNum(); 1287 FX_DWORD thisnum = syntax.GetDirectNum();
1288 FX_DWORD thisoff = syntax.GetDirectNum(); 1288 FX_DWORD thisoff = syntax.GetDirectNum();
1289 if (thisnum == objnum) { 1289 if (thisnum == objnum) {
1290 if (n == 1) { 1290 if (n == 1) {
1291 size = totalsize - (thisoff + offset); 1291 size = totalsize - (thisoff + offset);
1292 } else { 1292 } else {
1293 syntax.GetDirectNum(); // Skip nextnum. 1293 syntax.GetDirectNum(); // Skip nextnum.
1294 FX_DWORD nextoff = syntax.GetDirectNum(); 1294 FX_DWORD nextoff = syntax.GetDirectNum();
1295 size = nextoff - thisoff; 1295 size = nextoff - thisoff;
(...skipping 2397 matching lines...) Expand 10 before | Expand all | Expand 10 after
3693 FX_BYTE buffer[1024]; 3693 FX_BYTE buffer[1024];
3694 m_pFileRead->ReadBlock(buffer, 0, req_size); 3694 m_pFileRead->ReadBlock(buffer, 0, req_size);
3695 if (IsLinearizedFile(buffer, req_size)) { 3695 if (IsLinearizedFile(buffer, req_size)) {
3696 return PDF_IS_LINEARIZED; 3696 return PDF_IS_LINEARIZED;
3697 } 3697 }
3698 return PDF_NOT_LINEARIZED; 3698 return PDF_NOT_LINEARIZED;
3699 } 3699 }
3700 FX_BOOL CPDF_DataAvail::IsLinearizedFile(FX_LPBYTE pData, FX_DWORD dwLen) 3700 FX_BOOL CPDF_DataAvail::IsLinearizedFile(FX_LPBYTE pData, FX_DWORD dwLen)
3701 { 3701 {
3702 CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream(pData, (size_t)d wLen, FALSE)); 3702 CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream(pData, (size_t)d wLen, FALSE));
3703 FX_INT32 offset = GetHeaderOffset((IFX_FileStream*)file); 3703 FX_INT32 offset = GetHeaderOffset(file.Get());
3704 if (offset == -1) { 3704 if (offset == -1) {
3705 m_docStatus = PDF_DATAAVAIL_ERROR; 3705 m_docStatus = PDF_DATAAVAIL_ERROR;
3706 return FALSE; 3706 return FALSE;
3707 } 3707 }
3708 m_dwHeaderOffset = offset; 3708 m_dwHeaderOffset = offset;
3709 m_syntaxParser.InitParser((IFX_FileStream*)file, offset); 3709 m_syntaxParser.InitParser(file.Get(), offset);
3710 m_syntaxParser.RestorePos(m_syntaxParser.m_HeaderOffset + 9); 3710 m_syntaxParser.RestorePos(m_syntaxParser.m_HeaderOffset + 9);
3711 FX_BOOL bNumber = FALSE; 3711 FX_BOOL bNumber = FALSE;
3712 CFX_ByteString wordObjNum = m_syntaxParser.GetNextWord(bNumber); 3712 CFX_ByteString wordObjNum = m_syntaxParser.GetNextWord(bNumber);
3713 if (!bNumber) { 3713 if (!bNumber) {
3714 return FALSE; 3714 return FALSE;
3715 } 3715 }
3716 FX_DWORD objnum = FXSYS_atoi(wordObjNum); 3716 FX_DWORD objnum = FXSYS_atoi(wordObjNum);
3717 if (m_pLinearized) { 3717 if (m_pLinearized) {
3718 m_pLinearized->Release(); 3718 m_pLinearized->Release();
3719 m_pLinearized = NULL; 3719 m_pLinearized = NULL;
(...skipping 20 matching lines...) Expand all
3740 return FALSE; 3740 return FALSE;
3741 } 3741 }
3742 FX_BOOL CPDF_DataAvail::CheckEnd(IFX_DownloadHints* pHints) 3742 FX_BOOL CPDF_DataAvail::CheckEnd(IFX_DownloadHints* pHints)
3743 { 3743 {
3744 FX_DWORD req_pos = (FX_DWORD)(m_dwFileLen > 1024 ? m_dwFileLen - 1024 : 0); 3744 FX_DWORD req_pos = (FX_DWORD)(m_dwFileLen > 1024 ? m_dwFileLen - 1024 : 0);
3745 FX_DWORD dwSize = (FX_DWORD)(m_dwFileLen - req_pos); 3745 FX_DWORD dwSize = (FX_DWORD)(m_dwFileLen - req_pos);
3746 if (m_pFileAvail->IsDataAvail(req_pos, dwSize)) { 3746 if (m_pFileAvail->IsDataAvail(req_pos, dwSize)) {
3747 FX_BYTE buffer[1024]; 3747 FX_BYTE buffer[1024];
3748 m_pFileRead->ReadBlock(buffer, req_pos, dwSize); 3748 m_pFileRead->ReadBlock(buffer, req_pos, dwSize);
3749 CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream(buffer, (siz e_t)dwSize, FALSE)); 3749 CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream(buffer, (siz e_t)dwSize, FALSE));
3750 m_syntaxParser.InitParser((IFX_FileStream*)file, 0); 3750 m_syntaxParser.InitParser(file.Get(), 0);
3751 m_syntaxParser.RestorePos(dwSize - 1); 3751 m_syntaxParser.RestorePos(dwSize - 1);
3752 if (m_syntaxParser.SearchWord(FX_BSTRC("startxref"), TRUE, FALSE, dwSize )) { 3752 if (m_syntaxParser.SearchWord(FX_BSTRC("startxref"), TRUE, FALSE, dwSize )) {
3753 FX_BOOL bNumber; 3753 FX_BOOL bNumber;
3754 m_syntaxParser.GetNextWord(bNumber); 3754 m_syntaxParser.GetNextWord(bNumber);
3755 CFX_ByteString xrefpos_str = m_syntaxParser.GetNextWord(bNumber); 3755 CFX_ByteString xrefpos_str = m_syntaxParser.GetNextWord(bNumber);
3756 if (!bNumber) { 3756 if (!bNumber) {
3757 m_docStatus = PDF_DATAAVAIL_ERROR; 3757 m_docStatus = PDF_DATAAVAIL_ERROR;
3758 return FALSE; 3758 return FALSE;
3759 } 3759 }
3760 m_dwXRefOffset = (FX_FILESIZE)FXSYS_atoi64(xrefpos_str); 3760 m_dwXRefOffset = (FX_FILESIZE)FXSYS_atoi64(xrefpos_str);
(...skipping 16 matching lines...) Expand all
3777 FX_DWORD CPDF_DataAvail::CheckCrossRefStream(IFX_DownloadHints* pHints, FX_FILES IZE &xref_offset) 3777 FX_DWORD CPDF_DataAvail::CheckCrossRefStream(IFX_DownloadHints* pHints, FX_FILES IZE &xref_offset)
3778 { 3778 {
3779 xref_offset = 0; 3779 xref_offset = 0;
3780 FX_DWORD req_size = (FX_DWORD)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_P os : 512); 3780 FX_DWORD req_size = (FX_DWORD)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_P os : 512);
3781 if (m_pFileAvail->IsDataAvail(m_Pos, req_size)) { 3781 if (m_pFileAvail->IsDataAvail(m_Pos, req_size)) {
3782 FX_INT32 iSize = (FX_INT32)(m_Pos + req_size - m_dwCurrentXRefSteam); 3782 FX_INT32 iSize = (FX_INT32)(m_Pos + req_size - m_dwCurrentXRefSteam);
3783 CFX_BinaryBuf buf(iSize); 3783 CFX_BinaryBuf buf(iSize);
3784 FX_LPBYTE pBuf = buf.GetBuffer(); 3784 FX_LPBYTE pBuf = buf.GetBuffer();
3785 m_pFileRead->ReadBlock(pBuf, m_dwCurrentXRefSteam, iSize); 3785 m_pFileRead->ReadBlock(pBuf, m_dwCurrentXRefSteam, iSize);
3786 CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream(pBuf, (size_ t)iSize, FALSE)); 3786 CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream(pBuf, (size_ t)iSize, FALSE));
3787 m_parser.m_Syntax.InitParser((IFX_FileStream*)file, 0); 3787 m_parser.m_Syntax.InitParser(file.Get(), 0);
3788 FX_BOOL bNumber = FALSE; 3788 FX_BOOL bNumber = FALSE;
3789 CFX_ByteString objnum = m_parser.m_Syntax.GetNextWord(bNumber); 3789 CFX_ByteString objnum = m_parser.m_Syntax.GetNextWord(bNumber);
3790 if (!bNumber) { 3790 if (!bNumber) {
3791 return -1; 3791 return -1;
3792 } 3792 }
3793 FX_DWORD objNum = FXSYS_atoi(objnum); 3793 FX_DWORD objNum = FXSYS_atoi(objnum);
3794 CPDF_Object *pObj = m_parser.ParseIndirectObjectAt(NULL, 0, objNum, NULL ); 3794 CPDF_Object *pObj = m_parser.ParseIndirectObjectAt(NULL, 0, objNum, NULL );
3795 if (!pObj) { 3795 if (!pObj) {
3796 m_Pos += m_parser.m_Syntax.SavePos(); 3796 m_Pos += m_parser.m_Syntax.SavePos();
3797 return 0; 3797 return 0;
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
4021 CFX_BinaryBuf buf(iSize); 4021 CFX_BinaryBuf buf(iSize);
4022 FX_LPBYTE pBuf = buf.GetBuffer(); 4022 FX_LPBYTE pBuf = buf.GetBuffer();
4023 if (!pBuf) { 4023 if (!pBuf) {
4024 m_docStatus = PDF_DATAAVAIL_ERROR; 4024 m_docStatus = PDF_DATAAVAIL_ERROR;
4025 return FALSE; 4025 return FALSE;
4026 } 4026 }
4027 if (!m_pFileRead->ReadBlock(pBuf, m_dwTrailerOffset, iSize)) { 4027 if (!m_pFileRead->ReadBlock(pBuf, m_dwTrailerOffset, iSize)) {
4028 return FALSE; 4028 return FALSE;
4029 } 4029 }
4030 CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream(pBuf, (size_ t)iSize, FALSE)); 4030 CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream(pBuf, (size_ t)iSize, FALSE));
4031 m_syntaxParser.InitParser((IFX_FileStream*)file, 0); 4031 m_syntaxParser.InitParser(file.Get(), 0);
4032 CPDF_Object *pTrailer = m_syntaxParser.GetObject(NULL, 0, 0, 0); 4032 CPDF_Object *pTrailer = m_syntaxParser.GetObject(NULL, 0, 0, 0);
4033 if (!pTrailer) { 4033 if (!pTrailer) {
4034 m_Pos += m_syntaxParser.SavePos(); 4034 m_Pos += m_syntaxParser.SavePos();
4035 pHints->AddSegment(m_Pos, iTrailerSize); 4035 pHints->AddSegment(m_Pos, iTrailerSize);
4036 return FALSE; 4036 return FALSE;
4037 } 4037 }
4038 if (pTrailer->GetType() != PDFOBJ_DICTIONARY) { 4038 if (pTrailer->GetType() != PDFOBJ_DICTIONARY) {
4039 return FALSE; 4039 return FALSE;
4040 } 4040 }
4041 CPDF_Dictionary *pTrailerDict = pTrailer->GetDict(); 4041 CPDF_Dictionary *pTrailerDict = pTrailer->GetDict();
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
4628 { 4628 {
4629 FX_INT32 iSize = m_childNode.GetSize(); 4629 FX_INT32 iSize = m_childNode.GetSize();
4630 for (FX_INT32 i = 0; i < iSize; ++i) { 4630 for (FX_INT32 i = 0; i < iSize; ++i) {
4631 CPDF_PageNode *pNode = (CPDF_PageNode*)m_childNode[i]; 4631 CPDF_PageNode *pNode = (CPDF_PageNode*)m_childNode[i];
4632 if (pNode) { 4632 if (pNode) {
4633 delete pNode; 4633 delete pNode;
4634 } 4634 }
4635 } 4635 }
4636 m_childNode.RemoveAll(); 4636 m_childNode.RemoveAll();
4637 } 4637 }
OLDNEW
« no previous file with comments | « core/include/fxcrt/fx_basic.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698