summaryrefslogtreecommitdiff
path: root/core/fpdfdoc/cpdf_annotlist.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-10-16 13:20:32 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-10-16 19:35:56 +0000
commit9df8033a5c78719517a0351c14f6af4349bb160d (patch)
tree291f6c72600efdd6f6e12618ebaa7562b7e656c4 /core/fpdfdoc/cpdf_annotlist.cpp
parent72b82a8e863da1b369e9f37a9db48103024faf1b (diff)
downloadpdfium-9df8033a5c78719517a0351c14f6af4349bb160d.tar.xz
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 <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
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);
}
}