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

Side by Side Diff: fpdfsdk/cpdfsdk_baannothandler.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, 3 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #include "fpdfsdk/include/cpdfsdk_baannothandler.h"
8
9 #include <memory>
10 #include <vector>
11
12 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h"
13 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
14 #include "core/fpdfdoc/include/cpdf_interform.h"
15 #include "fpdfsdk/formfiller/cffl_formfiller.h"
16 #include "fpdfsdk/include/cpdfsdk_annot.h"
17 #include "fpdfsdk/include/cpdfsdk_baannot.h"
18 #include "fpdfsdk/include/fsdk_mgr.h"
19
20 #ifdef PDF_ENABLE_XFA
21 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h"
22 #endif // PDF_ENABLE_XFA
23
24 namespace {
25
26 void UpdateAnnotRects(CPDFSDK_PageView* pPageView, CPDFSDK_BAAnnot* pBAAnnot) {
27 std::vector<CFX_FloatRect> rects;
28 rects.push_back(pBAAnnot->GetRect());
29 if (CPDF_Annot* pPopupAnnot = pBAAnnot->GetPDFPopupAnnot())
30 rects.push_back(pPopupAnnot->GetRect());
31
32 pPageView->UpdateRects(rects);
33 }
34
35 } // namespace
36
37 CPDFSDK_BAAnnotHandler::CPDFSDK_BAAnnotHandler() {}
38
39 CPDFSDK_BAAnnotHandler::~CPDFSDK_BAAnnotHandler() {}
40
41 CFX_ByteString CPDFSDK_BAAnnotHandler::GetType() {
42 return CFX_ByteString("");
43 }
44
45 FX_BOOL CPDFSDK_BAAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) {
46 return FALSE;
47 }
48
49 CPDFSDK_Annot* CPDFSDK_BAAnnotHandler::NewAnnot(CPDF_Annot* pAnnot,
50 CPDFSDK_PageView* pPage) {
51 return new CPDFSDK_BAAnnot(pAnnot, pPage);
52 }
53
54 #ifdef PDF_ENABLE_XFA
55 CPDFSDK_Annot* CPDFSDK_BAAnnotHandler::NewAnnot(CXFA_FFWidget* hWidget,
56 CPDFSDK_PageView* pPage) {
57 return nullptr;
58 }
59 #endif // PDF_ENABLE_XFA
60
61 void CPDFSDK_BAAnnotHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) {
62 delete pAnnot;
63 }
64
65 void CPDFSDK_BAAnnotHandler::DeleteAnnot(CPDFSDK_Annot* pAnnot) {}
66
67 void CPDFSDK_BAAnnotHandler::OnDraw(CPDFSDK_PageView* pPageView,
68 CPDFSDK_Annot* pAnnot,
69 CFX_RenderDevice* pDevice,
70 CFX_Matrix* pUser2Device,
71 uint32_t dwFlags) {
72 #ifdef PDF_ENABLE_XFA
73 if (pAnnot->IsXFAField())
74 return;
75 #endif // PDF_ENABLE_XFA
76 static_cast<CPDFSDK_BAAnnot*>(pAnnot)->DrawAppearance(
77 pDevice, pUser2Device, CPDF_Annot::Normal, nullptr);
78 }
79
80 void CPDFSDK_BAAnnotHandler::OnDrawSleep(CPDFSDK_PageView* pPageView,
81 CPDFSDK_Annot* pAnnot,
82 CFX_RenderDevice* pDevice,
83 CFX_Matrix* pUser2Device,
84 const CFX_FloatRect& rcWindow,
85 uint32_t dwFlags) {}
86
87 void CPDFSDK_BAAnnotHandler::OnDelete(CPDFSDK_Annot* pAnnot) {}
88
89 void CPDFSDK_BAAnnotHandler::OnRelease(CPDFSDK_Annot* pAnnot) {}
90
91 void CPDFSDK_BAAnnotHandler::OnMouseEnter(CPDFSDK_PageView* pPageView,
92 CPDFSDK_Annot* pAnnot,
93 uint32_t nFlag) {
94 CPDFSDK_BAAnnot* pBAAnnot = static_cast<CPDFSDK_BAAnnot*>(pAnnot);
95 pBAAnnot->SetOpenState(true);
96 UpdateAnnotRects(pPageView, pBAAnnot);
97 }
98
99 void CPDFSDK_BAAnnotHandler::OnMouseExit(CPDFSDK_PageView* pPageView,
100 CPDFSDK_Annot* pAnnot,
101 uint32_t nFlag) {
102 CPDFSDK_BAAnnot* pBAAnnot = static_cast<CPDFSDK_BAAnnot*>(pAnnot);
103 pBAAnnot->SetOpenState(false);
104 UpdateAnnotRects(pPageView, pBAAnnot);
105 }
106
107 FX_BOOL CPDFSDK_BAAnnotHandler::OnLButtonDown(CPDFSDK_PageView* pPageView,
108 CPDFSDK_Annot* pAnnot,
109 uint32_t nFlags,
110 const CFX_FloatPoint& point) {
111 return FALSE;
112 }
113
114 FX_BOOL CPDFSDK_BAAnnotHandler::OnLButtonUp(CPDFSDK_PageView* pPageView,
115 CPDFSDK_Annot* pAnnot,
116 uint32_t nFlags,
117 const CFX_FloatPoint& point) {
118 return FALSE;
119 }
120
121 FX_BOOL CPDFSDK_BAAnnotHandler::OnLButtonDblClk(CPDFSDK_PageView* pPageView,
122 CPDFSDK_Annot* pAnnot,
123 uint32_t nFlags,
124 const CFX_FloatPoint& point) {
125 return FALSE;
126 }
127
128 FX_BOOL CPDFSDK_BAAnnotHandler::OnMouseMove(CPDFSDK_PageView* pPageView,
129 CPDFSDK_Annot* pAnnot,
130 uint32_t nFlags,
131 const CFX_FloatPoint& point) {
132 return FALSE;
133 }
134
135 FX_BOOL CPDFSDK_BAAnnotHandler::OnMouseWheel(CPDFSDK_PageView* pPageView,
136 CPDFSDK_Annot* pAnnot,
137 uint32_t nFlags,
138 short zDelta,
139 const CFX_FloatPoint& point) {
140 return FALSE;
141 }
142
143 FX_BOOL CPDFSDK_BAAnnotHandler::OnRButtonDown(CPDFSDK_PageView* pPageView,
144 CPDFSDK_Annot* pAnnot,
145 uint32_t nFlags,
146 const CFX_FloatPoint& point) {
147 return FALSE;
148 }
149
150 FX_BOOL CPDFSDK_BAAnnotHandler::OnRButtonUp(CPDFSDK_PageView* pPageView,
151 CPDFSDK_Annot* pAnnot,
152 uint32_t nFlags,
153 const CFX_FloatPoint& point) {
154 return FALSE;
155 }
156
157 FX_BOOL CPDFSDK_BAAnnotHandler::OnRButtonDblClk(CPDFSDK_PageView* pPageView,
158 CPDFSDK_Annot* pAnnot,
159 uint32_t nFlags,
160 const CFX_FloatPoint& point) {
161 return FALSE;
162 }
163
164 FX_BOOL CPDFSDK_BAAnnotHandler::OnChar(CPDFSDK_Annot* pAnnot,
165 uint32_t nChar,
166 uint32_t nFlags) {
167 return FALSE;
168 }
169
170 FX_BOOL CPDFSDK_BAAnnotHandler::OnKeyDown(CPDFSDK_Annot* pAnnot,
171 int nKeyCode,
172 int nFlag) {
173 return FALSE;
174 }
175
176 FX_BOOL CPDFSDK_BAAnnotHandler::OnKeyUp(CPDFSDK_Annot* pAnnot,
177 int nKeyCode,
178 int nFlag) {
179 return FALSE;
180 }
181
182 void CPDFSDK_BAAnnotHandler::OnDeSelected(CPDFSDK_Annot* pAnnot) {}
183
184 void CPDFSDK_BAAnnotHandler::OnSelected(CPDFSDK_Annot* pAnnot) {}
185
186 void CPDFSDK_BAAnnotHandler::OnCreate(CPDFSDK_Annot* pAnnot) {}
187
188 void CPDFSDK_BAAnnotHandler::OnLoad(CPDFSDK_Annot* pAnnot) {}
189
190 FX_BOOL CPDFSDK_BAAnnotHandler::OnSetFocus(CPDFSDK_Annot* pAnnot,
191 uint32_t nFlag) {
192 return FALSE;
193 }
194
195 FX_BOOL CPDFSDK_BAAnnotHandler::OnKillFocus(CPDFSDK_Annot* pAnnot,
196 uint32_t nFlag) {
197 return FALSE;
198 }
199
200 #ifdef PDF_ENABLE_XFA
201 FX_BOOL CPDFSDK_BAAnnotHandler::OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot,
202 CPDFSDK_Annot* pNewAnnot) {
203 return TRUE;
204 }
205 #endif // PDF_ENABLE_XFA
206
207 CFX_FloatRect CPDFSDK_BAAnnotHandler::GetViewBBox(CPDFSDK_PageView* pPageView,
208 CPDFSDK_Annot* pAnnot) {
209 return pAnnot->GetRect();
210 }
211
212 FX_BOOL CPDFSDK_BAAnnotHandler::HitTest(CPDFSDK_PageView* pPageView,
213 CPDFSDK_Annot* pAnnot,
214 const CFX_FloatPoint& point) {
215 ASSERT(pPageView);
216 ASSERT(pAnnot);
217
218 CFX_FloatRect rect = GetViewBBox(pPageView, pAnnot);
219 return rect.Contains(point.x, point.y);
220 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698