Tidy CheckUnSupportAnnot().
- Rename it to CheckForUnsupportedAnnot().
- Remove unneeded document parameter.
- Made the implementation into a switch statement.
Change-Id: I88588286142bf42d3b4822694690ebe9688d0770
Reviewed-on: https://pdfium-review.googlesource.com/c/51230
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fpdfsdk/cpdfsdk_helpers.cpp b/fpdfsdk/cpdfsdk_helpers.cpp
index 46a7c1c..fcedc1f 100644
--- a/fpdfsdk/cpdfsdk_helpers.cpp
+++ b/fpdfsdk/cpdfsdk_helpers.cpp
@@ -364,32 +364,43 @@
RaiseUnSupportError(FPDF_UNSP_DOC_XFAFORM);
}
-void CheckUnSupportAnnot(CPDF_Document* pDoc, const CPDF_Annot* pPDFAnnot) {
- CPDF_Annot::Subtype nAnnotSubtype = pPDFAnnot->GetSubtype();
- if (nAnnotSubtype == CPDF_Annot::Subtype::THREED) {
- RaiseUnSupportError(FPDF_UNSP_ANNOT_3DANNOT);
- } else if (nAnnotSubtype == CPDF_Annot::Subtype::SCREEN) {
- const CPDF_Dictionary* pAnnotDict = pPDFAnnot->GetAnnotDict();
- ByteString cbString;
- if (pAnnotDict->KeyExist("IT"))
- cbString = pAnnotDict->GetStringFor("IT");
- if (cbString.Compare("Img") != 0)
- RaiseUnSupportError(FPDF_UNSP_ANNOT_SCREEN_MEDIA);
- } else if (nAnnotSubtype == CPDF_Annot::Subtype::MOVIE) {
- RaiseUnSupportError(FPDF_UNSP_ANNOT_MOVIE);
- } else if (nAnnotSubtype == CPDF_Annot::Subtype::SOUND) {
- RaiseUnSupportError(FPDF_UNSP_ANNOT_SOUND);
- } else if (nAnnotSubtype == CPDF_Annot::Subtype::RICHMEDIA) {
- RaiseUnSupportError(FPDF_UNSP_ANNOT_SCREEN_RICHMEDIA);
- } else if (nAnnotSubtype == CPDF_Annot::Subtype::FILEATTACHMENT) {
- RaiseUnSupportError(FPDF_UNSP_ANNOT_ATTACHMENT);
- } else if (nAnnotSubtype == CPDF_Annot::Subtype::WIDGET) {
- const CPDF_Dictionary* pAnnotDict = pPDFAnnot->GetAnnotDict();
- ByteString cbString;
- if (pAnnotDict->KeyExist("FT"))
- cbString = pAnnotDict->GetStringFor("FT");
- if (cbString.Compare("Sig") == 0)
- RaiseUnSupportError(FPDF_UNSP_ANNOT_SIG);
+void CheckForUnsupportedAnnot(const CPDF_Annot* pAnnot) {
+ switch (pAnnot->GetSubtype()) {
+ case CPDF_Annot::Subtype::FILEATTACHMENT:
+ RaiseUnSupportError(FPDF_UNSP_ANNOT_ATTACHMENT);
+ break;
+ case CPDF_Annot::Subtype::MOVIE:
+ RaiseUnSupportError(FPDF_UNSP_ANNOT_MOVIE);
+ break;
+ case CPDF_Annot::Subtype::RICHMEDIA:
+ RaiseUnSupportError(FPDF_UNSP_ANNOT_SCREEN_RICHMEDIA);
+ break;
+ case CPDF_Annot::Subtype::SCREEN: {
+ const CPDF_Dictionary* pAnnotDict = pAnnot->GetAnnotDict();
+ ByteString cbString;
+ if (pAnnotDict->KeyExist("IT"))
+ cbString = pAnnotDict->GetStringFor("IT");
+ if (cbString.Compare("Img") != 0)
+ RaiseUnSupportError(FPDF_UNSP_ANNOT_SCREEN_MEDIA);
+ break;
+ }
+ case CPDF_Annot::Subtype::SOUND:
+ RaiseUnSupportError(FPDF_UNSP_ANNOT_SOUND);
+ break;
+ case CPDF_Annot::Subtype::THREED:
+ RaiseUnSupportError(FPDF_UNSP_ANNOT_3DANNOT);
+ break;
+ case CPDF_Annot::Subtype::WIDGET: {
+ const CPDF_Dictionary* pAnnotDict = pAnnot->GetAnnotDict();
+ ByteString cbString;
+ if (pAnnotDict->KeyExist("FT"))
+ cbString = pAnnotDict->GetStringFor("FT");
+ if (cbString.Compare("Sig") == 0)
+ RaiseUnSupportError(FPDF_UNSP_ANNOT_SIG);
+ break;
+ }
+ default:
+ break;
}
}
diff --git a/fpdfsdk/cpdfsdk_helpers.h b/fpdfsdk/cpdfsdk_helpers.h
index 8f837f3..25a1e78 100644
--- a/fpdfsdk/cpdfsdk_helpers.h
+++ b/fpdfsdk/cpdfsdk_helpers.h
@@ -263,7 +263,7 @@
IPDFSDK_PauseAdapter* pause);
void ReportUnsupportedFeatures(CPDF_Document* pDoc);
-void CheckUnSupportAnnot(CPDF_Document* pDoc, const CPDF_Annot* pPDFAnnot);
+void CheckForUnsupportedAnnot(const CPDF_Annot* pPDFAnnot);
#ifndef _WIN32
void SetLastError(int err);
diff --git a/fpdfsdk/cpdfsdk_pageview.cpp b/fpdfsdk/cpdfsdk_pageview.cpp
index def4731..cd51fe4 100644
--- a/fpdfsdk/cpdfsdk_pageview.cpp
+++ b/fpdfsdk/cpdfsdk_pageview.cpp
@@ -529,7 +529,7 @@
const size_t nCount = m_pAnnotList->Count();
for (size_t i = 0; i < nCount; ++i) {
CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i);
- CheckUnSupportAnnot(GetPDFDocument(), pPDFAnnot);
+ CheckForUnsupportedAnnot(pPDFAnnot);
CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this);
if (!pAnnot)
continue;