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

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

Issue 1239313005: Merge to XFA - else after returns. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 5 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
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 <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "../../../include/fpdfapi/fpdf_module.h" 10 #include "../../../include/fpdfapi/fpdf_module.h"
(...skipping 1979 matching lines...) Expand 10 before | Expand all | Expand 10 after
1990 } 1990 }
1991 } 1991 }
1992 if (!bFirst) { 1992 if (!bFirst) {
1993 buf.AppendByte((uint8_t)code); 1993 buf.AppendByte((uint8_t)code);
1994 } 1994 }
1995 return buf.GetByteString(); 1995 return buf.GetByteString();
1996 } 1996 }
1997 void CPDF_SyntaxParser::ToNextLine() 1997 void CPDF_SyntaxParser::ToNextLine()
1998 { 1998 {
1999 uint8_t ch; 1999 uint8_t ch;
2000 while (1) { 2000 while (GetNextChar(ch)) {
2001 if (!GetNextChar(ch)) {
2002 return;
2003 }
2004 if (ch == '\n') { 2001 if (ch == '\n') {
2005 return; 2002 break;
2006 } 2003 }
2007 if (ch == '\r') { 2004 if (ch == '\r') {
2008 GetNextChar(ch); 2005 GetNextChar(ch);
2009 if (ch == '\n') { 2006 if (ch != '\n') {
2010 return; 2007 --m_Pos;
2011 } else {
2012 m_Pos --;
2013 return;
2014 } 2008 }
2009 break;
2015 } 2010 }
2016 } 2011 }
2017 } 2012 }
2018 void CPDF_SyntaxParser::ToNextWord() 2013 void CPDF_SyntaxParser::ToNextWord()
2019 { 2014 {
2020 uint8_t ch; 2015 uint8_t ch;
2021 if (!GetNextChar(ch)) { 2016 if (!GetNextChar(ch)) {
2022 return; 2017 return;
2023 } 2018 }
2024 uint8_t type = PDF_CharType[ch]; 2019 uint8_t type = PDF_CharType[ch];
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2076 if (bIsNumber) { 2071 if (bIsNumber) {
2077 FX_FILESIZE SavedPos = m_Pos; 2072 FX_FILESIZE SavedPos = m_Pos;
2078 CFX_ByteString nextword = GetNextWord(bIsNumber); 2073 CFX_ByteString nextword = GetNextWord(bIsNumber);
2079 if (bIsNumber) { 2074 if (bIsNumber) {
2080 CFX_ByteString nextword2 = GetNextWord(bIsNumber); 2075 CFX_ByteString nextword2 = GetNextWord(bIsNumber);
2081 if (nextword2 == FX_BSTRC("R")) { 2076 if (nextword2 == FX_BSTRC("R")) {
2082 FX_DWORD objnum = FXSYS_atoi(word); 2077 FX_DWORD objnum = FXSYS_atoi(word);
2083 if (bTypeOnly) { 2078 if (bTypeOnly) {
2084 return (CPDF_Object*)PDFOBJ_REFERENCE; 2079 return (CPDF_Object*)PDFOBJ_REFERENCE;
2085 } 2080 }
2086 pRet = CPDF_Reference::Create(pObjList, objnum); 2081 return new CPDF_Reference(pObjList, objnum);
2087 return pRet;
2088 } else {
2089 m_Pos = SavedPos;
2090 if (bTypeOnly) {
2091 return (CPDF_Object*)PDFOBJ_NUMBER;
2092 }
2093 pRet = CPDF_Number::Create(word);
2094 return pRet;
2095 } 2082 }
2096 } else {
2097 m_Pos = SavedPos;
2098 if (bTypeOnly) {
2099 return (CPDF_Object*)PDFOBJ_NUMBER;
2100 }
2101 pRet = CPDF_Number::Create(word);
2102 return pRet;
2103 } 2083 }
2084 m_Pos = SavedPos;
2085 if (bTypeOnly) {
2086 return (CPDF_Object*)PDFOBJ_NUMBER;
2087 }
2088 return CPDF_Number::Create(word);
2104 } 2089 }
2105 if (word == FX_BSTRC("true") || word == FX_BSTRC("false")) { 2090 if (word == FX_BSTRC("true") || word == FX_BSTRC("false")) {
2106 if (bTypeOnly) { 2091 if (bTypeOnly) {
2107 return (CPDF_Object*)PDFOBJ_BOOLEAN; 2092 return (CPDF_Object*)PDFOBJ_BOOLEAN;
2108 } 2093 }
2109 pRet = CPDF_Boolean::Create(word == FX_BSTRC("true")); 2094 pRet = CPDF_Boolean::Create(word == FX_BSTRC("true"));
2110 return pRet; 2095 return pRet;
2111 } 2096 }
2112 if (word == FX_BSTRC("null")) { 2097 if (word == FX_BSTRC("null")) {
2113 if (bTypeOnly) { 2098 if (bTypeOnly) {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
2257 return (CPDF_Object*)PDFOBJ_INVALID; 2242 return (CPDF_Object*)PDFOBJ_INVALID;
2258 } 2243 }
2259 return NULL; 2244 return NULL;
2260 } 2245 }
2261 if (bIsNumber) { 2246 if (bIsNumber) {
2262 FX_FILESIZE SavedPos = m_Pos; 2247 FX_FILESIZE SavedPos = m_Pos;
2263 CFX_ByteString nextword = GetNextWord(bIsNumber); 2248 CFX_ByteString nextword = GetNextWord(bIsNumber);
2264 if (bIsNumber) { 2249 if (bIsNumber) {
2265 CFX_ByteString nextword2 = GetNextWord(bIsNumber); 2250 CFX_ByteString nextword2 = GetNextWord(bIsNumber);
2266 if (nextword2 == FX_BSTRC("R")) { 2251 if (nextword2 == FX_BSTRC("R")) {
2267 FX_DWORD objnum = FXSYS_atoi(word);
2268 if (bTypeOnly) { 2252 if (bTypeOnly) {
2269 return (CPDF_Object*)PDFOBJ_REFERENCE; 2253 return (CPDF_Object*)PDFOBJ_REFERENCE;
2270 } 2254 }
2271 return CPDF_Reference::Create(pObjList, objnum); 2255 FX_DWORD objnum = FXSYS_atoi(word);
2272 } else { 2256 return new CPDF_Reference(pObjList, objnum);
2273 m_Pos = SavedPos;
2274 if (bTypeOnly) {
2275 return (CPDF_Object*)PDFOBJ_NUMBER;
2276 }
2277 return CPDF_Number::Create(word);
2278 } 2257 }
2279 } else {
2280 m_Pos = SavedPos;
2281 if (bTypeOnly) {
2282 return (CPDF_Object*)PDFOBJ_NUMBER;
2283 }
2284 return CPDF_Number::Create(word);
2285 } 2258 }
2259 m_Pos = SavedPos;
2260 if (bTypeOnly) {
2261 return (CPDF_Object*)PDFOBJ_NUMBER;
2262 }
2263 return CPDF_Number::Create(word);
2286 } 2264 }
2287 if (word == FX_BSTRC("true") || word == FX_BSTRC("false")) { 2265 if (word == FX_BSTRC("true") || word == FX_BSTRC("false")) {
2288 if (bTypeOnly) { 2266 if (bTypeOnly) {
2289 return (CPDF_Object*)PDFOBJ_BOOLEAN; 2267 return (CPDF_Object*)PDFOBJ_BOOLEAN;
2290 } 2268 }
2291 return CPDF_Boolean::Create(word == FX_BSTRC("true")); 2269 return CPDF_Boolean::Create(word == FX_BSTRC("true"));
2292 } 2270 }
2293 if (word == FX_BSTRC("null")) { 2271 if (word == FX_BSTRC("null")) {
2294 if (bTypeOnly) { 2272 if (bTypeOnly) {
2295 return (CPDF_Object*)PDFOBJ_NULL; 2273 return (CPDF_Object*)PDFOBJ_NULL;
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after
3145 if (!m_objs_array.GetSize()) { 3123 if (!m_objs_array.GetSize()) {
3146 m_objs_array.RemoveAll(); 3124 m_objs_array.RemoveAll();
3147 m_objnum_array.RemoveAll(); 3125 m_objnum_array.RemoveAll();
3148 CFX_PtrArray obj_array; 3126 CFX_PtrArray obj_array;
3149 obj_array.Append(m_arrayAcroforms); 3127 obj_array.Append(m_arrayAcroforms);
3150 FX_BOOL bRet = IsObjectsAvail(obj_array, FALSE, pHints, m_objs_array); 3128 FX_BOOL bRet = IsObjectsAvail(obj_array, FALSE, pHints, m_objs_array);
3151 if (bRet) { 3129 if (bRet) {
3152 m_objs_array.RemoveAll(); 3130 m_objs_array.RemoveAll();
3153 } 3131 }
3154 return bRet; 3132 return bRet;
3133 }
3134 CFX_PtrArray new_objs_array;
3135 FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array);
3136 if (bRet) {
3137 int32_t iSize = m_arrayAcroforms.GetSize();
3138 for (int32_t i = 0; i < iSize; ++i) {
3139 ((CPDF_Object *)m_arrayAcroforms.GetAt(i))->Release();
3140 }
3141 m_arrayAcroforms.RemoveAll();
3155 } else { 3142 } else {
3156 CFX_PtrArray new_objs_array; 3143 m_objs_array.RemoveAll();
3157 FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_arra y); 3144 m_objs_array.Append(new_objs_array);
3158 if (bRet) {
3159 int32_t iSize = m_arrayAcroforms.GetSize();
3160 for (int32_t i = 0; i < iSize; ++i) {
3161 ((CPDF_Object *)m_arrayAcroforms.GetAt(i))->Release();
3162 }
3163 m_arrayAcroforms.RemoveAll();
3164 } else {
3165 m_objs_array.RemoveAll();
3166 m_objs_array.Append(new_objs_array);
3167 }
3168 return bRet;
3169 } 3145 }
3146 return bRet;
3170 } 3147 }
3171 FX_BOOL CPDF_DataAvail::CheckAcroForm(IFX_DownloadHints* pHints) 3148 FX_BOOL CPDF_DataAvail::CheckAcroForm(IFX_DownloadHints* pHints)
3172 { 3149 {
3173 FX_BOOL bExist = FALSE; 3150 FX_BOOL bExist = FALSE;
3174 m_pAcroForm = GetObject(m_dwAcroFormObjNum, pHints, &bExist); 3151 m_pAcroForm = GetObject(m_dwAcroFormObjNum, pHints, &bExist);
3175 if (!bExist) { 3152 if (!bExist) {
3176 m_docStatus = PDF_DATAAVAIL_PAGETREE; 3153 m_docStatus = PDF_DATAAVAIL_PAGETREE;
3177 return TRUE; 3154 return TRUE;
3178 } 3155 }
3179 if (!m_pAcroForm) { 3156 if (!m_pAcroForm) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
3213 return LoadAllFile(pHints); 3190 return LoadAllFile(pHints);
3214 case PDF_DATAAVAIL_ROOT: 3191 case PDF_DATAAVAIL_ROOT:
3215 return CheckRoot(pHints); 3192 return CheckRoot(pHints);
3216 case PDF_DATAAVAIL_INFO: 3193 case PDF_DATAAVAIL_INFO:
3217 return CheckInfo(pHints); 3194 return CheckInfo(pHints);
3218 case PDF_DATAAVAIL_ACROFORM: 3195 case PDF_DATAAVAIL_ACROFORM:
3219 return CheckAcroForm(pHints); 3196 return CheckAcroForm(pHints);
3220 case PDF_DATAAVAIL_PAGETREE: 3197 case PDF_DATAAVAIL_PAGETREE:
3221 if (m_bTotalLoadPageTree) { 3198 if (m_bTotalLoadPageTree) {
3222 return CheckPages(pHints); 3199 return CheckPages(pHints);
3223 } else {
3224 return LoadDocPages(pHints);
3225 } 3200 }
3201 return LoadDocPages(pHints);
3226 case PDF_DATAAVAIL_PAGE: 3202 case PDF_DATAAVAIL_PAGE:
3227 if (m_bTotalLoadPageTree) { 3203 if (m_bTotalLoadPageTree) {
3228 return CheckPage(pHints); 3204 return CheckPage(pHints);
3229 } else {
3230 m_docStatus = PDF_DATAAVAIL_PAGE_LATERLOAD;
3231 return TRUE;
3232 } 3205 }
3206 m_docStatus = PDF_DATAAVAIL_PAGE_LATERLOAD;
3207 return TRUE;
3233 case PDF_DATAAVAIL_ERROR: 3208 case PDF_DATAAVAIL_ERROR:
3234 return LoadAllFile(pHints); 3209 return LoadAllFile(pHints);
3235 case PDF_DATAAVAIL_PAGE_LATERLOAD: 3210 case PDF_DATAAVAIL_PAGE_LATERLOAD:
3236 m_docStatus = PDF_DATAAVAIL_PAGE; 3211 m_docStatus = PDF_DATAAVAIL_PAGE;
3237 default: 3212 default:
3238 m_bDocAvail = TRUE; 3213 m_bDocAvail = TRUE;
3239 return TRUE; 3214 return TRUE;
3240 } 3215 }
3241 } 3216 }
3242 FX_BOOL CPDF_DataAvail::CheckPageStatus(IFX_DownloadHints* pHints) 3217 FX_BOOL CPDF_DataAvail::CheckPageStatus(IFX_DownloadHints* pHints)
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
3766 } 3741 }
3767 m_dwXRefOffset = (FX_FILESIZE)FXSYS_atoi64(xrefpos_str); 3742 m_dwXRefOffset = (FX_FILESIZE)FXSYS_atoi64(xrefpos_str);
3768 if (!m_dwXRefOffset || m_dwXRefOffset > m_dwFileLen) { 3743 if (!m_dwXRefOffset || m_dwXRefOffset > m_dwFileLen) {
3769 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; 3744 m_docStatus = PDF_DATAAVAIL_LOADALLFILE;
3770 return TRUE; 3745 return TRUE;
3771 } 3746 }
3772 m_dwLastXRefOffset = m_dwXRefOffset; 3747 m_dwLastXRefOffset = m_dwXRefOffset;
3773 SetStartOffset(m_dwXRefOffset); 3748 SetStartOffset(m_dwXRefOffset);
3774 m_docStatus = PDF_DATAAVAIL_CROSSREF; 3749 m_docStatus = PDF_DATAAVAIL_CROSSREF;
3775 return TRUE; 3750 return TRUE;
3776 } else {
3777 m_docStatus = PDF_DATAAVAIL_LOADALLFILE;
3778 return TRUE;
3779 } 3751 }
3752 m_docStatus = PDF_DATAAVAIL_LOADALLFILE;
3753 return TRUE;
3780 } 3754 }
3781 pHints->AddSegment(req_pos, dwSize); 3755 pHints->AddSegment(req_pos, dwSize);
3782 return FALSE; 3756 return FALSE;
3783 } 3757 }
3784 int32_t CPDF_DataAvail::CheckCrossRefStream(IFX_DownloadHints* pHints, FX_FILESI ZE &xref_offset) 3758 int32_t CPDF_DataAvail::CheckCrossRefStream(IFX_DownloadHints* pHints, FX_FILESI ZE &xref_offset)
3785 { 3759 {
3786 xref_offset = 0; 3760 xref_offset = 0;
3787 FX_DWORD req_size = (FX_DWORD)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_P os : 512); 3761 FX_DWORD req_size = (FX_DWORD)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_P os : 512);
3788 if (m_pFileAvail->IsDataAvail(m_Pos, req_size)) { 3762 if (m_pFileAvail->IsDataAvail(m_Pos, req_size)) {
3789 int32_t iSize = (int32_t)(m_Pos + req_size - m_dwCurrentXRefSteam); 3763 int32_t iSize = (int32_t)(m_Pos + req_size - m_dwCurrentXRefSteam);
(...skipping 14 matching lines...) Expand all
3804 return 0; 3778 return 0;
3805 } 3779 }
3806 CPDF_Dictionary* pDict = pObj->GetDict(); 3780 CPDF_Dictionary* pDict = pObj->GetDict();
3807 CPDF_Object *pName = pDict ? pDict->GetElement(FX_BSTRC("Type")) : NULL; 3781 CPDF_Object *pName = pDict ? pDict->GetElement(FX_BSTRC("Type")) : NULL;
3808 if (pName && pName->GetType() == PDFOBJ_NAME) { 3782 if (pName && pName->GetType() == PDFOBJ_NAME) {
3809 if (pName->GetString() == FX_BSTRC("XRef")) { 3783 if (pName->GetString() == FX_BSTRC("XRef")) {
3810 m_Pos += m_parser.m_Syntax.SavePos(); 3784 m_Pos += m_parser.m_Syntax.SavePos();
3811 xref_offset = pObj->GetDict()->GetInteger(FX_BSTRC("Prev")); 3785 xref_offset = pObj->GetDict()->GetInteger(FX_BSTRC("Prev"));
3812 pObj->Release(); 3786 pObj->Release();
3813 return 1; 3787 return 1;
3814 } else {
3815 pObj->Release();
3816 return -1;
3817 } 3788 }
3818 } 3789 }
3819 pObj->Release(); 3790 pObj->Release();
3820 return -1; 3791 return -1;
3821 } 3792 }
3822 pHints->AddSegment(m_Pos, req_size); 3793 pHints->AddSegment(m_Pos, req_size);
3823 return 0; 3794 return 0;
3824 } 3795 }
3825 inline void CPDF_DataAvail::SetStartOffset(FX_FILESIZE dwOffset) 3796 inline void CPDF_DataAvail::SetStartOffset(FX_FILESIZE dwOffset)
3826 { 3797 {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
3960 FX_FILESIZE xref_offset = 0; 3931 FX_FILESIZE xref_offset = 0;
3961 int32_t nRet = CheckCrossRefStream(pHints, xref_offset); 3932 int32_t nRet = CheckCrossRefStream(pHints, xref_offset);
3962 if (nRet == 1) { 3933 if (nRet == 1) {
3963 if (!xref_offset) { 3934 if (!xref_offset) {
3964 m_docStatus = PDF_DATAAVAIL_LOADALLCRSOSSREF; 3935 m_docStatus = PDF_DATAAVAIL_LOADALLCRSOSSREF;
3965 } else { 3936 } else {
3966 m_dwCurrentXRefSteam = xref_offset; 3937 m_dwCurrentXRefSteam = xref_offset;
3967 m_Pos = xref_offset; 3938 m_Pos = xref_offset;
3968 } 3939 }
3969 return TRUE; 3940 return TRUE;
3970 } else if (nRet == -1) { 3941 }
3942 if (nRet == -1) {
3971 m_docStatus = PDF_DATAAVAIL_ERROR; 3943 m_docStatus = PDF_DATAAVAIL_ERROR;
3972 } 3944 }
3973 return FALSE; 3945 return FALSE;
3974 } 3946 }
3975 FX_BOOL CPDF_DataAvail::CheckCrossRef(IFX_DownloadHints* pHints) 3947 FX_BOOL CPDF_DataAvail::CheckCrossRef(IFX_DownloadHints* pHints)
3976 { 3948 {
3977 int32_t iSize = 0; 3949 int32_t iSize = 0;
3978 CFX_ByteString token; 3950 CFX_ByteString token;
3979 if (!GetNextToken(token)) { 3951 if (!GetNextToken(token)) {
3980 iSize = (int32_t)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512) ; 3952 iSize = (int32_t)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512) ;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
4063 } else { 4035 } else {
4064 m_dwPrevXRefOffset = xrefpos; 4036 m_dwPrevXRefOffset = xrefpos;
4065 if (m_dwPrevXRefOffset >= m_dwFileLen) { 4037 if (m_dwPrevXRefOffset >= m_dwFileLen) {
4066 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; 4038 m_docStatus = PDF_DATAAVAIL_LOADALLFILE;
4067 } else { 4039 } else {
4068 SetStartOffset(m_dwPrevXRefOffset); 4040 SetStartOffset(m_dwPrevXRefOffset);
4069 m_docStatus = PDF_DATAAVAIL_TRAILER_APPEND; 4041 m_docStatus = PDF_DATAAVAIL_TRAILER_APPEND;
4070 } 4042 }
4071 } 4043 }
4072 return TRUE; 4044 return TRUE;
4073 } else {
4074 m_dwPrevXRefOffset = 0;
4075 m_docStatus = PDF_DATAAVAIL_TRAILER_APPEND;
4076 pTrailer->Release();
4077 } 4045 }
4046 m_dwPrevXRefOffset = 0;
4047 m_docStatus = PDF_DATAAVAIL_TRAILER_APPEND;
4048 pTrailer->Release();
4078 return TRUE; 4049 return TRUE;
4079 } 4050 }
4080 pHints->AddSegment(m_Pos, iTrailerSize); 4051 pHints->AddSegment(m_Pos, iTrailerSize);
4081 return FALSE; 4052 return FALSE;
4082 } 4053 }
4083 FX_BOOL CPDF_DataAvail::CheckPage(int32_t iPage, IFX_DownloadHints* pHints) 4054 FX_BOOL CPDF_DataAvail::CheckPage(int32_t iPage, IFX_DownloadHints* pHints)
4084 { 4055 {
4085 while (TRUE) { 4056 while (TRUE) {
4086 switch (m_docStatus) { 4057 switch (m_docStatus) {
4087 case PDF_DATAAVAIL_PAGETREE: 4058 case PDF_DATAAVAIL_PAGETREE:
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
4300 return FALSE; 4271 return FALSE;
4301 } 4272 }
4302 FX_BOOL CPDF_DataAvail::LoadDocPages(IFX_DownloadHints* pHints) 4273 FX_BOOL CPDF_DataAvail::LoadDocPages(IFX_DownloadHints* pHints)
4303 { 4274 {
4304 if (!CheckUnkownPageNode(m_PagesObjNum, &m_pageNodes, pHints)) { 4275 if (!CheckUnkownPageNode(m_PagesObjNum, &m_pageNodes, pHints)) {
4305 return FALSE; 4276 return FALSE;
4306 } 4277 }
4307 if (CheckPageCount(pHints)) { 4278 if (CheckPageCount(pHints)) {
4308 m_docStatus = PDF_DATAAVAIL_PAGE; 4279 m_docStatus = PDF_DATAAVAIL_PAGE;
4309 return TRUE; 4280 return TRUE;
4310 } else {
4311 m_bTotalLoadPageTree = TRUE;
4312 } 4281 }
4282 m_bTotalLoadPageTree = TRUE;
4313 return FALSE; 4283 return FALSE;
4314 } 4284 }
4315 FX_BOOL CPDF_DataAvail::LoadPages(IFX_DownloadHints* pHints) 4285 FX_BOOL CPDF_DataAvail::LoadPages(IFX_DownloadHints* pHints)
4316 { 4286 {
4317 while (!m_bPagesTreeLoad) { 4287 while (!m_bPagesTreeLoad) {
4318 if (!CheckPageStatus(pHints)) { 4288 if (!CheckPageStatus(pHints)) {
4319 return FALSE; 4289 return FALSE;
4320 } 4290 }
4321 } 4291 }
4322 if (m_bPagesLoad) { 4292 if (m_bPagesLoad) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
4368 if (!pAnnots) { 4338 if (!pAnnots) {
4369 return TRUE; 4339 return TRUE;
4370 } 4340 }
4371 CFX_PtrArray obj_array; 4341 CFX_PtrArray obj_array;
4372 obj_array.Add(pAnnots); 4342 obj_array.Add(pAnnots);
4373 FX_BOOL bRet = IsObjectsAvail(obj_array, FALSE, pHints, m_objs_array); 4343 FX_BOOL bRet = IsObjectsAvail(obj_array, FALSE, pHints, m_objs_array);
4374 if (bRet) { 4344 if (bRet) {
4375 m_objs_array.RemoveAll(); 4345 m_objs_array.RemoveAll();
4376 } 4346 }
4377 return bRet; 4347 return bRet;
4378 } else {
4379 CFX_PtrArray new_objs_array;
4380 FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_arra y);
4381 m_objs_array.RemoveAll();
4382 if (!bRet) {
4383 m_objs_array.Append(new_objs_array);
4384 }
4385 return bRet;
4386 } 4348 }
4349 CFX_PtrArray new_objs_array;
4350 FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array);
4351 m_objs_array.RemoveAll();
4352 if (!bRet) {
4353 m_objs_array.Append(new_objs_array);
4354 }
4355 return bRet;
4387 } 4356 }
4388 FX_BOOL CPDF_DataAvail::CheckLinearizedFirstPage(int32_t iPage, IFX_DownloadHint s* pHints) 4357 FX_BOOL CPDF_DataAvail::CheckLinearizedFirstPage(int32_t iPage, IFX_DownloadHint s* pHints)
4389 { 4358 {
4390 if (!m_bAnnotsLoad) { 4359 if (!m_bAnnotsLoad) {
4391 if (!CheckPageAnnots(iPage, pHints)) { 4360 if (!CheckPageAnnots(iPage, pHints)) {
4392 return FALSE; 4361 return FALSE;
4393 } 4362 }
4394 m_bAnnotsLoad = TRUE; 4363 m_bAnnotsLoad = TRUE;
4395 } 4364 }
4396 if (m_bAnnotsLoad) 4365 if (m_bAnnotsLoad) {
4397 if (!CheckLinearizedData(pHints)) { 4366 if (!CheckLinearizedData(pHints))
4398 return FALSE; 4367 return FALSE;
4399 } 4368 }
4400 m_bPageLoadedOK = FALSE; 4369 m_bPageLoadedOK = FALSE;
4401 return TRUE; 4370 return TRUE;
4402 } 4371 }
4403 FX_BOOL CPDF_DataAvail::HaveResourceAncestor(CPDF_Dictionary *pDict) 4372 FX_BOOL CPDF_DataAvail::HaveResourceAncestor(CPDF_Dictionary *pDict)
4404 { 4373 {
4405 CFX_AutoRestorer<int> restorer(&s_CurrentDataAvailRecursionDepth); 4374 CFX_AutoRestorer<int> restorer(&s_CurrentDataAvailRecursionDepth);
4406 if (++s_CurrentDataAvailRecursionDepth > kMaxDataAvailRecursionDepth) { 4375 if (++s_CurrentDataAvailRecursionDepth > kMaxDataAvailRecursionDepth) {
4407 return FALSE; 4376 return FALSE;
4408 } 4377 }
4409 CPDF_Object *pParent = pDict->GetElement("Parent"); 4378 CPDF_Object *pParent = pDict->GetElement("Parent");
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
4544 { 4513 {
4545 if (!m_objs_array.GetSize()) { 4514 if (!m_objs_array.GetSize()) {
4546 m_objs_array.RemoveAll(); 4515 m_objs_array.RemoveAll();
4547 CFX_PtrArray obj_array; 4516 CFX_PtrArray obj_array;
4548 obj_array.Add(m_pPageResource); 4517 obj_array.Add(m_pPageResource);
4549 FX_BOOL bRet = IsObjectsAvail(obj_array, TRUE, pHints, m_objs_array); 4518 FX_BOOL bRet = IsObjectsAvail(obj_array, TRUE, pHints, m_objs_array);
4550 if (bRet) { 4519 if (bRet) {
4551 m_objs_array.RemoveAll(); 4520 m_objs_array.RemoveAll();
4552 } 4521 }
4553 return bRet; 4522 return bRet;
4554 } else {
4555 CFX_PtrArray new_objs_array;
4556 FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_arra y);
4557 m_objs_array.RemoveAll();
4558 if (!bRet) {
4559 m_objs_array.Append(new_objs_array);
4560 }
4561 return bRet;
4562 } 4523 }
4524 CFX_PtrArray new_objs_array;
4525 FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array);
4526 m_objs_array.RemoveAll();
4527 if (!bRet) {
4528 m_objs_array.Append(new_objs_array);
4529 }
4530 return bRet;
4563 } 4531 }
4564 void CPDF_DataAvail::GetLinearizedMainXRefInfo(FX_FILESIZE *pPos, FX_DWORD *pSiz e) 4532 void CPDF_DataAvail::GetLinearizedMainXRefInfo(FX_FILESIZE *pPos, FX_DWORD *pSiz e)
4565 { 4533 {
4566 if (pPos) { 4534 if (pPos) {
4567 *pPos = m_dwLastXRefOffset; 4535 *pPos = m_dwLastXRefOffset;
4568 } 4536 }
4569 if (pSize) { 4537 if (pSize) {
4570 *pSize = (FX_DWORD)(m_dwFileLen - m_dwLastXRefOffset); 4538 *pSize = (FX_DWORD)(m_dwFileLen - m_dwLastXRefOffset);
4571 } 4539 }
4572 } 4540 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
4609 } 4577 }
4610 m_number_array.InsertAt(iNext, dwObjNum); 4578 m_number_array.InsertAt(iNext, dwObjNum);
4611 } 4579 }
4612 FX_BOOL CPDF_SortObjNumArray::Find(FX_DWORD dwObjNum) 4580 FX_BOOL CPDF_SortObjNumArray::Find(FX_DWORD dwObjNum)
4613 { 4581 {
4614 int32_t iNext = 0; 4582 int32_t iNext = 0;
4615 return BinarySearch(dwObjNum, iNext); 4583 return BinarySearch(dwObjNum, iNext);
4616 } 4584 }
4617 FX_BOOL CPDF_SortObjNumArray::BinarySearch(FX_DWORD value, int32_t &iNext) 4585 FX_BOOL CPDF_SortObjNumArray::BinarySearch(FX_DWORD value, int32_t &iNext)
4618 { 4586 {
4619 int32_t iLen = m_number_array.GetSize();
4620 int32_t iLow = 0; 4587 int32_t iLow = 0;
4621 int32_t iHigh = iLen - 1; 4588 int32_t iHigh = m_number_array.GetSize() - 1;
4622 int32_t iMid = 0;
4623 while (iLow <= iHigh) { 4589 while (iLow <= iHigh) {
4624 iMid = (iLow + iHigh) / 2; 4590 int32_t iMid = (iLow + iHigh) / 2;
4625 if (m_number_array.GetAt(iMid) == value) { 4591 if (m_number_array.GetAt(iMid) == value) {
4626 iNext = iMid; 4592 iNext = iMid;
4627 return TRUE; 4593 return TRUE;
4628 } else if (m_number_array.GetAt(iMid) > value) { 4594 }
4595 if (m_number_array.GetAt(iMid) > value) {
4629 iHigh = iMid - 1; 4596 iHigh = iMid - 1;
4630 } else if (m_number_array.GetAt(iMid) < value) { 4597 } else if (m_number_array.GetAt(iMid) < value) {
4631 iLow = iMid + 1; 4598 iLow = iMid + 1;
4632 } 4599 }
4633 } 4600 }
4634 iNext = iLow; 4601 iNext = iLow;
4635 return FALSE; 4602 return FALSE;
4636 } 4603 }
4637 CPDF_PageNode::~CPDF_PageNode() 4604 CPDF_PageNode::~CPDF_PageNode()
4638 { 4605 {
4639 int32_t iSize = m_childNode.GetSize(); 4606 int32_t iSize = m_childNode.GetSize();
4640 for (int32_t i = 0; i < iSize; ++i) { 4607 for (int32_t i = 0; i < iSize; ++i) {
4641 CPDF_PageNode* pNode = (CPDF_PageNode*)m_childNode[i]; 4608 CPDF_PageNode* pNode = (CPDF_PageNode*)m_childNode[i];
4642 delete pNode; 4609 delete pNode;
4643 } 4610 }
4644 m_childNode.RemoveAll(); 4611 m_childNode.RemoveAll();
4645 } 4612 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698