| 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_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/fxcodec/fx_codec.h" | 9 #include "../../../include/fxcodec/fx_codec.h" |
| 10 #include <limits.h> | 10 #include <limits.h> |
| 11 #define _STREAM_MAX_SIZE_ 20 * 1024 * 1024 | 11 #define _STREAM_MAX_SIZE_ 20 * 1024 * 1024 |
| 12 FX_DWORD _A85Decode(const FX_BYTE* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_b
uf, FX_DWORD& dest_size) | 12 FX_DWORD _A85Decode(const FX_BYTE* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_b
uf, FX_DWORD& dest_size) |
| 13 { | 13 { |
| 14 dest_size = 0; | 14 dest_size = 0; |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 0x00dc, 0x00dd, 0x00de, 0x00df, 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00
e5, | 395 0x00dc, 0x00dd, 0x00de, 0x00df, 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00
e5, |
| 396 0x00e6, 0x00e7, 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00
ef, | 396 0x00e6, 0x00e7, 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00
ef, |
| 397 0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7, 0x00f8, 0x00
f9, | 397 0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7, 0x00f8, 0x00
f9, |
| 398 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff | 398 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff |
| 399 }; | 399 }; |
| 400 CFX_WideString PDF_DecodeText(FX_LPCBYTE src_data, FX_DWORD src_len, CFX_CharMap
* pCharMap) | 400 CFX_WideString PDF_DecodeText(FX_LPCBYTE src_data, FX_DWORD src_len, CFX_CharMap
* pCharMap) |
| 401 { | 401 { |
| 402 CFX_WideString result; | 402 CFX_WideString result; |
| 403 if (src_len >= 2 && ((src_data[0] == 0xfe && src_data[1] == 0xff) || (src_da
ta[0] == 0xff && src_data[1] == 0xfe))) { | 403 if (src_len >= 2 && ((src_data[0] == 0xfe && src_data[1] == 0xff) || (src_da
ta[0] == 0xff && src_data[1] == 0xfe))) { |
| 404 FX_BOOL bBE = src_data[0] == 0xfe; | 404 FX_BOOL bBE = src_data[0] == 0xfe; |
| 405 int max_chars = (src_len - 2) / 2; | 405 FX_DWORD max_chars = (src_len - 2) / 2; |
| 406 if (!max_chars) { | 406 if (!max_chars) { |
| 407 return result; | 407 return result; |
| 408 } | 408 } |
| 409 if (src_data[0] == 0xff) { | 409 if (src_data[0] == 0xff) { |
| 410 bBE = !src_data[2]; | 410 bBE = !src_data[2]; |
| 411 } | 411 } |
| 412 FX_LPWSTR dest_buf = result.GetBuffer(max_chars); | 412 FX_LPWSTR dest_buf = result.GetBuffer(max_chars); |
| 413 FX_LPCBYTE uni_str = src_data + 2; | 413 FX_LPCBYTE uni_str = src_data + 2; |
| 414 int dest_pos = 0; | 414 int dest_pos = 0; |
| 415 for (int i = 0; i < max_chars * 2; i += 2) { | 415 for (FX_DWORD i = 0; i < max_chars * 2; i += 2) { |
| 416 FX_WORD unicode = bBE ? (uni_str[i] << 8 | uni_str[i + 1]) : (uni_st
r[i + 1] << 8 | uni_str[i]); | 416 FX_WORD unicode = bBE ? (uni_str[i] << 8 | uni_str[i + 1]) : (uni_st
r[i + 1] << 8 | uni_str[i]); |
| 417 if (unicode == 0x1b) { | 417 if (unicode == 0x1b) { |
| 418 i += 2; | 418 i += 2; |
| 419 while (i < max_chars * 2) { | 419 while (i < max_chars * 2) { |
| 420 FX_WORD unicode = bBE ? (uni_str[i] << 8 | uni_str[i + 1]) :
(uni_str[i + 1] << 8 | uni_str[i]); | 420 FX_WORD unicode = bBE ? (uni_str[i] << 8 | uni_str[i + 1]) :
(uni_str[i + 1] << 8 | uni_str[i]); |
| 421 i += 2; | 421 i += 2; |
| 422 if (unicode == 0x1b) { | 422 if (unicode == 0x1b) { |
| 423 break; | 423 break; |
| 424 } | 424 } |
| 425 } | 425 } |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 } | 525 } |
| 526 } | 526 } |
| 527 FX_DWORD FlateDecode(const FX_BYTE* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_
buf, FX_DWORD& dest_size) | 527 FX_DWORD FlateDecode(const FX_BYTE* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_
buf, FX_DWORD& dest_size) |
| 528 { | 528 { |
| 529 CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule(); | 529 CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule(); |
| 530 if (pEncoders) { | 530 if (pEncoders) { |
| 531 return pEncoders->GetFlateModule()->FlateOrLZWDecode(FALSE, src_buf, src
_size, FALSE, 0, 0, 0, 0, 0, dest_buf, dest_size); | 531 return pEncoders->GetFlateModule()->FlateOrLZWDecode(FALSE, src_buf, src
_size, FALSE, 0, 0, 0, 0, 0, dest_buf, dest_size); |
| 532 } | 532 } |
| 533 return 0; | 533 return 0; |
| 534 } | 534 } |
| OLD | NEW |