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 <dsinclair@chromium.org>
Commit-Queue: Jane Liu <janeliulwq@google.com>
diff --git a/public/fpdf_annot.h b/public/fpdf_annot.h
index bd18898..0a1646f 100644
--- a/public/fpdf_annot.h
+++ b/public/fpdf_annot.h
@@ -71,13 +71,10 @@
//
// page - handle to a page.
// subtype - the subtype of the new annotation.
-// annot - receives the newly created annotation.
//
-// Returns true if successful, false otherwise.
-DLLEXPORT FPDF_BOOL STDCALL
-FPDFPage_CreateAnnot(FPDF_PAGE page,
- FPDF_ANNOTATION_SUBTYPE subtype,
- FPDF_ANNOTATION* annot);
+// Returns a handle to the new annotation object, or NULL on failure.
+DLLEXPORT FPDF_ANNOTATION STDCALL
+FPDFPage_CreateAnnot(FPDF_PAGE page, FPDF_ANNOTATION_SUBTYPE subtype);
// Get the number of annotations in |page|.
//
@@ -90,12 +87,9 @@
//
// page - handle to a page.
// index - the index of the annotation.
-// annot - receives the annotation.
//
-// Returns true if successful, false otherwise.
-DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GetAnnot(FPDF_PAGE page,
- int index,
- FPDF_ANNOTATION* annot);
+// Returns a handle to the annotation object, or NULL on failure.
+DLLEXPORT FPDF_ANNOTATION STDCALL FPDFPage_GetAnnot(FPDF_PAGE page, int index);
// Close an annotation. Must be called when the annotation returned by
// FPDFPage_CreateAnnot() or FPDFPage_GetAnnot() is no longer needed. This
@@ -169,12 +163,10 @@
// Get the attachment points (i.e. quadpoints) of an annotation.
//
// annot - handle to an annotation.
-// quadPoints - receives the attachment points.
//
-// Returns true if successful, false otherwise.
-DLLEXPORT FPDF_BOOL STDCALL
-FPDFAnnot_GetAttachmentPoints(FPDF_ANNOTATION annot,
- FS_QUADPOINTSF* quadPoints);
+// Returns a quadpoints object, or an empty set of quadpoints on failure.
+DLLEXPORT FS_QUADPOINTSF STDCALL
+FPDFAnnot_GetAttachmentPoints(FPDF_ANNOTATION annot);
// Set the annotation rectangle defining the location of the annotation.
//
@@ -188,11 +180,9 @@
// Get the annotation rectangle defining the location of the annotation.
//
// annot - handle to an annotation.
-// rect - receives the annotation rectangle.
//
-// Returns true if successful, false otherwise.
-DLLEXPORT FPDF_BOOL STDCALL FPDFAnnot_GetRect(FPDF_ANNOTATION annot,
- FS_RECTF* rect);
+// Returns a rectangle object, or an empty rectangle on failure.
+DLLEXPORT FS_RECTF STDCALL FPDFAnnot_GetRect(FPDF_ANNOTATION annot);
// Set the contents of an annotation.
//