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/fxcodec/fx_codec.h" | 7 #include "../../core/include/fxcodec/fx_codec.h" |
8 #include "../../core/include/fxcrt/fx_safe_types.h" | 8 #include "../../core/include/fxcrt/fx_safe_types.h" |
9 #include "../../public/fpdf_ext.h" | 9 #include "../../public/fpdf_ext.h" |
10 #include "../../public/fpdf_progressive.h" | 10 #include "../../public/fpdf_progressive.h" |
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 continue; | 875 continue; |
876 if (i == index) | 876 if (i == index) |
877 break; | 877 break; |
878 i++; | 878 i++; |
879 } | 879 } |
880 } else { | 880 } else { |
881 pDestObj = nameTree.LookupValue(index, bsName); | 881 pDestObj = nameTree.LookupValue(index, bsName); |
882 } | 882 } |
883 if (!pDestObj) | 883 if (!pDestObj) |
884 return NULL; | 884 return NULL; |
885 if (pDestObj->GetType() == PDFOBJ_DICTIONARY) { | 885 if (CPDF_Dictionary* pDict = pDestObj->AsDictionary()) { |
886 pDestObj = ((CPDF_Dictionary*)pDestObj)->GetArray(FX_BSTRC("D")); | 886 pDestObj = pDict->GetArray(FX_BSTRC("D")); |
887 if (!pDestObj) | 887 if (!pDestObj) |
888 return NULL; | 888 return NULL; |
889 } | 889 } |
890 if (pDestObj->GetType() != PDFOBJ_ARRAY) | 890 if (pDestObj->GetType() != PDFOBJ_ARRAY) |
891 return NULL; | 891 return NULL; |
892 CFX_WideString wsName = PDF_DecodeText(bsName); | 892 CFX_WideString wsName = PDF_DecodeText(bsName); |
893 CFX_ByteString utf16Name = wsName.UTF16LE_Encode(); | 893 CFX_ByteString utf16Name = wsName.UTF16LE_Encode(); |
894 unsigned int len = utf16Name.GetLength(); | 894 unsigned int len = utf16Name.GetLength(); |
895 if (!buffer) { | 895 if (!buffer) { |
896 *buflen = len; | 896 *buflen = len; |
897 } else if (*buflen >= len) { | 897 } else if (*buflen >= len) { |
898 memcpy(buffer, utf16Name.c_str(), len); | 898 memcpy(buffer, utf16Name.c_str(), len); |
899 *buflen = len; | 899 *buflen = len; |
900 } else { | 900 } else { |
901 *buflen = -1; | 901 *buflen = -1; |
902 } | 902 } |
903 return (FPDF_DEST)pDestObj; | 903 return (FPDF_DEST)pDestObj; |
904 } | 904 } |
OLD | NEW |