Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(390)

Unified Diff: fpdfsdk/src/fpdfdoc.cpp

Issue 834703002: Add APIs for getting bookmarks and named destinations. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: use C style query mode for destination name Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: fpdfsdk/src/fpdfdoc.cpp
diff --git a/fpdfsdk/src/fpdfdoc.cpp b/fpdfsdk/src/fpdfdoc.cpp
index ab2351f9d8102912ffce7709bcc7c97f7238ca2f..0176bad3a5ba802a74f2607ba897b8f9e9955e4e 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)
raymes 2015/01/08 03:55:44 should you check if pDict is null here too (as in
Bo Xu 2015/01/09 19:35:21 Done.
+ return NULL;
+ CPDF_Document* pDoc = (CPDF_Document*)document;
+ CPDF_BookmarkTree tree(pDoc);
+ CPDF_Bookmark bookmark = CPDF_Bookmark((CPDF_Dictionary*)pDict);
raymes 2015/01/08 03:55:44 nit: indentation
Bo Xu 2015/01/09 19:35:21 Done.
+ 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);
raymes 2015/01/08 03:55:44 nit: indentation (here and the next line)
Bo Xu 2015/01/09 19:35:21 Done.
+ return tree.GetNextSibling(bookmark).GetDict();
+}
+
+DLLEXPORT unsigned long STDCALL FPDFBookmark_GetTitle(FPDF_BOOKMARK pDict, void* buffer, unsigned long buflen)
+{
+ if (!NULL)
raymes 2015/01/08 03:55:44 I think you want pDict here
Bo Xu 2015/01/09 19:35:21 Done.
+ 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();
raymes 2015/01/08 03:55:44 nit: indentation
Bo Xu 2015/01/09 19:35:21 Done.
+ 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)

Powered by Google App Engine
This is Rietveld 408576698