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

Side by Side Diff: fpdfsdk/cpdfsdk_pageview.cpp

Issue 2400673002: Convert CPDFSDK_PageView to have a CPDFSDK_FormFillEnvironment (Closed)
Patch Set: Rebase to master Created 4 years, 2 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
« no previous file with comments | « fpdfsdk/cpdfsdk_pageview.h ('k') | fpdfsdk/cpdfsdk_widget.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "fpdfsdk/cpdfsdk_pageview.h" 7 #include "fpdfsdk/cpdfsdk_pageview.h"
8 8
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
(...skipping 11 matching lines...) Expand all
22 22
23 #ifdef PDF_ENABLE_XFA 23 #ifdef PDF_ENABLE_XFA
24 #include "fpdfsdk/fpdfxfa/cpdfxfa_page.h" 24 #include "fpdfsdk/fpdfxfa/cpdfxfa_page.h"
25 #include "xfa/fxfa/xfa_ffdocview.h" 25 #include "xfa/fxfa/xfa_ffdocview.h"
26 #include "xfa/fxfa/xfa_ffpageview.h" 26 #include "xfa/fxfa/xfa_ffpageview.h"
27 #include "xfa/fxfa/xfa_ffwidgethandler.h" 27 #include "xfa/fxfa/xfa_ffwidgethandler.h"
28 #include "xfa/fxfa/xfa_rendercontext.h" 28 #include "xfa/fxfa/xfa_rendercontext.h"
29 #include "xfa/fxgraphics/cfx_graphics.h" 29 #include "xfa/fxgraphics/cfx_graphics.h"
30 #endif // PDF_ENABLE_XFA 30 #endif // PDF_ENABLE_XFA
31 31
32 CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc, 32 CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_FormFillEnvironment* pFormFillEnv,
33 UnderlyingPageType* page) 33 UnderlyingPageType* page)
34 : m_page(page), 34 : m_page(page),
35 m_pSDKDoc(pSDKDoc), 35 m_pFormFillEnv(pFormFillEnv),
36 #ifndef PDF_ENABLE_XFA 36 #ifndef PDF_ENABLE_XFA
37 m_bOwnsPage(false), 37 m_bOwnsPage(false),
38 #endif // PDF_ENABLE_XFA 38 #endif // PDF_ENABLE_XFA
39 m_bEnterWidget(FALSE), 39 m_bEnterWidget(FALSE),
40 m_bExitWidget(FALSE), 40 m_bExitWidget(FALSE),
41 m_bOnWidget(FALSE), 41 m_bOnWidget(FALSE),
42 m_bValid(FALSE), 42 m_bValid(FALSE),
43 m_bLocked(FALSE), 43 m_bLocked(FALSE),
44 m_bBeingDestroyed(false) { 44 m_bBeingDestroyed(false) {
45 CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm(); 45 CPDFSDK_InterForm* pInterForm =
46 pFormFillEnv->GetSDKDocument()->GetInterForm();
46 if (pInterForm) { 47 if (pInterForm) {
47 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); 48 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm();
48 #ifdef PDF_ENABLE_XFA 49 #ifdef PDF_ENABLE_XFA
49 if (page->GetPDFPage()) 50 if (page->GetPDFPage())
50 pPDFInterForm->FixPageFields(page->GetPDFPage()); 51 pPDFInterForm->FixPageFields(page->GetPDFPage());
51 #else // PDF_ENABLE_XFA 52 #else // PDF_ENABLE_XFA
52 pPDFInterForm->FixPageFields(page); 53 pPDFInterForm->FixPageFields(page);
53 #endif // PDF_ENABLE_XFA 54 #endif // PDF_ENABLE_XFA
54 } 55 }
55 #ifndef PDF_ENABLE_XFA 56 #ifndef PDF_ENABLE_XFA
56 m_page->SetView(this); 57 m_page->SetView(this);
57 #endif // PDF_ENABLE_XFA 58 #endif // PDF_ENABLE_XFA
58 } 59 }
59 60
60 CPDFSDK_PageView::~CPDFSDK_PageView() { 61 CPDFSDK_PageView::~CPDFSDK_PageView() {
61 #ifndef PDF_ENABLE_XFA 62 #ifndef PDF_ENABLE_XFA
62 // The call to |ReleaseAnnot| can cause the page pointed to by |m_page| to 63 // The call to |ReleaseAnnot| can cause the page pointed to by |m_page| to
63 // be freed, which will cause issues if we try to cleanup the pageview pointer 64 // be freed, which will cause issues if we try to cleanup the pageview pointer
64 // in |m_page|. So, reset the pageview pointer before doing anything else. 65 // in |m_page|. So, reset the pageview pointer before doing anything else.
65 m_page->SetView(nullptr); 66 m_page->SetView(nullptr);
66 #endif // PDF_ENABLE_XFA 67 #endif // PDF_ENABLE_XFA
67 68
68 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); 69 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr =
69 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); 70 m_pFormFillEnv->GetAnnotHandlerMgr();
70 for (CPDFSDK_Annot* pAnnot : m_SDKAnnotArray) 71 for (CPDFSDK_Annot* pAnnot : m_SDKAnnotArray)
71 pAnnotHandlerMgr->ReleaseAnnot(pAnnot); 72 pAnnotHandlerMgr->ReleaseAnnot(pAnnot);
72 73
73 m_SDKAnnotArray.clear(); 74 m_SDKAnnotArray.clear();
74 m_pAnnotList.reset(); 75 m_pAnnotList.reset();
75 76
76 #ifndef PDF_ENABLE_XFA 77 #ifndef PDF_ENABLE_XFA
77 if (m_bOwnsPage) 78 if (m_bOwnsPage)
78 delete m_page; 79 delete m_page;
79 #endif // PDF_ENABLE_XFA 80 #endif // PDF_ENABLE_XFA
80 } 81 }
81 82
82 void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, 83 void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice,
83 CFX_Matrix* pUser2Device, 84 CFX_Matrix* pUser2Device,
84 #ifdef PDF_ENABLE_XFA 85 #ifdef PDF_ENABLE_XFA
85 CPDF_RenderOptions* pOptions, 86 CPDF_RenderOptions* pOptions,
86 const FX_RECT& pClip) { 87 const FX_RECT& pClip) {
87 #else 88 #else
88 CPDF_RenderOptions* pOptions) { 89 CPDF_RenderOptions* pOptions) {
89 #endif // PDF_ENABLE_XFA 90 #endif // PDF_ENABLE_XFA
90 m_curMatrix = *pUser2Device; 91 m_curMatrix = *pUser2Device;
91 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv();
92 92
93 #ifdef PDF_ENABLE_XFA 93 #ifdef PDF_ENABLE_XFA
94 CPDFXFA_Page* pPage = GetPDFXFAPage(); 94 CPDFXFA_Page* pPage = GetPDFXFAPage();
95 if (!pPage) 95 if (!pPage)
96 return; 96 return;
97 97
98 if (pPage->GetDocument()->GetDocType() == DOCTYPE_DYNAMIC_XFA) { 98 if (pPage->GetDocument()->GetDocType() == DOCTYPE_DYNAMIC_XFA) {
99 CFX_Graphics gs; 99 CFX_Graphics gs;
100 gs.Create(pDevice); 100 gs.Create(pDevice);
101 CFX_RectF rectClip; 101 CFX_RectF rectClip;
(...skipping 18 matching lines...) Expand all
120 // Render the focus widget 120 // Render the focus widget
121 docView->GetWidgetHandler()->RenderWidget(annot->GetXFAWidget(), &gs, 121 docView->GetWidgetHandler()->RenderWidget(annot->GetXFAWidget(), &gs,
122 pUser2Device, FALSE); 122 pUser2Device, FALSE);
123 return; 123 return;
124 } 124 }
125 #endif // PDF_ENABLE_XFA 125 #endif // PDF_ENABLE_XFA
126 126
127 // for pdf/static xfa. 127 // for pdf/static xfa.
128 CPDFSDK_AnnotIterator annotIterator(this, true); 128 CPDFSDK_AnnotIterator annotIterator(this, true);
129 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { 129 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) {
130 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); 130 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr =
131 m_pFormFillEnv->GetAnnotHandlerMgr();
131 pAnnotHandlerMgr->Annot_OnDraw(this, pSDKAnnot, pDevice, pUser2Device, 132 pAnnotHandlerMgr->Annot_OnDraw(this, pSDKAnnot, pDevice, pUser2Device,
132 pOptions->m_bDrawAnnots); 133 pOptions->m_bDrawAnnots);
133 } 134 }
134 } 135 }
135 136
136 CPDFSDK_Annot* CPDFSDK_PageView::GetFXAnnotAtPoint(FX_FLOAT pageX, 137 CPDFSDK_Annot* CPDFSDK_PageView::GetFXAnnotAtPoint(FX_FLOAT pageX,
137 FX_FLOAT pageY) { 138 FX_FLOAT pageY) {
138 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); 139 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = m_pFormFillEnv->GetAnnotHandlerMgr();
139 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr();
140 CPDFSDK_AnnotIterator annotIterator(this, false); 140 CPDFSDK_AnnotIterator annotIterator(this, false);
141 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { 141 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) {
142 CFX_FloatRect rc = pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); 142 CFX_FloatRect rc = pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot);
143 if (pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::POPUP) 143 if (pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::POPUP)
144 continue; 144 continue;
145 if (rc.Contains(pageX, pageY)) 145 if (rc.Contains(pageX, pageY))
146 return pSDKAnnot; 146 return pSDKAnnot;
147 } 147 }
148 148
149 return nullptr; 149 return nullptr;
150 } 150 }
151 151
152 CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX, 152 CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX,
153 FX_FLOAT pageY) { 153 FX_FLOAT pageY) {
154 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); 154 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = m_pFormFillEnv->GetAnnotHandlerMgr();
155 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr();
156 CPDFSDK_AnnotIterator annotIterator(this, false); 155 CPDFSDK_AnnotIterator annotIterator(this, false);
157 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { 156 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) {
158 bool bHitTest = pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::WIDGET; 157 bool bHitTest = pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::WIDGET;
159 #ifdef PDF_ENABLE_XFA 158 #ifdef PDF_ENABLE_XFA
160 bHitTest = bHitTest || 159 bHitTest = bHitTest ||
161 pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::XFAWIDGET; 160 pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::XFAWIDGET;
162 #endif // PDF_ENABLE_XFA 161 #endif // PDF_ENABLE_XFA
163 if (bHitTest) { 162 if (bHitTest) {
164 pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); 163 pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot);
165 CFX_FloatPoint point(pageX, pageY); 164 CFX_FloatPoint point(pageX, pageY);
166 if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point)) 165 if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point))
167 return pSDKAnnot; 166 return pSDKAnnot;
168 } 167 }
169 } 168 }
170 169
171 return nullptr; 170 return nullptr;
172 } 171 }
173 172
174 #ifdef PDF_ENABLE_XFA 173 #ifdef PDF_ENABLE_XFA
175 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CXFA_FFWidget* pPDFAnnot) { 174 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CXFA_FFWidget* pPDFAnnot) {
176 if (!pPDFAnnot) 175 if (!pPDFAnnot)
177 return nullptr; 176 return nullptr;
178 177
179 CPDFSDK_Annot* pSDKAnnot = GetAnnotByXFAWidget(pPDFAnnot); 178 CPDFSDK_Annot* pSDKAnnot = GetAnnotByXFAWidget(pPDFAnnot);
180 if (pSDKAnnot) 179 if (pSDKAnnot)
181 return pSDKAnnot; 180 return pSDKAnnot;
182 181
183 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); 182 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = m_pFormFillEnv->GetAnnotHandlerMgr();
184 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = pEnv->GetAnnotHandlerMgr();
185 pSDKAnnot = pAnnotHandler->NewAnnot(pPDFAnnot, this); 183 pSDKAnnot = pAnnotHandler->NewAnnot(pPDFAnnot, this);
186 if (!pSDKAnnot) 184 if (!pSDKAnnot)
187 return nullptr; 185 return nullptr;
188 186
189 m_SDKAnnotArray.push_back(pSDKAnnot); 187 m_SDKAnnotArray.push_back(pSDKAnnot);
190 return pSDKAnnot; 188 return pSDKAnnot;
191 } 189 }
192 190
193 FX_BOOL CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) { 191 FX_BOOL CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) {
194 if (!pAnnot) 192 if (!pAnnot)
195 return FALSE; 193 return FALSE;
196 CPDFXFA_Page* pPage = pAnnot->GetPDFXFAPage(); 194 CPDFXFA_Page* pPage = pAnnot->GetPDFXFAPage();
197 if (!pPage || (pPage->GetDocument()->GetDocType() != DOCTYPE_STATIC_XFA && 195 if (!pPage || (pPage->GetDocument()->GetDocType() != DOCTYPE_STATIC_XFA &&
198 pPage->GetDocument()->GetDocType() != DOCTYPE_DYNAMIC_XFA)) 196 pPage->GetDocument()->GetDocType() != DOCTYPE_DYNAMIC_XFA))
199 return FALSE; 197 return FALSE;
200 198
201 if (GetFocusAnnot() == pAnnot) 199 if (GetFocusAnnot() == pAnnot)
202 m_pSDKDoc->KillFocusAnnot(0); 200 m_pFormFillEnv->GetSDKDocument()->KillFocusAnnot(0);
203 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); 201 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = m_pFormFillEnv->GetAnnotHandlerMgr();
204 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = pEnv->GetAnnotHandlerMgr();
205 if (pAnnotHandler) 202 if (pAnnotHandler)
206 pAnnotHandler->ReleaseAnnot(pAnnot); 203 pAnnotHandler->ReleaseAnnot(pAnnot);
207 204
208 auto it = std::find(m_SDKAnnotArray.begin(), m_SDKAnnotArray.end(), pAnnot); 205 auto it = std::find(m_SDKAnnotArray.begin(), m_SDKAnnotArray.end(), pAnnot);
209 if (it != m_SDKAnnotArray.end()) 206 if (it != m_SDKAnnotArray.end())
210 m_SDKAnnotArray.erase(it); 207 m_SDKAnnotArray.erase(it);
211 if (m_pCaptureWidget.Get() == pAnnot) 208 if (m_pCaptureWidget.Get() == pAnnot)
212 m_pCaptureWidget.Reset(); 209 m_pCaptureWidget.Reset();
213 210
214 return TRUE; 211 return TRUE;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 return pAnnot; 249 return pAnnot;
253 } 250 }
254 return nullptr; 251 return nullptr;
255 } 252 }
256 #endif // PDF_ENABLE_XFA 253 #endif // PDF_ENABLE_XFA
257 254
258 FX_BOOL CPDFSDK_PageView::OnLButtonDown(const CFX_FloatPoint& point, 255 FX_BOOL CPDFSDK_PageView::OnLButtonDown(const CFX_FloatPoint& point,
259 uint32_t nFlag) { 256 uint32_t nFlag) {
260 CPDFSDK_Annot::ObservedPtr pAnnot(GetFXWidgetAtPoint(point.x, point.y)); 257 CPDFSDK_Annot::ObservedPtr pAnnot(GetFXWidgetAtPoint(point.x, point.y));
261 if (!pAnnot) { 258 if (!pAnnot) {
262 m_pSDKDoc->KillFocusAnnot(nFlag); 259 m_pFormFillEnv->GetSDKDocument()->KillFocusAnnot(nFlag);
263 return FALSE; 260 return FALSE;
264 } 261 }
265 262
266 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); 263 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr =
267 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); 264 m_pFormFillEnv->GetAnnotHandlerMgr();
268 if (!pAnnotHandlerMgr->Annot_OnLButtonDown(this, &pAnnot, nFlag, point)) 265 if (!pAnnotHandlerMgr->Annot_OnLButtonDown(this, &pAnnot, nFlag, point))
269 return FALSE; 266 return FALSE;
270 267
271 if (!pAnnot) 268 if (!pAnnot)
272 return FALSE; 269 return FALSE;
273 270
274 m_pSDKDoc->SetFocusAnnot(&pAnnot); 271 m_pFormFillEnv->GetSDKDocument()->SetFocusAnnot(&pAnnot);
275 return TRUE; 272 return TRUE;
276 } 273 }
277 274
278 #ifdef PDF_ENABLE_XFA 275 #ifdef PDF_ENABLE_XFA
279 FX_BOOL CPDFSDK_PageView::OnRButtonDown(const CFX_FloatPoint& point, 276 FX_BOOL CPDFSDK_PageView::OnRButtonDown(const CFX_FloatPoint& point,
280 uint32_t nFlag) { 277 uint32_t nFlag) {
281 CPDFSDK_Annot::ObservedPtr pAnnot(GetFXWidgetAtPoint(point.x, point.y)); 278 CPDFSDK_Annot::ObservedPtr pAnnot(GetFXWidgetAtPoint(point.x, point.y));
282 if (!pAnnot) 279 if (!pAnnot)
283 return FALSE; 280 return FALSE;
284 281
285 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); 282 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr =
286 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); 283 m_pFormFillEnv->GetAnnotHandlerMgr();
287 FX_BOOL ok = 284 FX_BOOL ok =
288 pAnnotHandlerMgr->Annot_OnRButtonDown(this, &pAnnot, nFlag, point); 285 pAnnotHandlerMgr->Annot_OnRButtonDown(this, &pAnnot, nFlag, point);
289 if (!pAnnot) 286 if (!pAnnot)
290 return FALSE; 287 return FALSE;
291 288
292 if (ok) 289 if (ok)
293 m_pSDKDoc->SetFocusAnnot(&pAnnot); 290 m_pFormFillEnv->GetSDKDocument()->SetFocusAnnot(&pAnnot);
294 291
295 return TRUE; 292 return TRUE;
296 } 293 }
297 294
298 FX_BOOL CPDFSDK_PageView::OnRButtonUp(const CFX_FloatPoint& point, 295 FX_BOOL CPDFSDK_PageView::OnRButtonUp(const CFX_FloatPoint& point,
299 uint32_t nFlag) { 296 uint32_t nFlag) {
300 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); 297 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr =
301 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); 298 m_pFormFillEnv->GetAnnotHandlerMgr();
302 CPDFSDK_Annot::ObservedPtr pFXAnnot(GetFXWidgetAtPoint(point.x, point.y)); 299 CPDFSDK_Annot::ObservedPtr pFXAnnot(GetFXWidgetAtPoint(point.x, point.y));
303 if (!pFXAnnot) 300 if (!pFXAnnot)
304 return FALSE; 301 return FALSE;
305 302
306 if (pAnnotHandlerMgr->Annot_OnRButtonUp(this, &pFXAnnot, nFlag, point)) 303 if (pAnnotHandlerMgr->Annot_OnRButtonUp(this, &pFXAnnot, nFlag, point))
307 m_pSDKDoc->SetFocusAnnot(&pFXAnnot); 304 m_pFormFillEnv->GetSDKDocument()->SetFocusAnnot(&pFXAnnot);
308 305
309 return TRUE; 306 return TRUE;
310 } 307 }
311 #endif // PDF_ENABLE_XFA 308 #endif // PDF_ENABLE_XFA
312 309
313 FX_BOOL CPDFSDK_PageView::OnLButtonUp(const CFX_FloatPoint& point, 310 FX_BOOL CPDFSDK_PageView::OnLButtonUp(const CFX_FloatPoint& point,
314 uint32_t nFlag) { 311 uint32_t nFlag) {
315 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); 312 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr =
316 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); 313 m_pFormFillEnv->GetAnnotHandlerMgr();
317 CPDFSDK_Annot::ObservedPtr pFXAnnot(GetFXWidgetAtPoint(point.x, point.y)); 314 CPDFSDK_Annot::ObservedPtr pFXAnnot(GetFXWidgetAtPoint(point.x, point.y));
318 CPDFSDK_Annot::ObservedPtr pFocusAnnot(GetFocusAnnot()); 315 CPDFSDK_Annot::ObservedPtr pFocusAnnot(GetFocusAnnot());
319 if (pFocusAnnot && pFocusAnnot != pFXAnnot) { 316 if (pFocusAnnot && pFocusAnnot != pFXAnnot) {
320 // Last focus Annot gets a chance to handle the event. 317 // Last focus Annot gets a chance to handle the event.
321 if (pAnnotHandlerMgr->Annot_OnLButtonUp(this, &pFocusAnnot, nFlag, point)) 318 if (pAnnotHandlerMgr->Annot_OnLButtonUp(this, &pFocusAnnot, nFlag, point))
322 return TRUE; 319 return TRUE;
323 } 320 }
324 return pFXAnnot && 321 return pFXAnnot &&
325 pAnnotHandlerMgr->Annot_OnLButtonUp(this, &pFXAnnot, nFlag, point); 322 pAnnotHandlerMgr->Annot_OnLButtonUp(this, &pFXAnnot, nFlag, point);
326 } 323 }
327 324
328 FX_BOOL CPDFSDK_PageView::OnMouseMove(const CFX_FloatPoint& point, int nFlag) { 325 FX_BOOL CPDFSDK_PageView::OnMouseMove(const CFX_FloatPoint& point, int nFlag) {
329 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); 326 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr =
330 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); 327 m_pFormFillEnv->GetAnnotHandlerMgr();
331 CPDFSDK_Annot::ObservedPtr pFXAnnot(GetFXAnnotAtPoint(point.x, point.y)); 328 CPDFSDK_Annot::ObservedPtr pFXAnnot(GetFXAnnotAtPoint(point.x, point.y));
332 if (pFXAnnot) { 329 if (pFXAnnot) {
333 if (m_pCaptureWidget && m_pCaptureWidget != pFXAnnot) { 330 if (m_pCaptureWidget && m_pCaptureWidget != pFXAnnot) {
334 m_bExitWidget = TRUE; 331 m_bExitWidget = TRUE;
335 m_bEnterWidget = FALSE; 332 m_bEnterWidget = FALSE;
336 pAnnotHandlerMgr->Annot_OnMouseExit(this, &m_pCaptureWidget, nFlag); 333 pAnnotHandlerMgr->Annot_OnMouseExit(this, &m_pCaptureWidget, nFlag);
337 } 334 }
338 m_pCaptureWidget.Reset(pFXAnnot.Get()); 335 m_pCaptureWidget.Reset(pFXAnnot.Get());
339 m_bOnWidget = TRUE; 336 m_bOnWidget = TRUE;
340 if (!m_bEnterWidget) { 337 if (!m_bEnterWidget) {
(...skipping 17 matching lines...) Expand all
358 } 355 }
359 356
360 FX_BOOL CPDFSDK_PageView::OnMouseWheel(double deltaX, 357 FX_BOOL CPDFSDK_PageView::OnMouseWheel(double deltaX,
361 double deltaY, 358 double deltaY,
362 const CFX_FloatPoint& point, 359 const CFX_FloatPoint& point,
363 int nFlag) { 360 int nFlag) {
364 CPDFSDK_Annot::ObservedPtr pAnnot(GetFXWidgetAtPoint(point.x, point.y)); 361 CPDFSDK_Annot::ObservedPtr pAnnot(GetFXWidgetAtPoint(point.x, point.y));
365 if (!pAnnot) 362 if (!pAnnot)
366 return FALSE; 363 return FALSE;
367 364
368 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); 365 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr =
369 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); 366 m_pFormFillEnv->GetAnnotHandlerMgr();
370 return pAnnotHandlerMgr->Annot_OnMouseWheel(this, &pAnnot, nFlag, (int)deltaY, 367 return pAnnotHandlerMgr->Annot_OnMouseWheel(this, &pAnnot, nFlag, (int)deltaY,
371 point); 368 point);
372 } 369 }
373 370
374 FX_BOOL CPDFSDK_PageView::OnChar(int nChar, uint32_t nFlag) { 371 FX_BOOL CPDFSDK_PageView::OnChar(int nChar, uint32_t nFlag) {
375 if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) { 372 if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) {
376 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); 373 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr =
377 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); 374 m_pFormFillEnv->GetAnnotHandlerMgr();
378 return pAnnotHandlerMgr->Annot_OnChar(pAnnot, nChar, nFlag); 375 return pAnnotHandlerMgr->Annot_OnChar(pAnnot, nChar, nFlag);
379 } 376 }
380 377
381 return FALSE; 378 return FALSE;
382 } 379 }
383 380
384 FX_BOOL CPDFSDK_PageView::OnKeyDown(int nKeyCode, int nFlag) { 381 FX_BOOL CPDFSDK_PageView::OnKeyDown(int nKeyCode, int nFlag) {
385 if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) { 382 if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) {
386 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); 383 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr =
387 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); 384 m_pFormFillEnv->GetAnnotHandlerMgr();
388 return pAnnotHandlerMgr->Annot_OnKeyDown(pAnnot, nKeyCode, nFlag); 385 return pAnnotHandlerMgr->Annot_OnKeyDown(pAnnot, nKeyCode, nFlag);
389 } 386 }
390 return FALSE; 387 return FALSE;
391 } 388 }
392 389
393 FX_BOOL CPDFSDK_PageView::OnKeyUp(int nKeyCode, int nFlag) { 390 FX_BOOL CPDFSDK_PageView::OnKeyUp(int nKeyCode, int nFlag) {
394 return FALSE; 391 return FALSE;
395 } 392 }
396 393
397 void CPDFSDK_PageView::LoadFXAnnots() { 394 void CPDFSDK_PageView::LoadFXAnnots() {
398 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); 395 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr =
399 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); 396 m_pFormFillEnv->GetAnnotHandlerMgr();
400 397
401 SetLock(TRUE); 398 SetLock(TRUE);
402 399
403 #ifdef PDF_ENABLE_XFA 400 #ifdef PDF_ENABLE_XFA
404 CFX_RetainPtr<CPDFXFA_Page> protector(m_page); 401 CFX_RetainPtr<CPDFXFA_Page> protector(m_page);
405 if (m_pSDKDoc->GetXFADocument()->GetDocType() == DOCTYPE_DYNAMIC_XFA) { 402 if (m_pFormFillEnv->GetSDKDocument()->GetXFADocument()->GetDocType() ==
403 DOCTYPE_DYNAMIC_XFA) {
406 CXFA_FFPageView* pageView = m_page->GetXFAPageView(); 404 CXFA_FFPageView* pageView = m_page->GetXFAPageView();
407 std::unique_ptr<IXFA_WidgetIterator> pWidgetHander( 405 std::unique_ptr<IXFA_WidgetIterator> pWidgetHander(
408 pageView->CreateWidgetIterator( 406 pageView->CreateWidgetIterator(
409 XFA_TRAVERSEWAY_Form, 407 XFA_TRAVERSEWAY_Form,
410 XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable)); 408 XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable));
411 if (!pWidgetHander) { 409 if (!pWidgetHander) {
412 SetLock(FALSE); 410 SetLock(FALSE);
413 return; 411 return;
414 } 412 }
415 413
(...skipping 26 matching lines...) Expand all
442 if (!pAnnot) 440 if (!pAnnot)
443 continue; 441 continue;
444 m_SDKAnnotArray.push_back(pAnnot); 442 m_SDKAnnotArray.push_back(pAnnot);
445 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); 443 pAnnotHandlerMgr->Annot_OnLoad(pAnnot);
446 } 444 }
447 445
448 SetLock(FALSE); 446 SetLock(FALSE);
449 } 447 }
450 448
451 void CPDFSDK_PageView::UpdateRects(const std::vector<CFX_FloatRect>& rects) { 449 void CPDFSDK_PageView::UpdateRects(const std::vector<CFX_FloatRect>& rects) {
452 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv();
453 for (const auto& rc : rects) 450 for (const auto& rc : rects)
454 pEnv->Invalidate(m_page, rc.left, rc.top, rc.right, rc.bottom); 451 m_pFormFillEnv->Invalidate(m_page, rc.left, rc.top, rc.right, rc.bottom);
455 } 452 }
456 453
457 void CPDFSDK_PageView::UpdateView(CPDFSDK_Annot* pAnnot) { 454 void CPDFSDK_PageView::UpdateView(CPDFSDK_Annot* pAnnot) {
458 CFX_FloatRect rcWindow = pAnnot->GetRect(); 455 CFX_FloatRect rcWindow = pAnnot->GetRect();
459 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); 456 m_pFormFillEnv->Invalidate(m_page, rcWindow.left, rcWindow.top,
460 pEnv->Invalidate(m_page, rcWindow.left, rcWindow.top, rcWindow.right, 457 rcWindow.right, rcWindow.bottom);
461 rcWindow.bottom);
462 } 458 }
463 459
464 int CPDFSDK_PageView::GetPageIndex() const { 460 int CPDFSDK_PageView::GetPageIndex() const {
465 if (!m_page) 461 if (!m_page)
466 return -1; 462 return -1;
467 463
468 #ifdef PDF_ENABLE_XFA 464 #ifdef PDF_ENABLE_XFA
469 int nDocType = m_page->GetDocument()->GetDocType(); 465 int nDocType = m_page->GetDocument()->GetDocType();
470 switch (nDocType) { 466 switch (nDocType) {
471 case DOCTYPE_DYNAMIC_XFA: { 467 case DOCTYPE_DYNAMIC_XFA: {
(...skipping 23 matching lines...) Expand all
495 return it != annots.end(); 491 return it != annots.end();
496 } 492 }
497 493
498 bool CPDFSDK_PageView::IsValidSDKAnnot(const CPDFSDK_Annot* p) const { 494 bool CPDFSDK_PageView::IsValidSDKAnnot(const CPDFSDK_Annot* p) const {
499 if (!p) 495 if (!p)
500 return false; 496 return false;
501 return pdfium::ContainsValue(m_SDKAnnotArray, p); 497 return pdfium::ContainsValue(m_SDKAnnotArray, p);
502 } 498 }
503 499
504 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() { 500 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() {
505 CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot(); 501 CPDFSDK_Annot* pFocusAnnot =
502 m_pFormFillEnv->GetSDKDocument()->GetFocusAnnot();
506 return IsValidSDKAnnot(pFocusAnnot) ? pFocusAnnot : nullptr; 503 return IsValidSDKAnnot(pFocusAnnot) ? pFocusAnnot : nullptr;
507 } 504 }
508 505
509 int CPDFSDK_PageView::GetPageIndexForStaticPDF() const { 506 int CPDFSDK_PageView::GetPageIndexForStaticPDF() const {
510 CPDF_Dictionary* pDict = GetPDFPage()->m_pFormDict; 507 CPDF_Dictionary* pDict = GetPDFPage()->m_pFormDict;
511 CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument(); 508 CPDF_Document* pDoc = m_pFormFillEnv->GetSDKDocument()->GetPDFDocument();
512 return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1; 509 return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1;
513 } 510 }
OLDNEW
« no previous file with comments | « fpdfsdk/cpdfsdk_pageview.h ('k') | fpdfsdk/cpdfsdk_widget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698