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

Side by Side Diff: fpdfsdk/cpdfsdk_widgethandler.cpp

Issue 2400473002: Start proxying CPDFSDK_Document methods through 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_widgethandler.h ('k') | fpdfsdk/cpdfsdk_xfawidgethandler.h » ('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_widgethandler.h" 7 #include "fpdfsdk/cpdfsdk_widgethandler.h"
8 8
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
11 11
12 #include "core/fpdfapi/page/cpdf_page.h" 12 #include "core/fpdfapi/page/cpdf_page.h"
13 #include "core/fpdfapi/parser/cpdf_document.h" 13 #include "core/fpdfapi/parser/cpdf_document.h"
14 #include "core/fpdfdoc/cpdf_interform.h" 14 #include "core/fpdfdoc/cpdf_interform.h"
15 #include "fpdfsdk/cpdfsdk_annot.h" 15 #include "fpdfsdk/cpdfsdk_annot.h"
16 #include "fpdfsdk/cpdfsdk_document.h" 16 #include "fpdfsdk/cpdfsdk_document.h"
17 #include "fpdfsdk/cpdfsdk_formfillenvironment.h" 17 #include "fpdfsdk/cpdfsdk_formfillenvironment.h"
18 #include "fpdfsdk/cpdfsdk_interform.h" 18 #include "fpdfsdk/cpdfsdk_interform.h"
19 #include "fpdfsdk/cpdfsdk_pageview.h" 19 #include "fpdfsdk/cpdfsdk_pageview.h"
20 #include "fpdfsdk/cpdfsdk_widget.h" 20 #include "fpdfsdk/cpdfsdk_widget.h"
21 #include "fpdfsdk/formfiller/cffl_formfiller.h" 21 #include "fpdfsdk/formfiller/cffl_formfiller.h"
22 22
23 #ifdef PDF_ENABLE_XFA 23 #ifdef PDF_ENABLE_XFA
24 #include "fpdfsdk/fpdfxfa/cpdfxfa_document.h" 24 #include "fpdfsdk/fpdfxfa/cpdfxfa_document.h"
25 #endif // PDF_ENABLE_XFA 25 #endif // PDF_ENABLE_XFA
26 26
27 CPDFSDK_WidgetHandler::CPDFSDK_WidgetHandler(CPDFSDK_FormFillEnvironment* pEnv) 27 CPDFSDK_WidgetHandler::CPDFSDK_WidgetHandler(
28 : m_pEnv(pEnv), m_pFormFiller(nullptr) {} 28 CPDFSDK_FormFillEnvironment* pFormFillEnv)
29 : m_pFormFillEnv(pFormFillEnv), m_pFormFiller(nullptr) {}
29 30
30 CPDFSDK_WidgetHandler::~CPDFSDK_WidgetHandler() {} 31 CPDFSDK_WidgetHandler::~CPDFSDK_WidgetHandler() {}
31 32
32 FX_BOOL CPDFSDK_WidgetHandler::CanAnswer(CPDFSDK_Annot* pAnnot) { 33 FX_BOOL CPDFSDK_WidgetHandler::CanAnswer(CPDFSDK_Annot* pAnnot) {
33 ASSERT(pAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::WIDGET); 34 ASSERT(pAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::WIDGET);
34 if (pAnnot->IsSignatureWidget()) 35 if (pAnnot->IsSignatureWidget())
35 return FALSE; 36 return FALSE;
36 37
37 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot); 38 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot);
38 if (!pWidget->IsVisible()) 39 if (!pWidget->IsVisible())
39 return FALSE; 40 return FALSE;
40 41
41 int nFieldFlags = pWidget->GetFieldFlags(); 42 int nFieldFlags = pWidget->GetFieldFlags();
42 if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) 43 if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY)
43 return FALSE; 44 return FALSE;
44 45
45 if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON) 46 if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON)
46 return TRUE; 47 return TRUE;
47 48
48 CPDF_Page* pPage = pWidget->GetPDFPage(); 49 CPDF_Page* pPage = pWidget->GetPDFPage();
49 CPDF_Document* pDocument = pPage->m_pDocument; 50 CPDF_Document* pDocument = pPage->m_pDocument;
50 uint32_t dwPermissions = pDocument->GetUserPermissions(); 51 uint32_t dwPermissions = pDocument->GetUserPermissions();
51 return (dwPermissions & FPDFPERM_FILL_FORM) || 52 return (dwPermissions & FPDFPERM_FILL_FORM) ||
52 (dwPermissions & FPDFPERM_ANNOT_FORM); 53 (dwPermissions & FPDFPERM_ANNOT_FORM);
53 } 54 }
54 55
55 CPDFSDK_Annot* CPDFSDK_WidgetHandler::NewAnnot(CPDF_Annot* pAnnot, 56 CPDFSDK_Annot* CPDFSDK_WidgetHandler::NewAnnot(CPDF_Annot* pAnnot,
56 CPDFSDK_PageView* pPage) { 57 CPDFSDK_PageView* pPage) {
57 CPDFSDK_Document* pSDKDoc = m_pEnv->GetSDKDocument(); 58 CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
58 CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm();
59 CPDF_FormControl* pCtrl = CPDFSDK_Widget::GetFormControl( 59 CPDF_FormControl* pCtrl = CPDFSDK_Widget::GetFormControl(
60 pInterForm->GetInterForm(), pAnnot->GetAnnotDict()); 60 pInterForm->GetInterForm(), pAnnot->GetAnnotDict());
61 if (!pCtrl) 61 if (!pCtrl)
62 return nullptr; 62 return nullptr;
63 63
64 CPDFSDK_Widget* pWidget = new CPDFSDK_Widget(pAnnot, pPage, pInterForm); 64 CPDFSDK_Widget* pWidget = new CPDFSDK_Widget(pAnnot, pPage, pInterForm);
65 pInterForm->AddMap(pCtrl, pWidget); 65 pInterForm->AddMap(pCtrl, pWidget);
66 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); 66 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm();
67 if (pPDFInterForm && pPDFInterForm->NeedConstructAP()) 67 if (pPDFInterForm && pPDFInterForm->NeedConstructAP())
68 pWidget->ResetAppearance(nullptr, FALSE); 68 pWidget->ResetAppearance(nullptr, FALSE);
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 int nFieldType = pWidget->GetFieldType(); 244 int nFieldType = pWidget->GetFieldType();
245 if (nFieldType == FIELDTYPE_TEXTFIELD || nFieldType == FIELDTYPE_COMBOBOX) { 245 if (nFieldType == FIELDTYPE_TEXTFIELD || nFieldType == FIELDTYPE_COMBOBOX) {
246 FX_BOOL bFormatted = FALSE; 246 FX_BOOL bFormatted = FALSE;
247 CFX_WideString sValue = pWidget->OnFormat(bFormatted); 247 CFX_WideString sValue = pWidget->OnFormat(bFormatted);
248 if (bFormatted && nFieldType == FIELDTYPE_COMBOBOX) 248 if (bFormatted && nFieldType == FIELDTYPE_COMBOBOX)
249 pWidget->ResetAppearance(&sValue, FALSE); 249 pWidget->ResetAppearance(&sValue, FALSE);
250 } 250 }
251 251
252 #ifdef PDF_ENABLE_XFA 252 #ifdef PDF_ENABLE_XFA
253 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); 253 CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
254 CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument(); 254 CPDFXFA_Document* pDoc = pPageView->GetFormFillEnv()->GetXFADocument();
255 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument();
256 if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { 255 if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) {
257 if (!pWidget->IsAppearanceValid() && !pWidget->GetValue().IsEmpty()) 256 if (!pWidget->IsAppearanceValid() && !pWidget->GetValue().IsEmpty())
258 pWidget->ResetAppearance(FALSE); 257 pWidget->ResetAppearance(FALSE);
259 } 258 }
260 #endif // PDF_ENABLE_XFA 259 #endif // PDF_ENABLE_XFA
261 if (m_pFormFiller) 260 if (m_pFormFiller)
262 m_pFormFiller->OnLoad(pAnnot); 261 m_pFormFiller->OnLoad(pAnnot);
263 } 262 }
264 263
265 FX_BOOL CPDFSDK_WidgetHandler::OnSetFocus(CPDFSDK_Annot::ObservedPtr* pAnnot, 264 FX_BOOL CPDFSDK_WidgetHandler::OnSetFocus(CPDFSDK_Annot::ObservedPtr* pAnnot,
(...skipping 30 matching lines...) Expand all
296 295
297 FX_BOOL CPDFSDK_WidgetHandler::HitTest(CPDFSDK_PageView* pPageView, 296 FX_BOOL CPDFSDK_WidgetHandler::HitTest(CPDFSDK_PageView* pPageView,
298 CPDFSDK_Annot* pAnnot, 297 CPDFSDK_Annot* pAnnot,
299 const CFX_FloatPoint& point) { 298 const CFX_FloatPoint& point) {
300 ASSERT(pPageView); 299 ASSERT(pPageView);
301 ASSERT(pAnnot); 300 ASSERT(pAnnot);
302 301
303 CFX_FloatRect rect = GetViewBBox(pPageView, pAnnot); 302 CFX_FloatRect rect = GetViewBBox(pPageView, pAnnot);
304 return rect.Contains(point.x, point.y); 303 return rect.Contains(point.x, point.y);
305 } 304 }
OLDNEW
« no previous file with comments | « fpdfsdk/cpdfsdk_widgethandler.h ('k') | fpdfsdk/cpdfsdk_xfawidgethandler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698