From 476cd69a6f5c5096a3145e0c4d567010f37739c3 Mon Sep 17 00:00:00 2001 From: Bo Xu Date: Sat, 10 Jan 2015 22:52:59 -0800 Subject: Add APIs for getting bookmarks and named destinations. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/834703002 --- fpdfsdk/src/fpdfdoc.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'fpdfsdk/src/fpdfdoc.cpp') diff --git a/fpdfsdk/src/fpdfdoc.cpp b/fpdfsdk/src/fpdfdoc.cpp index ab2351f9d8..feb7cfbde5 100644 --- a/fpdfsdk/src/fpdfdoc.cpp +++ b/fpdfsdk/src/fpdfdoc.cpp @@ -27,6 +27,42 @@ static CPDF_Bookmark FindBookmark(const CPDF_BookmarkTree& tree, CPDF_Bookmark b return CPDF_Bookmark(); } +DLLEXPORT FPDF_BOOKMARK STDCALL FPDFBookmark_GetFirstChild(FPDF_DOCUMENT document, FPDF_BOOKMARK pDict) +{ + if (!document || !pDict) + return NULL; + CPDF_Document* pDoc = (CPDF_Document*)document; + CPDF_BookmarkTree tree(pDoc); + CPDF_Bookmark bookmark = CPDF_Bookmark((CPDF_Dictionary*)pDict); + return tree.GetFirstChild(bookmark).GetDict(); +} + +DLLEXPORT FPDF_BOOKMARK STDCALL FPDFBookmark_GetNextSibling(FPDF_DOCUMENT document, FPDF_BOOKMARK pDict) +{ + if (!document || !pDict) + return NULL; + CPDF_Document* pDoc = (CPDF_Document*)document; + CPDF_BookmarkTree tree(pDoc); + CPDF_Bookmark bookmark = CPDF_Bookmark((CPDF_Dictionary*)pDict); + return tree.GetNextSibling(bookmark).GetDict(); +} + +DLLEXPORT unsigned long STDCALL FPDFBookmark_GetTitle(FPDF_BOOKMARK pDict, void* buffer, unsigned long buflen) +{ + if (!pDict) + return 0; + CPDF_Bookmark bookmark((CPDF_Dictionary*)pDict); + CFX_WideString title = bookmark.GetTitle(); + CFX_ByteString encodedTitle = title.UTF16LE_Encode(FALSE); + unsigned long len = encodedTitle.GetLength(); + if (buffer && buflen >= len + 2) { + FXSYS_memcpy(buffer, encodedTitle.c_str(), len); + ((FX_BYTE*)buffer)[len] = 0; + ((FX_BYTE*)buffer)[len + 1] = 0; + } + return len + 2; +} + DLLEXPORT FPDF_BOOKMARK STDCALL FPDFBookmark_Find(FPDF_DOCUMENT document, FPDF_WIDESTRING title) { if (!document) -- cgit v1.2.3