Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2041)

Unified Diff: core/fpdfdoc/cpdf_annotlist.cpp

Issue 2273893002: Display content of the annotation when mouse hover. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Display content of the annotation when mouse hover. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/fpdfdoc/cpdf_annot.cpp ('k') | core/fpdfdoc/cpvt_generateap.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfdoc/cpdf_annotlist.cpp
diff --git a/core/fpdfdoc/cpdf_annotlist.cpp b/core/fpdfdoc/cpdf_annotlist.cpp
index e6c93c1d1ebf2602454d8d984695cf8cc49e7db5..4c569892c2056c9b235d822756657811db36a800 100644
--- a/core/fpdfdoc/cpdf_annotlist.cpp
+++ b/core/fpdfdoc/cpdf_annotlist.cpp
@@ -16,6 +16,40 @@
#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>();
+
+ CFX_ByteString sContents = pParentDict->GetStringBy("Contents");
+ if (sContents.IsEmpty())
+ 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", sContents);
+
+ 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,6 +76,12 @@ CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage)
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)));
if (bRegenerateAP && pDict->GetStringBy("Subtype") == "Widget" &&
@@ -49,6 +89,14 @@ CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage)
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() {}
« no previous file with comments | « core/fpdfdoc/cpdf_annot.cpp ('k') | core/fpdfdoc/cpvt_generateap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698