CPDF_Bookmark CPDF_BookmarkTree::GetNextSibling( const CPDF_Bookmark& bookmark) const { if (!bookmark.m_pDict) { return CPDF_Bookmark(); } CPDF_Dictionary* pNext = bookmark.m_pDict->GetDict("Next"); return pNext == bookmark.m_pDict ? CPDF_Bookmark() : CPDF_Bookmark(pNext); }
CPDF_Bookmark CPDF_BookmarkTree::GetFirstChild( const CPDF_Bookmark& parent) const { if (!parent.m_pDict) { CPDF_Dictionary* pRoot = m_pDocument->GetRoot()->GetDict("Outlines"); if (!pRoot) { return CPDF_Bookmark(); } return CPDF_Bookmark(pRoot->GetDict("First")); } return CPDF_Bookmark(parent.m_pDict->GetDict("First")); }
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 FPDF_BOOKMARK STDCALL FPDFBookmark_GetFirstChild(FPDF_DOCUMENT document, FPDF_BOOKMARK pDict) { CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); if (!pDoc) return nullptr; CPDF_BookmarkTree tree(pDoc); CPDF_Bookmark bookmark = CPDF_Bookmark(ToDictionary(static_cast<CPDF_Object*>(pDict))); return tree.GetFirstChild(bookmark).GetDict(); }
DLLEXPORT FPDF_BOOKMARK STDCALL FPDFBookmark_Find(FPDF_DOCUMENT document, FPDF_WIDESTRING title) { if (!document) return NULL; if (!title || title[0] == 0) return NULL; CPDF_Document* pDoc = (CPDF_Document*)document; CPDF_BookmarkTree tree(pDoc); FX_STRSIZE len = CFX_WideString::WStringLength(title); CFX_WideString encodedTitle = CFX_WideString::FromUTF16LE(title, len); return FindBookmark(tree, CPDF_Bookmark(), encodedTitle).GetDict(); }
DLLEXPORT FPDF_BOOKMARK STDCALL FPDFBookmark_Find(FPDF_DOCUMENT document, FPDF_WIDESTRING title) { if (!title || title[0] == 0) return nullptr; CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); if (!pDoc) return nullptr; CPDF_BookmarkTree tree(pDoc); FX_STRSIZE len = CFX_WideString::WStringLength(title); CFX_WideString encodedTitle = CFX_WideString::FromUTF16LE(title, len); std::set<CPDF_Dictionary*> visited; return FindBookmark(tree, CPDF_Bookmark(), encodedTitle, &visited).GetDict(); }
FPDF_EXPORT FPDF_BOOKMARK FPDF_CALLCONV FPDFBookmark_Find(FPDF_DOCUMENT document, FPDF_WIDESTRING title) { CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); if (!pDoc) return nullptr; if (!title || title[0] == 0) return nullptr; CPDF_BookmarkTree tree(pDoc); size_t len = WideString::WStringLength(title); WideString encodedTitle = WideString::FromUTF16LE(title, len); std::set<const CPDF_Dictionary*> visited; return FPDFBookmarkFromCPDFDictionary( FindBookmark(tree, CPDF_Bookmark(), encodedTitle, &visited).GetDict()); }