| 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/fsdk_define.h" | 7 #include "../include/fsdk_define.h" |
| 8 #include "../include/fsdk_mgr.h" | 8 #include "../include/fsdk_mgr.h" |
| 9 #include "../include/fsdk_rendercontext.h" | 9 #include "../include/fsdk_rendercontext.h" |
| 10 #include "../../public/fpdfview.h" | 10 #include "../../public/fpdfview.h" |
| (...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 if (!document) | 818 if (!document) |
| 819 return NULL; | 819 return NULL; |
| 820 if (!name || name[0] == 0) | 820 if (!name || name[0] == 0) |
| 821 return NULL; | 821 return NULL; |
| 822 | 822 |
| 823 CPDF_Document* pDoc = (CPDF_Document*)document; | 823 CPDF_Document* pDoc = (CPDF_Document*)document; |
| 824 CPDF_NameTree name_tree(pDoc, FX_BSTRC("Dests")); | 824 CPDF_NameTree name_tree(pDoc, FX_BSTRC("Dests")); |
| 825 return name_tree.LookupNamedDest(pDoc, name); | 825 return name_tree.LookupNamedDest(pDoc, name); |
| 826 } | 826 } |
| 827 | 827 |
| 828 DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document, int index,
void* buffer, long& buflen) | 828 DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document, int index,
void* buffer, long* buflen) |
| 829 { | 829 { |
| 830 if (!buffer) | 830 if (!buffer) |
| 831 buflen = 0; | 831 *buflen = 0; |
| 832 if (!document || index < 0) return NULL; | 832 if (!document || index < 0) return NULL; |
| 833 CPDF_Document* pDoc = (CPDF_Document*)document; | 833 CPDF_Document* pDoc = (CPDF_Document*)document; |
| 834 | 834 |
| 835 CPDF_Dictionary* pRoot = pDoc->GetRoot(); | 835 CPDF_Dictionary* pRoot = pDoc->GetRoot(); |
| 836 if (!pRoot) return NULL; | 836 if (!pRoot) return NULL; |
| 837 | 837 |
| 838 CPDF_Object* pDestObj = NULL; | 838 CPDF_Object* pDestObj = NULL; |
| 839 CFX_ByteString bsName; | 839 CFX_ByteString bsName; |
| 840 CPDF_NameTree nameTree(pDoc, FX_BSTRC("Dests")); | 840 CPDF_NameTree nameTree(pDoc, FX_BSTRC("Dests")); |
| 841 int count = nameTree.GetCount(); | 841 int count = nameTree.GetCount(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 858 if (!pDestObj) return NULL; | 858 if (!pDestObj) return NULL; |
| 859 if (pDestObj->GetType() == PDFOBJ_DICTIONARY) { | 859 if (pDestObj->GetType() == PDFOBJ_DICTIONARY) { |
| 860 pDestObj = ((CPDF_Dictionary*)pDestObj)->GetArray(FX_BSTRC("D")); | 860 pDestObj = ((CPDF_Dictionary*)pDestObj)->GetArray(FX_BSTRC("D")); |
| 861 if (!pDestObj) return NULL; | 861 if (!pDestObj) return NULL; |
| 862 } | 862 } |
| 863 if (pDestObj->GetType() != PDFOBJ_ARRAY) return NULL; | 863 if (pDestObj->GetType() != PDFOBJ_ARRAY) return NULL; |
| 864 CFX_WideString wsName = PDF_DecodeText(bsName); | 864 CFX_WideString wsName = PDF_DecodeText(bsName); |
| 865 CFX_ByteString utf16Name = wsName.UTF16LE_Encode(); | 865 CFX_ByteString utf16Name = wsName.UTF16LE_Encode(); |
| 866 unsigned int len = utf16Name.GetLength(); | 866 unsigned int len = utf16Name.GetLength(); |
| 867 if (!buffer) { | 867 if (!buffer) { |
| 868 buflen = len; | 868 *buflen = len; |
| 869 } else if (buflen >= len) { | 869 } else if (*buflen >= len) { |
| 870 memcpy(buffer, utf16Name.c_str(), len); | 870 memcpy(buffer, utf16Name.c_str(), len); |
| 871 buflen = len; | 871 *buflen = len; |
| 872 } else { | 872 } else { |
| 873 buflen = -1; | 873 *buflen = -1; |
| 874 } | 874 } |
| 875 return (FPDF_DEST)pDestObj; | 875 return (FPDF_DEST)pDestObj; |
| 876 } | 876 } |
| OLD | NEW |