diff options
author | Ralf Sippl <ralf.sippl@gmail.com> | 2018-03-26 18:38:20 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-03-26 18:38:20 +0000 |
commit | ca28cb636331de447125de476decbec333fe613b (patch) | |
tree | b532813458060d0700e76ea53e940d1587e2a6bb /fpdfsdk/fpdfannot.cpp | |
parent | 3ae75c2f2e5759fcf8218e59fa380c26b98aa6b6 (diff) | |
download | pdfium-ca28cb636331de447125de476decbec333fe613b.tar.xz |
Add FPDFAnnot_CountAttachmentPoints
This CL adds a function to the API that returns the number of quadpoint
sets.
Change-Id: I999bc567a4c98f6c32e87810e7ecfbb634c7b677
Reviewed-on: https://pdfium-review.googlesource.com/29130
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfannot.cpp')
-rw-r--r-- | fpdfsdk/fpdfannot.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/fpdfsdk/fpdfannot.cpp b/fpdfsdk/fpdfannot.cpp index b5dccaade1..c52807148e 100644 --- a/fpdfsdk/fpdfannot.cpp +++ b/fpdfsdk/fpdfannot.cpp @@ -583,7 +583,7 @@ FPDFAnnot_HasAttachmentPoints(FPDF_ANNOTATION annot) { FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetAttachmentPoints(FPDF_ANNOTATION annot, const FS_QUADPOINTSF* quad_points) { - if (!annot || !quad_points || !FPDFAnnot_HasAttachmentPoints(annot)) + if (!FPDFAnnot_HasAttachmentPoints(annot) || !quad_points) return false; CPDF_Dictionary* pAnnotDict = @@ -621,10 +621,21 @@ FPDFAnnot_SetAttachmentPoints(FPDF_ANNOTATION annot, return true; } +FPDF_EXPORT size_t FPDF_CALLCONV +FPDFAnnot_CountAttachmentPoints(FPDF_ANNOTATION annot) { + if (!FPDFAnnot_HasAttachmentPoints(annot)) + return 0; + + CPDF_Dictionary* pAnnotDict = + CPDFAnnotContextFromFPDFAnnotation(annot)->GetAnnotDict(); + const CPDF_Array* pArray = GetQuadPointsArrayFromDictionary(pAnnotDict); + return pArray ? pArray->GetCount() / 8 : 0; +} + FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetAttachmentPoints(FPDF_ANNOTATION annot, FS_QUADPOINTSF* quad_points) { - if (!annot || !quad_points || !FPDFAnnot_HasAttachmentPoints(annot)) + if (!FPDFAnnot_HasAttachmentPoints(annot) || !quad_points) return false; return GetQuadPointsFromDictionary( |