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/include/fpdfapi/fpdf_module.h" | 7 #include "../../core/include/fpdfapi/fpdf_module.h" |
8 #include "../../core/include/fxcodec/fx_codec.h" | 8 #include "../../core/include/fxcodec/fx_codec.h" |
9 #include "../../core/include/fxcrt/fx_safe_types.h" | 9 #include "../../core/include/fxcrt/fx_safe_types.h" |
10 #include "../../public/fpdf_ext.h" | 10 #include "../../public/fpdf_ext.h" |
(...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1044 continue; | 1044 continue; |
1045 if (i == index) | 1045 if (i == index) |
1046 break; | 1046 break; |
1047 i++; | 1047 i++; |
1048 } | 1048 } |
1049 } else { | 1049 } else { |
1050 pDestObj = nameTree.LookupValue(index, bsName); | 1050 pDestObj = nameTree.LookupValue(index, bsName); |
1051 } | 1051 } |
1052 if (!pDestObj) | 1052 if (!pDestObj) |
1053 return NULL; | 1053 return NULL; |
1054 if (pDestObj->GetType() == PDFOBJ_DICTIONARY) { | 1054 if (CPDF_Dictionary* pDict = pDestObj->AsDictionary()) { |
1055 pDestObj = ((CPDF_Dictionary*)pDestObj)->GetArray(FX_BSTRC("D")); | 1055 pDestObj = pDict->GetArray(FX_BSTRC("D")); |
1056 if (!pDestObj) | 1056 if (!pDestObj) |
1057 return NULL; | 1057 return NULL; |
1058 } | 1058 } |
1059 if (pDestObj->GetType() != PDFOBJ_ARRAY) | 1059 if (pDestObj->GetType() != PDFOBJ_ARRAY) |
1060 return NULL; | 1060 return NULL; |
1061 CFX_WideString wsName = PDF_DecodeText(bsName); | 1061 CFX_WideString wsName = PDF_DecodeText(bsName); |
1062 CFX_ByteString utf16Name = wsName.UTF16LE_Encode(); | 1062 CFX_ByteString utf16Name = wsName.UTF16LE_Encode(); |
1063 unsigned int len = utf16Name.GetLength(); | 1063 unsigned int len = utf16Name.GetLength(); |
1064 if (!buffer) { | 1064 if (!buffer) { |
1065 *buflen = len; | 1065 *buflen = len; |
1066 } else if (*buflen >= len) { | 1066 } else if (*buflen >= len) { |
1067 memcpy(buffer, utf16Name.c_str(), len); | 1067 memcpy(buffer, utf16Name.c_str(), len); |
1068 *buflen = len; | 1068 *buflen = len; |
1069 } else { | 1069 } else { |
1070 *buflen = -1; | 1070 *buflen = -1; |
1071 } | 1071 } |
1072 return (FPDF_DEST)pDestObj; | 1072 return (FPDF_DEST)pDestObj; |
1073 } | 1073 } |
OLD | NEW |