| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 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 "../include/fpdfxfa/fpdfxfa_doc.h" | 7 #include "../include/fpdfxfa/fpdfxfa_doc.h" |
| 8 #include "../include/fpdfxfa/fpdfxfa_util.h" | 8 #include "../include/fpdfxfa/fpdfxfa_util.h" |
| 9 #include "fpdfsdk/include/formfiller/FFL_FormFiller.h" | 9 #include "fpdfsdk/include/formfiller/FFL_FormFiller.h" |
| 10 #include "fpdfsdk/include/fsdk_actionhandler.h" | 10 #include "fpdfsdk/include/fsdk_actionhandler.h" |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 CPDF_FormField* pField = GetFormField(); | 498 CPDF_FormField* pField = GetFormField(); |
| 499 ASSERT(pField != NULL); | 499 ASSERT(pField != NULL); |
| 500 | 500 |
| 501 return pField->GetFieldType(); | 501 return pField->GetFieldType(); |
| 502 } | 502 } |
| 503 | 503 |
| 504 FX_BOOL CPDFSDK_Widget::IsAppearanceValid() { | 504 FX_BOOL CPDFSDK_Widget::IsAppearanceValid() { |
| 505 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); | 505 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); |
| 506 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); | 506 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); |
| 507 int nDocType = pDoc->GetDocType(); | 507 int nDocType = pDoc->GetDocType(); |
| 508 if (nDocType == DOCTYPE_PDF || nDocType == DOCTYPE_STATIC_XFA) | 508 if (nDocType != DOCTYPE_PDF && nDocType != DOCTYPE_STATIC_XFA) |
| 509 return CPDFSDK_BAAnnot::IsAppearanceValid(); | 509 return TRUE; |
| 510 | 510 |
| 511 return TRUE; | 511 return CPDFSDK_BAAnnot::IsAppearanceValid(); |
| 512 } | 512 } |
| 513 | 513 |
| 514 int CPDFSDK_Widget::GetFieldFlags() const { | 514 int CPDFSDK_Widget::GetFieldFlags() const { |
| 515 CPDF_InterForm* pPDFInterForm = m_pInterForm->GetInterForm(); | 515 CPDF_InterForm* pPDFInterForm = m_pInterForm->GetInterForm(); |
| 516 ASSERT(pPDFInterForm != NULL); | 516 ASSERT(pPDFInterForm != NULL); |
| 517 | 517 |
| 518 CPDF_FormControl* pFormControl = | 518 CPDF_FormControl* pFormControl = |
| 519 pPDFInterForm->GetControlByDict(m_pAnnot->GetAnnotDict()); | 519 pPDFInterForm->GetControlByDict(m_pAnnot->GetAnnotDict()); |
| 520 CPDF_FormField* pFormField = pFormControl->GetField(); | 520 CPDF_FormField* pFormField = pFormControl->GetField(); |
| 521 return pFormField->GetFieldFlags(); | 521 return pFormField->GetFieldFlags(); |
| (...skipping 1426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1948 void CPDFSDK_Widget::RemoveAppearance(const CFX_ByteString& sAPType) { | 1948 void CPDFSDK_Widget::RemoveAppearance(const CFX_ByteString& sAPType) { |
| 1949 if (CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDict("AP")) { | 1949 if (CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDict("AP")) { |
| 1950 pAPDict->RemoveAt(sAPType); | 1950 pAPDict->RemoveAt(sAPType); |
| 1951 } | 1951 } |
| 1952 } | 1952 } |
| 1953 | 1953 |
| 1954 FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type, | 1954 FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type, |
| 1955 PDFSDK_FieldAction& data, | 1955 PDFSDK_FieldAction& data, |
| 1956 CPDFSDK_PageView* pPageView) { | 1956 CPDFSDK_PageView* pPageView) { |
| 1957 CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); | 1957 CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); |
| 1958 CPDFXFA_Document* pDoc = pDocument->GetXFADocument(); | |
| 1959 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); | 1958 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); |
| 1960 | 1959 |
| 1961 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) { | 1960 CPDFXFA_Document* pDoc = pDocument->GetXFADocument(); |
| 1961 if (IXFA_Widget* hWidget = GetMixXFAWidget()) { |
| 1962 XFA_EVENTTYPE eEventType = GetXFAEventType(type, data.bWillCommit); | 1962 XFA_EVENTTYPE eEventType = GetXFAEventType(type, data.bWillCommit); |
| 1963 | 1963 |
| 1964 if (eEventType != XFA_EVENT_Unknown) { | 1964 if (eEventType != XFA_EVENT_Unknown) { |
| 1965 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) { | 1965 if (IXFA_WidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { |
| 1966 CXFA_EventParam param; | 1966 CXFA_EventParam param; |
| 1967 param.m_eType = eEventType; | 1967 param.m_eType = eEventType; |
| 1968 param.m_wsChange = data.sChange; | 1968 param.m_wsChange = data.sChange; |
| 1969 param.m_iCommitKey = data.nCommitKey; | 1969 param.m_iCommitKey = data.nCommitKey; |
| 1970 param.m_bShift = data.bShift; | 1970 param.m_bShift = data.bShift; |
| 1971 param.m_iSelStart = data.nSelStart; | 1971 param.m_iSelStart = data.nSelStart; |
| 1972 param.m_iSelEnd = data.nSelEnd; | 1972 param.m_iSelEnd = data.nSelEnd; |
| 1973 param.m_wsFullText = data.sValue; | 1973 param.m_wsFullText = data.sValue; |
| 1974 param.m_bKeyDown = data.bKeyDown; | 1974 param.m_bKeyDown = data.bKeyDown; |
| 1975 param.m_bModifier = data.bModifier; | 1975 param.m_bModifier = data.bModifier; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2060 | 2060 |
| 2061 int nFieldFlags = GetFieldFlags(); | 2061 int nFieldFlags = GetFieldFlags(); |
| 2062 if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) | 2062 if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) |
| 2063 return FALSE; | 2063 return FALSE; |
| 2064 | 2064 |
| 2065 return TRUE; | 2065 return TRUE; |
| 2066 } | 2066 } |
| 2067 return FALSE; | 2067 return FALSE; |
| 2068 } | 2068 } |
| 2069 | 2069 |
| 2070 // CPDFSDK_XFAWidget | |
| 2071 CPDFSDK_XFAWidget::CPDFSDK_XFAWidget(IXFA_Widget* pAnnot, | 2070 CPDFSDK_XFAWidget::CPDFSDK_XFAWidget(IXFA_Widget* pAnnot, |
| 2072 CPDFSDK_PageView* pPageView, | 2071 CPDFSDK_PageView* pPageView, |
| 2073 CPDFSDK_InterForm* pInterForm) | 2072 CPDFSDK_InterForm* pInterForm) |
| 2074 : CPDFSDK_Annot(pPageView), m_pInterForm(pInterForm), m_hXFAWidget(pAnnot) { | 2073 : CPDFSDK_Annot(pPageView), m_pInterForm(pInterForm), m_hXFAWidget(pAnnot) { |
| 2075 } | 2074 } |
| 2076 | 2075 |
| 2077 FX_BOOL CPDFSDK_XFAWidget::IsXFAField() { | 2076 FX_BOOL CPDFSDK_XFAWidget::IsXFAField() { |
| 2078 return TRUE; | 2077 return TRUE; |
| 2079 } | 2078 } |
| 2080 | 2079 |
| 2081 CFX_ByteString CPDFSDK_XFAWidget::GetType() const { | 2080 CFX_ByteString CPDFSDK_XFAWidget::GetType() const { |
| 2082 return FSDK_XFAWIDGET_TYPENAME; | 2081 return FSDK_XFAWIDGET_TYPENAME; |
| 2083 } | 2082 } |
| 2084 | 2083 |
| 2085 CFX_FloatRect CPDFSDK_XFAWidget::GetRect() const { | 2084 CFX_FloatRect CPDFSDK_XFAWidget::GetRect() const { |
| 2086 CPDFSDK_PageView* pPageView = GetPageView(); | 2085 CPDFSDK_PageView* pPageView = GetPageView(); |
| 2087 CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); | 2086 CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); |
| 2088 CPDFXFA_Document* pDoc = pDocument->GetXFADocument(); | 2087 CPDFXFA_Document* pDoc = pDocument->GetXFADocument(); |
| 2089 IXFA_DocView* pDocView = pDoc->GetXFADocView(); | 2088 IXFA_DocView* pDocView = pDoc->GetXFADocView(); |
| 2090 IXFA_WidgetHandler* pWidgetHandler = pDocView->GetWidgetHandler(); | 2089 IXFA_WidgetHandler* pWidgetHandler = pDocView->GetWidgetHandler(); |
| 2091 | 2090 |
| 2092 CFX_RectF rcBBox; | 2091 CFX_RectF rcBBox; |
| 2093 pWidgetHandler->GetRect(GetXFAWidget(), rcBBox); | 2092 pWidgetHandler->GetRect(GetXFAWidget(), rcBBox); |
| 2094 | 2093 |
| 2095 return CFX_FloatRect(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width, | 2094 return CFX_FloatRect(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width, |
| 2096 rcBBox.top + rcBBox.height); | 2095 rcBBox.top + rcBBox.height); |
| 2097 } | 2096 } |
| 2098 | 2097 |
| 2099 // CPDFSDK_InterForm | |
| 2100 CPDFSDK_InterForm::CPDFSDK_InterForm(CPDFSDK_Document* pDocument) | 2098 CPDFSDK_InterForm::CPDFSDK_InterForm(CPDFSDK_Document* pDocument) |
| 2101 : m_pDocument(pDocument), | 2099 : m_pDocument(pDocument), |
| 2102 m_pInterForm(NULL), | 2100 m_pInterForm(NULL), |
| 2103 m_bCalculate(TRUE), | 2101 m_bCalculate(TRUE), |
| 2104 m_bXfaCalculate(TRUE), | 2102 m_bXfaCalculate(TRUE), |
| 2105 m_bXfaValidationsEnabled(TRUE), | 2103 m_bXfaValidationsEnabled(TRUE), |
| 2106 m_bBusy(FALSE) { | 2104 m_bBusy(FALSE) { |
| 2107 ASSERT(m_pDocument != NULL); | |
| 2108 m_pInterForm = new CPDF_InterForm(m_pDocument->GetPDFDocument(), FALSE); | 2105 m_pInterForm = new CPDF_InterForm(m_pDocument->GetPDFDocument(), FALSE); |
| 2109 m_pInterForm->SetFormNotify(this); | 2106 m_pInterForm->SetFormNotify(this); |
| 2110 | 2107 |
| 2111 for (int i = 0; i < kNumFieldTypes; ++i) | 2108 for (int i = 0; i < kNumFieldTypes; ++i) |
| 2112 m_bNeedHightlight[i] = FALSE; | 2109 m_bNeedHightlight[i] = FALSE; |
| 2113 m_iHighlightAlpha = 0; | 2110 m_iHighlightAlpha = 0; |
| 2114 } | 2111 } |
| 2115 | 2112 |
| 2116 CPDFSDK_InterForm::~CPDFSDK_InterForm() { | 2113 CPDFSDK_InterForm::~CPDFSDK_InterForm() { |
| 2117 delete m_pInterForm; | 2114 delete m_pInterForm; |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2445 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); | 2442 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); |
| 2446 ASSERT(pFormCtrl != NULL); | 2443 ASSERT(pFormCtrl != NULL); |
| 2447 | 2444 |
| 2448 ASSERT(m_pInterForm != NULL); | 2445 ASSERT(m_pInterForm != NULL); |
| 2449 if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) | 2446 if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) |
| 2450 pWidget->ResetAppearance(sValue, bValueChanged); | 2447 pWidget->ResetAppearance(sValue, bValueChanged); |
| 2451 } | 2448 } |
| 2452 } | 2449 } |
| 2453 | 2450 |
| 2454 void CPDFSDK_InterForm::UpdateField(CPDF_FormField* pFormField) { | 2451 void CPDFSDK_InterForm::UpdateField(CPDF_FormField* pFormField) { |
| 2455 ASSERT(pFormField != NULL); | |
| 2456 | |
| 2457 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { | 2452 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { |
| 2458 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); | 2453 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); |
| 2459 ASSERT(pFormCtrl != NULL); | 2454 ASSERT(pFormCtrl != NULL); |
| 2460 | 2455 |
| 2461 if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) { | 2456 if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) { |
| 2462 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | 2457 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); |
| 2463 CFFL_IFormFiller* pIFormFiller = pEnv->GetIFormFiller(); | 2458 CFFL_IFormFiller* pIFormFiller = pEnv->GetIFormFiller(); |
| 2464 | 2459 UnderlyingPageType* pPage = pWidget->GetUnderlyingPage(); |
| 2465 CPDFXFA_Page* pPage = pWidget->GetPDFXFAPage(); | |
| 2466 CPDFSDK_PageView* pPageView = m_pDocument->GetPageView(pPage, FALSE); | 2460 CPDFSDK_PageView* pPageView = m_pDocument->GetPageView(pPage, FALSE); |
| 2467 | |
| 2468 FX_RECT rcBBox = pIFormFiller->GetViewBBox(pPageView, pWidget); | 2461 FX_RECT rcBBox = pIFormFiller->GetViewBBox(pPageView, pWidget); |
| 2469 | 2462 |
| 2470 pEnv->FFI_Invalidate(pPage, rcBBox.left, rcBBox.top, rcBBox.right, | 2463 pEnv->FFI_Invalidate(pPage, rcBBox.left, rcBBox.top, rcBBox.right, |
| 2471 rcBBox.bottom); | 2464 rcBBox.bottom); |
| 2472 } | 2465 } |
| 2473 } | 2466 } |
| 2474 } | 2467 } |
| 2475 | 2468 |
| 2476 void CPDFSDK_InterForm::OnKeyStrokeCommit(CPDF_FormField* pFormField, | 2469 void CPDFSDK_InterForm::OnKeyStrokeCommit(CPDF_FormField* pFormField, |
| 2477 CFX_WideString& csValue, | 2470 CFX_WideString& csValue, |
| (...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3137 break; | 3130 break; |
| 3138 } | 3131 } |
| 3139 } | 3132 } |
| 3140 } | 3133 } |
| 3141 | 3134 |
| 3142 CPDF_Rect CBA_AnnotIterator::GetAnnotRect(CPDFSDK_Annot* pAnnot) { | 3135 CPDF_Rect CBA_AnnotIterator::GetAnnotRect(CPDFSDK_Annot* pAnnot) { |
| 3143 CPDF_Rect rcAnnot; | 3136 CPDF_Rect rcAnnot; |
| 3144 pAnnot->GetPDFAnnot()->GetRect(rcAnnot); | 3137 pAnnot->GetPDFAnnot()->GetRect(rcAnnot); |
| 3145 return rcAnnot; | 3138 return rcAnnot; |
| 3146 } | 3139 } |
| OLD | NEW |