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)); } }