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