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 <limits.h> | 7 #include <limits.h> |
8 | 8 |
9 #include "core/include/fpdfapi/fpdf_module.h" | 9 #include "core/include/fpdfapi/fpdf_module.h" |
10 #include "core/include/fpdfapi/fpdf_parser.h" | 10 #include "core/include/fpdfapi/fpdf_parser.h" |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 i += 2; | 447 i += 2; |
448 if (unicode == 0x1b) { | 448 if (unicode == 0x1b) { |
449 break; | 449 break; |
450 } | 450 } |
451 } | 451 } |
452 } else { | 452 } else { |
453 dest_buf[dest_pos++] = unicode; | 453 dest_buf[dest_pos++] = unicode; |
454 } | 454 } |
455 } | 455 } |
456 result.ReleaseBuffer(dest_pos); | 456 result.ReleaseBuffer(dest_pos); |
457 } else if (pCharMap == NULL) { | 457 } else if (!pCharMap) { |
458 FX_WCHAR* dest_buf = result.GetBuffer(src_len); | 458 FX_WCHAR* dest_buf = result.GetBuffer(src_len); |
459 for (FX_DWORD i = 0; i < src_len; i++) { | 459 for (FX_DWORD i = 0; i < src_len; i++) { |
460 dest_buf[i] = PDFDocEncoding[src_data[i]]; | 460 dest_buf[i] = PDFDocEncoding[src_data[i]]; |
461 } | 461 } |
462 result.ReleaseBuffer(src_len); | 462 result.ReleaseBuffer(src_len); |
463 } else { | 463 } else { |
464 return (*pCharMap->m_GetWideString)( | 464 return (*pCharMap->m_GetWideString)( |
465 pCharMap, CFX_ByteString((const FX_CHAR*)src_data, src_len)); | 465 pCharMap, CFX_ByteString((const FX_CHAR*)src_data, src_len)); |
466 } | 466 } |
467 return result; | 467 return result; |
468 } | 468 } |
469 CFX_ByteString PDF_EncodeText(const FX_WCHAR* pString, | 469 CFX_ByteString PDF_EncodeText(const FX_WCHAR* pString, |
470 int len, | 470 int len, |
471 CFX_CharMap* pCharMap) { | 471 CFX_CharMap* pCharMap) { |
472 if (len == -1) { | 472 if (len == -1) { |
473 len = FXSYS_wcslen(pString); | 473 len = FXSYS_wcslen(pString); |
474 } | 474 } |
475 CFX_ByteString result; | 475 CFX_ByteString result; |
476 if (pCharMap == NULL) { | 476 if (!pCharMap) { |
477 FX_CHAR* dest_buf1 = result.GetBuffer(len); | 477 FX_CHAR* dest_buf1 = result.GetBuffer(len); |
478 int i; | 478 int i; |
479 for (i = 0; i < len; i++) { | 479 for (i = 0; i < len; i++) { |
480 int code; | 480 int code; |
481 for (code = 0; code < 256; code++) | 481 for (code = 0; code < 256; code++) |
482 if (PDFDocEncoding[code] == pString[i]) { | 482 if (PDFDocEncoding[code] == pString[i]) { |
483 break; | 483 break; |
484 } | 484 } |
485 if (code == 256) { | 485 if (code == 256) { |
486 break; | 486 break; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 FX_DWORD src_size, | 568 FX_DWORD src_size, |
569 uint8_t*& dest_buf, | 569 uint8_t*& dest_buf, |
570 FX_DWORD& dest_size) { | 570 FX_DWORD& dest_size) { |
571 CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule(); | 571 CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule(); |
572 if (pEncoders) { | 572 if (pEncoders) { |
573 return pEncoders->GetFlateModule()->FlateOrLZWDecode( | 573 return pEncoders->GetFlateModule()->FlateOrLZWDecode( |
574 FALSE, src_buf, src_size, FALSE, 0, 0, 0, 0, 0, dest_buf, dest_size); | 574 FALSE, src_buf, src_size, FALSE, 0, 0, 0, 0, 0, dest_buf, dest_size); |
575 } | 575 } |
576 return 0; | 576 return 0; |
577 } | 577 } |
OLD | NEW |