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 "core/fpdfapi/fpdf_parser/fpdf_parser_utility.h" | 7 #include "core/fpdfapi/fpdf_parser/fpdf_parser_utility.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" | 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 } | 80 } |
81 return -1; | 81 return -1; |
82 } | 82 } |
83 | 83 |
84 int32_t GetDirectInteger(CPDF_Dictionary* pDict, const CFX_ByteStringC& key) { | 84 int32_t GetDirectInteger(CPDF_Dictionary* pDict, const CFX_ByteStringC& key) { |
85 CPDF_Number* pObj = ToNumber(pDict->GetObjectBy(key)); | 85 CPDF_Number* pObj = ToNumber(pDict->GetObjectBy(key)); |
86 return pObj ? pObj->GetInteger() : 0; | 86 return pObj ? pObj->GetInteger() : 0; |
87 } | 87 } |
88 | 88 |
89 CFX_ByteString PDF_NameDecode(const CFX_ByteStringC& bstr) { | 89 CFX_ByteString PDF_NameDecode(const CFX_ByteStringC& bstr) { |
90 int size = bstr.GetLength(); | |
91 const FX_CHAR* pSrc = bstr.c_str(); | |
92 if (bstr.Find('#') == -1) | 90 if (bstr.Find('#') == -1) |
93 return bstr; | 91 return bstr; |
94 | 92 |
| 93 int size = bstr.GetLength(); |
95 CFX_ByteString result; | 94 CFX_ByteString result; |
96 FX_CHAR* pDestStart = result.GetBuffer(size); | 95 FX_CHAR* pDestStart = result.GetBuffer(size); |
97 FX_CHAR* pDest = pDestStart; | 96 FX_CHAR* pDest = pDestStart; |
98 for (int i = 0; i < size; i++) { | 97 for (int i = 0; i < size; i++) { |
99 if (pSrc[i] == '#' && i < size - 2) { | 98 if (bstr[i] == '#' && i < size - 2) { |
100 *pDest++ = | 99 *pDest++ = |
101 FXSYS_toHexDigit(pSrc[i + 1]) * 16 + FXSYS_toHexDigit(pSrc[i + 2]); | 100 FXSYS_toHexDigit(bstr[i + 1]) * 16 + FXSYS_toHexDigit(bstr[i + 2]); |
102 i += 2; | 101 i += 2; |
103 } else { | 102 } else { |
104 *pDest++ = pSrc[i]; | 103 *pDest++ = bstr[i]; |
105 } | 104 } |
106 } | 105 } |
107 result.ReleaseBuffer((FX_STRSIZE)(pDest - pDestStart)); | 106 result.ReleaseBuffer((FX_STRSIZE)(pDest - pDestStart)); |
108 return result; | 107 return result; |
109 } | 108 } |
110 | 109 |
111 CFX_ByteString PDF_NameDecode(const CFX_ByteString& orig) { | 110 CFX_ByteString PDF_NameDecode(const CFX_ByteString& orig) { |
112 if (orig.Find('#') == -1) | 111 if (orig.Find('#') == -1) |
113 return orig; | 112 return orig; |
114 return PDF_NameDecode(orig.AsStringC()); | 113 return PDF_NameDecode(orig.AsStringC()); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 buf.AppendBlock(acc.GetData(), acc.GetSize()); | 212 buf.AppendBlock(acc.GetData(), acc.GetSize()); |
214 buf << "\r\nendstream"; | 213 buf << "\r\nendstream"; |
215 break; | 214 break; |
216 } | 215 } |
217 default: | 216 default: |
218 ASSERT(FALSE); | 217 ASSERT(FALSE); |
219 break; | 218 break; |
220 } | 219 } |
221 return buf; | 220 return buf; |
222 } | 221 } |
OLD | NEW |