From d60e9ad5194e13475ccb21575a7c57de1e2e22c4 Mon Sep 17 00:00:00 2001 From: Jane Liu Date: Mon, 26 Jun 2017 11:28:36 -0400 Subject: Changed the return type for annotation APIs Before: When returning FPDF_ANNOTATION, the APIs would take in a FPDF_ANNTOATION* and write the handle of the annotation to it, while returning a boolean as status. This CL: This CL changes the APIs to directly return FPDF_ANNOTATION, which would be null on failure. Also adds more null checks within the annotation APIs. Bug=pdfium:737 Change-Id: I4f77dd1b16d43eab3f16c303598b76591da0dcab Reviewed-on: https://pdfium-review.googlesource.com/6952 Reviewed-by: dsinclair Commit-Queue: Jane Liu --- samples/pdfium_test.cc | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) (limited to 'samples') diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc index ccd57a7e6a..5a3668f6ce 100644 --- a/samples/pdfium_test.cc +++ b/samples/pdfium_test.cc @@ -277,8 +277,8 @@ void WriteAnnot(FPDF_PAGE page, const char* pdf_name, int num) { for (int i = 0; i < annot_count; i++) { // Retrieve the annotation object and its subtype. fprintf(fp, "Annotation #%d:\n", i + 1); - FPDF_ANNOTATION annot; - if (!FPDFPage_GetAnnot(page, i, &annot)) { + FPDF_ANNOTATION annot = FPDFPage_GetAnnot(page, i); + if (!annot) { fprintf(fp, "Failed to retrieve annotation!\n\n"); continue; } @@ -319,25 +319,17 @@ void WriteAnnot(FPDF_PAGE page, const char* pdf_name, int num) { .c_str()); // Retrieve the annotation's quadpoints if it is a markup annotation. - FS_QUADPOINTSF quadpoints; if (FPDFAnnot_HasAttachmentPoints(annot)) { - if (!FPDFAnnot_GetAttachmentPoints(annot, &quadpoints)) { - fprintf(fp, "Failed to retrieve quadpoints.\n"); - } else { - fprintf(fp, "Quadpoints: (%f, %f), (%f, %f), (%f, %f), (%f, %f)\n", - quadpoints.x1, quadpoints.y1, quadpoints.x2, quadpoints.y2, - quadpoints.x3, quadpoints.y3, quadpoints.x4, quadpoints.y4); - } + FS_QUADPOINTSF quadpoints = FPDFAnnot_GetAttachmentPoints(annot); + fprintf(fp, "Quadpoints: (%f, %f), (%f, %f), (%f, %f), (%f, %f)\n", + quadpoints.x1, quadpoints.y1, quadpoints.x2, quadpoints.y2, + quadpoints.x3, quadpoints.y3, quadpoints.x4, quadpoints.y4); } // Retrieve the annotation's rectangle coordinates. - FS_RECTF rect; - if (!FPDFAnnot_GetRect(annot, &rect)) { - fprintf(fp, "Failed to retrieve rectangle.\n\n"); - } else { - fprintf(fp, "Rectangle: l - %f, b - %f, r - %f, t - %f\n\n", rect.left, - rect.bottom, rect.right, rect.top); - } + FS_RECTF rect = FPDFAnnot_GetRect(annot); + fprintf(fp, "Rectangle: l - %f, b - %f, r - %f, t - %f\n\n", rect.left, + rect.bottom, rect.right, rect.top); } (void)fclose(fp); -- cgit v1.2.3