DLLEXPORT FPDF_BOOKMARK STDCALL FPDFBookmark_Find(FPDF_DOCUMENT document, FPDF_WIDESTRING title) { if (document == NULL) return NULL; if (title == NULL || title[0] == 0) return NULL; CPDF_Document* pDoc = (CPDF_Document*)document; CPDF_BookmarkTree tree(pDoc); CFX_WideString wstr = CFX_WideString::FromUTF16LE(title); return FindBookmark(tree, NULL, wstr); }
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(); }
CChainElement_Rtf* CRTF_SummaryBuilder::InsertAtBookmark (LPCSTR szName, CChainElement_Rtf* pDoc, CChainElement_Rtf* pNew) { pDoc = FindBookmark(szName, pDoc); if (pDoc) { pDoc->Insert(pNew); } else { CHECK_CONDITION_NOT_EXPECTED; // Bookmarks changed in Template.rtf? delete pNew; } return pDoc; }
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()); }
static CPDF_Bookmark FindBookmark(CPDF_BookmarkTree& tree, CPDF_Bookmark This, const CFX_WideString& title) { if (This != NULL) { // First check this item CFX_WideString this_title = This.GetTitle(); if (this_title.CompareNoCase(title) == 0) return This; } // go into children items CPDF_Bookmark Child = tree.GetFirstChild(This); while (Child != NULL) { // check if this item CPDF_Bookmark Found = FindBookmark(tree, Child, title); if (Found) return Found; Child = tree.GetNextSibling(Child); } return NULL; }
CChainElement_Rtf* CRTF_SummaryBuilder::FindBookmark (LPCSTR szName, CChainElement_Rtf* pDoc) { while(pDoc) { switch(pDoc->GetType()) { case ROT_Table: { CRTF_Table* pTable = (CRTF_Table*)pDoc; int iCells = pTable->GetCellCount(); for(int i = 0; i < iCells; i++) { CRTF_Cell* pCell = pTable->Cell(i); CChainElement_Rtf* p = FindBookmark(szName, pCell->GetContent()); if (p) return p; } break; } case ROT_Bookmark: { if (((CRTF_Bookmark*)pDoc)->Is(szName)) return pDoc; break; } } pDoc = pDoc->GetNext(); } return NULL; }