| 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 "public/fpdf_doc.h" | 7 #include "public/fpdf_doc.h" |
| 8 | 8 |
| 9 #include "fpdfsdk/include/fsdk_define.h" | 9 #include "fpdfsdk/include/fsdk_define.h" |
| 10 | 10 |
| 11 namespace { | 11 namespace { |
| 12 | 12 |
| 13 int THISMODULE = 0; | 13 int THISMODULE = 0; |
| 14 | 14 |
| 15 CPDF_Bookmark FindBookmark(const CPDF_BookmarkTree& tree, | 15 CPDF_Bookmark FindBookmark(const CPDF_BookmarkTree& tree, |
| 16 CPDF_Bookmark bookmark, | 16 CPDF_Bookmark bookmark, |
| 17 const CFX_WideString& title) { | 17 const CFX_WideString& title) { |
| 18 if (bookmark && bookmark.GetTitle().CompareNoCase(title.c_str()) == 0) { | 18 if (bookmark.GetDict() && |
| 19 bookmark.GetTitle().CompareNoCase(title.c_str()) == 0) { |
| 19 // First check this item | 20 // First check this item |
| 20 return bookmark; | 21 return bookmark; |
| 21 } | 22 } |
| 22 // go into children items | 23 // go into children items |
| 23 CPDF_Bookmark child = tree.GetFirstChild(bookmark); | 24 CPDF_Bookmark child = tree.GetFirstChild(bookmark); |
| 24 while (child) { | 25 while (child.GetDict()) { |
| 25 // check if this item | 26 // check if this item |
| 26 CPDF_Bookmark found = FindBookmark(tree, child, title); | 27 CPDF_Bookmark found = FindBookmark(tree, child, title); |
| 27 if (found) | 28 if (found.GetDict()) |
| 28 return found; | 29 return found; |
| 29 child = tree.GetNextSibling(child); | 30 child = tree.GetNextSibling(child); |
| 30 } | 31 } |
| 31 return CPDF_Bookmark(); | 32 return CPDF_Bookmark(); |
| 32 } | 33 } |
| 33 | 34 |
| 34 void ReleaseLinkList(void* data) { | 35 void ReleaseLinkList(void* data) { |
| 35 delete (CPDF_LinkList*)data; | 36 delete (CPDF_LinkList*)data; |
| 36 } | 37 } |
| 37 | 38 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 | 106 |
| 106 DLLEXPORT FPDF_DEST STDCALL FPDFBookmark_GetDest(FPDF_DOCUMENT document, | 107 DLLEXPORT FPDF_DEST STDCALL FPDFBookmark_GetDest(FPDF_DOCUMENT document, |
| 107 FPDF_BOOKMARK pDict) { | 108 FPDF_BOOKMARK pDict) { |
| 108 if (!pDict) | 109 if (!pDict) |
| 109 return nullptr; | 110 return nullptr; |
| 110 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); | 111 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); |
| 111 if (!pDoc) | 112 if (!pDoc) |
| 112 return nullptr; | 113 return nullptr; |
| 113 CPDF_Bookmark bookmark(ToDictionary(static_cast<CPDF_Object*>(pDict))); | 114 CPDF_Bookmark bookmark(ToDictionary(static_cast<CPDF_Object*>(pDict))); |
| 114 CPDF_Dest dest = bookmark.GetDest(pDoc); | 115 CPDF_Dest dest = bookmark.GetDest(pDoc); |
| 115 if (dest) | 116 if (dest.GetObject()) |
| 116 return dest.GetObject(); | 117 return dest.GetObject(); |
| 117 // If this bookmark is not directly associated with a dest, we try to get | 118 // If this bookmark is not directly associated with a dest, we try to get |
| 118 // action | 119 // action |
| 119 CPDF_Action action = bookmark.GetAction(); | 120 CPDF_Action action = bookmark.GetAction(); |
| 120 if (!action) | 121 if (!action) |
| 121 return nullptr; | 122 return nullptr; |
| 122 return action.GetDest(pDoc).GetObject(); | 123 return action.GetDest(pDoc).GetObject(); |
| 123 } | 124 } |
| 124 | 125 |
| 125 DLLEXPORT FPDF_ACTION STDCALL FPDFBookmark_GetAction(FPDF_BOOKMARK pDict) { | 126 DLLEXPORT FPDF_ACTION STDCALL FPDFBookmark_GetAction(FPDF_BOOKMARK pDict) { |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 return 0; | 347 return 0; |
| 347 CFX_WideString text = pInfo->GetUnicodeTextBy(tag); | 348 CFX_WideString text = pInfo->GetUnicodeTextBy(tag); |
| 348 // Use UTF-16LE encoding | 349 // Use UTF-16LE encoding |
| 349 CFX_ByteString encodedText = text.UTF16LE_Encode(); | 350 CFX_ByteString encodedText = text.UTF16LE_Encode(); |
| 350 unsigned long len = encodedText.GetLength(); | 351 unsigned long len = encodedText.GetLength(); |
| 351 if (buffer && buflen >= len) { | 352 if (buffer && buflen >= len) { |
| 352 FXSYS_memcpy(buffer, encodedText.c_str(), len); | 353 FXSYS_memcpy(buffer, encodedText.c_str(), len); |
| 353 } | 354 } |
| 354 return len; | 355 return len; |
| 355 } | 356 } |
| OLD | NEW |