Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Side by Side Diff: fpdfsdk/javascript/Field.cpp

Issue 2400443005: Convert Field to use CPDFSDK_FormFillEnvironment (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« fpdfsdk/javascript/Field.h ('K') | « fpdfsdk/javascript/Field.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "fpdfsdk/javascript/Field.h" 7 #include "fpdfsdk/javascript/Field.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 : eProp(prop), nControlIndex(idx), sFieldName(name) {} 168 : eProp(prop), nControlIndex(idx), sFieldName(name) {}
169 169
170 CJS_DelayData::~CJS_DelayData() {} 170 CJS_DelayData::~CJS_DelayData() {}
171 171
172 void CJS_Field::InitInstance(IJS_Runtime* pIRuntime) { 172 void CJS_Field::InitInstance(IJS_Runtime* pIRuntime) {
173 } 173 }
174 174
175 Field::Field(CJS_Object* pJSObject) 175 Field::Field(CJS_Object* pJSObject)
176 : CJS_EmbedObj(pJSObject), 176 : CJS_EmbedObj(pJSObject),
177 m_pJSDoc(nullptr), 177 m_pJSDoc(nullptr),
178 m_pDocument(nullptr), 178 m_pFormFillEnv(nullptr),
179 m_nFormControlIndex(-1), 179 m_nFormControlIndex(-1),
180 m_bCanSet(FALSE), 180 m_bCanSet(FALSE),
181 m_bDelay(FALSE) {} 181 m_bDelay(FALSE) {}
182 182
183 Field::~Field() {} 183 Field::~Field() {}
184 184
185 // note: iControlNo = -1, means not a widget. 185 // note: iControlNo = -1, means not a widget.
186 void Field::ParseFieldName(const std::wstring& strFieldNameParsed, 186 void Field::ParseFieldName(const std::wstring& strFieldNameParsed,
187 std::wstring& strFieldName, 187 std::wstring& strFieldName,
188 int& iControlNo) { 188 int& iControlNo) {
(...skipping 16 matching lines...) Expand all
205 iControlNo = -1; 205 iControlNo = -1;
206 return; 206 return;
207 } 207 }
208 } 208 }
209 strFieldName = strFieldNameParsed.substr(0, iStart); 209 strFieldName = strFieldNameParsed.substr(0, iStart);
210 } 210 }
211 211
212 FX_BOOL Field::AttachField(Document* pDocument, 212 FX_BOOL Field::AttachField(Document* pDocument,
213 const CFX_WideString& csFieldName) { 213 const CFX_WideString& csFieldName) {
214 m_pJSDoc = pDocument; 214 m_pJSDoc = pDocument;
215 m_pDocument.Reset(pDocument->GetReaderDoc()); 215 m_pFormFillEnv.Reset(pDocument->GetReaderDoc()->GetEnv());
216 m_bCanSet = m_pDocument->GetPermissions(FPDFPERM_FILL_FORM) || 216 m_bCanSet =
217 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) || 217 m_pFormFillEnv->GetSDKDocument()->GetPermissions(FPDFPERM_FILL_FORM) ||
218 m_pDocument->GetPermissions(FPDFPERM_MODIFY); 218 m_pFormFillEnv->GetSDKDocument()->GetPermissions(FPDFPERM_ANNOT_FORM) ||
219 m_pFormFillEnv->GetSDKDocument()->GetPermissions(FPDFPERM_MODIFY);
219 220
220 CPDFSDK_InterForm* pRDInterForm = m_pDocument->GetInterForm(); 221 CPDFSDK_InterForm* pRDInterForm =
222 m_pFormFillEnv->GetSDKDocument()->GetInterForm();
221 CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm(); 223 CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm();
222 CFX_WideString swFieldNameTemp = csFieldName; 224 CFX_WideString swFieldNameTemp = csFieldName;
223 swFieldNameTemp.Replace(L"..", L"."); 225 swFieldNameTemp.Replace(L"..", L".");
224 226
225 if (pInterForm->CountFields(swFieldNameTemp) <= 0) { 227 if (pInterForm->CountFields(swFieldNameTemp) <= 0) {
226 std::wstring strFieldName; 228 std::wstring strFieldName;
227 int iControlNo = -1; 229 int iControlNo = -1;
228 ParseFieldName(swFieldNameTemp.c_str(), strFieldName, iControlNo); 230 ParseFieldName(swFieldNameTemp.c_str(), strFieldName, iControlNo);
229 if (iControlNo == -1) 231 if (iControlNo == -1)
230 return FALSE; 232 return FALSE;
231 233
232 m_FieldName = strFieldName.c_str(); 234 m_FieldName = strFieldName.c_str();
233 m_nFormControlIndex = iControlNo; 235 m_nFormControlIndex = iControlNo;
234 return TRUE; 236 return TRUE;
235 } 237 }
236 238
237 m_FieldName = swFieldNameTemp; 239 m_FieldName = swFieldNameTemp;
238 m_nFormControlIndex = -1; 240 m_nFormControlIndex = -1;
239 241
240 return TRUE; 242 return TRUE;
241 } 243 }
242 244
243 std::vector<CPDF_FormField*> Field::GetFormFields( 245 std::vector<CPDF_FormField*> Field::GetFormFields(
244 CPDFSDK_Document* pDocument, 246 CPDFSDK_FormFillEnvironment* pFormFillEnv,
245 const CFX_WideString& csFieldName) { 247 const CFX_WideString& csFieldName) {
246 std::vector<CPDF_FormField*> fields; 248 std::vector<CPDF_FormField*> fields;
247 CPDFSDK_InterForm* pReaderInterForm = pDocument->GetInterForm(); 249 CPDFSDK_InterForm* pReaderInterForm =
250 pFormFillEnv->GetSDKDocument()->GetInterForm();
248 CPDF_InterForm* pInterForm = pReaderInterForm->GetInterForm(); 251 CPDF_InterForm* pInterForm = pReaderInterForm->GetInterForm();
249 for (int i = 0, sz = pInterForm->CountFields(csFieldName); i < sz; ++i) { 252 for (int i = 0, sz = pInterForm->CountFields(csFieldName); i < sz; ++i) {
250 if (CPDF_FormField* pFormField = pInterForm->GetField(i, csFieldName)) 253 if (CPDF_FormField* pFormField = pInterForm->GetField(i, csFieldName))
251 fields.push_back(pFormField); 254 fields.push_back(pFormField);
252 } 255 }
253 return fields; 256 return fields;
254 } 257 }
255 258
256 std::vector<CPDF_FormField*> Field::GetFormFields( 259 std::vector<CPDF_FormField*> Field::GetFormFields(
257 const CFX_WideString& csFieldName) const { 260 const CFX_WideString& csFieldName) const {
258 return Field::GetFormFields(m_pDocument.Get(), csFieldName); 261 return Field::GetFormFields(m_pFormFillEnv.Get(), csFieldName);
259 } 262 }
260 263
261 void Field::UpdateFormField(CPDFSDK_Document* pDocument, 264 void Field::UpdateFormField(CPDFSDK_FormFillEnvironment* pFormFillEnv,
262 CPDF_FormField* pFormField, 265 CPDF_FormField* pFormField,
263 FX_BOOL bChangeMark, 266 FX_BOOL bChangeMark,
264 FX_BOOL bResetAP, 267 FX_BOOL bResetAP,
265 FX_BOOL bRefresh) { 268 FX_BOOL bRefresh) {
266 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); 269 CPDFSDK_InterForm* pInterForm =
270 pFormFillEnv->GetSDKDocument()->GetInterForm();
267 271
268 if (bResetAP) { 272 if (bResetAP) {
269 std::vector<CPDFSDK_Widget*> widgets; 273 std::vector<CPDFSDK_Widget*> widgets;
270 pInterForm->GetWidgets(pFormField, &widgets); 274 pInterForm->GetWidgets(pFormField, &widgets);
271 275
272 int nFieldType = pFormField->GetFieldType(); 276 int nFieldType = pFormField->GetFieldType();
273 if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_TEXTFIELD) { 277 if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_TEXTFIELD) {
274 for (CPDFSDK_Annot* pAnnot : widgets) { 278 for (CPDFSDK_Annot* pAnnot : widgets) {
275 FX_BOOL bFormatted = FALSE; 279 FX_BOOL bFormatted = FALSE;
276 CPDFSDK_Annot::ObservedPtr pObserved(pAnnot); 280 CPDFSDK_Annot::ObservedPtr pObserved(pAnnot);
(...skipping 20 matching lines...) Expand all
297 301
298 for (CPDFSDK_Widget* pWidget : widgets) { 302 for (CPDFSDK_Widget* pWidget : widgets) {
299 pWidget->GetInterForm() 303 pWidget->GetInterForm()
300 ->GetFormFillEnv() 304 ->GetFormFillEnv()
301 ->GetSDKDocument() 305 ->GetSDKDocument()
302 ->UpdateAllViews(nullptr, pWidget); 306 ->UpdateAllViews(nullptr, pWidget);
303 } 307 }
304 } 308 }
305 309
306 if (bChangeMark) 310 if (bChangeMark)
307 pDocument->SetChangeMark(); 311 pFormFillEnv->GetSDKDocument()->SetChangeMark();
308 } 312 }
309 313
310 void Field::UpdateFormControl(CPDFSDK_Document* pDocument, 314 void Field::UpdateFormControl(CPDFSDK_FormFillEnvironment* pFormFillEnv,
311 CPDF_FormControl* pFormControl, 315 CPDF_FormControl* pFormControl,
312 FX_BOOL bChangeMark, 316 FX_BOOL bChangeMark,
313 FX_BOOL bResetAP, 317 FX_BOOL bResetAP,
314 FX_BOOL bRefresh) { 318 FX_BOOL bRefresh) {
315 ASSERT(pFormControl); 319 ASSERT(pFormControl);
316 320
317 CPDFSDK_InterForm* pForm = pDocument->GetInterForm(); 321 CPDFSDK_InterForm* pForm = pFormFillEnv->GetSDKDocument()->GetInterForm();
318 CPDFSDK_Widget* pWidget = pForm->GetWidget(pFormControl, false); 322 CPDFSDK_Widget* pWidget = pForm->GetWidget(pFormControl, false);
319 323
320 if (pWidget) { 324 if (pWidget) {
321 if (bResetAP) { 325 if (bResetAP) {
322 int nFieldType = pWidget->GetFieldType(); 326 int nFieldType = pWidget->GetFieldType();
323 if (nFieldType == FIELDTYPE_COMBOBOX || 327 if (nFieldType == FIELDTYPE_COMBOBOX ||
324 nFieldType == FIELDTYPE_TEXTFIELD) { 328 nFieldType == FIELDTYPE_TEXTFIELD) {
325 FX_BOOL bFormatted = FALSE; 329 FX_BOOL bFormatted = FALSE;
326 CFX_WideString sValue = pWidget->OnFormat(bFormatted); 330 CFX_WideString sValue = pWidget->OnFormat(bFormatted);
327 pWidget->ResetAppearance(bFormatted ? &sValue : nullptr, FALSE); 331 pWidget->ResetAppearance(bFormatted ? &sValue : nullptr, FALSE);
328 } else { 332 } else {
329 pWidget->ResetAppearance(nullptr, FALSE); 333 pWidget->ResetAppearance(nullptr, FALSE);
330 } 334 }
331 } 335 }
332 336
333 if (bRefresh) { 337 if (bRefresh) {
334 CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm(); 338 CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm();
335 pInterForm->GetFormFillEnv()->GetSDKDocument()->UpdateAllViews(nullptr, 339 pInterForm->GetFormFillEnv()->GetSDKDocument()->UpdateAllViews(nullptr,
336 pWidget); 340 pWidget);
337 } 341 }
338 } 342 }
339 343
340 if (bChangeMark) 344 if (bChangeMark)
341 pDocument->SetChangeMark(); 345 pFormFillEnv->GetSDKDocument()->SetChangeMark();
342 } 346 }
343 347
344 CPDFSDK_Widget* Field::GetWidget(CPDFSDK_Document* pDocument, 348 CPDFSDK_Widget* Field::GetWidget(CPDFSDK_FormFillEnvironment* pFormFillEnv,
345 CPDF_FormControl* pFormControl, 349 CPDF_FormControl* pFormControl,
346 bool createIfNeeded) { 350 bool createIfNeeded) {
347 CPDFSDK_InterForm* pInterForm = 351 CPDFSDK_InterForm* pInterForm = static_cast<CPDFSDK_InterForm*>(
348 static_cast<CPDFSDK_InterForm*>(pDocument->GetInterForm()); 352 pFormFillEnv->GetSDKDocument()->GetInterForm());
349 return pInterForm ? pInterForm->GetWidget(pFormControl, createIfNeeded) 353 return pInterForm ? pInterForm->GetWidget(pFormControl, createIfNeeded)
350 : nullptr; 354 : nullptr;
351 } 355 }
352 356
353 FX_BOOL Field::ValueIsOccur(CPDF_FormField* pFormField, 357 FX_BOOL Field::ValueIsOccur(CPDF_FormField* pFormField,
354 CFX_WideString csOptLabel) { 358 CFX_WideString csOptLabel) {
355 for (int i = 0, sz = pFormField->CountOptions(); i < sz; i++) { 359 for (int i = 0, sz = pFormField->CountOptions(); i < sz; i++) {
356 if (csOptLabel.Compare(pFormField->GetOptionLabel(i)) == 0) 360 if (csOptLabel.Compare(pFormField->GetOptionLabel(i)) == 0)
357 return TRUE; 361 return TRUE;
358 } 362 }
359 363
360 return FALSE; 364 return FALSE;
361 } 365 }
362 366
363 CPDF_FormControl* Field::GetSmartFieldControl(CPDF_FormField* pFormField) { 367 CPDF_FormControl* Field::GetSmartFieldControl(CPDF_FormField* pFormField) {
364 if (!pFormField->CountControls() || 368 if (!pFormField->CountControls() ||
365 m_nFormControlIndex >= pFormField->CountControls()) 369 m_nFormControlIndex >= pFormField->CountControls())
366 return nullptr; 370 return nullptr;
367 371
368 if (m_nFormControlIndex < 0) 372 if (m_nFormControlIndex < 0)
369 return pFormField->GetControl(0); 373 return pFormField->GetControl(0);
370 374
371 return pFormField->GetControl(m_nFormControlIndex); 375 return pFormField->GetControl(m_nFormControlIndex);
372 } 376 }
373 377
374 FX_BOOL Field::alignment(IJS_Context* cc, 378 FX_BOOL Field::alignment(IJS_Context* cc,
375 CJS_PropValue& vp, 379 CJS_PropValue& vp,
376 CFX_WideString& sError) { 380 CFX_WideString& sError) {
377 ASSERT(m_pDocument); 381 ASSERT(m_pFormFillEnv);
378 382
379 if (vp.IsSetting()) { 383 if (vp.IsSetting()) {
380 if (!m_bCanSet) 384 if (!m_bCanSet)
381 return FALSE; 385 return FALSE;
382 386
383 CFX_ByteString alignStr; 387 CFX_ByteString alignStr;
384 vp >> alignStr; 388 vp >> alignStr;
385 389
386 if (m_bDelay) { 390 if (m_bDelay) {
387 AddDelay_String(FP_ALIGNMENT, alignStr); 391 AddDelay_String(FP_ALIGNMENT, alignStr);
388 } else { 392 } else {
389 Field::SetAlignment(m_pDocument.Get(), m_FieldName, m_nFormControlIndex, 393 Field::SetAlignment(m_pFormFillEnv.Get(), m_FieldName,
390 alignStr); 394 m_nFormControlIndex, alignStr);
391 } 395 }
392 } else { 396 } else {
393 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 397 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
394 if (FieldArray.empty()) 398 if (FieldArray.empty())
395 return FALSE; 399 return FALSE;
396 400
397 CPDF_FormField* pFormField = FieldArray[0]; 401 CPDF_FormField* pFormField = FieldArray[0];
398 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) 402 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
399 return FALSE; 403 return FALSE;
400 404
(...skipping 12 matching lines...) Expand all
413 vp << L"right"; 417 vp << L"right";
414 break; 418 break;
415 default: 419 default:
416 vp << L""; 420 vp << L"";
417 } 421 }
418 } 422 }
419 423
420 return TRUE; 424 return TRUE;
421 } 425 }
422 426
423 void Field::SetAlignment(CPDFSDK_Document* pDocument, 427 void Field::SetAlignment(CPDFSDK_FormFillEnvironment* pFormFillEnv,
424 const CFX_WideString& swFieldName, 428 const CFX_WideString& swFieldName,
425 int nControlIndex, 429 int nControlIndex,
426 const CFX_ByteString& string) { 430 const CFX_ByteString& string) {
427 // Not supported. 431 // Not supported.
428 } 432 }
429 433
430 FX_BOOL Field::borderStyle(IJS_Context* cc, 434 FX_BOOL Field::borderStyle(IJS_Context* cc,
431 CJS_PropValue& vp, 435 CJS_PropValue& vp,
432 CFX_WideString& sError) { 436 CFX_WideString& sError) {
433 ASSERT(m_pDocument); 437 ASSERT(m_pFormFillEnv);
434 438
435 if (vp.IsSetting()) { 439 if (vp.IsSetting()) {
436 if (!m_bCanSet) 440 if (!m_bCanSet)
437 return FALSE; 441 return FALSE;
438 442
439 CFX_ByteString strType = ""; 443 CFX_ByteString strType = "";
440 vp >> strType; 444 vp >> strType;
441 445
442 if (m_bDelay) { 446 if (m_bDelay) {
443 AddDelay_String(FP_BORDERSTYLE, strType); 447 AddDelay_String(FP_BORDERSTYLE, strType);
444 } else { 448 } else {
445 Field::SetBorderStyle(m_pDocument.Get(), m_FieldName, m_nFormControlIndex, 449 Field::SetBorderStyle(m_pFormFillEnv.Get(), m_FieldName,
446 strType); 450 m_nFormControlIndex, strType);
447 } 451 }
448 } else { 452 } else {
449 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 453 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
450 if (FieldArray.empty()) 454 if (FieldArray.empty())
451 return FALSE; 455 return FALSE;
452 456
453 CPDF_FormField* pFormField = FieldArray[0]; 457 CPDF_FormField* pFormField = FieldArray[0];
454 if (!pFormField) 458 if (!pFormField)
455 return FALSE; 459 return FALSE;
456 460
457 CPDFSDK_Widget* pWidget = 461 CPDFSDK_Widget* pWidget = GetWidget(
458 GetWidget(m_pDocument.Get(), GetSmartFieldControl(pFormField), false); 462 m_pFormFillEnv.Get(), GetSmartFieldControl(pFormField), false);
459 if (!pWidget) 463 if (!pWidget)
460 return FALSE; 464 return FALSE;
461 465
462 switch (pWidget->GetBorderStyle()) { 466 switch (pWidget->GetBorderStyle()) {
463 case BorderStyle::SOLID: 467 case BorderStyle::SOLID:
464 vp << L"solid"; 468 vp << L"solid";
465 break; 469 break;
466 case BorderStyle::DASH: 470 case BorderStyle::DASH:
467 vp << L"dashed"; 471 vp << L"dashed";
468 break; 472 break;
469 case BorderStyle::BEVELED: 473 case BorderStyle::BEVELED:
470 vp << L"beveled"; 474 vp << L"beveled";
471 break; 475 break;
472 case BorderStyle::INSET: 476 case BorderStyle::INSET:
473 vp << L"inset"; 477 vp << L"inset";
474 break; 478 break;
475 case BorderStyle::UNDERLINE: 479 case BorderStyle::UNDERLINE:
476 vp << L"underline"; 480 vp << L"underline";
477 break; 481 break;
478 default: 482 default:
479 vp << L""; 483 vp << L"";
480 break; 484 break;
481 } 485 }
482 } 486 }
483 487
484 return TRUE; 488 return TRUE;
485 } 489 }
486 490
487 void Field::SetBorderStyle(CPDFSDK_Document* pDocument, 491 void Field::SetBorderStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv,
488 const CFX_WideString& swFieldName, 492 const CFX_WideString& swFieldName,
489 int nControlIndex, 493 int nControlIndex,
490 const CFX_ByteString& string) { 494 const CFX_ByteString& string) {
491 ASSERT(pDocument); 495 ASSERT(pFormFillEnv);
492 496
493 BorderStyle nBorderStyle = BorderStyle::SOLID; 497 BorderStyle nBorderStyle = BorderStyle::SOLID;
494 if (string == "solid") 498 if (string == "solid")
495 nBorderStyle = BorderStyle::SOLID; 499 nBorderStyle = BorderStyle::SOLID;
496 else if (string == "beveled") 500 else if (string == "beveled")
497 nBorderStyle = BorderStyle::BEVELED; 501 nBorderStyle = BorderStyle::BEVELED;
498 else if (string == "dashed") 502 else if (string == "dashed")
499 nBorderStyle = BorderStyle::DASH; 503 nBorderStyle = BorderStyle::DASH;
500 else if (string == "inset") 504 else if (string == "inset")
501 nBorderStyle = BorderStyle::INSET; 505 nBorderStyle = BorderStyle::INSET;
502 else if (string == "underline") 506 else if (string == "underline")
503 nBorderStyle = BorderStyle::UNDERLINE; 507 nBorderStyle = BorderStyle::UNDERLINE;
504 else 508 else
505 return; 509 return;
506 510
507 std::vector<CPDF_FormField*> FieldArray = 511 std::vector<CPDF_FormField*> FieldArray =
508 GetFormFields(pDocument, swFieldName); 512 GetFormFields(pFormFillEnv, swFieldName);
509 for (CPDF_FormField* pFormField : FieldArray) { 513 for (CPDF_FormField* pFormField : FieldArray) {
510 if (nControlIndex < 0) { 514 if (nControlIndex < 0) {
511 FX_BOOL bSet = FALSE; 515 FX_BOOL bSet = FALSE;
512 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { 516 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) {
513 if (CPDFSDK_Widget* pWidget = 517 if (CPDFSDK_Widget* pWidget =
514 GetWidget(pDocument, pFormField->GetControl(i), false)) { 518 GetWidget(pFormFillEnv, pFormField->GetControl(i), false)) {
515 if (pWidget->GetBorderStyle() != nBorderStyle) { 519 if (pWidget->GetBorderStyle() != nBorderStyle) {
516 pWidget->SetBorderStyle(nBorderStyle); 520 pWidget->SetBorderStyle(nBorderStyle);
517 bSet = TRUE; 521 bSet = TRUE;
518 } 522 }
519 } 523 }
520 } 524 }
521 if (bSet) 525 if (bSet)
522 UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE); 526 UpdateFormField(pFormFillEnv, pFormField, TRUE, TRUE, TRUE);
523 } else { 527 } else {
524 if (nControlIndex >= pFormField->CountControls()) 528 if (nControlIndex >= pFormField->CountControls())
525 return; 529 return;
526 if (CPDF_FormControl* pFormControl = 530 if (CPDF_FormControl* pFormControl =
527 pFormField->GetControl(nControlIndex)) { 531 pFormField->GetControl(nControlIndex)) {
528 if (CPDFSDK_Widget* pWidget = 532 if (CPDFSDK_Widget* pWidget =
529 GetWidget(pDocument, pFormControl, false)) { 533 GetWidget(pFormFillEnv, pFormControl, false)) {
530 if (pWidget->GetBorderStyle() != nBorderStyle) { 534 if (pWidget->GetBorderStyle() != nBorderStyle) {
531 pWidget->SetBorderStyle(nBorderStyle); 535 pWidget->SetBorderStyle(nBorderStyle);
532 UpdateFormControl(pDocument, pFormControl, TRUE, TRUE, TRUE); 536 UpdateFormControl(pFormFillEnv, pFormControl, TRUE, TRUE, TRUE);
533 } 537 }
534 } 538 }
535 } 539 }
536 } 540 }
537 } 541 }
538 } 542 }
539 543
540 FX_BOOL Field::buttonAlignX(IJS_Context* cc, 544 FX_BOOL Field::buttonAlignX(IJS_Context* cc,
541 CJS_PropValue& vp, 545 CJS_PropValue& vp,
542 CFX_WideString& sError) { 546 CFX_WideString& sError) {
543 ASSERT(m_pDocument); 547 ASSERT(m_pFormFillEnv);
544 548
545 if (vp.IsSetting()) { 549 if (vp.IsSetting()) {
546 if (!m_bCanSet) 550 if (!m_bCanSet)
547 return FALSE; 551 return FALSE;
548 552
549 int nVP; 553 int nVP;
550 vp >> nVP; 554 vp >> nVP;
551 555
552 if (m_bDelay) { 556 if (m_bDelay) {
553 AddDelay_Int(FP_BUTTONALIGNX, nVP); 557 AddDelay_Int(FP_BUTTONALIGNX, nVP);
554 } else { 558 } else {
555 Field::SetButtonAlignX(m_pDocument.Get(), m_FieldName, 559 Field::SetButtonAlignX(m_pFormFillEnv.Get(), m_FieldName,
556 m_nFormControlIndex, nVP); 560 m_nFormControlIndex, nVP);
557 } 561 }
558 } else { 562 } else {
559 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 563 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
560 if (FieldArray.empty()) 564 if (FieldArray.empty())
561 return FALSE; 565 return FALSE;
562 566
563 CPDF_FormField* pFormField = FieldArray[0]; 567 CPDF_FormField* pFormField = FieldArray[0];
564 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) 568 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
565 return FALSE; 569 return FALSE;
566 570
567 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 571 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
568 if (!pFormControl) 572 if (!pFormControl)
569 return FALSE; 573 return FALSE;
570 574
571 CPDF_IconFit IconFit = pFormControl->GetIconFit(); 575 CPDF_IconFit IconFit = pFormControl->GetIconFit();
572 576
573 FX_FLOAT fLeft, fBottom; 577 FX_FLOAT fLeft, fBottom;
574 IconFit.GetIconPosition(fLeft, fBottom); 578 IconFit.GetIconPosition(fLeft, fBottom);
575 579
576 vp << (int32_t)fLeft; 580 vp << (int32_t)fLeft;
577 } 581 }
578 582
579 return TRUE; 583 return TRUE;
580 } 584 }
581 585
582 void Field::SetButtonAlignX(CPDFSDK_Document* pDocument, 586 void Field::SetButtonAlignX(CPDFSDK_FormFillEnvironment* pFormFillEnv,
583 const CFX_WideString& swFieldName, 587 const CFX_WideString& swFieldName,
584 int nControlIndex, 588 int nControlIndex,
585 int number) { 589 int number) {
586 // Not supported. 590 // Not supported.
587 } 591 }
588 592
589 FX_BOOL Field::buttonAlignY(IJS_Context* cc, 593 FX_BOOL Field::buttonAlignY(IJS_Context* cc,
590 CJS_PropValue& vp, 594 CJS_PropValue& vp,
591 CFX_WideString& sError) { 595 CFX_WideString& sError) {
592 ASSERT(m_pDocument); 596 ASSERT(m_pFormFillEnv);
593 597
594 if (vp.IsSetting()) { 598 if (vp.IsSetting()) {
595 if (!m_bCanSet) 599 if (!m_bCanSet)
596 return FALSE; 600 return FALSE;
597 601
598 int nVP; 602 int nVP;
599 vp >> nVP; 603 vp >> nVP;
600 604
601 if (m_bDelay) { 605 if (m_bDelay) {
602 AddDelay_Int(FP_BUTTONALIGNY, nVP); 606 AddDelay_Int(FP_BUTTONALIGNY, nVP);
603 } else { 607 } else {
604 Field::SetButtonAlignY(m_pDocument.Get(), m_FieldName, 608 Field::SetButtonAlignY(m_pFormFillEnv.Get(), m_FieldName,
605 m_nFormControlIndex, nVP); 609 m_nFormControlIndex, nVP);
606 } 610 }
607 } else { 611 } else {
608 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 612 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
609 if (FieldArray.empty()) 613 if (FieldArray.empty())
610 return FALSE; 614 return FALSE;
611 615
612 CPDF_FormField* pFormField = FieldArray[0]; 616 CPDF_FormField* pFormField = FieldArray[0];
613 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) 617 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
614 return FALSE; 618 return FALSE;
615 619
616 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 620 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
617 if (!pFormControl) 621 if (!pFormControl)
618 return FALSE; 622 return FALSE;
619 623
620 CPDF_IconFit IconFit = pFormControl->GetIconFit(); 624 CPDF_IconFit IconFit = pFormControl->GetIconFit();
621 625
622 FX_FLOAT fLeft, fBottom; 626 FX_FLOAT fLeft, fBottom;
623 IconFit.GetIconPosition(fLeft, fBottom); 627 IconFit.GetIconPosition(fLeft, fBottom);
624 628
625 vp << (int32_t)fBottom; 629 vp << (int32_t)fBottom;
626 } 630 }
627 631
628 return TRUE; 632 return TRUE;
629 } 633 }
630 634
631 void Field::SetButtonAlignY(CPDFSDK_Document* pDocument, 635 void Field::SetButtonAlignY(CPDFSDK_FormFillEnvironment* pFormFillEnv,
632 const CFX_WideString& swFieldName, 636 const CFX_WideString& swFieldName,
633 int nControlIndex, 637 int nControlIndex,
634 int number) { 638 int number) {
635 // Not supported. 639 // Not supported.
636 } 640 }
637 641
638 FX_BOOL Field::buttonFitBounds(IJS_Context* cc, 642 FX_BOOL Field::buttonFitBounds(IJS_Context* cc,
639 CJS_PropValue& vp, 643 CJS_PropValue& vp,
640 CFX_WideString& sError) { 644 CFX_WideString& sError) {
641 ASSERT(m_pDocument); 645 ASSERT(m_pFormFillEnv);
642 646
643 if (vp.IsSetting()) { 647 if (vp.IsSetting()) {
644 if (!m_bCanSet) 648 if (!m_bCanSet)
645 return FALSE; 649 return FALSE;
646 650
647 bool bVP; 651 bool bVP;
648 vp >> bVP; 652 vp >> bVP;
649 653
650 if (m_bDelay) { 654 if (m_bDelay) {
651 AddDelay_Bool(FP_BUTTONFITBOUNDS, bVP); 655 AddDelay_Bool(FP_BUTTONFITBOUNDS, bVP);
652 } else { 656 } else {
653 Field::SetButtonFitBounds(m_pDocument.Get(), m_FieldName, 657 Field::SetButtonFitBounds(m_pFormFillEnv.Get(), m_FieldName,
654 m_nFormControlIndex, bVP); 658 m_nFormControlIndex, bVP);
655 } 659 }
656 } else { 660 } else {
657 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 661 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
658 if (FieldArray.empty()) 662 if (FieldArray.empty())
659 return FALSE; 663 return FALSE;
660 664
661 CPDF_FormField* pFormField = FieldArray[0]; 665 CPDF_FormField* pFormField = FieldArray[0];
662 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) 666 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
663 return FALSE; 667 return FALSE;
664 668
665 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 669 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
666 if (!pFormControl) 670 if (!pFormControl)
667 return FALSE; 671 return FALSE;
668 672
669 vp << pFormControl->GetIconFit().GetFittingBounds(); 673 vp << pFormControl->GetIconFit().GetFittingBounds();
670 } 674 }
671 675
672 return TRUE; 676 return TRUE;
673 } 677 }
674 678
675 void Field::SetButtonFitBounds(CPDFSDK_Document* pDocument, 679 void Field::SetButtonFitBounds(CPDFSDK_FormFillEnvironment* pFormFillEnv,
676 const CFX_WideString& swFieldName, 680 const CFX_WideString& swFieldName,
677 int nControlIndex, 681 int nControlIndex,
678 bool b) { 682 bool b) {
679 // Not supported. 683 // Not supported.
680 } 684 }
681 685
682 FX_BOOL Field::buttonPosition(IJS_Context* cc, 686 FX_BOOL Field::buttonPosition(IJS_Context* cc,
683 CJS_PropValue& vp, 687 CJS_PropValue& vp,
684 CFX_WideString& sError) { 688 CFX_WideString& sError) {
685 ASSERT(m_pDocument); 689 ASSERT(m_pFormFillEnv);
686 690
687 if (vp.IsSetting()) { 691 if (vp.IsSetting()) {
688 if (!m_bCanSet) 692 if (!m_bCanSet)
689 return FALSE; 693 return FALSE;
690 694
691 int nVP; 695 int nVP;
692 vp >> nVP; 696 vp >> nVP;
693 697
694 if (m_bDelay) { 698 if (m_bDelay) {
695 AddDelay_Int(FP_BUTTONPOSITION, nVP); 699 AddDelay_Int(FP_BUTTONPOSITION, nVP);
696 } else { 700 } else {
697 Field::SetButtonPosition(m_pDocument.Get(), m_FieldName, 701 Field::SetButtonPosition(m_pFormFillEnv.Get(), m_FieldName,
698 m_nFormControlIndex, nVP); 702 m_nFormControlIndex, nVP);
699 } 703 }
700 } else { 704 } else {
701 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 705 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
702 if (FieldArray.empty()) 706 if (FieldArray.empty())
703 return FALSE; 707 return FALSE;
704 708
705 CPDF_FormField* pFormField = FieldArray[0]; 709 CPDF_FormField* pFormField = FieldArray[0];
706 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) 710 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
707 return FALSE; 711 return FALSE;
708 712
709 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 713 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
710 if (!pFormControl) 714 if (!pFormControl)
711 return FALSE; 715 return FALSE;
712 716
713 vp << pFormControl->GetTextPosition(); 717 vp << pFormControl->GetTextPosition();
714 } 718 }
715 return TRUE; 719 return TRUE;
716 } 720 }
717 721
718 void Field::SetButtonPosition(CPDFSDK_Document* pDocument, 722 void Field::SetButtonPosition(CPDFSDK_FormFillEnvironment* pFormFillEnv,
719 const CFX_WideString& swFieldName, 723 const CFX_WideString& swFieldName,
720 int nControlIndex, 724 int nControlIndex,
721 int number) { 725 int number) {
722 // Not supported. 726 // Not supported.
723 } 727 }
724 728
725 FX_BOOL Field::buttonScaleHow(IJS_Context* cc, 729 FX_BOOL Field::buttonScaleHow(IJS_Context* cc,
726 CJS_PropValue& vp, 730 CJS_PropValue& vp,
727 CFX_WideString& sError) { 731 CFX_WideString& sError) {
728 ASSERT(m_pDocument); 732 ASSERT(m_pFormFillEnv);
729 733
730 if (vp.IsSetting()) { 734 if (vp.IsSetting()) {
731 if (!m_bCanSet) 735 if (!m_bCanSet)
732 return FALSE; 736 return FALSE;
733 737
734 int nVP; 738 int nVP;
735 vp >> nVP; 739 vp >> nVP;
736 740
737 if (m_bDelay) { 741 if (m_bDelay) {
738 AddDelay_Int(FP_BUTTONSCALEHOW, nVP); 742 AddDelay_Int(FP_BUTTONSCALEHOW, nVP);
739 } else { 743 } else {
740 Field::SetButtonScaleHow(m_pDocument.Get(), m_FieldName, 744 Field::SetButtonScaleHow(m_pFormFillEnv.Get(), m_FieldName,
741 m_nFormControlIndex, nVP); 745 m_nFormControlIndex, nVP);
742 } 746 }
743 } else { 747 } else {
744 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 748 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
745 if (FieldArray.empty()) 749 if (FieldArray.empty())
746 return FALSE; 750 return FALSE;
747 751
748 CPDF_FormField* pFormField = FieldArray[0]; 752 CPDF_FormField* pFormField = FieldArray[0];
749 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) 753 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
750 return FALSE; 754 return FALSE;
751 755
752 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 756 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
753 if (!pFormControl) 757 if (!pFormControl)
754 return FALSE; 758 return FALSE;
755 759
756 CPDF_IconFit IconFit = pFormControl->GetIconFit(); 760 CPDF_IconFit IconFit = pFormControl->GetIconFit();
757 if (IconFit.IsProportionalScale()) 761 if (IconFit.IsProportionalScale())
758 vp << (int32_t)0; 762 vp << (int32_t)0;
759 else 763 else
760 vp << (int32_t)1; 764 vp << (int32_t)1;
761 } 765 }
762 766
763 return TRUE; 767 return TRUE;
764 } 768 }
765 769
766 void Field::SetButtonScaleHow(CPDFSDK_Document* pDocument, 770 void Field::SetButtonScaleHow(CPDFSDK_FormFillEnvironment* pFormFillEnv,
767 const CFX_WideString& swFieldName, 771 const CFX_WideString& swFieldName,
768 int nControlIndex, 772 int nControlIndex,
769 int number) { 773 int number) {
770 // Not supported. 774 // Not supported.
771 } 775 }
772 776
773 FX_BOOL Field::buttonScaleWhen(IJS_Context* cc, 777 FX_BOOL Field::buttonScaleWhen(IJS_Context* cc,
774 CJS_PropValue& vp, 778 CJS_PropValue& vp,
775 CFX_WideString& sError) { 779 CFX_WideString& sError) {
776 ASSERT(m_pDocument); 780 ASSERT(m_pFormFillEnv);
777 781
778 if (vp.IsSetting()) { 782 if (vp.IsSetting()) {
779 if (!m_bCanSet) 783 if (!m_bCanSet)
780 return FALSE; 784 return FALSE;
781 785
782 int nVP; 786 int nVP;
783 vp >> nVP; 787 vp >> nVP;
784 788
785 if (m_bDelay) { 789 if (m_bDelay) {
786 AddDelay_Int(FP_BUTTONSCALEWHEN, nVP); 790 AddDelay_Int(FP_BUTTONSCALEWHEN, nVP);
787 } else { 791 } else {
788 Field::SetButtonScaleWhen(m_pDocument.Get(), m_FieldName, 792 Field::SetButtonScaleWhen(m_pFormFillEnv.Get(), m_FieldName,
789 m_nFormControlIndex, nVP); 793 m_nFormControlIndex, nVP);
790 } 794 }
791 } else { 795 } else {
792 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 796 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
793 if (FieldArray.empty()) 797 if (FieldArray.empty())
794 return FALSE; 798 return FALSE;
795 799
796 CPDF_FormField* pFormField = FieldArray[0]; 800 CPDF_FormField* pFormField = FieldArray[0];
797 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) 801 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
798 return FALSE; 802 return FALSE;
(...skipping 16 matching lines...) Expand all
815 break; 819 break;
816 case CPDF_IconFit::Smaller: 820 case CPDF_IconFit::Smaller:
817 vp << (int32_t)CPDF_IconFit::Smaller; 821 vp << (int32_t)CPDF_IconFit::Smaller;
818 break; 822 break;
819 } 823 }
820 } 824 }
821 825
822 return TRUE; 826 return TRUE;
823 } 827 }
824 828
825 void Field::SetButtonScaleWhen(CPDFSDK_Document* pDocument, 829 void Field::SetButtonScaleWhen(CPDFSDK_FormFillEnvironment* pFormFillEnv,
826 const CFX_WideString& swFieldName, 830 const CFX_WideString& swFieldName,
827 int nControlIndex, 831 int nControlIndex,
828 int number) { 832 int number) {
829 // Not supported. 833 // Not supported.
830 } 834 }
831 835
832 FX_BOOL Field::calcOrderIndex(IJS_Context* cc, 836 FX_BOOL Field::calcOrderIndex(IJS_Context* cc,
833 CJS_PropValue& vp, 837 CJS_PropValue& vp,
834 CFX_WideString& sError) { 838 CFX_WideString& sError) {
835 ASSERT(m_pDocument); 839 ASSERT(m_pFormFillEnv);
836 840
837 if (vp.IsSetting()) { 841 if (vp.IsSetting()) {
838 if (!m_bCanSet) 842 if (!m_bCanSet)
839 return FALSE; 843 return FALSE;
840 844
841 int nVP; 845 int nVP;
842 vp >> nVP; 846 vp >> nVP;
843 847
844 if (m_bDelay) { 848 if (m_bDelay) {
845 AddDelay_Int(FP_CALCORDERINDEX, nVP); 849 AddDelay_Int(FP_CALCORDERINDEX, nVP);
846 } else { 850 } else {
847 Field::SetCalcOrderIndex(m_pDocument.Get(), m_FieldName, 851 Field::SetCalcOrderIndex(m_pFormFillEnv.Get(), m_FieldName,
848 m_nFormControlIndex, nVP); 852 m_nFormControlIndex, nVP);
849 } 853 }
850 } else { 854 } else {
851 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 855 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
852 if (FieldArray.empty()) 856 if (FieldArray.empty())
853 return FALSE; 857 return FALSE;
854 858
855 CPDF_FormField* pFormField = FieldArray[0]; 859 CPDF_FormField* pFormField = FieldArray[0];
856 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && 860 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX &&
857 pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) { 861 pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) {
858 return FALSE; 862 return FALSE;
859 } 863 }
860 864
861 CPDFSDK_InterForm* pRDInterForm = m_pDocument->GetInterForm(); 865 CPDFSDK_InterForm* pRDInterForm =
866 m_pFormFillEnv->GetSDKDocument()->GetInterForm();
862 CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm(); 867 CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm();
863 vp << (int32_t)pInterForm->FindFieldInCalculationOrder(pFormField); 868 vp << (int32_t)pInterForm->FindFieldInCalculationOrder(pFormField);
864 } 869 }
865 870
866 return TRUE; 871 return TRUE;
867 } 872 }
868 873
869 void Field::SetCalcOrderIndex(CPDFSDK_Document* pDocument, 874 void Field::SetCalcOrderIndex(CPDFSDK_FormFillEnvironment* pFormFillEnv,
870 const CFX_WideString& swFieldName, 875 const CFX_WideString& swFieldName,
871 int nControlIndex, 876 int nControlIndex,
872 int number) { 877 int number) {
873 // Not supported. 878 // Not supported.
874 } 879 }
875 880
876 FX_BOOL Field::charLimit(IJS_Context* cc, 881 FX_BOOL Field::charLimit(IJS_Context* cc,
877 CJS_PropValue& vp, 882 CJS_PropValue& vp,
878 CFX_WideString& sError) { 883 CFX_WideString& sError) {
879 ASSERT(m_pDocument); 884 ASSERT(m_pFormFillEnv);
880 885
881 if (vp.IsSetting()) { 886 if (vp.IsSetting()) {
882 if (!m_bCanSet) 887 if (!m_bCanSet)
883 return FALSE; 888 return FALSE;
884 889
885 int nVP; 890 int nVP;
886 vp >> nVP; 891 vp >> nVP;
887 892
888 if (m_bDelay) { 893 if (m_bDelay) {
889 AddDelay_Int(FP_CHARLIMIT, nVP); 894 AddDelay_Int(FP_CHARLIMIT, nVP);
890 } else { 895 } else {
891 Field::SetCharLimit(m_pDocument.Get(), m_FieldName, m_nFormControlIndex, 896 Field::SetCharLimit(m_pFormFillEnv.Get(), m_FieldName,
892 nVP); 897 m_nFormControlIndex, nVP);
893 } 898 }
894 } else { 899 } else {
895 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 900 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
896 if (FieldArray.empty()) 901 if (FieldArray.empty())
897 return FALSE; 902 return FALSE;
898 903
899 CPDF_FormField* pFormField = FieldArray[0]; 904 CPDF_FormField* pFormField = FieldArray[0];
900 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) 905 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
901 return FALSE; 906 return FALSE;
902 907
903 vp << (int32_t)pFormField->GetMaxLen(); 908 vp << (int32_t)pFormField->GetMaxLen();
904 } 909 }
905 return TRUE; 910 return TRUE;
906 } 911 }
907 912
908 void Field::SetCharLimit(CPDFSDK_Document* pDocument, 913 void Field::SetCharLimit(CPDFSDK_FormFillEnvironment* pFormFillEnv,
909 const CFX_WideString& swFieldName, 914 const CFX_WideString& swFieldName,
910 int nControlIndex, 915 int nControlIndex,
911 int number) { 916 int number) {
912 // Not supported. 917 // Not supported.
913 } 918 }
914 919
915 FX_BOOL Field::comb(IJS_Context* cc, 920 FX_BOOL Field::comb(IJS_Context* cc,
916 CJS_PropValue& vp, 921 CJS_PropValue& vp,
917 CFX_WideString& sError) { 922 CFX_WideString& sError) {
918 ASSERT(m_pDocument); 923 ASSERT(m_pFormFillEnv);
919 924
920 if (vp.IsSetting()) { 925 if (vp.IsSetting()) {
921 if (!m_bCanSet) 926 if (!m_bCanSet)
922 return FALSE; 927 return FALSE;
923 928
924 bool bVP; 929 bool bVP;
925 vp >> bVP; 930 vp >> bVP;
926 931
927 if (m_bDelay) { 932 if (m_bDelay) {
928 AddDelay_Bool(FP_COMB, bVP); 933 AddDelay_Bool(FP_COMB, bVP);
929 } else { 934 } else {
930 Field::SetComb(m_pDocument.Get(), m_FieldName, m_nFormControlIndex, bVP); 935 Field::SetComb(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
936 bVP);
931 } 937 }
932 } else { 938 } else {
933 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 939 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
934 if (FieldArray.empty()) 940 if (FieldArray.empty())
935 return FALSE; 941 return FALSE;
936 942
937 CPDF_FormField* pFormField = FieldArray[0]; 943 CPDF_FormField* pFormField = FieldArray[0];
938 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) 944 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
939 return FALSE; 945 return FALSE;
940 946
941 if (pFormField->GetFieldFlags() & FIELDFLAG_COMB) 947 if (pFormField->GetFieldFlags() & FIELDFLAG_COMB)
942 vp << true; 948 vp << true;
943 else 949 else
944 vp << false; 950 vp << false;
945 } 951 }
946 952
947 return TRUE; 953 return TRUE;
948 } 954 }
949 955
950 void Field::SetComb(CPDFSDK_Document* pDocument, 956 void Field::SetComb(CPDFSDK_FormFillEnvironment* pFormFillEnv,
951 const CFX_WideString& swFieldName, 957 const CFX_WideString& swFieldName,
952 int nControlIndex, 958 int nControlIndex,
953 bool b) { 959 bool b) {
954 // Not supported. 960 // Not supported.
955 } 961 }
956 962
957 FX_BOOL Field::commitOnSelChange(IJS_Context* cc, 963 FX_BOOL Field::commitOnSelChange(IJS_Context* cc,
958 CJS_PropValue& vp, 964 CJS_PropValue& vp,
959 CFX_WideString& sError) { 965 CFX_WideString& sError) {
960 ASSERT(m_pDocument); 966 ASSERT(m_pFormFillEnv);
961 967
962 if (vp.IsSetting()) { 968 if (vp.IsSetting()) {
963 if (!m_bCanSet) 969 if (!m_bCanSet)
964 return FALSE; 970 return FALSE;
965 971
966 bool bVP; 972 bool bVP;
967 vp >> bVP; 973 vp >> bVP;
968 974
969 if (m_bDelay) { 975 if (m_bDelay) {
970 AddDelay_Bool(FP_COMMITONSELCHANGE, bVP); 976 AddDelay_Bool(FP_COMMITONSELCHANGE, bVP);
971 } else { 977 } else {
972 Field::SetCommitOnSelChange(m_pDocument.Get(), m_FieldName, 978 Field::SetCommitOnSelChange(m_pFormFillEnv.Get(), m_FieldName,
973 m_nFormControlIndex, bVP); 979 m_nFormControlIndex, bVP);
974 } 980 }
975 } else { 981 } else {
976 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 982 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
977 if (FieldArray.empty()) 983 if (FieldArray.empty())
978 return FALSE; 984 return FALSE;
979 985
980 CPDF_FormField* pFormField = FieldArray[0]; 986 CPDF_FormField* pFormField = FieldArray[0];
981 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && 987 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX &&
982 pFormField->GetFieldType() != FIELDTYPE_LISTBOX) { 988 pFormField->GetFieldType() != FIELDTYPE_LISTBOX) {
983 return FALSE; 989 return FALSE;
984 } 990 }
985 991
986 if (pFormField->GetFieldFlags() & FIELDFLAG_COMMITONSELCHANGE) 992 if (pFormField->GetFieldFlags() & FIELDFLAG_COMMITONSELCHANGE)
987 vp << true; 993 vp << true;
988 else 994 else
989 vp << false; 995 vp << false;
990 } 996 }
991 997
992 return TRUE; 998 return TRUE;
993 } 999 }
994 1000
995 void Field::SetCommitOnSelChange(CPDFSDK_Document* pDocument, 1001 void Field::SetCommitOnSelChange(CPDFSDK_FormFillEnvironment* pFormFillEnv,
996 const CFX_WideString& swFieldName, 1002 const CFX_WideString& swFieldName,
997 int nControlIndex, 1003 int nControlIndex,
998 bool b) { 1004 bool b) {
999 // Not supported. 1005 // Not supported.
1000 } 1006 }
1001 1007
1002 FX_BOOL Field::currentValueIndices(IJS_Context* cc, 1008 FX_BOOL Field::currentValueIndices(IJS_Context* cc,
1003 CJS_PropValue& vp, 1009 CJS_PropValue& vp,
1004 CFX_WideString& sError) { 1010 CFX_WideString& sError) {
1005 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); 1011 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
(...skipping 15 matching lines...) Expand all
1021 for (int i = 0, sz = SelArray.GetLength(pRuntime); i < sz; i++) { 1027 for (int i = 0, sz = SelArray.GetLength(pRuntime); i < sz; i++) {
1022 SelArray.GetElement(pRuntime, i, SelValue); 1028 SelArray.GetElement(pRuntime, i, SelValue);
1023 iSelecting = SelValue.ToInt(pRuntime); 1029 iSelecting = SelValue.ToInt(pRuntime);
1024 array.push_back(iSelecting); 1030 array.push_back(iSelecting);
1025 } 1031 }
1026 } 1032 }
1027 1033
1028 if (m_bDelay) { 1034 if (m_bDelay) {
1029 AddDelay_WordArray(FP_CURRENTVALUEINDICES, array); 1035 AddDelay_WordArray(FP_CURRENTVALUEINDICES, array);
1030 } else { 1036 } else {
1031 Field::SetCurrentValueIndices(m_pDocument.Get(), m_FieldName, 1037 Field::SetCurrentValueIndices(m_pFormFillEnv.Get(), m_FieldName,
1032 m_nFormControlIndex, array); 1038 m_nFormControlIndex, array);
1033 } 1039 }
1034 } else { 1040 } else {
1035 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1041 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1036 if (FieldArray.empty()) 1042 if (FieldArray.empty())
1037 return FALSE; 1043 return FALSE;
1038 1044
1039 CPDF_FormField* pFormField = FieldArray[0]; 1045 CPDF_FormField* pFormField = FieldArray[0];
1040 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && 1046 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX &&
1041 pFormField->GetFieldType() != FIELDTYPE_LISTBOX) { 1047 pFormField->GetFieldType() != FIELDTYPE_LISTBOX) {
(...skipping 10 matching lines...) Expand all
1052 } 1058 }
1053 vp << SelArray; 1059 vp << SelArray;
1054 } else { 1060 } else {
1055 vp << -1; 1061 vp << -1;
1056 } 1062 }
1057 } 1063 }
1058 1064
1059 return TRUE; 1065 return TRUE;
1060 } 1066 }
1061 1067
1062 void Field::SetCurrentValueIndices(CPDFSDK_Document* pDocument, 1068 void Field::SetCurrentValueIndices(CPDFSDK_FormFillEnvironment* pFormFillEnv,
1063 const CFX_WideString& swFieldName, 1069 const CFX_WideString& swFieldName,
1064 int nControlIndex, 1070 int nControlIndex,
1065 const std::vector<uint32_t>& array) { 1071 const std::vector<uint32_t>& array) {
1066 ASSERT(pDocument); 1072 ASSERT(pFormFillEnv);
1067 std::vector<CPDF_FormField*> FieldArray = 1073 std::vector<CPDF_FormField*> FieldArray =
1068 GetFormFields(pDocument, swFieldName); 1074 GetFormFields(pFormFillEnv, swFieldName);
1069 1075
1070 for (CPDF_FormField* pFormField : FieldArray) { 1076 for (CPDF_FormField* pFormField : FieldArray) {
1071 int nFieldType = pFormField->GetFieldType(); 1077 int nFieldType = pFormField->GetFieldType();
1072 if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_LISTBOX) { 1078 if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_LISTBOX) {
1073 uint32_t dwFieldFlags = pFormField->GetFieldFlags(); 1079 uint32_t dwFieldFlags = pFormField->GetFieldFlags();
1074 pFormField->ClearSelection(TRUE); 1080 pFormField->ClearSelection(TRUE);
1075 for (size_t i = 0; i < array.size(); ++i) { 1081 for (size_t i = 0; i < array.size(); ++i) {
1076 if (i != 0 && !(dwFieldFlags & (1 << 21))) 1082 if (i != 0 && !(dwFieldFlags & (1 << 21)))
1077 break; 1083 break;
1078 if (array[i] < static_cast<uint32_t>(pFormField->CountOptions()) && 1084 if (array[i] < static_cast<uint32_t>(pFormField->CountOptions()) &&
1079 !pFormField->IsItemSelected(array[i])) { 1085 !pFormField->IsItemSelected(array[i])) {
1080 pFormField->SetItemSelection(array[i], TRUE); 1086 pFormField->SetItemSelection(array[i], TRUE);
1081 } 1087 }
1082 } 1088 }
1083 UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE); 1089 UpdateFormField(pFormFillEnv, pFormField, TRUE, TRUE, TRUE);
1084 } 1090 }
1085 } 1091 }
1086 } 1092 }
1087 1093
1088 FX_BOOL Field::defaultStyle(IJS_Context* cc, 1094 FX_BOOL Field::defaultStyle(IJS_Context* cc,
1089 CJS_PropValue& vp, 1095 CJS_PropValue& vp,
1090 CFX_WideString& sError) { 1096 CFX_WideString& sError) {
1091 return FALSE; 1097 return FALSE;
1092 } 1098 }
1093 1099
1094 void Field::SetDefaultStyle(CPDFSDK_Document* pDocument, 1100 void Field::SetDefaultStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv,
1095 const CFX_WideString& swFieldName, 1101 const CFX_WideString& swFieldName,
1096 int nControlIndex) { 1102 int nControlIndex) {
1097 // Not supported. 1103 // Not supported.
1098 } 1104 }
1099 1105
1100 FX_BOOL Field::defaultValue(IJS_Context* cc, 1106 FX_BOOL Field::defaultValue(IJS_Context* cc,
1101 CJS_PropValue& vp, 1107 CJS_PropValue& vp,
1102 CFX_WideString& sError) { 1108 CFX_WideString& sError) {
1103 ASSERT(m_pDocument); 1109 ASSERT(m_pFormFillEnv);
1104 1110
1105 if (vp.IsSetting()) { 1111 if (vp.IsSetting()) {
1106 if (!m_bCanSet) 1112 if (!m_bCanSet)
1107 return FALSE; 1113 return FALSE;
1108 1114
1109 CFX_WideString WideStr; 1115 CFX_WideString WideStr;
1110 vp >> WideStr; 1116 vp >> WideStr;
1111 1117
1112 if (m_bDelay) { 1118 if (m_bDelay) {
1113 AddDelay_WideString(FP_DEFAULTVALUE, WideStr); 1119 AddDelay_WideString(FP_DEFAULTVALUE, WideStr);
1114 } else { 1120 } else {
1115 Field::SetDefaultValue(m_pDocument.Get(), m_FieldName, 1121 Field::SetDefaultValue(m_pFormFillEnv.Get(), m_FieldName,
1116 m_nFormControlIndex, WideStr); 1122 m_nFormControlIndex, WideStr);
1117 } 1123 }
1118 } else { 1124 } else {
1119 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1125 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1120 if (FieldArray.empty()) 1126 if (FieldArray.empty())
1121 return FALSE; 1127 return FALSE;
1122 1128
1123 CPDF_FormField* pFormField = FieldArray[0]; 1129 CPDF_FormField* pFormField = FieldArray[0];
1124 if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON || 1130 if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON ||
1125 pFormField->GetFieldType() == FIELDTYPE_SIGNATURE) { 1131 pFormField->GetFieldType() == FIELDTYPE_SIGNATURE) {
1126 return FALSE; 1132 return FALSE;
1127 } 1133 }
1128 1134
1129 vp << pFormField->GetDefaultValue(); 1135 vp << pFormField->GetDefaultValue();
1130 } 1136 }
1131 return TRUE; 1137 return TRUE;
1132 } 1138 }
1133 1139
1134 void Field::SetDefaultValue(CPDFSDK_Document* pDocument, 1140 void Field::SetDefaultValue(CPDFSDK_FormFillEnvironment* pFormFillEnv,
1135 const CFX_WideString& swFieldName, 1141 const CFX_WideString& swFieldName,
1136 int nControlIndex, 1142 int nControlIndex,
1137 const CFX_WideString& string) { 1143 const CFX_WideString& string) {
1138 // Not supported. 1144 // Not supported.
1139 } 1145 }
1140 1146
1141 FX_BOOL Field::doNotScroll(IJS_Context* cc, 1147 FX_BOOL Field::doNotScroll(IJS_Context* cc,
1142 CJS_PropValue& vp, 1148 CJS_PropValue& vp,
1143 CFX_WideString& sError) { 1149 CFX_WideString& sError) {
1144 ASSERT(m_pDocument); 1150 ASSERT(m_pFormFillEnv);
1145 1151
1146 if (vp.IsSetting()) { 1152 if (vp.IsSetting()) {
1147 if (!m_bCanSet) 1153 if (!m_bCanSet)
1148 return FALSE; 1154 return FALSE;
1149 1155
1150 bool bVP; 1156 bool bVP;
1151 vp >> bVP; 1157 vp >> bVP;
1152 1158
1153 if (m_bDelay) { 1159 if (m_bDelay) {
1154 AddDelay_Bool(FP_DONOTSCROLL, bVP); 1160 AddDelay_Bool(FP_DONOTSCROLL, bVP);
1155 } else { 1161 } else {
1156 Field::SetDoNotScroll(m_pDocument.Get(), m_FieldName, m_nFormControlIndex, 1162 Field::SetDoNotScroll(m_pFormFillEnv.Get(), m_FieldName,
1157 bVP); 1163 m_nFormControlIndex, bVP);
1158 } 1164 }
1159 } else { 1165 } else {
1160 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1166 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1161 if (FieldArray.empty()) 1167 if (FieldArray.empty())
1162 return FALSE; 1168 return FALSE;
1163 1169
1164 CPDF_FormField* pFormField = FieldArray[0]; 1170 CPDF_FormField* pFormField = FieldArray[0];
1165 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) 1171 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
1166 return FALSE; 1172 return FALSE;
1167 1173
1168 if (pFormField->GetFieldFlags() & FIELDFLAG_DONOTSCROLL) 1174 if (pFormField->GetFieldFlags() & FIELDFLAG_DONOTSCROLL)
1169 vp << true; 1175 vp << true;
1170 else 1176 else
1171 vp << false; 1177 vp << false;
1172 } 1178 }
1173 1179
1174 return TRUE; 1180 return TRUE;
1175 } 1181 }
1176 1182
1177 void Field::SetDoNotScroll(CPDFSDK_Document* pDocument, 1183 void Field::SetDoNotScroll(CPDFSDK_FormFillEnvironment* pFormFillEnv,
1178 const CFX_WideString& swFieldName, 1184 const CFX_WideString& swFieldName,
1179 int nControlIndex, 1185 int nControlIndex,
1180 bool b) { 1186 bool b) {
1181 // Not supported. 1187 // Not supported.
1182 } 1188 }
1183 1189
1184 FX_BOOL Field::doNotSpellCheck(IJS_Context* cc, 1190 FX_BOOL Field::doNotSpellCheck(IJS_Context* cc,
1185 CJS_PropValue& vp, 1191 CJS_PropValue& vp,
1186 CFX_WideString& sError) { 1192 CFX_WideString& sError) {
1187 ASSERT(m_pDocument); 1193 ASSERT(m_pFormFillEnv);
1188 1194
1189 if (vp.IsSetting()) { 1195 if (vp.IsSetting()) {
1190 if (!m_bCanSet) 1196 if (!m_bCanSet)
1191 return FALSE; 1197 return FALSE;
1192 1198
1193 bool bVP; 1199 bool bVP;
1194 vp >> bVP; 1200 vp >> bVP;
1195 } else { 1201 } else {
1196 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1202 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1197 if (FieldArray.empty()) 1203 if (FieldArray.empty())
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 if (vp.IsSetting()) { 1250 if (vp.IsSetting()) {
1245 if (!m_bCanSet) 1251 if (!m_bCanSet)
1246 return FALSE; 1252 return FALSE;
1247 1253
1248 int nVP; 1254 int nVP;
1249 vp >> nVP; 1255 vp >> nVP;
1250 1256
1251 if (m_bDelay) { 1257 if (m_bDelay) {
1252 AddDelay_Int(FP_DISPLAY, nVP); 1258 AddDelay_Int(FP_DISPLAY, nVP);
1253 } else { 1259 } else {
1254 Field::SetDisplay(m_pDocument.Get(), m_FieldName, m_nFormControlIndex, 1260 Field::SetDisplay(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
1255 nVP); 1261 nVP);
1256 } 1262 }
1257 } else { 1263 } else {
1258 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1264 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1259 if (FieldArray.empty()) 1265 if (FieldArray.empty())
1260 return FALSE; 1266 return FALSE;
1261 1267
1262 CPDF_FormField* pFormField = FieldArray[0]; 1268 CPDF_FormField* pFormField = FieldArray[0];
1263 ASSERT(pFormField); 1269 ASSERT(pFormField);
1264 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); 1270 CPDFSDK_InterForm* pInterForm =
1271 m_pFormFillEnv->GetSDKDocument()->GetInterForm();
1265 CPDFSDK_Widget* pWidget = 1272 CPDFSDK_Widget* pWidget =
1266 pInterForm->GetWidget(GetSmartFieldControl(pFormField), true); 1273 pInterForm->GetWidget(GetSmartFieldControl(pFormField), true);
1267 if (!pWidget) 1274 if (!pWidget)
1268 return FALSE; 1275 return FALSE;
1269 1276
1270 uint32_t dwFlag = pWidget->GetFlags(); 1277 uint32_t dwFlag = pWidget->GetFlags();
1271 1278
1272 if (ANNOTFLAG_INVISIBLE & dwFlag || ANNOTFLAG_HIDDEN & dwFlag) { 1279 if (ANNOTFLAG_INVISIBLE & dwFlag || ANNOTFLAG_HIDDEN & dwFlag) {
1273 vp << (int32_t)1; 1280 vp << (int32_t)1;
1274 } else { 1281 } else {
1275 if (ANNOTFLAG_PRINT & dwFlag) { 1282 if (ANNOTFLAG_PRINT & dwFlag) {
1276 if (ANNOTFLAG_NOVIEW & dwFlag) { 1283 if (ANNOTFLAG_NOVIEW & dwFlag) {
1277 vp << (int32_t)3; 1284 vp << (int32_t)3;
1278 } else { 1285 } else {
1279 vp << (int32_t)0; 1286 vp << (int32_t)0;
1280 } 1287 }
1281 } else { 1288 } else {
1282 vp << (int32_t)2; 1289 vp << (int32_t)2;
1283 } 1290 }
1284 } 1291 }
1285 } 1292 }
1286 1293
1287 return TRUE; 1294 return TRUE;
1288 } 1295 }
1289 1296
1290 void Field::SetDisplay(CPDFSDK_Document* pDocument, 1297 void Field::SetDisplay(CPDFSDK_FormFillEnvironment* pFormFillEnv,
1291 const CFX_WideString& swFieldName, 1298 const CFX_WideString& swFieldName,
1292 int nControlIndex, 1299 int nControlIndex,
1293 int number) { 1300 int number) {
1294 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); 1301 CPDFSDK_InterForm* pInterForm =
1302 pFormFillEnv->GetSDKDocument()->GetInterForm();
1295 std::vector<CPDF_FormField*> FieldArray = 1303 std::vector<CPDF_FormField*> FieldArray =
1296 GetFormFields(pDocument, swFieldName); 1304 GetFormFields(pFormFillEnv, swFieldName);
1297 for (CPDF_FormField* pFormField : FieldArray) { 1305 for (CPDF_FormField* pFormField : FieldArray) {
1298 if (nControlIndex < 0) { 1306 if (nControlIndex < 0) {
1299 bool bAnySet = false; 1307 bool bAnySet = false;
1300 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { 1308 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) {
1301 CPDF_FormControl* pFormControl = pFormField->GetControl(i); 1309 CPDF_FormControl* pFormControl = pFormField->GetControl(i);
1302 ASSERT(pFormControl); 1310 ASSERT(pFormControl);
1303 1311
1304 CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl, true); 1312 CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl, true);
1305 if (SetWidgetDisplayStatus(pWidget, number)) 1313 if (SetWidgetDisplayStatus(pWidget, number))
1306 bAnySet = true; 1314 bAnySet = true;
1307 } 1315 }
1308 1316
1309 if (bAnySet) 1317 if (bAnySet)
1310 UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE); 1318 UpdateFormField(pFormFillEnv, pFormField, TRUE, FALSE, TRUE);
1311 } else { 1319 } else {
1312 if (nControlIndex >= pFormField->CountControls()) 1320 if (nControlIndex >= pFormField->CountControls())
1313 return; 1321 return;
1314 1322
1315 CPDF_FormControl* pFormControl = pFormField->GetControl(nControlIndex); 1323 CPDF_FormControl* pFormControl = pFormField->GetControl(nControlIndex);
1316 if (!pFormControl) 1324 if (!pFormControl)
1317 return; 1325 return;
1318 1326
1319 CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl, true); 1327 CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl, true);
1320 if (SetWidgetDisplayStatus(pWidget, number)) 1328 if (SetWidgetDisplayStatus(pWidget, number))
1321 UpdateFormControl(pDocument, pFormControl, TRUE, FALSE, TRUE); 1329 UpdateFormControl(pFormFillEnv, pFormControl, TRUE, FALSE, TRUE);
1322 } 1330 }
1323 } 1331 }
1324 } 1332 }
1325 1333
1326 FX_BOOL Field::doc(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { 1334 FX_BOOL Field::doc(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
1327 if (!vp.IsGetting()) { 1335 if (!vp.IsGetting()) {
1328 return FALSE; 1336 return FALSE;
1329 } 1337 }
1330 vp << m_pJSDoc->GetCJSDoc(); 1338 vp << m_pJSDoc->GetCJSDoc();
1331 return TRUE; 1339 return TRUE;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1447 if (!vp.GetJSValue()->IsArrayObject()) 1455 if (!vp.GetJSValue()->IsArrayObject())
1448 return FALSE; 1456 return FALSE;
1449 1457
1450 vp >> crArray; 1458 vp >> crArray;
1451 1459
1452 CPWL_Color color; 1460 CPWL_Color color;
1453 color::ConvertArrayToPWLColor(pRuntime, crArray, &color); 1461 color::ConvertArrayToPWLColor(pRuntime, crArray, &color);
1454 if (m_bDelay) { 1462 if (m_bDelay) {
1455 AddDelay_Color(FP_FILLCOLOR, color); 1463 AddDelay_Color(FP_FILLCOLOR, color);
1456 } else { 1464 } else {
1457 Field::SetFillColor(m_pDocument.Get(), m_FieldName, m_nFormControlIndex, 1465 Field::SetFillColor(m_pFormFillEnv.Get(), m_FieldName,
1458 color); 1466 m_nFormControlIndex, color);
1459 } 1467 }
1460 } else { 1468 } else {
1461 CPDF_FormField* pFormField = FieldArray[0]; 1469 CPDF_FormField* pFormField = FieldArray[0];
1462 ASSERT(pFormField); 1470 ASSERT(pFormField);
1463 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 1471 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
1464 if (!pFormControl) 1472 if (!pFormControl)
1465 return FALSE; 1473 return FALSE;
1466 1474
1467 int iColorType; 1475 int iColorType;
1468 pFormControl->GetBackgroundColor(iColorType); 1476 pFormControl->GetBackgroundColor(iColorType);
(...skipping 19 matching lines...) Expand all
1488 return FALSE; 1496 return FALSE;
1489 } 1497 }
1490 1498
1491 color::ConvertPWLColorToArray(pRuntime, color, &crArray); 1499 color::ConvertPWLColorToArray(pRuntime, color, &crArray);
1492 vp << crArray; 1500 vp << crArray;
1493 } 1501 }
1494 1502
1495 return TRUE; 1503 return TRUE;
1496 } 1504 }
1497 1505
1498 void Field::SetFillColor(CPDFSDK_Document* pDocument, 1506 void Field::SetFillColor(CPDFSDK_FormFillEnvironment* pFormFillEnv,
1499 const CFX_WideString& swFieldName, 1507 const CFX_WideString& swFieldName,
1500 int nControlIndex, 1508 int nControlIndex,
1501 const CPWL_Color& color) { 1509 const CPWL_Color& color) {
1502 // Not supported. 1510 // Not supported.
1503 } 1511 }
1504 1512
1505 FX_BOOL Field::hidden(IJS_Context* cc, 1513 FX_BOOL Field::hidden(IJS_Context* cc,
1506 CJS_PropValue& vp, 1514 CJS_PropValue& vp,
1507 CFX_WideString& sError) { 1515 CFX_WideString& sError) {
1508 if (vp.IsSetting()) { 1516 if (vp.IsSetting()) {
1509 if (!m_bCanSet) 1517 if (!m_bCanSet)
1510 return FALSE; 1518 return FALSE;
1511 1519
1512 bool bVP; 1520 bool bVP;
1513 vp >> bVP; 1521 vp >> bVP;
1514 1522
1515 if (m_bDelay) { 1523 if (m_bDelay) {
1516 AddDelay_Bool(FP_HIDDEN, bVP); 1524 AddDelay_Bool(FP_HIDDEN, bVP);
1517 } else { 1525 } else {
1518 Field::SetHidden(m_pDocument.Get(), m_FieldName, m_nFormControlIndex, 1526 Field::SetHidden(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
1519 bVP); 1527 bVP);
1520 } 1528 }
1521 } else { 1529 } else {
1522 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1530 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1523 if (FieldArray.empty()) 1531 if (FieldArray.empty())
1524 return FALSE; 1532 return FALSE;
1525 1533
1526 CPDF_FormField* pFormField = FieldArray[0]; 1534 CPDF_FormField* pFormField = FieldArray[0];
1527 ASSERT(pFormField); 1535 ASSERT(pFormField);
1528 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); 1536 CPDFSDK_InterForm* pInterForm =
1537 m_pFormFillEnv->GetSDKDocument()->GetInterForm();
1529 CPDFSDK_Widget* pWidget = 1538 CPDFSDK_Widget* pWidget =
1530 pInterForm->GetWidget(GetSmartFieldControl(pFormField), false); 1539 pInterForm->GetWidget(GetSmartFieldControl(pFormField), false);
1531 if (!pWidget) 1540 if (!pWidget)
1532 return FALSE; 1541 return FALSE;
1533 1542
1534 uint32_t dwFlags = pWidget->GetFlags(); 1543 uint32_t dwFlags = pWidget->GetFlags();
1535 1544
1536 if (ANNOTFLAG_INVISIBLE & dwFlags || ANNOTFLAG_HIDDEN & dwFlags) 1545 if (ANNOTFLAG_INVISIBLE & dwFlags || ANNOTFLAG_HIDDEN & dwFlags)
1537 vp << true; 1546 vp << true;
1538 else 1547 else
1539 vp << false; 1548 vp << false;
1540 } 1549 }
1541 1550
1542 return TRUE; 1551 return TRUE;
1543 } 1552 }
1544 1553
1545 void Field::SetHidden(CPDFSDK_Document* pDocument, 1554 void Field::SetHidden(CPDFSDK_FormFillEnvironment* pFormFillEnv,
1546 const CFX_WideString& swFieldName, 1555 const CFX_WideString& swFieldName,
1547 int nControlIndex, 1556 int nControlIndex,
1548 bool b) { 1557 bool b) {
1549 int display = b ? 1 /*Hidden*/ : 0 /*Visible*/; 1558 int display = b ? 1 /*Hidden*/ : 0 /*Visible*/;
1550 SetDisplay(pDocument, swFieldName, nControlIndex, display); 1559 SetDisplay(pFormFillEnv, swFieldName, nControlIndex, display);
1551 } 1560 }
1552 1561
1553 FX_BOOL Field::highlight(IJS_Context* cc, 1562 FX_BOOL Field::highlight(IJS_Context* cc,
1554 CJS_PropValue& vp, 1563 CJS_PropValue& vp,
1555 CFX_WideString& sError) { 1564 CFX_WideString& sError) {
1556 ASSERT(m_pDocument); 1565 ASSERT(m_pFormFillEnv);
1557 1566
1558 if (vp.IsSetting()) { 1567 if (vp.IsSetting()) {
1559 if (!m_bCanSet) 1568 if (!m_bCanSet)
1560 return FALSE; 1569 return FALSE;
1561 1570
1562 CFX_ByteString strMode; 1571 CFX_ByteString strMode;
1563 vp >> strMode; 1572 vp >> strMode;
1564 1573
1565 if (m_bDelay) { 1574 if (m_bDelay) {
1566 AddDelay_String(FP_HIGHLIGHT, strMode); 1575 AddDelay_String(FP_HIGHLIGHT, strMode);
1567 } else { 1576 } else {
1568 Field::SetHighlight(m_pDocument.Get(), m_FieldName, m_nFormControlIndex, 1577 Field::SetHighlight(m_pFormFillEnv.Get(), m_FieldName,
1569 strMode); 1578 m_nFormControlIndex, strMode);
1570 } 1579 }
1571 } else { 1580 } else {
1572 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1581 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1573 if (FieldArray.empty()) 1582 if (FieldArray.empty())
1574 return FALSE; 1583 return FALSE;
1575 1584
1576 CPDF_FormField* pFormField = FieldArray[0]; 1585 CPDF_FormField* pFormField = FieldArray[0];
1577 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) 1586 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
1578 return FALSE; 1587 return FALSE;
1579 1588
(...skipping 17 matching lines...) Expand all
1597 break; 1606 break;
1598 case CPDF_FormControl::Toggle: 1607 case CPDF_FormControl::Toggle:
1599 vp << L"toggle"; 1608 vp << L"toggle";
1600 break; 1609 break;
1601 } 1610 }
1602 } 1611 }
1603 1612
1604 return TRUE; 1613 return TRUE;
1605 } 1614 }
1606 1615
1607 void Field::SetHighlight(CPDFSDK_Document* pDocument, 1616 void Field::SetHighlight(CPDFSDK_FormFillEnvironment* pFormFillEnv,
1608 const CFX_WideString& swFieldName, 1617 const CFX_WideString& swFieldName,
1609 int nControlIndex, 1618 int nControlIndex,
1610 const CFX_ByteString& string) { 1619 const CFX_ByteString& string) {
1611 // Not supported. 1620 // Not supported.
1612 } 1621 }
1613 1622
1614 FX_BOOL Field::lineWidth(IJS_Context* cc, 1623 FX_BOOL Field::lineWidth(IJS_Context* cc,
1615 CJS_PropValue& vp, 1624 CJS_PropValue& vp,
1616 CFX_WideString& sError) { 1625 CFX_WideString& sError) {
1617 if (vp.IsSetting()) { 1626 if (vp.IsSetting()) {
1618 if (!m_bCanSet) 1627 if (!m_bCanSet)
1619 return FALSE; 1628 return FALSE;
1620 1629
1621 int iWidth; 1630 int iWidth;
1622 vp >> iWidth; 1631 vp >> iWidth;
1623 1632
1624 if (m_bDelay) { 1633 if (m_bDelay) {
1625 AddDelay_Int(FP_LINEWIDTH, iWidth); 1634 AddDelay_Int(FP_LINEWIDTH, iWidth);
1626 } else { 1635 } else {
1627 Field::SetLineWidth(m_pDocument.Get(), m_FieldName, m_nFormControlIndex, 1636 Field::SetLineWidth(m_pFormFillEnv.Get(), m_FieldName,
1628 iWidth); 1637 m_nFormControlIndex, iWidth);
1629 } 1638 }
1630 } else { 1639 } else {
1631 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1640 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1632 if (FieldArray.empty()) 1641 if (FieldArray.empty())
1633 return FALSE; 1642 return FALSE;
1634 1643
1635 CPDF_FormField* pFormField = FieldArray[0]; 1644 CPDF_FormField* pFormField = FieldArray[0];
1636 ASSERT(pFormField); 1645 ASSERT(pFormField);
1637 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 1646 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
1638 if (!pFormControl) 1647 if (!pFormControl)
1639 return FALSE; 1648 return FALSE;
1640 1649
1641 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); 1650 CPDFSDK_InterForm* pInterForm =
1651 m_pFormFillEnv->GetSDKDocument()->GetInterForm();
1642 if (!pFormField->CountControls()) 1652 if (!pFormField->CountControls())
1643 return FALSE; 1653 return FALSE;
1644 1654
1645 CPDFSDK_Widget* pWidget = 1655 CPDFSDK_Widget* pWidget =
1646 pInterForm->GetWidget(pFormField->GetControl(0), false); 1656 pInterForm->GetWidget(pFormField->GetControl(0), false);
1647 if (!pWidget) 1657 if (!pWidget)
1648 return FALSE; 1658 return FALSE;
1649 1659
1650 vp << (int32_t)pWidget->GetBorderWidth(); 1660 vp << (int32_t)pWidget->GetBorderWidth();
1651 } 1661 }
1652 1662
1653 return TRUE; 1663 return TRUE;
1654 } 1664 }
1655 1665
1656 void Field::SetLineWidth(CPDFSDK_Document* pDocument, 1666 void Field::SetLineWidth(CPDFSDK_FormFillEnvironment* pFormFillEnv,
1657 const CFX_WideString& swFieldName, 1667 const CFX_WideString& swFieldName,
1658 int nControlIndex, 1668 int nControlIndex,
1659 int number) { 1669 int number) {
1660 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); 1670 CPDFSDK_InterForm* pInterForm =
1671 pFormFillEnv->GetSDKDocument()->GetInterForm();
1661 std::vector<CPDF_FormField*> FieldArray = 1672 std::vector<CPDF_FormField*> FieldArray =
1662 GetFormFields(pDocument, swFieldName); 1673 GetFormFields(pFormFillEnv, swFieldName);
1663 for (CPDF_FormField* pFormField : FieldArray) { 1674 for (CPDF_FormField* pFormField : FieldArray) {
1664 if (nControlIndex < 0) { 1675 if (nControlIndex < 0) {
1665 FX_BOOL bSet = FALSE; 1676 FX_BOOL bSet = FALSE;
1666 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { 1677 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) {
1667 CPDF_FormControl* pFormControl = pFormField->GetControl(i); 1678 CPDF_FormControl* pFormControl = pFormField->GetControl(i);
1668 ASSERT(pFormControl); 1679 ASSERT(pFormControl);
1669 1680
1670 if (CPDFSDK_Widget* pWidget = 1681 if (CPDFSDK_Widget* pWidget =
1671 pInterForm->GetWidget(pFormControl, false)) { 1682 pInterForm->GetWidget(pFormControl, false)) {
1672 if (number != pWidget->GetBorderWidth()) { 1683 if (number != pWidget->GetBorderWidth()) {
1673 pWidget->SetBorderWidth(number); 1684 pWidget->SetBorderWidth(number);
1674 bSet = TRUE; 1685 bSet = TRUE;
1675 } 1686 }
1676 } 1687 }
1677 } 1688 }
1678 if (bSet) 1689 if (bSet)
1679 UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE); 1690 UpdateFormField(pFormFillEnv, pFormField, TRUE, TRUE, TRUE);
1680 } else { 1691 } else {
1681 if (nControlIndex >= pFormField->CountControls()) 1692 if (nControlIndex >= pFormField->CountControls())
1682 return; 1693 return;
1683 if (CPDF_FormControl* pFormControl = 1694 if (CPDF_FormControl* pFormControl =
1684 pFormField->GetControl(nControlIndex)) { 1695 pFormField->GetControl(nControlIndex)) {
1685 if (CPDFSDK_Widget* pWidget = 1696 if (CPDFSDK_Widget* pWidget =
1686 pInterForm->GetWidget(pFormControl, false)) { 1697 pInterForm->GetWidget(pFormControl, false)) {
1687 if (number != pWidget->GetBorderWidth()) { 1698 if (number != pWidget->GetBorderWidth()) {
1688 pWidget->SetBorderWidth(number); 1699 pWidget->SetBorderWidth(number);
1689 UpdateFormControl(pDocument, pFormControl, TRUE, TRUE, TRUE); 1700 UpdateFormControl(pFormFillEnv, pFormControl, TRUE, TRUE, TRUE);
1690 } 1701 }
1691 } 1702 }
1692 } 1703 }
1693 } 1704 }
1694 } 1705 }
1695 } 1706 }
1696 1707
1697 FX_BOOL Field::multiline(IJS_Context* cc, 1708 FX_BOOL Field::multiline(IJS_Context* cc,
1698 CJS_PropValue& vp, 1709 CJS_PropValue& vp,
1699 CFX_WideString& sError) { 1710 CFX_WideString& sError) {
1700 ASSERT(m_pDocument); 1711 ASSERT(m_pFormFillEnv);
1701 1712
1702 if (vp.IsSetting()) { 1713 if (vp.IsSetting()) {
1703 if (!m_bCanSet) 1714 if (!m_bCanSet)
1704 return FALSE; 1715 return FALSE;
1705 1716
1706 bool bVP; 1717 bool bVP;
1707 vp >> bVP; 1718 vp >> bVP;
1708 1719
1709 if (m_bDelay) { 1720 if (m_bDelay) {
1710 AddDelay_Bool(FP_MULTILINE, bVP); 1721 AddDelay_Bool(FP_MULTILINE, bVP);
1711 } else { 1722 } else {
1712 Field::SetMultiline(m_pDocument.Get(), m_FieldName, m_nFormControlIndex, 1723 Field::SetMultiline(m_pFormFillEnv.Get(), m_FieldName,
1713 bVP); 1724 m_nFormControlIndex, bVP);
1714 } 1725 }
1715 } else { 1726 } else {
1716 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1727 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1717 if (FieldArray.empty()) 1728 if (FieldArray.empty())
1718 return FALSE; 1729 return FALSE;
1719 1730
1720 CPDF_FormField* pFormField = FieldArray[0]; 1731 CPDF_FormField* pFormField = FieldArray[0];
1721 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) 1732 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
1722 return FALSE; 1733 return FALSE;
1723 1734
1724 if (pFormField->GetFieldFlags() & FIELDFLAG_MULTILINE) 1735 if (pFormField->GetFieldFlags() & FIELDFLAG_MULTILINE)
1725 vp << true; 1736 vp << true;
1726 else 1737 else
1727 vp << false; 1738 vp << false;
1728 } 1739 }
1729 1740
1730 return TRUE; 1741 return TRUE;
1731 } 1742 }
1732 1743
1733 void Field::SetMultiline(CPDFSDK_Document* pDocument, 1744 void Field::SetMultiline(CPDFSDK_FormFillEnvironment* pFormFillEnv,
1734 const CFX_WideString& swFieldName, 1745 const CFX_WideString& swFieldName,
1735 int nControlIndex, 1746 int nControlIndex,
1736 bool b) { 1747 bool b) {
1737 // Not supported. 1748 // Not supported.
1738 } 1749 }
1739 1750
1740 FX_BOOL Field::multipleSelection(IJS_Context* cc, 1751 FX_BOOL Field::multipleSelection(IJS_Context* cc,
1741 CJS_PropValue& vp, 1752 CJS_PropValue& vp,
1742 CFX_WideString& sError) { 1753 CFX_WideString& sError) {
1743 ASSERT(m_pDocument); 1754 ASSERT(m_pFormFillEnv);
1744 1755
1745 if (vp.IsSetting()) { 1756 if (vp.IsSetting()) {
1746 if (!m_bCanSet) 1757 if (!m_bCanSet)
1747 return FALSE; 1758 return FALSE;
1748 1759
1749 bool bVP; 1760 bool bVP;
1750 vp >> bVP; 1761 vp >> bVP;
1751 1762
1752 if (m_bDelay) { 1763 if (m_bDelay) {
1753 AddDelay_Bool(FP_MULTIPLESELECTION, bVP); 1764 AddDelay_Bool(FP_MULTIPLESELECTION, bVP);
1754 } else { 1765 } else {
1755 Field::SetMultipleSelection(m_pDocument.Get(), m_FieldName, 1766 Field::SetMultipleSelection(m_pFormFillEnv.Get(), m_FieldName,
1756 m_nFormControlIndex, bVP); 1767 m_nFormControlIndex, bVP);
1757 } 1768 }
1758 } else { 1769 } else {
1759 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1770 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1760 if (FieldArray.empty()) 1771 if (FieldArray.empty())
1761 return FALSE; 1772 return FALSE;
1762 1773
1763 CPDF_FormField* pFormField = FieldArray[0]; 1774 CPDF_FormField* pFormField = FieldArray[0];
1764 if (pFormField->GetFieldType() != FIELDTYPE_LISTBOX) 1775 if (pFormField->GetFieldType() != FIELDTYPE_LISTBOX)
1765 return FALSE; 1776 return FALSE;
1766 1777
1767 if (pFormField->GetFieldFlags() & FIELDFLAG_MULTISELECT) 1778 if (pFormField->GetFieldFlags() & FIELDFLAG_MULTISELECT)
1768 vp << true; 1779 vp << true;
1769 else 1780 else
1770 vp << false; 1781 vp << false;
1771 } 1782 }
1772 1783
1773 return TRUE; 1784 return TRUE;
1774 } 1785 }
1775 1786
1776 void Field::SetMultipleSelection(CPDFSDK_Document* pDocument, 1787 void Field::SetMultipleSelection(CPDFSDK_FormFillEnvironment* pFormFillEnv,
1777 const CFX_WideString& swFieldName, 1788 const CFX_WideString& swFieldName,
1778 int nControlIndex, 1789 int nControlIndex,
1779 bool b) { 1790 bool b) {
1780 // Not supported. 1791 // Not supported.
1781 } 1792 }
1782 1793
1783 FX_BOOL Field::name(IJS_Context* cc, 1794 FX_BOOL Field::name(IJS_Context* cc,
1784 CJS_PropValue& vp, 1795 CJS_PropValue& vp,
1785 CFX_WideString& sError) { 1796 CFX_WideString& sError) {
1786 if (!vp.IsGetting()) 1797 if (!vp.IsGetting())
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1823 1834
1824 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1835 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1825 if (FieldArray.empty()) 1836 if (FieldArray.empty())
1826 return FALSE; 1837 return FALSE;
1827 1838
1828 CPDF_FormField* pFormField = FieldArray[0]; 1839 CPDF_FormField* pFormField = FieldArray[0];
1829 if (!pFormField) 1840 if (!pFormField)
1830 return FALSE; 1841 return FALSE;
1831 1842
1832 std::vector<CPDFSDK_Widget*> widgets; 1843 std::vector<CPDFSDK_Widget*> widgets;
1833 m_pDocument->GetInterForm()->GetWidgets(pFormField, &widgets); 1844 m_pFormFillEnv->GetSDKDocument()->GetInterForm()->GetWidgets(pFormField,
1845 &widgets);
1834 1846
1835 if (widgets.empty()) { 1847 if (widgets.empty()) {
1836 vp << (int32_t)-1; 1848 vp << (int32_t)-1;
1837 return TRUE; 1849 return TRUE;
1838 } 1850 }
1839 1851
1840 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); 1852 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
1841 CJS_Array PageArray; 1853 CJS_Array PageArray;
1842 for (size_t i = 0; i < widgets.size(); ++i) { 1854 for (size_t i = 0; i < widgets.size(); ++i) {
1843 CPDFSDK_PageView* pPageView = widgets[i]->GetPageView(); 1855 CPDFSDK_PageView* pPageView = widgets[i]->GetPageView();
1844 if (!pPageView) 1856 if (!pPageView)
1845 return FALSE; 1857 return FALSE;
1846 1858
1847 PageArray.SetElement( 1859 PageArray.SetElement(
1848 pRuntime, i, CJS_Value(pRuntime, (int32_t)pPageView->GetPageIndex())); 1860 pRuntime, i, CJS_Value(pRuntime, (int32_t)pPageView->GetPageIndex()));
1849 } 1861 }
1850 1862
1851 vp << PageArray; 1863 vp << PageArray;
1852 return TRUE; 1864 return TRUE;
1853 } 1865 }
1854 1866
1855 FX_BOOL Field::password(IJS_Context* cc, 1867 FX_BOOL Field::password(IJS_Context* cc,
1856 CJS_PropValue& vp, 1868 CJS_PropValue& vp,
1857 CFX_WideString& sError) { 1869 CFX_WideString& sError) {
1858 ASSERT(m_pDocument); 1870 ASSERT(m_pFormFillEnv);
1859 1871
1860 if (vp.IsSetting()) { 1872 if (vp.IsSetting()) {
1861 if (!m_bCanSet) 1873 if (!m_bCanSet)
1862 return FALSE; 1874 return FALSE;
1863 1875
1864 bool bVP; 1876 bool bVP;
1865 vp >> bVP; 1877 vp >> bVP;
1866 1878
1867 if (m_bDelay) { 1879 if (m_bDelay) {
1868 AddDelay_Bool(FP_PASSWORD, bVP); 1880 AddDelay_Bool(FP_PASSWORD, bVP);
1869 } else { 1881 } else {
1870 Field::SetPassword(m_pDocument.Get(), m_FieldName, m_nFormControlIndex, 1882 Field::SetPassword(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
1871 bVP); 1883 bVP);
1872 } 1884 }
1873 } else { 1885 } else {
1874 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1886 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1875 if (FieldArray.empty()) 1887 if (FieldArray.empty())
1876 return FALSE; 1888 return FALSE;
1877 1889
1878 CPDF_FormField* pFormField = FieldArray[0]; 1890 CPDF_FormField* pFormField = FieldArray[0];
1879 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) 1891 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
1880 return FALSE; 1892 return FALSE;
1881 1893
1882 if (pFormField->GetFieldFlags() & FIELDFLAG_PASSWORD) 1894 if (pFormField->GetFieldFlags() & FIELDFLAG_PASSWORD)
1883 vp << true; 1895 vp << true;
1884 else 1896 else
1885 vp << false; 1897 vp << false;
1886 } 1898 }
1887 1899
1888 return TRUE; 1900 return TRUE;
1889 } 1901 }
1890 1902
1891 void Field::SetPassword(CPDFSDK_Document* pDocument, 1903 void Field::SetPassword(CPDFSDK_FormFillEnvironment* pFormFillEnv,
1892 const CFX_WideString& swFieldName, 1904 const CFX_WideString& swFieldName,
1893 int nControlIndex, 1905 int nControlIndex,
1894 bool b) { 1906 bool b) {
1895 // Not supported. 1907 // Not supported.
1896 } 1908 }
1897 1909
1898 FX_BOOL Field::print(IJS_Context* cc, 1910 FX_BOOL Field::print(IJS_Context* cc,
1899 CJS_PropValue& vp, 1911 CJS_PropValue& vp,
1900 CFX_WideString& sError) { 1912 CFX_WideString& sError) {
1901 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); 1913 CPDFSDK_InterForm* pInterForm =
1914 m_pFormFillEnv->GetSDKDocument()->GetInterForm();
1902 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1915 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1903 if (FieldArray.empty()) 1916 if (FieldArray.empty())
1904 return FALSE; 1917 return FALSE;
1905 1918
1906 if (vp.IsSetting()) { 1919 if (vp.IsSetting()) {
1907 if (!m_bCanSet) 1920 if (!m_bCanSet)
1908 return FALSE; 1921 return FALSE;
1909 1922
1910 bool bVP; 1923 bool bVP;
1911 vp >> bVP; 1924 vp >> bVP;
(...skipping 11 matching lines...) Expand all
1923 dwFlags &= ~ANNOTFLAG_PRINT; 1936 dwFlags &= ~ANNOTFLAG_PRINT;
1924 1937
1925 if (dwFlags != pWidget->GetFlags()) { 1938 if (dwFlags != pWidget->GetFlags()) {
1926 pWidget->SetFlags(dwFlags); 1939 pWidget->SetFlags(dwFlags);
1927 bSet = TRUE; 1940 bSet = TRUE;
1928 } 1941 }
1929 } 1942 }
1930 } 1943 }
1931 1944
1932 if (bSet) 1945 if (bSet)
1933 UpdateFormField(m_pDocument.Get(), pFormField, TRUE, FALSE, TRUE); 1946 UpdateFormField(m_pFormFillEnv.Get(), pFormField, TRUE, FALSE, TRUE);
1934 } else { 1947 } else {
1935 if (m_nFormControlIndex >= pFormField->CountControls()) 1948 if (m_nFormControlIndex >= pFormField->CountControls())
1936 return FALSE; 1949 return FALSE;
1937 if (CPDF_FormControl* pFormControl = 1950 if (CPDF_FormControl* pFormControl =
1938 pFormField->GetControl(m_nFormControlIndex)) { 1951 pFormField->GetControl(m_nFormControlIndex)) {
1939 if (CPDFSDK_Widget* pWidget = 1952 if (CPDFSDK_Widget* pWidget =
1940 pInterForm->GetWidget(pFormControl, true)) { 1953 pInterForm->GetWidget(pFormControl, true)) {
1941 uint32_t dwFlags = pWidget->GetFlags(); 1954 uint32_t dwFlags = pWidget->GetFlags();
1942 if (bVP) 1955 if (bVP)
1943 dwFlags |= ANNOTFLAG_PRINT; 1956 dwFlags |= ANNOTFLAG_PRINT;
1944 else 1957 else
1945 dwFlags &= ~ANNOTFLAG_PRINT; 1958 dwFlags &= ~ANNOTFLAG_PRINT;
1946 1959
1947 if (dwFlags != pWidget->GetFlags()) { 1960 if (dwFlags != pWidget->GetFlags()) {
1948 pWidget->SetFlags(dwFlags); 1961 pWidget->SetFlags(dwFlags);
1949 UpdateFormControl(m_pDocument.Get(), 1962 UpdateFormControl(m_pFormFillEnv.Get(),
1950 pFormField->GetControl(m_nFormControlIndex), 1963 pFormField->GetControl(m_nFormControlIndex),
1951 TRUE, FALSE, TRUE); 1964 TRUE, FALSE, TRUE);
1952 } 1965 }
1953 } 1966 }
1954 } 1967 }
1955 } 1968 }
1956 } 1969 }
1957 } else { 1970 } else {
1958 CPDF_FormField* pFormField = FieldArray[0]; 1971 CPDF_FormField* pFormField = FieldArray[0];
1959 CPDFSDK_Widget* pWidget = 1972 CPDFSDK_Widget* pWidget =
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
2048 FX_FLOAT pArray[4] = {0.0f, 0.0f, 0.0f, 0.0f}; 2061 FX_FLOAT pArray[4] = {0.0f, 0.0f, 0.0f, 0.0f};
2049 pArray[0] = static_cast<FX_FLOAT>(Upper_Leftx.ToInt(pRuntime)); 2062 pArray[0] = static_cast<FX_FLOAT>(Upper_Leftx.ToInt(pRuntime));
2050 pArray[1] = static_cast<FX_FLOAT>(Lower_Righty.ToInt(pRuntime)); 2063 pArray[1] = static_cast<FX_FLOAT>(Lower_Righty.ToInt(pRuntime));
2051 pArray[2] = static_cast<FX_FLOAT>(Lower_Rightx.ToInt(pRuntime)); 2064 pArray[2] = static_cast<FX_FLOAT>(Lower_Rightx.ToInt(pRuntime));
2052 pArray[3] = static_cast<FX_FLOAT>(Upper_Lefty.ToInt(pRuntime)); 2065 pArray[3] = static_cast<FX_FLOAT>(Upper_Lefty.ToInt(pRuntime));
2053 2066
2054 CFX_FloatRect crRect(pArray); 2067 CFX_FloatRect crRect(pArray);
2055 if (m_bDelay) { 2068 if (m_bDelay) {
2056 AddDelay_Rect(FP_RECT, crRect); 2069 AddDelay_Rect(FP_RECT, crRect);
2057 } else { 2070 } else {
2058 Field::SetRect(m_pDocument.Get(), m_FieldName, m_nFormControlIndex, 2071 Field::SetRect(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
2059 crRect); 2072 crRect);
2060 } 2073 }
2061 } else { 2074 } else {
2062 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 2075 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
2063 if (FieldArray.empty()) 2076 if (FieldArray.empty())
2064 return FALSE; 2077 return FALSE;
2065 2078
2066 CPDF_FormField* pFormField = FieldArray[0]; 2079 CPDF_FormField* pFormField = FieldArray[0];
2067 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); 2080 CPDFSDK_InterForm* pInterForm =
2081 m_pFormFillEnv->GetSDKDocument()->GetInterForm();
2068 CPDFSDK_Widget* pWidget = 2082 CPDFSDK_Widget* pWidget =
2069 pInterForm->GetWidget(GetSmartFieldControl(pFormField), true); 2083 pInterForm->GetWidget(GetSmartFieldControl(pFormField), true);
2070 if (!pWidget) 2084 if (!pWidget)
2071 return FALSE; 2085 return FALSE;
2072 2086
2073 CFX_FloatRect crRect = pWidget->GetRect(); 2087 CFX_FloatRect crRect = pWidget->GetRect();
2074 Upper_Leftx = CJS_Value(pRuntime, static_cast<int32_t>(crRect.left)); 2088 Upper_Leftx = CJS_Value(pRuntime, static_cast<int32_t>(crRect.left));
2075 Upper_Lefty = CJS_Value(pRuntime, static_cast<int32_t>(crRect.top)); 2089 Upper_Lefty = CJS_Value(pRuntime, static_cast<int32_t>(crRect.top));
2076 Lower_Rightx = CJS_Value(pRuntime, static_cast<int32_t>(crRect.right)); 2090 Lower_Rightx = CJS_Value(pRuntime, static_cast<int32_t>(crRect.right));
2077 Lower_Righty = CJS_Value(pRuntime, static_cast<int32_t>(crRect.bottom)); 2091 Lower_Righty = CJS_Value(pRuntime, static_cast<int32_t>(crRect.bottom));
2078 2092
2079 CJS_Array rcArray; 2093 CJS_Array rcArray;
2080 rcArray.SetElement(pRuntime, 0, Upper_Leftx); 2094 rcArray.SetElement(pRuntime, 0, Upper_Leftx);
2081 rcArray.SetElement(pRuntime, 1, Upper_Lefty); 2095 rcArray.SetElement(pRuntime, 1, Upper_Lefty);
2082 rcArray.SetElement(pRuntime, 2, Lower_Rightx); 2096 rcArray.SetElement(pRuntime, 2, Lower_Rightx);
2083 rcArray.SetElement(pRuntime, 3, Lower_Righty); 2097 rcArray.SetElement(pRuntime, 3, Lower_Righty);
2084 vp << rcArray; 2098 vp << rcArray;
2085 } 2099 }
2086 return TRUE; 2100 return TRUE;
2087 } 2101 }
2088 2102
2089 void Field::SetRect(CPDFSDK_Document* pDocument, 2103 void Field::SetRect(CPDFSDK_FormFillEnvironment* pFormFillEnv,
2090 const CFX_WideString& swFieldName, 2104 const CFX_WideString& swFieldName,
2091 int nControlIndex, 2105 int nControlIndex,
2092 const CFX_FloatRect& rect) { 2106 const CFX_FloatRect& rect) {
2093 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); 2107 CPDFSDK_InterForm* pInterForm =
2108 pFormFillEnv->GetSDKDocument()->GetInterForm();
2094 std::vector<CPDF_FormField*> FieldArray = 2109 std::vector<CPDF_FormField*> FieldArray =
2095 GetFormFields(pDocument, swFieldName); 2110 GetFormFields(pFormFillEnv, swFieldName);
2096 for (CPDF_FormField* pFormField : FieldArray) { 2111 for (CPDF_FormField* pFormField : FieldArray) {
2097 if (nControlIndex < 0) { 2112 if (nControlIndex < 0) {
2098 FX_BOOL bSet = FALSE; 2113 FX_BOOL bSet = FALSE;
2099 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { 2114 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) {
2100 CPDF_FormControl* pFormControl = pFormField->GetControl(i); 2115 CPDF_FormControl* pFormControl = pFormField->GetControl(i);
2101 ASSERT(pFormControl); 2116 ASSERT(pFormControl);
2102 2117
2103 if (CPDFSDK_Widget* pWidget = 2118 if (CPDFSDK_Widget* pWidget =
2104 pInterForm->GetWidget(pFormControl, false)) { 2119 pInterForm->GetWidget(pFormControl, false)) {
2105 CFX_FloatRect crRect = rect; 2120 CFX_FloatRect crRect = rect;
2106 2121
2107 CPDF_Page* pPDFPage = pWidget->GetPDFPage(); 2122 CPDF_Page* pPDFPage = pWidget->GetPDFPage();
2108 crRect.Intersect(pPDFPage->GetPageBBox()); 2123 crRect.Intersect(pPDFPage->GetPageBBox());
2109 2124
2110 if (!crRect.IsEmpty()) { 2125 if (!crRect.IsEmpty()) {
2111 CFX_FloatRect rcOld = pWidget->GetRect(); 2126 CFX_FloatRect rcOld = pWidget->GetRect();
2112 if (crRect.left != rcOld.left || crRect.right != rcOld.right || 2127 if (crRect.left != rcOld.left || crRect.right != rcOld.right ||
2113 crRect.top != rcOld.top || crRect.bottom != rcOld.bottom) { 2128 crRect.top != rcOld.top || crRect.bottom != rcOld.bottom) {
2114 pWidget->SetRect(crRect); 2129 pWidget->SetRect(crRect);
2115 bSet = TRUE; 2130 bSet = TRUE;
2116 } 2131 }
2117 } 2132 }
2118 } 2133 }
2119 } 2134 }
2120 2135
2121 if (bSet) 2136 if (bSet)
2122 UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE); 2137 UpdateFormField(pFormFillEnv, pFormField, TRUE, TRUE, TRUE);
2123 } else { 2138 } else {
2124 if (nControlIndex >= pFormField->CountControls()) 2139 if (nControlIndex >= pFormField->CountControls())
2125 return; 2140 return;
2126 if (CPDF_FormControl* pFormControl = 2141 if (CPDF_FormControl* pFormControl =
2127 pFormField->GetControl(nControlIndex)) { 2142 pFormField->GetControl(nControlIndex)) {
2128 if (CPDFSDK_Widget* pWidget = 2143 if (CPDFSDK_Widget* pWidget =
2129 pInterForm->GetWidget(pFormControl, false)) { 2144 pInterForm->GetWidget(pFormControl, false)) {
2130 CFX_FloatRect crRect = rect; 2145 CFX_FloatRect crRect = rect;
2131 2146
2132 CPDF_Page* pPDFPage = pWidget->GetPDFPage(); 2147 CPDF_Page* pPDFPage = pWidget->GetPDFPage();
2133 crRect.Intersect(pPDFPage->GetPageBBox()); 2148 crRect.Intersect(pPDFPage->GetPageBBox());
2134 2149
2135 if (!crRect.IsEmpty()) { 2150 if (!crRect.IsEmpty()) {
2136 CFX_FloatRect rcOld = pWidget->GetRect(); 2151 CFX_FloatRect rcOld = pWidget->GetRect();
2137 if (crRect.left != rcOld.left || crRect.right != rcOld.right || 2152 if (crRect.left != rcOld.left || crRect.right != rcOld.right ||
2138 crRect.top != rcOld.top || crRect.bottom != rcOld.bottom) { 2153 crRect.top != rcOld.top || crRect.bottom != rcOld.bottom) {
2139 pWidget->SetRect(crRect); 2154 pWidget->SetRect(crRect);
2140 UpdateFormControl(pDocument, pFormControl, TRUE, TRUE, TRUE); 2155 UpdateFormControl(pFormFillEnv, pFormControl, TRUE, TRUE, TRUE);
2141 } 2156 }
2142 } 2157 }
2143 } 2158 }
2144 } 2159 }
2145 } 2160 }
2146 } 2161 }
2147 } 2162 }
2148 2163
2149 FX_BOOL Field::required(IJS_Context* cc, 2164 FX_BOOL Field::required(IJS_Context* cc,
2150 CJS_PropValue& vp, 2165 CJS_PropValue& vp,
(...skipping 19 matching lines...) Expand all
2170 else 2185 else
2171 vp << false; 2186 vp << false;
2172 } 2187 }
2173 2188
2174 return TRUE; 2189 return TRUE;
2175 } 2190 }
2176 2191
2177 FX_BOOL Field::richText(IJS_Context* cc, 2192 FX_BOOL Field::richText(IJS_Context* cc,
2178 CJS_PropValue& vp, 2193 CJS_PropValue& vp,
2179 CFX_WideString& sError) { 2194 CFX_WideString& sError) {
2180 ASSERT(m_pDocument); 2195 ASSERT(m_pFormFillEnv);
2181 2196
2182 if (vp.IsSetting()) { 2197 if (vp.IsSetting()) {
2183 if (!m_bCanSet) 2198 if (!m_bCanSet)
2184 return FALSE; 2199 return FALSE;
2185 2200
2186 bool bVP; 2201 bool bVP;
2187 vp >> bVP; 2202 vp >> bVP;
2188 2203
2189 if (m_bDelay) { 2204 if (m_bDelay) {
2190 AddDelay_Bool(FP_RICHTEXT, bVP); 2205 AddDelay_Bool(FP_RICHTEXT, bVP);
(...skipping 18 matching lines...) Expand all
2209 2224
2210 FX_BOOL Field::richValue(IJS_Context* cc, 2225 FX_BOOL Field::richValue(IJS_Context* cc,
2211 CJS_PropValue& vp, 2226 CJS_PropValue& vp,
2212 CFX_WideString& sError) { 2227 CFX_WideString& sError) {
2213 return TRUE; 2228 return TRUE;
2214 } 2229 }
2215 2230
2216 FX_BOOL Field::rotation(IJS_Context* cc, 2231 FX_BOOL Field::rotation(IJS_Context* cc,
2217 CJS_PropValue& vp, 2232 CJS_PropValue& vp,
2218 CFX_WideString& sError) { 2233 CFX_WideString& sError) {
2219 ASSERT(m_pDocument); 2234 ASSERT(m_pFormFillEnv);
2220 2235
2221 if (vp.IsSetting()) { 2236 if (vp.IsSetting()) {
2222 if (!m_bCanSet) 2237 if (!m_bCanSet)
2223 return FALSE; 2238 return FALSE;
2224 2239
2225 int nVP; 2240 int nVP;
2226 vp >> nVP; 2241 vp >> nVP;
2227 2242
2228 if (m_bDelay) { 2243 if (m_bDelay) {
2229 AddDelay_Int(FP_ROTATION, nVP); 2244 AddDelay_Int(FP_ROTATION, nVP);
2230 } else { 2245 } else {
2231 Field::SetRotation(m_pDocument.Get(), m_FieldName, m_nFormControlIndex, 2246 Field::SetRotation(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
2232 nVP); 2247 nVP);
2233 } 2248 }
2234 } else { 2249 } else {
2235 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 2250 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
2236 if (FieldArray.empty()) 2251 if (FieldArray.empty())
2237 return FALSE; 2252 return FALSE;
2238 2253
2239 CPDF_FormField* pFormField = FieldArray[0]; 2254 CPDF_FormField* pFormField = FieldArray[0];
2240 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 2255 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
2241 if (!pFormControl) 2256 if (!pFormControl)
2242 return FALSE; 2257 return FALSE;
2243 2258
2244 vp << (int32_t)pFormControl->GetRotation(); 2259 vp << (int32_t)pFormControl->GetRotation();
2245 } 2260 }
2246 2261
2247 return TRUE; 2262 return TRUE;
2248 } 2263 }
2249 2264
2250 void Field::SetRotation(CPDFSDK_Document* pDocument, 2265 void Field::SetRotation(CPDFSDK_FormFillEnvironment* pFormFillEnv,
2251 const CFX_WideString& swFieldName, 2266 const CFX_WideString& swFieldName,
2252 int nControlIndex, 2267 int nControlIndex,
2253 int number) { 2268 int number) {
2254 // Not supported. 2269 // Not supported.
2255 } 2270 }
2256 2271
2257 FX_BOOL Field::strokeColor(IJS_Context* cc, 2272 FX_BOOL Field::strokeColor(IJS_Context* cc,
2258 CJS_PropValue& vp, 2273 CJS_PropValue& vp,
2259 CFX_WideString& sError) { 2274 CFX_WideString& sError) {
2260 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); 2275 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
2261 CJS_Array crArray; 2276 CJS_Array crArray;
2262 2277
2263 if (vp.IsSetting()) { 2278 if (vp.IsSetting()) {
2264 if (!m_bCanSet) 2279 if (!m_bCanSet)
2265 return FALSE; 2280 return FALSE;
2266 2281
2267 if (!vp.GetJSValue()->IsArrayObject()) 2282 if (!vp.GetJSValue()->IsArrayObject())
2268 return FALSE; 2283 return FALSE;
2269 2284
2270 vp >> crArray; 2285 vp >> crArray;
2271 2286
2272 CPWL_Color color; 2287 CPWL_Color color;
2273 color::ConvertArrayToPWLColor(pRuntime, crArray, &color); 2288 color::ConvertArrayToPWLColor(pRuntime, crArray, &color);
2274 2289
2275 if (m_bDelay) { 2290 if (m_bDelay) {
2276 AddDelay_Color(FP_STROKECOLOR, color); 2291 AddDelay_Color(FP_STROKECOLOR, color);
2277 } else { 2292 } else {
2278 Field::SetStrokeColor(m_pDocument.Get(), m_FieldName, m_nFormControlIndex, 2293 Field::SetStrokeColor(m_pFormFillEnv.Get(), m_FieldName,
2279 color); 2294 m_nFormControlIndex, color);
2280 } 2295 }
2281 } else { 2296 } else {
2282 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 2297 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
2283 if (FieldArray.empty()) 2298 if (FieldArray.empty())
2284 return FALSE; 2299 return FALSE;
2285 2300
2286 CPDF_FormField* pFormField = FieldArray[0]; 2301 CPDF_FormField* pFormField = FieldArray[0];
2287 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 2302 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
2288 if (!pFormControl) 2303 if (!pFormControl)
2289 return FALSE; 2304 return FALSE;
(...skipping 20 matching lines...) Expand all
2310 } else { 2325 } else {
2311 return FALSE; 2326 return FALSE;
2312 } 2327 }
2313 2328
2314 color::ConvertPWLColorToArray(pRuntime, color, &crArray); 2329 color::ConvertPWLColorToArray(pRuntime, color, &crArray);
2315 vp << crArray; 2330 vp << crArray;
2316 } 2331 }
2317 return TRUE; 2332 return TRUE;
2318 } 2333 }
2319 2334
2320 void Field::SetStrokeColor(CPDFSDK_Document* pDocument, 2335 void Field::SetStrokeColor(CPDFSDK_FormFillEnvironment* pFormFillEnv,
2321 const CFX_WideString& swFieldName, 2336 const CFX_WideString& swFieldName,
2322 int nControlIndex, 2337 int nControlIndex,
2323 const CPWL_Color& color) { 2338 const CPWL_Color& color) {
2324 // Not supported. 2339 // Not supported.
2325 } 2340 }
2326 2341
2327 FX_BOOL Field::style(IJS_Context* cc, 2342 FX_BOOL Field::style(IJS_Context* cc,
2328 CJS_PropValue& vp, 2343 CJS_PropValue& vp,
2329 CFX_WideString& sError) { 2344 CFX_WideString& sError) {
2330 ASSERT(m_pDocument); 2345 ASSERT(m_pFormFillEnv);
2331 2346
2332 if (vp.IsSetting()) { 2347 if (vp.IsSetting()) {
2333 if (!m_bCanSet) 2348 if (!m_bCanSet)
2334 return FALSE; 2349 return FALSE;
2335 2350
2336 CFX_ByteString csBCaption; 2351 CFX_ByteString csBCaption;
2337 vp >> csBCaption; 2352 vp >> csBCaption;
2338 2353
2339 if (m_bDelay) { 2354 if (m_bDelay) {
2340 AddDelay_String(FP_STYLE, csBCaption); 2355 AddDelay_String(FP_STYLE, csBCaption);
2341 } else { 2356 } else {
2342 Field::SetStyle(m_pDocument.Get(), m_FieldName, m_nFormControlIndex, 2357 Field::SetStyle(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
2343 csBCaption); 2358 csBCaption);
2344 } 2359 }
2345 } else { 2360 } else {
2346 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 2361 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
2347 if (FieldArray.empty()) 2362 if (FieldArray.empty())
2348 return FALSE; 2363 return FALSE;
2349 2364
2350 CPDF_FormField* pFormField = FieldArray[0]; 2365 CPDF_FormField* pFormField = FieldArray[0];
2351 if (pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON && 2366 if (pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON &&
2352 pFormField->GetFieldType() != FIELDTYPE_CHECKBOX) { 2367 pFormField->GetFieldType() != FIELDTYPE_CHECKBOX) {
(...skipping 26 matching lines...) Expand all
2379 default: // L'4' 2394 default: // L'4'
2380 csBCaption = "check"; 2395 csBCaption = "check";
2381 break; 2396 break;
2382 } 2397 }
2383 vp << csBCaption; 2398 vp << csBCaption;
2384 } 2399 }
2385 2400
2386 return TRUE; 2401 return TRUE;
2387 } 2402 }
2388 2403
2389 void Field::SetStyle(CPDFSDK_Document* pDocument, 2404 void Field::SetStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv,
2390 const CFX_WideString& swFieldName, 2405 const CFX_WideString& swFieldName,
2391 int nControlIndex, 2406 int nControlIndex,
2392 const CFX_ByteString& string) { 2407 const CFX_ByteString& string) {
2393 // Not supported. 2408 // Not supported.
2394 } 2409 }
2395 2410
2396 FX_BOOL Field::submitName(IJS_Context* cc, 2411 FX_BOOL Field::submitName(IJS_Context* cc,
2397 CJS_PropValue& vp, 2412 CJS_PropValue& vp,
2398 CFX_WideString& sError) { 2413 CFX_WideString& sError) {
2399 return TRUE; 2414 return TRUE;
(...skipping 13 matching lines...) Expand all
2413 return FALSE; 2428 return FALSE;
2414 2429
2415 vp >> crArray; 2430 vp >> crArray;
2416 2431
2417 CPWL_Color color; 2432 CPWL_Color color;
2418 color::ConvertArrayToPWLColor(pRuntime, crArray, &color); 2433 color::ConvertArrayToPWLColor(pRuntime, crArray, &color);
2419 2434
2420 if (m_bDelay) { 2435 if (m_bDelay) {
2421 AddDelay_Color(FP_TEXTCOLOR, color); 2436 AddDelay_Color(FP_TEXTCOLOR, color);
2422 } else { 2437 } else {
2423 Field::SetTextColor(m_pDocument.Get(), m_FieldName, m_nFormControlIndex, 2438 Field::SetTextColor(m_pFormFillEnv.Get(), m_FieldName,
2424 color); 2439 m_nFormControlIndex, color);
2425 } 2440 }
2426 } else { 2441 } else {
2427 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 2442 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
2428 if (FieldArray.empty()) 2443 if (FieldArray.empty())
2429 return FALSE; 2444 return FALSE;
2430 2445
2431 CPDF_FormField* pFormField = FieldArray[0]; 2446 CPDF_FormField* pFormField = FieldArray[0];
2432 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 2447 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
2433 if (!pFormControl) 2448 if (!pFormControl)
2434 return FALSE; 2449 return FALSE;
(...skipping 11 matching lines...) Expand all
2446 2461
2447 if (iColorType == COLORTYPE_TRANSPARENT) 2462 if (iColorType == COLORTYPE_TRANSPARENT)
2448 crRet = CPWL_Color(COLORTYPE_TRANSPARENT); 2463 crRet = CPWL_Color(COLORTYPE_TRANSPARENT);
2449 2464
2450 color::ConvertPWLColorToArray(pRuntime, crRet, &crArray); 2465 color::ConvertPWLColorToArray(pRuntime, crRet, &crArray);
2451 vp << crArray; 2466 vp << crArray;
2452 } 2467 }
2453 return TRUE; 2468 return TRUE;
2454 } 2469 }
2455 2470
2456 void Field::SetTextColor(CPDFSDK_Document* pDocument, 2471 void Field::SetTextColor(CPDFSDK_FormFillEnvironment* pFormFillEnv,
2457 const CFX_WideString& swFieldName, 2472 const CFX_WideString& swFieldName,
2458 int nControlIndex, 2473 int nControlIndex,
2459 const CPWL_Color& color) { 2474 const CPWL_Color& color) {
2460 // Not supported. 2475 // Not supported.
2461 } 2476 }
2462 2477
2463 FX_BOOL Field::textFont(IJS_Context* cc, 2478 FX_BOOL Field::textFont(IJS_Context* cc,
2464 CJS_PropValue& vp, 2479 CJS_PropValue& vp,
2465 CFX_WideString& sError) { 2480 CFX_WideString& sError) {
2466 ASSERT(m_pDocument); 2481 ASSERT(m_pFormFillEnv);
2467 2482
2468 if (vp.IsSetting()) { 2483 if (vp.IsSetting()) {
2469 if (!m_bCanSet) 2484 if (!m_bCanSet)
2470 return FALSE; 2485 return FALSE;
2471 2486
2472 CFX_ByteString csFontName; 2487 CFX_ByteString csFontName;
2473 vp >> csFontName; 2488 vp >> csFontName;
2474 if (csFontName.IsEmpty()) 2489 if (csFontName.IsEmpty())
2475 return FALSE; 2490 return FALSE;
2476 2491
2477 if (m_bDelay) { 2492 if (m_bDelay) {
2478 AddDelay_String(FP_TEXTFONT, csFontName); 2493 AddDelay_String(FP_TEXTFONT, csFontName);
2479 } else { 2494 } else {
2480 Field::SetTextFont(m_pDocument.Get(), m_FieldName, m_nFormControlIndex, 2495 Field::SetTextFont(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
2481 csFontName); 2496 csFontName);
2482 } 2497 }
2483 } else { 2498 } else {
2484 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 2499 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
2485 if (FieldArray.empty()) 2500 if (FieldArray.empty())
2486 return FALSE; 2501 return FALSE;
2487 2502
2488 CPDF_FormField* pFormField = FieldArray[0]; 2503 CPDF_FormField* pFormField = FieldArray[0];
2489 ASSERT(pFormField); 2504 ASSERT(pFormField);
2490 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 2505 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
(...skipping 11 matching lines...) Expand all
2502 2517
2503 vp << pFont->GetBaseFont(); 2518 vp << pFont->GetBaseFont();
2504 } else { 2519 } else {
2505 return FALSE; 2520 return FALSE;
2506 } 2521 }
2507 } 2522 }
2508 2523
2509 return TRUE; 2524 return TRUE;
2510 } 2525 }
2511 2526
2512 void Field::SetTextFont(CPDFSDK_Document* pDocument, 2527 void Field::SetTextFont(CPDFSDK_FormFillEnvironment* pFormFillEnv,
2513 const CFX_WideString& swFieldName, 2528 const CFX_WideString& swFieldName,
2514 int nControlIndex, 2529 int nControlIndex,
2515 const CFX_ByteString& string) { 2530 const CFX_ByteString& string) {
2516 // Not supported. 2531 // Not supported.
2517 } 2532 }
2518 2533
2519 FX_BOOL Field::textSize(IJS_Context* cc, 2534 FX_BOOL Field::textSize(IJS_Context* cc,
2520 CJS_PropValue& vp, 2535 CJS_PropValue& vp,
2521 CFX_WideString& sError) { 2536 CFX_WideString& sError) {
2522 ASSERT(m_pDocument); 2537 ASSERT(m_pFormFillEnv);
2523 2538
2524 if (vp.IsSetting()) { 2539 if (vp.IsSetting()) {
2525 if (!m_bCanSet) 2540 if (!m_bCanSet)
2526 return FALSE; 2541 return FALSE;
2527 2542
2528 int nVP; 2543 int nVP;
2529 vp >> nVP; 2544 vp >> nVP;
2530 2545
2531 if (m_bDelay) { 2546 if (m_bDelay) {
2532 AddDelay_Int(FP_TEXTSIZE, nVP); 2547 AddDelay_Int(FP_TEXTSIZE, nVP);
2533 } else { 2548 } else {
2534 Field::SetTextSize(m_pDocument.Get(), m_FieldName, m_nFormControlIndex, 2549 Field::SetTextSize(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
2535 nVP); 2550 nVP);
2536 } 2551 }
2537 } else { 2552 } else {
2538 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 2553 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
2539 if (FieldArray.empty()) 2554 if (FieldArray.empty())
2540 return FALSE; 2555 return FALSE;
2541 2556
2542 CPDF_FormField* pFormField = FieldArray[0]; 2557 CPDF_FormField* pFormField = FieldArray[0];
2543 ASSERT(pFormField); 2558 ASSERT(pFormField);
2544 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 2559 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
2545 if (!pFormControl) 2560 if (!pFormControl)
2546 return FALSE; 2561 return FALSE;
2547 2562
2548 CPDF_DefaultAppearance FieldAppearance = 2563 CPDF_DefaultAppearance FieldAppearance =
2549 pFormControl->GetDefaultAppearance(); 2564 pFormControl->GetDefaultAppearance();
2550 2565
2551 CFX_ByteString csFontNameTag; 2566 CFX_ByteString csFontNameTag;
2552 FX_FLOAT fFontSize; 2567 FX_FLOAT fFontSize;
2553 FieldAppearance.GetFont(csFontNameTag, fFontSize); 2568 FieldAppearance.GetFont(csFontNameTag, fFontSize);
2554 2569
2555 vp << (int)fFontSize; 2570 vp << (int)fFontSize;
2556 } 2571 }
2557 2572
2558 return TRUE; 2573 return TRUE;
2559 } 2574 }
2560 2575
2561 void Field::SetTextSize(CPDFSDK_Document* pDocument, 2576 void Field::SetTextSize(CPDFSDK_FormFillEnvironment* pFormFillEnv,
2562 const CFX_WideString& swFieldName, 2577 const CFX_WideString& swFieldName,
2563 int nControlIndex, 2578 int nControlIndex,
2564 int number) { 2579 int number) {
2565 // Not supported. 2580 // Not supported.
2566 } 2581 }
2567 2582
2568 FX_BOOL Field::type(IJS_Context* cc, 2583 FX_BOOL Field::type(IJS_Context* cc,
2569 CJS_PropValue& vp, 2584 CJS_PropValue& vp,
2570 CFX_WideString& sError) { 2585 CFX_WideString& sError) {
2571 if (!vp.IsGetting()) 2586 if (!vp.IsGetting())
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2605 vp << L"unknown"; 2620 vp << L"unknown";
2606 break; 2621 break;
2607 } 2622 }
2608 2623
2609 return TRUE; 2624 return TRUE;
2610 } 2625 }
2611 2626
2612 FX_BOOL Field::userName(IJS_Context* cc, 2627 FX_BOOL Field::userName(IJS_Context* cc,
2613 CJS_PropValue& vp, 2628 CJS_PropValue& vp,
2614 CFX_WideString& sError) { 2629 CFX_WideString& sError) {
2615 ASSERT(m_pDocument); 2630 ASSERT(m_pFormFillEnv);
2616 2631
2617 if (vp.IsSetting()) { 2632 if (vp.IsSetting()) {
2618 if (!m_bCanSet) 2633 if (!m_bCanSet)
2619 return FALSE; 2634 return FALSE;
2620 2635
2621 CFX_WideString swName; 2636 CFX_WideString swName;
2622 vp >> swName; 2637 vp >> swName;
2623 2638
2624 if (m_bDelay) { 2639 if (m_bDelay) {
2625 AddDelay_WideString(FP_USERNAME, swName); 2640 AddDelay_WideString(FP_USERNAME, swName);
2626 } else { 2641 } else {
2627 Field::SetUserName(m_pDocument.Get(), m_FieldName, m_nFormControlIndex, 2642 Field::SetUserName(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
2628 swName); 2643 swName);
2629 } 2644 }
2630 } else { 2645 } else {
2631 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 2646 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
2632 if (FieldArray.empty()) 2647 if (FieldArray.empty())
2633 return FALSE; 2648 return FALSE;
2634 2649
2635 CPDF_FormField* pFormField = FieldArray[0]; 2650 CPDF_FormField* pFormField = FieldArray[0];
2636 vp << (CFX_WideString)pFormField->GetAlternateName(); 2651 vp << (CFX_WideString)pFormField->GetAlternateName();
2637 } 2652 }
2638 2653
2639 return TRUE; 2654 return TRUE;
2640 } 2655 }
2641 2656
2642 void Field::SetUserName(CPDFSDK_Document* pDocument, 2657 void Field::SetUserName(CPDFSDK_FormFillEnvironment* pFormFillEnv,
2643 const CFX_WideString& swFieldName, 2658 const CFX_WideString& swFieldName,
2644 int nControlIndex, 2659 int nControlIndex,
2645 const CFX_WideString& string) { 2660 const CFX_WideString& string) {
2646 // Not supported. 2661 // Not supported.
2647 } 2662 }
2648 2663
2649 FX_BOOL Field::value(IJS_Context* cc, 2664 FX_BOOL Field::value(IJS_Context* cc,
2650 CJS_PropValue& vp, 2665 CJS_PropValue& vp,
2651 CFX_WideString& sError) { 2666 CFX_WideString& sError) {
2652 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); 2667 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
(...skipping 13 matching lines...) Expand all
2666 } 2681 }
2667 } else { 2682 } else {
2668 CFX_WideString swValue; 2683 CFX_WideString swValue;
2669 vp >> swValue; 2684 vp >> swValue;
2670 strArray.push_back(swValue); 2685 strArray.push_back(swValue);
2671 } 2686 }
2672 2687
2673 if (m_bDelay) { 2688 if (m_bDelay) {
2674 AddDelay_WideStringArray(FP_VALUE, strArray); 2689 AddDelay_WideStringArray(FP_VALUE, strArray);
2675 } else { 2690 } else {
2676 Field::SetValue(m_pDocument.Get(), m_FieldName, m_nFormControlIndex, 2691 Field::SetValue(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
2677 strArray); 2692 strArray);
2678 } 2693 }
2679 } else { 2694 } else {
2680 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 2695 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
2681 if (FieldArray.empty()) 2696 if (FieldArray.empty())
2682 return FALSE; 2697 return FALSE;
2683 2698
2684 CPDF_FormField* pFormField = FieldArray[0]; 2699 CPDF_FormField* pFormField = FieldArray[0];
2685 switch (pFormField->GetFieldType()) { 2700 switch (pFormField->GetFieldType()) {
2686 case FIELDTYPE_PUSHBUTTON: 2701 case FIELDTYPE_PUSHBUTTON:
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2725 } break; 2740 } break;
2726 default: 2741 default:
2727 vp << pFormField->GetValue(); 2742 vp << pFormField->GetValue();
2728 break; 2743 break;
2729 } 2744 }
2730 } 2745 }
2731 vp.GetJSValue()->MaybeCoerceToNumber(pRuntime); 2746 vp.GetJSValue()->MaybeCoerceToNumber(pRuntime);
2732 return TRUE; 2747 return TRUE;
2733 } 2748 }
2734 2749
2735 void Field::SetValue(CPDFSDK_Document* pDocument, 2750 void Field::SetValue(CPDFSDK_FormFillEnvironment* pFormFillEnv,
2736 const CFX_WideString& swFieldName, 2751 const CFX_WideString& swFieldName,
2737 int nControlIndex, 2752 int nControlIndex,
2738 const std::vector<CFX_WideString>& strArray) { 2753 const std::vector<CFX_WideString>& strArray) {
2739 ASSERT(pDocument); 2754 ASSERT(pFormFillEnv);
2740 if (strArray.empty()) 2755 if (strArray.empty())
2741 return; 2756 return;
2742 2757
2743 std::vector<CPDF_FormField*> FieldArray = 2758 std::vector<CPDF_FormField*> FieldArray =
2744 GetFormFields(pDocument, swFieldName); 2759 GetFormFields(pFormFillEnv, swFieldName);
2745 2760
2746 for (CPDF_FormField* pFormField : FieldArray) { 2761 for (CPDF_FormField* pFormField : FieldArray) {
2747 if (pFormField->GetFullName().Compare(swFieldName) != 0) 2762 if (pFormField->GetFullName().Compare(swFieldName) != 0)
2748 continue; 2763 continue;
2749 2764
2750 switch (pFormField->GetFieldType()) { 2765 switch (pFormField->GetFieldType()) {
2751 case FIELDTYPE_TEXTFIELD: 2766 case FIELDTYPE_TEXTFIELD:
2752 case FIELDTYPE_COMBOBOX: 2767 case FIELDTYPE_COMBOBOX:
2753 if (pFormField->GetValue() != strArray[0]) { 2768 if (pFormField->GetValue() != strArray[0]) {
2754 pFormField->SetValue(strArray[0], TRUE); 2769 pFormField->SetValue(strArray[0], TRUE);
2755 UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE); 2770 UpdateFormField(pFormFillEnv, pFormField, TRUE, FALSE, TRUE);
2756 } 2771 }
2757 break; 2772 break;
2758 case FIELDTYPE_CHECKBOX: 2773 case FIELDTYPE_CHECKBOX:
2759 case FIELDTYPE_RADIOBUTTON: { 2774 case FIELDTYPE_RADIOBUTTON: {
2760 if (pFormField->GetValue() != strArray[0]) { 2775 if (pFormField->GetValue() != strArray[0]) {
2761 pFormField->SetValue(strArray[0], TRUE); 2776 pFormField->SetValue(strArray[0], TRUE);
2762 UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE); 2777 UpdateFormField(pFormFillEnv, pFormField, TRUE, FALSE, TRUE);
2763 } 2778 }
2764 } break; 2779 } break;
2765 case FIELDTYPE_LISTBOX: { 2780 case FIELDTYPE_LISTBOX: {
2766 FX_BOOL bModified = FALSE; 2781 FX_BOOL bModified = FALSE;
2767 for (const auto& str : strArray) { 2782 for (const auto& str : strArray) {
2768 if (!pFormField->IsItemSelected(pFormField->FindOption(str))) { 2783 if (!pFormField->IsItemSelected(pFormField->FindOption(str))) {
2769 bModified = TRUE; 2784 bModified = TRUE;
2770 break; 2785 break;
2771 } 2786 }
2772 } 2787 }
2773 if (bModified) { 2788 if (bModified) {
2774 pFormField->ClearSelection(TRUE); 2789 pFormField->ClearSelection(TRUE);
2775 for (const auto& str : strArray) { 2790 for (const auto& str : strArray) {
2776 int index = pFormField->FindOption(str); 2791 int index = pFormField->FindOption(str);
2777 if (!pFormField->IsItemSelected(index)) 2792 if (!pFormField->IsItemSelected(index))
2778 pFormField->SetItemSelection(index, TRUE, TRUE); 2793 pFormField->SetItemSelection(index, TRUE, TRUE);
2779 } 2794 }
2780 UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE); 2795 UpdateFormField(pFormFillEnv, pFormField, TRUE, FALSE, TRUE);
2781 } 2796 }
2782 } break; 2797 } break;
2783 default: 2798 default:
2784 break; 2799 break;
2785 } 2800 }
2786 } 2801 }
2787 } 2802 }
2788 2803
2789 FX_BOOL Field::valueAsString(IJS_Context* cc, 2804 FX_BOOL Field::valueAsString(IJS_Context* cc,
2790 CJS_PropValue& vp, 2805 CJS_PropValue& vp,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2830 2845
2831 FX_BOOL Field::browseForFileToSubmit(IJS_Context* cc, 2846 FX_BOOL Field::browseForFileToSubmit(IJS_Context* cc,
2832 const std::vector<CJS_Value>& params, 2847 const std::vector<CJS_Value>& params,
2833 CJS_Value& vRet, 2848 CJS_Value& vRet,
2834 CFX_WideString& sError) { 2849 CFX_WideString& sError) {
2835 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 2850 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
2836 if (FieldArray.empty()) 2851 if (FieldArray.empty())
2837 return FALSE; 2852 return FALSE;
2838 2853
2839 CPDF_FormField* pFormField = FieldArray[0]; 2854 CPDF_FormField* pFormField = FieldArray[0];
2840 CPDFSDK_FormFillEnvironment* pApp = m_pDocument->GetEnv();
2841 if ((pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT) && 2855 if ((pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT) &&
2842 (pFormField->GetFieldType() == FIELDTYPE_TEXTFIELD)) { 2856 (pFormField->GetFieldType() == FIELDTYPE_TEXTFIELD)) {
2843 CFX_WideString wsFileName = pApp->JS_fieldBrowse(); 2857 CFX_WideString wsFileName = m_pFormFillEnv->JS_fieldBrowse();
2844 if (!wsFileName.IsEmpty()) { 2858 if (!wsFileName.IsEmpty()) {
2845 pFormField->SetValue(wsFileName); 2859 pFormField->SetValue(wsFileName);
2846 UpdateFormField(m_pDocument.Get(), pFormField, TRUE, TRUE, TRUE); 2860 UpdateFormField(m_pFormFillEnv.Get(), pFormField, TRUE, TRUE, TRUE);
2847 } 2861 }
2848 return TRUE; 2862 return TRUE;
2849 } 2863 }
2850 return FALSE; 2864 return FALSE;
2851 } 2865 }
2852 2866
2853 FX_BOOL Field::buttonGetCaption(IJS_Context* cc, 2867 FX_BOOL Field::buttonGetCaption(IJS_Context* cc,
2854 const std::vector<CJS_Value>& params, 2868 const std::vector<CJS_Value>& params,
2855 CJS_Value& vRet, 2869 CJS_Value& vRet,
2856 CFX_WideString& sError) { 2870 CFX_WideString& sError) {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
2980 return FALSE; 2994 return FALSE;
2981 if (nWidget < 0 || nWidget >= pFormField->CountControls()) 2995 if (nWidget < 0 || nWidget >= pFormField->CountControls())
2982 return FALSE; 2996 return FALSE;
2983 // TODO(weili): Check whether anything special needed for radio button, 2997 // TODO(weili): Check whether anything special needed for radio button,
2984 // otherwise merge these branches. 2998 // otherwise merge these branches.
2985 if (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON) 2999 if (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON)
2986 pFormField->CheckControl(nWidget, bCheckit, true); 3000 pFormField->CheckControl(nWidget, bCheckit, true);
2987 else 3001 else
2988 pFormField->CheckControl(nWidget, bCheckit, true); 3002 pFormField->CheckControl(nWidget, bCheckit, true);
2989 3003
2990 UpdateFormField(m_pDocument.Get(), pFormField, TRUE, TRUE, TRUE); 3004 UpdateFormField(m_pFormFillEnv.Get(), pFormField, TRUE, TRUE, TRUE);
2991 return TRUE; 3005 return TRUE;
2992 } 3006 }
2993 3007
2994 FX_BOOL Field::clearItems(IJS_Context* cc, 3008 FX_BOOL Field::clearItems(IJS_Context* cc,
2995 const std::vector<CJS_Value>& params, 3009 const std::vector<CJS_Value>& params,
2996 CJS_Value& vRet, 3010 CJS_Value& vRet,
2997 CFX_WideString& sError) { 3011 CFX_WideString& sError) {
2998 return TRUE; 3012 return TRUE;
2999 } 3013 }
3000 3014
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
3192 CFX_WideString& sError) { 3206 CFX_WideString& sError) {
3193 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 3207 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
3194 if (FieldArray.empty()) 3208 if (FieldArray.empty())
3195 return FALSE; 3209 return FALSE;
3196 3210
3197 CPDF_FormField* pFormField = FieldArray[0]; 3211 CPDF_FormField* pFormField = FieldArray[0];
3198 int32_t nCount = pFormField->CountControls(); 3212 int32_t nCount = pFormField->CountControls();
3199 if (nCount < 1) 3213 if (nCount < 1)
3200 return FALSE; 3214 return FALSE;
3201 3215
3202 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); 3216 CPDFSDK_InterForm* pInterForm =
3217 m_pFormFillEnv->GetSDKDocument()->GetInterForm();
3203 CPDFSDK_Widget* pWidget = nullptr; 3218 CPDFSDK_Widget* pWidget = nullptr;
3204 if (nCount == 1) { 3219 if (nCount == 1) {
3205 pWidget = pInterForm->GetWidget(pFormField->GetControl(0), false); 3220 pWidget = pInterForm->GetWidget(pFormField->GetControl(0), false);
3206 } else { 3221 } else {
3207 CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetEnv(); 3222 UnderlyingPageType* pPage =
3208 UnderlyingPageType* pPage = UnderlyingFromFPDFPage( 3223 UnderlyingFromFPDFPage(m_pFormFillEnv->GetCurrentPage(
3209 pEnv->GetCurrentPage(m_pDocument->GetUnderlyingDocument())); 3224 m_pFormFillEnv->GetUnderlyingDocument()));
3210 if (!pPage) 3225 if (!pPage)
3211 return FALSE; 3226 return FALSE;
3212 if (CPDFSDK_PageView* pCurPageView = 3227 if (CPDFSDK_PageView* pCurPageView =
3213 m_pDocument->GetPageView(pPage, true)) { 3228 m_pFormFillEnv->GetSDKDocument()->GetPageView(pPage, true)) {
3214 for (int32_t i = 0; i < nCount; i++) { 3229 for (int32_t i = 0; i < nCount; i++) {
3215 if (CPDFSDK_Widget* pTempWidget = 3230 if (CPDFSDK_Widget* pTempWidget =
3216 pInterForm->GetWidget(pFormField->GetControl(i), false)) { 3231 pInterForm->GetWidget(pFormField->GetControl(i), false)) {
3217 if (pTempWidget->GetPDFPage() == pCurPageView->GetPDFPage()) { 3232 if (pTempWidget->GetPDFPage() == pCurPageView->GetPDFPage()) {
3218 pWidget = pTempWidget; 3233 pWidget = pTempWidget;
3219 break; 3234 break;
3220 } 3235 }
3221 } 3236 }
3222 } 3237 }
3223 } 3238 }
3224 } 3239 }
3225 3240
3226 if (pWidget) { 3241 if (pWidget) {
3227 CPDFSDK_Annot::ObservedPtr pObserved(pWidget); 3242 CPDFSDK_Annot::ObservedPtr pObserved(pWidget);
3228 m_pDocument->SetFocusAnnot(&pObserved); 3243 m_pFormFillEnv->GetSDKDocument()->SetFocusAnnot(&pObserved);
3229 } 3244 }
3230 3245
3231 return TRUE; 3246 return TRUE;
3232 } 3247 }
3233 3248
3234 FX_BOOL Field::setItems(IJS_Context* cc, 3249 FX_BOOL Field::setItems(IJS_Context* cc,
3235 const std::vector<CJS_Value>& params, 3250 const std::vector<CJS_Value>& params,
3236 CJS_Value& vRet, 3251 CJS_Value& vRet,
3237 CFX_WideString& sError) { 3252 CFX_WideString& sError) {
3238 return TRUE; 3253 return TRUE;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
3348 } 3363 }
3349 3364
3350 void Field::AddDelay_WideStringArray(FIELD_PROP prop, 3365 void Field::AddDelay_WideStringArray(FIELD_PROP prop,
3351 const std::vector<CFX_WideString>& array) { 3366 const std::vector<CFX_WideString>& array) {
3352 CJS_DelayData* pNewData = 3367 CJS_DelayData* pNewData =
3353 new CJS_DelayData(prop, m_nFormControlIndex, m_FieldName); 3368 new CJS_DelayData(prop, m_nFormControlIndex, m_FieldName);
3354 pNewData->widestringarray = array; 3369 pNewData->widestringarray = array;
3355 m_pJSDoc->AddDelayData(pNewData); 3370 m_pJSDoc->AddDelayData(pNewData);
3356 } 3371 }
3357 3372
3358 void Field::DoDelay(CPDFSDK_Document* pDocument, CJS_DelayData* pData) { 3373 void Field::DoDelay(CPDFSDK_FormFillEnvironment* pFormFillEnv,
3359 ASSERT(pDocument); 3374 CJS_DelayData* pData) {
3375 ASSERT(pFormFillEnv);
3360 switch (pData->eProp) { 3376 switch (pData->eProp) {
3361 case FP_ALIGNMENT: 3377 case FP_ALIGNMENT:
3362 Field::SetAlignment(pDocument, pData->sFieldName, pData->nControlIndex, 3378 Field::SetAlignment(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
3363 pData->string); 3379 pData->string);
3364 break; 3380 break;
3365 case FP_BORDERSTYLE: 3381 case FP_BORDERSTYLE:
3366 Field::SetBorderStyle(pDocument, pData->sFieldName, pData->nControlIndex, 3382 Field::SetBorderStyle(pFormFillEnv, pData->sFieldName,
3367 pData->string); 3383 pData->nControlIndex, pData->string);
3368 break; 3384 break;
3369 case FP_BUTTONALIGNX: 3385 case FP_BUTTONALIGNX:
3370 Field::SetButtonAlignX(pDocument, pData->sFieldName, pData->nControlIndex, 3386 Field::SetButtonAlignX(pFormFillEnv, pData->sFieldName,
3371 pData->num); 3387 pData->nControlIndex, pData->num);
3372 break; 3388 break;
3373 case FP_BUTTONALIGNY: 3389 case FP_BUTTONALIGNY:
3374 Field::SetButtonAlignY(pDocument, pData->sFieldName, pData->nControlIndex, 3390 Field::SetButtonAlignY(pFormFillEnv, pData->sFieldName,
3375 pData->num); 3391 pData->nControlIndex, pData->num);
3376 break; 3392 break;
3377 case FP_BUTTONFITBOUNDS: 3393 case FP_BUTTONFITBOUNDS:
3378 Field::SetButtonFitBounds(pDocument, pData->sFieldName, 3394 Field::SetButtonFitBounds(pFormFillEnv, pData->sFieldName,
3379 pData->nControlIndex, pData->b); 3395 pData->nControlIndex, pData->b);
3380 break; 3396 break;
3381 case FP_BUTTONPOSITION: 3397 case FP_BUTTONPOSITION:
3382 Field::SetButtonPosition(pDocument, pData->sFieldName, 3398 Field::SetButtonPosition(pFormFillEnv, pData->sFieldName,
3383 pData->nControlIndex, pData->num); 3399 pData->nControlIndex, pData->num);
3384 break; 3400 break;
3385 case FP_BUTTONSCALEHOW: 3401 case FP_BUTTONSCALEHOW:
3386 Field::SetButtonScaleHow(pDocument, pData->sFieldName, 3402 Field::SetButtonScaleHow(pFormFillEnv, pData->sFieldName,
3387 pData->nControlIndex, pData->num); 3403 pData->nControlIndex, pData->num);
3388 break; 3404 break;
3389 case FP_BUTTONSCALEWHEN: 3405 case FP_BUTTONSCALEWHEN:
3390 Field::SetButtonScaleWhen(pDocument, pData->sFieldName, 3406 Field::SetButtonScaleWhen(pFormFillEnv, pData->sFieldName,
3391 pData->nControlIndex, pData->num); 3407 pData->nControlIndex, pData->num);
3392 break; 3408 break;
3393 case FP_CALCORDERINDEX: 3409 case FP_CALCORDERINDEX:
3394 Field::SetCalcOrderIndex(pDocument, pData->sFieldName, 3410 Field::SetCalcOrderIndex(pFormFillEnv, pData->sFieldName,
3395 pData->nControlIndex, pData->num); 3411 pData->nControlIndex, pData->num);
3396 break; 3412 break;
3397 case FP_CHARLIMIT: 3413 case FP_CHARLIMIT:
3398 Field::SetCharLimit(pDocument, pData->sFieldName, pData->nControlIndex, 3414 Field::SetCharLimit(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
3399 pData->num); 3415 pData->num);
3400 break; 3416 break;
3401 case FP_COMB: 3417 case FP_COMB:
3402 Field::SetComb(pDocument, pData->sFieldName, pData->nControlIndex, 3418 Field::SetComb(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
3403 pData->b); 3419 pData->b);
3404 break; 3420 break;
3405 case FP_COMMITONSELCHANGE: 3421 case FP_COMMITONSELCHANGE:
3406 Field::SetCommitOnSelChange(pDocument, pData->sFieldName, 3422 Field::SetCommitOnSelChange(pFormFillEnv, pData->sFieldName,
3407 pData->nControlIndex, pData->b); 3423 pData->nControlIndex, pData->b);
3408 break; 3424 break;
3409 case FP_CURRENTVALUEINDICES: 3425 case FP_CURRENTVALUEINDICES:
3410 Field::SetCurrentValueIndices(pDocument, pData->sFieldName, 3426 Field::SetCurrentValueIndices(pFormFillEnv, pData->sFieldName,
3411 pData->nControlIndex, pData->wordarray); 3427 pData->nControlIndex, pData->wordarray);
3412 break; 3428 break;
3413 case FP_DEFAULTVALUE: 3429 case FP_DEFAULTVALUE:
3414 Field::SetDefaultValue(pDocument, pData->sFieldName, pData->nControlIndex, 3430 Field::SetDefaultValue(pFormFillEnv, pData->sFieldName,
3415 pData->widestring); 3431 pData->nControlIndex, pData->widestring);
3416 break; 3432 break;
3417 case FP_DONOTSCROLL: 3433 case FP_DONOTSCROLL:
3418 Field::SetDoNotScroll(pDocument, pData->sFieldName, pData->nControlIndex, 3434 Field::SetDoNotScroll(pFormFillEnv, pData->sFieldName,
3419 pData->b); 3435 pData->nControlIndex, pData->b);
3420 break; 3436 break;
3421 case FP_DISPLAY: 3437 case FP_DISPLAY:
3422 Field::SetDisplay(pDocument, pData->sFieldName, pData->nControlIndex, 3438 Field::SetDisplay(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
3423 pData->num); 3439 pData->num);
3424 break; 3440 break;
3425 case FP_FILLCOLOR: 3441 case FP_FILLCOLOR:
3426 Field::SetFillColor(pDocument, pData->sFieldName, pData->nControlIndex, 3442 Field::SetFillColor(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
3427 pData->color); 3443 pData->color);
3428 break; 3444 break;
3429 case FP_HIDDEN: 3445 case FP_HIDDEN:
3430 Field::SetHidden(pDocument, pData->sFieldName, pData->nControlIndex, 3446 Field::SetHidden(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
3431 pData->b); 3447 pData->b);
3432 break; 3448 break;
3433 case FP_HIGHLIGHT: 3449 case FP_HIGHLIGHT:
3434 Field::SetHighlight(pDocument, pData->sFieldName, pData->nControlIndex, 3450 Field::SetHighlight(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
3435 pData->string); 3451 pData->string);
3436 break; 3452 break;
3437 case FP_LINEWIDTH: 3453 case FP_LINEWIDTH:
3438 Field::SetLineWidth(pDocument, pData->sFieldName, pData->nControlIndex, 3454 Field::SetLineWidth(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
3439 pData->num); 3455 pData->num);
3440 break; 3456 break;
3441 case FP_MULTILINE: 3457 case FP_MULTILINE:
3442 Field::SetMultiline(pDocument, pData->sFieldName, pData->nControlIndex, 3458 Field::SetMultiline(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
3443 pData->b); 3459 pData->b);
3444 break; 3460 break;
3445 case FP_MULTIPLESELECTION: 3461 case FP_MULTIPLESELECTION:
3446 Field::SetMultipleSelection(pDocument, pData->sFieldName, 3462 Field::SetMultipleSelection(pFormFillEnv, pData->sFieldName,
3447 pData->nControlIndex, pData->b); 3463 pData->nControlIndex, pData->b);
3448 break; 3464 break;
3449 case FP_PASSWORD: 3465 case FP_PASSWORD:
3450 Field::SetPassword(pDocument, pData->sFieldName, pData->nControlIndex, 3466 Field::SetPassword(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
3451 pData->b); 3467 pData->b);
3452 break; 3468 break;
3453 case FP_RECT: 3469 case FP_RECT:
3454 Field::SetRect(pDocument, pData->sFieldName, pData->nControlIndex, 3470 Field::SetRect(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
3455 pData->rect); 3471 pData->rect);
3456 break; 3472 break;
3457 case FP_RICHTEXT: 3473 case FP_RICHTEXT:
3458 // Not supported. 3474 // Not supported.
3459 break; 3475 break;
3460 case FP_RICHVALUE: 3476 case FP_RICHVALUE:
3461 break; 3477 break;
3462 case FP_ROTATION: 3478 case FP_ROTATION:
3463 Field::SetRotation(pDocument, pData->sFieldName, pData->nControlIndex, 3479 Field::SetRotation(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
3464 pData->num); 3480 pData->num);
3465 break; 3481 break;
3466 case FP_STROKECOLOR: 3482 case FP_STROKECOLOR:
3467 Field::SetStrokeColor(pDocument, pData->sFieldName, pData->nControlIndex, 3483 Field::SetStrokeColor(pFormFillEnv, pData->sFieldName,
3468 pData->color); 3484 pData->nControlIndex, pData->color);
3469 break; 3485 break;
3470 case FP_STYLE: 3486 case FP_STYLE:
3471 Field::SetStyle(pDocument, pData->sFieldName, pData->nControlIndex, 3487 Field::SetStyle(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
3472 pData->string); 3488 pData->string);
3473 break; 3489 break;
3474 case FP_TEXTCOLOR: 3490 case FP_TEXTCOLOR:
3475 Field::SetTextColor(pDocument, pData->sFieldName, pData->nControlIndex, 3491 Field::SetTextColor(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
3476 pData->color); 3492 pData->color);
3477 break; 3493 break;
3478 case FP_TEXTFONT: 3494 case FP_TEXTFONT:
3479 Field::SetTextFont(pDocument, pData->sFieldName, pData->nControlIndex, 3495 Field::SetTextFont(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
3480 pData->string); 3496 pData->string);
3481 break; 3497 break;
3482 case FP_TEXTSIZE: 3498 case FP_TEXTSIZE:
3483 Field::SetTextSize(pDocument, pData->sFieldName, pData->nControlIndex, 3499 Field::SetTextSize(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
3484 pData->num); 3500 pData->num);
3485 break; 3501 break;
3486 case FP_USERNAME: 3502 case FP_USERNAME:
3487 Field::SetUserName(pDocument, pData->sFieldName, pData->nControlIndex, 3503 Field::SetUserName(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
3488 pData->widestring); 3504 pData->widestring);
3489 break; 3505 break;
3490 case FP_VALUE: 3506 case FP_VALUE:
3491 Field::SetValue(pDocument, pData->sFieldName, pData->nControlIndex, 3507 Field::SetValue(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
3492 pData->widestringarray); 3508 pData->widestringarray);
3493 break; 3509 break;
3494 } 3510 }
3495 } 3511 }
3496 3512
3497 void Field::AddField(CPDFSDK_Document* pDocument, 3513 void Field::AddField(CPDFSDK_FormFillEnvironment* pFormFillEnv,
3498 int nPageIndex, 3514 int nPageIndex,
3499 int nFieldType, 3515 int nFieldType,
3500 const CFX_WideString& sName, 3516 const CFX_WideString& sName,
3501 const CFX_FloatRect& rcCoords) { 3517 const CFX_FloatRect& rcCoords) {
3502 // Not supported. 3518 // Not supported.
3503 } 3519 }
OLDNEW
« fpdfsdk/javascript/Field.h ('K') | « fpdfsdk/javascript/Field.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698