Index: core/fpdfdoc/cpdf_annotlist.cpp |
diff --git a/core/fpdfdoc/cpdf_annotlist.cpp b/core/fpdfdoc/cpdf_annotlist.cpp |
index 9dc0e9587d1ca2f92b6a3372df4033aed18e3399..890c59dd596a58109eef339269f9de1c9bb14d40 100644 |
--- a/core/fpdfdoc/cpdf_annotlist.cpp |
+++ b/core/fpdfdoc/cpdf_annotlist.cpp |
@@ -16,6 +16,34 @@ |
#include "core/fpdfdoc/include/cpdf_occontext.h" |
#include "core/fxge/include/cfx_renderdevice.h" |
+namespace { |
+ |
+CPDF_Annot* CreatePopupAnnot(CPDF_Annot* pAnnot, CPDF_Document* pDocument) { |
dsinclair
2016/08/24 14:00:20
Can this return a std::unique_ptr<CPDF_Annot> to s
jaepark
2016/08/24 18:37:48
Done.
|
+ CPDF_Dictionary* pParentDict = pAnnot->GetAnnotDict(); |
+ if (!pParentDict) |
+ return nullptr; |
+ |
+ 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"); |
+ CFX_FloatRect popupRect(0, 0, 200, 200); |
dsinclair
2016/08/24 14:00:20
Where does 200 come from? Is it spec, or just a nu
jaepark
2016/08/24 18:37:48
This is just a number. This represents the rectang
|
+ popupRect.Translate((rect.left + rect.right) / 2, |
dsinclair
2016/08/24 14:00:20
Why left + right and not left + popupRect.width? i
jaepark
2016/08/24 18:37:48
I wanted to place the popup note in the middle of
|
+ rect.bottom - popupRect.Height()); |
+ |
+ pAnnotDict->SetAtRect("Rect", popupRect); |
+ pAnnotDict->SetAtInteger("F", 0); |
+ |
+ CPDF_Annot* pPopupAnnot = new CPDF_Annot(pAnnotDict, pDocument); |
+ pAnnot->SetPopupAnnot(pPopupAnnot); |
+ return pPopupAnnot; |
+} |
+ |
+} // namespace |
+ |
CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage) |
: m_pDocument(pPage->m_pDocument) { |
if (!pPage->m_pFormDict) |
@@ -42,8 +70,11 @@ 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))); |
+ |
+ CPDF_Annot* pAnnot = new CPDF_Annot(pDict, m_pDocument); |
+ m_AnnotList.push_back(WrapUnique(pAnnot)); |
+ m_AnnotList.push_back(WrapUnique(CreatePopupAnnot(pAnnot, m_pDocument))); |
+ |
if (bRegenerateAP && pDict->GetStringBy("Subtype") == "Widget" && |
CPDF_InterForm::IsUpdateAPEnabled()) { |
FPDF_GenerateAP(m_pDocument, pDict); |