From 956553e715787cfc4dd8423d5e9a04a0131878c3 Mon Sep 17 00:00:00 2001 From: jaepark Date: Wed, 31 Aug 2016 06:49:27 -0700 Subject: Use enum class for subtypes of CPDF_Annot. Comparing CFX_ByteString for annotation subtypes is inefficient and error-prone. This CL uses enum class to compare annotation subtypes. Also, remove unused IPDFSDK_AnnotHandler::GetType() and FSDK_XFAWIDGET_TYPENAME. Review-Url: https://codereview.chromium.org/2295953002 --- fpdfsdk/fpdf_ext.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'fpdfsdk/fpdf_ext.cpp') diff --git a/fpdfsdk/fpdf_ext.cpp b/fpdfsdk/fpdf_ext.cpp index d03b4383ca..46bc7e57a4 100644 --- a/fpdfsdk/fpdf_ext.cpp +++ b/fpdfsdk/fpdf_ext.cpp @@ -46,33 +46,31 @@ FSDK_SetUnSpObjProcessHandler(UNSUPPORT_INFO* unsp_info) { } void CheckUnSupportAnnot(CPDF_Document* pDoc, const CPDF_Annot* pPDFAnnot) { - CFX_ByteString cbSubType = pPDFAnnot->GetSubtype(); - if (cbSubType.Compare("3D") == 0) { + CPDF_Annot::Subtype nAnnotSubtype = pPDFAnnot->GetSubtype(); + if (nAnnotSubtype == CPDF_Annot::Subtype::THREED) { FPDF_UnSupportError(FPDF_UNSP_ANNOT_3DANNOT); - } else if (cbSubType.Compare("Screen") == 0) { + } else if (nAnnotSubtype == CPDF_Annot::Subtype::SCREEN) { const CPDF_Dictionary* pAnnotDict = pPDFAnnot->GetAnnotDict(); CFX_ByteString cbString; if (pAnnotDict->KeyExist("IT")) cbString = pAnnotDict->GetStringBy("IT"); if (cbString.Compare("Img") != 0) FPDF_UnSupportError(FPDF_UNSP_ANNOT_SCREEN_MEDIA); - } else if (cbSubType.Compare("Movie") == 0) { + } else if (nAnnotSubtype == CPDF_Annot::Subtype::MOVIE) { FPDF_UnSupportError(FPDF_UNSP_ANNOT_MOVIE); - } else if (cbSubType.Compare("Sound") == 0) { + } else if (nAnnotSubtype == CPDF_Annot::Subtype::SOUND) { FPDF_UnSupportError(FPDF_UNSP_ANNOT_SOUND); - } else if (cbSubType.Compare("RichMedia") == 0) { + } else if (nAnnotSubtype == CPDF_Annot::Subtype::RICHMEDIA) { FPDF_UnSupportError(FPDF_UNSP_ANNOT_SCREEN_RICHMEDIA); - } else if (cbSubType.Compare("FileAttachment") == 0) { + } else if (nAnnotSubtype == CPDF_Annot::Subtype::FILEATTACHMENT) { FPDF_UnSupportError(FPDF_UNSP_ANNOT_ATTACHMENT); - } else if (cbSubType.Compare("Widget") == 0) { + } else if (nAnnotSubtype == CPDF_Annot::Subtype::WIDGET) { const CPDF_Dictionary* pAnnotDict = pPDFAnnot->GetAnnotDict(); CFX_ByteString cbString; - if (pAnnotDict->KeyExist("FT")) { + if (pAnnotDict->KeyExist("FT")) cbString = pAnnotDict->GetStringBy("FT"); - } - if (cbString.Compare("Sig") == 0) { + if (cbString.Compare("Sig") == 0) FPDF_UnSupportError(FPDF_UNSP_ANNOT_SIG); - } } } -- cgit v1.2.3