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 --- core/fpdfdoc/include/cpdf_annot.h | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'core/fpdfdoc/include') diff --git a/core/fpdfdoc/include/cpdf_annot.h b/core/fpdfdoc/include/cpdf_annot.h index 416c540cc3..82b3d3ca31 100644 --- a/core/fpdfdoc/include/cpdf_annot.h +++ b/core/fpdfdoc/include/cpdf_annot.h @@ -36,13 +36,46 @@ class CPDF_Stream; class CPDF_Annot { public: enum AppearanceMode { Normal, Rollover, Down }; + enum class Subtype { + UNKNOWN = 0, + TEXT, + LINK, + FREETEXT, + LINE, + SQUARE, + CIRCLE, + POLYGON, + POLYLINE, + HIGHLIGHT, + UNDERLINE, + SQUIGGLY, + STRIKEOUT, + STAMP, + CARET, + INK, + POPUP, + FILEATTACHMENT, + SOUND, + MOVIE, + WIDGET, + SCREEN, + PRINTERMARK, + TRAPNET, + WATERMARK, + THREED, + RICHMEDIA, + XFAWIDGET + }; static bool IsAnnotationHidden(CPDF_Dictionary* pAnnotDict); + static CPDF_Annot::Subtype StringToAnnotSubtype( + const CFX_ByteString& sSubtype); + static CFX_ByteString AnnotSubtypeToString(CPDF_Annot::Subtype nSubtype); CPDF_Annot(CPDF_Dictionary* pDict, CPDF_Document* pDocument); ~CPDF_Annot(); - CFX_ByteString GetSubtype() const; + CPDF_Annot::Subtype GetSubtype() const; uint32_t GetFlags() const; CFX_FloatRect GetRect() const; const CPDF_Dictionary* GetAnnotDict() const { return m_pAnnotDict; } @@ -70,7 +103,7 @@ class CPDF_Annot { CPDF_Dictionary* const m_pAnnotDict; CPDF_Document* const m_pDocument; - const CFX_ByteString m_sSubtype; + CPDF_Annot::Subtype m_nSubtype; std::map> m_APMap; // |m_bOpenState| is only set for popup annotations. bool m_bOpenState; -- cgit v1.2.3