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

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: Created 6 years 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 19ca06ca276416e0df34c3f7e432b423ca910cc1..7a8a5350e2074a707b3627dca895a32e0738453e 100644
--- a/fpdfsdk/src/fpdfdoc.cpp
+++ b/fpdfsdk/src/fpdfdoc.cpp
@@ -28,6 +28,39 @@ static CPDF_Bookmark FindBookmark(CPDF_BookmarkTree& tree, CPDF_Bookmark This, c
return NULL;
}
+DLLEXPORT FPDF_BOOKMARK STDCALL FPDFBookmark_GetFirstChild(FPDF_DOCUMENT document, FPDF_BOOKMARK bookmark)
+{
+ if (document == NULL) return NULL;
Tom Sepez 2015/01/01 01:10:08 nit: or just !document.
Bo Xu 2015/01/05 22:46:52 Done.
+
+ CPDF_Document* pDoc = (CPDF_Document*)document;
+ CPDF_BookmarkTree tree(pDoc);
+ return (CPDF_Dictionary*)tree.GetFirstChild((CPDF_Dictionary*)bookmark);
Tom Sepez 2015/01/01 01:10:08 The cast of the return value doen't match the decl
Bo Xu 2015/01/01 06:40:38 This is an operator in CPDF_Bookmark class. I remo
+}
+
+DLLEXPORT FPDF_BOOKMARK STDCALL FPDFBookmark_GetNextSibling(FPDF_DOCUMENT document, FPDF_BOOKMARK bookmark)
+{
+ if (!document || !bookmark) return NULL;
+
+ CPDF_Document* pDoc = (CPDF_Document*)document;
+ CPDF_BookmarkTree tree(pDoc);
+ return (CPDF_Dictionary*)tree.GetNextSibling((CPDF_Dictionary*)bookmark);
Tom Sepez 2015/01/01 01:10:08 ditto.
Bo Xu 2015/01/01 06:40:38 ditto
+}
+
+DLLEXPORT unsigned long STDCALL FPDFBookmark_GetTitle(FPDF_BOOKMARK bookmark, void* buffer, unsigned long buflen)
+{
+ if (bookmark == NULL) return 0;
+
Tom Sepez 2015/01/01 01:10:08 nit: or just !bookmark
Bo Xu 2015/01/05 22:46:52 Done.
+ CPDF_Bookmark Bookmark = (CPDF_Dictionary*)bookmark;
Tom Sepez 2015/01/01 01:10:08 nit: maybe pBookmark to avoid starting local varia
Bo Xu 2015/01/05 22:46:52 Done.
+ CFX_WideString title = Bookmark.GetTitle();
+ CFX_ByteString bstr = title.UTF16LE_Encode(FALSE);
Tom Sepez 2015/01/01 01:10:08 nit: how about encoded_title instead of bstr (foll
+ unsigned long len = bstr.GetLength();
Tom Sepez 2015/01/01 01:10:08 nit: how about title_len instead of just len
+ if (buffer != NULL && buflen >= len + 2) {
Tom Sepez 2015/01/01 01:10:08 nit: (buffer && buflen >= len + 2)
Bo Xu 2015/01/05 22:46:52 Done.
+ FXSYS_memcpy(buffer, bstr.c_str(), len);
+ ((FX_BYTE*)buffer)[len] = ((FX_BYTE*)buffer)[len + 1] = 0;
Tom Sepez 2015/01/01 01:10:08 nit: two separate statements.
Bo Xu 2015/01/05 22:46:52 Done.
+ }
+ return len + 2;
+}
+
DLLEXPORT FPDF_BOOKMARK STDCALL FPDFBookmark_Find(FPDF_DOCUMENT document, FPDF_WIDESTRING title)
{
if (document == NULL) return NULL;
@@ -257,4 +290,3 @@ DLLEXPORT unsigned long STDCALL FPDF_GetMetaText(FPDF_DOCUMENT doc, FPDF_BYTESTR
}
return len+2;
}
-

Powered by Google App Engine
This is Rietveld 408576698