Index: core/fpdfdoc/cpdf_annotlist.cpp |
diff --git a/core/fpdfdoc/cpdf_annotlist.cpp b/core/fpdfdoc/cpdf_annotlist.cpp |
index 153b25fac49db54d3793a4cfe0dba15ba93a35f4..30ed2e3ea7ddd1ecd58e5bc7e6b992ccfba31aed 100644 |
--- a/core/fpdfdoc/cpdf_annotlist.cpp |
+++ b/core/fpdfdoc/cpdf_annotlist.cpp |
@@ -16,6 +16,36 @@ |
#include "core/fpdfdoc/include/cpdf_occontext.h" |
#include "core/fxge/include/cfx_renderdevice.h" |
+namespace { |
+ |
+std::unique_ptr<CPDF_Annot> CreatePopupAnnot(CPDF_Annot* pAnnot, |
+ CPDF_Document* pDocument) { |
+ CPDF_Dictionary* pParentDict = pAnnot->GetAnnotDict(); |
+ if (!pParentDict) |
+ return std::unique_ptr<CPDF_Annot>(); |
+ |
+ CPDF_Dictionary* pAnnotDict = new CPDF_Dictionary; |
+ pAnnotDict->SetAtName("Type", "Annot"); |
+ pAnnotDict->SetAtName("Subtype", "Popup"); |
+ pAnnotDict->SetAtString("T", pParentDict->GetStringBy("T")); |
+ pAnnotDict->SetAtString("Contents", pParentDict->GetStringBy("Contents")); |
+ |
+ CFX_FloatRect rect = pParentDict->GetRectBy("Rect"); |
+ rect.Normalize(); |
+ CFX_FloatRect popupRect(0, 0, 200, 200); |
+ popupRect.Translate(rect.left, rect.bottom - popupRect.Height()); |
+ |
+ pAnnotDict->SetAtRect("Rect", popupRect); |
+ pAnnotDict->SetAtInteger("F", 0); |
+ |
+ std::unique_ptr<CPDF_Annot> pPopupAnnot( |
+ new CPDF_Annot(pAnnotDict, pDocument)); |
+ pAnnot->SetPopupAnnot(pPopupAnnot.get()); |
+ return pPopupAnnot; |
+} |
+ |
+} // namespace |
+ |
CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage) |
: m_pDocument(pPage->m_pDocument) { |
if (!pPage->m_pFormDict) |
@@ -42,13 +72,19 @@ CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage) |
pAnnots->RemoveAt(i + 1); |
pDict = pAnnots->GetDictAt(i); |
} |
+ |
m_AnnotList.push_back( |
std::unique_ptr<CPDF_Annot>(new CPDF_Annot(pDict, m_pDocument))); |
+ |
if (bRegenerateAP && pDict->GetStringBy("Subtype") == "Widget" && |
CPDF_InterForm::IsUpdateAPEnabled()) { |
FPDF_GenerateAP(m_pDocument, pDict); |
} |
} |
+ |
+ size_t nAnnotListCount = m_AnnotList.size(); |
Lei Zhang
2016/08/27 02:16:53
no need for variable.
jaepark
2016/08/29 21:19:24
Actually, the below for loop is pushing back to th
|
+ for (size_t i = 0; i < nAnnotListCount; ++i) |
+ m_AnnotList.push_back(CreatePopupAnnot(m_AnnotList[i].get(), m_pDocument)); |
} |
CPDF_AnnotList::~CPDF_AnnotList() {} |