OLD | NEW |
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_page.h" | 7 #include "../../../include/fpdfapi/fpdf_page.h" |
8 #include "../../../include/fpdfapi/fpdf_module.h" | 8 #include "../../../include/fpdfapi/fpdf_module.h" |
9 #include "../../../include/fxcodec/fx_codec.h" | 9 #include "../../../include/fxcodec/fx_codec.h" |
10 #include "pageint.h" | 10 #include "pageint.h" |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 FX_BOOL bDecode) { | 325 FX_BOOL bDecode) { |
326 if (m_Pos == m_Size) { | 326 if (m_Pos == m_Size) { |
327 return NULL; | 327 return NULL; |
328 } | 328 } |
329 if (PDF_CharType[m_pBuf[m_Pos]] == 'W') { | 329 if (PDF_CharType[m_pBuf[m_Pos]] == 'W') { |
330 m_Pos++; | 330 m_Pos++; |
331 } | 331 } |
332 CFX_ByteString Decoder; | 332 CFX_ByteString Decoder; |
333 CPDF_Dictionary* pParam = NULL; | 333 CPDF_Dictionary* pParam = NULL; |
334 CPDF_Object* pFilter = pDict->GetElementValue(FX_BSTRC("Filter")); | 334 CPDF_Object* pFilter = pDict->GetElementValue(FX_BSTRC("Filter")); |
335 if (pFilter == NULL) { | 335 if (pFilter) { |
336 } else if (pFilter->GetType() == PDFOBJ_ARRAY) { | 336 if (CPDF_Array* pArray = pFilter->AsArray()) { |
337 Decoder = ((CPDF_Array*)pFilter)->GetString(0); | 337 Decoder = pArray->GetString(0); |
338 CPDF_Array* pParams = pDict->GetArray(FX_BSTRC("DecodeParms")); | 338 CPDF_Array* pParams = pDict->GetArray(FX_BSTRC("DecodeParms")); |
339 if (pParams) { | 339 if (pParams) |
340 pParam = pParams->GetDict(0); | 340 pParam = pParams->GetDict(0); |
| 341 } else { |
| 342 Decoder = pFilter->GetString(); |
| 343 pParam = pDict->GetDict(FX_BSTRC("DecodeParms")); |
341 } | 344 } |
342 } else { | |
343 Decoder = pFilter->GetString(); | |
344 pParam = pDict->GetDict(FX_BSTRC("DecodeParms")); | |
345 } | 345 } |
346 FX_DWORD width = pDict->GetInteger(FX_BSTRC("Width")); | 346 FX_DWORD width = pDict->GetInteger(FX_BSTRC("Width")); |
347 FX_DWORD height = pDict->GetInteger(FX_BSTRC("Height")); | 347 FX_DWORD height = pDict->GetInteger(FX_BSTRC("Height")); |
348 FX_DWORD OrigSize = 0; | 348 FX_DWORD OrigSize = 0; |
349 if (pCSObj != NULL) { | 349 if (pCSObj != NULL) { |
350 FX_DWORD bpc = pDict->GetInteger(FX_BSTRC("BitsPerComponent")); | 350 FX_DWORD bpc = pDict->GetInteger(FX_BSTRC("BitsPerComponent")); |
351 FX_DWORD nComponents = 1; | 351 FX_DWORD nComponents = 1; |
352 CPDF_ColorSpace* pCS = pDoc->LoadColorSpace(pCSObj); | 352 CPDF_ColorSpace* pCS = pDoc->LoadColorSpace(pCSObj); |
353 if (pCS == NULL) { | 353 if (pCS == NULL) { |
354 nComponents = 3; | 354 nComponents = 3; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 dwStreamSize = | 396 dwStreamSize = |
397 PDF_DecodeInlineStream(m_pBuf + m_Pos, m_Size - m_Pos, width, height, | 397 PDF_DecodeInlineStream(m_pBuf + m_Pos, m_Size - m_Pos, width, height, |
398 Decoder, pParam, pData, dwDestSize); | 398 Decoder, pParam, pData, dwDestSize); |
399 if ((int)dwStreamSize < 0) { | 399 if ((int)dwStreamSize < 0) { |
400 FX_Free(pData); | 400 FX_Free(pData); |
401 return NULL; | 401 return NULL; |
402 } | 402 } |
403 if (bDecode) { | 403 if (bDecode) { |
404 m_Pos += dwStreamSize; | 404 m_Pos += dwStreamSize; |
405 dwStreamSize = dwDestSize; | 405 dwStreamSize = dwDestSize; |
406 if (pFilter->GetType() == PDFOBJ_ARRAY) { | 406 if (CPDF_Array* pArray = pFilter->AsArray()) { |
407 ((CPDF_Array*)pFilter)->RemoveAt(0); | 407 pArray->RemoveAt(0); |
408 CPDF_Array* pParams = pDict->GetArray(FX_BSTRC("DecodeParms")); | 408 CPDF_Array* pParams = pDict->GetArray(FX_BSTRC("DecodeParms")); |
409 if (pParams) { | 409 if (pParams) |
410 pParams->RemoveAt(0); | 410 pParams->RemoveAt(0); |
411 } | |
412 } else { | 411 } else { |
413 pDict->RemoveAt(FX_BSTRC("Filter")); | 412 pDict->RemoveAt(FX_BSTRC("Filter")); |
414 pDict->RemoveAt(FX_BSTRC("DecodeParms")); | 413 pDict->RemoveAt(FX_BSTRC("DecodeParms")); |
415 } | 414 } |
416 } else { | 415 } else { |
417 FX_Free(pData); | 416 FX_Free(pData); |
418 FX_DWORD dwSavePos = m_Pos; | 417 FX_DWORD dwSavePos = m_Pos; |
419 m_Pos += dwStreamSize; | 418 m_Pos += dwStreamSize; |
420 while (1) { | 419 while (1) { |
421 FX_DWORD dwPrevPos = m_Pos; | 420 FX_DWORD dwPrevPos = m_Pos; |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 CPDF_Object* pContent = | 957 CPDF_Object* pContent = |
959 pPage->m_pFormDict->GetElementValue(FX_BSTRC("Contents")); | 958 pPage->m_pFormDict->GetElementValue(FX_BSTRC("Contents")); |
960 if (pContent == NULL) { | 959 if (pContent == NULL) { |
961 m_Status = Done; | 960 m_Status = Done; |
962 return; | 961 return; |
963 } | 962 } |
964 if (pContent->GetType() == PDFOBJ_STREAM) { | 963 if (pContent->GetType() == PDFOBJ_STREAM) { |
965 m_nStreams = 0; | 964 m_nStreams = 0; |
966 m_pSingleStream = new CPDF_StreamAcc; | 965 m_pSingleStream = new CPDF_StreamAcc; |
967 m_pSingleStream->LoadAllData((CPDF_Stream*)pContent, FALSE); | 966 m_pSingleStream->LoadAllData((CPDF_Stream*)pContent, FALSE); |
968 } else if (pContent->GetType() == PDFOBJ_ARRAY) { | 967 } else if (CPDF_Array* pArray = pContent->AsArray()) { |
969 CPDF_Array* pArray = (CPDF_Array*)pContent; | |
970 m_nStreams = pArray->GetCount(); | 968 m_nStreams = pArray->GetCount(); |
971 if (m_nStreams == 0) { | 969 if (m_nStreams == 0) { |
972 m_Status = Done; | 970 m_Status = Done; |
973 return; | 971 return; |
974 } | 972 } |
975 m_pStreamArray = FX_Alloc(CPDF_StreamAcc*, m_nStreams); | 973 m_pStreamArray = FX_Alloc(CPDF_StreamAcc*, m_nStreams); |
976 } else { | 974 } else { |
977 m_Status = Done; | 975 m_Status = Done; |
978 return; | 976 return; |
979 } | 977 } |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1144 } | 1142 } |
1145 m_Status = Done; | 1143 m_Status = Done; |
1146 return; | 1144 return; |
1147 } | 1145 } |
1148 steps++; | 1146 steps++; |
1149 if (pPause && pPause->NeedToPauseNow()) { | 1147 if (pPause && pPause->NeedToPauseNow()) { |
1150 break; | 1148 break; |
1151 } | 1149 } |
1152 } | 1150 } |
1153 } | 1151 } |
OLD | NEW |