OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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/fpdf_parser/include/ipdf_data_avail.h" | 7 #include "core/fpdfapi/fpdf_parser/include/cpdf_data_avail.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_parser/cpdf_data_avail.h" | 9 #include "core/fpdfapi/fpdf_parser/cpdf_hint_tables.h" |
10 #include "core/fpdfapi/fpdf_parser/fpdf_parser_utility.h" | 10 #include "core/fpdfapi/fpdf_parser/fpdf_parser_utility.h" |
11 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 11 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
12 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" | 12 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" |
13 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 13 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
14 #include "core/fpdfapi/fpdf_parser/include/cpdf_name.h" | 14 #include "core/fpdfapi/fpdf_parser/include/cpdf_name.h" |
15 #include "core/fpdfapi/fpdf_parser/include/cpdf_number.h" | 15 #include "core/fpdfapi/fpdf_parser/include/cpdf_number.h" |
16 #include "core/fpdfapi/fpdf_parser/include/cpdf_reference.h" | 16 #include "core/fpdfapi/fpdf_parser/include/cpdf_reference.h" |
17 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h" | 17 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h" |
18 #include "core/fpdfapi/include/cpdf_modulemgr.h" | 18 #include "core/fpdfapi/include/cpdf_modulemgr.h" |
19 #include "core/fxcrt/include/fx_ext.h" | 19 #include "core/fxcrt/include/fx_ext.h" |
20 #include "core/fxcrt/include/fx_safe_types.h" | 20 #include "core/fxcrt/include/fx_safe_types.h" |
21 #include "third_party/base/stl_util.h" | 21 #include "third_party/base/stl_util.h" |
22 | 22 |
23 IPDF_DataAvail::IPDF_DataAvail(IPDF_DataAvail::FileAvail* pFileAvail, | 23 CPDF_DataAvail::FileAvail::~FileAvail() {} |
24 IFX_FileRead* pFileRead) | |
25 : m_pFileAvail(pFileAvail), m_pFileRead(pFileRead) {} | |
26 | 24 |
27 IPDF_DataAvail::~IPDF_DataAvail() {} | 25 CPDF_DataAvail::DownloadHints::~DownloadHints() {} |
28 | |
29 IPDF_DataAvail::FileAvail::~FileAvail() {} | |
30 | |
31 IPDF_DataAvail::DownloadHints::~DownloadHints() {} | |
32 | |
33 // static | |
34 IPDF_DataAvail* IPDF_DataAvail::Create(IPDF_DataAvail::FileAvail* pFileAvail, | |
35 IFX_FileRead* pFileRead) { | |
36 return new CPDF_DataAvail(pFileAvail, pFileRead, TRUE); | |
37 } | |
38 | 26 |
39 // static | 27 // static |
40 int CPDF_DataAvail::s_CurrentDataAvailRecursionDepth = 0; | 28 int CPDF_DataAvail::s_CurrentDataAvailRecursionDepth = 0; |
41 | 29 |
42 CPDF_DataAvail::CPDF_DataAvail(IPDF_DataAvail::FileAvail* pFileAvail, | 30 CPDF_DataAvail::CPDF_DataAvail(FileAvail* pFileAvail, |
43 IFX_FileRead* pFileRead, | 31 IFX_FileRead* pFileRead, |
44 FX_BOOL bSupportHintTable) | 32 FX_BOOL bSupportHintTable) |
45 : IPDF_DataAvail(pFileAvail, pFileRead) { | 33 : m_pFileAvail(pFileAvail), m_pFileRead(pFileRead) { |
46 m_Pos = 0; | 34 m_Pos = 0; |
47 m_dwFileLen = 0; | 35 m_dwFileLen = 0; |
48 if (m_pFileRead) { | 36 if (m_pFileRead) { |
49 m_dwFileLen = (uint32_t)m_pFileRead->GetSize(); | 37 m_dwFileLen = (uint32_t)m_pFileRead->GetSize(); |
50 } | 38 } |
51 m_dwCurrentOffset = 0; | 39 m_dwCurrentOffset = 0; |
52 m_dwXRefOffset = 0; | 40 m_dwXRefOffset = 0; |
53 m_bufferOffset = 0; | 41 m_bufferOffset = 0; |
54 m_dwFirstPageNo = 0; | 42 m_dwFirstPageNo = 0; |
55 m_bufferSize = 0; | 43 m_bufferSize = 0; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 if (it == pParser->m_SortedOffset.end() || | 117 if (it == pParser->m_SortedOffset.end() || |
130 ++it == pParser->m_SortedOffset.end()) { | 118 ++it == pParser->m_SortedOffset.end()) { |
131 return 0; | 119 return 0; |
132 } | 120 } |
133 return *it - offset; | 121 return *it - offset; |
134 } | 122 } |
135 | 123 |
136 FX_BOOL CPDF_DataAvail::IsObjectsAvail( | 124 FX_BOOL CPDF_DataAvail::IsObjectsAvail( |
137 CFX_ArrayTemplate<CPDF_Object*>& obj_array, | 125 CFX_ArrayTemplate<CPDF_Object*>& obj_array, |
138 FX_BOOL bParsePage, | 126 FX_BOOL bParsePage, |
139 IPDF_DataAvail::DownloadHints* pHints, | 127 DownloadHints* pHints, |
140 CFX_ArrayTemplate<CPDF_Object*>& ret_array) { | 128 CFX_ArrayTemplate<CPDF_Object*>& ret_array) { |
141 if (!obj_array.GetSize()) | 129 if (!obj_array.GetSize()) |
142 return TRUE; | 130 return TRUE; |
143 | 131 |
144 uint32_t count = 0; | 132 uint32_t count = 0; |
145 CFX_ArrayTemplate<CPDF_Object*> new_obj_array; | 133 CFX_ArrayTemplate<CPDF_Object*> new_obj_array; |
146 for (int i = 0; i < obj_array.GetSize(); i++) { | 134 for (int i = 0; i < obj_array.GetSize(); i++) { |
147 CPDF_Object* pObj = obj_array[i]; | 135 CPDF_Object* pObj = obj_array[i]; |
148 if (!pObj) | 136 if (!pObj) |
149 continue; | 137 continue; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 } | 192 } |
205 } | 193 } |
206 return FALSE; | 194 return FALSE; |
207 } | 195 } |
208 | 196 |
209 obj_array.RemoveAll(); | 197 obj_array.RemoveAll(); |
210 obj_array.Append(new_obj_array); | 198 obj_array.Append(new_obj_array); |
211 return IsObjectsAvail(obj_array, FALSE, pHints, ret_array); | 199 return IsObjectsAvail(obj_array, FALSE, pHints, ret_array); |
212 } | 200 } |
213 | 201 |
214 IPDF_DataAvail::DocAvailStatus CPDF_DataAvail::IsDocAvail( | 202 CPDF_DataAvail::DocAvailStatus CPDF_DataAvail::IsDocAvail( |
215 IPDF_DataAvail::DownloadHints* pHints) { | 203 DownloadHints* pHints) { |
216 if (!m_dwFileLen && m_pFileRead) { | 204 if (!m_dwFileLen && m_pFileRead) { |
217 m_dwFileLen = (uint32_t)m_pFileRead->GetSize(); | 205 m_dwFileLen = (uint32_t)m_pFileRead->GetSize(); |
218 if (!m_dwFileLen) | 206 if (!m_dwFileLen) |
219 return DataError; | 207 return DataError; |
220 } | 208 } |
221 | 209 |
222 while (!m_bDocAvail) { | 210 while (!m_bDocAvail) { |
223 if (!CheckDocStatus(pHints)) | 211 if (!CheckDocStatus(pHints)) |
224 return DataNotAvailable; | 212 return DataNotAvailable; |
225 } | 213 } |
226 | 214 |
227 return DataAvailable; | 215 return DataAvailable; |
228 } | 216 } |
229 | 217 |
230 FX_BOOL CPDF_DataAvail::CheckAcroFormSubObject( | 218 FX_BOOL CPDF_DataAvail::CheckAcroFormSubObject(DownloadHints* pHints) { |
231 IPDF_DataAvail::DownloadHints* pHints) { | |
232 if (!m_objs_array.GetSize()) { | 219 if (!m_objs_array.GetSize()) { |
233 m_objs_array.RemoveAll(); | 220 m_objs_array.RemoveAll(); |
234 m_ObjectSet.clear(); | 221 m_ObjectSet.clear(); |
235 CFX_ArrayTemplate<CPDF_Object*> obj_array; | 222 CFX_ArrayTemplate<CPDF_Object*> obj_array; |
236 obj_array.Append(m_arrayAcroforms); | 223 obj_array.Append(m_arrayAcroforms); |
237 FX_BOOL bRet = IsObjectsAvail(obj_array, FALSE, pHints, m_objs_array); | 224 FX_BOOL bRet = IsObjectsAvail(obj_array, FALSE, pHints, m_objs_array); |
238 if (bRet) | 225 if (bRet) |
239 m_objs_array.RemoveAll(); | 226 m_objs_array.RemoveAll(); |
240 return bRet; | 227 return bRet; |
241 } | 228 } |
242 | 229 |
243 CFX_ArrayTemplate<CPDF_Object*> new_objs_array; | 230 CFX_ArrayTemplate<CPDF_Object*> new_objs_array; |
244 FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array); | 231 FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array); |
245 if (bRet) { | 232 if (bRet) { |
246 int32_t iSize = m_arrayAcroforms.GetSize(); | 233 int32_t iSize = m_arrayAcroforms.GetSize(); |
247 for (int32_t i = 0; i < iSize; ++i) { | 234 for (int32_t i = 0; i < iSize; ++i) { |
248 m_arrayAcroforms.GetAt(i)->Release(); | 235 m_arrayAcroforms.GetAt(i)->Release(); |
249 } | 236 } |
250 m_arrayAcroforms.RemoveAll(); | 237 m_arrayAcroforms.RemoveAll(); |
251 } else { | 238 } else { |
252 m_objs_array.RemoveAll(); | 239 m_objs_array.RemoveAll(); |
253 m_objs_array.Append(new_objs_array); | 240 m_objs_array.Append(new_objs_array); |
254 } | 241 } |
255 return bRet; | 242 return bRet; |
256 } | 243 } |
257 | 244 |
258 FX_BOOL CPDF_DataAvail::CheckAcroForm(IPDF_DataAvail::DownloadHints* pHints) { | 245 FX_BOOL CPDF_DataAvail::CheckAcroForm(DownloadHints* pHints) { |
259 FX_BOOL bExist = FALSE; | 246 FX_BOOL bExist = FALSE; |
260 m_pAcroForm = GetObject(m_dwAcroFormObjNum, pHints, &bExist); | 247 m_pAcroForm = GetObject(m_dwAcroFormObjNum, pHints, &bExist); |
261 if (!bExist) { | 248 if (!bExist) { |
262 m_docStatus = PDF_DATAAVAIL_PAGETREE; | 249 m_docStatus = PDF_DATAAVAIL_PAGETREE; |
263 return TRUE; | 250 return TRUE; |
264 } | 251 } |
265 | 252 |
266 if (!m_pAcroForm) { | 253 if (!m_pAcroForm) { |
267 if (m_docStatus == PDF_DATAAVAIL_ERROR) { | 254 if (m_docStatus == PDF_DATAAVAIL_ERROR) { |
268 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; | 255 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; |
269 return TRUE; | 256 return TRUE; |
270 } | 257 } |
271 return FALSE; | 258 return FALSE; |
272 } | 259 } |
273 | 260 |
274 m_arrayAcroforms.Add(m_pAcroForm); | 261 m_arrayAcroforms.Add(m_pAcroForm); |
275 m_docStatus = PDF_DATAAVAIL_PAGETREE; | 262 m_docStatus = PDF_DATAAVAIL_PAGETREE; |
276 return TRUE; | 263 return TRUE; |
277 } | 264 } |
278 | 265 |
279 FX_BOOL CPDF_DataAvail::CheckDocStatus(IPDF_DataAvail::DownloadHints* pHints) { | 266 FX_BOOL CPDF_DataAvail::CheckDocStatus(DownloadHints* pHints) { |
280 switch (m_docStatus) { | 267 switch (m_docStatus) { |
281 case PDF_DATAAVAIL_HEADER: | 268 case PDF_DATAAVAIL_HEADER: |
282 return CheckHeader(pHints); | 269 return CheckHeader(pHints); |
283 case PDF_DATAAVAIL_FIRSTPAGE: | 270 case PDF_DATAAVAIL_FIRSTPAGE: |
284 case PDF_DATAAVAIL_FIRSTPAGE_PREPARE: | 271 case PDF_DATAAVAIL_FIRSTPAGE_PREPARE: |
285 return CheckFirstPage(pHints); | 272 return CheckFirstPage(pHints); |
286 case PDF_DATAAVAIL_HINTTABLE: | 273 case PDF_DATAAVAIL_HINTTABLE: |
287 return CheckHintTables(pHints); | 274 return CheckHintTables(pHints); |
288 case PDF_DATAAVAIL_END: | 275 case PDF_DATAAVAIL_END: |
289 return CheckEnd(pHints); | 276 return CheckEnd(pHints); |
(...skipping 29 matching lines...) Expand all Loading... |
319 case PDF_DATAAVAIL_ERROR: | 306 case PDF_DATAAVAIL_ERROR: |
320 return LoadAllFile(pHints); | 307 return LoadAllFile(pHints); |
321 case PDF_DATAAVAIL_PAGE_LATERLOAD: | 308 case PDF_DATAAVAIL_PAGE_LATERLOAD: |
322 m_docStatus = PDF_DATAAVAIL_PAGE; | 309 m_docStatus = PDF_DATAAVAIL_PAGE; |
323 default: | 310 default: |
324 m_bDocAvail = TRUE; | 311 m_bDocAvail = TRUE; |
325 return TRUE; | 312 return TRUE; |
326 } | 313 } |
327 } | 314 } |
328 | 315 |
329 FX_BOOL CPDF_DataAvail::CheckPageStatus(IPDF_DataAvail::DownloadHints* pHints) { | 316 FX_BOOL CPDF_DataAvail::CheckPageStatus(DownloadHints* pHints) { |
330 switch (m_docStatus) { | 317 switch (m_docStatus) { |
331 case PDF_DATAAVAIL_PAGETREE: | 318 case PDF_DATAAVAIL_PAGETREE: |
332 return CheckPages(pHints); | 319 return CheckPages(pHints); |
333 case PDF_DATAAVAIL_PAGE: | 320 case PDF_DATAAVAIL_PAGE: |
334 return CheckPage(pHints); | 321 return CheckPage(pHints); |
335 case PDF_DATAAVAIL_ERROR: | 322 case PDF_DATAAVAIL_ERROR: |
336 return LoadAllFile(pHints); | 323 return LoadAllFile(pHints); |
337 default: | 324 default: |
338 m_bPagesTreeLoad = TRUE; | 325 m_bPagesTreeLoad = TRUE; |
339 m_bPagesLoad = TRUE; | 326 m_bPagesLoad = TRUE; |
340 return TRUE; | 327 return TRUE; |
341 } | 328 } |
342 } | 329 } |
343 | 330 |
344 FX_BOOL CPDF_DataAvail::LoadAllFile(IPDF_DataAvail::DownloadHints* pHints) { | 331 FX_BOOL CPDF_DataAvail::LoadAllFile(DownloadHints* pHints) { |
345 if (m_pFileAvail->IsDataAvail(0, (uint32_t)m_dwFileLen)) { | 332 if (m_pFileAvail->IsDataAvail(0, (uint32_t)m_dwFileLen)) { |
346 m_docStatus = PDF_DATAAVAIL_DONE; | 333 m_docStatus = PDF_DATAAVAIL_DONE; |
347 return TRUE; | 334 return TRUE; |
348 } | 335 } |
349 | 336 |
350 pHints->AddSegment(0, (uint32_t)m_dwFileLen); | 337 pHints->AddSegment(0, (uint32_t)m_dwFileLen); |
351 return FALSE; | 338 return FALSE; |
352 } | 339 } |
353 | 340 |
354 FX_BOOL CPDF_DataAvail::LoadAllXref(IPDF_DataAvail::DownloadHints* pHints) { | 341 FX_BOOL CPDF_DataAvail::LoadAllXref(DownloadHints* pHints) { |
355 m_parser.m_pSyntax->InitParser(m_pFileRead, (uint32_t)m_dwHeaderOffset); | 342 m_parser.m_pSyntax->InitParser(m_pFileRead, (uint32_t)m_dwHeaderOffset); |
356 m_parser.m_bOwnFileRead = false; | 343 m_parser.m_bOwnFileRead = false; |
357 if (!m_parser.LoadAllCrossRefV4(m_dwLastXRefOffset) && | 344 if (!m_parser.LoadAllCrossRefV4(m_dwLastXRefOffset) && |
358 !m_parser.LoadAllCrossRefV5(m_dwLastXRefOffset)) { | 345 !m_parser.LoadAllCrossRefV5(m_dwLastXRefOffset)) { |
359 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; | 346 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; |
360 return FALSE; | 347 return FALSE; |
361 } | 348 } |
362 | 349 |
363 m_dwRootObjNum = m_parser.GetRootObjNum(); | 350 m_dwRootObjNum = m_parser.GetRootObjNum(); |
364 m_dwInfoObjNum = m_parser.GetInfoObjNum(); | 351 m_dwInfoObjNum = m_parser.GetInfoObjNum(); |
365 m_pCurrentParser = &m_parser; | 352 m_pCurrentParser = &m_parser; |
366 m_docStatus = PDF_DATAAVAIL_ROOT; | 353 m_docStatus = PDF_DATAAVAIL_ROOT; |
367 return TRUE; | 354 return TRUE; |
368 } | 355 } |
369 | 356 |
370 CPDF_Object* CPDF_DataAvail::GetObject(uint32_t objnum, | 357 CPDF_Object* CPDF_DataAvail::GetObject(uint32_t objnum, |
371 IPDF_DataAvail::DownloadHints* pHints, | 358 DownloadHints* pHints, |
372 FX_BOOL* pExistInFile) { | 359 FX_BOOL* pExistInFile) { |
373 CPDF_Object* pRet = nullptr; | 360 CPDF_Object* pRet = nullptr; |
374 uint32_t size = 0; | 361 uint32_t size = 0; |
375 FX_FILESIZE offset = 0; | 362 FX_FILESIZE offset = 0; |
376 CPDF_Parser* pParser = nullptr; | 363 CPDF_Parser* pParser = nullptr; |
377 | 364 |
378 if (pExistInFile) | 365 if (pExistInFile) |
379 *pExistInFile = TRUE; | 366 *pExistInFile = TRUE; |
380 | 367 |
381 if (m_pDocument) { | 368 if (m_pDocument) { |
(...skipping 10 matching lines...) Expand all Loading... |
392 | 379 |
393 if (pParser) | 380 if (pParser) |
394 pRet = pParser->ParseIndirectObject(nullptr, objnum); | 381 pRet = pParser->ParseIndirectObject(nullptr, objnum); |
395 | 382 |
396 if (!pRet && pExistInFile) | 383 if (!pRet && pExistInFile) |
397 *pExistInFile = FALSE; | 384 *pExistInFile = FALSE; |
398 | 385 |
399 return pRet; | 386 return pRet; |
400 } | 387 } |
401 | 388 |
402 FX_BOOL CPDF_DataAvail::CheckInfo(IPDF_DataAvail::DownloadHints* pHints) { | 389 FX_BOOL CPDF_DataAvail::CheckInfo(DownloadHints* pHints) { |
403 FX_BOOL bExist = FALSE; | 390 FX_BOOL bExist = FALSE; |
404 CPDF_Object* pInfo = GetObject(m_dwInfoObjNum, pHints, &bExist); | 391 CPDF_Object* pInfo = GetObject(m_dwInfoObjNum, pHints, &bExist); |
405 if (!bExist) { | 392 if (!bExist) { |
406 m_docStatus = | 393 m_docStatus = |
407 (m_bHaveAcroForm ? PDF_DATAAVAIL_ACROFORM : PDF_DATAAVAIL_PAGETREE); | 394 (m_bHaveAcroForm ? PDF_DATAAVAIL_ACROFORM : PDF_DATAAVAIL_PAGETREE); |
408 return TRUE; | 395 return TRUE; |
409 } | 396 } |
410 | 397 |
411 if (!pInfo) { | 398 if (!pInfo) { |
412 if (m_docStatus == PDF_DATAAVAIL_ERROR) { | 399 if (m_docStatus == PDF_DATAAVAIL_ERROR) { |
413 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; | 400 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; |
414 return TRUE; | 401 return TRUE; |
415 } | 402 } |
416 | 403 |
417 if (m_Pos == m_dwFileLen) | 404 if (m_Pos == m_dwFileLen) |
418 m_docStatus = PDF_DATAAVAIL_ERROR; | 405 m_docStatus = PDF_DATAAVAIL_ERROR; |
419 return FALSE; | 406 return FALSE; |
420 } | 407 } |
421 | 408 |
422 if (pInfo) | 409 if (pInfo) |
423 pInfo->Release(); | 410 pInfo->Release(); |
424 | 411 |
425 m_docStatus = | 412 m_docStatus = |
426 (m_bHaveAcroForm ? PDF_DATAAVAIL_ACROFORM : PDF_DATAAVAIL_PAGETREE); | 413 (m_bHaveAcroForm ? PDF_DATAAVAIL_ACROFORM : PDF_DATAAVAIL_PAGETREE); |
427 | 414 |
428 return TRUE; | 415 return TRUE; |
429 } | 416 } |
430 | 417 |
431 FX_BOOL CPDF_DataAvail::CheckRoot(IPDF_DataAvail::DownloadHints* pHints) { | 418 FX_BOOL CPDF_DataAvail::CheckRoot(DownloadHints* pHints) { |
432 FX_BOOL bExist = FALSE; | 419 FX_BOOL bExist = FALSE; |
433 m_pRoot = GetObject(m_dwRootObjNum, pHints, &bExist); | 420 m_pRoot = GetObject(m_dwRootObjNum, pHints, &bExist); |
434 if (!bExist) { | 421 if (!bExist) { |
435 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; | 422 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; |
436 return TRUE; | 423 return TRUE; |
437 } | 424 } |
438 | 425 |
439 if (!m_pRoot) { | 426 if (!m_pRoot) { |
440 if (m_docStatus == PDF_DATAAVAIL_ERROR) { | 427 if (m_docStatus == PDF_DATAAVAIL_ERROR) { |
441 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; | 428 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 } | 476 } |
490 | 477 |
491 bool CPDF_DataAvail::IsFirstCheck(int iPage) { | 478 bool CPDF_DataAvail::IsFirstCheck(int iPage) { |
492 return m_pageMapCheckState.insert(iPage).second; | 479 return m_pageMapCheckState.insert(iPage).second; |
493 } | 480 } |
494 | 481 |
495 void CPDF_DataAvail::ResetFirstCheck(int iPage) { | 482 void CPDF_DataAvail::ResetFirstCheck(int iPage) { |
496 m_pageMapCheckState.erase(iPage); | 483 m_pageMapCheckState.erase(iPage); |
497 } | 484 } |
498 | 485 |
499 FX_BOOL CPDF_DataAvail::CheckPage(IPDF_DataAvail::DownloadHints* pHints) { | 486 FX_BOOL CPDF_DataAvail::CheckPage(DownloadHints* pHints) { |
500 uint32_t iPageObjs = m_PageObjList.GetSize(); | 487 uint32_t iPageObjs = m_PageObjList.GetSize(); |
501 CFX_ArrayTemplate<uint32_t> UnavailObjList; | 488 CFX_ArrayTemplate<uint32_t> UnavailObjList; |
502 for (uint32_t i = 0; i < iPageObjs; ++i) { | 489 for (uint32_t i = 0; i < iPageObjs; ++i) { |
503 uint32_t dwPageObjNum = m_PageObjList.GetAt(i); | 490 uint32_t dwPageObjNum = m_PageObjList.GetAt(i); |
504 FX_BOOL bExist = FALSE; | 491 FX_BOOL bExist = FALSE; |
505 CPDF_Object* pObj = GetObject(dwPageObjNum, pHints, &bExist); | 492 CPDF_Object* pObj = GetObject(dwPageObjNum, pHints, &bExist); |
506 if (!pObj) { | 493 if (!pObj) { |
507 if (bExist) | 494 if (bExist) |
508 UnavailObjList.Add(dwPageObjNum); | 495 UnavailObjList.Add(dwPageObjNum); |
509 continue; | 496 continue; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 m_PageObjList.Add(pRef->GetRefObjNum()); | 571 m_PageObjList.Add(pRef->GetRefObjNum()); |
585 } | 572 } |
586 } break; | 573 } break; |
587 default: | 574 default: |
588 m_docStatus = PDF_DATAAVAIL_ERROR; | 575 m_docStatus = PDF_DATAAVAIL_ERROR; |
589 return FALSE; | 576 return FALSE; |
590 } | 577 } |
591 return TRUE; | 578 return TRUE; |
592 } | 579 } |
593 | 580 |
594 FX_BOOL CPDF_DataAvail::CheckPages(IPDF_DataAvail::DownloadHints* pHints) { | 581 FX_BOOL CPDF_DataAvail::CheckPages(DownloadHints* pHints) { |
595 FX_BOOL bExist = FALSE; | 582 FX_BOOL bExist = FALSE; |
596 CPDF_Object* pPages = GetObject(m_PagesObjNum, pHints, &bExist); | 583 CPDF_Object* pPages = GetObject(m_PagesObjNum, pHints, &bExist); |
597 if (!bExist) { | 584 if (!bExist) { |
598 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; | 585 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; |
599 return TRUE; | 586 return TRUE; |
600 } | 587 } |
601 | 588 |
602 if (!pPages) { | 589 if (!pPages) { |
603 if (m_docStatus == PDF_DATAAVAIL_ERROR) { | 590 if (m_docStatus == PDF_DATAAVAIL_ERROR) { |
604 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; | 591 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; |
605 return TRUE; | 592 return TRUE; |
606 } | 593 } |
607 return FALSE; | 594 return FALSE; |
608 } | 595 } |
609 | 596 |
610 if (!GetPageKids(m_pCurrentParser, pPages)) { | 597 if (!GetPageKids(m_pCurrentParser, pPages)) { |
611 pPages->Release(); | 598 pPages->Release(); |
612 m_docStatus = PDF_DATAAVAIL_ERROR; | 599 m_docStatus = PDF_DATAAVAIL_ERROR; |
613 return FALSE; | 600 return FALSE; |
614 } | 601 } |
615 | 602 |
616 pPages->Release(); | 603 pPages->Release(); |
617 m_docStatus = PDF_DATAAVAIL_PAGE; | 604 m_docStatus = PDF_DATAAVAIL_PAGE; |
618 return TRUE; | 605 return TRUE; |
619 } | 606 } |
620 | 607 |
621 FX_BOOL CPDF_DataAvail::CheckHeader(IPDF_DataAvail::DownloadHints* pHints) { | 608 FX_BOOL CPDF_DataAvail::CheckHeader(DownloadHints* pHints) { |
622 ASSERT(m_dwFileLen >= 0); | 609 ASSERT(m_dwFileLen >= 0); |
623 const uint32_t kReqSize = std::min(static_cast<uint32_t>(m_dwFileLen), 1024U); | 610 const uint32_t kReqSize = std::min(static_cast<uint32_t>(m_dwFileLen), 1024U); |
624 | 611 |
625 if (m_pFileAvail->IsDataAvail(0, kReqSize)) { | 612 if (m_pFileAvail->IsDataAvail(0, kReqSize)) { |
626 uint8_t buffer[1024]; | 613 uint8_t buffer[1024]; |
627 m_pFileRead->ReadBlock(buffer, 0, kReqSize); | 614 m_pFileRead->ReadBlock(buffer, 0, kReqSize); |
628 | 615 |
629 if (IsLinearizedFile(buffer, kReqSize)) { | 616 if (IsLinearizedFile(buffer, kReqSize)) { |
630 m_docStatus = PDF_DATAAVAIL_FIRSTPAGE; | 617 m_docStatus = PDF_DATAAVAIL_FIRSTPAGE; |
631 } else { | 618 } else { |
632 if (m_docStatus == PDF_DATAAVAIL_ERROR) | 619 if (m_docStatus == PDF_DATAAVAIL_ERROR) |
633 return FALSE; | 620 return FALSE; |
634 m_docStatus = PDF_DATAAVAIL_END; | 621 m_docStatus = PDF_DATAAVAIL_END; |
635 } | 622 } |
636 return TRUE; | 623 return TRUE; |
637 } | 624 } |
638 | 625 |
639 pHints->AddSegment(0, kReqSize); | 626 pHints->AddSegment(0, kReqSize); |
640 return FALSE; | 627 return FALSE; |
641 } | 628 } |
642 | 629 |
643 FX_BOOL CPDF_DataAvail::CheckFirstPage(IPDF_DataAvail::DownloadHints* pHints) { | 630 FX_BOOL CPDF_DataAvail::CheckFirstPage(DownloadHints* pHints) { |
644 CPDF_Dictionary* pDict = m_pLinearized->GetDict(); | 631 CPDF_Dictionary* pDict = m_pLinearized->GetDict(); |
645 CPDF_Object* pEndOffSet = pDict ? pDict->GetObjectBy("E") : nullptr; | 632 CPDF_Object* pEndOffSet = pDict ? pDict->GetObjectBy("E") : nullptr; |
646 if (!pEndOffSet) { | 633 if (!pEndOffSet) { |
647 m_docStatus = PDF_DATAAVAIL_ERROR; | 634 m_docStatus = PDF_DATAAVAIL_ERROR; |
648 return FALSE; | 635 return FALSE; |
649 } | 636 } |
650 | 637 |
651 CPDF_Object* pXRefOffset = pDict ? pDict->GetObjectBy("T") : nullptr; | 638 CPDF_Object* pXRefOffset = pDict ? pDict->GetObjectBy("T") : nullptr; |
652 if (!pXRefOffset) { | 639 if (!pXRefOffset) { |
653 m_docStatus = PDF_DATAAVAIL_ERROR; | 640 m_docStatus = PDF_DATAAVAIL_ERROR; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 return FALSE; | 690 return FALSE; |
704 } | 691 } |
705 | 692 |
706 m_docStatus = | 693 m_docStatus = |
707 m_bSupportHintTable ? PDF_DATAAVAIL_HINTTABLE : PDF_DATAAVAIL_DONE; | 694 m_bSupportHintTable ? PDF_DATAAVAIL_HINTTABLE : PDF_DATAAVAIL_DONE; |
708 return TRUE; | 695 return TRUE; |
709 } | 696 } |
710 | 697 |
711 FX_BOOL CPDF_DataAvail::IsDataAvail(FX_FILESIZE offset, | 698 FX_BOOL CPDF_DataAvail::IsDataAvail(FX_FILESIZE offset, |
712 uint32_t size, | 699 uint32_t size, |
713 IPDF_DataAvail::DownloadHints* pHints) { | 700 DownloadHints* pHints) { |
714 if (offset < 0 || offset > m_dwFileLen) | 701 if (offset < 0 || offset > m_dwFileLen) |
715 return TRUE; | 702 return TRUE; |
716 | 703 |
717 FX_SAFE_FILESIZE safeSize = offset; | 704 FX_SAFE_FILESIZE safeSize = offset; |
718 safeSize += size; | 705 safeSize += size; |
719 safeSize += 512; | 706 safeSize += 512; |
720 if (!safeSize.IsValid() || safeSize.ValueOrDie() > m_dwFileLen) | 707 if (!safeSize.IsValid() || safeSize.ValueOrDie() > m_dwFileLen) |
721 size = m_dwFileLen - offset; | 708 size = m_dwFileLen - offset; |
722 else | 709 else |
723 size += 512; | 710 size += 512; |
724 | 711 |
725 if (!m_pFileAvail->IsDataAvail(offset, size)) { | 712 if (!m_pFileAvail->IsDataAvail(offset, size)) { |
726 pHints->AddSegment(offset, size); | 713 pHints->AddSegment(offset, size); |
727 return FALSE; | 714 return FALSE; |
728 } | 715 } |
729 return TRUE; | 716 return TRUE; |
730 } | 717 } |
731 | 718 |
732 FX_BOOL CPDF_DataAvail::CheckHintTables(IPDF_DataAvail::DownloadHints* pHints) { | 719 FX_BOOL CPDF_DataAvail::CheckHintTables(DownloadHints* pHints) { |
733 CPDF_Dictionary* pDict = m_pLinearized->GetDict(); | 720 CPDF_Dictionary* pDict = m_pLinearized->GetDict(); |
734 if (!pDict) { | 721 if (!pDict) { |
735 m_docStatus = PDF_DATAAVAIL_ERROR; | 722 m_docStatus = PDF_DATAAVAIL_ERROR; |
736 return FALSE; | 723 return FALSE; |
737 } | 724 } |
738 | 725 |
739 if (!pDict->KeyExist("H") || !pDict->KeyExist("O") || !pDict->KeyExist("N")) { | 726 if (!pDict->KeyExist("H") || !pDict->KeyExist("O") || !pDict->KeyExist("N")) { |
740 m_docStatus = PDF_DATAAVAIL_ERROR; | 727 m_docStatus = PDF_DATAAVAIL_ERROR; |
741 return FALSE; | 728 return FALSE; |
742 } | 729 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 m_syntaxParser.RestorePos(SavedPos); | 795 m_syntaxParser.RestorePos(SavedPos); |
809 return nullptr; | 796 return nullptr; |
810 } | 797 } |
811 | 798 |
812 CPDF_Object* pObj = | 799 CPDF_Object* pObj = |
813 m_syntaxParser.GetObject(pObjList, parser_objnum, gennum, true); | 800 m_syntaxParser.GetObject(pObjList, parser_objnum, gennum, true); |
814 m_syntaxParser.RestorePos(SavedPos); | 801 m_syntaxParser.RestorePos(SavedPos); |
815 return pObj; | 802 return pObj; |
816 } | 803 } |
817 | 804 |
818 IPDF_DataAvail::DocLinearizationStatus CPDF_DataAvail::IsLinearizedPDF() { | 805 CPDF_DataAvail::DocLinearizationStatus CPDF_DataAvail::IsLinearizedPDF() { |
819 const uint32_t kReqSize = 1024; | 806 const uint32_t kReqSize = 1024; |
820 if (!m_pFileAvail->IsDataAvail(0, kReqSize)) | 807 if (!m_pFileAvail->IsDataAvail(0, kReqSize)) |
821 return LinearizationUnknown; | 808 return LinearizationUnknown; |
822 | 809 |
823 if (!m_pFileRead) | 810 if (!m_pFileRead) |
824 return NotLinearized; | 811 return NotLinearized; |
825 | 812 |
826 FX_FILESIZE dwSize = m_pFileRead->GetSize(); | 813 FX_FILESIZE dwSize = m_pFileRead->GetSize(); |
827 if (dwSize < (FX_FILESIZE)kReqSize) | 814 if (dwSize < (FX_FILESIZE)kReqSize) |
828 return LinearizationUnknown; | 815 return LinearizationUnknown; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 return FALSE; | 865 return FALSE; |
879 | 866 |
880 m_bLinearized = TRUE; | 867 m_bLinearized = TRUE; |
881 | 868 |
882 if (CPDF_Number* pNo = ToNumber(pDict->GetObjectBy("P"))) | 869 if (CPDF_Number* pNo = ToNumber(pDict->GetObjectBy("P"))) |
883 m_dwFirstPageNo = pNo->GetInteger(); | 870 m_dwFirstPageNo = pNo->GetInteger(); |
884 | 871 |
885 return TRUE; | 872 return TRUE; |
886 } | 873 } |
887 | 874 |
888 FX_BOOL CPDF_DataAvail::CheckEnd(IPDF_DataAvail::DownloadHints* pHints) { | 875 FX_BOOL CPDF_DataAvail::CheckEnd(DownloadHints* pHints) { |
889 uint32_t req_pos = (uint32_t)(m_dwFileLen > 1024 ? m_dwFileLen - 1024 : 0); | 876 uint32_t req_pos = (uint32_t)(m_dwFileLen > 1024 ? m_dwFileLen - 1024 : 0); |
890 uint32_t dwSize = (uint32_t)(m_dwFileLen - req_pos); | 877 uint32_t dwSize = (uint32_t)(m_dwFileLen - req_pos); |
891 | 878 |
892 if (m_pFileAvail->IsDataAvail(req_pos, dwSize)) { | 879 if (m_pFileAvail->IsDataAvail(req_pos, dwSize)) { |
893 uint8_t buffer[1024]; | 880 uint8_t buffer[1024]; |
894 m_pFileRead->ReadBlock(buffer, req_pos, dwSize); | 881 m_pFileRead->ReadBlock(buffer, req_pos, dwSize); |
895 | 882 |
896 ScopedFileStream file(FX_CreateMemoryStream(buffer, (size_t)dwSize, FALSE)); | 883 ScopedFileStream file(FX_CreateMemoryStream(buffer, (size_t)dwSize, FALSE)); |
897 m_syntaxParser.InitParser(file.get(), 0); | 884 m_syntaxParser.InitParser(file.get(), 0); |
898 m_syntaxParser.RestorePos(dwSize - 1); | 885 m_syntaxParser.RestorePos(dwSize - 1); |
(...skipping 21 matching lines...) Expand all Loading... |
920 } | 907 } |
921 | 908 |
922 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; | 909 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; |
923 return TRUE; | 910 return TRUE; |
924 } | 911 } |
925 | 912 |
926 pHints->AddSegment(req_pos, dwSize); | 913 pHints->AddSegment(req_pos, dwSize); |
927 return FALSE; | 914 return FALSE; |
928 } | 915 } |
929 | 916 |
930 int32_t CPDF_DataAvail::CheckCrossRefStream( | 917 int32_t CPDF_DataAvail::CheckCrossRefStream(DownloadHints* pHints, |
931 IPDF_DataAvail::DownloadHints* pHints, | 918 FX_FILESIZE& xref_offset) { |
932 FX_FILESIZE& xref_offset) { | |
933 xref_offset = 0; | 919 xref_offset = 0; |
934 uint32_t req_size = | 920 uint32_t req_size = |
935 (uint32_t)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512); | 921 (uint32_t)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512); |
936 | 922 |
937 if (m_pFileAvail->IsDataAvail(m_Pos, req_size)) { | 923 if (m_pFileAvail->IsDataAvail(m_Pos, req_size)) { |
938 int32_t iSize = (int32_t)(m_Pos + req_size - m_dwCurrentXRefSteam); | 924 int32_t iSize = (int32_t)(m_Pos + req_size - m_dwCurrentXRefSteam); |
939 CFX_BinaryBuf buf(iSize); | 925 CFX_BinaryBuf buf(iSize); |
940 uint8_t* pBuf = buf.GetBuffer(); | 926 uint8_t* pBuf = buf.GetBuffer(); |
941 | 927 |
942 m_pFileRead->ReadBlock(pBuf, m_dwCurrentXRefSteam, iSize); | 928 m_pFileRead->ReadBlock(pBuf, m_dwCurrentXRefSteam, iSize); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1077 return FALSE; | 1063 return FALSE; |
1078 | 1064 |
1079 m_bufferOffset = read_pos; | 1065 m_bufferOffset = read_pos; |
1080 m_bufferSize = read_size; | 1066 m_bufferSize = read_size; |
1081 } | 1067 } |
1082 ch = m_bufferData[pos - m_bufferOffset]; | 1068 ch = m_bufferData[pos - m_bufferOffset]; |
1083 m_Pos++; | 1069 m_Pos++; |
1084 return TRUE; | 1070 return TRUE; |
1085 } | 1071 } |
1086 | 1072 |
1087 FX_BOOL CPDF_DataAvail::CheckCrossRefItem( | 1073 FX_BOOL CPDF_DataAvail::CheckCrossRefItem(DownloadHints* pHints) { |
1088 IPDF_DataAvail::DownloadHints* pHints) { | |
1089 int32_t iSize = 0; | 1074 int32_t iSize = 0; |
1090 CFX_ByteString token; | 1075 CFX_ByteString token; |
1091 while (1) { | 1076 while (1) { |
1092 if (!GetNextToken(token)) { | 1077 if (!GetNextToken(token)) { |
1093 iSize = (int32_t)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512); | 1078 iSize = (int32_t)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512); |
1094 pHints->AddSegment(m_Pos, iSize); | 1079 pHints->AddSegment(m_Pos, iSize); |
1095 return FALSE; | 1080 return FALSE; |
1096 } | 1081 } |
1097 | 1082 |
1098 if (token == "trailer") { | 1083 if (token == "trailer") { |
1099 m_dwTrailerOffset = m_Pos; | 1084 m_dwTrailerOffset = m_Pos; |
1100 m_docStatus = PDF_DATAAVAIL_TRAILER; | 1085 m_docStatus = PDF_DATAAVAIL_TRAILER; |
1101 return TRUE; | 1086 return TRUE; |
1102 } | 1087 } |
1103 } | 1088 } |
1104 } | 1089 } |
1105 | 1090 |
1106 FX_BOOL CPDF_DataAvail::CheckAllCrossRefStream( | 1091 FX_BOOL CPDF_DataAvail::CheckAllCrossRefStream(DownloadHints* pHints) { |
1107 IPDF_DataAvail::DownloadHints* pHints) { | |
1108 FX_FILESIZE xref_offset = 0; | 1092 FX_FILESIZE xref_offset = 0; |
1109 | 1093 |
1110 int32_t nRet = CheckCrossRefStream(pHints, xref_offset); | 1094 int32_t nRet = CheckCrossRefStream(pHints, xref_offset); |
1111 if (nRet == 1) { | 1095 if (nRet == 1) { |
1112 if (!xref_offset) { | 1096 if (!xref_offset) { |
1113 m_docStatus = PDF_DATAAVAIL_LOADALLCROSSREF; | 1097 m_docStatus = PDF_DATAAVAIL_LOADALLCROSSREF; |
1114 } else { | 1098 } else { |
1115 m_dwCurrentXRefSteam = xref_offset; | 1099 m_dwCurrentXRefSteam = xref_offset; |
1116 m_Pos = xref_offset; | 1100 m_Pos = xref_offset; |
1117 } | 1101 } |
1118 return TRUE; | 1102 return TRUE; |
1119 } | 1103 } |
1120 | 1104 |
1121 if (nRet == -1) | 1105 if (nRet == -1) |
1122 m_docStatus = PDF_DATAAVAIL_ERROR; | 1106 m_docStatus = PDF_DATAAVAIL_ERROR; |
1123 return FALSE; | 1107 return FALSE; |
1124 } | 1108 } |
1125 | 1109 |
1126 FX_BOOL CPDF_DataAvail::CheckCrossRef(IPDF_DataAvail::DownloadHints* pHints) { | 1110 FX_BOOL CPDF_DataAvail::CheckCrossRef(DownloadHints* pHints) { |
1127 int32_t iSize = 0; | 1111 int32_t iSize = 0; |
1128 CFX_ByteString token; | 1112 CFX_ByteString token; |
1129 if (!GetNextToken(token)) { | 1113 if (!GetNextToken(token)) { |
1130 iSize = (int32_t)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512); | 1114 iSize = (int32_t)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512); |
1131 pHints->AddSegment(m_Pos, iSize); | 1115 pHints->AddSegment(m_Pos, iSize); |
1132 return FALSE; | 1116 return FALSE; |
1133 } | 1117 } |
1134 | 1118 |
1135 if (token == "xref") { | 1119 if (token == "xref") { |
1136 while (1) { | 1120 while (1) { |
(...skipping 11 matching lines...) Expand all Loading... |
1148 return TRUE; | 1132 return TRUE; |
1149 } | 1133 } |
1150 } | 1134 } |
1151 } else { | 1135 } else { |
1152 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; | 1136 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; |
1153 return TRUE; | 1137 return TRUE; |
1154 } | 1138 } |
1155 return FALSE; | 1139 return FALSE; |
1156 } | 1140 } |
1157 | 1141 |
1158 FX_BOOL CPDF_DataAvail::CheckTrailerAppend( | 1142 FX_BOOL CPDF_DataAvail::CheckTrailerAppend(DownloadHints* pHints) { |
1159 IPDF_DataAvail::DownloadHints* pHints) { | |
1160 if (m_Pos < m_dwFileLen) { | 1143 if (m_Pos < m_dwFileLen) { |
1161 FX_FILESIZE dwAppendPos = m_Pos + m_syntaxParser.SavePos(); | 1144 FX_FILESIZE dwAppendPos = m_Pos + m_syntaxParser.SavePos(); |
1162 int32_t iSize = (int32_t)( | 1145 int32_t iSize = (int32_t)( |
1163 dwAppendPos + 512 > m_dwFileLen ? m_dwFileLen - dwAppendPos : 512); | 1146 dwAppendPos + 512 > m_dwFileLen ? m_dwFileLen - dwAppendPos : 512); |
1164 | 1147 |
1165 if (!m_pFileAvail->IsDataAvail(dwAppendPos, iSize)) { | 1148 if (!m_pFileAvail->IsDataAvail(dwAppendPos, iSize)) { |
1166 pHints->AddSegment(dwAppendPos, iSize); | 1149 pHints->AddSegment(dwAppendPos, iSize); |
1167 return FALSE; | 1150 return FALSE; |
1168 } | 1151 } |
1169 } | 1152 } |
1170 | 1153 |
1171 if (m_dwPrevXRefOffset) { | 1154 if (m_dwPrevXRefOffset) { |
1172 SetStartOffset(m_dwPrevXRefOffset); | 1155 SetStartOffset(m_dwPrevXRefOffset); |
1173 m_docStatus = PDF_DATAAVAIL_CROSSREF; | 1156 m_docStatus = PDF_DATAAVAIL_CROSSREF; |
1174 } else { | 1157 } else { |
1175 m_docStatus = PDF_DATAAVAIL_LOADALLCROSSREF; | 1158 m_docStatus = PDF_DATAAVAIL_LOADALLCROSSREF; |
1176 } | 1159 } |
1177 return TRUE; | 1160 return TRUE; |
1178 } | 1161 } |
1179 | 1162 |
1180 FX_BOOL CPDF_DataAvail::CheckTrailer(IPDF_DataAvail::DownloadHints* pHints) { | 1163 FX_BOOL CPDF_DataAvail::CheckTrailer(DownloadHints* pHints) { |
1181 int32_t iTrailerSize = | 1164 int32_t iTrailerSize = |
1182 (int32_t)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512); | 1165 (int32_t)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512); |
1183 if (m_pFileAvail->IsDataAvail(m_Pos, iTrailerSize)) { | 1166 if (m_pFileAvail->IsDataAvail(m_Pos, iTrailerSize)) { |
1184 int32_t iSize = (int32_t)(m_Pos + iTrailerSize - m_dwTrailerOffset); | 1167 int32_t iSize = (int32_t)(m_Pos + iTrailerSize - m_dwTrailerOffset); |
1185 CFX_BinaryBuf buf(iSize); | 1168 CFX_BinaryBuf buf(iSize); |
1186 uint8_t* pBuf = buf.GetBuffer(); | 1169 uint8_t* pBuf = buf.GetBuffer(); |
1187 if (!pBuf) { | 1170 if (!pBuf) { |
1188 m_docStatus = PDF_DATAAVAIL_ERROR; | 1171 m_docStatus = PDF_DATAAVAIL_ERROR; |
1189 return FALSE; | 1172 return FALSE; |
1190 } | 1173 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1230 return TRUE; | 1213 return TRUE; |
1231 } | 1214 } |
1232 m_dwPrevXRefOffset = 0; | 1215 m_dwPrevXRefOffset = 0; |
1233 m_docStatus = PDF_DATAAVAIL_TRAILER_APPEND; | 1216 m_docStatus = PDF_DATAAVAIL_TRAILER_APPEND; |
1234 return TRUE; | 1217 return TRUE; |
1235 } | 1218 } |
1236 pHints->AddSegment(m_Pos, iTrailerSize); | 1219 pHints->AddSegment(m_Pos, iTrailerSize); |
1237 return FALSE; | 1220 return FALSE; |
1238 } | 1221 } |
1239 | 1222 |
1240 FX_BOOL CPDF_DataAvail::CheckPage(int32_t iPage, | 1223 FX_BOOL CPDF_DataAvail::CheckPage(int32_t iPage, DownloadHints* pHints) { |
1241 IPDF_DataAvail::DownloadHints* pHints) { | |
1242 while (TRUE) { | 1224 while (TRUE) { |
1243 switch (m_docStatus) { | 1225 switch (m_docStatus) { |
1244 case PDF_DATAAVAIL_PAGETREE: | 1226 case PDF_DATAAVAIL_PAGETREE: |
1245 if (!LoadDocPages(pHints)) | 1227 if (!LoadDocPages(pHints)) |
1246 return FALSE; | 1228 return FALSE; |
1247 break; | 1229 break; |
1248 case PDF_DATAAVAIL_PAGE: | 1230 case PDF_DATAAVAIL_PAGE: |
1249 if (!LoadDocPage(iPage, pHints)) | 1231 if (!LoadDocPage(iPage, pHints)) |
1250 return FALSE; | 1232 return FALSE; |
1251 break; | 1233 break; |
1252 case PDF_DATAAVAIL_ERROR: | 1234 case PDF_DATAAVAIL_ERROR: |
1253 return LoadAllFile(pHints); | 1235 return LoadAllFile(pHints); |
1254 default: | 1236 default: |
1255 m_bPagesTreeLoad = TRUE; | 1237 m_bPagesTreeLoad = TRUE; |
1256 m_bPagesLoad = TRUE; | 1238 m_bPagesLoad = TRUE; |
1257 m_bCurPageDictLoadOK = TRUE; | 1239 m_bCurPageDictLoadOK = TRUE; |
1258 m_docStatus = PDF_DATAAVAIL_PAGE; | 1240 m_docStatus = PDF_DATAAVAIL_PAGE; |
1259 return TRUE; | 1241 return TRUE; |
1260 } | 1242 } |
1261 } | 1243 } |
1262 } | 1244 } |
1263 | 1245 |
1264 FX_BOOL CPDF_DataAvail::CheckArrayPageNode( | 1246 FX_BOOL CPDF_DataAvail::CheckArrayPageNode(uint32_t dwPageNo, |
1265 uint32_t dwPageNo, | 1247 PageNode* pPageNode, |
1266 CPDF_DataAvail::PageNode* pPageNode, | 1248 DownloadHints* pHints) { |
1267 IPDF_DataAvail::DownloadHints* pHints) { | |
1268 FX_BOOL bExist = FALSE; | 1249 FX_BOOL bExist = FALSE; |
1269 CPDF_Object* pPages = GetObject(dwPageNo, pHints, &bExist); | 1250 CPDF_Object* pPages = GetObject(dwPageNo, pHints, &bExist); |
1270 if (!bExist) { | 1251 if (!bExist) { |
1271 m_docStatus = PDF_DATAAVAIL_ERROR; | 1252 m_docStatus = PDF_DATAAVAIL_ERROR; |
1272 return FALSE; | 1253 return FALSE; |
1273 } | 1254 } |
1274 | 1255 |
1275 if (!pPages) { | 1256 if (!pPages) { |
1276 if (m_docStatus == PDF_DATAAVAIL_ERROR) { | 1257 if (m_docStatus == PDF_DATAAVAIL_ERROR) { |
1277 m_docStatus = PDF_DATAAVAIL_ERROR; | 1258 m_docStatus = PDF_DATAAVAIL_ERROR; |
(...skipping 16 matching lines...) Expand all Loading... |
1294 continue; | 1275 continue; |
1295 | 1276 |
1296 PageNode* pNode = new PageNode(); | 1277 PageNode* pNode = new PageNode(); |
1297 pPageNode->m_childNode.Add(pNode); | 1278 pPageNode->m_childNode.Add(pNode); |
1298 pNode->m_dwPageNo = pKid->GetRefObjNum(); | 1279 pNode->m_dwPageNo = pKid->GetRefObjNum(); |
1299 } | 1280 } |
1300 pPages->Release(); | 1281 pPages->Release(); |
1301 return TRUE; | 1282 return TRUE; |
1302 } | 1283 } |
1303 | 1284 |
1304 FX_BOOL CPDF_DataAvail::CheckUnkownPageNode( | 1285 FX_BOOL CPDF_DataAvail::CheckUnkownPageNode(uint32_t dwPageNo, |
1305 uint32_t dwPageNo, | 1286 PageNode* pPageNode, |
1306 CPDF_DataAvail::PageNode* pPageNode, | 1287 DownloadHints* pHints) { |
1307 IPDF_DataAvail::DownloadHints* pHints) { | |
1308 FX_BOOL bExist = FALSE; | 1288 FX_BOOL bExist = FALSE; |
1309 CPDF_Object* pPage = GetObject(dwPageNo, pHints, &bExist); | 1289 CPDF_Object* pPage = GetObject(dwPageNo, pHints, &bExist); |
1310 if (!bExist) { | 1290 if (!bExist) { |
1311 m_docStatus = PDF_DATAAVAIL_ERROR; | 1291 m_docStatus = PDF_DATAAVAIL_ERROR; |
1312 return FALSE; | 1292 return FALSE; |
1313 } | 1293 } |
1314 | 1294 |
1315 if (!pPage) { | 1295 if (!pPage) { |
1316 if (m_docStatus == PDF_DATAAVAIL_ERROR) | 1296 if (m_docStatus == PDF_DATAAVAIL_ERROR) |
1317 m_docStatus = PDF_DATAAVAIL_ERROR; | 1297 m_docStatus = PDF_DATAAVAIL_ERROR; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1371 m_docStatus = PDF_DATAAVAIL_ERROR; | 1351 m_docStatus = PDF_DATAAVAIL_ERROR; |
1372 return FALSE; | 1352 return FALSE; |
1373 } | 1353 } |
1374 pPage->Release(); | 1354 pPage->Release(); |
1375 return TRUE; | 1355 return TRUE; |
1376 } | 1356 } |
1377 | 1357 |
1378 FX_BOOL CPDF_DataAvail::CheckPageNode(CPDF_DataAvail::PageNode& pageNodes, | 1358 FX_BOOL CPDF_DataAvail::CheckPageNode(CPDF_DataAvail::PageNode& pageNodes, |
1379 int32_t iPage, | 1359 int32_t iPage, |
1380 int32_t& iCount, | 1360 int32_t& iCount, |
1381 IPDF_DataAvail::DownloadHints* pHints, | 1361 DownloadHints* pHints, |
1382 int level) { | 1362 int level) { |
1383 if (level >= kMaxPageRecursionDepth) | 1363 if (level >= kMaxPageRecursionDepth) |
1384 return FALSE; | 1364 return FALSE; |
1385 | 1365 |
1386 int32_t iSize = pageNodes.m_childNode.GetSize(); | 1366 int32_t iSize = pageNodes.m_childNode.GetSize(); |
1387 if (iSize <= 0 || iPage >= iSize) { | 1367 if (iSize <= 0 || iPage >= iSize) { |
1388 m_docStatus = PDF_DATAAVAIL_ERROR; | 1368 m_docStatus = PDF_DATAAVAIL_ERROR; |
1389 return FALSE; | 1369 return FALSE; |
1390 } | 1370 } |
1391 | 1371 |
(...skipping 26 matching lines...) Expand all Loading... |
1418 } | 1398 } |
1419 | 1399 |
1420 if (iPage == iCount) { | 1400 if (iPage == iCount) { |
1421 m_docStatus = PDF_DATAAVAIL_DONE; | 1401 m_docStatus = PDF_DATAAVAIL_DONE; |
1422 return TRUE; | 1402 return TRUE; |
1423 } | 1403 } |
1424 } | 1404 } |
1425 return TRUE; | 1405 return TRUE; |
1426 } | 1406 } |
1427 | 1407 |
1428 FX_BOOL CPDF_DataAvail::LoadDocPage(int32_t iPage, | 1408 FX_BOOL CPDF_DataAvail::LoadDocPage(int32_t iPage, DownloadHints* pHints) { |
1429 IPDF_DataAvail::DownloadHints* pHints) { | |
1430 if (m_pDocument->GetPageCount() <= iPage || | 1409 if (m_pDocument->GetPageCount() <= iPage || |
1431 m_pDocument->m_PageList.GetAt(iPage)) { | 1410 m_pDocument->m_PageList.GetAt(iPage)) { |
1432 m_docStatus = PDF_DATAAVAIL_DONE; | 1411 m_docStatus = PDF_DATAAVAIL_DONE; |
1433 return TRUE; | 1412 return TRUE; |
1434 } | 1413 } |
1435 | 1414 |
1436 if (m_pageNodes.m_type == PDF_PAGENODE_PAGE) { | 1415 if (m_pageNodes.m_type == PDF_PAGENODE_PAGE) { |
1437 if (iPage == 0) { | 1416 if (iPage == 0) { |
1438 m_docStatus = PDF_DATAAVAIL_DONE; | 1417 m_docStatus = PDF_DATAAVAIL_DONE; |
1439 return TRUE; | 1418 return TRUE; |
1440 } | 1419 } |
1441 m_docStatus = PDF_DATAAVAIL_ERROR; | 1420 m_docStatus = PDF_DATAAVAIL_ERROR; |
1442 return TRUE; | 1421 return TRUE; |
1443 } | 1422 } |
1444 int32_t iCount = -1; | 1423 int32_t iCount = -1; |
1445 return CheckPageNode(m_pageNodes, iPage, iCount, pHints, 0); | 1424 return CheckPageNode(m_pageNodes, iPage, iCount, pHints, 0); |
1446 } | 1425 } |
1447 | 1426 |
1448 FX_BOOL CPDF_DataAvail::CheckPageCount(IPDF_DataAvail::DownloadHints* pHints) { | 1427 FX_BOOL CPDF_DataAvail::CheckPageCount(DownloadHints* pHints) { |
1449 FX_BOOL bExist = FALSE; | 1428 FX_BOOL bExist = FALSE; |
1450 CPDF_Object* pPages = GetObject(m_PagesObjNum, pHints, &bExist); | 1429 CPDF_Object* pPages = GetObject(m_PagesObjNum, pHints, &bExist); |
1451 if (!bExist) { | 1430 if (!bExist) { |
1452 m_docStatus = PDF_DATAAVAIL_ERROR; | 1431 m_docStatus = PDF_DATAAVAIL_ERROR; |
1453 return FALSE; | 1432 return FALSE; |
1454 } | 1433 } |
1455 | 1434 |
1456 if (!pPages) | 1435 if (!pPages) |
1457 return FALSE; | 1436 return FALSE; |
1458 | 1437 |
(...skipping 12 matching lines...) Expand all Loading... |
1471 int count = pPagesDict->GetIntegerBy("Count"); | 1450 int count = pPagesDict->GetIntegerBy("Count"); |
1472 if (count > 0) { | 1451 if (count > 0) { |
1473 pPages->Release(); | 1452 pPages->Release(); |
1474 return TRUE; | 1453 return TRUE; |
1475 } | 1454 } |
1476 | 1455 |
1477 pPages->Release(); | 1456 pPages->Release(); |
1478 return FALSE; | 1457 return FALSE; |
1479 } | 1458 } |
1480 | 1459 |
1481 FX_BOOL CPDF_DataAvail::LoadDocPages(IPDF_DataAvail::DownloadHints* pHints) { | 1460 FX_BOOL CPDF_DataAvail::LoadDocPages(DownloadHints* pHints) { |
1482 if (!CheckUnkownPageNode(m_PagesObjNum, &m_pageNodes, pHints)) | 1461 if (!CheckUnkownPageNode(m_PagesObjNum, &m_pageNodes, pHints)) |
1483 return FALSE; | 1462 return FALSE; |
1484 | 1463 |
1485 if (CheckPageCount(pHints)) { | 1464 if (CheckPageCount(pHints)) { |
1486 m_docStatus = PDF_DATAAVAIL_PAGE; | 1465 m_docStatus = PDF_DATAAVAIL_PAGE; |
1487 return TRUE; | 1466 return TRUE; |
1488 } | 1467 } |
1489 | 1468 |
1490 m_bTotalLoadPageTree = TRUE; | 1469 m_bTotalLoadPageTree = TRUE; |
1491 return FALSE; | 1470 return FALSE; |
1492 } | 1471 } |
1493 | 1472 |
1494 FX_BOOL CPDF_DataAvail::LoadPages(IPDF_DataAvail::DownloadHints* pHints) { | 1473 FX_BOOL CPDF_DataAvail::LoadPages(DownloadHints* pHints) { |
1495 while (!m_bPagesTreeLoad) { | 1474 while (!m_bPagesTreeLoad) { |
1496 if (!CheckPageStatus(pHints)) | 1475 if (!CheckPageStatus(pHints)) |
1497 return FALSE; | 1476 return FALSE; |
1498 } | 1477 } |
1499 | 1478 |
1500 if (m_bPagesLoad) | 1479 if (m_bPagesLoad) |
1501 return TRUE; | 1480 return TRUE; |
1502 | 1481 |
1503 m_pDocument->LoadPages(); | 1482 m_pDocument->LoadPages(); |
1504 return FALSE; | 1483 return FALSE; |
1505 } | 1484 } |
1506 | 1485 |
1507 IPDF_DataAvail::DocAvailStatus CPDF_DataAvail::CheckLinearizedData( | 1486 CPDF_DataAvail::DocAvailStatus CPDF_DataAvail::CheckLinearizedData( |
1508 IPDF_DataAvail::DownloadHints* pHints) { | 1487 DownloadHints* pHints) { |
1509 if (m_bLinearedDataOK) | 1488 if (m_bLinearedDataOK) |
1510 return DataAvailable; | 1489 return DataAvailable; |
1511 | 1490 |
1512 if (!m_bMainXRefLoadTried) { | 1491 if (!m_bMainXRefLoadTried) { |
1513 FX_SAFE_UINT32 data_size = m_dwFileLen; | 1492 FX_SAFE_UINT32 data_size = m_dwFileLen; |
1514 data_size -= m_dwLastXRefOffset; | 1493 data_size -= m_dwLastXRefOffset; |
1515 if (!data_size.IsValid()) | 1494 if (!data_size.IsValid()) |
1516 return DataError; | 1495 return DataError; |
1517 | 1496 |
1518 if (!m_pFileAvail->IsDataAvail(m_dwLastXRefOffset, | 1497 if (!m_pFileAvail->IsDataAvail(m_dwLastXRefOffset, |
(...skipping 11 matching lines...) Expand all Loading... |
1530 if (!PreparePageItem()) | 1509 if (!PreparePageItem()) |
1531 return DataNotAvailable; | 1510 return DataNotAvailable; |
1532 | 1511 |
1533 m_bMainXRefLoadedOK = TRUE; | 1512 m_bMainXRefLoadedOK = TRUE; |
1534 m_bLinearedDataOK = TRUE; | 1513 m_bLinearedDataOK = TRUE; |
1535 } | 1514 } |
1536 | 1515 |
1537 return m_bLinearedDataOK ? DataAvailable : DataNotAvailable; | 1516 return m_bLinearedDataOK ? DataAvailable : DataNotAvailable; |
1538 } | 1517 } |
1539 | 1518 |
1540 FX_BOOL CPDF_DataAvail::CheckPageAnnots(int32_t iPage, | 1519 FX_BOOL CPDF_DataAvail::CheckPageAnnots(int32_t iPage, DownloadHints* pHints) { |
1541 IPDF_DataAvail::DownloadHints* pHints) { | |
1542 if (!m_objs_array.GetSize()) { | 1520 if (!m_objs_array.GetSize()) { |
1543 m_objs_array.RemoveAll(); | 1521 m_objs_array.RemoveAll(); |
1544 m_ObjectSet.clear(); | 1522 m_ObjectSet.clear(); |
1545 | 1523 |
1546 CPDF_Dictionary* pPageDict = m_pDocument->GetPage(iPage); | 1524 CPDF_Dictionary* pPageDict = m_pDocument->GetPage(iPage); |
1547 if (!pPageDict) | 1525 if (!pPageDict) |
1548 return TRUE; | 1526 return TRUE; |
1549 | 1527 |
1550 CPDF_Object* pAnnots = pPageDict->GetObjectBy("Annots"); | 1528 CPDF_Object* pAnnots = pPageDict->GetObjectBy("Annots"); |
1551 if (!pAnnots) | 1529 if (!pAnnots) |
(...skipping 11 matching lines...) Expand all Loading... |
1563 | 1541 |
1564 CFX_ArrayTemplate<CPDF_Object*> new_objs_array; | 1542 CFX_ArrayTemplate<CPDF_Object*> new_objs_array; |
1565 FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array); | 1543 FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array); |
1566 m_objs_array.RemoveAll(); | 1544 m_objs_array.RemoveAll(); |
1567 if (!bRet) | 1545 if (!bRet) |
1568 m_objs_array.Append(new_objs_array); | 1546 m_objs_array.Append(new_objs_array); |
1569 | 1547 |
1570 return bRet; | 1548 return bRet; |
1571 } | 1549 } |
1572 | 1550 |
1573 IPDF_DataAvail::DocAvailStatus CPDF_DataAvail::CheckLinearizedFirstPage( | 1551 CPDF_DataAvail::DocAvailStatus CPDF_DataAvail::CheckLinearizedFirstPage( |
1574 int32_t iPage, | 1552 int32_t iPage, |
1575 IPDF_DataAvail::DownloadHints* pHints) { | 1553 DownloadHints* pHints) { |
1576 if (!m_bAnnotsLoad) { | 1554 if (!m_bAnnotsLoad) { |
1577 if (!CheckPageAnnots(iPage, pHints)) | 1555 if (!CheckPageAnnots(iPage, pHints)) |
1578 return DataNotAvailable; | 1556 return DataNotAvailable; |
1579 m_bAnnotsLoad = TRUE; | 1557 m_bAnnotsLoad = TRUE; |
1580 } | 1558 } |
1581 | 1559 |
1582 DocAvailStatus nRet = CheckLinearizedData(pHints); | 1560 DocAvailStatus nRet = CheckLinearizedData(pHints); |
1583 if (nRet == DataAvailable) | 1561 if (nRet == DataAvailable) |
1584 m_bPageLoadedOK = FALSE; | 1562 m_bPageLoadedOK = FALSE; |
1585 return nRet; | 1563 return nRet; |
(...skipping 14 matching lines...) Expand all Loading... |
1600 | 1578 |
1601 CPDF_Object* pRet = pParentDict->GetObjectBy("Resources"); | 1579 CPDF_Object* pRet = pParentDict->GetObjectBy("Resources"); |
1602 if (pRet) { | 1580 if (pRet) { |
1603 m_pPageResource = pRet; | 1581 m_pPageResource = pRet; |
1604 return TRUE; | 1582 return TRUE; |
1605 } | 1583 } |
1606 | 1584 |
1607 return HaveResourceAncestor(pParentDict); | 1585 return HaveResourceAncestor(pParentDict); |
1608 } | 1586 } |
1609 | 1587 |
1610 IPDF_DataAvail::DocAvailStatus CPDF_DataAvail::IsPageAvail( | 1588 CPDF_DataAvail::DocAvailStatus CPDF_DataAvail::IsPageAvail( |
1611 int32_t iPage, | 1589 int32_t iPage, |
1612 IPDF_DataAvail::DownloadHints* pHints) { | 1590 DownloadHints* pHints) { |
1613 if (!m_pDocument) | 1591 if (!m_pDocument) |
1614 return DataError; | 1592 return DataError; |
1615 | 1593 |
1616 if (IsFirstCheck(iPage)) { | 1594 if (IsFirstCheck(iPage)) { |
1617 m_bCurPageDictLoadOK = FALSE; | 1595 m_bCurPageDictLoadOK = FALSE; |
1618 m_bPageLoadedOK = FALSE; | 1596 m_bPageLoadedOK = FALSE; |
1619 m_bAnnotsLoad = FALSE; | 1597 m_bAnnotsLoad = FALSE; |
1620 m_bNeedDownLoadResource = FALSE; | 1598 m_bNeedDownLoadResource = FALSE; |
1621 m_objs_array.RemoveAll(); | 1599 m_objs_array.RemoveAll(); |
1622 m_ObjectSet.clear(); | 1600 m_ObjectSet.clear(); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1728 | 1706 |
1729 m_bPageLoadedOK = FALSE; | 1707 m_bPageLoadedOK = FALSE; |
1730 m_bAnnotsLoad = FALSE; | 1708 m_bAnnotsLoad = FALSE; |
1731 m_bCurPageDictLoadOK = FALSE; | 1709 m_bCurPageDictLoadOK = FALSE; |
1732 | 1710 |
1733 ResetFirstCheck(iPage); | 1711 ResetFirstCheck(iPage); |
1734 m_pagesLoadState.insert(iPage); | 1712 m_pagesLoadState.insert(iPage); |
1735 return DataAvailable; | 1713 return DataAvailable; |
1736 } | 1714 } |
1737 | 1715 |
1738 FX_BOOL CPDF_DataAvail::CheckResources(IPDF_DataAvail::DownloadHints* pHints) { | 1716 FX_BOOL CPDF_DataAvail::CheckResources(DownloadHints* pHints) { |
1739 if (!m_objs_array.GetSize()) { | 1717 if (!m_objs_array.GetSize()) { |
1740 m_objs_array.RemoveAll(); | 1718 m_objs_array.RemoveAll(); |
1741 CFX_ArrayTemplate<CPDF_Object*> obj_array; | 1719 CFX_ArrayTemplate<CPDF_Object*> obj_array; |
1742 obj_array.Add(m_pPageResource); | 1720 obj_array.Add(m_pPageResource); |
1743 | 1721 |
1744 FX_BOOL bRet = IsObjectsAvail(obj_array, TRUE, pHints, m_objs_array); | 1722 FX_BOOL bRet = IsObjectsAvail(obj_array, TRUE, pHints, m_objs_array); |
1745 if (bRet) | 1723 if (bRet) |
1746 m_objs_array.RemoveAll(); | 1724 m_objs_array.RemoveAll(); |
1747 return bRet; | 1725 return bRet; |
1748 } | 1726 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1796 return nullptr; | 1774 return nullptr; |
1797 | 1775 |
1798 if (!m_pDocument->InsertIndirectObject(dwObjNum, pPageDict)) | 1776 if (!m_pDocument->InsertIndirectObject(dwObjNum, pPageDict)) |
1799 return nullptr; | 1777 return nullptr; |
1800 return pPageDict->GetDict(); | 1778 return pPageDict->GetDict(); |
1801 } | 1779 } |
1802 } | 1780 } |
1803 return m_pDocument->GetPage(index); | 1781 return m_pDocument->GetPage(index); |
1804 } | 1782 } |
1805 | 1783 |
1806 IPDF_DataAvail::DocFormStatus CPDF_DataAvail::IsFormAvail( | 1784 CPDF_DataAvail::DocFormStatus CPDF_DataAvail::IsFormAvail( |
1807 IPDF_DataAvail::DownloadHints* pHints) { | 1785 DownloadHints* pHints) { |
1808 if (!m_pDocument) | 1786 if (!m_pDocument) |
1809 return FormAvailable; | 1787 return FormAvailable; |
1810 | 1788 |
1811 if (!m_bLinearizedFormParamLoad) { | 1789 if (!m_bLinearizedFormParamLoad) { |
1812 CPDF_Dictionary* pRoot = m_pDocument->GetRoot(); | 1790 CPDF_Dictionary* pRoot = m_pDocument->GetRoot(); |
1813 if (!pRoot) | 1791 if (!pRoot) |
1814 return FormAvailable; | 1792 return FormAvailable; |
1815 | 1793 |
1816 CPDF_Object* pAcroForm = pRoot->GetObjectBy("AcroForm"); | 1794 CPDF_Object* pAcroForm = pRoot->GetObjectBy("AcroForm"); |
1817 if (!pAcroForm) | 1795 if (!pAcroForm) |
(...skipping 20 matching lines...) Expand all Loading... |
1838 return FormAvailable; | 1816 return FormAvailable; |
1839 } | 1817 } |
1840 | 1818 |
1841 CPDF_DataAvail::PageNode::PageNode() : m_type(PDF_PAGENODE_UNKNOWN) {} | 1819 CPDF_DataAvail::PageNode::PageNode() : m_type(PDF_PAGENODE_UNKNOWN) {} |
1842 | 1820 |
1843 CPDF_DataAvail::PageNode::~PageNode() { | 1821 CPDF_DataAvail::PageNode::~PageNode() { |
1844 for (int32_t i = 0; i < m_childNode.GetSize(); ++i) | 1822 for (int32_t i = 0; i < m_childNode.GetSize(); ++i) |
1845 delete m_childNode[i]; | 1823 delete m_childNode[i]; |
1846 m_childNode.RemoveAll(); | 1824 m_childNode.RemoveAll(); |
1847 } | 1825 } |
OLD | NEW |