Change FPDFAnnot_IsSupportedSubtype() to use a switch statement.
As the list of supported subtypes get longer, it becomes a bit hard to
read. A switch statement lays out the cases more cleanly.
Do the same in the API documentation, and then fix an entry that is
missing from the documentation.
https://pdfium-review.googlesource.com/26390 forgot to add it.
Change-Id: Ie7c0ad07b05e27e1e556733510a23eff68830edd
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/79532
Reviewed-by: Daniel Hosseinian <dhoss@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fpdfsdk/fpdf_annot.cpp b/fpdfsdk/fpdf_annot.cpp
index ddedcf1..8545459 100644
--- a/fpdfsdk/fpdf_annot.cpp
+++ b/fpdfsdk/fpdf_annot.cpp
@@ -314,12 +314,23 @@
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDFAnnot_IsSupportedSubtype(FPDF_ANNOTATION_SUBTYPE subtype) {
// The supported subtypes must also be communicated in the user doc.
- return subtype == FPDF_ANNOT_CIRCLE || subtype == FPDF_ANNOT_FREETEXT ||
- subtype == FPDF_ANNOT_HIGHLIGHT || subtype == FPDF_ANNOT_INK ||
- subtype == FPDF_ANNOT_LINK || subtype == FPDF_ANNOT_POPUP ||
- subtype == FPDF_ANNOT_SQUARE || subtype == FPDF_ANNOT_SQUIGGLY ||
- subtype == FPDF_ANNOT_STAMP || subtype == FPDF_ANNOT_STRIKEOUT ||
- subtype == FPDF_ANNOT_TEXT || subtype == FPDF_ANNOT_UNDERLINE;
+ switch (subtype) {
+ case FPDF_ANNOT_CIRCLE:
+ case FPDF_ANNOT_FREETEXT:
+ case FPDF_ANNOT_HIGHLIGHT:
+ case FPDF_ANNOT_INK:
+ case FPDF_ANNOT_LINK:
+ case FPDF_ANNOT_POPUP:
+ case FPDF_ANNOT_SQUARE:
+ case FPDF_ANNOT_SQUIGGLY:
+ case FPDF_ANNOT_STAMP:
+ case FPDF_ANNOT_STRIKEOUT:
+ case FPDF_ANNOT_TEXT:
+ case FPDF_ANNOT_UNDERLINE:
+ return true;
+ default:
+ return false;
+ }
}
FPDF_EXPORT FPDF_ANNOTATION FPDF_CALLCONV
diff --git a/public/fpdf_annot.h b/public/fpdf_annot.h
index e4729ce..04e411a 100644
--- a/public/fpdf_annot.h
+++ b/public/fpdf_annot.h
@@ -91,8 +91,19 @@
// Experimental API.
// Check if an annotation subtype is currently supported for creation.
-// Currently supported subtypes: circle, highlight, ink, link, popup, square,
-// squiggly, stamp, strikeout, text, and underline.
+// Currently supported subtypes:
+// - circle
+// - freetext
+// - highlight
+// - ink
+// - link
+// - popup
+// - square,
+// - squiggly
+// - stamp
+// - strikeout
+// - text
+// - underline
//
// subtype - the subtype to be checked.
//