OLD | NEW |
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" | |
17 #include "fpdfsdk/cpdfsdk_formfillenvironment.h" | 16 #include "fpdfsdk/cpdfsdk_formfillenvironment.h" |
18 #include "fpdfsdk/cpdfsdk_interform.h" | 17 #include "fpdfsdk/cpdfsdk_interform.h" |
19 #include "fpdfsdk/cpdfsdk_pageview.h" | 18 #include "fpdfsdk/cpdfsdk_pageview.h" |
20 #include "fpdfsdk/cpdfsdk_widget.h" | 19 #include "fpdfsdk/cpdfsdk_widget.h" |
21 #include "fpdfsdk/formfiller/cffl_formfiller.h" | 20 #include "fpdfsdk/formfiller/cffl_formfiller.h" |
22 | 21 |
23 #ifdef PDF_ENABLE_XFA | 22 #ifdef PDF_ENABLE_XFA |
24 #include "fpdfsdk/fpdfxfa/cpdfxfa_document.h" | 23 #include "fpdfsdk/fpdfxfa/cpdfxfa_document.h" |
25 #endif // PDF_ENABLE_XFA | 24 #endif // PDF_ENABLE_XFA |
26 | 25 |
(...skipping 20 matching lines...) Expand all Loading... |
47 | 46 |
48 CPDF_Page* pPage = pWidget->GetPDFPage(); | 47 CPDF_Page* pPage = pWidget->GetPDFPage(); |
49 CPDF_Document* pDocument = pPage->m_pDocument; | 48 CPDF_Document* pDocument = pPage->m_pDocument; |
50 uint32_t dwPermissions = pDocument->GetUserPermissions(); | 49 uint32_t dwPermissions = pDocument->GetUserPermissions(); |
51 return (dwPermissions & FPDFPERM_FILL_FORM) || | 50 return (dwPermissions & FPDFPERM_FILL_FORM) || |
52 (dwPermissions & FPDFPERM_ANNOT_FORM); | 51 (dwPermissions & FPDFPERM_ANNOT_FORM); |
53 } | 52 } |
54 | 53 |
55 CPDFSDK_Annot* CPDFSDK_WidgetHandler::NewAnnot(CPDF_Annot* pAnnot, | 54 CPDFSDK_Annot* CPDFSDK_WidgetHandler::NewAnnot(CPDF_Annot* pAnnot, |
56 CPDFSDK_PageView* pPage) { | 55 CPDFSDK_PageView* pPage) { |
57 CPDFSDK_InterForm* pInterForm = m_pEnv->GetSDKDocument()->GetInterForm(); | 56 CPDFSDK_InterForm* pInterForm = m_pEnv->GetInterForm(); |
58 CPDF_FormControl* pCtrl = CPDFSDK_Widget::GetFormControl( | 57 CPDF_FormControl* pCtrl = CPDFSDK_Widget::GetFormControl( |
59 pInterForm->GetInterForm(), pAnnot->GetAnnotDict()); | 58 pInterForm->GetInterForm(), pAnnot->GetAnnotDict()); |
60 if (!pCtrl) | 59 if (!pCtrl) |
61 return nullptr; | 60 return nullptr; |
62 | 61 |
63 CPDFSDK_Widget* pWidget = new CPDFSDK_Widget(pAnnot, pPage, pInterForm); | 62 CPDFSDK_Widget* pWidget = new CPDFSDK_Widget(pAnnot, pPage, pInterForm); |
64 pInterForm->AddMap(pCtrl, pWidget); | 63 pInterForm->AddMap(pCtrl, pWidget); |
65 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); | 64 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); |
66 if (pPDFInterForm && pPDFInterForm->NeedConstructAP()) | 65 if (pPDFInterForm && pPDFInterForm->NeedConstructAP()) |
67 pWidget->ResetAppearance(nullptr, FALSE); | 66 pWidget->ResetAppearance(nullptr, FALSE); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 int nFieldType = pWidget->GetFieldType(); | 242 int nFieldType = pWidget->GetFieldType(); |
244 if (nFieldType == FIELDTYPE_TEXTFIELD || nFieldType == FIELDTYPE_COMBOBOX) { | 243 if (nFieldType == FIELDTYPE_TEXTFIELD || nFieldType == FIELDTYPE_COMBOBOX) { |
245 FX_BOOL bFormatted = FALSE; | 244 FX_BOOL bFormatted = FALSE; |
246 CFX_WideString sValue = pWidget->OnFormat(bFormatted); | 245 CFX_WideString sValue = pWidget->OnFormat(bFormatted); |
247 if (bFormatted && nFieldType == FIELDTYPE_COMBOBOX) | 246 if (bFormatted && nFieldType == FIELDTYPE_COMBOBOX) |
248 pWidget->ResetAppearance(&sValue, FALSE); | 247 pWidget->ResetAppearance(&sValue, FALSE); |
249 } | 248 } |
250 | 249 |
251 #ifdef PDF_ENABLE_XFA | 250 #ifdef PDF_ENABLE_XFA |
252 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); | 251 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); |
253 CPDFXFA_Document* pDoc = | 252 CPDFXFA_Document* pDoc = pPageView->GetFormFillEnv()->GetXFADocument(); |
254 pPageView->GetFormFillEnv()->GetSDKDocument()->GetXFADocument(); | |
255 if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { | 253 if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { |
256 if (!pWidget->IsAppearanceValid() && !pWidget->GetValue().IsEmpty()) | 254 if (!pWidget->IsAppearanceValid() && !pWidget->GetValue().IsEmpty()) |
257 pWidget->ResetAppearance(FALSE); | 255 pWidget->ResetAppearance(FALSE); |
258 } | 256 } |
259 #endif // PDF_ENABLE_XFA | 257 #endif // PDF_ENABLE_XFA |
260 if (m_pFormFiller) | 258 if (m_pFormFiller) |
261 m_pFormFiller->OnLoad(pAnnot); | 259 m_pFormFiller->OnLoad(pAnnot); |
262 } | 260 } |
263 | 261 |
264 FX_BOOL CPDFSDK_WidgetHandler::OnSetFocus(CPDFSDK_Annot::ObservedPtr* pAnnot, | 262 FX_BOOL CPDFSDK_WidgetHandler::OnSetFocus(CPDFSDK_Annot::ObservedPtr* pAnnot, |
(...skipping 30 matching lines...) Expand all Loading... |
295 | 293 |
296 FX_BOOL CPDFSDK_WidgetHandler::HitTest(CPDFSDK_PageView* pPageView, | 294 FX_BOOL CPDFSDK_WidgetHandler::HitTest(CPDFSDK_PageView* pPageView, |
297 CPDFSDK_Annot* pAnnot, | 295 CPDFSDK_Annot* pAnnot, |
298 const CFX_FloatPoint& point) { | 296 const CFX_FloatPoint& point) { |
299 ASSERT(pPageView); | 297 ASSERT(pPageView); |
300 ASSERT(pAnnot); | 298 ASSERT(pAnnot); |
301 | 299 |
302 CFX_FloatRect rect = GetViewBBox(pPageView, pAnnot); | 300 CFX_FloatRect rect = GetViewBBox(pPageView, pAnnot); |
303 return rect.Contains(point.x, point.y); | 301 return rect.Contains(point.x, point.y); |
304 } | 302 } |
OLD | NEW |