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

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: Removing useless comments. 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 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 CFX_FloatRect popupRect;
31 pPopupAnnot->GetRect(popupRect);
32 rects.push_back(popupRect);
33 }
34 pPageView->UpdateRects(rects);
35 }
36
37 } // namespace
38
39 CPDFSDK_BAAnnotHandler::CPDFSDK_BAAnnotHandler() {}
40
41 CPDFSDK_BAAnnotHandler::~CPDFSDK_BAAnnotHandler() {}
42
43 CFX_ByteString CPDFSDK_BAAnnotHandler::GetType() {
44 return CFX_ByteString("");
45 }
46
47 CFX_ByteString CPDFSDK_BAAnnotHandler::GetName() {
48 return CFX_ByteString("");
49 }
50
51 FX_BOOL CPDFSDK_BAAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) {
52 return FALSE;
53 }
54
55 CPDFSDK_Annot* CPDFSDK_BAAnnotHandler::NewAnnot(CPDF_Annot* pAnnot,
56 CPDFSDK_PageView* pPage) {
57 return new CPDFSDK_BAAnnot(pAnnot, pPage);
58 }
59
60 #ifdef PDF_ENABLE_XFA
61 CPDFSDK_Annot* CPDFSDK_BAAnnotHandler::NewAnnot(CXFA_FFWidget* hWidget,
62 CPDFSDK_PageView* pPage) {
63 return nullptr;
64 }
65 #endif // PDF_ENABLE_XFA
66
67 void CPDFSDK_BAAnnotHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) {
68 ASSERT(pAnnot);
dsinclair 2016/08/24 14:00:21 I believe this assert isn't needed as you can call
jaepark 2016/08/24 18:37:49 Done.
69 delete pAnnot;
70 }
71
72 void CPDFSDK_BAAnnotHandler::DeleteAnnot(CPDFSDK_Annot* pAnnot) {}
73
74 void CPDFSDK_BAAnnotHandler::OnDraw(CPDFSDK_PageView* pPageView,
75 CPDFSDK_Annot* pAnnot,
76 CFX_RenderDevice* pDevice,
77 CFX_Matrix* pUser2Device,
78 uint32_t dwFlags) {
79 #ifdef PDF_ENABLE_XFA
80 if (pAnnot->IsXFAField())
81 return;
82 #endif // PDF_ENABLE_XFA
83 static_cast<CPDFSDK_BAAnnot*>(pAnnot)->DrawAppearance(
84 pDevice, pUser2Device, CPDF_Annot::Normal, nullptr);
85 }
86
87 void CPDFSDK_BAAnnotHandler::OnDrawSleep(CPDFSDK_PageView* pPageView,
88 CPDFSDK_Annot* pAnnot,
89 CFX_RenderDevice* pDevice,
90 CFX_Matrix* pUser2Device,
91 const CFX_FloatRect& rcWindow,
92 uint32_t dwFlags) {}
93
94 void CPDFSDK_BAAnnotHandler::OnDelete(CPDFSDK_Annot* pAnnot) {}
95
96 void CPDFSDK_BAAnnotHandler::OnRelease(CPDFSDK_Annot* pAnnot) {}
97
98 void CPDFSDK_BAAnnotHandler::OnMouseEnter(CPDFSDK_PageView* pPageView,
99 CPDFSDK_Annot* pAnnot,
100 uint32_t nFlag) {
101 CPDFSDK_BAAnnot* pBAAnnot = static_cast<CPDFSDK_BAAnnot*>(pAnnot);
102 pBAAnnot->SetOpenState(true);
103 UpdateAnnotRects(pPageView, pBAAnnot);
104 }
105
106 void CPDFSDK_BAAnnotHandler::OnMouseExit(CPDFSDK_PageView* pPageView,
107 CPDFSDK_Annot* pAnnot,
108 uint32_t nFlag) {
109 CPDFSDK_BAAnnot* pBAAnnot = static_cast<CPDFSDK_BAAnnot*>(pAnnot);
110 pBAAnnot->SetOpenState(false);
111 UpdateAnnotRects(pPageView, pBAAnnot);
112 }
113
114 FX_BOOL CPDFSDK_BAAnnotHandler::OnLButtonDown(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::OnLButtonUp(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::OnLButtonDblClk(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::OnMouseMove(CPDFSDK_PageView* pPageView,
136 CPDFSDK_Annot* pAnnot,
137 uint32_t nFlags,
138 const CFX_FloatPoint& point) {
139 return FALSE;
140 }
141
142 FX_BOOL CPDFSDK_BAAnnotHandler::OnMouseWheel(CPDFSDK_PageView* pPageView,
143 CPDFSDK_Annot* pAnnot,
144 uint32_t nFlags,
145 short zDelta,
146 const CFX_FloatPoint& point) {
147 return FALSE;
148 }
149
150 FX_BOOL CPDFSDK_BAAnnotHandler::OnRButtonDown(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::OnRButtonUp(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::OnRButtonDblClk(CPDFSDK_PageView* pPageView,
165 CPDFSDK_Annot* pAnnot,
166 uint32_t nFlags,
167 const CFX_FloatPoint& point) {
168 return FALSE;
169 }
170
171 FX_BOOL CPDFSDK_BAAnnotHandler::OnChar(CPDFSDK_Annot* pAnnot,
172 uint32_t nChar,
173 uint32_t nFlags) {
174 return FALSE;
175 }
176
177 FX_BOOL CPDFSDK_BAAnnotHandler::OnKeyDown(CPDFSDK_Annot* pAnnot,
178 int nKeyCode,
179 int nFlag) {
180 return FALSE;
181 }
182
183 FX_BOOL CPDFSDK_BAAnnotHandler::OnKeyUp(CPDFSDK_Annot* pAnnot,
184 int nKeyCode,
185 int nFlag) {
186 return FALSE;
187 }
188
189 void CPDFSDK_BAAnnotHandler::OnDeSelected(CPDFSDK_Annot* pAnnot) {}
190
191 void CPDFSDK_BAAnnotHandler::OnSelected(CPDFSDK_Annot* pAnnot) {}
192
193 void CPDFSDK_BAAnnotHandler::OnCreate(CPDFSDK_Annot* pAnnot) {}
194
195 void CPDFSDK_BAAnnotHandler::OnLoad(CPDFSDK_Annot* pAnnot) {}
196
197 FX_BOOL CPDFSDK_BAAnnotHandler::OnSetFocus(CPDFSDK_Annot* pAnnot,
198 uint32_t nFlag) {
199 return FALSE;
200 }
201
202 FX_BOOL CPDFSDK_BAAnnotHandler::OnKillFocus(CPDFSDK_Annot* pAnnot,
203 uint32_t nFlag) {
204 return FALSE;
205 }
206
207 #ifdef PDF_ENABLE_XFA
208 FX_BOOL CPDFSDK_BAAnnotHandler::OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot,
209 CPDFSDK_Annot* pNewAnnot) {
210 return TRUE;
211 }
212 #endif // PDF_ENABLE_XFA
213
214 CFX_FloatRect CPDFSDK_BAAnnotHandler::GetViewBBox(CPDFSDK_PageView* pPageView,
215 CPDFSDK_Annot* pAnnot) {
216 return pAnnot->GetRect();
217 }
218
219 FX_BOOL CPDFSDK_BAAnnotHandler::HitTest(CPDFSDK_PageView* pPageView,
220 CPDFSDK_Annot* pAnnot,
221 const CFX_FloatPoint& point) {
222 ASSERT(pPageView);
223 ASSERT(pAnnot);
224
225 CFX_FloatRect rect = GetViewBBox(pPageView, pAnnot);
226 return rect.Contains(point.x, point.y);
227 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698