From 90fffb31e2ec6cf66fe1b85b466cd2f12ee9c87f Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 16 Oct 2017 15:34:05 -0400 Subject: Simplify CPVT_GenerateAP interface This CL moves the annotation decision inside GenerateAnnotAP and hides the individual annotation AP generation methods. The form methods are hidden inside GenerateFormAP and a general GenerateEmptyAP has been added. Change-Id: I9e761cb10ceca70681df4e546631a7859f1bfc7c Reviewed-on: https://pdfium-review.googlesource.com/16130 Reviewed-by: Henrique Nakashima Commit-Queue: dsinclair --- core/fpdfdoc/cpdf_annot.cpp | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) (limited to 'core/fpdfdoc/cpdf_annot.cpp') diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp index 1ccb890c04..9f8ab7878f 100644 --- a/core/fpdfdoc/cpdf_annot.cpp +++ b/core/fpdfdoc/cpdf_annot.cpp @@ -87,32 +87,13 @@ void CPDF_Annot::Init() { void CPDF_Annot::GenerateAPIfNeeded() { if (!ShouldGenerateAPForAnnotation(m_pAnnotDict.Get())) return; - - CPDF_Dictionary* pDict = m_pAnnotDict.Get(); - bool result = false; - if (m_nSubtype == CPDF_Annot::Subtype::CIRCLE) - result = CPVT_GenerateAP::GenerateCircleAP(m_pDocument.Get(), pDict); - else if (m_nSubtype == CPDF_Annot::Subtype::HIGHLIGHT) - result = CPVT_GenerateAP::GenerateHighlightAP(m_pDocument.Get(), pDict); - else if (m_nSubtype == CPDF_Annot::Subtype::INK) - result = CPVT_GenerateAP::GenerateInkAP(m_pDocument.Get(), pDict); - else if (m_nSubtype == CPDF_Annot::Subtype::POPUP) - result = CPVT_GenerateAP::GeneratePopupAP(m_pDocument.Get(), pDict); - else if (m_nSubtype == CPDF_Annot::Subtype::SQUARE) - result = CPVT_GenerateAP::GenerateSquareAP(m_pDocument.Get(), pDict); - else if (m_nSubtype == CPDF_Annot::Subtype::SQUIGGLY) - result = CPVT_GenerateAP::GenerateSquigglyAP(m_pDocument.Get(), pDict); - else if (m_nSubtype == CPDF_Annot::Subtype::STRIKEOUT) - result = CPVT_GenerateAP::GenerateStrikeOutAP(m_pDocument.Get(), pDict); - else if (m_nSubtype == CPDF_Annot::Subtype::TEXT) - result = CPVT_GenerateAP::GenerateTextAP(m_pDocument.Get(), pDict); - else if (m_nSubtype == CPDF_Annot::Subtype::UNDERLINE) - result = CPVT_GenerateAP::GenerateUnderlineAP(m_pDocument.Get(), pDict); - - if (result) { - m_pAnnotDict->SetNewFor(kPDFiumKey_HasGeneratedAP, result); - m_bHasGeneratedAP = result; + if (!CPVT_GenerateAP::GenerateAnnotAP(m_nSubtype, m_pDocument.Get(), + m_pAnnotDict.Get())) { + return; } + + m_pAnnotDict->SetNewFor(kPDFiumKey_HasGeneratedAP, true); + m_bHasGeneratedAP = true; } bool CPDF_Annot::ShouldDrawAnnotation() { -- cgit v1.2.3