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

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

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

Powered by Google App Engine
This is Rietveld 408576698