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 "Field.h" | 7 #include "Field.h" |
8 | 8 |
9 #include "../../include/fsdk_mgr.h" // For CPDFDoc_Environment. | 9 #include "../../include/fsdk_mgr.h" // For CPDFDoc_Environment. |
10 #include "../../include/javascript/IJavaScript.h" | 10 #include "../../include/javascript/IJavaScript.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 JS_STATIC_METHOD_ENTRY(signatureSign) | 107 JS_STATIC_METHOD_ENTRY(signatureSign) |
108 JS_STATIC_METHOD_ENTRY(signatureValidate) | 108 JS_STATIC_METHOD_ENTRY(signatureValidate) |
109 END_JS_STATIC_METHOD() | 109 END_JS_STATIC_METHOD() |
110 | 110 |
111 IMPLEMENT_JS_CLASS(CJS_Field, Field) | 111 IMPLEMENT_JS_CLASS(CJS_Field, Field) |
112 | 112 |
113 void CJS_Field::InitInstance(IJS_Runtime* pIRuntime) { | 113 void CJS_Field::InitInstance(IJS_Runtime* pIRuntime) { |
114 CJS_Runtime* pRuntime = static_cast<CJS_Runtime*>(pIRuntime); | 114 CJS_Runtime* pRuntime = static_cast<CJS_Runtime*>(pIRuntime); |
115 Field* pField = static_cast<Field*>(GetEmbedObject()); | 115 Field* pField = static_cast<Field*>(GetEmbedObject()); |
116 pField->SetIsolate(pRuntime->GetIsolate()); | 116 pField->SetIsolate(pRuntime->GetIsolate()); |
117 }; | 117 } |
118 | 118 |
119 Field::Field(CJS_Object* pJSObject) | 119 Field::Field(CJS_Object* pJSObject) |
120 : CJS_EmbedObj(pJSObject), | 120 : CJS_EmbedObj(pJSObject), |
121 m_pJSDoc(NULL), | 121 m_pJSDoc(NULL), |
122 m_pDocument(NULL), | 122 m_pDocument(NULL), |
123 m_nFormControlIndex(-1), | 123 m_nFormControlIndex(-1), |
124 m_bCanSet(FALSE), | 124 m_bCanSet(FALSE), |
125 m_bDelay(FALSE), | 125 m_bDelay(FALSE), |
126 m_isolate(NULL) {} | 126 m_isolate(NULL) {} |
127 | 127 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 m_nFormControlIndex = iControlNo; | 186 m_nFormControlIndex = iControlNo; |
187 return TRUE; | 187 return TRUE; |
188 } | 188 } |
189 | 189 |
190 m_FieldName = swFieldNameTemp; | 190 m_FieldName = swFieldNameTemp; |
191 m_nFormControlIndex = -1; | 191 m_nFormControlIndex = -1; |
192 | 192 |
193 return TRUE; | 193 return TRUE; |
194 } | 194 } |
195 | 195 |
196 void Field::GetFormFields(CPDFSDK_Document* pDocument, | 196 std::vector<CPDF_FormField*> Field::GetFormFields( |
197 const CFX_WideString& csFieldName, | 197 CPDFSDK_Document* pDocument, |
198 CFX_PtrArray& FieldArray) { | 198 const CFX_WideString& csFieldName) { |
199 ASSERT(pDocument != NULL); | 199 std::vector<CPDF_FormField*> fields; |
200 | |
201 CPDFSDK_InterForm* pReaderInterForm = pDocument->GetInterForm(); | 200 CPDFSDK_InterForm* pReaderInterForm = pDocument->GetInterForm(); |
202 ASSERT(pReaderInterForm != NULL); | |
203 | |
204 CPDF_InterForm* pInterForm = pReaderInterForm->GetInterForm(); | 201 CPDF_InterForm* pInterForm = pReaderInterForm->GetInterForm(); |
205 ASSERT(pInterForm != NULL); | 202 for (int i = 0, sz = pInterForm->CountFields(csFieldName); i < sz; ++i) { |
206 | |
207 ASSERT(FieldArray.GetSize() == 0); | |
208 | |
209 for (int i = 0, sz = pInterForm->CountFields(csFieldName); i < sz; i++) { | |
210 if (CPDF_FormField* pFormField = pInterForm->GetField(i, csFieldName)) | 203 if (CPDF_FormField* pFormField = pInterForm->GetField(i, csFieldName)) |
211 FieldArray.Add((void*)pFormField); | 204 fields.push_back(pFormField); |
212 } | 205 } |
| 206 return fields; |
213 } | 207 } |
214 | 208 |
215 void Field::GetFormFields(const CFX_WideString& csFieldName, | 209 std::vector<CPDF_FormField*> Field::GetFormFields( |
216 CFX_PtrArray& FieldArray) { | 210 const CFX_WideString& csFieldName) const { |
217 ASSERT(m_pDocument != NULL); | 211 return Field::GetFormFields(m_pDocument, csFieldName); |
218 | |
219 Field::GetFormFields(m_pDocument, csFieldName, FieldArray); | |
220 } | 212 } |
221 | 213 |
222 void Field::UpdateFormField(CPDFSDK_Document* pDocument, | 214 void Field::UpdateFormField(CPDFSDK_Document* pDocument, |
223 CPDF_FormField* pFormField, | 215 CPDF_FormField* pFormField, |
224 FX_BOOL bChangeMark, | 216 FX_BOOL bChangeMark, |
225 FX_BOOL bResetAP, | 217 FX_BOOL bResetAP, |
226 FX_BOOL bRefresh) { | 218 FX_BOOL bRefresh) { |
227 ASSERT(pDocument != NULL); | 219 std::vector<CPDFSDK_Widget*> widgets; |
228 ASSERT(pFormField != NULL); | |
229 | |
230 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); | 220 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); |
231 ASSERT(pInterForm != NULL); | 221 pInterForm->GetWidgets(pFormField, &widgets); |
232 | |
233 CFX_PtrArray widgets; | |
234 pInterForm->GetWidgets(pFormField, widgets); | |
235 | 222 |
236 if (bResetAP) { | 223 if (bResetAP) { |
237 int nFieldType = pFormField->GetFieldType(); | 224 int nFieldType = pFormField->GetFieldType(); |
238 if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_TEXTFIELD) { | 225 if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_TEXTFIELD) { |
239 for (int i = 0, sz = widgets.GetSize(); i < sz; i++) { | 226 for (CPDFSDK_Widget* pWidget : widgets) { |
240 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widgets.GetAt(i); | 227 FX_BOOL bFormatted = FALSE; |
241 ASSERT(pWidget != NULL); | 228 CFX_WideString sValue = pWidget->OnFormat(bFormatted); |
242 | 229 pWidget->ResetAppearance(bFormatted ? sValue.c_str() : nullptr, FALSE); |
243 FX_BOOL bFormated = FALSE; | |
244 CFX_WideString sValue = pWidget->OnFormat(bFormated); | |
245 if (bFormated) | |
246 pWidget->ResetAppearance(sValue.c_str(), FALSE); | |
247 else | |
248 pWidget->ResetAppearance(NULL, FALSE); | |
249 } | 230 } |
250 } else { | 231 } else { |
251 for (int i = 0, sz = widgets.GetSize(); i < sz; i++) { | 232 for (CPDFSDK_Widget* pWidget : widgets) { |
252 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widgets.GetAt(i); | 233 pWidget->ResetAppearance(nullptr, FALSE); |
253 ASSERT(pWidget != NULL); | |
254 | |
255 pWidget->ResetAppearance(NULL, FALSE); | |
256 } | 234 } |
257 } | 235 } |
258 } | 236 } |
259 | 237 |
260 if (bRefresh) { | 238 if (bRefresh) { |
261 for (int i = 0, sz = widgets.GetSize(); i < sz; i++) { | 239 for (CPDFSDK_Widget* pWidget : widgets) { |
262 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widgets.GetAt(i); | 240 CPDFSDK_Document* pDoc = pWidget->GetInterForm()->GetDocument(); |
263 ASSERT(pWidget != NULL); | 241 pDoc->UpdateAllViews(nullptr, pWidget); |
264 | |
265 CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm(); | |
266 CPDFSDK_Document* pDoc = pInterForm->GetDocument(); | |
267 // CReader_Page* pPage = pWidget->GetPage(); | |
268 ASSERT(pDoc != NULL); | |
269 pDoc->UpdateAllViews(NULL, pWidget); | |
270 } | 242 } |
271 } | 243 } |
272 | 244 |
273 if (bChangeMark) | 245 if (bChangeMark) |
274 pDocument->SetChangeMark(); | 246 pDocument->SetChangeMark(); |
275 } | 247 } |
276 | 248 |
277 void Field::UpdateFormControl(CPDFSDK_Document* pDocument, | 249 void Field::UpdateFormControl(CPDFSDK_Document* pDocument, |
278 CPDF_FormControl* pFormControl, | 250 CPDF_FormControl* pFormControl, |
279 FX_BOOL bChangeMark, | 251 FX_BOOL bChangeMark, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 CFX_ByteString alignStr; | 336 CFX_ByteString alignStr; |
365 vp >> alignStr; | 337 vp >> alignStr; |
366 | 338 |
367 if (m_bDelay) { | 339 if (m_bDelay) { |
368 AddDelay_String(FP_ALIGNMENT, alignStr); | 340 AddDelay_String(FP_ALIGNMENT, alignStr); |
369 } else { | 341 } else { |
370 Field::SetAlignment(m_pDocument, m_FieldName, m_nFormControlIndex, | 342 Field::SetAlignment(m_pDocument, m_FieldName, m_nFormControlIndex, |
371 alignStr); | 343 alignStr); |
372 } | 344 } |
373 } else { | 345 } else { |
374 CFX_PtrArray FieldArray; | 346 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
375 GetFormFields(m_FieldName, FieldArray); | 347 if (FieldArray.empty()) |
376 if (FieldArray.GetSize() <= 0) | |
377 return FALSE; | 348 return FALSE; |
378 | 349 |
379 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 350 CPDF_FormField* pFormField = FieldArray[0]; |
380 ASSERT(pFormField != NULL); | |
381 | |
382 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) | 351 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) |
383 return FALSE; | 352 return FALSE; |
384 | 353 |
385 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | 354 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
386 if (!pFormControl) | 355 if (!pFormControl) |
387 return FALSE; | 356 return FALSE; |
388 | 357 |
389 switch (pFormControl->GetControlAlignment()) { | 358 switch (pFormControl->GetControlAlignment()) { |
390 case 1: | 359 case 1: |
391 vp << L"center"; | 360 vp << L"center"; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 CFX_ByteString strType = ""; | 392 CFX_ByteString strType = ""; |
424 vp >> strType; | 393 vp >> strType; |
425 | 394 |
426 if (m_bDelay) { | 395 if (m_bDelay) { |
427 AddDelay_String(FP_BORDERSTYLE, strType); | 396 AddDelay_String(FP_BORDERSTYLE, strType); |
428 } else { | 397 } else { |
429 Field::SetBorderStyle(m_pDocument, m_FieldName, m_nFormControlIndex, | 398 Field::SetBorderStyle(m_pDocument, m_FieldName, m_nFormControlIndex, |
430 strType); | 399 strType); |
431 } | 400 } |
432 } else { | 401 } else { |
433 CFX_PtrArray FieldArray; | 402 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
434 GetFormFields(m_FieldName, FieldArray); | 403 if (FieldArray.empty()) |
435 if (FieldArray.GetSize() <= 0) | |
436 return FALSE; | 404 return FALSE; |
437 | 405 |
438 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 406 CPDF_FormField* pFormField = FieldArray[0]; |
439 if (!pFormField) | 407 if (!pFormField) |
440 return FALSE; | 408 return FALSE; |
441 | 409 |
442 CPDFSDK_Widget* pWidget = | 410 CPDFSDK_Widget* pWidget = |
443 GetWidget(m_pDocument, GetSmartFieldControl(pFormField)); | 411 GetWidget(m_pDocument, GetSmartFieldControl(pFormField)); |
444 if (!pWidget) | 412 if (!pWidget) |
445 return FALSE; | 413 return FALSE; |
446 | 414 |
447 int nBorderstyle = pWidget->GetBorderStyle(); | 415 int nBorderstyle = pWidget->GetBorderStyle(); |
448 | 416 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 nBorderStyle = BBS_BEVELED; | 453 nBorderStyle = BBS_BEVELED; |
486 else if (string == "dashed") | 454 else if (string == "dashed") |
487 nBorderStyle = BBS_DASH; | 455 nBorderStyle = BBS_DASH; |
488 else if (string == "inset") | 456 else if (string == "inset") |
489 nBorderStyle = BBS_INSET; | 457 nBorderStyle = BBS_INSET; |
490 else if (string == "underline") | 458 else if (string == "underline") |
491 nBorderStyle = BBS_UNDERLINE; | 459 nBorderStyle = BBS_UNDERLINE; |
492 else | 460 else |
493 return; | 461 return; |
494 | 462 |
495 CFX_PtrArray FieldArray; | 463 std::vector<CPDF_FormField*> FieldArray = |
496 GetFormFields(pDocument, swFieldName, FieldArray); | 464 GetFormFields(pDocument, swFieldName); |
497 | 465 for (CPDF_FormField* pFormField : FieldArray) { |
498 for (int i = 0, isz = FieldArray.GetSize(); i < isz; i++) { | |
499 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i); | |
500 ASSERT(pFormField != NULL); | |
501 | |
502 if (nControlIndex < 0) { | 466 if (nControlIndex < 0) { |
503 FX_BOOL bSet = FALSE; | 467 FX_BOOL bSet = FALSE; |
504 for (int j = 0, jsz = pFormField->CountControls(); j < jsz; j++) { | 468 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { |
505 if (CPDFSDK_Widget* pWidget = | 469 if (CPDFSDK_Widget* pWidget = |
506 GetWidget(pDocument, pFormField->GetControl(j))) { | 470 GetWidget(pDocument, pFormField->GetControl(i))) { |
507 if (pWidget->GetBorderStyle() != nBorderStyle) { | 471 if (pWidget->GetBorderStyle() != nBorderStyle) { |
508 pWidget->SetBorderStyle(nBorderStyle); | 472 pWidget->SetBorderStyle(nBorderStyle); |
509 bSet = TRUE; | 473 bSet = TRUE; |
510 } | 474 } |
511 } | 475 } |
512 } | 476 } |
513 if (bSet) | 477 if (bSet) |
514 UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE); | 478 UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE); |
515 } else { | 479 } else { |
516 if (nControlIndex >= pFormField->CountControls()) | 480 if (nControlIndex >= pFormField->CountControls()) |
(...skipping 23 matching lines...) Expand all Loading... |
540 int nVP; | 504 int nVP; |
541 vp >> nVP; | 505 vp >> nVP; |
542 | 506 |
543 if (m_bDelay) { | 507 if (m_bDelay) { |
544 AddDelay_Int(FP_BUTTONALIGNX, nVP); | 508 AddDelay_Int(FP_BUTTONALIGNX, nVP); |
545 } else { | 509 } else { |
546 Field::SetButtonAlignX(m_pDocument, m_FieldName, m_nFormControlIndex, | 510 Field::SetButtonAlignX(m_pDocument, m_FieldName, m_nFormControlIndex, |
547 nVP); | 511 nVP); |
548 } | 512 } |
549 } else { | 513 } else { |
550 CFX_PtrArray FieldArray; | 514 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
551 GetFormFields(m_FieldName, FieldArray); | 515 if (FieldArray.empty()) |
552 if (FieldArray.GetSize() <= 0) | |
553 return FALSE; | 516 return FALSE; |
554 | 517 |
555 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 518 CPDF_FormField* pFormField = FieldArray[0]; |
556 ASSERT(pFormField != NULL); | |
557 | |
558 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) | 519 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) |
559 return FALSE; | 520 return FALSE; |
560 | 521 |
561 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | 522 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
562 if (!pFormControl) | 523 if (!pFormControl) |
563 return FALSE; | 524 return FALSE; |
564 | 525 |
565 CPDF_IconFit IconFit = pFormControl->GetIconFit(); | 526 CPDF_IconFit IconFit = pFormControl->GetIconFit(); |
566 | 527 |
567 FX_FLOAT fLeft, fBottom; | 528 FX_FLOAT fLeft, fBottom; |
(...skipping 24 matching lines...) Expand all Loading... |
592 int nVP; | 553 int nVP; |
593 vp >> nVP; | 554 vp >> nVP; |
594 | 555 |
595 if (m_bDelay) { | 556 if (m_bDelay) { |
596 AddDelay_Int(FP_BUTTONALIGNY, nVP); | 557 AddDelay_Int(FP_BUTTONALIGNY, nVP); |
597 } else { | 558 } else { |
598 Field::SetButtonAlignY(m_pDocument, m_FieldName, m_nFormControlIndex, | 559 Field::SetButtonAlignY(m_pDocument, m_FieldName, m_nFormControlIndex, |
599 nVP); | 560 nVP); |
600 } | 561 } |
601 } else { | 562 } else { |
602 CFX_PtrArray FieldArray; | 563 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
603 GetFormFields(m_FieldName, FieldArray); | 564 if (FieldArray.empty()) |
604 if (FieldArray.GetSize() <= 0) | |
605 return FALSE; | 565 return FALSE; |
606 | 566 |
607 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 567 CPDF_FormField* pFormField = FieldArray[0]; |
608 ASSERT(pFormField != NULL); | |
609 | |
610 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) | 568 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) |
611 return FALSE; | 569 return FALSE; |
612 | 570 |
613 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | 571 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
614 if (!pFormControl) | 572 if (!pFormControl) |
615 return FALSE; | 573 return FALSE; |
616 | 574 |
617 CPDF_IconFit IconFit = pFormControl->GetIconFit(); | 575 CPDF_IconFit IconFit = pFormControl->GetIconFit(); |
618 | 576 |
619 FX_FLOAT fLeft, fBottom; | 577 FX_FLOAT fLeft, fBottom; |
(...skipping 24 matching lines...) Expand all Loading... |
644 bool bVP; | 602 bool bVP; |
645 vp >> bVP; | 603 vp >> bVP; |
646 | 604 |
647 if (m_bDelay) { | 605 if (m_bDelay) { |
648 AddDelay_Bool(FP_BUTTONFITBOUNDS, bVP); | 606 AddDelay_Bool(FP_BUTTONFITBOUNDS, bVP); |
649 } else { | 607 } else { |
650 Field::SetButtonFitBounds(m_pDocument, m_FieldName, m_nFormControlIndex, | 608 Field::SetButtonFitBounds(m_pDocument, m_FieldName, m_nFormControlIndex, |
651 bVP); | 609 bVP); |
652 } | 610 } |
653 } else { | 611 } else { |
654 CFX_PtrArray FieldArray; | 612 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
655 GetFormFields(m_FieldName, FieldArray); | 613 if (FieldArray.empty()) |
656 if (FieldArray.GetSize() <= 0) | |
657 return FALSE; | 614 return FALSE; |
658 | 615 |
659 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 616 CPDF_FormField* pFormField = FieldArray[0]; |
660 ASSERT(pFormField != NULL); | |
661 | |
662 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) | 617 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) |
663 return FALSE; | 618 return FALSE; |
664 | 619 |
665 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | 620 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
666 if (!pFormControl) | 621 if (!pFormControl) |
667 return FALSE; | 622 return FALSE; |
668 | 623 |
669 CPDF_IconFit IconFit = pFormControl->GetIconFit(); | 624 CPDF_IconFit IconFit = pFormControl->GetIconFit(); |
670 vp << IconFit.GetFittingBounds(); | 625 vp << IconFit.GetFittingBounds(); |
671 } | 626 } |
(...skipping 20 matching lines...) Expand all Loading... |
692 int nVP; | 647 int nVP; |
693 vp >> nVP; | 648 vp >> nVP; |
694 | 649 |
695 if (m_bDelay) { | 650 if (m_bDelay) { |
696 AddDelay_Int(FP_BUTTONPOSITION, nVP); | 651 AddDelay_Int(FP_BUTTONPOSITION, nVP); |
697 } else { | 652 } else { |
698 Field::SetButtonPosition(m_pDocument, m_FieldName, m_nFormControlIndex, | 653 Field::SetButtonPosition(m_pDocument, m_FieldName, m_nFormControlIndex, |
699 nVP); | 654 nVP); |
700 } | 655 } |
701 } else { | 656 } else { |
702 CFX_PtrArray FieldArray; | 657 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
703 GetFormFields(m_FieldName, FieldArray); | 658 if (FieldArray.empty()) |
704 if (FieldArray.GetSize() <= 0) | |
705 return FALSE; | 659 return FALSE; |
706 | 660 |
707 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 661 CPDF_FormField* pFormField = FieldArray[0]; |
708 ASSERT(pFormField != NULL); | |
709 | |
710 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) | 662 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) |
711 return FALSE; | 663 return FALSE; |
712 | 664 |
713 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | 665 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
714 if (!pFormControl) | 666 if (!pFormControl) |
715 return FALSE; | 667 return FALSE; |
716 | 668 |
717 vp << pFormControl->GetTextPosition(); | 669 vp << pFormControl->GetTextPosition(); |
718 } | 670 } |
719 return TRUE; | 671 return TRUE; |
(...skipping 18 matching lines...) Expand all Loading... |
738 int nVP; | 690 int nVP; |
739 vp >> nVP; | 691 vp >> nVP; |
740 | 692 |
741 if (m_bDelay) { | 693 if (m_bDelay) { |
742 AddDelay_Int(FP_BUTTONSCALEHOW, nVP); | 694 AddDelay_Int(FP_BUTTONSCALEHOW, nVP); |
743 } else { | 695 } else { |
744 Field::SetButtonScaleHow(m_pDocument, m_FieldName, m_nFormControlIndex, | 696 Field::SetButtonScaleHow(m_pDocument, m_FieldName, m_nFormControlIndex, |
745 nVP); | 697 nVP); |
746 } | 698 } |
747 } else { | 699 } else { |
748 CFX_PtrArray FieldArray; | 700 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
749 GetFormFields(m_FieldName, FieldArray); | 701 if (FieldArray.empty()) |
750 if (FieldArray.GetSize() <= 0) | |
751 return FALSE; | 702 return FALSE; |
752 | 703 |
753 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 704 CPDF_FormField* pFormField = FieldArray[0]; |
754 ASSERT(pFormField != NULL); | |
755 | |
756 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) | 705 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) |
757 return FALSE; | 706 return FALSE; |
758 | 707 |
759 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | 708 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
760 if (!pFormControl) | 709 if (!pFormControl) |
761 return FALSE; | 710 return FALSE; |
762 | 711 |
763 CPDF_IconFit IconFit = pFormControl->GetIconFit(); | 712 CPDF_IconFit IconFit = pFormControl->GetIconFit(); |
764 if (IconFit.IsProportionalScale()) | 713 if (IconFit.IsProportionalScale()) |
765 vp << (int32_t)0; | 714 vp << (int32_t)0; |
(...skipping 23 matching lines...) Expand all Loading... |
789 int nVP; | 738 int nVP; |
790 vp >> nVP; | 739 vp >> nVP; |
791 | 740 |
792 if (m_bDelay) { | 741 if (m_bDelay) { |
793 AddDelay_Int(FP_BUTTONSCALEWHEN, nVP); | 742 AddDelay_Int(FP_BUTTONSCALEWHEN, nVP); |
794 } else { | 743 } else { |
795 Field::SetButtonScaleWhen(m_pDocument, m_FieldName, m_nFormControlIndex, | 744 Field::SetButtonScaleWhen(m_pDocument, m_FieldName, m_nFormControlIndex, |
796 nVP); | 745 nVP); |
797 } | 746 } |
798 } else { | 747 } else { |
799 CFX_PtrArray FieldArray; | 748 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
800 GetFormFields(m_FieldName, FieldArray); | 749 if (FieldArray.empty()) |
801 if (FieldArray.GetSize() <= 0) | |
802 return FALSE; | 750 return FALSE; |
803 | 751 |
804 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 752 CPDF_FormField* pFormField = FieldArray[0]; |
805 ASSERT(pFormField != NULL); | |
806 | |
807 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) | 753 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) |
808 return FALSE; | 754 return FALSE; |
809 | 755 |
810 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | 756 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
811 if (!pFormControl) | 757 if (!pFormControl) |
812 return FALSE; | 758 return FALSE; |
813 | 759 |
814 CPDF_IconFit IconFit = pFormControl->GetIconFit(); | 760 CPDF_IconFit IconFit = pFormControl->GetIconFit(); |
815 int ScaleM = IconFit.GetScaleMethod(); | 761 int ScaleM = IconFit.GetScaleMethod(); |
816 switch (ScaleM) { | 762 switch (ScaleM) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 int nVP; | 797 int nVP; |
852 vp >> nVP; | 798 vp >> nVP; |
853 | 799 |
854 if (m_bDelay) { | 800 if (m_bDelay) { |
855 AddDelay_Int(FP_CALCORDERINDEX, nVP); | 801 AddDelay_Int(FP_CALCORDERINDEX, nVP); |
856 } else { | 802 } else { |
857 Field::SetCalcOrderIndex(m_pDocument, m_FieldName, m_nFormControlIndex, | 803 Field::SetCalcOrderIndex(m_pDocument, m_FieldName, m_nFormControlIndex, |
858 nVP); | 804 nVP); |
859 } | 805 } |
860 } else { | 806 } else { |
861 CFX_PtrArray FieldArray; | 807 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
862 GetFormFields(m_FieldName, FieldArray); | 808 if (FieldArray.empty()) |
863 if (FieldArray.GetSize() <= 0) | |
864 return FALSE; | 809 return FALSE; |
865 | 810 |
866 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 811 CPDF_FormField* pFormField = FieldArray[0]; |
867 ASSERT(pFormField != NULL); | |
868 | |
869 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && | 812 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && |
870 pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) | 813 pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) { |
871 return FALSE; | 814 return FALSE; |
| 815 } |
872 | 816 |
873 CPDFSDK_InterForm* pRDInterForm = m_pDocument->GetInterForm(); | 817 CPDFSDK_InterForm* pRDInterForm = m_pDocument->GetInterForm(); |
874 ASSERT(pRDInterForm != NULL); | 818 ASSERT(pRDInterForm != NULL); |
875 | 819 |
876 CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm(); | 820 CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm(); |
877 ASSERT(pInterForm != NULL); | 821 ASSERT(pInterForm != NULL); |
878 | 822 |
879 vp << (int32_t)pInterForm->FindFieldInCalculationOrder(pFormField); | 823 vp << (int32_t)pInterForm->FindFieldInCalculationOrder(pFormField); |
880 } | 824 } |
881 | 825 |
(...skipping 18 matching lines...) Expand all Loading... |
900 | 844 |
901 int nVP; | 845 int nVP; |
902 vp >> nVP; | 846 vp >> nVP; |
903 | 847 |
904 if (m_bDelay) { | 848 if (m_bDelay) { |
905 AddDelay_Int(FP_CHARLIMIT, nVP); | 849 AddDelay_Int(FP_CHARLIMIT, nVP); |
906 } else { | 850 } else { |
907 Field::SetCharLimit(m_pDocument, m_FieldName, m_nFormControlIndex, nVP); | 851 Field::SetCharLimit(m_pDocument, m_FieldName, m_nFormControlIndex, nVP); |
908 } | 852 } |
909 } else { | 853 } else { |
910 CFX_PtrArray FieldArray; | 854 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
911 GetFormFields(m_FieldName, FieldArray); | 855 if (FieldArray.empty()) |
912 if (FieldArray.GetSize() <= 0) | |
913 return FALSE; | 856 return FALSE; |
914 | 857 |
915 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 858 CPDF_FormField* pFormField = FieldArray[0]; |
916 ASSERT(pFormField != NULL); | |
917 | |
918 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) | 859 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) |
919 return FALSE; | 860 return FALSE; |
920 | 861 |
921 vp << (int32_t)pFormField->GetMaxLen(); | 862 vp << (int32_t)pFormField->GetMaxLen(); |
922 } | 863 } |
923 return TRUE; | 864 return TRUE; |
924 } | 865 } |
925 | 866 |
926 void Field::SetCharLimit(CPDFSDK_Document* pDocument, | 867 void Field::SetCharLimit(CPDFSDK_Document* pDocument, |
927 const CFX_WideString& swFieldName, | 868 const CFX_WideString& swFieldName, |
(...skipping 13 matching lines...) Expand all Loading... |
941 | 882 |
942 bool bVP; | 883 bool bVP; |
943 vp >> bVP; | 884 vp >> bVP; |
944 | 885 |
945 if (m_bDelay) { | 886 if (m_bDelay) { |
946 AddDelay_Bool(FP_COMB, bVP); | 887 AddDelay_Bool(FP_COMB, bVP); |
947 } else { | 888 } else { |
948 Field::SetComb(m_pDocument, m_FieldName, m_nFormControlIndex, bVP); | 889 Field::SetComb(m_pDocument, m_FieldName, m_nFormControlIndex, bVP); |
949 } | 890 } |
950 } else { | 891 } else { |
951 CFX_PtrArray FieldArray; | 892 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
952 GetFormFields(m_FieldName, FieldArray); | 893 if (FieldArray.empty()) |
953 if (FieldArray.GetSize() <= 0) | |
954 return FALSE; | 894 return FALSE; |
955 | 895 |
956 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 896 CPDF_FormField* pFormField = FieldArray[0]; |
957 ASSERT(pFormField != NULL); | |
958 | |
959 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) | 897 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) |
960 return FALSE; | 898 return FALSE; |
961 | 899 |
962 if (pFormField->GetFieldFlags() & FIELDFLAG_COMB) | 900 if (pFormField->GetFieldFlags() & FIELDFLAG_COMB) |
963 vp << true; | 901 vp << true; |
964 else | 902 else |
965 vp << false; | 903 vp << false; |
966 } | 904 } |
967 | 905 |
968 return TRUE; | 906 return TRUE; |
(...skipping 18 matching lines...) Expand all Loading... |
987 bool bVP; | 925 bool bVP; |
988 vp >> bVP; | 926 vp >> bVP; |
989 | 927 |
990 if (m_bDelay) { | 928 if (m_bDelay) { |
991 AddDelay_Bool(FP_COMMITONSELCHANGE, bVP); | 929 AddDelay_Bool(FP_COMMITONSELCHANGE, bVP); |
992 } else { | 930 } else { |
993 Field::SetCommitOnSelChange(m_pDocument, m_FieldName, m_nFormControlIndex, | 931 Field::SetCommitOnSelChange(m_pDocument, m_FieldName, m_nFormControlIndex, |
994 bVP); | 932 bVP); |
995 } | 933 } |
996 } else { | 934 } else { |
997 CFX_PtrArray FieldArray; | 935 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
998 GetFormFields(m_FieldName, FieldArray); | 936 if (FieldArray.empty()) |
999 if (FieldArray.GetSize() <= 0) | |
1000 return FALSE; | 937 return FALSE; |
1001 | 938 |
1002 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 939 CPDF_FormField* pFormField = FieldArray[0]; |
1003 ASSERT(pFormField != NULL); | |
1004 | |
1005 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && | 940 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && |
1006 pFormField->GetFieldType() != FIELDTYPE_LISTBOX) | 941 pFormField->GetFieldType() != FIELDTYPE_LISTBOX) { |
1007 return FALSE; | 942 return FALSE; |
| 943 } |
1008 | 944 |
1009 if (pFormField->GetFieldFlags() & FIELDFLAG_COMMITONSELCHANGE) | 945 if (pFormField->GetFieldFlags() & FIELDFLAG_COMMITONSELCHANGE) |
1010 vp << true; | 946 vp << true; |
1011 else | 947 else |
1012 vp << false; | 948 vp << false; |
1013 } | 949 } |
1014 | 950 |
1015 return TRUE; | 951 return TRUE; |
1016 } | 952 } |
1017 | 953 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1049 } | 985 } |
1050 } | 986 } |
1051 | 987 |
1052 if (m_bDelay) { | 988 if (m_bDelay) { |
1053 AddDelay_WordArray(FP_CURRENTVALUEINDICES, array); | 989 AddDelay_WordArray(FP_CURRENTVALUEINDICES, array); |
1054 } else { | 990 } else { |
1055 Field::SetCurrentValueIndices(m_pDocument, m_FieldName, | 991 Field::SetCurrentValueIndices(m_pDocument, m_FieldName, |
1056 m_nFormControlIndex, array); | 992 m_nFormControlIndex, array); |
1057 } | 993 } |
1058 } else { | 994 } else { |
1059 CFX_PtrArray FieldArray; | 995 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
1060 GetFormFields(m_FieldName, FieldArray); | 996 if (FieldArray.empty()) |
1061 if (FieldArray.GetSize() <= 0) | |
1062 return FALSE; | 997 return FALSE; |
1063 | 998 |
1064 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 999 CPDF_FormField* pFormField = FieldArray[0]; |
1065 ASSERT(pFormField != NULL); | 1000 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && |
| 1001 pFormField->GetFieldType() != FIELDTYPE_LISTBOX) { |
| 1002 return FALSE; |
| 1003 } |
1066 | 1004 |
1067 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && | 1005 if (pFormField->CountSelectedItems() == 1) { |
1068 pFormField->GetFieldType() != FIELDTYPE_LISTBOX) | |
1069 return FALSE; | |
1070 | |
1071 if (pFormField->CountSelectedItems() == 1) | |
1072 vp << pFormField->GetSelectedIndex(0); | 1006 vp << pFormField->GetSelectedIndex(0); |
1073 else if (pFormField->CountSelectedItems() > 1) { | 1007 } else if (pFormField->CountSelectedItems() > 1) { |
1074 CJS_Array SelArray(pRuntime); | 1008 CJS_Array SelArray(pRuntime); |
1075 for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) { | 1009 for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) { |
1076 SelArray.SetElement( | 1010 SelArray.SetElement( |
1077 i, CJS_Value(pRuntime, pFormField->GetSelectedIndex(i))); | 1011 i, CJS_Value(pRuntime, pFormField->GetSelectedIndex(i))); |
1078 } | 1012 } |
1079 vp << SelArray; | 1013 vp << SelArray; |
1080 } else | 1014 } else { |
1081 vp << -1; | 1015 vp << -1; |
| 1016 } |
1082 } | 1017 } |
1083 | 1018 |
1084 return TRUE; | 1019 return TRUE; |
1085 } | 1020 } |
1086 | 1021 |
1087 void Field::SetCurrentValueIndices(CPDFSDK_Document* pDocument, | 1022 void Field::SetCurrentValueIndices(CPDFSDK_Document* pDocument, |
1088 const CFX_WideString& swFieldName, | 1023 const CFX_WideString& swFieldName, |
1089 int nControlIndex, | 1024 int nControlIndex, |
1090 const CFX_DWordArray& array) { | 1025 const CFX_DWordArray& array) { |
1091 ASSERT(pDocument != NULL); | 1026 ASSERT(pDocument != NULL); |
1092 | 1027 |
1093 CFX_PtrArray FieldArray; | 1028 std::vector<CPDF_FormField*> FieldArray = |
1094 GetFormFields(pDocument, swFieldName, FieldArray); | 1029 GetFormFields(pDocument, swFieldName); |
1095 | 1030 for (CPDF_FormField* pFormField : FieldArray) { |
1096 for (int i = 0, isz = FieldArray.GetSize(); i < isz; i++) { | |
1097 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i); | |
1098 ASSERT(pFormField != NULL); | |
1099 | |
1100 int nFieldType = pFormField->GetFieldType(); | 1031 int nFieldType = pFormField->GetFieldType(); |
1101 if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_LISTBOX) { | 1032 if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_LISTBOX) { |
1102 FX_DWORD dwFieldFlags = pFormField->GetFieldFlags(); | 1033 FX_DWORD dwFieldFlags = pFormField->GetFieldFlags(); |
1103 pFormField->ClearSelection(TRUE); | 1034 pFormField->ClearSelection(TRUE); |
1104 | 1035 |
1105 for (int i = 0, sz = array.GetSize(); i < sz; i++) { | 1036 for (int i = 0, sz = array.GetSize(); i < sz; i++) { |
1106 if (i > 0 && !(dwFieldFlags & (1 << 21))) { | 1037 if (i > 0 && !(dwFieldFlags & (1 << 21))) { |
1107 break; | 1038 break; |
1108 } | 1039 } |
1109 | 1040 |
1110 int iSelecting = (int32_t)array.GetAt(i); | 1041 int iSelecting = (int32_t)array.GetAt(i); |
1111 if (iSelecting < pFormField->CountOptions() && | 1042 if (iSelecting < pFormField->CountOptions() && |
1112 !pFormField->IsItemSelected(iSelecting)) | 1043 !pFormField->IsItemSelected(iSelecting)) |
1113 pFormField->SetItemSelection(iSelecting, TRUE); | 1044 pFormField->SetItemSelection(iSelecting, TRUE); |
1114 } | 1045 } |
1115 UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE); | 1046 UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE); |
1116 } | 1047 } |
1117 } | 1048 } |
1118 } | 1049 } |
1119 | 1050 |
1120 FX_BOOL Field::defaultStyle(IJS_Context* cc, | 1051 FX_BOOL Field::defaultStyle(IJS_Context* cc, |
1121 CJS_PropValue& vp, | 1052 CJS_PropValue& vp, |
1122 CFX_WideString& sError) { | 1053 CFX_WideString& sError) { |
1123 // MQG sError = JSGetStringFromID(IDS_STRING_NOTSUPPORT); | |
1124 return FALSE; | 1054 return FALSE; |
1125 | |
1126 if (vp.IsSetting()) { | |
1127 if (!m_bCanSet) | |
1128 return FALSE; | |
1129 | |
1130 ; | |
1131 } else { | |
1132 ; | |
1133 } | |
1134 return TRUE; | |
1135 } | 1055 } |
1136 | 1056 |
1137 void Field::SetDefaultStyle(CPDFSDK_Document* pDocument, | 1057 void Field::SetDefaultStyle(CPDFSDK_Document* pDocument, |
1138 const CFX_WideString& swFieldName, | 1058 const CFX_WideString& swFieldName, |
1139 int nControlIndex) { | 1059 int nControlIndex) { |
1140 // Not supported. | 1060 // Not supported. |
1141 } | 1061 } |
1142 | 1062 |
1143 FX_BOOL Field::defaultValue(IJS_Context* cc, | 1063 FX_BOOL Field::defaultValue(IJS_Context* cc, |
1144 CJS_PropValue& vp, | 1064 CJS_PropValue& vp, |
1145 CFX_WideString& sError) { | 1065 CFX_WideString& sError) { |
1146 ASSERT(m_pDocument != NULL); | 1066 ASSERT(m_pDocument != NULL); |
1147 | 1067 |
1148 if (vp.IsSetting()) { | 1068 if (vp.IsSetting()) { |
1149 if (!m_bCanSet) | 1069 if (!m_bCanSet) |
1150 return FALSE; | 1070 return FALSE; |
1151 | 1071 |
1152 CFX_WideString WideStr; | 1072 CFX_WideString WideStr; |
1153 vp >> WideStr; | 1073 vp >> WideStr; |
1154 | 1074 |
1155 if (m_bDelay) { | 1075 if (m_bDelay) { |
1156 AddDelay_WideString(FP_DEFAULTVALUE, WideStr); | 1076 AddDelay_WideString(FP_DEFAULTVALUE, WideStr); |
1157 } else { | 1077 } else { |
1158 Field::SetDefaultValue(m_pDocument, m_FieldName, m_nFormControlIndex, | 1078 Field::SetDefaultValue(m_pDocument, m_FieldName, m_nFormControlIndex, |
1159 WideStr); | 1079 WideStr); |
1160 } | 1080 } |
1161 } else { | 1081 } else { |
1162 CFX_PtrArray FieldArray; | 1082 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
1163 GetFormFields(m_FieldName, FieldArray); | 1083 if (FieldArray.empty()) |
1164 if (FieldArray.GetSize() <= 0) | |
1165 return FALSE; | 1084 return FALSE; |
1166 | 1085 |
1167 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 1086 CPDF_FormField* pFormField = FieldArray[0]; |
1168 ASSERT(pFormField != NULL); | |
1169 | |
1170 if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON || | 1087 if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON || |
1171 pFormField->GetFieldType() == FIELDTYPE_SIGNATURE) | 1088 pFormField->GetFieldType() == FIELDTYPE_SIGNATURE) { |
1172 return FALSE; | 1089 return FALSE; |
| 1090 } |
1173 | 1091 |
1174 vp << pFormField->GetDefaultValue(); | 1092 vp << pFormField->GetDefaultValue(); |
1175 } | 1093 } |
1176 return TRUE; | 1094 return TRUE; |
1177 } | 1095 } |
1178 | 1096 |
1179 void Field::SetDefaultValue(CPDFSDK_Document* pDocument, | 1097 void Field::SetDefaultValue(CPDFSDK_Document* pDocument, |
1180 const CFX_WideString& swFieldName, | 1098 const CFX_WideString& swFieldName, |
1181 int nControlIndex, | 1099 int nControlIndex, |
1182 const CFX_WideString& string) { | 1100 const CFX_WideString& string) { |
(...skipping 11 matching lines...) Expand all Loading... |
1194 | 1112 |
1195 bool bVP; | 1113 bool bVP; |
1196 vp >> bVP; | 1114 vp >> bVP; |
1197 | 1115 |
1198 if (m_bDelay) { | 1116 if (m_bDelay) { |
1199 AddDelay_Bool(FP_DONOTSCROLL, bVP); | 1117 AddDelay_Bool(FP_DONOTSCROLL, bVP); |
1200 } else { | 1118 } else { |
1201 Field::SetDoNotScroll(m_pDocument, m_FieldName, m_nFormControlIndex, bVP); | 1119 Field::SetDoNotScroll(m_pDocument, m_FieldName, m_nFormControlIndex, bVP); |
1202 } | 1120 } |
1203 } else { | 1121 } else { |
1204 CFX_PtrArray FieldArray; | 1122 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
1205 GetFormFields(m_FieldName, FieldArray); | 1123 if (FieldArray.empty()) |
1206 if (FieldArray.GetSize() <= 0) | |
1207 return FALSE; | 1124 return FALSE; |
1208 | 1125 |
1209 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 1126 CPDF_FormField* pFormField = FieldArray[0]; |
1210 ASSERT(pFormField != NULL); | |
1211 | |
1212 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) | 1127 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) |
1213 return FALSE; | 1128 return FALSE; |
1214 | 1129 |
1215 if (pFormField->GetFieldFlags() & FIELDFLAG_DONOTSCROLL) | 1130 if (pFormField->GetFieldFlags() & FIELDFLAG_DONOTSCROLL) |
1216 vp << true; | 1131 vp << true; |
1217 else | 1132 else |
1218 vp << false; | 1133 vp << false; |
1219 } | 1134 } |
1220 | 1135 |
1221 return TRUE; | 1136 return TRUE; |
(...skipping 11 matching lines...) Expand all Loading... |
1233 CFX_WideString& sError) { | 1148 CFX_WideString& sError) { |
1234 ASSERT(m_pDocument != NULL); | 1149 ASSERT(m_pDocument != NULL); |
1235 | 1150 |
1236 if (vp.IsSetting()) { | 1151 if (vp.IsSetting()) { |
1237 if (!m_bCanSet) | 1152 if (!m_bCanSet) |
1238 return FALSE; | 1153 return FALSE; |
1239 | 1154 |
1240 bool bVP; | 1155 bool bVP; |
1241 vp >> bVP; | 1156 vp >> bVP; |
1242 } else { | 1157 } else { |
1243 CFX_PtrArray FieldArray; | 1158 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
1244 GetFormFields(m_FieldName, FieldArray); | 1159 if (FieldArray.empty()) |
1245 if (FieldArray.GetSize() <= 0) | |
1246 return FALSE; | 1160 return FALSE; |
1247 | 1161 |
1248 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 1162 CPDF_FormField* pFormField = FieldArray[0]; |
1249 ASSERT(pFormField != NULL); | |
1250 | |
1251 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD && | 1163 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD && |
1252 pFormField->GetFieldType() != FIELDTYPE_COMBOBOX) | 1164 pFormField->GetFieldType() != FIELDTYPE_COMBOBOX) { |
1253 return FALSE; | 1165 return FALSE; |
| 1166 } |
1254 | 1167 |
1255 if (pFormField->GetFieldFlags() & FIELDFLAG_DONOTSPELLCHECK) | 1168 if (pFormField->GetFieldFlags() & FIELDFLAG_DONOTSPELLCHECK) |
1256 vp << true; | 1169 vp << true; |
1257 else | 1170 else |
1258 vp << false; | 1171 vp << false; |
1259 } | 1172 } |
1260 | 1173 |
1261 return TRUE; | 1174 return TRUE; |
1262 } | 1175 } |
1263 | 1176 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1298 | 1211 |
1299 int nVP; | 1212 int nVP; |
1300 vp >> nVP; | 1213 vp >> nVP; |
1301 | 1214 |
1302 if (m_bDelay) { | 1215 if (m_bDelay) { |
1303 AddDelay_Int(FP_DISPLAY, nVP); | 1216 AddDelay_Int(FP_DISPLAY, nVP); |
1304 } else { | 1217 } else { |
1305 Field::SetDisplay(m_pDocument, m_FieldName, m_nFormControlIndex, nVP); | 1218 Field::SetDisplay(m_pDocument, m_FieldName, m_nFormControlIndex, nVP); |
1306 } | 1219 } |
1307 } else { | 1220 } else { |
1308 CFX_PtrArray FieldArray; | 1221 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
1309 GetFormFields(m_FieldName, FieldArray); | 1222 if (FieldArray.empty()) |
1310 if (FieldArray.GetSize() <= 0) | |
1311 return FALSE; | 1223 return FALSE; |
1312 | 1224 |
1313 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 1225 CPDF_FormField* pFormField = FieldArray[0]; |
1314 ASSERT(pFormField != NULL); | 1226 ASSERT(pFormField); |
1315 | |
1316 CPDFSDK_InterForm* pInterForm = | 1227 CPDFSDK_InterForm* pInterForm = |
1317 (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); | 1228 (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); |
1318 ASSERT(pInterForm != NULL); | |
1319 | |
1320 CPDFSDK_Widget* pWidget = | 1229 CPDFSDK_Widget* pWidget = |
1321 pInterForm->GetWidget(GetSmartFieldControl(pFormField)); | 1230 pInterForm->GetWidget(GetSmartFieldControl(pFormField)); |
1322 if (!pWidget) | 1231 if (!pWidget) |
1323 return FALSE; | 1232 return FALSE; |
1324 | 1233 |
1325 FX_DWORD dwFlag = pWidget->GetFlags(); | 1234 FX_DWORD dwFlag = pWidget->GetFlags(); |
1326 | 1235 |
1327 if (ANNOTFLAG_INVISIBLE & dwFlag || ANNOTFLAG_HIDDEN & dwFlag) { | 1236 if (ANNOTFLAG_INVISIBLE & dwFlag || ANNOTFLAG_HIDDEN & dwFlag) { |
1328 vp << (int32_t)1; | 1237 vp << (int32_t)1; |
1329 } else { | 1238 } else { |
(...skipping 14 matching lines...) Expand all Loading... |
1344 | 1253 |
1345 void Field::SetDisplay(CPDFSDK_Document* pDocument, | 1254 void Field::SetDisplay(CPDFSDK_Document* pDocument, |
1346 const CFX_WideString& swFieldName, | 1255 const CFX_WideString& swFieldName, |
1347 int nControlIndex, | 1256 int nControlIndex, |
1348 int number) { | 1257 int number) { |
1349 ASSERT(pDocument != NULL); | 1258 ASSERT(pDocument != NULL); |
1350 | 1259 |
1351 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); | 1260 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); |
1352 ASSERT(pInterForm != NULL); | 1261 ASSERT(pInterForm != NULL); |
1353 | 1262 |
1354 CFX_PtrArray FieldArray; | 1263 std::vector<CPDF_FormField*> FieldArray = |
1355 GetFormFields(pDocument, swFieldName, FieldArray); | 1264 GetFormFields(pDocument, swFieldName); |
1356 | 1265 for (CPDF_FormField* pFormField : FieldArray) { |
1357 for (int i = 0, isz = FieldArray.GetSize(); i < isz; i++) { | |
1358 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i); | |
1359 ASSERT(pFormField != NULL); | |
1360 | |
1361 if (nControlIndex < 0) { | 1266 if (nControlIndex < 0) { |
1362 FX_BOOL bSet = FALSE; | 1267 FX_BOOL bSet = FALSE; |
1363 for (int j = 0, jsz = pFormField->CountControls(); j < jsz; j++) { | 1268 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { |
1364 CPDF_FormControl* pFormControl = pFormField->GetControl(j); | 1269 CPDF_FormControl* pFormControl = pFormField->GetControl(i); |
1365 ASSERT(pFormControl != NULL); | 1270 ASSERT(pFormControl != NULL); |
1366 | 1271 |
1367 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) { | 1272 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) { |
1368 FX_DWORD dwFlag = pWidget->GetFlags(); | 1273 FX_DWORD dwFlag = pWidget->GetFlags(); |
1369 switch (number) { | 1274 switch (number) { |
1370 case 0: | 1275 case 0: |
1371 dwFlag &= (~ANNOTFLAG_INVISIBLE); | 1276 dwFlag &= (~ANNOTFLAG_INVISIBLE); |
1372 dwFlag &= (~ANNOTFLAG_HIDDEN); | 1277 dwFlag &= (~ANNOTFLAG_HIDDEN); |
1373 dwFlag &= (~ANNOTFLAG_NOVIEW); | 1278 dwFlag &= (~ANNOTFLAG_NOVIEW); |
1374 dwFlag |= ANNOTFLAG_PRINT; | 1279 dwFlag |= ANNOTFLAG_PRINT; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1453 CJS_PropValue& vp, | 1358 CJS_PropValue& vp, |
1454 CFX_WideString& sError) { | 1359 CFX_WideString& sError) { |
1455 ASSERT(m_pDocument != NULL); | 1360 ASSERT(m_pDocument != NULL); |
1456 if (vp.IsSetting()) { | 1361 if (vp.IsSetting()) { |
1457 if (!m_bCanSet) | 1362 if (!m_bCanSet) |
1458 return FALSE; | 1363 return FALSE; |
1459 | 1364 |
1460 bool bVP; | 1365 bool bVP; |
1461 vp >> bVP; | 1366 vp >> bVP; |
1462 } else { | 1367 } else { |
1463 CFX_PtrArray FieldArray; | 1368 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
1464 GetFormFields(m_FieldName, FieldArray); | 1369 if (FieldArray.empty()) |
1465 if (FieldArray.GetSize() <= 0) | |
1466 return FALSE; | 1370 return FALSE; |
1467 | 1371 |
1468 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 1372 CPDF_FormField* pFormField = FieldArray[0]; |
1469 ASSERT(pFormField != NULL); | |
1470 | |
1471 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX) | 1373 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX) |
1472 return FALSE; | 1374 return FALSE; |
1473 | 1375 |
1474 if (pFormField->GetFieldFlags() & FIELDFLAG_EDIT) | 1376 if (pFormField->GetFieldFlags() & FIELDFLAG_EDIT) |
1475 vp << true; | 1377 vp << true; |
1476 else | 1378 else |
1477 vp << false; | 1379 vp << false; |
1478 } | 1380 } |
1479 | 1381 |
1480 return TRUE; | 1382 return TRUE; |
1481 } | 1383 } |
1482 | 1384 |
1483 FX_BOOL Field::exportValues(IJS_Context* cc, | 1385 FX_BOOL Field::exportValues(IJS_Context* cc, |
1484 CJS_PropValue& vp, | 1386 CJS_PropValue& vp, |
1485 CFX_WideString& sError) { | 1387 CFX_WideString& sError) { |
1486 CFX_PtrArray FieldArray; | 1388 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
1487 GetFormFields(m_FieldName, FieldArray); | 1389 if (FieldArray.empty()) |
1488 if (FieldArray.GetSize() <= 0) | |
1489 return FALSE; | 1390 return FALSE; |
1490 | 1391 |
1491 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 1392 CPDF_FormField* pFormField = FieldArray[0]; |
1492 if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX && | 1393 if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX && |
1493 pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON) | 1394 pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON) { |
1494 return FALSE; | 1395 return FALSE; |
| 1396 } |
1495 | 1397 |
1496 if (vp.IsSetting()) { | 1398 if (vp.IsSetting()) { |
1497 if (!m_bCanSet) | 1399 if (!m_bCanSet) |
1498 return FALSE; | 1400 return FALSE; |
1499 | 1401 |
1500 if (!vp.IsArrayObject()) | 1402 if (!vp.IsArrayObject()) |
1501 return FALSE; | 1403 return FALSE; |
1502 } else { | 1404 } else { |
1503 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); | 1405 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
1504 CJS_Array ExportValusArray(pRuntime); | 1406 CJS_Array ExportValusArray(pRuntime); |
(...skipping 18 matching lines...) Expand all Loading... |
1523 vp << ExportValusArray; | 1425 vp << ExportValusArray; |
1524 } | 1426 } |
1525 return TRUE; | 1427 return TRUE; |
1526 } | 1428 } |
1527 | 1429 |
1528 FX_BOOL Field::fileSelect(IJS_Context* cc, | 1430 FX_BOOL Field::fileSelect(IJS_Context* cc, |
1529 CJS_PropValue& vp, | 1431 CJS_PropValue& vp, |
1530 CFX_WideString& sError) { | 1432 CFX_WideString& sError) { |
1531 ASSERT(m_pDocument != NULL); | 1433 ASSERT(m_pDocument != NULL); |
1532 | 1434 |
1533 CFX_PtrArray FieldArray; | 1435 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
1534 GetFormFields(m_FieldName, FieldArray); | 1436 if (FieldArray.empty()) |
1535 if (FieldArray.GetSize() <= 0) | |
1536 return FALSE; | 1437 return FALSE; |
1537 | 1438 |
1538 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 1439 CPDF_FormField* pFormField = FieldArray[0]; |
1539 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) | 1440 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) |
1540 return FALSE; | 1441 return FALSE; |
1541 | 1442 |
1542 if (vp.IsSetting()) { | 1443 if (vp.IsSetting()) { |
1543 if (!m_bCanSet) | 1444 if (!m_bCanSet) |
1544 return FALSE; | 1445 return FALSE; |
1545 | 1446 |
1546 bool bVP; | 1447 bool bVP; |
1547 vp >> bVP; | 1448 vp >> bVP; |
1548 } else { | 1449 } else { |
1549 if (pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT) | 1450 if (pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT) |
1550 vp << true; | 1451 vp << true; |
1551 else | 1452 else |
1552 vp << false; | 1453 vp << false; |
1553 } | 1454 } |
1554 return TRUE; | 1455 return TRUE; |
1555 } | 1456 } |
1556 | 1457 |
1557 FX_BOOL Field::fillColor(IJS_Context* cc, | 1458 FX_BOOL Field::fillColor(IJS_Context* cc, |
1558 CJS_PropValue& vp, | 1459 CJS_PropValue& vp, |
1559 CFX_WideString& sError) { | 1460 CFX_WideString& sError) { |
1560 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); | 1461 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
1561 CJS_Array crArray(pRuntime); | 1462 CJS_Array crArray(pRuntime); |
1562 CFX_PtrArray FieldArray; | 1463 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
1563 GetFormFields(m_FieldName, FieldArray); | 1464 if (FieldArray.empty()) |
1564 if (FieldArray.GetSize() <= 0) | |
1565 return FALSE; | 1465 return FALSE; |
1566 | 1466 |
1567 if (vp.IsSetting()) { | 1467 if (vp.IsSetting()) { |
1568 if (!m_bCanSet) | 1468 if (!m_bCanSet) |
1569 return FALSE; | 1469 return FALSE; |
1570 | 1470 |
1571 if (!vp.IsArrayObject()) | 1471 if (!vp.IsArrayObject()) |
1572 return FALSE; | 1472 return FALSE; |
1573 | 1473 |
1574 vp >> crArray; | 1474 vp >> crArray; |
1575 | 1475 |
1576 CPWL_Color color; | 1476 CPWL_Color color; |
1577 color::ConvertArrayToPWLColor(crArray, color); | 1477 color::ConvertArrayToPWLColor(crArray, color); |
1578 if (m_bDelay) { | 1478 if (m_bDelay) { |
1579 AddDelay_Color(FP_FILLCOLOR, color); | 1479 AddDelay_Color(FP_FILLCOLOR, color); |
1580 } else { | 1480 } else { |
1581 Field::SetFillColor(m_pDocument, m_FieldName, m_nFormControlIndex, color); | 1481 Field::SetFillColor(m_pDocument, m_FieldName, m_nFormControlIndex, color); |
1582 } | 1482 } |
1583 } else { | 1483 } else { |
1584 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 1484 CPDF_FormField* pFormField = FieldArray[0]; |
1585 ASSERT(pFormField != NULL); | 1485 ASSERT(pFormField); |
1586 | |
1587 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | 1486 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
1588 if (!pFormControl) | 1487 if (!pFormControl) |
1589 return FALSE; | 1488 return FALSE; |
1590 | 1489 |
1591 int iColorType; | 1490 int iColorType; |
1592 pFormControl->GetBackgroundColor(iColorType); | 1491 pFormControl->GetBackgroundColor(iColorType); |
1593 | 1492 |
1594 CPWL_Color color; | 1493 CPWL_Color color; |
1595 if (iColorType == COLORTYPE_TRANSPARENT) { | 1494 if (iColorType == COLORTYPE_TRANSPARENT) { |
1596 color = CPWL_Color(COLORTYPE_TRANSPARENT); | 1495 color = CPWL_Color(COLORTYPE_TRANSPARENT); |
1597 } else if (iColorType == COLORTYPE_GRAY) { | 1496 } else if (iColorType == COLORTYPE_GRAY) { |
1598 color = CPWL_Color(COLORTYPE_GRAY, | 1497 color = CPWL_Color(COLORTYPE_GRAY, |
1599 pFormControl->GetOriginalBackgroundColor(0)); | 1498 pFormControl->GetOriginalBackgroundColor(0)); |
1600 } else if (iColorType == COLORTYPE_RGB) { | 1499 } else if (iColorType == COLORTYPE_RGB) { |
1601 color = | 1500 color = |
1602 CPWL_Color(COLORTYPE_RGB, pFormControl->GetOriginalBackgroundColor(0), | 1501 CPWL_Color(COLORTYPE_RGB, pFormControl->GetOriginalBackgroundColor(0), |
1603 pFormControl->GetOriginalBackgroundColor(1), | 1502 pFormControl->GetOriginalBackgroundColor(1), |
1604 pFormControl->GetOriginalBackgroundColor(2)); | 1503 pFormControl->GetOriginalBackgroundColor(2)); |
1605 } else if (iColorType == COLORTYPE_CMYK) { | 1504 } else if (iColorType == COLORTYPE_CMYK) { |
1606 color = CPWL_Color(COLORTYPE_CMYK, | 1505 color = CPWL_Color(COLORTYPE_CMYK, |
1607 pFormControl->GetOriginalBackgroundColor(0), | 1506 pFormControl->GetOriginalBackgroundColor(0), |
1608 pFormControl->GetOriginalBackgroundColor(1), | 1507 pFormControl->GetOriginalBackgroundColor(1), |
1609 pFormControl->GetOriginalBackgroundColor(2), | 1508 pFormControl->GetOriginalBackgroundColor(2), |
1610 pFormControl->GetOriginalBackgroundColor(3)); | 1509 pFormControl->GetOriginalBackgroundColor(3)); |
1611 } else | 1510 } else { |
1612 return FALSE; | 1511 return FALSE; |
| 1512 } |
1613 | 1513 |
1614 color::ConvertPWLColorToArray(color, crArray); | 1514 color::ConvertPWLColorToArray(color, crArray); |
1615 vp << crArray; | 1515 vp << crArray; |
1616 } | 1516 } |
1617 | 1517 |
1618 return TRUE; | 1518 return TRUE; |
1619 } | 1519 } |
1620 | 1520 |
1621 void Field::SetFillColor(CPDFSDK_Document* pDocument, | 1521 void Field::SetFillColor(CPDFSDK_Document* pDocument, |
1622 const CFX_WideString& swFieldName, | 1522 const CFX_WideString& swFieldName, |
(...skipping 13 matching lines...) Expand all Loading... |
1636 | 1536 |
1637 bool bVP; | 1537 bool bVP; |
1638 vp >> bVP; | 1538 vp >> bVP; |
1639 | 1539 |
1640 if (m_bDelay) { | 1540 if (m_bDelay) { |
1641 AddDelay_Bool(FP_HIDDEN, bVP); | 1541 AddDelay_Bool(FP_HIDDEN, bVP); |
1642 } else { | 1542 } else { |
1643 Field::SetHidden(m_pDocument, m_FieldName, m_nFormControlIndex, bVP); | 1543 Field::SetHidden(m_pDocument, m_FieldName, m_nFormControlIndex, bVP); |
1644 } | 1544 } |
1645 } else { | 1545 } else { |
1646 CFX_PtrArray FieldArray; | 1546 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
1647 GetFormFields(m_FieldName, FieldArray); | 1547 if (FieldArray.empty()) |
1648 if (FieldArray.GetSize() <= 0) | |
1649 return FALSE; | 1548 return FALSE; |
1650 | 1549 |
1651 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 1550 CPDF_FormField* pFormField = FieldArray[0]; |
1652 ASSERT(pFormField != NULL); | 1551 ASSERT(pFormField); |
1653 | |
1654 CPDFSDK_InterForm* pInterForm = | 1552 CPDFSDK_InterForm* pInterForm = |
1655 (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); | 1553 (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); |
1656 ASSERT(pInterForm != NULL); | |
1657 | |
1658 CPDFSDK_Widget* pWidget = | 1554 CPDFSDK_Widget* pWidget = |
1659 pInterForm->GetWidget(GetSmartFieldControl(pFormField)); | 1555 pInterForm->GetWidget(GetSmartFieldControl(pFormField)); |
1660 if (!pWidget) | 1556 if (!pWidget) |
1661 return FALSE; | 1557 return FALSE; |
1662 | 1558 |
1663 FX_DWORD dwFlags = pWidget->GetFlags(); | 1559 FX_DWORD dwFlags = pWidget->GetFlags(); |
1664 | 1560 |
1665 if (ANNOTFLAG_INVISIBLE & dwFlags || ANNOTFLAG_HIDDEN & dwFlags) { | 1561 if (ANNOTFLAG_INVISIBLE & dwFlags || ANNOTFLAG_HIDDEN & dwFlags) |
1666 vp << true; | 1562 vp << true; |
1667 } else | 1563 else |
1668 vp << false; | 1564 vp << false; |
1669 } | 1565 } |
1670 | 1566 |
1671 return TRUE; | 1567 return TRUE; |
1672 } | 1568 } |
1673 | 1569 |
1674 void Field::SetHidden(CPDFSDK_Document* pDocument, | 1570 void Field::SetHidden(CPDFSDK_Document* pDocument, |
1675 const CFX_WideString& swFieldName, | 1571 const CFX_WideString& swFieldName, |
1676 int nControlIndex, | 1572 int nControlIndex, |
1677 bool b) { | 1573 bool b) { |
1678 ASSERT(pDocument != NULL); | 1574 ASSERT(pDocument != NULL); |
1679 | 1575 |
1680 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); | 1576 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); |
1681 ASSERT(pInterForm != NULL); | 1577 ASSERT(pInterForm != NULL); |
1682 | 1578 |
1683 CFX_PtrArray FieldArray; | 1579 std::vector<CPDF_FormField*> FieldArray = |
1684 GetFormFields(pDocument, swFieldName, FieldArray); | 1580 GetFormFields(pDocument, swFieldName); |
1685 | 1581 for (CPDF_FormField* pFormField : FieldArray) { |
1686 for (int i = 0, isz = FieldArray.GetSize(); i < isz; i++) { | |
1687 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i); | |
1688 ASSERT(pFormField != NULL); | |
1689 | |
1690 if (nControlIndex < 0) { | 1582 if (nControlIndex < 0) { |
1691 FX_BOOL bSet = FALSE; | 1583 FX_BOOL bSet = FALSE; |
1692 for (int j = 0, jsz = pFormField->CountControls(); j < jsz; j++) { | 1584 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { |
1693 if (CPDFSDK_Widget* pWidget = | 1585 if (CPDFSDK_Widget* pWidget = |
1694 pInterForm->GetWidget(pFormField->GetControl(j))) { | 1586 pInterForm->GetWidget(pFormField->GetControl(i))) { |
1695 FX_DWORD dwFlags = pWidget->GetFlags(); | 1587 FX_DWORD dwFlags = pWidget->GetFlags(); |
1696 | 1588 |
1697 if (b) { | 1589 if (b) { |
1698 dwFlags &= (~ANNOTFLAG_INVISIBLE); | 1590 dwFlags &= (~ANNOTFLAG_INVISIBLE); |
1699 dwFlags &= (~ANNOTFLAG_NOVIEW); | 1591 dwFlags &= (~ANNOTFLAG_NOVIEW); |
1700 dwFlags |= (ANNOTFLAG_HIDDEN | ANNOTFLAG_PRINT); | 1592 dwFlags |= (ANNOTFLAG_HIDDEN | ANNOTFLAG_PRINT); |
1701 } else { | 1593 } else { |
1702 dwFlags &= (~ANNOTFLAG_INVISIBLE); | 1594 dwFlags &= (~ANNOTFLAG_INVISIBLE); |
1703 dwFlags &= (~ANNOTFLAG_HIDDEN); | 1595 dwFlags &= (~ANNOTFLAG_HIDDEN); |
1704 dwFlags &= (~ANNOTFLAG_NOVIEW); | 1596 dwFlags &= (~ANNOTFLAG_NOVIEW); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1755 CFX_ByteString strMode; | 1647 CFX_ByteString strMode; |
1756 vp >> strMode; | 1648 vp >> strMode; |
1757 | 1649 |
1758 if (m_bDelay) { | 1650 if (m_bDelay) { |
1759 AddDelay_String(FP_HIGHLIGHT, strMode); | 1651 AddDelay_String(FP_HIGHLIGHT, strMode); |
1760 } else { | 1652 } else { |
1761 Field::SetHighlight(m_pDocument, m_FieldName, m_nFormControlIndex, | 1653 Field::SetHighlight(m_pDocument, m_FieldName, m_nFormControlIndex, |
1762 strMode); | 1654 strMode); |
1763 } | 1655 } |
1764 } else { | 1656 } else { |
1765 CFX_PtrArray FieldArray; | 1657 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
1766 GetFormFields(m_FieldName, FieldArray); | 1658 if (FieldArray.empty()) |
1767 if (FieldArray.GetSize() <= 0) | |
1768 return FALSE; | 1659 return FALSE; |
1769 | 1660 |
1770 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 1661 CPDF_FormField* pFormField = FieldArray[0]; |
1771 ASSERT(pFormField != NULL); | |
1772 | |
1773 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) | 1662 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) |
1774 return FALSE; | 1663 return FALSE; |
1775 | 1664 |
1776 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | 1665 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
1777 if (!pFormControl) | 1666 if (!pFormControl) |
1778 return FALSE; | 1667 return FALSE; |
1779 | 1668 |
1780 int eHM = pFormControl->GetHighlightingMode(); | 1669 int eHM = pFormControl->GetHighlightingMode(); |
1781 switch (eHM) { | 1670 switch (eHM) { |
1782 case CPDF_FormControl::None: | 1671 case CPDF_FormControl::None: |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1819 int iWidth; | 1708 int iWidth; |
1820 vp >> iWidth; | 1709 vp >> iWidth; |
1821 | 1710 |
1822 if (m_bDelay) { | 1711 if (m_bDelay) { |
1823 AddDelay_Int(FP_LINEWIDTH, iWidth); | 1712 AddDelay_Int(FP_LINEWIDTH, iWidth); |
1824 } else { | 1713 } else { |
1825 Field::SetLineWidth(m_pDocument, m_FieldName, m_nFormControlIndex, | 1714 Field::SetLineWidth(m_pDocument, m_FieldName, m_nFormControlIndex, |
1826 iWidth); | 1715 iWidth); |
1827 } | 1716 } |
1828 } else { | 1717 } else { |
1829 CFX_PtrArray FieldArray; | 1718 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
1830 GetFormFields(m_FieldName, FieldArray); | 1719 if (FieldArray.empty()) |
1831 if (FieldArray.GetSize() <= 0) | |
1832 return FALSE; | 1720 return FALSE; |
1833 | 1721 |
1834 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 1722 CPDF_FormField* pFormField = FieldArray[0]; |
1835 ASSERT(pFormField != NULL); | 1723 ASSERT(pFormField); |
1836 | |
1837 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | 1724 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
1838 if (!pFormControl) | 1725 if (!pFormControl) |
1839 return FALSE; | 1726 return FALSE; |
1840 | 1727 |
1841 CPDFSDK_InterForm* pInterForm = | 1728 CPDFSDK_InterForm* pInterForm = |
1842 (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); | 1729 (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); |
1843 ASSERT(pInterForm != NULL); | 1730 ASSERT(pInterForm != NULL); |
1844 | 1731 |
1845 if (!pFormField->CountControls()) | 1732 if (!pFormField->CountControls()) |
1846 return FALSE; | 1733 return FALSE; |
(...skipping 10 matching lines...) Expand all Loading... |
1857 | 1744 |
1858 void Field::SetLineWidth(CPDFSDK_Document* pDocument, | 1745 void Field::SetLineWidth(CPDFSDK_Document* pDocument, |
1859 const CFX_WideString& swFieldName, | 1746 const CFX_WideString& swFieldName, |
1860 int nControlIndex, | 1747 int nControlIndex, |
1861 int number) { | 1748 int number) { |
1862 ASSERT(pDocument != NULL); | 1749 ASSERT(pDocument != NULL); |
1863 | 1750 |
1864 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); | 1751 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); |
1865 ASSERT(pInterForm != NULL); | 1752 ASSERT(pInterForm != NULL); |
1866 | 1753 |
1867 CFX_PtrArray FieldArray; | 1754 std::vector<CPDF_FormField*> FieldArray = |
1868 GetFormFields(pDocument, swFieldName, FieldArray); | 1755 GetFormFields(pDocument, swFieldName); |
1869 | 1756 for (CPDF_FormField* pFormField : FieldArray) { |
1870 for (int i = 0, isz = FieldArray.GetSize(); i < isz; i++) { | |
1871 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i); | |
1872 ASSERT(pFormField != NULL); | |
1873 | |
1874 if (nControlIndex < 0) { | 1757 if (nControlIndex < 0) { |
1875 FX_BOOL bSet = FALSE; | 1758 FX_BOOL bSet = FALSE; |
1876 for (int j = 0, jsz = pFormField->CountControls(); j < jsz; j++) { | 1759 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { |
1877 CPDF_FormControl* pFormControl = pFormField->GetControl(j); | 1760 CPDF_FormControl* pFormControl = pFormField->GetControl(i); |
1878 ASSERT(pFormControl != NULL); | 1761 ASSERT(pFormControl != NULL); |
1879 | 1762 |
1880 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) { | 1763 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) { |
1881 if (number != pWidget->GetBorderWidth()) { | 1764 if (number != pWidget->GetBorderWidth()) { |
1882 pWidget->SetBorderWidth(number); | 1765 pWidget->SetBorderWidth(number); |
1883 bSet = TRUE; | 1766 bSet = TRUE; |
1884 } | 1767 } |
1885 } | 1768 } |
1886 } | 1769 } |
1887 if (bSet) | 1770 if (bSet) |
(...skipping 25 matching lines...) Expand all Loading... |
1913 | 1796 |
1914 bool bVP; | 1797 bool bVP; |
1915 vp >> bVP; | 1798 vp >> bVP; |
1916 | 1799 |
1917 if (m_bDelay) { | 1800 if (m_bDelay) { |
1918 AddDelay_Bool(FP_MULTILINE, bVP); | 1801 AddDelay_Bool(FP_MULTILINE, bVP); |
1919 } else { | 1802 } else { |
1920 Field::SetMultiline(m_pDocument, m_FieldName, m_nFormControlIndex, bVP); | 1803 Field::SetMultiline(m_pDocument, m_FieldName, m_nFormControlIndex, bVP); |
1921 } | 1804 } |
1922 } else { | 1805 } else { |
1923 CFX_PtrArray FieldArray; | 1806 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
1924 GetFormFields(m_FieldName, FieldArray); | 1807 if (FieldArray.empty()) |
1925 if (FieldArray.GetSize() <= 0) | |
1926 return FALSE; | 1808 return FALSE; |
1927 | 1809 |
1928 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 1810 CPDF_FormField* pFormField = FieldArray[0]; |
1929 ASSERT(pFormField != NULL); | |
1930 | |
1931 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) | 1811 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) |
1932 return FALSE; | 1812 return FALSE; |
1933 | 1813 |
1934 if (pFormField->GetFieldFlags() & FIELDFLAG_MULTILINE) | 1814 if (pFormField->GetFieldFlags() & FIELDFLAG_MULTILINE) |
1935 vp << true; | 1815 vp << true; |
1936 else | 1816 else |
1937 vp << false; | 1817 vp << false; |
1938 } | 1818 } |
1939 | 1819 |
1940 return TRUE; | 1820 return TRUE; |
(...skipping 18 matching lines...) Expand all Loading... |
1959 bool bVP; | 1839 bool bVP; |
1960 vp >> bVP; | 1840 vp >> bVP; |
1961 | 1841 |
1962 if (m_bDelay) { | 1842 if (m_bDelay) { |
1963 AddDelay_Bool(FP_MULTIPLESELECTION, bVP); | 1843 AddDelay_Bool(FP_MULTIPLESELECTION, bVP); |
1964 } else { | 1844 } else { |
1965 Field::SetMultipleSelection(m_pDocument, m_FieldName, m_nFormControlIndex, | 1845 Field::SetMultipleSelection(m_pDocument, m_FieldName, m_nFormControlIndex, |
1966 bVP); | 1846 bVP); |
1967 } | 1847 } |
1968 } else { | 1848 } else { |
1969 CFX_PtrArray FieldArray; | 1849 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
1970 GetFormFields(m_FieldName, FieldArray); | 1850 if (FieldArray.empty()) |
1971 if (FieldArray.GetSize() <= 0) | |
1972 return FALSE; | 1851 return FALSE; |
1973 | 1852 |
1974 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 1853 CPDF_FormField* pFormField = FieldArray[0]; |
1975 ASSERT(pFormField != NULL); | |
1976 | |
1977 if (pFormField->GetFieldType() != FIELDTYPE_LISTBOX) | 1854 if (pFormField->GetFieldType() != FIELDTYPE_LISTBOX) |
1978 return FALSE; | 1855 return FALSE; |
1979 | 1856 |
1980 if (pFormField->GetFieldFlags() & FIELDFLAG_MULTISELECT) | 1857 if (pFormField->GetFieldFlags() & FIELDFLAG_MULTISELECT) |
1981 vp << true; | 1858 vp << true; |
1982 else | 1859 else |
1983 vp << false; | 1860 vp << false; |
1984 } | 1861 } |
1985 | 1862 |
1986 return TRUE; | 1863 return TRUE; |
1987 } | 1864 } |
1988 | 1865 |
1989 void Field::SetMultipleSelection(CPDFSDK_Document* pDocument, | 1866 void Field::SetMultipleSelection(CPDFSDK_Document* pDocument, |
1990 const CFX_WideString& swFieldName, | 1867 const CFX_WideString& swFieldName, |
1991 int nControlIndex, | 1868 int nControlIndex, |
1992 bool b) { | 1869 bool b) { |
1993 // Not supported. | 1870 // Not supported. |
1994 } | 1871 } |
1995 | 1872 |
1996 FX_BOOL Field::name(IJS_Context* cc, | 1873 FX_BOOL Field::name(IJS_Context* cc, |
1997 CJS_PropValue& vp, | 1874 CJS_PropValue& vp, |
1998 CFX_WideString& sError) { | 1875 CFX_WideString& sError) { |
1999 if (!vp.IsGetting()) | 1876 if (!vp.IsGetting()) |
2000 return FALSE; | 1877 return FALSE; |
2001 | 1878 |
2002 CFX_PtrArray FieldArray; | 1879 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
2003 GetFormFields(m_FieldName, FieldArray); | 1880 if (FieldArray.empty()) |
2004 if (FieldArray.GetSize() <= 0) | |
2005 return FALSE; | 1881 return FALSE; |
2006 | 1882 |
2007 vp << m_FieldName; | 1883 vp << m_FieldName; |
2008 | 1884 |
2009 return TRUE; | 1885 return TRUE; |
2010 } | 1886 } |
2011 | 1887 |
2012 FX_BOOL Field::numItems(IJS_Context* cc, | 1888 FX_BOOL Field::numItems(IJS_Context* cc, |
2013 CJS_PropValue& vp, | 1889 CJS_PropValue& vp, |
2014 CFX_WideString& sError) { | 1890 CFX_WideString& sError) { |
2015 if (!vp.IsGetting()) | 1891 if (!vp.IsGetting()) |
2016 return FALSE; | 1892 return FALSE; |
2017 | 1893 |
2018 CFX_PtrArray FieldArray; | 1894 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
2019 GetFormFields(m_FieldName, FieldArray); | 1895 if (FieldArray.empty()) |
2020 if (FieldArray.GetSize() <= 0) | |
2021 return FALSE; | 1896 return FALSE; |
2022 | 1897 |
2023 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 1898 CPDF_FormField* pFormField = FieldArray[0]; |
2024 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && | 1899 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && |
2025 pFormField->GetFieldType() != FIELDTYPE_LISTBOX) | 1900 pFormField->GetFieldType() != FIELDTYPE_LISTBOX) { |
2026 return FALSE; | 1901 return FALSE; |
| 1902 } |
2027 | 1903 |
2028 vp << (int32_t)pFormField->CountOptions(); | 1904 vp << (int32_t)pFormField->CountOptions(); |
2029 return TRUE; | 1905 return TRUE; |
2030 } | 1906 } |
2031 | 1907 |
2032 FX_BOOL Field::page(IJS_Context* cc, | 1908 FX_BOOL Field::page(IJS_Context* cc, |
2033 CJS_PropValue& vp, | 1909 CJS_PropValue& vp, |
2034 CFX_WideString& sError) { | 1910 CFX_WideString& sError) { |
2035 if (!vp.IsGetting()) | 1911 if (!vp.IsGetting()) |
2036 return FALSE; | 1912 return FALSE; |
2037 | 1913 |
2038 CFX_PtrArray FieldArray; | 1914 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
2039 GetFormFields(m_FieldName, FieldArray); | 1915 if (FieldArray.empty()) |
2040 if (FieldArray.GetSize() <= 0) | |
2041 return FALSE; | 1916 return FALSE; |
2042 | 1917 |
2043 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 1918 CPDF_FormField* pFormField = FieldArray[0]; |
2044 if (!pFormField) | 1919 if (!pFormField) |
2045 return FALSE; | 1920 return FALSE; |
2046 | 1921 |
2047 CFX_PtrArray widgetArray; | 1922 std::vector<CPDFSDK_Widget*> widgets; |
2048 CPDFSDK_InterForm* pInterForm = | 1923 m_pDocument->GetInterForm()->GetWidgets(pFormField, &widgets); |
2049 (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); | |
2050 pInterForm->GetWidgets(pFormField, widgetArray); | |
2051 | 1924 |
2052 if (widgetArray.GetSize() > 0) { | 1925 if (widgets.empty()) { |
2053 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); | |
2054 CJS_Array PageArray(pRuntime); | |
2055 for (int i = 0, sz = widgetArray.GetSize(); i < sz; i++) { | |
2056 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widgetArray.GetAt(i); | |
2057 CPDFSDK_PageView* pPageView = pWidget->GetPageView(); | |
2058 if (!pPageView) | |
2059 return FALSE; | |
2060 | |
2061 PageArray.SetElement( | |
2062 i, CJS_Value(pRuntime, (int32_t)pPageView->GetPageIndex())); | |
2063 } | |
2064 | |
2065 vp << PageArray; | |
2066 } else { | |
2067 vp << (int32_t)-1; | 1926 vp << (int32_t)-1; |
| 1927 return TRUE; |
2068 } | 1928 } |
2069 | 1929 |
| 1930 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
| 1931 CJS_Array PageArray(pRuntime); |
| 1932 for (size_t i = 0; i < widgets.size(); ++i) { |
| 1933 CPDFSDK_PageView* pPageView = widgets[i]->GetPageView(); |
| 1934 if (!pPageView) |
| 1935 return FALSE; |
| 1936 |
| 1937 PageArray.SetElement( |
| 1938 i, CJS_Value(pRuntime, (int32_t)pPageView->GetPageIndex())); |
| 1939 } |
| 1940 |
| 1941 vp << PageArray; |
2070 return TRUE; | 1942 return TRUE; |
2071 } | 1943 } |
2072 | 1944 |
2073 FX_BOOL Field::password(IJS_Context* cc, | 1945 FX_BOOL Field::password(IJS_Context* cc, |
2074 CJS_PropValue& vp, | 1946 CJS_PropValue& vp, |
2075 CFX_WideString& sError) { | 1947 CFX_WideString& sError) { |
2076 ASSERT(m_pDocument != NULL); | 1948 ASSERT(m_pDocument != NULL); |
2077 | 1949 |
2078 if (vp.IsSetting()) { | 1950 if (vp.IsSetting()) { |
2079 if (!m_bCanSet) | 1951 if (!m_bCanSet) |
2080 return FALSE; | 1952 return FALSE; |
2081 | 1953 |
2082 bool bVP; | 1954 bool bVP; |
2083 vp >> bVP; | 1955 vp >> bVP; |
2084 | 1956 |
2085 if (m_bDelay) { | 1957 if (m_bDelay) { |
2086 AddDelay_Bool(FP_PASSWORD, bVP); | 1958 AddDelay_Bool(FP_PASSWORD, bVP); |
2087 } else { | 1959 } else { |
2088 Field::SetPassword(m_pDocument, m_FieldName, m_nFormControlIndex, bVP); | 1960 Field::SetPassword(m_pDocument, m_FieldName, m_nFormControlIndex, bVP); |
2089 } | 1961 } |
2090 } else { | 1962 } else { |
2091 CFX_PtrArray FieldArray; | 1963 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
2092 GetFormFields(m_FieldName, FieldArray); | 1964 if (FieldArray.empty()) |
2093 if (FieldArray.GetSize() <= 0) | |
2094 return FALSE; | 1965 return FALSE; |
2095 | 1966 |
2096 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 1967 CPDF_FormField* pFormField = FieldArray[0]; |
2097 ASSERT(pFormField != NULL); | |
2098 | |
2099 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) | 1968 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) |
2100 return FALSE; | 1969 return FALSE; |
2101 | 1970 |
2102 if (pFormField->GetFieldFlags() & FIELDFLAG_PASSWORD) | 1971 if (pFormField->GetFieldFlags() & FIELDFLAG_PASSWORD) |
2103 vp << true; | 1972 vp << true; |
2104 else | 1973 else |
2105 vp << false; | 1974 vp << false; |
2106 } | 1975 } |
2107 | 1976 |
2108 return TRUE; | 1977 return TRUE; |
2109 } | 1978 } |
2110 | 1979 |
2111 void Field::SetPassword(CPDFSDK_Document* pDocument, | 1980 void Field::SetPassword(CPDFSDK_Document* pDocument, |
2112 const CFX_WideString& swFieldName, | 1981 const CFX_WideString& swFieldName, |
2113 int nControlIndex, | 1982 int nControlIndex, |
2114 bool b) { | 1983 bool b) { |
2115 // Not supported. | 1984 // Not supported. |
2116 } | 1985 } |
2117 | 1986 |
2118 FX_BOOL Field::print(IJS_Context* cc, | 1987 FX_BOOL Field::print(IJS_Context* cc, |
2119 CJS_PropValue& vp, | 1988 CJS_PropValue& vp, |
2120 CFX_WideString& sError) { | 1989 CFX_WideString& sError) { |
2121 ASSERT(m_pDocument != NULL); | 1990 ASSERT(m_pDocument != NULL); |
2122 | 1991 |
2123 CPDFSDK_InterForm* pInterForm = | 1992 CPDFSDK_InterForm* pInterForm = |
2124 (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); | 1993 (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); |
2125 ASSERT(pInterForm != NULL); | 1994 ASSERT(pInterForm != NULL); |
2126 | 1995 |
2127 CFX_PtrArray FieldArray; | 1996 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
2128 GetFormFields(m_FieldName, FieldArray); | 1997 if (FieldArray.empty()) |
2129 if (FieldArray.GetSize() <= 0) | |
2130 return FALSE; | 1998 return FALSE; |
2131 | 1999 |
2132 if (vp.IsSetting()) { | 2000 if (vp.IsSetting()) { |
2133 if (!m_bCanSet) | 2001 if (!m_bCanSet) |
2134 return FALSE; | 2002 return FALSE; |
2135 | 2003 |
2136 bool bVP; | 2004 bool bVP; |
2137 vp >> bVP; | 2005 vp >> bVP; |
2138 | 2006 |
2139 for (int i = 0, isz = FieldArray.GetSize(); i < isz; i++) { | 2007 for (CPDF_FormField* pFormField : FieldArray) { |
2140 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i); | |
2141 ASSERT(pFormField != NULL); | |
2142 | |
2143 if (m_nFormControlIndex < 0) { | 2008 if (m_nFormControlIndex < 0) { |
2144 FX_BOOL bSet = FALSE; | 2009 FX_BOOL bSet = FALSE; |
2145 for (int j = 0, jsz = pFormField->CountControls(); j < jsz; j++) { | 2010 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { |
2146 if (CPDFSDK_Widget* pWidget = | 2011 if (CPDFSDK_Widget* pWidget = |
2147 pInterForm->GetWidget(pFormField->GetControl(j))) { | 2012 pInterForm->GetWidget(pFormField->GetControl(i))) { |
2148 FX_DWORD dwFlags = pWidget->GetFlags(); | 2013 FX_DWORD dwFlags = pWidget->GetFlags(); |
2149 if (bVP) | 2014 if (bVP) |
2150 dwFlags |= ANNOTFLAG_PRINT; | 2015 dwFlags |= ANNOTFLAG_PRINT; |
2151 else | 2016 else |
2152 dwFlags &= ~ANNOTFLAG_PRINT; | 2017 dwFlags &= ~ANNOTFLAG_PRINT; |
2153 | 2018 |
2154 if (dwFlags != pWidget->GetFlags()) { | 2019 if (dwFlags != pWidget->GetFlags()) { |
2155 pWidget->SetFlags(dwFlags); | 2020 pWidget->SetFlags(dwFlags); |
2156 bSet = TRUE; | 2021 bSet = TRUE; |
2157 } | 2022 } |
(...skipping 18 matching lines...) Expand all Loading... |
2176 pWidget->SetFlags(dwFlags); | 2041 pWidget->SetFlags(dwFlags); |
2177 UpdateFormControl(m_pDocument, | 2042 UpdateFormControl(m_pDocument, |
2178 pFormField->GetControl(m_nFormControlIndex), | 2043 pFormField->GetControl(m_nFormControlIndex), |
2179 TRUE, FALSE, TRUE); | 2044 TRUE, FALSE, TRUE); |
2180 } | 2045 } |
2181 } | 2046 } |
2182 } | 2047 } |
2183 } | 2048 } |
2184 } | 2049 } |
2185 } else { | 2050 } else { |
2186 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 2051 CPDF_FormField* pFormField = FieldArray[0]; |
2187 ASSERT(pFormField != NULL); | |
2188 | |
2189 CPDFSDK_Widget* pWidget = | 2052 CPDFSDK_Widget* pWidget = |
2190 pInterForm->GetWidget(GetSmartFieldControl(pFormField)); | 2053 pInterForm->GetWidget(GetSmartFieldControl(pFormField)); |
2191 if (!pWidget) | 2054 if (!pWidget) |
2192 return FALSE; | 2055 return FALSE; |
2193 | 2056 |
2194 if (pWidget->GetFlags() & ANNOTFLAG_PRINT) | 2057 if (pWidget->GetFlags() & ANNOTFLAG_PRINT) |
2195 vp << true; | 2058 vp << true; |
2196 else | 2059 else |
2197 vp << false; | 2060 vp << false; |
2198 } | 2061 } |
2199 | 2062 |
2200 return TRUE; | 2063 return TRUE; |
2201 } | 2064 } |
2202 | 2065 |
2203 FX_BOOL Field::radiosInUnison(IJS_Context* cc, | 2066 FX_BOOL Field::radiosInUnison(IJS_Context* cc, |
2204 CJS_PropValue& vp, | 2067 CJS_PropValue& vp, |
2205 CFX_WideString& sError) { | 2068 CFX_WideString& sError) { |
2206 ASSERT(m_pDocument != NULL); | 2069 ASSERT(m_pDocument != NULL); |
2207 | 2070 |
2208 CFX_PtrArray FieldArray; | 2071 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
2209 GetFormFields(m_FieldName, FieldArray); | 2072 if (FieldArray.empty()) |
2210 if (FieldArray.GetSize() <= 0) | |
2211 return FALSE; | 2073 return FALSE; |
2212 | 2074 |
2213 if (vp.IsSetting()) { | 2075 if (vp.IsSetting()) { |
2214 if (!m_bCanSet) | 2076 if (!m_bCanSet) |
2215 return FALSE; | 2077 return FALSE; |
2216 | 2078 |
2217 bool bVP; | 2079 bool bVP; |
2218 vp >> bVP; | 2080 vp >> bVP; |
2219 | 2081 |
2220 } else { | 2082 } else { |
2221 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 2083 CPDF_FormField* pFormField = FieldArray[0]; |
2222 ASSERT(pFormField != NULL); | |
2223 | |
2224 if (pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON) | 2084 if (pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON) |
2225 return FALSE; | 2085 return FALSE; |
2226 | 2086 |
2227 if (pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON) | 2087 if (pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON) |
2228 vp << true; | 2088 vp << true; |
2229 else | 2089 else |
2230 vp << false; | 2090 vp << false; |
2231 } | 2091 } |
2232 | 2092 |
2233 return TRUE; | 2093 return TRUE; |
2234 } | 2094 } |
2235 | 2095 |
2236 FX_BOOL Field::readonly(IJS_Context* cc, | 2096 FX_BOOL Field::readonly(IJS_Context* cc, |
2237 CJS_PropValue& vp, | 2097 CJS_PropValue& vp, |
2238 CFX_WideString& sError) { | 2098 CFX_WideString& sError) { |
2239 ASSERT(m_pDocument != NULL); | 2099 ASSERT(m_pDocument != NULL); |
2240 | 2100 |
2241 CFX_PtrArray FieldArray; | 2101 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
2242 GetFormFields(m_FieldName, FieldArray); | 2102 if (FieldArray.empty()) |
2243 if (FieldArray.GetSize() <= 0) | |
2244 return FALSE; | 2103 return FALSE; |
2245 | 2104 |
2246 if (vp.IsSetting()) { | 2105 if (vp.IsSetting()) { |
2247 if (!m_bCanSet) | 2106 if (!m_bCanSet) |
2248 return FALSE; | 2107 return FALSE; |
2249 | 2108 |
2250 bool bVP; | 2109 bool bVP; |
2251 vp >> bVP; | 2110 vp >> bVP; |
2252 | 2111 |
2253 } else { | 2112 } else { |
2254 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 2113 CPDF_FormField* pFormField = FieldArray[0]; |
2255 ASSERT(pFormField != NULL); | |
2256 | |
2257 if (pFormField->GetFieldFlags() & FIELDFLAG_READONLY) | 2114 if (pFormField->GetFieldFlags() & FIELDFLAG_READONLY) |
2258 vp << true; | 2115 vp << true; |
2259 else | 2116 else |
2260 vp << false; | 2117 vp << false; |
2261 } | 2118 } |
2262 | 2119 |
2263 return TRUE; | 2120 return TRUE; |
2264 } | 2121 } |
2265 | 2122 |
2266 FX_BOOL Field::rect(IJS_Context* cc, | 2123 FX_BOOL Field::rect(IJS_Context* cc, |
(...skipping 24 matching lines...) Expand all Loading... |
2291 pArray[2] = (FX_FLOAT)Lower_Rightx.ToInt(); | 2148 pArray[2] = (FX_FLOAT)Lower_Rightx.ToInt(); |
2292 pArray[3] = (FX_FLOAT)Upper_Lefty.ToInt(); | 2149 pArray[3] = (FX_FLOAT)Upper_Lefty.ToInt(); |
2293 | 2150 |
2294 CPDF_Rect crRect(pArray); | 2151 CPDF_Rect crRect(pArray); |
2295 if (m_bDelay) { | 2152 if (m_bDelay) { |
2296 AddDelay_Rect(FP_RECT, crRect); | 2153 AddDelay_Rect(FP_RECT, crRect); |
2297 } else { | 2154 } else { |
2298 Field::SetRect(m_pDocument, m_FieldName, m_nFormControlIndex, crRect); | 2155 Field::SetRect(m_pDocument, m_FieldName, m_nFormControlIndex, crRect); |
2299 } | 2156 } |
2300 } else { | 2157 } else { |
2301 CFX_PtrArray FieldArray; | 2158 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
2302 GetFormFields(m_FieldName, FieldArray); | 2159 if (FieldArray.empty()) |
2303 if (FieldArray.GetSize() <= 0) | |
2304 return FALSE; | 2160 return FALSE; |
2305 | 2161 |
2306 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 2162 CPDF_FormField* pFormField = FieldArray[0]; |
2307 CPDFSDK_InterForm* pInterForm = | 2163 CPDFSDK_InterForm* pInterForm = |
2308 (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); | 2164 (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); |
2309 CPDFSDK_Widget* pWidget = | 2165 CPDFSDK_Widget* pWidget = |
2310 pInterForm->GetWidget(GetSmartFieldControl(pFormField)); | 2166 pInterForm->GetWidget(GetSmartFieldControl(pFormField)); |
2311 if (!pWidget) | 2167 if (!pWidget) |
2312 return FALSE; | 2168 return FALSE; |
2313 | 2169 |
2314 CFX_FloatRect crRect = pWidget->GetRect(); | 2170 CFX_FloatRect crRect = pWidget->GetRect(); |
2315 Upper_Leftx = (int32_t)crRect.left; | 2171 Upper_Leftx = (int32_t)crRect.left; |
2316 Upper_Lefty = (int32_t)crRect.top; | 2172 Upper_Lefty = (int32_t)crRect.top; |
(...skipping 12 matching lines...) Expand all Loading... |
2329 | 2185 |
2330 void Field::SetRect(CPDFSDK_Document* pDocument, | 2186 void Field::SetRect(CPDFSDK_Document* pDocument, |
2331 const CFX_WideString& swFieldName, | 2187 const CFX_WideString& swFieldName, |
2332 int nControlIndex, | 2188 int nControlIndex, |
2333 const CPDF_Rect& rect) { | 2189 const CPDF_Rect& rect) { |
2334 ASSERT(pDocument != NULL); | 2190 ASSERT(pDocument != NULL); |
2335 | 2191 |
2336 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); | 2192 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); |
2337 ASSERT(pInterForm != NULL); | 2193 ASSERT(pInterForm != NULL); |
2338 | 2194 |
2339 CFX_PtrArray FieldArray; | 2195 std::vector<CPDF_FormField*> FieldArray = |
2340 GetFormFields(pDocument, swFieldName, FieldArray); | 2196 GetFormFields(pDocument, swFieldName); |
2341 | 2197 for (CPDF_FormField* pFormField : FieldArray) { |
2342 for (int i = 0, isz = FieldArray.GetSize(); i < isz; i++) { | |
2343 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i); | |
2344 ASSERT(pFormField != NULL); | |
2345 | |
2346 if (nControlIndex < 0) { | 2198 if (nControlIndex < 0) { |
2347 FX_BOOL bSet = FALSE; | 2199 FX_BOOL bSet = FALSE; |
2348 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { | 2200 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { |
2349 CPDF_FormControl* pFormControl = pFormField->GetControl(i); | 2201 CPDF_FormControl* pFormControl = pFormField->GetControl(i); |
2350 ASSERT(pFormControl != NULL); | 2202 ASSERT(pFormControl != NULL); |
2351 | 2203 |
2352 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) { | 2204 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) { |
2353 CPDF_Rect crRect = rect; | 2205 CPDF_Rect crRect = rect; |
2354 | 2206 |
2355 CPDF_Page* pPDFPage = pWidget->GetPDFPage(); | 2207 CPDF_Page* pPDFPage = pWidget->GetPDFPage(); |
2356 ASSERT(pPDFPage != NULL); | |
2357 | |
2358 // CPDF_Page* pPDFPage = pPage->GetPage(); | |
2359 // ASSERT(pPDFPage != NULL); | |
2360 | |
2361 crRect.Intersect(pPDFPage->GetPageBBox()); | 2208 crRect.Intersect(pPDFPage->GetPageBBox()); |
2362 | 2209 |
2363 if (!crRect.IsEmpty()) { | 2210 if (!crRect.IsEmpty()) { |
2364 CPDF_Rect rcOld = pWidget->GetRect(); | 2211 CPDF_Rect rcOld = pWidget->GetRect(); |
2365 if (crRect.left != rcOld.left || crRect.right != rcOld.right || | 2212 if (crRect.left != rcOld.left || crRect.right != rcOld.right || |
2366 crRect.top != rcOld.top || crRect.bottom != rcOld.bottom) { | 2213 crRect.top != rcOld.top || crRect.bottom != rcOld.bottom) { |
2367 pWidget->SetRect(crRect); | 2214 pWidget->SetRect(crRect); |
2368 bSet = TRUE; | 2215 bSet = TRUE; |
2369 } | 2216 } |
2370 } | 2217 } |
(...skipping 30 matching lines...) Expand all Loading... |
2401 } | 2248 } |
2402 } | 2249 } |
2403 } | 2250 } |
2404 } | 2251 } |
2405 | 2252 |
2406 FX_BOOL Field::required(IJS_Context* cc, | 2253 FX_BOOL Field::required(IJS_Context* cc, |
2407 CJS_PropValue& vp, | 2254 CJS_PropValue& vp, |
2408 CFX_WideString& sError) { | 2255 CFX_WideString& sError) { |
2409 ASSERT(m_pDocument != NULL); | 2256 ASSERT(m_pDocument != NULL); |
2410 | 2257 |
2411 CFX_PtrArray FieldArray; | 2258 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
2412 GetFormFields(m_FieldName, FieldArray); | 2259 if (FieldArray.empty()) |
2413 if (FieldArray.GetSize() <= 0) | |
2414 return FALSE; | 2260 return FALSE; |
2415 | 2261 |
2416 if (vp.IsSetting()) { | 2262 if (vp.IsSetting()) { |
2417 if (!m_bCanSet) | 2263 if (!m_bCanSet) |
2418 return FALSE; | 2264 return FALSE; |
2419 | 2265 |
2420 bool bVP; | 2266 bool bVP; |
2421 vp >> bVP; | 2267 vp >> bVP; |
2422 | 2268 |
2423 } else { | 2269 } else { |
2424 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 2270 CPDF_FormField* pFormField = FieldArray[0]; |
2425 ASSERT(pFormField != NULL); | |
2426 | |
2427 if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON) | 2271 if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON) |
2428 return FALSE; | 2272 return FALSE; |
2429 | 2273 |
2430 if (pFormField->GetFieldFlags() & FIELDFLAG_REQUIRED) | 2274 if (pFormField->GetFieldFlags() & FIELDFLAG_REQUIRED) |
2431 vp << true; | 2275 vp << true; |
2432 else | 2276 else |
2433 vp << false; | 2277 vp << false; |
2434 } | 2278 } |
2435 | 2279 |
2436 return TRUE; | 2280 return TRUE; |
(...skipping 10 matching lines...) Expand all Loading... |
2447 | 2291 |
2448 bool bVP; | 2292 bool bVP; |
2449 vp >> bVP; | 2293 vp >> bVP; |
2450 | 2294 |
2451 if (m_bDelay) { | 2295 if (m_bDelay) { |
2452 AddDelay_Bool(FP_RICHTEXT, bVP); | 2296 AddDelay_Bool(FP_RICHTEXT, bVP); |
2453 } else { | 2297 } else { |
2454 Field::SetRichText(m_pDocument, m_FieldName, m_nFormControlIndex, bVP); | 2298 Field::SetRichText(m_pDocument, m_FieldName, m_nFormControlIndex, bVP); |
2455 } | 2299 } |
2456 } else { | 2300 } else { |
2457 CFX_PtrArray FieldArray; | 2301 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
2458 GetFormFields(m_FieldName, FieldArray); | 2302 if (FieldArray.empty()) |
2459 if (FieldArray.GetSize() <= 0) | |
2460 return FALSE; | 2303 return FALSE; |
2461 | 2304 |
2462 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 2305 CPDF_FormField* pFormField = FieldArray[0]; |
2463 ASSERT(pFormField != NULL); | |
2464 | |
2465 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) | 2306 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) |
2466 return FALSE; | 2307 return FALSE; |
2467 | 2308 |
2468 if (pFormField->GetFieldFlags() & FIELDFLAG_RICHTEXT) | 2309 if (pFormField->GetFieldFlags() & FIELDFLAG_RICHTEXT) |
2469 vp << true; | 2310 vp << true; |
2470 else | 2311 else |
2471 vp << false; | 2312 vp << false; |
2472 } | 2313 } |
2473 | 2314 |
2474 return TRUE; | 2315 return TRUE; |
2475 } | 2316 } |
2476 | 2317 |
2477 void Field::SetRichText(CPDFSDK_Document* pDocument, | 2318 void Field::SetRichText(CPDFSDK_Document* pDocument, |
2478 const CFX_WideString& swFieldName, | 2319 const CFX_WideString& swFieldName, |
2479 int nControlIndex, | 2320 int nControlIndex, |
2480 bool b) { | 2321 bool b) { |
2481 // Not supported. | 2322 // Not supported. |
2482 } | 2323 } |
2483 | 2324 |
2484 FX_BOOL Field::richValue(IJS_Context* cc, | 2325 FX_BOOL Field::richValue(IJS_Context* cc, |
2485 CJS_PropValue& vp, | 2326 CJS_PropValue& vp, |
2486 CFX_WideString& sError) { | 2327 CFX_WideString& sError) { |
2487 return TRUE; | 2328 return TRUE; |
2488 if (vp.IsSetting()) { | |
2489 if (!m_bCanSet) | |
2490 return FALSE; | |
2491 ; | |
2492 } else { | |
2493 ; | |
2494 } | |
2495 return TRUE; | |
2496 } | 2329 } |
2497 | 2330 |
2498 void Field::SetRichValue(CPDFSDK_Document* pDocument, | 2331 void Field::SetRichValue(CPDFSDK_Document* pDocument, |
2499 const CFX_WideString& swFieldName, | 2332 const CFX_WideString& swFieldName, |
2500 int nControlIndex) { | 2333 int nControlIndex) { |
2501 // Not supported. | 2334 // Not supported. |
2502 } | 2335 } |
2503 | 2336 |
2504 FX_BOOL Field::rotation(IJS_Context* cc, | 2337 FX_BOOL Field::rotation(IJS_Context* cc, |
2505 CJS_PropValue& vp, | 2338 CJS_PropValue& vp, |
2506 CFX_WideString& sError) { | 2339 CFX_WideString& sError) { |
2507 ASSERT(m_pDocument != NULL); | 2340 ASSERT(m_pDocument != NULL); |
2508 | 2341 |
2509 if (vp.IsSetting()) { | 2342 if (vp.IsSetting()) { |
2510 if (!m_bCanSet) | 2343 if (!m_bCanSet) |
2511 return FALSE; | 2344 return FALSE; |
2512 | 2345 |
2513 int nVP; | 2346 int nVP; |
2514 vp >> nVP; | 2347 vp >> nVP; |
2515 | 2348 |
2516 if (m_bDelay) { | 2349 if (m_bDelay) { |
2517 AddDelay_Int(FP_ROTATION, nVP); | 2350 AddDelay_Int(FP_ROTATION, nVP); |
2518 } else { | 2351 } else { |
2519 Field::SetRotation(m_pDocument, m_FieldName, m_nFormControlIndex, nVP); | 2352 Field::SetRotation(m_pDocument, m_FieldName, m_nFormControlIndex, nVP); |
2520 } | 2353 } |
2521 } else { | 2354 } else { |
2522 CFX_PtrArray FieldArray; | 2355 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
2523 GetFormFields(m_FieldName, FieldArray); | 2356 if (FieldArray.empty()) |
2524 if (FieldArray.GetSize() <= 0) | |
2525 return FALSE; | 2357 return FALSE; |
2526 | 2358 |
2527 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 2359 CPDF_FormField* pFormField = FieldArray[0]; |
2528 ASSERT(pFormField != NULL); | |
2529 | |
2530 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | 2360 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
2531 if (!pFormControl) | 2361 if (!pFormControl) |
2532 return FALSE; | 2362 return FALSE; |
2533 | 2363 |
2534 vp << (int32_t)pFormControl->GetRotation(); | 2364 vp << (int32_t)pFormControl->GetRotation(); |
2535 } | 2365 } |
2536 | 2366 |
2537 return TRUE; | 2367 return TRUE; |
2538 } | 2368 } |
2539 | 2369 |
(...skipping 22 matching lines...) Expand all Loading... |
2562 CPWL_Color color; | 2392 CPWL_Color color; |
2563 color::ConvertArrayToPWLColor(crArray, color); | 2393 color::ConvertArrayToPWLColor(crArray, color); |
2564 | 2394 |
2565 if (m_bDelay) { | 2395 if (m_bDelay) { |
2566 AddDelay_Color(FP_STROKECOLOR, color); | 2396 AddDelay_Color(FP_STROKECOLOR, color); |
2567 } else { | 2397 } else { |
2568 Field::SetStrokeColor(m_pDocument, m_FieldName, m_nFormControlIndex, | 2398 Field::SetStrokeColor(m_pDocument, m_FieldName, m_nFormControlIndex, |
2569 color); | 2399 color); |
2570 } | 2400 } |
2571 } else { | 2401 } else { |
2572 CFX_PtrArray FieldArray; | 2402 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
2573 GetFormFields(m_FieldName, FieldArray); | 2403 if (FieldArray.empty()) |
2574 if (FieldArray.GetSize() <= 0) | |
2575 return FALSE; | 2404 return FALSE; |
2576 | 2405 |
2577 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 2406 CPDF_FormField* pFormField = FieldArray[0]; |
2578 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | 2407 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
2579 if (!pFormControl) | 2408 if (!pFormControl) |
2580 return FALSE; | 2409 return FALSE; |
2581 | 2410 |
2582 int iColorType; | 2411 int iColorType; |
2583 pFormControl->GetBorderColor(iColorType); | 2412 pFormControl->GetBorderColor(iColorType); |
2584 | 2413 |
2585 CPWL_Color color; | 2414 CPWL_Color color; |
2586 if (iColorType == COLORTYPE_TRANSPARENT) { | 2415 if (iColorType == COLORTYPE_TRANSPARENT) { |
2587 color = CPWL_Color(COLORTYPE_TRANSPARENT); | 2416 color = CPWL_Color(COLORTYPE_TRANSPARENT); |
2588 } else if (iColorType == COLORTYPE_GRAY) { | 2417 } else if (iColorType == COLORTYPE_GRAY) { |
2589 color = | 2418 color = |
2590 CPWL_Color(COLORTYPE_GRAY, pFormControl->GetOriginalBorderColor(0)); | 2419 CPWL_Color(COLORTYPE_GRAY, pFormControl->GetOriginalBorderColor(0)); |
2591 } else if (iColorType == COLORTYPE_RGB) { | 2420 } else if (iColorType == COLORTYPE_RGB) { |
2592 color = CPWL_Color(COLORTYPE_RGB, pFormControl->GetOriginalBorderColor(0), | 2421 color = CPWL_Color(COLORTYPE_RGB, pFormControl->GetOriginalBorderColor(0), |
2593 pFormControl->GetOriginalBorderColor(1), | 2422 pFormControl->GetOriginalBorderColor(1), |
2594 pFormControl->GetOriginalBorderColor(2)); | 2423 pFormControl->GetOriginalBorderColor(2)); |
2595 } else if (iColorType == COLORTYPE_CMYK) { | 2424 } else if (iColorType == COLORTYPE_CMYK) { |
2596 color = | 2425 color = |
2597 CPWL_Color(COLORTYPE_CMYK, pFormControl->GetOriginalBorderColor(0), | 2426 CPWL_Color(COLORTYPE_CMYK, pFormControl->GetOriginalBorderColor(0), |
2598 pFormControl->GetOriginalBorderColor(1), | 2427 pFormControl->GetOriginalBorderColor(1), |
2599 pFormControl->GetOriginalBorderColor(2), | 2428 pFormControl->GetOriginalBorderColor(2), |
2600 pFormControl->GetOriginalBorderColor(3)); | 2429 pFormControl->GetOriginalBorderColor(3)); |
2601 } else | 2430 } else { |
2602 return FALSE; | 2431 return FALSE; |
| 2432 } |
2603 | 2433 |
2604 color::ConvertPWLColorToArray(color, crArray); | 2434 color::ConvertPWLColorToArray(color, crArray); |
2605 vp << crArray; | 2435 vp << crArray; |
2606 } | 2436 } |
2607 return TRUE; | 2437 return TRUE; |
2608 } | 2438 } |
2609 | 2439 |
2610 void Field::SetStrokeColor(CPDFSDK_Document* pDocument, | 2440 void Field::SetStrokeColor(CPDFSDK_Document* pDocument, |
2611 const CFX_WideString& swFieldName, | 2441 const CFX_WideString& swFieldName, |
2612 int nControlIndex, | 2442 int nControlIndex, |
(...skipping 13 matching lines...) Expand all Loading... |
2626 CFX_ByteString csBCaption; | 2456 CFX_ByteString csBCaption; |
2627 vp >> csBCaption; | 2457 vp >> csBCaption; |
2628 | 2458 |
2629 if (m_bDelay) { | 2459 if (m_bDelay) { |
2630 AddDelay_String(FP_STYLE, csBCaption); | 2460 AddDelay_String(FP_STYLE, csBCaption); |
2631 } else { | 2461 } else { |
2632 Field::SetStyle(m_pDocument, m_FieldName, m_nFormControlIndex, | 2462 Field::SetStyle(m_pDocument, m_FieldName, m_nFormControlIndex, |
2633 csBCaption); | 2463 csBCaption); |
2634 } | 2464 } |
2635 } else { | 2465 } else { |
2636 CFX_PtrArray FieldArray; | 2466 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
2637 GetFormFields(m_FieldName, FieldArray); | 2467 if (FieldArray.empty()) |
2638 if (FieldArray.GetSize() <= 0) | |
2639 return FALSE; | 2468 return FALSE; |
2640 | 2469 |
2641 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 2470 CPDF_FormField* pFormField = FieldArray[0]; |
2642 ASSERT(pFormField != NULL); | |
2643 | |
2644 if (pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON && | 2471 if (pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON && |
2645 pFormField->GetFieldType() != FIELDTYPE_CHECKBOX) | 2472 pFormField->GetFieldType() != FIELDTYPE_CHECKBOX) { |
2646 return FALSE; | 2473 return FALSE; |
| 2474 } |
2647 | 2475 |
2648 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | 2476 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
2649 if (!pFormControl) | 2477 if (!pFormControl) |
2650 return FALSE; | 2478 return FALSE; |
2651 | 2479 |
2652 CFX_WideString csWCaption = pFormControl->GetNormalCaption(); | 2480 CFX_WideString csWCaption = pFormControl->GetNormalCaption(); |
2653 CFX_ByteString csBCaption; | 2481 CFX_ByteString csBCaption; |
2654 | 2482 |
2655 switch (csWCaption[0]) { | 2483 switch (csWCaption[0]) { |
2656 case L'l': | 2484 case L'l': |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2708 | 2536 |
2709 CPWL_Color color; | 2537 CPWL_Color color; |
2710 color::ConvertArrayToPWLColor(crArray, color); | 2538 color::ConvertArrayToPWLColor(crArray, color); |
2711 | 2539 |
2712 if (m_bDelay) { | 2540 if (m_bDelay) { |
2713 AddDelay_Color(FP_TEXTCOLOR, color); | 2541 AddDelay_Color(FP_TEXTCOLOR, color); |
2714 } else { | 2542 } else { |
2715 Field::SetTextColor(m_pDocument, m_FieldName, m_nFormControlIndex, color); | 2543 Field::SetTextColor(m_pDocument, m_FieldName, m_nFormControlIndex, color); |
2716 } | 2544 } |
2717 } else { | 2545 } else { |
2718 CFX_PtrArray FieldArray; | 2546 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
2719 GetFormFields(m_FieldName, FieldArray); | 2547 if (FieldArray.empty()) |
2720 if (FieldArray.GetSize() <= 0) | |
2721 return FALSE; | 2548 return FALSE; |
2722 | 2549 |
2723 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 2550 CPDF_FormField* pFormField = FieldArray[0]; |
2724 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | 2551 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
2725 if (!pFormControl) | 2552 if (!pFormControl) |
2726 return FALSE; | 2553 return FALSE; |
2727 | 2554 |
2728 int iColorType; | 2555 int iColorType; |
2729 FX_ARGB color; | 2556 FX_ARGB color; |
2730 CPDF_DefaultAppearance FieldAppearance = | 2557 CPDF_DefaultAppearance FieldAppearance = |
2731 pFormControl->GetDefaultAppearance(); | 2558 pFormControl->GetDefaultAppearance(); |
2732 FieldAppearance.GetColor(color, iColorType); | 2559 FieldAppearance.GetColor(color, iColorType); |
2733 int32_t a, r, g, b; | 2560 int32_t a, r, g, b; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2766 if (csFontName.IsEmpty()) | 2593 if (csFontName.IsEmpty()) |
2767 return FALSE; | 2594 return FALSE; |
2768 | 2595 |
2769 if (m_bDelay) { | 2596 if (m_bDelay) { |
2770 AddDelay_String(FP_TEXTFONT, csFontName); | 2597 AddDelay_String(FP_TEXTFONT, csFontName); |
2771 } else { | 2598 } else { |
2772 Field::SetTextFont(m_pDocument, m_FieldName, m_nFormControlIndex, | 2599 Field::SetTextFont(m_pDocument, m_FieldName, m_nFormControlIndex, |
2773 csFontName); | 2600 csFontName); |
2774 } | 2601 } |
2775 } else { | 2602 } else { |
2776 CFX_PtrArray FieldArray; | 2603 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
2777 GetFormFields(m_FieldName, FieldArray); | 2604 if (FieldArray.empty()) |
2778 if (FieldArray.GetSize() <= 0) | |
2779 return FALSE; | 2605 return FALSE; |
2780 | 2606 |
2781 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 2607 CPDF_FormField* pFormField = FieldArray[0]; |
2782 ASSERT(pFormField != NULL); | 2608 ASSERT(pFormField); |
2783 | |
2784 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | 2609 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
2785 if (!pFormControl) | 2610 if (!pFormControl) |
2786 return FALSE; | 2611 return FALSE; |
2787 | 2612 |
2788 int nFieldType = pFormField->GetFieldType(); | 2613 int nFieldType = pFormField->GetFieldType(); |
2789 | 2614 |
2790 if (nFieldType == FIELDTYPE_PUSHBUTTON || | 2615 if (nFieldType == FIELDTYPE_PUSHBUTTON || |
2791 nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_LISTBOX || | 2616 nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_LISTBOX || |
2792 nFieldType == FIELDTYPE_TEXTFIELD) { | 2617 nFieldType == FIELDTYPE_TEXTFIELD) { |
2793 CPDF_Font* pFont = pFormControl->GetDefaultControlFont(); | 2618 CPDF_Font* pFont = pFormControl->GetDefaultControlFont(); |
2794 if (!pFont) | 2619 if (!pFont) |
2795 return FALSE; | 2620 return FALSE; |
2796 | 2621 |
2797 vp << pFont->GetBaseFont(); | 2622 vp << pFont->GetBaseFont(); |
2798 } else | 2623 } else { |
2799 return FALSE; | 2624 return FALSE; |
| 2625 } |
2800 } | 2626 } |
2801 | 2627 |
2802 return TRUE; | 2628 return TRUE; |
2803 } | 2629 } |
2804 | 2630 |
2805 void Field::SetTextFont(CPDFSDK_Document* pDocument, | 2631 void Field::SetTextFont(CPDFSDK_Document* pDocument, |
2806 const CFX_WideString& swFieldName, | 2632 const CFX_WideString& swFieldName, |
2807 int nControlIndex, | 2633 int nControlIndex, |
2808 const CFX_ByteString& string) { | 2634 const CFX_ByteString& string) { |
2809 // Not supported. | 2635 // Not supported. |
(...skipping 10 matching lines...) Expand all Loading... |
2820 | 2646 |
2821 int nVP; | 2647 int nVP; |
2822 vp >> nVP; | 2648 vp >> nVP; |
2823 | 2649 |
2824 if (m_bDelay) { | 2650 if (m_bDelay) { |
2825 AddDelay_Int(FP_TEXTSIZE, nVP); | 2651 AddDelay_Int(FP_TEXTSIZE, nVP); |
2826 } else { | 2652 } else { |
2827 Field::SetTextSize(m_pDocument, m_FieldName, m_nFormControlIndex, nVP); | 2653 Field::SetTextSize(m_pDocument, m_FieldName, m_nFormControlIndex, nVP); |
2828 } | 2654 } |
2829 } else { | 2655 } else { |
2830 CFX_PtrArray FieldArray; | 2656 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
2831 GetFormFields(m_FieldName, FieldArray); | 2657 if (FieldArray.empty()) |
2832 if (FieldArray.GetSize() <= 0) | |
2833 return FALSE; | 2658 return FALSE; |
2834 | 2659 |
2835 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 2660 CPDF_FormField* pFormField = FieldArray[0]; |
2836 ASSERT(pFormField != NULL); | 2661 ASSERT(pFormField); |
2837 | |
2838 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | 2662 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
2839 if (!pFormControl) | 2663 if (!pFormControl) |
2840 return FALSE; | 2664 return FALSE; |
2841 | 2665 |
2842 CPDF_DefaultAppearance FieldAppearance = | 2666 CPDF_DefaultAppearance FieldAppearance = |
2843 pFormControl->GetDefaultAppearance(); | 2667 pFormControl->GetDefaultAppearance(); |
2844 | 2668 |
2845 CFX_ByteString csFontNameTag; | 2669 CFX_ByteString csFontNameTag; |
2846 FX_FLOAT fFontSize; | 2670 FX_FLOAT fFontSize; |
2847 FieldAppearance.GetFont(csFontNameTag, fFontSize); | 2671 FieldAppearance.GetFont(csFontNameTag, fFontSize); |
(...skipping 12 matching lines...) Expand all Loading... |
2860 } | 2684 } |
2861 | 2685 |
2862 FX_BOOL Field::type(IJS_Context* cc, | 2686 FX_BOOL Field::type(IJS_Context* cc, |
2863 CJS_PropValue& vp, | 2687 CJS_PropValue& vp, |
2864 CFX_WideString& sError) { | 2688 CFX_WideString& sError) { |
2865 ASSERT(m_pDocument != NULL); | 2689 ASSERT(m_pDocument != NULL); |
2866 | 2690 |
2867 if (!vp.IsGetting()) | 2691 if (!vp.IsGetting()) |
2868 return FALSE; | 2692 return FALSE; |
2869 | 2693 |
2870 CFX_PtrArray FieldArray; | 2694 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
2871 GetFormFields(m_FieldName, FieldArray); | 2695 if (FieldArray.empty()) |
2872 if (FieldArray.GetSize() <= 0) | |
2873 return FALSE; | 2696 return FALSE; |
2874 | 2697 |
2875 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 2698 CPDF_FormField* pFormField = FieldArray[0]; |
2876 ASSERT(pFormField != NULL); | |
2877 | |
2878 switch (pFormField->GetFieldType()) { | 2699 switch (pFormField->GetFieldType()) { |
2879 case FIELDTYPE_UNKNOWN: | 2700 case FIELDTYPE_UNKNOWN: |
2880 vp << L"unknown"; | 2701 vp << L"unknown"; |
2881 break; | 2702 break; |
2882 case FIELDTYPE_PUSHBUTTON: | 2703 case FIELDTYPE_PUSHBUTTON: |
2883 vp << L"button"; | 2704 vp << L"button"; |
2884 break; | 2705 break; |
2885 case FIELDTYPE_CHECKBOX: | 2706 case FIELDTYPE_CHECKBOX: |
2886 vp << L"checkbox"; | 2707 vp << L"checkbox"; |
2887 break; | 2708 break; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2919 | 2740 |
2920 CFX_WideString swName; | 2741 CFX_WideString swName; |
2921 vp >> swName; | 2742 vp >> swName; |
2922 | 2743 |
2923 if (m_bDelay) { | 2744 if (m_bDelay) { |
2924 AddDelay_WideString(FP_USERNAME, swName); | 2745 AddDelay_WideString(FP_USERNAME, swName); |
2925 } else { | 2746 } else { |
2926 Field::SetUserName(m_pDocument, m_FieldName, m_nFormControlIndex, swName); | 2747 Field::SetUserName(m_pDocument, m_FieldName, m_nFormControlIndex, swName); |
2927 } | 2748 } |
2928 } else { | 2749 } else { |
2929 CFX_PtrArray FieldArray; | 2750 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
2930 GetFormFields(m_FieldName, FieldArray); | 2751 if (FieldArray.empty()) |
2931 if (FieldArray.GetSize() <= 0) | |
2932 return FALSE; | 2752 return FALSE; |
2933 | 2753 |
2934 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 2754 CPDF_FormField* pFormField = FieldArray[0]; |
2935 ASSERT(pFormField != NULL); | |
2936 | |
2937 vp << (CFX_WideString)pFormField->GetAlternateName(); | 2755 vp << (CFX_WideString)pFormField->GetAlternateName(); |
2938 } | 2756 } |
2939 | 2757 |
2940 return TRUE; | 2758 return TRUE; |
2941 } | 2759 } |
2942 | 2760 |
2943 void Field::SetUserName(CPDFSDK_Document* pDocument, | 2761 void Field::SetUserName(CPDFSDK_Document* pDocument, |
2944 const CFX_WideString& swFieldName, | 2762 const CFX_WideString& swFieldName, |
2945 int nControlIndex, | 2763 int nControlIndex, |
2946 const CFX_WideString& string) { | 2764 const CFX_WideString& string) { |
(...skipping 24 matching lines...) Expand all Loading... |
2971 vp >> swValue; | 2789 vp >> swValue; |
2972 strArray.Add(swValue); | 2790 strArray.Add(swValue); |
2973 } | 2791 } |
2974 | 2792 |
2975 if (m_bDelay) { | 2793 if (m_bDelay) { |
2976 AddDelay_WideStringArray(FP_VALUE, strArray); | 2794 AddDelay_WideStringArray(FP_VALUE, strArray); |
2977 } else { | 2795 } else { |
2978 Field::SetValue(m_pDocument, m_FieldName, m_nFormControlIndex, strArray); | 2796 Field::SetValue(m_pDocument, m_FieldName, m_nFormControlIndex, strArray); |
2979 } | 2797 } |
2980 } else { | 2798 } else { |
2981 CFX_PtrArray FieldArray; | 2799 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
2982 GetFormFields(m_FieldName, FieldArray); | 2800 if (FieldArray.empty()) |
2983 if (FieldArray.GetSize() <= 0) | |
2984 return FALSE; | 2801 return FALSE; |
2985 | 2802 |
2986 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 2803 CPDF_FormField* pFormField = FieldArray[0]; |
2987 switch (pFormField->GetFieldType()) { | 2804 switch (pFormField->GetFieldType()) { |
2988 case FIELDTYPE_PUSHBUTTON: | 2805 case FIELDTYPE_PUSHBUTTON: |
2989 return FALSE; | 2806 return FALSE; |
2990 case FIELDTYPE_COMBOBOX: | 2807 case FIELDTYPE_COMBOBOX: |
2991 case FIELDTYPE_TEXTFIELD: { | 2808 case FIELDTYPE_TEXTFIELD: { |
2992 CFX_WideString swValue = pFormField->GetValue(); | 2809 CFX_WideString swValue = pFormField->GetValue(); |
2993 | 2810 |
2994 double dRet; | 2811 double dRet; |
2995 FX_BOOL bDot; | 2812 FX_BOOL bDot; |
2996 if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet, | 2813 if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet, |
2997 bDot)) { | 2814 bDot)) { |
2998 if (bDot) | 2815 if (bDot) |
2999 vp << dRet; | 2816 vp << dRet; |
3000 else | 2817 else |
3001 vp << dRet; | 2818 vp << dRet; |
3002 } else | 2819 } else { |
3003 vp << swValue; | 2820 vp << swValue; |
| 2821 } |
3004 } break; | 2822 } break; |
3005 case FIELDTYPE_LISTBOX: { | 2823 case FIELDTYPE_LISTBOX: { |
3006 if (pFormField->CountSelectedItems() > 1) { | 2824 if (pFormField->CountSelectedItems() > 1) { |
3007 CJS_Array ValueArray(pRuntime); | 2825 CJS_Array ValueArray(pRuntime); |
3008 CJS_Value ElementValue(pRuntime); | 2826 CJS_Value ElementValue(pRuntime); |
3009 int iIndex; | 2827 int iIndex; |
3010 for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) { | 2828 for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) { |
3011 iIndex = pFormField->GetSelectedIndex(i); | 2829 iIndex = pFormField->GetSelectedIndex(i); |
3012 ElementValue = pFormField->GetOptionValue(iIndex).c_str(); | 2830 ElementValue = pFormField->GetOptionValue(iIndex).c_str(); |
3013 if (FXSYS_wcslen(ElementValue.ToCFXWideString().c_str()) == 0) | 2831 if (FXSYS_wcslen(ElementValue.ToCFXWideString().c_str()) == 0) |
3014 ElementValue = pFormField->GetOptionLabel(iIndex).c_str(); | 2832 ElementValue = pFormField->GetOptionLabel(iIndex).c_str(); |
3015 ValueArray.SetElement(i, ElementValue); | 2833 ValueArray.SetElement(i, ElementValue); |
3016 } | 2834 } |
3017 vp << ValueArray; | 2835 vp << ValueArray; |
3018 } else { | 2836 } else { |
3019 CFX_WideString swValue = pFormField->GetValue(); | 2837 CFX_WideString swValue = pFormField->GetValue(); |
3020 | 2838 |
3021 double dRet; | 2839 double dRet; |
3022 FX_BOOL bDot; | 2840 FX_BOOL bDot; |
3023 if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet, | 2841 if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet, |
3024 bDot)) { | 2842 bDot)) { |
3025 if (bDot) | 2843 if (bDot) |
3026 vp << dRet; | 2844 vp << dRet; |
3027 else | 2845 else |
3028 vp << dRet; | 2846 vp << dRet; |
3029 } else | 2847 } else { |
3030 vp << swValue; | 2848 vp << swValue; |
| 2849 } |
3031 } | 2850 } |
3032 } break; | 2851 } break; |
3033 case FIELDTYPE_CHECKBOX: | 2852 case FIELDTYPE_CHECKBOX: |
3034 case FIELDTYPE_RADIOBUTTON: { | 2853 case FIELDTYPE_RADIOBUTTON: { |
3035 FX_BOOL bFind = FALSE; | 2854 FX_BOOL bFind = FALSE; |
3036 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { | 2855 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { |
3037 if (pFormField->GetControl(i)->IsChecked()) { | 2856 if (!pFormField->GetControl(i)->IsChecked()) |
3038 CFX_WideString swValue = | 2857 continue; |
3039 pFormField->GetControl(i)->GetExportValue(); | |
3040 double dRet; | |
3041 FX_BOOL bDot; | |
3042 if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet, | |
3043 bDot)) { | |
3044 if (bDot) | |
3045 vp << dRet; | |
3046 else | |
3047 vp << dRet; | |
3048 } else | |
3049 vp << swValue; | |
3050 | 2858 |
3051 bFind = TRUE; | 2859 CFX_WideString swValue = pFormField->GetControl(i)->GetExportValue(); |
3052 break; | 2860 double dRet; |
3053 } else | 2861 FX_BOOL bDotDummy; |
3054 continue; | 2862 if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet, |
| 2863 bDotDummy)) { |
| 2864 vp << dRet; |
| 2865 } else { |
| 2866 vp << swValue; |
| 2867 } |
| 2868 |
| 2869 bFind = TRUE; |
| 2870 break; |
3055 } | 2871 } |
3056 if (!bFind) | 2872 if (!bFind) |
3057 vp << L"Off"; | 2873 vp << L"Off"; |
3058 } break; | 2874 } break; |
3059 default: | 2875 default: |
3060 vp << pFormField->GetValue(); | 2876 vp << pFormField->GetValue(); |
3061 break; | 2877 break; |
3062 } | 2878 } |
3063 } | 2879 } |
3064 | 2880 |
3065 return TRUE; | 2881 return TRUE; |
3066 } | 2882 } |
3067 | 2883 |
3068 void Field::SetValue(CPDFSDK_Document* pDocument, | 2884 void Field::SetValue(CPDFSDK_Document* pDocument, |
3069 const CFX_WideString& swFieldName, | 2885 const CFX_WideString& swFieldName, |
3070 int nControlIndex, | 2886 int nControlIndex, |
3071 const CJS_WideStringArray& strArray) { | 2887 const CJS_WideStringArray& strArray) { |
3072 ASSERT(pDocument != NULL); | 2888 ASSERT(pDocument != NULL); |
3073 | 2889 |
3074 if (strArray.GetSize() < 1) | 2890 if (strArray.GetSize() < 1) |
3075 return; | 2891 return; |
3076 | 2892 |
3077 CFX_PtrArray FieldArray; | 2893 std::vector<CPDF_FormField*> FieldArray = |
3078 GetFormFields(pDocument, swFieldName, FieldArray); | 2894 GetFormFields(pDocument, swFieldName); |
3079 | 2895 |
3080 for (int i = 0, isz = FieldArray.GetSize(); i < isz; i++) { | 2896 for (CPDF_FormField* pFormField : FieldArray) { |
3081 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i); | |
3082 ASSERT(pFormField != NULL); | |
3083 | |
3084 if (pFormField->GetFullName().Compare(swFieldName) != 0) | 2897 if (pFormField->GetFullName().Compare(swFieldName) != 0) |
3085 continue; | 2898 continue; |
3086 | 2899 |
3087 switch (pFormField->GetFieldType()) { | 2900 switch (pFormField->GetFieldType()) { |
3088 case FIELDTYPE_TEXTFIELD: | 2901 case FIELDTYPE_TEXTFIELD: |
3089 case FIELDTYPE_COMBOBOX: | 2902 case FIELDTYPE_COMBOBOX: |
3090 if (pFormField->GetValue() != strArray.GetAt(0)) { | 2903 if (pFormField->GetValue() != strArray.GetAt(0)) { |
3091 CFX_WideString WideString = strArray.GetAt(0); | 2904 CFX_WideString WideString = strArray.GetAt(0); |
3092 pFormField->SetValue(strArray.GetAt(0), TRUE); | 2905 pFormField->SetValue(strArray.GetAt(0), TRUE); |
3093 UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE); | 2906 UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3129 } | 2942 } |
3130 | 2943 |
3131 FX_BOOL Field::valueAsString(IJS_Context* cc, | 2944 FX_BOOL Field::valueAsString(IJS_Context* cc, |
3132 CJS_PropValue& vp, | 2945 CJS_PropValue& vp, |
3133 CFX_WideString& sError) { | 2946 CFX_WideString& sError) { |
3134 ASSERT(m_pDocument != NULL); | 2947 ASSERT(m_pDocument != NULL); |
3135 | 2948 |
3136 if (!vp.IsGetting()) | 2949 if (!vp.IsGetting()) |
3137 return FALSE; | 2950 return FALSE; |
3138 | 2951 |
3139 CFX_PtrArray FieldArray; | 2952 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
3140 GetFormFields(m_FieldName, FieldArray); | 2953 if (FieldArray.empty()) |
3141 if (FieldArray.GetSize() <= 0) | |
3142 return FALSE; | 2954 return FALSE; |
3143 | 2955 |
3144 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 2956 CPDF_FormField* pFormField = FieldArray[0]; |
3145 ASSERT(pFormField != NULL); | |
3146 | |
3147 if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON) | 2957 if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON) |
3148 return FALSE; | 2958 return FALSE; |
3149 | 2959 |
3150 if (pFormField->GetFieldType() == FIELDTYPE_CHECKBOX) { | 2960 if (pFormField->GetFieldType() == FIELDTYPE_CHECKBOX) { |
3151 if (!pFormField->CountControls()) | 2961 if (!pFormField->CountControls()) |
3152 return FALSE; | 2962 return FALSE; |
3153 | 2963 |
3154 if (pFormField->GetControl(0)->IsChecked()) | 2964 if (pFormField->GetControl(0)->IsChecked()) |
3155 vp << L"Yes"; | 2965 vp << L"Yes"; |
3156 else | 2966 else |
3157 vp << L"Off"; | 2967 vp << L"Off"; |
3158 } else if (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON && | 2968 } else if (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON && |
3159 !(pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON)) { | 2969 !(pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON)) { |
3160 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { | 2970 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { |
3161 if (pFormField->GetControl(i)->IsChecked()) { | 2971 if (pFormField->GetControl(i)->IsChecked()) { |
3162 vp << pFormField->GetControl(i)->GetExportValue().c_str(); | 2972 vp << pFormField->GetControl(i)->GetExportValue().c_str(); |
3163 break; | 2973 break; |
3164 } else | 2974 } else { |
3165 vp << L"Off"; | 2975 vp << L"Off"; |
| 2976 } |
3166 } | 2977 } |
3167 } else if (pFormField->GetFieldType() == FIELDTYPE_LISTBOX && | 2978 } else if (pFormField->GetFieldType() == FIELDTYPE_LISTBOX && |
3168 (pFormField->CountSelectedItems() > 1)) { | 2979 (pFormField->CountSelectedItems() > 1)) { |
3169 vp << L""; | 2980 vp << L""; |
3170 } else | 2981 } else { |
3171 vp << pFormField->GetValue().c_str(); | 2982 vp << pFormField->GetValue().c_str(); |
| 2983 } |
3172 | 2984 |
3173 return TRUE; | 2985 return TRUE; |
3174 } | 2986 } |
3175 | 2987 |
3176 /* --------------------------------- methods --------------------------------- | 2988 /* --------------------------------- methods --------------------------------- |
3177 */ | 2989 */ |
3178 | 2990 |
3179 FX_BOOL Field::browseForFileToSubmit(IJS_Context* cc, | 2991 FX_BOOL Field::browseForFileToSubmit(IJS_Context* cc, |
3180 const CJS_Parameters& params, | 2992 const CJS_Parameters& params, |
3181 CJS_Value& vRet, | 2993 CJS_Value& vRet, |
3182 CFX_WideString& sError) { | 2994 CFX_WideString& sError) { |
3183 ASSERT(m_pDocument != NULL); | 2995 ASSERT(m_pDocument != NULL); |
3184 | 2996 |
3185 CFX_PtrArray FieldArray; | 2997 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
3186 GetFormFields(m_FieldName, FieldArray); | 2998 if (FieldArray.empty()) |
3187 if (FieldArray.GetSize() <= 0) | |
3188 return FALSE; | 2999 return FALSE; |
3189 | 3000 |
3190 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 3001 CPDF_FormField* pFormField = FieldArray[0]; |
3191 ASSERT(pFormField != NULL); | |
3192 | |
3193 CPDFDoc_Environment* pApp = m_pDocument->GetEnv(); | 3002 CPDFDoc_Environment* pApp = m_pDocument->GetEnv(); |
3194 ASSERT(pApp != NULL); | |
3195 | |
3196 if ((pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT) && | 3003 if ((pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT) && |
3197 (pFormField->GetFieldType() == FIELDTYPE_TEXTFIELD)) { | 3004 (pFormField->GetFieldType() == FIELDTYPE_TEXTFIELD)) { |
3198 CFX_WideString wsFileName = pApp->JS_fieldBrowse(); | 3005 CFX_WideString wsFileName = pApp->JS_fieldBrowse(); |
3199 if (!wsFileName.IsEmpty()) { | 3006 if (!wsFileName.IsEmpty()) { |
3200 pFormField->SetValue(wsFileName); | 3007 pFormField->SetValue(wsFileName); |
3201 UpdateFormField(m_pDocument, pFormField, TRUE, TRUE, TRUE); | 3008 UpdateFormField(m_pDocument, pFormField, TRUE, TRUE, TRUE); |
3202 } | 3009 } |
3203 } else | 3010 return TRUE; |
3204 return FALSE; | 3011 } |
3205 | 3012 return FALSE; |
3206 return TRUE; | |
3207 } | 3013 } |
3208 | 3014 |
3209 FX_BOOL Field::buttonGetCaption(IJS_Context* cc, | 3015 FX_BOOL Field::buttonGetCaption(IJS_Context* cc, |
3210 const CJS_Parameters& params, | 3016 const CJS_Parameters& params, |
3211 CJS_Value& vRet, | 3017 CJS_Value& vRet, |
3212 CFX_WideString& sError) { | 3018 CFX_WideString& sError) { |
3213 ASSERT(m_pDocument != NULL); | 3019 ASSERT(m_pDocument != NULL); |
3214 | 3020 |
3215 int nface = 0; | 3021 int nface = 0; |
3216 int iSize = params.size(); | 3022 int iSize = params.size(); |
3217 if (iSize >= 1) | 3023 if (iSize >= 1) |
3218 nface = params[0].ToInt(); | 3024 nface = params[0].ToInt(); |
3219 | 3025 |
3220 CFX_PtrArray FieldArray; | 3026 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
3221 GetFormFields(m_FieldName, FieldArray); | 3027 if (FieldArray.empty()) |
3222 if (FieldArray.GetSize() <= 0) | |
3223 return FALSE; | 3028 return FALSE; |
3224 | 3029 |
3225 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 3030 CPDF_FormField* pFormField = FieldArray[0]; |
3226 ASSERT(pFormField != NULL); | |
3227 | |
3228 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) | 3031 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) |
3229 return FALSE; | 3032 return FALSE; |
3230 | 3033 |
3231 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | 3034 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
3232 if (!pFormControl) | 3035 if (!pFormControl) |
3233 return FALSE; | 3036 return FALSE; |
3234 | 3037 |
3235 if (nface == 0) | 3038 if (nface == 0) |
3236 vRet = pFormControl->GetNormalCaption().c_str(); | 3039 vRet = pFormControl->GetNormalCaption().c_str(); |
3237 else if (nface == 1) | 3040 else if (nface == 1) |
3238 vRet = pFormControl->GetDownCaption().c_str(); | 3041 vRet = pFormControl->GetDownCaption().c_str(); |
3239 else if (nface == 2) | 3042 else if (nface == 2) |
3240 vRet = pFormControl->GetRolloverCaption().c_str(); | 3043 vRet = pFormControl->GetRolloverCaption().c_str(); |
3241 else | 3044 else |
3242 return FALSE; | 3045 return FALSE; |
3243 | 3046 |
3244 return TRUE; | 3047 return TRUE; |
3245 } | 3048 } |
3246 | 3049 |
3247 //#pragma warning(disable: 4800) | |
3248 | |
3249 FX_BOOL Field::buttonGetIcon(IJS_Context* cc, | 3050 FX_BOOL Field::buttonGetIcon(IJS_Context* cc, |
3250 const CJS_Parameters& params, | 3051 const CJS_Parameters& params, |
3251 CJS_Value& vRet, | 3052 CJS_Value& vRet, |
3252 CFX_WideString& sError) { | 3053 CFX_WideString& sError) { |
3253 ASSERT(m_pDocument != NULL); | 3054 ASSERT(m_pDocument != NULL); |
3254 | 3055 |
3255 int nface = 0; | 3056 int nface = 0; |
3256 int iSize = params.size(); | 3057 int iSize = params.size(); |
3257 if (iSize >= 1) | 3058 if (iSize >= 1) |
3258 nface = params[0].ToInt(); | 3059 nface = params[0].ToInt(); |
3259 | 3060 |
3260 CFX_PtrArray FieldArray; | 3061 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
3261 GetFormFields(m_FieldName, FieldArray); | 3062 if (FieldArray.empty()) |
3262 if (FieldArray.GetSize() <= 0) | |
3263 return FALSE; | 3063 return FALSE; |
3264 | 3064 |
3265 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 3065 CPDF_FormField* pFormField = FieldArray[0]; |
3266 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) | 3066 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) |
3267 return FALSE; | 3067 return FALSE; |
3268 | 3068 |
3269 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | 3069 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
3270 if (!pFormControl) | 3070 if (!pFormControl) |
3271 return FALSE; | 3071 return FALSE; |
3272 | 3072 |
3273 CJS_Context* pContext = (CJS_Context*)cc; | 3073 CJS_Context* pContext = (CJS_Context*)cc; |
3274 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 3074 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
3275 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( | 3075 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( |
(...skipping 16 matching lines...) Expand all Loading... |
3292 pIcon->SetStream(pIconStream); | 3092 pIcon->SetStream(pIconStream); |
3293 vRet = pJS_Icon; | 3093 vRet = pJS_Icon; |
3294 | 3094 |
3295 return TRUE; | 3095 return TRUE; |
3296 } | 3096 } |
3297 | 3097 |
3298 FX_BOOL Field::buttonImportIcon(IJS_Context* cc, | 3098 FX_BOOL Field::buttonImportIcon(IJS_Context* cc, |
3299 const CJS_Parameters& params, | 3099 const CJS_Parameters& params, |
3300 CJS_Value& vRet, | 3100 CJS_Value& vRet, |
3301 CFX_WideString& sError) { | 3101 CFX_WideString& sError) { |
3302 #if 0 | |
3303 ASSERT(m_pDocument != NULL); | |
3304 | |
3305 CFX_PtrArray FieldArray; | |
3306 GetFormFields(m_FieldName,FieldArray); | |
3307 if (FieldArray.GetSize() <= 0) return FALSE; | |
3308 | |
3309 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
3310 if (!pFormField)return FALSE; | |
3311 | |
3312 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | |
3313 ASSERT(pEnv); | |
3314 | |
3315 CFX_WideString sIconFileName = pEnv->JS_fieldBrowse(); | |
3316 if (sIconFileName.IsEmpty()) | |
3317 { | |
3318 vRet = 1; | |
3319 return TRUE; | |
3320 } | |
3321 | |
3322 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterFor
m(); | |
3323 ASSERT(pInterForm != NULL); | |
3324 | |
3325 CPDF_Stream* pStream = pInterForm->LoadImageFromFile(sIconFileName); | |
3326 if (!pStream) | |
3327 { | |
3328 vRet = -1; | |
3329 return TRUE; | |
3330 } | |
3331 | |
3332 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | |
3333 if (!pFormControl)return FALSE; | |
3334 | |
3335 pFormControl->SetNormalIcon(pStream); | |
3336 UpdateFormControl(m_pDocument, pFormControl, TRUE, TRUE, TRUE); | |
3337 | |
3338 vRet = 0; | |
3339 #endif // 0 | |
3340 return TRUE; | 3102 return TRUE; |
3341 } | 3103 } |
3342 | 3104 |
3343 FX_BOOL Field::buttonSetCaption(IJS_Context* cc, | 3105 FX_BOOL Field::buttonSetCaption(IJS_Context* cc, |
3344 const CJS_Parameters& params, | 3106 const CJS_Parameters& params, |
3345 CJS_Value& vRet, | 3107 CJS_Value& vRet, |
3346 CFX_WideString& sError) { | 3108 CFX_WideString& sError) { |
3347 return FALSE; | 3109 return FALSE; |
3348 } | 3110 } |
3349 | 3111 |
(...skipping 16 matching lines...) Expand all Loading... |
3366 int iSize = params.size(); | 3128 int iSize = params.size(); |
3367 if (iSize < 1) | 3129 if (iSize < 1) |
3368 return FALSE; | 3130 return FALSE; |
3369 | 3131 |
3370 int nWidget = params[0].ToInt(); | 3132 int nWidget = params[0].ToInt(); |
3371 | 3133 |
3372 FX_BOOL bCheckit = TRUE; | 3134 FX_BOOL bCheckit = TRUE; |
3373 if (iSize >= 2) | 3135 if (iSize >= 2) |
3374 bCheckit = params[1].ToBool(); | 3136 bCheckit = params[1].ToBool(); |
3375 | 3137 |
3376 CFX_PtrArray FieldArray; | 3138 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
3377 GetFormFields(m_FieldName, FieldArray); | 3139 if (FieldArray.empty()) |
3378 if (FieldArray.GetSize() <= 0) | |
3379 return FALSE; | 3140 return FALSE; |
3380 | 3141 |
3381 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 3142 CPDF_FormField* pFormField = FieldArray[0]; |
3382 ASSERT(pFormField != NULL); | |
3383 | |
3384 if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX && | 3143 if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX && |
3385 pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON) | 3144 pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON) |
3386 return FALSE; | 3145 return FALSE; |
3387 if (nWidget < 0 || nWidget >= pFormField->CountControls()) | 3146 if (nWidget < 0 || nWidget >= pFormField->CountControls()) |
3388 return FALSE; | 3147 return FALSE; |
3389 if (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON) | 3148 if (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON) |
3390 pFormField->CheckControl(nWidget, bCheckit, TRUE); | 3149 pFormField->CheckControl(nWidget, bCheckit, TRUE); |
3391 else | 3150 else |
3392 pFormField->CheckControl(nWidget, bCheckit, TRUE); | 3151 pFormField->CheckControl(nWidget, bCheckit, TRUE); |
3393 | 3152 |
(...skipping 16 matching lines...) Expand all Loading... |
3410 | 3169 |
3411 if (!m_bCanSet) | 3170 if (!m_bCanSet) |
3412 return FALSE; | 3171 return FALSE; |
3413 | 3172 |
3414 int iSize = params.size(); | 3173 int iSize = params.size(); |
3415 if (iSize < 1) | 3174 if (iSize < 1) |
3416 return FALSE; | 3175 return FALSE; |
3417 | 3176 |
3418 int nWidget = params[0].ToInt(); | 3177 int nWidget = params[0].ToInt(); |
3419 | 3178 |
3420 CFX_PtrArray FieldArray; | 3179 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
3421 GetFormFields(m_FieldName, FieldArray); | 3180 if (FieldArray.empty()) |
3422 if (FieldArray.GetSize() <= 0) | |
3423 return FALSE; | 3181 return FALSE; |
3424 | 3182 |
3425 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 3183 CPDF_FormField* pFormField = FieldArray[0]; |
3426 ASSERT(pFormField != NULL); | |
3427 | |
3428 if (nWidget < 0 || nWidget >= pFormField->CountControls()) { | 3184 if (nWidget < 0 || nWidget >= pFormField->CountControls()) { |
3429 vRet = FALSE; | 3185 vRet = FALSE; |
3430 return FALSE; | 3186 return FALSE; |
3431 } | 3187 } |
3432 if ((pFormField->GetFieldType() == FIELDTYPE_CHECKBOX) || | 3188 vRet = pFormField->GetFieldType() == FIELDTYPE_CHECKBOX || |
3433 (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON)) { | 3189 pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON; |
3434 vRet = TRUE; | |
3435 } else | |
3436 vRet = FALSE; | |
3437 | 3190 |
3438 return TRUE; | 3191 return TRUE; |
3439 } | 3192 } |
3440 | 3193 |
3441 FX_BOOL Field::deleteItemAt(IJS_Context* cc, | 3194 FX_BOOL Field::deleteItemAt(IJS_Context* cc, |
3442 const CJS_Parameters& params, | 3195 const CJS_Parameters& params, |
3443 CJS_Value& vRet, | 3196 CJS_Value& vRet, |
3444 CFX_WideString& sError) { | 3197 CFX_WideString& sError) { |
3445 return TRUE; | 3198 return TRUE; |
3446 } | 3199 } |
3447 | 3200 |
3448 int JS_COMPARESTRING(CFX_WideString* ps1, CFX_WideString* ps2) { | 3201 int JS_COMPARESTRING(CFX_WideString* ps1, CFX_WideString* ps2) { |
3449 ASSERT(ps1 != NULL); | 3202 ASSERT(ps1 != NULL); |
3450 ASSERT(ps2 != NULL); | 3203 ASSERT(ps2 != NULL); |
3451 | 3204 |
3452 return ps1->Compare(*ps2); | 3205 return ps1->Compare(*ps2); |
3453 } | 3206 } |
3454 | 3207 |
3455 FX_BOOL Field::getArray(IJS_Context* cc, | 3208 FX_BOOL Field::getArray(IJS_Context* cc, |
3456 const CJS_Parameters& params, | 3209 const CJS_Parameters& params, |
3457 CJS_Value& vRet, | 3210 CJS_Value& vRet, |
3458 CFX_WideString& sError) { | 3211 CFX_WideString& sError) { |
3459 ASSERT(m_pDocument != NULL); | 3212 ASSERT(m_pDocument != NULL); |
3460 | 3213 |
3461 CFX_PtrArray FieldArray; | 3214 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
3462 GetFormFields(m_FieldName, FieldArray); | 3215 if (FieldArray.empty()) |
3463 if (FieldArray.GetSize() <= 0) | |
3464 return FALSE; | 3216 return FALSE; |
3465 | 3217 |
3466 CGW_ArrayTemplate<CFX_WideString*> swSort; | 3218 CGW_ArrayTemplate<CFX_WideString*> swSort; |
3467 | 3219 |
3468 for (int i = 0, sz = FieldArray.GetSize(); i < sz; i++) { | 3220 for (CPDF_FormField* pFormField : FieldArray) |
3469 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i); | |
3470 ASSERT(pFormField != NULL); | |
3471 | |
3472 swSort.Add(new CFX_WideString(pFormField->GetFullName())); | 3221 swSort.Add(new CFX_WideString(pFormField->GetFullName())); |
3473 } | |
3474 swSort.Sort(JS_COMPARESTRING); | 3222 swSort.Sort(JS_COMPARESTRING); |
3475 | 3223 |
3476 CJS_Context* pContext = (CJS_Context*)cc; | 3224 CJS_Context* pContext = (CJS_Context*)cc; |
3477 ASSERT(pContext != NULL); | |
3478 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 3225 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
3479 ASSERT(pRuntime != NULL); | 3226 ASSERT(pRuntime); |
3480 | 3227 |
3481 CJS_Array FormFieldArray(pRuntime); | 3228 CJS_Array FormFieldArray(pRuntime); |
3482 for (int j = 0, jsz = swSort.GetSize(); j < jsz; j++) { | 3229 for (int j = 0, jsz = swSort.GetSize(); j < jsz; j++) { |
3483 nonstd::unique_ptr<CFX_WideString> pStr(swSort.GetAt(j)); | 3230 nonstd::unique_ptr<CFX_WideString> pStr(swSort.GetAt(j)); |
3484 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( | 3231 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( |
3485 pRuntime->GetIsolate(), pRuntime, CJS_Field::g_nObjDefnID); | 3232 pRuntime->GetIsolate(), pRuntime, CJS_Field::g_nObjDefnID); |
3486 ASSERT(!pObj.IsEmpty()); | 3233 ASSERT(!pObj.IsEmpty()); |
3487 | 3234 |
3488 CJS_Field* pJSField = | 3235 CJS_Field* pJSField = |
3489 (CJS_Field*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); | 3236 (CJS_Field*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); |
(...skipping 18 matching lines...) Expand all Loading... |
3508 int iSize = params.size(); | 3255 int iSize = params.size(); |
3509 | 3256 |
3510 int nIdx = -1; | 3257 int nIdx = -1; |
3511 if (iSize >= 1) | 3258 if (iSize >= 1) |
3512 nIdx = params[0].ToInt(); | 3259 nIdx = params[0].ToInt(); |
3513 | 3260 |
3514 FX_BOOL bExport = TRUE; | 3261 FX_BOOL bExport = TRUE; |
3515 if (iSize >= 2) | 3262 if (iSize >= 2) |
3516 bExport = params[1].ToBool(); | 3263 bExport = params[1].ToBool(); |
3517 | 3264 |
3518 CFX_PtrArray FieldArray; | 3265 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
3519 GetFormFields(m_FieldName, FieldArray); | 3266 if (FieldArray.empty()) |
3520 if (FieldArray.GetSize() <= 0) | |
3521 return FALSE; | 3267 return FALSE; |
3522 | 3268 |
3523 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 3269 CPDF_FormField* pFormField = FieldArray[0]; |
3524 ASSERT(pFormField != NULL); | |
3525 | |
3526 if ((pFormField->GetFieldType() == FIELDTYPE_LISTBOX) || | 3270 if ((pFormField->GetFieldType() == FIELDTYPE_LISTBOX) || |
3527 (pFormField->GetFieldType() == FIELDTYPE_COMBOBOX)) { | 3271 (pFormField->GetFieldType() == FIELDTYPE_COMBOBOX)) { |
3528 if (nIdx == -1 || nIdx > pFormField->CountOptions()) | 3272 if (nIdx == -1 || nIdx > pFormField->CountOptions()) |
3529 nIdx = pFormField->CountOptions() - 1; | 3273 nIdx = pFormField->CountOptions() - 1; |
3530 if (bExport) { | 3274 if (bExport) { |
3531 CFX_WideString strval = pFormField->GetOptionValue(nIdx); | 3275 CFX_WideString strval = pFormField->GetOptionValue(nIdx); |
3532 if (strval.IsEmpty()) | 3276 if (strval.IsEmpty()) |
3533 vRet = pFormField->GetOptionLabel(nIdx).c_str(); | 3277 vRet = pFormField->GetOptionLabel(nIdx).c_str(); |
3534 else | 3278 else |
3535 vRet = strval.c_str(); | 3279 vRet = strval.c_str(); |
3536 } else | 3280 } else { |
3537 vRet = pFormField->GetOptionLabel(nIdx).c_str(); | 3281 vRet = pFormField->GetOptionLabel(nIdx).c_str(); |
3538 } else | 3282 } |
| 3283 } else { |
3539 return FALSE; | 3284 return FALSE; |
| 3285 } |
3540 | 3286 |
3541 return TRUE; | 3287 return TRUE; |
3542 } | 3288 } |
3543 | 3289 |
3544 FX_BOOL Field::getLock(IJS_Context* cc, | 3290 FX_BOOL Field::getLock(IJS_Context* cc, |
3545 const CJS_Parameters& params, | 3291 const CJS_Parameters& params, |
3546 CJS_Value& vRet, | 3292 CJS_Value& vRet, |
3547 CFX_WideString& sError) { | 3293 CFX_WideString& sError) { |
3548 return FALSE; | 3294 return FALSE; |
3549 } | 3295 } |
3550 | 3296 |
3551 FX_BOOL Field::insertItemAt(IJS_Context* cc, | 3297 FX_BOOL Field::insertItemAt(IJS_Context* cc, |
3552 const CJS_Parameters& params, | 3298 const CJS_Parameters& params, |
3553 CJS_Value& vRet, | 3299 CJS_Value& vRet, |
3554 CFX_WideString& sError) { | 3300 CFX_WideString& sError) { |
3555 return TRUE; | 3301 return TRUE; |
3556 } | 3302 } |
3557 | 3303 |
3558 FX_BOOL Field::isBoxChecked(IJS_Context* cc, | 3304 FX_BOOL Field::isBoxChecked(IJS_Context* cc, |
3559 const CJS_Parameters& params, | 3305 const CJS_Parameters& params, |
3560 CJS_Value& vRet, | 3306 CJS_Value& vRet, |
3561 CFX_WideString& sError) { | 3307 CFX_WideString& sError) { |
3562 ASSERT(m_pDocument != NULL); | 3308 ASSERT(m_pDocument != NULL); |
3563 | 3309 |
3564 int nIndex = -1; | 3310 int nIndex = -1; |
3565 if (params.size() >= 1) | 3311 if (params.size() >= 1) |
3566 nIndex = params[0].ToInt(); | 3312 nIndex = params[0].ToInt(); |
3567 | 3313 |
3568 CFX_PtrArray FieldArray; | 3314 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
3569 GetFormFields(m_FieldName, FieldArray); | 3315 if (FieldArray.empty()) |
3570 if (FieldArray.GetSize() <= 0) | |
3571 return FALSE; | 3316 return FALSE; |
3572 | 3317 |
3573 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 3318 CPDF_FormField* pFormField = FieldArray[0]; |
3574 ASSERT(pFormField != NULL); | |
3575 | |
3576 if (nIndex < 0 || nIndex >= pFormField->CountControls()) { | 3319 if (nIndex < 0 || nIndex >= pFormField->CountControls()) { |
3577 vRet = FALSE; | 3320 vRet = FALSE; |
3578 return FALSE; | 3321 return FALSE; |
3579 } | 3322 } |
3580 | 3323 |
3581 if ((pFormField->GetFieldType() == FIELDTYPE_CHECKBOX) || | 3324 if ((pFormField->GetFieldType() == FIELDTYPE_CHECKBOX) || |
3582 (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON)) { | 3325 (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON)) { |
3583 if (pFormField->GetControl(nIndex)->IsChecked() != 0) | 3326 if (pFormField->GetControl(nIndex)->IsChecked() != 0) |
3584 vRet = TRUE; | 3327 vRet = TRUE; |
3585 else | 3328 else |
3586 vRet = FALSE; | 3329 vRet = FALSE; |
3587 } else | 3330 } else { |
3588 vRet = FALSE; | 3331 vRet = FALSE; |
| 3332 } |
3589 | 3333 |
3590 return TRUE; | 3334 return TRUE; |
3591 } | 3335 } |
3592 | 3336 |
3593 FX_BOOL Field::isDefaultChecked(IJS_Context* cc, | 3337 FX_BOOL Field::isDefaultChecked(IJS_Context* cc, |
3594 const CJS_Parameters& params, | 3338 const CJS_Parameters& params, |
3595 CJS_Value& vRet, | 3339 CJS_Value& vRet, |
3596 CFX_WideString& sError) { | 3340 CFX_WideString& sError) { |
3597 ASSERT(m_pDocument != NULL); | 3341 ASSERT(m_pDocument != NULL); |
3598 | 3342 |
3599 int nIndex = -1; | 3343 int nIndex = -1; |
3600 if (params.size() >= 1) | 3344 if (params.size() >= 1) |
3601 nIndex = params[0].ToInt(); | 3345 nIndex = params[0].ToInt(); |
3602 | 3346 |
3603 CFX_PtrArray FieldArray; | 3347 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
3604 GetFormFields(m_FieldName, FieldArray); | 3348 if (FieldArray.empty()) |
3605 if (FieldArray.GetSize() <= 0) | |
3606 return FALSE; | 3349 return FALSE; |
3607 | 3350 |
3608 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 3351 CPDF_FormField* pFormField = FieldArray[0]; |
3609 ASSERT(pFormField != NULL); | |
3610 | |
3611 if (nIndex < 0 || nIndex >= pFormField->CountControls()) { | 3352 if (nIndex < 0 || nIndex >= pFormField->CountControls()) { |
3612 vRet = FALSE; | 3353 vRet = FALSE; |
3613 return FALSE; | 3354 return FALSE; |
3614 } | 3355 } |
3615 if ((pFormField->GetFieldType() == FIELDTYPE_CHECKBOX) || | 3356 if ((pFormField->GetFieldType() == FIELDTYPE_CHECKBOX) || |
3616 (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON)) { | 3357 (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON)) { |
3617 if (pFormField->GetControl(nIndex)->IsDefaultChecked() != 0) | 3358 if (pFormField->GetControl(nIndex)->IsDefaultChecked() != 0) |
3618 vRet = TRUE; | 3359 vRet = TRUE; |
3619 else | 3360 else |
3620 vRet = FALSE; | 3361 vRet = FALSE; |
3621 } else | 3362 } else { |
3622 vRet = FALSE; | 3363 vRet = FALSE; |
| 3364 } |
3623 | 3365 |
3624 return TRUE; | 3366 return TRUE; |
3625 } | 3367 } |
3626 | 3368 |
3627 FX_BOOL Field::setAction(IJS_Context* cc, | 3369 FX_BOOL Field::setAction(IJS_Context* cc, |
3628 const CJS_Parameters& params, | 3370 const CJS_Parameters& params, |
3629 CJS_Value& vRet, | 3371 CJS_Value& vRet, |
3630 CFX_WideString& sError) { | 3372 CFX_WideString& sError) { |
3631 return TRUE; | 3373 return TRUE; |
3632 } | 3374 } |
3633 | 3375 |
3634 FX_BOOL Field::setFocus(IJS_Context* cc, | 3376 FX_BOOL Field::setFocus(IJS_Context* cc, |
3635 const CJS_Parameters& params, | 3377 const CJS_Parameters& params, |
3636 CJS_Value& vRet, | 3378 CJS_Value& vRet, |
3637 CFX_WideString& sError) { | 3379 CFX_WideString& sError) { |
3638 ASSERT(m_pDocument != NULL); | 3380 ASSERT(m_pDocument != NULL); |
3639 | 3381 |
3640 CFX_PtrArray FieldArray; | 3382 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
3641 GetFormFields(m_FieldName, FieldArray); | 3383 if (FieldArray.empty()) |
3642 if (FieldArray.GetSize() <= 0) | |
3643 return FALSE; | 3384 return FALSE; |
3644 | 3385 |
3645 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 3386 CPDF_FormField* pFormField = FieldArray[0]; |
3646 ASSERT(pFormField != NULL); | |
3647 | |
3648 int32_t nCount = pFormField->CountControls(); | 3387 int32_t nCount = pFormField->CountControls(); |
3649 | |
3650 if (nCount < 1) | 3388 if (nCount < 1) |
3651 return FALSE; | 3389 return FALSE; |
3652 | 3390 |
3653 CPDFSDK_InterForm* pInterForm = | 3391 CPDFSDK_InterForm* pInterForm = |
3654 (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); | 3392 (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); |
3655 ASSERT(pInterForm != NULL); | 3393 ASSERT(pInterForm != NULL); |
3656 | 3394 |
3657 CPDFSDK_Widget* pWidget = NULL; | 3395 CPDFSDK_Widget* pWidget = NULL; |
3658 if (nCount == 1) { | 3396 if (nCount == 1) { |
3659 pWidget = pInterForm->GetWidget(pFormField->GetControl(0)); | 3397 pWidget = pInterForm->GetWidget(pFormField->GetControl(0)); |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4001 #define JS_FIELD_MINWIDTH 1 | 3739 #define JS_FIELD_MINWIDTH 1 |
4002 #define JS_FIELD_MINHEIGHT 1 | 3740 #define JS_FIELD_MINHEIGHT 1 |
4003 | 3741 |
4004 void Field::AddField(CPDFSDK_Document* pDocument, | 3742 void Field::AddField(CPDFSDK_Document* pDocument, |
4005 int nPageIndex, | 3743 int nPageIndex, |
4006 int nFieldType, | 3744 int nFieldType, |
4007 const CFX_WideString& sName, | 3745 const CFX_WideString& sName, |
4008 const CPDF_Rect& rcCoords) { | 3746 const CPDF_Rect& rcCoords) { |
4009 // Not supported. | 3747 // Not supported. |
4010 } | 3748 } |
OLD | NEW |