From 300bb27bf4a9a84fcd3f1348a4c0076d68a305ce Mon Sep 17 00:00:00 2001 From: Jane Liu Date: Mon, 21 Aug 2017 14:37:53 -0400 Subject: Added FPDFAnnot_GetLinkedAnnot() Added FPDFAnnot_GetLinkedAnnot() to retrieve annotations linked to other annotations through a specified key. Bug=pdfium:863,pdfium:737 Change-Id: If81f41178fb4c40f6561bd392215c709722c4000 Reviewed-on: https://pdfium-review.googlesource.com/11491 Reviewed-by: Lei Zhang Commit-Queue: Jane Liu --- fpdfsdk/fpdfannot.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'fpdfsdk/fpdfannot.cpp') diff --git a/fpdfsdk/fpdfannot.cpp b/fpdfsdk/fpdfannot.cpp index 5c4aae2075..ec748e66ec 100644 --- a/fpdfsdk/fpdfannot.cpp +++ b/fpdfsdk/fpdfannot.cpp @@ -727,6 +727,22 @@ FPDFAnnot_GetStringValue(FPDF_ANNOTATION annot, buffer, buflen); } +FPDF_EXPORT FPDF_ANNOTATION FPDF_CALLCONV +FPDFAnnot_GetLinkedAnnot(FPDF_ANNOTATION annot, FPDF_WIDESTRING key) { + CPDF_AnnotContext* pAnnot = CPDFAnnotContextFromFPDFAnnotation(annot); + if (!pAnnot || !pAnnot->GetAnnotDict()) + return nullptr; + + CPDF_Dictionary* pLinkedDict = + pAnnot->GetAnnotDict()->GetDictFor(CFXByteStringFromFPDFWideString(key)); + if (!pLinkedDict || pLinkedDict->GetStringFor("Type") != "Annot") + return nullptr; + + auto pLinkedAnnot = pdfium::MakeUnique( + pLinkedDict, pAnnot->GetPage(), nullptr); + return pLinkedAnnot.release(); +} + FPDF_EXPORT int FPDF_CALLCONV FPDFAnnot_GetFlags(FPDF_ANNOTATION annot) { if (!annot) return FPDF_ANNOT_FLAG_NONE; -- cgit v1.2.3