From 9df8033a5c78719517a0351c14f6af4349bb160d Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 16 Oct 2017 13:20:32 -0400 Subject: Cleanup CPVT_GenerateAP This CL moves FPDF_GenerateAP into the anonymous namespace of CPDF_AnnotList. Several methods are moved into the anonymous namespace of CPVT_GenerateAP which are only used internally. Change-Id: I6e8fef54ba3757cc9873ed5ac370dec7eaca5d8b Reviewed-on: https://pdfium-review.googlesource.com/16070 Reviewed-by: Henrique Nakashima Commit-Queue: dsinclair --- core/fpdfdoc/cpdf_annotlist.cpp | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'core/fpdfdoc/cpdf_annotlist.cpp') diff --git a/core/fpdfdoc/cpdf_annotlist.cpp b/core/fpdfdoc/cpdf_annotlist.cpp index c0f7ae2f23..c7da676b98 100644 --- a/core/fpdfdoc/cpdf_annotlist.cpp +++ b/core/fpdfdoc/cpdf_annotlist.cpp @@ -75,6 +75,44 @@ std::unique_ptr CreatePopupAnnot(CPDF_Annot* pAnnot, return pPopupAnnot; } +void GenerateAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict) { + if (!pAnnotDict || pAnnotDict->GetStringFor("Subtype") != "Widget") + return; + + CPDF_Object* pFieldTypeObj = FPDF_GetFieldAttr(pAnnotDict, "FT"); + if (!pFieldTypeObj) + return; + + ByteString field_type = pFieldTypeObj->GetString(); + if (field_type == "Tx") { + CPVT_GenerateAP::GenerateTextFieldAP(pDoc, pAnnotDict); + return; + } + + CPDF_Object* pFieldFlagsObj = FPDF_GetFieldAttr(pAnnotDict, "Ff"); + uint32_t flags = pFieldFlagsObj ? pFieldFlagsObj->GetInteger() : 0; + if (field_type == "Ch") { + (flags & (1 << 17)) ? CPVT_GenerateAP::GenerateComboBoxAP(pDoc, pAnnotDict) + : CPVT_GenerateAP::GenerateListBoxAP(pDoc, pAnnotDict); + return; + } + + if (field_type != "Btn") + return; + if (flags & (1 << 16)) + return; + if (pAnnotDict->KeyExist("AS")) + return; + + CPDF_Dictionary* pParentDict = pAnnotDict->GetDictFor("Parent"); + if (!pParentDict || !pParentDict->KeyExist("AS")) + return; + + pAnnotDict->SetNewFor("AS", pParentDict->GetStringFor("AS"), + false); + return; +} + } // namespace CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage) @@ -103,7 +141,7 @@ CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage) m_AnnotList.push_back(pdfium::MakeUnique(pDict, m_pDocument)); if (bRegenerateAP && subtype == "Widget" && CPDF_InterForm::IsUpdateAPEnabled() && !pDict->GetDictFor("AP")) { - FPDF_GenerateAP(m_pDocument, pDict); + GenerateAP(m_pDocument, pDict); } } -- cgit v1.2.3