| 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 "fpdfsdk/javascript/Field.h" | 7 #include "fpdfsdk/javascript/Field.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 std::vector<CPDF_FormField*> Field::GetFormFields( | 253 std::vector<CPDF_FormField*> Field::GetFormFields( |
| 254 const CFX_WideString& csFieldName) const { | 254 const CFX_WideString& csFieldName) const { |
| 255 return Field::GetFormFields(m_pDocument, csFieldName); | 255 return Field::GetFormFields(m_pDocument, csFieldName); |
| 256 } | 256 } |
| 257 | 257 |
| 258 void Field::UpdateFormField(CPDFSDK_Document* pDocument, | 258 void Field::UpdateFormField(CPDFSDK_Document* pDocument, |
| 259 CPDF_FormField* pFormField, | 259 CPDF_FormField* pFormField, |
| 260 FX_BOOL bChangeMark, | 260 FX_BOOL bChangeMark, |
| 261 FX_BOOL bResetAP, | 261 FX_BOOL bResetAP, |
| 262 FX_BOOL bRefresh) { | 262 FX_BOOL bRefresh) { |
| 263 std::vector<CPDFSDK_Widget*> widgets; | |
| 264 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); | 263 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); |
| 265 pInterForm->GetWidgets(pFormField, &widgets); | |
| 266 | 264 |
| 267 if (bResetAP) { | 265 if (bResetAP) { |
| 266 std::vector<CPDFSDK_Widget*> widgets; |
| 267 pInterForm->GetWidgets(pFormField, &widgets); |
| 268 |
| 268 int nFieldType = pFormField->GetFieldType(); | 269 int nFieldType = pFormField->GetFieldType(); |
| 269 if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_TEXTFIELD) { | 270 if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_TEXTFIELD) { |
| 270 for (CPDFSDK_Annot* pAnnot : widgets) { | 271 for (CPDFSDK_Annot* pAnnot : widgets) { |
| 271 FX_BOOL bFormatted = FALSE; | 272 FX_BOOL bFormatted = FALSE; |
| 272 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot); | 273 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot); |
| 273 CPDFSDK_Widget::Observer observer(&pAnnot); | 274 CPDFSDK_Widget::Observer observer(&pAnnot); |
| 274 CFX_WideString sValue = pWidget->OnFormat(bFormatted); | 275 CFX_WideString sValue = pWidget->OnFormat(bFormatted); |
| 275 if (pAnnot) { | 276 if (pAnnot) { |
| 276 pWidget->ResetAppearance(bFormatted ? sValue.c_str() : nullptr, | 277 pWidget->ResetAppearance(bFormatted ? sValue.c_str() : nullptr, |
| 277 FALSE); | 278 FALSE); |
| 278 } | 279 } |
| 279 } | 280 } |
| 280 } else { | 281 } else { |
| 281 for (CPDFSDK_Widget* pWidget : widgets) { | 282 for (CPDFSDK_Widget* pWidget : widgets) { |
| 282 pWidget->ResetAppearance(nullptr, FALSE); | 283 pWidget->ResetAppearance(nullptr, FALSE); |
| 283 } | 284 } |
| 284 } | 285 } |
| 285 } | 286 } |
| 286 | 287 |
| 287 if (bRefresh) { | 288 if (bRefresh) { |
| 289 // Refresh the widget list. The calls in |bResetAP| may have caused widgets |
| 290 // to be removed from the list. We need to call |GetWidgets| again to be |
| 291 // sure none of the widgets have been deleted. |
| 292 std::vector<CPDFSDK_Widget*> widgets; |
| 293 pInterForm->GetWidgets(pFormField, &widgets); |
| 294 |
| 288 for (CPDFSDK_Widget* pWidget : widgets) { | 295 for (CPDFSDK_Widget* pWidget : widgets) { |
| 289 CPDFSDK_Document* pDoc = pWidget->GetInterForm()->GetDocument(); | 296 CPDFSDK_Document* pDoc = pWidget->GetInterForm()->GetDocument(); |
| 290 pDoc->UpdateAllViews(nullptr, pWidget); | 297 pDoc->UpdateAllViews(nullptr, pWidget); |
| 291 } | 298 } |
| 292 } | 299 } |
| 293 | 300 |
| 294 if (bChangeMark) | 301 if (bChangeMark) |
| 295 pDocument->SetChangeMark(); | 302 pDocument->SetChangeMark(); |
| 296 } | 303 } |
| 297 | 304 |
| (...skipping 3173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3471 } | 3478 } |
| 3472 } | 3479 } |
| 3473 | 3480 |
| 3474 void Field::AddField(CPDFSDK_Document* pDocument, | 3481 void Field::AddField(CPDFSDK_Document* pDocument, |
| 3475 int nPageIndex, | 3482 int nPageIndex, |
| 3476 int nFieldType, | 3483 int nFieldType, |
| 3477 const CFX_WideString& sName, | 3484 const CFX_WideString& sName, |
| 3478 const CFX_FloatRect& rcCoords) { | 3485 const CFX_FloatRect& rcCoords) { |
| 3479 // Not supported. | 3486 // Not supported. |
| 3480 } | 3487 } |
| OLD | NEW |