summaryrefslogtreecommitdiff
path: root/core/fpdfdoc/cpdf_annotlist.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfdoc/cpdf_annotlist.cpp')
-rw-r--r--core/fpdfdoc/cpdf_annotlist.cpp40
1 files changed, 39 insertions, 1 deletions
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<CPDF_Annot> 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<CPDF_String>("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<CPDF_Annot>(pDict, m_pDocument));
if (bRegenerateAP && subtype == "Widget" &&
CPDF_InterForm::IsUpdateAPEnabled() && !pDict->GetDictFor("AP")) {
- FPDF_GenerateAP(m_pDocument, pDict);
+ GenerateAP(m_pDocument, pDict);
}
}