void CPDF_FormField::UpdateAP(CPDF_FormControl* pControl) { if (m_Type == PushButton) { return; } if (m_Type == RadioButton || m_Type == CheckBox) { return; } if (!m_pForm->m_bGenerateAP) { return; } for (int i = 0; i < CountControls(); i++) { CPDF_FormControl* pControl = GetControl(i); FPDF_GenerateAP(m_pForm->m_pDocument, pControl->m_pWidgetDict); } }
CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage) : m_pDocument(pPage->m_pDocument) { if (!pPage->m_pFormDict) return; CPDF_Array* pAnnots = pPage->m_pFormDict->GetArrayBy("Annots"); if (!pAnnots) return; CPDF_Dictionary* pRoot = m_pDocument->GetRoot(); CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm"); FX_BOOL bRegenerateAP = pAcroForm && pAcroForm->GetBooleanBy("NeedAppearances"); for (size_t i = 0; i < pAnnots->GetCount(); ++i) { CPDF_Dictionary* pDict = ToDictionary(pAnnots->GetDirectObjectAt(i)); if (!pDict) continue; uint32_t dwObjNum = pDict->GetObjNum(); if (dwObjNum == 0) { dwObjNum = m_pDocument->AddIndirectObject(pDict); CPDF_Reference* pAction = new CPDF_Reference(m_pDocument, dwObjNum); pAnnots->InsertAt(i, pAction); pAnnots->RemoveAt(i + 1); pDict = pAnnots->GetDictAt(i); } // Skip creating Popup annotation in the PDF document since PDFium provides // its own Popup annotations. if (pDict->GetStringBy("Subtype") == "Popup") continue; m_AnnotList.push_back( std::unique_ptr<CPDF_Annot>(new CPDF_Annot(pDict, m_pDocument, false))); if (bRegenerateAP && pDict->GetStringBy("Subtype") == "Widget" && CPDF_InterForm::IsUpdateAPEnabled()) { FPDF_GenerateAP(m_pDocument, pDict); } } size_t nAnnotListSize = m_AnnotList.size(); for (size_t i = 0; i < nAnnotListSize; ++i) { std::unique_ptr<CPDF_Annot> pPopupAnnot( CreatePopupAnnot(m_AnnotList[i].get(), m_pDocument)); if (pPopupAnnot) m_AnnotList.push_back(std::move(pPopupAnnot)); } }
CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage) { ASSERT(pPage != NULL); m_pPageDict = pPage->m_pFormDict; if (m_pPageDict == NULL) { return; } m_pDocument = pPage->m_pDocument; CPDF_Array* pAnnots = m_pPageDict->GetArray("Annots"); if (pAnnots == NULL) { return; } CPDF_Dictionary* pRoot = m_pDocument->GetRoot(); CPDF_Dictionary* pAcroForm = pRoot->GetDict("AcroForm"); FX_BOOL bRegenerateAP = pAcroForm && pAcroForm->GetBoolean("NeedAppearances"); for (FX_DWORD i = 0; i < pAnnots->GetCount(); i ++) { CPDF_Dictionary* pDict = (CPDF_Dictionary*)pAnnots->GetElementValue(i); if (pDict == NULL || pDict->GetType() != PDFOBJ_DICTIONARY) { continue; } FX_DWORD dwObjNum = pDict->GetObjNum(); if (dwObjNum == 0) { dwObjNum = m_pDocument->AddIndirectObject(pDict); CPDF_Reference* pAction = CPDF_Reference::Create(m_pDocument, dwObjNum); if (pAction == NULL) { break; } pAnnots->InsertAt(i, pAction); pAnnots->RemoveAt(i + 1); pDict = pAnnots->GetDict(i); } CPDF_Annot* pAnnot = FX_NEW CPDF_Annot(pDict); if (pAnnot == NULL) { break; } pAnnot->m_pList = this; m_AnnotList.Add(pAnnot); if (bRegenerateAP && pDict->GetConstString(FX_BSTRC("Subtype")) == FX_BSTRC("Widget")) if (CPDF_InterForm::UpdatingAPEnabled()) { FPDF_GenerateAP(m_pDocument, pDict); } } }