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

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

Issue 2453683011: Remove FX_BOOL from fpdfsdk. (Closed)
Patch Set: Regenerate patch after rebase. Created 4 years, 1 month 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') | fpdfsdk/javascript/Icon.h » ('j') | 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 CJS_DelayData::~CJS_DelayData() {} 169 CJS_DelayData::~CJS_DelayData() {}
170 170
171 void CJS_Field::InitInstance(IJS_Runtime* pIRuntime) { 171 void CJS_Field::InitInstance(IJS_Runtime* pIRuntime) {
172 } 172 }
173 173
174 Field::Field(CJS_Object* pJSObject) 174 Field::Field(CJS_Object* pJSObject)
175 : CJS_EmbedObj(pJSObject), 175 : CJS_EmbedObj(pJSObject),
176 m_pJSDoc(nullptr), 176 m_pJSDoc(nullptr),
177 m_pFormFillEnv(nullptr), 177 m_pFormFillEnv(nullptr),
178 m_nFormControlIndex(-1), 178 m_nFormControlIndex(-1),
179 m_bCanSet(FALSE), 179 m_bCanSet(false),
180 m_bDelay(FALSE) {} 180 m_bDelay(false) {}
181 181
182 Field::~Field() {} 182 Field::~Field() {}
183 183
184 // note: iControlNo = -1, means not a widget. 184 // note: iControlNo = -1, means not a widget.
185 void Field::ParseFieldName(const std::wstring& strFieldNameParsed, 185 void Field::ParseFieldName(const std::wstring& strFieldNameParsed,
186 std::wstring& strFieldName, 186 std::wstring& strFieldName,
187 int& iControlNo) { 187 int& iControlNo) {
188 int iStart = strFieldNameParsed.find_last_of(L'.'); 188 int iStart = strFieldNameParsed.find_last_of(L'.');
189 if (iStart == -1) { 189 if (iStart == -1) {
190 strFieldName = strFieldNameParsed; 190 strFieldName = strFieldNameParsed;
(...skipping 10 matching lines...) Expand all
201 201
202 if (suffixal.compare(L"0") != 0) { 202 if (suffixal.compare(L"0") != 0) {
203 strFieldName = strFieldNameParsed; 203 strFieldName = strFieldNameParsed;
204 iControlNo = -1; 204 iControlNo = -1;
205 return; 205 return;
206 } 206 }
207 } 207 }
208 strFieldName = strFieldNameParsed.substr(0, iStart); 208 strFieldName = strFieldNameParsed.substr(0, iStart);
209 } 209 }
210 210
211 FX_BOOL Field::AttachField(Document* pDocument, 211 bool Field::AttachField(Document* pDocument,
212 const CFX_WideString& csFieldName) { 212 const CFX_WideString& csFieldName) {
213 m_pJSDoc = pDocument; 213 m_pJSDoc = pDocument;
214 m_pFormFillEnv.Reset(pDocument->GetFormFillEnv()); 214 m_pFormFillEnv.Reset(pDocument->GetFormFillEnv());
215 m_bCanSet = m_pFormFillEnv->GetPermissions(FPDFPERM_FILL_FORM) || 215 m_bCanSet = m_pFormFillEnv->GetPermissions(FPDFPERM_FILL_FORM) ||
216 m_pFormFillEnv->GetPermissions(FPDFPERM_ANNOT_FORM) || 216 m_pFormFillEnv->GetPermissions(FPDFPERM_ANNOT_FORM) ||
217 m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY); 217 m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY);
218 218
219 CPDFSDK_InterForm* pRDInterForm = m_pFormFillEnv->GetInterForm(); 219 CPDFSDK_InterForm* pRDInterForm = m_pFormFillEnv->GetInterForm();
220 CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm(); 220 CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm();
221 CFX_WideString swFieldNameTemp = csFieldName; 221 CFX_WideString swFieldNameTemp = csFieldName;
222 swFieldNameTemp.Replace(L"..", L"."); 222 swFieldNameTemp.Replace(L"..", L".");
223 223
224 if (pInterForm->CountFields(swFieldNameTemp) <= 0) { 224 if (pInterForm->CountFields(swFieldNameTemp) <= 0) {
225 std::wstring strFieldName; 225 std::wstring strFieldName;
226 int iControlNo = -1; 226 int iControlNo = -1;
227 ParseFieldName(swFieldNameTemp.c_str(), strFieldName, iControlNo); 227 ParseFieldName(swFieldNameTemp.c_str(), strFieldName, iControlNo);
228 if (iControlNo == -1) 228 if (iControlNo == -1)
229 return FALSE; 229 return false;
230 230
231 m_FieldName = strFieldName.c_str(); 231 m_FieldName = strFieldName.c_str();
232 m_nFormControlIndex = iControlNo; 232 m_nFormControlIndex = iControlNo;
233 return TRUE; 233 return true;
234 } 234 }
235 235
236 m_FieldName = swFieldNameTemp; 236 m_FieldName = swFieldNameTemp;
237 m_nFormControlIndex = -1; 237 m_nFormControlIndex = -1;
238 238
239 return TRUE; 239 return true;
240 } 240 }
241 241
242 std::vector<CPDF_FormField*> Field::GetFormFields( 242 std::vector<CPDF_FormField*> Field::GetFormFields(
243 CPDFSDK_FormFillEnvironment* pFormFillEnv, 243 CPDFSDK_FormFillEnvironment* pFormFillEnv,
244 const CFX_WideString& csFieldName) { 244 const CFX_WideString& csFieldName) {
245 std::vector<CPDF_FormField*> fields; 245 std::vector<CPDF_FormField*> fields;
246 CPDFSDK_InterForm* pReaderInterForm = pFormFillEnv->GetInterForm(); 246 CPDFSDK_InterForm* pReaderInterForm = pFormFillEnv->GetInterForm();
247 CPDF_InterForm* pInterForm = pReaderInterForm->GetInterForm(); 247 CPDF_InterForm* pInterForm = pReaderInterForm->GetInterForm();
248 for (int i = 0, sz = pInterForm->CountFields(csFieldName); i < sz; ++i) { 248 for (int i = 0, sz = pInterForm->CountFields(csFieldName); i < sz; ++i) {
249 if (CPDF_FormField* pFormField = pInterForm->GetField(i, csFieldName)) 249 if (CPDF_FormField* pFormField = pInterForm->GetField(i, csFieldName))
250 fields.push_back(pFormField); 250 fields.push_back(pFormField);
251 } 251 }
252 return fields; 252 return fields;
253 } 253 }
254 254
255 std::vector<CPDF_FormField*> Field::GetFormFields( 255 std::vector<CPDF_FormField*> Field::GetFormFields(
256 const CFX_WideString& csFieldName) const { 256 const CFX_WideString& csFieldName) const {
257 return Field::GetFormFields(m_pFormFillEnv.Get(), csFieldName); 257 return Field::GetFormFields(m_pFormFillEnv.Get(), csFieldName);
258 } 258 }
259 259
260 void Field::UpdateFormField(CPDFSDK_FormFillEnvironment* pFormFillEnv, 260 void Field::UpdateFormField(CPDFSDK_FormFillEnvironment* pFormFillEnv,
261 CPDF_FormField* pFormField, 261 CPDF_FormField* pFormField,
262 FX_BOOL bChangeMark, 262 bool bChangeMark,
263 FX_BOOL bResetAP, 263 bool bResetAP,
264 FX_BOOL bRefresh) { 264 bool bRefresh) {
265 CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm(); 265 CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm();
266 266
267 if (bResetAP) { 267 if (bResetAP) {
268 std::vector<CPDFSDK_Widget*> widgets; 268 std::vector<CPDFSDK_Widget*> widgets;
269 pInterForm->GetWidgets(pFormField, &widgets); 269 pInterForm->GetWidgets(pFormField, &widgets);
270 270
271 int nFieldType = pFormField->GetFieldType(); 271 int nFieldType = pFormField->GetFieldType();
272 if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_TEXTFIELD) { 272 if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_TEXTFIELD) {
273 for (CPDFSDK_Annot* pAnnot : widgets) { 273 for (CPDFSDK_Annot* pAnnot : widgets) {
274 FX_BOOL bFormatted = FALSE; 274 bool bFormatted = false;
275 CPDFSDK_Annot::ObservedPtr pObserved(pAnnot); 275 CPDFSDK_Annot::ObservedPtr pObserved(pAnnot);
276 CFX_WideString sValue = 276 CFX_WideString sValue =
277 static_cast<CPDFSDK_Widget*>(pObserved.Get())->OnFormat(bFormatted); 277 static_cast<CPDFSDK_Widget*>(pObserved.Get())->OnFormat(bFormatted);
278 if (pObserved) { 278 if (pObserved) {
279 static_cast<CPDFSDK_Widget*>(pObserved.Get()) 279 static_cast<CPDFSDK_Widget*>(pObserved.Get())
280 ->ResetAppearance(bFormatted ? &sValue : nullptr, FALSE); 280 ->ResetAppearance(bFormatted ? &sValue : nullptr, false);
281 } 281 }
282 } 282 }
283 } else { 283 } else {
284 for (CPDFSDK_Widget* pWidget : widgets) { 284 for (CPDFSDK_Widget* pWidget : widgets) {
285 pWidget->ResetAppearance(nullptr, FALSE); 285 pWidget->ResetAppearance(nullptr, false);
286 } 286 }
287 } 287 }
288 } 288 }
289 289
290 if (bRefresh) { 290 if (bRefresh) {
291 // Refresh the widget list. The calls in |bResetAP| may have caused widgets 291 // Refresh the widget list. The calls in |bResetAP| may have caused widgets
292 // to be removed from the list. We need to call |GetWidgets| again to be 292 // to be removed from the list. We need to call |GetWidgets| again to be
293 // sure none of the widgets have been deleted. 293 // sure none of the widgets have been deleted.
294 std::vector<CPDFSDK_Widget*> widgets; 294 std::vector<CPDFSDK_Widget*> widgets;
295 pInterForm->GetWidgets(pFormField, &widgets); 295 pInterForm->GetWidgets(pFormField, &widgets);
296 296
297 // TODO(dsinclair): Determine if all widgets share the same 297 // TODO(dsinclair): Determine if all widgets share the same
298 // CPDFSDK_InterForm. If that's the case, we can move the code to 298 // CPDFSDK_InterForm. If that's the case, we can move the code to
299 // |GetFormFillEnv| out of the loop. 299 // |GetFormFillEnv| out of the loop.
300 for (CPDFSDK_Widget* pWidget : widgets) { 300 for (CPDFSDK_Widget* pWidget : widgets) {
301 pWidget->GetInterForm() 301 pWidget->GetInterForm()
302 ->GetFormFillEnv() 302 ->GetFormFillEnv()
303 ->UpdateAllViews(nullptr, pWidget); 303 ->UpdateAllViews(nullptr, pWidget);
304 } 304 }
305 } 305 }
306 306
307 if (bChangeMark) 307 if (bChangeMark)
308 pFormFillEnv->SetChangeMark(); 308 pFormFillEnv->SetChangeMark();
309 } 309 }
310 310
311 void Field::UpdateFormControl(CPDFSDK_FormFillEnvironment* pFormFillEnv, 311 void Field::UpdateFormControl(CPDFSDK_FormFillEnvironment* pFormFillEnv,
312 CPDF_FormControl* pFormControl, 312 CPDF_FormControl* pFormControl,
313 FX_BOOL bChangeMark, 313 bool bChangeMark,
314 FX_BOOL bResetAP, 314 bool bResetAP,
315 FX_BOOL bRefresh) { 315 bool bRefresh) {
316 ASSERT(pFormControl); 316 ASSERT(pFormControl);
317 317
318 CPDFSDK_InterForm* pForm = pFormFillEnv->GetInterForm(); 318 CPDFSDK_InterForm* pForm = pFormFillEnv->GetInterForm();
319 CPDFSDK_Widget* pWidget = pForm->GetWidget(pFormControl, false); 319 CPDFSDK_Widget* pWidget = pForm->GetWidget(pFormControl, false);
320 320
321 if (pWidget) { 321 if (pWidget) {
322 if (bResetAP) { 322 if (bResetAP) {
323 int nFieldType = pWidget->GetFieldType(); 323 int nFieldType = pWidget->GetFieldType();
324 if (nFieldType == FIELDTYPE_COMBOBOX || 324 if (nFieldType == FIELDTYPE_COMBOBOX ||
325 nFieldType == FIELDTYPE_TEXTFIELD) { 325 nFieldType == FIELDTYPE_TEXTFIELD) {
326 FX_BOOL bFormatted = FALSE; 326 bool bFormatted = false;
327 CFX_WideString sValue = pWidget->OnFormat(bFormatted); 327 CFX_WideString sValue = pWidget->OnFormat(bFormatted);
328 pWidget->ResetAppearance(bFormatted ? &sValue : nullptr, FALSE); 328 pWidget->ResetAppearance(bFormatted ? &sValue : nullptr, false);
329 } else { 329 } else {
330 pWidget->ResetAppearance(nullptr, FALSE); 330 pWidget->ResetAppearance(nullptr, false);
331 } 331 }
332 } 332 }
333 333
334 if (bRefresh) { 334 if (bRefresh) {
335 CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm(); 335 CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm();
336 pInterForm->GetFormFillEnv()->UpdateAllViews(nullptr, pWidget); 336 pInterForm->GetFormFillEnv()->UpdateAllViews(nullptr, pWidget);
337 } 337 }
338 } 338 }
339 339
340 if (bChangeMark) 340 if (bChangeMark)
341 pFormFillEnv->SetChangeMark(); 341 pFormFillEnv->SetChangeMark();
342 } 342 }
343 343
344 CPDFSDK_Widget* Field::GetWidget(CPDFSDK_FormFillEnvironment* pFormFillEnv, 344 CPDFSDK_Widget* Field::GetWidget(CPDFSDK_FormFillEnvironment* pFormFillEnv,
345 CPDF_FormControl* pFormControl, 345 CPDF_FormControl* pFormControl,
346 bool createIfNeeded) { 346 bool createIfNeeded) {
347 CPDFSDK_InterForm* pInterForm = 347 CPDFSDK_InterForm* pInterForm =
348 static_cast<CPDFSDK_InterForm*>(pFormFillEnv->GetInterForm()); 348 static_cast<CPDFSDK_InterForm*>(pFormFillEnv->GetInterForm());
349 return pInterForm ? pInterForm->GetWidget(pFormControl, createIfNeeded) 349 return pInterForm ? pInterForm->GetWidget(pFormControl, createIfNeeded)
350 : nullptr; 350 : nullptr;
351 } 351 }
352 352
353 FX_BOOL Field::ValueIsOccur(CPDF_FormField* pFormField, 353 bool Field::ValueIsOccur(CPDF_FormField* pFormField,
354 CFX_WideString csOptLabel) { 354 CFX_WideString csOptLabel) {
355 for (int i = 0, sz = pFormField->CountOptions(); i < sz; i++) { 355 for (int i = 0, sz = pFormField->CountOptions(); i < sz; i++) {
356 if (csOptLabel.Compare(pFormField->GetOptionLabel(i)) == 0) 356 if (csOptLabel.Compare(pFormField->GetOptionLabel(i)) == 0)
357 return TRUE; 357 return true;
358 } 358 }
359 359
360 return FALSE; 360 return false;
361 } 361 }
362 362
363 CPDF_FormControl* Field::GetSmartFieldControl(CPDF_FormField* pFormField) { 363 CPDF_FormControl* Field::GetSmartFieldControl(CPDF_FormField* pFormField) {
364 if (!pFormField->CountControls() || 364 if (!pFormField->CountControls() ||
365 m_nFormControlIndex >= pFormField->CountControls()) 365 m_nFormControlIndex >= pFormField->CountControls())
366 return nullptr; 366 return nullptr;
367 367
368 if (m_nFormControlIndex < 0) 368 if (m_nFormControlIndex < 0)
369 return pFormField->GetControl(0); 369 return pFormField->GetControl(0);
370 370
371 return pFormField->GetControl(m_nFormControlIndex); 371 return pFormField->GetControl(m_nFormControlIndex);
372 } 372 }
373 373
374 FX_BOOL Field::alignment(IJS_Context* cc, 374 bool Field::alignment(IJS_Context* cc,
375 CJS_PropValue& vp, 375 CJS_PropValue& vp,
376 CFX_WideString& sError) { 376 CFX_WideString& sError) {
377 ASSERT(m_pFormFillEnv); 377 ASSERT(m_pFormFillEnv);
378 378
379 if (vp.IsSetting()) { 379 if (vp.IsSetting()) {
380 if (!m_bCanSet) 380 if (!m_bCanSet)
381 return FALSE; 381 return false;
382 382
383 CFX_ByteString alignStr; 383 CFX_ByteString alignStr;
384 vp >> alignStr; 384 vp >> alignStr;
385 385
386 if (m_bDelay) { 386 if (m_bDelay) {
387 AddDelay_String(FP_ALIGNMENT, alignStr); 387 AddDelay_String(FP_ALIGNMENT, alignStr);
388 } else { 388 } else {
389 Field::SetAlignment(m_pFormFillEnv.Get(), m_FieldName, 389 Field::SetAlignment(m_pFormFillEnv.Get(), m_FieldName,
390 m_nFormControlIndex, alignStr); 390 m_nFormControlIndex, alignStr);
391 } 391 }
392 } else { 392 } else {
393 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 393 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
394 if (FieldArray.empty()) 394 if (FieldArray.empty())
395 return FALSE; 395 return false;
396 396
397 CPDF_FormField* pFormField = FieldArray[0]; 397 CPDF_FormField* pFormField = FieldArray[0];
398 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) 398 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
399 return FALSE; 399 return false;
400 400
401 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 401 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
402 if (!pFormControl) 402 if (!pFormControl)
403 return FALSE; 403 return false;
404 404
405 switch (pFormControl->GetControlAlignment()) { 405 switch (pFormControl->GetControlAlignment()) {
406 case 1: 406 case 1:
407 vp << L"center"; 407 vp << L"center";
408 break; 408 break;
409 case 0: 409 case 0:
410 vp << L"left"; 410 vp << L"left";
411 break; 411 break;
412 case 2: 412 case 2:
413 vp << L"right"; 413 vp << L"right";
414 break; 414 break;
415 default: 415 default:
416 vp << L""; 416 vp << L"";
417 } 417 }
418 } 418 }
419 419
420 return TRUE; 420 return true;
421 } 421 }
422 422
423 void Field::SetAlignment(CPDFSDK_FormFillEnvironment* pFormFillEnv, 423 void Field::SetAlignment(CPDFSDK_FormFillEnvironment* pFormFillEnv,
424 const CFX_WideString& swFieldName, 424 const CFX_WideString& swFieldName,
425 int nControlIndex, 425 int nControlIndex,
426 const CFX_ByteString& string) { 426 const CFX_ByteString& string) {
427 // Not supported. 427 // Not supported.
428 } 428 }
429 429
430 FX_BOOL Field::borderStyle(IJS_Context* cc, 430 bool Field::borderStyle(IJS_Context* cc,
431 CJS_PropValue& vp, 431 CJS_PropValue& vp,
432 CFX_WideString& sError) { 432 CFX_WideString& sError) {
433 ASSERT(m_pFormFillEnv); 433 ASSERT(m_pFormFillEnv);
434 434
435 if (vp.IsSetting()) { 435 if (vp.IsSetting()) {
436 if (!m_bCanSet) 436 if (!m_bCanSet)
437 return FALSE; 437 return false;
438 438
439 CFX_ByteString strType = ""; 439 CFX_ByteString strType = "";
440 vp >> strType; 440 vp >> strType;
441 441
442 if (m_bDelay) { 442 if (m_bDelay) {
443 AddDelay_String(FP_BORDERSTYLE, strType); 443 AddDelay_String(FP_BORDERSTYLE, strType);
444 } else { 444 } else {
445 Field::SetBorderStyle(m_pFormFillEnv.Get(), m_FieldName, 445 Field::SetBorderStyle(m_pFormFillEnv.Get(), m_FieldName,
446 m_nFormControlIndex, strType); 446 m_nFormControlIndex, strType);
447 } 447 }
448 } else { 448 } else {
449 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 449 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
450 if (FieldArray.empty()) 450 if (FieldArray.empty())
451 return FALSE; 451 return false;
452 452
453 CPDF_FormField* pFormField = FieldArray[0]; 453 CPDF_FormField* pFormField = FieldArray[0];
454 if (!pFormField) 454 if (!pFormField)
455 return FALSE; 455 return false;
456 456
457 CPDFSDK_Widget* pWidget = GetWidget( 457 CPDFSDK_Widget* pWidget = GetWidget(
458 m_pFormFillEnv.Get(), GetSmartFieldControl(pFormField), false); 458 m_pFormFillEnv.Get(), GetSmartFieldControl(pFormField), false);
459 if (!pWidget) 459 if (!pWidget)
460 return FALSE; 460 return false;
461 461
462 switch (pWidget->GetBorderStyle()) { 462 switch (pWidget->GetBorderStyle()) {
463 case BorderStyle::SOLID: 463 case BorderStyle::SOLID:
464 vp << L"solid"; 464 vp << L"solid";
465 break; 465 break;
466 case BorderStyle::DASH: 466 case BorderStyle::DASH:
467 vp << L"dashed"; 467 vp << L"dashed";
468 break; 468 break;
469 case BorderStyle::BEVELED: 469 case BorderStyle::BEVELED:
470 vp << L"beveled"; 470 vp << L"beveled";
471 break; 471 break;
472 case BorderStyle::INSET: 472 case BorderStyle::INSET:
473 vp << L"inset"; 473 vp << L"inset";
474 break; 474 break;
475 case BorderStyle::UNDERLINE: 475 case BorderStyle::UNDERLINE:
476 vp << L"underline"; 476 vp << L"underline";
477 break; 477 break;
478 default: 478 default:
479 vp << L""; 479 vp << L"";
480 break; 480 break;
481 } 481 }
482 } 482 }
483 483
484 return TRUE; 484 return true;
485 } 485 }
486 486
487 void Field::SetBorderStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv, 487 void Field::SetBorderStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv,
488 const CFX_WideString& swFieldName, 488 const CFX_WideString& swFieldName,
489 int nControlIndex, 489 int nControlIndex,
490 const CFX_ByteString& string) { 490 const CFX_ByteString& string) {
491 ASSERT(pFormFillEnv); 491 ASSERT(pFormFillEnv);
492 492
493 BorderStyle nBorderStyle = BorderStyle::SOLID; 493 BorderStyle nBorderStyle = BorderStyle::SOLID;
494 if (string == "solid") 494 if (string == "solid")
495 nBorderStyle = BorderStyle::SOLID; 495 nBorderStyle = BorderStyle::SOLID;
496 else if (string == "beveled") 496 else if (string == "beveled")
497 nBorderStyle = BorderStyle::BEVELED; 497 nBorderStyle = BorderStyle::BEVELED;
498 else if (string == "dashed") 498 else if (string == "dashed")
499 nBorderStyle = BorderStyle::DASH; 499 nBorderStyle = BorderStyle::DASH;
500 else if (string == "inset") 500 else if (string == "inset")
501 nBorderStyle = BorderStyle::INSET; 501 nBorderStyle = BorderStyle::INSET;
502 else if (string == "underline") 502 else if (string == "underline")
503 nBorderStyle = BorderStyle::UNDERLINE; 503 nBorderStyle = BorderStyle::UNDERLINE;
504 else 504 else
505 return; 505 return;
506 506
507 std::vector<CPDF_FormField*> FieldArray = 507 std::vector<CPDF_FormField*> FieldArray =
508 GetFormFields(pFormFillEnv, swFieldName); 508 GetFormFields(pFormFillEnv, swFieldName);
509 for (CPDF_FormField* pFormField : FieldArray) { 509 for (CPDF_FormField* pFormField : FieldArray) {
510 if (nControlIndex < 0) { 510 if (nControlIndex < 0) {
511 FX_BOOL bSet = FALSE; 511 bool bSet = false;
512 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { 512 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) {
513 if (CPDFSDK_Widget* pWidget = 513 if (CPDFSDK_Widget* pWidget =
514 GetWidget(pFormFillEnv, pFormField->GetControl(i), false)) { 514 GetWidget(pFormFillEnv, pFormField->GetControl(i), false)) {
515 if (pWidget->GetBorderStyle() != nBorderStyle) { 515 if (pWidget->GetBorderStyle() != nBorderStyle) {
516 pWidget->SetBorderStyle(nBorderStyle); 516 pWidget->SetBorderStyle(nBorderStyle);
517 bSet = TRUE; 517 bSet = true;
518 } 518 }
519 } 519 }
520 } 520 }
521 if (bSet) 521 if (bSet)
522 UpdateFormField(pFormFillEnv, pFormField, TRUE, TRUE, TRUE); 522 UpdateFormField(pFormFillEnv, pFormField, true, true, true);
523 } else { 523 } else {
524 if (nControlIndex >= pFormField->CountControls()) 524 if (nControlIndex >= pFormField->CountControls())
525 return; 525 return;
526 if (CPDF_FormControl* pFormControl = 526 if (CPDF_FormControl* pFormControl =
527 pFormField->GetControl(nControlIndex)) { 527 pFormField->GetControl(nControlIndex)) {
528 if (CPDFSDK_Widget* pWidget = 528 if (CPDFSDK_Widget* pWidget =
529 GetWidget(pFormFillEnv, pFormControl, false)) { 529 GetWidget(pFormFillEnv, pFormControl, false)) {
530 if (pWidget->GetBorderStyle() != nBorderStyle) { 530 if (pWidget->GetBorderStyle() != nBorderStyle) {
531 pWidget->SetBorderStyle(nBorderStyle); 531 pWidget->SetBorderStyle(nBorderStyle);
532 UpdateFormControl(pFormFillEnv, pFormControl, TRUE, TRUE, TRUE); 532 UpdateFormControl(pFormFillEnv, pFormControl, true, true, true);
533 } 533 }
534 } 534 }
535 } 535 }
536 } 536 }
537 } 537 }
538 } 538 }
539 539
540 FX_BOOL Field::buttonAlignX(IJS_Context* cc, 540 bool Field::buttonAlignX(IJS_Context* cc,
541 CJS_PropValue& vp, 541 CJS_PropValue& vp,
542 CFX_WideString& sError) { 542 CFX_WideString& sError) {
543 ASSERT(m_pFormFillEnv); 543 ASSERT(m_pFormFillEnv);
544 544
545 if (vp.IsSetting()) { 545 if (vp.IsSetting()) {
546 if (!m_bCanSet) 546 if (!m_bCanSet)
547 return FALSE; 547 return false;
548 548
549 int nVP; 549 int nVP;
550 vp >> nVP; 550 vp >> nVP;
551 551
552 if (m_bDelay) { 552 if (m_bDelay) {
553 AddDelay_Int(FP_BUTTONALIGNX, nVP); 553 AddDelay_Int(FP_BUTTONALIGNX, nVP);
554 } else { 554 } else {
555 Field::SetButtonAlignX(m_pFormFillEnv.Get(), m_FieldName, 555 Field::SetButtonAlignX(m_pFormFillEnv.Get(), m_FieldName,
556 m_nFormControlIndex, nVP); 556 m_nFormControlIndex, nVP);
557 } 557 }
558 } else { 558 } else {
559 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 559 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
560 if (FieldArray.empty()) 560 if (FieldArray.empty())
561 return FALSE; 561 return false;
562 562
563 CPDF_FormField* pFormField = FieldArray[0]; 563 CPDF_FormField* pFormField = FieldArray[0];
564 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) 564 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
565 return FALSE; 565 return false;
566 566
567 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 567 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
568 if (!pFormControl) 568 if (!pFormControl)
569 return FALSE; 569 return false;
570 570
571 CPDF_IconFit IconFit = pFormControl->GetIconFit(); 571 CPDF_IconFit IconFit = pFormControl->GetIconFit();
572 572
573 FX_FLOAT fLeft, fBottom; 573 FX_FLOAT fLeft, fBottom;
574 IconFit.GetIconPosition(fLeft, fBottom); 574 IconFit.GetIconPosition(fLeft, fBottom);
575 575
576 vp << (int32_t)fLeft; 576 vp << (int32_t)fLeft;
577 } 577 }
578 578
579 return TRUE; 579 return true;
580 } 580 }
581 581
582 void Field::SetButtonAlignX(CPDFSDK_FormFillEnvironment* pFormFillEnv, 582 void Field::SetButtonAlignX(CPDFSDK_FormFillEnvironment* pFormFillEnv,
583 const CFX_WideString& swFieldName, 583 const CFX_WideString& swFieldName,
584 int nControlIndex, 584 int nControlIndex,
585 int number) { 585 int number) {
586 // Not supported. 586 // Not supported.
587 } 587 }
588 588
589 FX_BOOL Field::buttonAlignY(IJS_Context* cc, 589 bool Field::buttonAlignY(IJS_Context* cc,
590 CJS_PropValue& vp, 590 CJS_PropValue& vp,
591 CFX_WideString& sError) { 591 CFX_WideString& sError) {
592 ASSERT(m_pFormFillEnv); 592 ASSERT(m_pFormFillEnv);
593 593
594 if (vp.IsSetting()) { 594 if (vp.IsSetting()) {
595 if (!m_bCanSet) 595 if (!m_bCanSet)
596 return FALSE; 596 return false;
597 597
598 int nVP; 598 int nVP;
599 vp >> nVP; 599 vp >> nVP;
600 600
601 if (m_bDelay) { 601 if (m_bDelay) {
602 AddDelay_Int(FP_BUTTONALIGNY, nVP); 602 AddDelay_Int(FP_BUTTONALIGNY, nVP);
603 } else { 603 } else {
604 Field::SetButtonAlignY(m_pFormFillEnv.Get(), m_FieldName, 604 Field::SetButtonAlignY(m_pFormFillEnv.Get(), m_FieldName,
605 m_nFormControlIndex, nVP); 605 m_nFormControlIndex, nVP);
606 } 606 }
607 } else { 607 } else {
608 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 608 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
609 if (FieldArray.empty()) 609 if (FieldArray.empty())
610 return FALSE; 610 return false;
611 611
612 CPDF_FormField* pFormField = FieldArray[0]; 612 CPDF_FormField* pFormField = FieldArray[0];
613 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) 613 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
614 return FALSE; 614 return false;
615 615
616 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 616 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
617 if (!pFormControl) 617 if (!pFormControl)
618 return FALSE; 618 return false;
619 619
620 CPDF_IconFit IconFit = pFormControl->GetIconFit(); 620 CPDF_IconFit IconFit = pFormControl->GetIconFit();
621 621
622 FX_FLOAT fLeft, fBottom; 622 FX_FLOAT fLeft, fBottom;
623 IconFit.GetIconPosition(fLeft, fBottom); 623 IconFit.GetIconPosition(fLeft, fBottom);
624 624
625 vp << (int32_t)fBottom; 625 vp << (int32_t)fBottom;
626 } 626 }
627 627
628 return TRUE; 628 return true;
629 } 629 }
630 630
631 void Field::SetButtonAlignY(CPDFSDK_FormFillEnvironment* pFormFillEnv, 631 void Field::SetButtonAlignY(CPDFSDK_FormFillEnvironment* pFormFillEnv,
632 const CFX_WideString& swFieldName, 632 const CFX_WideString& swFieldName,
633 int nControlIndex, 633 int nControlIndex,
634 int number) { 634 int number) {
635 // Not supported. 635 // Not supported.
636 } 636 }
637 637
638 FX_BOOL Field::buttonFitBounds(IJS_Context* cc, 638 bool Field::buttonFitBounds(IJS_Context* cc,
639 CJS_PropValue& vp, 639 CJS_PropValue& vp,
640 CFX_WideString& sError) { 640 CFX_WideString& sError) {
641 ASSERT(m_pFormFillEnv); 641 ASSERT(m_pFormFillEnv);
642 642
643 if (vp.IsSetting()) { 643 if (vp.IsSetting()) {
644 if (!m_bCanSet) 644 if (!m_bCanSet)
645 return FALSE; 645 return false;
646 646
647 bool bVP; 647 bool bVP;
648 vp >> bVP; 648 vp >> bVP;
649 649
650 if (m_bDelay) { 650 if (m_bDelay) {
651 AddDelay_Bool(FP_BUTTONFITBOUNDS, bVP); 651 AddDelay_Bool(FP_BUTTONFITBOUNDS, bVP);
652 } else { 652 } else {
653 Field::SetButtonFitBounds(m_pFormFillEnv.Get(), m_FieldName, 653 Field::SetButtonFitBounds(m_pFormFillEnv.Get(), m_FieldName,
654 m_nFormControlIndex, bVP); 654 m_nFormControlIndex, bVP);
655 } 655 }
656 } else { 656 } else {
657 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 657 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
658 if (FieldArray.empty()) 658 if (FieldArray.empty())
659 return FALSE; 659 return false;
660 660
661 CPDF_FormField* pFormField = FieldArray[0]; 661 CPDF_FormField* pFormField = FieldArray[0];
662 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) 662 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
663 return FALSE; 663 return false;
664 664
665 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 665 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
666 if (!pFormControl) 666 if (!pFormControl)
667 return FALSE; 667 return false;
668 668
669 vp << pFormControl->GetIconFit().GetFittingBounds(); 669 vp << pFormControl->GetIconFit().GetFittingBounds();
670 } 670 }
671 671
672 return TRUE; 672 return true;
673 } 673 }
674 674
675 void Field::SetButtonFitBounds(CPDFSDK_FormFillEnvironment* pFormFillEnv, 675 void Field::SetButtonFitBounds(CPDFSDK_FormFillEnvironment* pFormFillEnv,
676 const CFX_WideString& swFieldName, 676 const CFX_WideString& swFieldName,
677 int nControlIndex, 677 int nControlIndex,
678 bool b) { 678 bool b) {
679 // Not supported. 679 // Not supported.
680 } 680 }
681 681
682 FX_BOOL Field::buttonPosition(IJS_Context* cc, 682 bool Field::buttonPosition(IJS_Context* cc,
683 CJS_PropValue& vp, 683 CJS_PropValue& vp,
684 CFX_WideString& sError) { 684 CFX_WideString& sError) {
685 ASSERT(m_pFormFillEnv); 685 ASSERT(m_pFormFillEnv);
686 686
687 if (vp.IsSetting()) { 687 if (vp.IsSetting()) {
688 if (!m_bCanSet) 688 if (!m_bCanSet)
689 return FALSE; 689 return false;
690 690
691 int nVP; 691 int nVP;
692 vp >> nVP; 692 vp >> nVP;
693 693
694 if (m_bDelay) { 694 if (m_bDelay) {
695 AddDelay_Int(FP_BUTTONPOSITION, nVP); 695 AddDelay_Int(FP_BUTTONPOSITION, nVP);
696 } else { 696 } else {
697 Field::SetButtonPosition(m_pFormFillEnv.Get(), m_FieldName, 697 Field::SetButtonPosition(m_pFormFillEnv.Get(), m_FieldName,
698 m_nFormControlIndex, nVP); 698 m_nFormControlIndex, nVP);
699 } 699 }
700 } else { 700 } else {
701 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 701 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
702 if (FieldArray.empty()) 702 if (FieldArray.empty())
703 return FALSE; 703 return false;
704 704
705 CPDF_FormField* pFormField = FieldArray[0]; 705 CPDF_FormField* pFormField = FieldArray[0];
706 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) 706 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
707 return FALSE; 707 return false;
708 708
709 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 709 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
710 if (!pFormControl) 710 if (!pFormControl)
711 return FALSE; 711 return false;
712 712
713 vp << pFormControl->GetTextPosition(); 713 vp << pFormControl->GetTextPosition();
714 } 714 }
715 return TRUE; 715 return true;
716 } 716 }
717 717
718 void Field::SetButtonPosition(CPDFSDK_FormFillEnvironment* pFormFillEnv, 718 void Field::SetButtonPosition(CPDFSDK_FormFillEnvironment* pFormFillEnv,
719 const CFX_WideString& swFieldName, 719 const CFX_WideString& swFieldName,
720 int nControlIndex, 720 int nControlIndex,
721 int number) { 721 int number) {
722 // Not supported. 722 // Not supported.
723 } 723 }
724 724
725 FX_BOOL Field::buttonScaleHow(IJS_Context* cc, 725 bool Field::buttonScaleHow(IJS_Context* cc,
726 CJS_PropValue& vp, 726 CJS_PropValue& vp,
727 CFX_WideString& sError) { 727 CFX_WideString& sError) {
728 ASSERT(m_pFormFillEnv); 728 ASSERT(m_pFormFillEnv);
729 729
730 if (vp.IsSetting()) { 730 if (vp.IsSetting()) {
731 if (!m_bCanSet) 731 if (!m_bCanSet)
732 return FALSE; 732 return false;
733 733
734 int nVP; 734 int nVP;
735 vp >> nVP; 735 vp >> nVP;
736 736
737 if (m_bDelay) { 737 if (m_bDelay) {
738 AddDelay_Int(FP_BUTTONSCALEHOW, nVP); 738 AddDelay_Int(FP_BUTTONSCALEHOW, nVP);
739 } else { 739 } else {
740 Field::SetButtonScaleHow(m_pFormFillEnv.Get(), m_FieldName, 740 Field::SetButtonScaleHow(m_pFormFillEnv.Get(), m_FieldName,
741 m_nFormControlIndex, nVP); 741 m_nFormControlIndex, nVP);
742 } 742 }
743 } else { 743 } else {
744 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 744 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
745 if (FieldArray.empty()) 745 if (FieldArray.empty())
746 return FALSE; 746 return false;
747 747
748 CPDF_FormField* pFormField = FieldArray[0]; 748 CPDF_FormField* pFormField = FieldArray[0];
749 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) 749 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
750 return FALSE; 750 return false;
751 751
752 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 752 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
753 if (!pFormControl) 753 if (!pFormControl)
754 return FALSE; 754 return false;
755 755
756 CPDF_IconFit IconFit = pFormControl->GetIconFit(); 756 CPDF_IconFit IconFit = pFormControl->GetIconFit();
757 if (IconFit.IsProportionalScale()) 757 if (IconFit.IsProportionalScale())
758 vp << (int32_t)0; 758 vp << (int32_t)0;
759 else 759 else
760 vp << (int32_t)1; 760 vp << (int32_t)1;
761 } 761 }
762 762
763 return TRUE; 763 return true;
764 } 764 }
765 765
766 void Field::SetButtonScaleHow(CPDFSDK_FormFillEnvironment* pFormFillEnv, 766 void Field::SetButtonScaleHow(CPDFSDK_FormFillEnvironment* pFormFillEnv,
767 const CFX_WideString& swFieldName, 767 const CFX_WideString& swFieldName,
768 int nControlIndex, 768 int nControlIndex,
769 int number) { 769 int number) {
770 // Not supported. 770 // Not supported.
771 } 771 }
772 772
773 FX_BOOL Field::buttonScaleWhen(IJS_Context* cc, 773 bool Field::buttonScaleWhen(IJS_Context* cc,
774 CJS_PropValue& vp, 774 CJS_PropValue& vp,
775 CFX_WideString& sError) { 775 CFX_WideString& sError) {
776 ASSERT(m_pFormFillEnv); 776 ASSERT(m_pFormFillEnv);
777 777
778 if (vp.IsSetting()) { 778 if (vp.IsSetting()) {
779 if (!m_bCanSet) 779 if (!m_bCanSet)
780 return FALSE; 780 return false;
781 781
782 int nVP; 782 int nVP;
783 vp >> nVP; 783 vp >> nVP;
784 784
785 if (m_bDelay) { 785 if (m_bDelay) {
786 AddDelay_Int(FP_BUTTONSCALEWHEN, nVP); 786 AddDelay_Int(FP_BUTTONSCALEWHEN, nVP);
787 } else { 787 } else {
788 Field::SetButtonScaleWhen(m_pFormFillEnv.Get(), m_FieldName, 788 Field::SetButtonScaleWhen(m_pFormFillEnv.Get(), m_FieldName,
789 m_nFormControlIndex, nVP); 789 m_nFormControlIndex, nVP);
790 } 790 }
791 } else { 791 } else {
792 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 792 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
793 if (FieldArray.empty()) 793 if (FieldArray.empty())
794 return FALSE; 794 return false;
795 795
796 CPDF_FormField* pFormField = FieldArray[0]; 796 CPDF_FormField* pFormField = FieldArray[0];
797 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) 797 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
798 return FALSE; 798 return false;
799 799
800 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 800 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
801 if (!pFormControl) 801 if (!pFormControl)
802 return FALSE; 802 return false;
803 803
804 CPDF_IconFit IconFit = pFormControl->GetIconFit(); 804 CPDF_IconFit IconFit = pFormControl->GetIconFit();
805 int ScaleM = IconFit.GetScaleMethod(); 805 int ScaleM = IconFit.GetScaleMethod();
806 switch (ScaleM) { 806 switch (ScaleM) {
807 case CPDF_IconFit::Always: 807 case CPDF_IconFit::Always:
808 vp << (int32_t)CPDF_IconFit::Always; 808 vp << (int32_t)CPDF_IconFit::Always;
809 break; 809 break;
810 case CPDF_IconFit::Bigger: 810 case CPDF_IconFit::Bigger:
811 vp << (int32_t)CPDF_IconFit::Bigger; 811 vp << (int32_t)CPDF_IconFit::Bigger;
812 break; 812 break;
813 case CPDF_IconFit::Never: 813 case CPDF_IconFit::Never:
814 vp << (int32_t)CPDF_IconFit::Never; 814 vp << (int32_t)CPDF_IconFit::Never;
815 break; 815 break;
816 case CPDF_IconFit::Smaller: 816 case CPDF_IconFit::Smaller:
817 vp << (int32_t)CPDF_IconFit::Smaller; 817 vp << (int32_t)CPDF_IconFit::Smaller;
818 break; 818 break;
819 } 819 }
820 } 820 }
821 821
822 return TRUE; 822 return true;
823 } 823 }
824 824
825 void Field::SetButtonScaleWhen(CPDFSDK_FormFillEnvironment* pFormFillEnv, 825 void Field::SetButtonScaleWhen(CPDFSDK_FormFillEnvironment* pFormFillEnv,
826 const CFX_WideString& swFieldName, 826 const CFX_WideString& swFieldName,
827 int nControlIndex, 827 int nControlIndex,
828 int number) { 828 int number) {
829 // Not supported. 829 // Not supported.
830 } 830 }
831 831
832 FX_BOOL Field::calcOrderIndex(IJS_Context* cc, 832 bool Field::calcOrderIndex(IJS_Context* cc,
833 CJS_PropValue& vp, 833 CJS_PropValue& vp,
834 CFX_WideString& sError) { 834 CFX_WideString& sError) {
835 ASSERT(m_pFormFillEnv); 835 ASSERT(m_pFormFillEnv);
836 836
837 if (vp.IsSetting()) { 837 if (vp.IsSetting()) {
838 if (!m_bCanSet) 838 if (!m_bCanSet)
839 return FALSE; 839 return false;
840 840
841 int nVP; 841 int nVP;
842 vp >> nVP; 842 vp >> nVP;
843 843
844 if (m_bDelay) { 844 if (m_bDelay) {
845 AddDelay_Int(FP_CALCORDERINDEX, nVP); 845 AddDelay_Int(FP_CALCORDERINDEX, nVP);
846 } else { 846 } else {
847 Field::SetCalcOrderIndex(m_pFormFillEnv.Get(), m_FieldName, 847 Field::SetCalcOrderIndex(m_pFormFillEnv.Get(), m_FieldName,
848 m_nFormControlIndex, nVP); 848 m_nFormControlIndex, nVP);
849 } 849 }
850 } else { 850 } else {
851 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 851 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
852 if (FieldArray.empty()) 852 if (FieldArray.empty())
853 return FALSE; 853 return false;
854 854
855 CPDF_FormField* pFormField = FieldArray[0]; 855 CPDF_FormField* pFormField = FieldArray[0];
856 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && 856 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX &&
857 pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) { 857 pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) {
858 return FALSE; 858 return false;
859 } 859 }
860 860
861 CPDFSDK_InterForm* pRDInterForm = m_pFormFillEnv->GetInterForm(); 861 CPDFSDK_InterForm* pRDInterForm = m_pFormFillEnv->GetInterForm();
862 CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm(); 862 CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm();
863 vp << (int32_t)pInterForm->FindFieldInCalculationOrder(pFormField); 863 vp << (int32_t)pInterForm->FindFieldInCalculationOrder(pFormField);
864 } 864 }
865 865
866 return TRUE; 866 return true;
867 } 867 }
868 868
869 void Field::SetCalcOrderIndex(CPDFSDK_FormFillEnvironment* pFormFillEnv, 869 void Field::SetCalcOrderIndex(CPDFSDK_FormFillEnvironment* pFormFillEnv,
870 const CFX_WideString& swFieldName, 870 const CFX_WideString& swFieldName,
871 int nControlIndex, 871 int nControlIndex,
872 int number) { 872 int number) {
873 // Not supported. 873 // Not supported.
874 } 874 }
875 875
876 FX_BOOL Field::charLimit(IJS_Context* cc, 876 bool Field::charLimit(IJS_Context* cc,
877 CJS_PropValue& vp, 877 CJS_PropValue& vp,
878 CFX_WideString& sError) { 878 CFX_WideString& sError) {
879 ASSERT(m_pFormFillEnv); 879 ASSERT(m_pFormFillEnv);
880 880
881 if (vp.IsSetting()) { 881 if (vp.IsSetting()) {
882 if (!m_bCanSet) 882 if (!m_bCanSet)
883 return FALSE; 883 return false;
884 884
885 int nVP; 885 int nVP;
886 vp >> nVP; 886 vp >> nVP;
887 887
888 if (m_bDelay) { 888 if (m_bDelay) {
889 AddDelay_Int(FP_CHARLIMIT, nVP); 889 AddDelay_Int(FP_CHARLIMIT, nVP);
890 } else { 890 } else {
891 Field::SetCharLimit(m_pFormFillEnv.Get(), m_FieldName, 891 Field::SetCharLimit(m_pFormFillEnv.Get(), m_FieldName,
892 m_nFormControlIndex, nVP); 892 m_nFormControlIndex, nVP);
893 } 893 }
894 } else { 894 } else {
895 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 895 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
896 if (FieldArray.empty()) 896 if (FieldArray.empty())
897 return FALSE; 897 return false;
898 898
899 CPDF_FormField* pFormField = FieldArray[0]; 899 CPDF_FormField* pFormField = FieldArray[0];
900 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) 900 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
901 return FALSE; 901 return false;
902 902
903 vp << (int32_t)pFormField->GetMaxLen(); 903 vp << (int32_t)pFormField->GetMaxLen();
904 } 904 }
905 return TRUE; 905 return true;
906 } 906 }
907 907
908 void Field::SetCharLimit(CPDFSDK_FormFillEnvironment* pFormFillEnv, 908 void Field::SetCharLimit(CPDFSDK_FormFillEnvironment* pFormFillEnv,
909 const CFX_WideString& swFieldName, 909 const CFX_WideString& swFieldName,
910 int nControlIndex, 910 int nControlIndex,
911 int number) { 911 int number) {
912 // Not supported. 912 // Not supported.
913 } 913 }
914 914
915 FX_BOOL Field::comb(IJS_Context* cc, 915 bool Field::comb(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
916 CJS_PropValue& vp,
917 CFX_WideString& sError) {
918 ASSERT(m_pFormFillEnv); 916 ASSERT(m_pFormFillEnv);
919 917
920 if (vp.IsSetting()) { 918 if (vp.IsSetting()) {
921 if (!m_bCanSet) 919 if (!m_bCanSet)
922 return FALSE; 920 return false;
923 921
924 bool bVP; 922 bool bVP;
925 vp >> bVP; 923 vp >> bVP;
926 924
927 if (m_bDelay) { 925 if (m_bDelay) {
928 AddDelay_Bool(FP_COMB, bVP); 926 AddDelay_Bool(FP_COMB, bVP);
929 } else { 927 } else {
930 Field::SetComb(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, 928 Field::SetComb(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
931 bVP); 929 bVP);
932 } 930 }
933 } else { 931 } else {
934 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 932 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
935 if (FieldArray.empty()) 933 if (FieldArray.empty())
936 return FALSE; 934 return false;
937 935
938 CPDF_FormField* pFormField = FieldArray[0]; 936 CPDF_FormField* pFormField = FieldArray[0];
939 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) 937 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
940 return FALSE; 938 return false;
941 939
942 if (pFormField->GetFieldFlags() & FIELDFLAG_COMB) 940 if (pFormField->GetFieldFlags() & FIELDFLAG_COMB)
943 vp << true; 941 vp << true;
944 else 942 else
945 vp << false; 943 vp << false;
946 } 944 }
947 945
948 return TRUE; 946 return true;
949 } 947 }
950 948
951 void Field::SetComb(CPDFSDK_FormFillEnvironment* pFormFillEnv, 949 void Field::SetComb(CPDFSDK_FormFillEnvironment* pFormFillEnv,
952 const CFX_WideString& swFieldName, 950 const CFX_WideString& swFieldName,
953 int nControlIndex, 951 int nControlIndex,
954 bool b) { 952 bool b) {
955 // Not supported. 953 // Not supported.
956 } 954 }
957 955
958 FX_BOOL Field::commitOnSelChange(IJS_Context* cc, 956 bool Field::commitOnSelChange(IJS_Context* cc,
959 CJS_PropValue& vp, 957 CJS_PropValue& vp,
960 CFX_WideString& sError) { 958 CFX_WideString& sError) {
961 ASSERT(m_pFormFillEnv); 959 ASSERT(m_pFormFillEnv);
962 960
963 if (vp.IsSetting()) { 961 if (vp.IsSetting()) {
964 if (!m_bCanSet) 962 if (!m_bCanSet)
965 return FALSE; 963 return false;
966 964
967 bool bVP; 965 bool bVP;
968 vp >> bVP; 966 vp >> bVP;
969 967
970 if (m_bDelay) { 968 if (m_bDelay) {
971 AddDelay_Bool(FP_COMMITONSELCHANGE, bVP); 969 AddDelay_Bool(FP_COMMITONSELCHANGE, bVP);
972 } else { 970 } else {
973 Field::SetCommitOnSelChange(m_pFormFillEnv.Get(), m_FieldName, 971 Field::SetCommitOnSelChange(m_pFormFillEnv.Get(), m_FieldName,
974 m_nFormControlIndex, bVP); 972 m_nFormControlIndex, bVP);
975 } 973 }
976 } else { 974 } else {
977 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 975 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
978 if (FieldArray.empty()) 976 if (FieldArray.empty())
979 return FALSE; 977 return false;
980 978
981 CPDF_FormField* pFormField = FieldArray[0]; 979 CPDF_FormField* pFormField = FieldArray[0];
982 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && 980 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX &&
983 pFormField->GetFieldType() != FIELDTYPE_LISTBOX) { 981 pFormField->GetFieldType() != FIELDTYPE_LISTBOX) {
984 return FALSE; 982 return false;
985 } 983 }
986 984
987 if (pFormField->GetFieldFlags() & FIELDFLAG_COMMITONSELCHANGE) 985 if (pFormField->GetFieldFlags() & FIELDFLAG_COMMITONSELCHANGE)
988 vp << true; 986 vp << true;
989 else 987 else
990 vp << false; 988 vp << false;
991 } 989 }
992 990
993 return TRUE; 991 return true;
994 } 992 }
995 993
996 void Field::SetCommitOnSelChange(CPDFSDK_FormFillEnvironment* pFormFillEnv, 994 void Field::SetCommitOnSelChange(CPDFSDK_FormFillEnvironment* pFormFillEnv,
997 const CFX_WideString& swFieldName, 995 const CFX_WideString& swFieldName,
998 int nControlIndex, 996 int nControlIndex,
999 bool b) { 997 bool b) {
1000 // Not supported. 998 // Not supported.
1001 } 999 }
1002 1000
1003 FX_BOOL Field::currentValueIndices(IJS_Context* cc, 1001 bool Field::currentValueIndices(IJS_Context* cc,
1004 CJS_PropValue& vp, 1002 CJS_PropValue& vp,
1005 CFX_WideString& sError) { 1003 CFX_WideString& sError) {
1006 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); 1004 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
1007 1005
1008 if (vp.IsSetting()) { 1006 if (vp.IsSetting()) {
1009 if (!m_bCanSet) 1007 if (!m_bCanSet)
1010 return FALSE; 1008 return false;
1011 1009
1012 std::vector<uint32_t> array; 1010 std::vector<uint32_t> array;
1013 if (vp.GetJSValue()->GetType() == CJS_Value::VT_number) { 1011 if (vp.GetJSValue()->GetType() == CJS_Value::VT_number) {
1014 int iSelecting = 0; 1012 int iSelecting = 0;
1015 vp >> iSelecting; 1013 vp >> iSelecting;
1016 array.push_back(iSelecting); 1014 array.push_back(iSelecting);
1017 } else if (vp.GetJSValue()->IsArrayObject()) { 1015 } else if (vp.GetJSValue()->IsArrayObject()) {
1018 CJS_Array SelArray; 1016 CJS_Array SelArray;
1019 CJS_Value SelValue(pRuntime); 1017 CJS_Value SelValue(pRuntime);
1020 int iSelecting; 1018 int iSelecting;
1021 vp >> SelArray; 1019 vp >> SelArray;
1022 for (int i = 0, sz = SelArray.GetLength(pRuntime); i < sz; i++) { 1020 for (int i = 0, sz = SelArray.GetLength(pRuntime); i < sz; i++) {
1023 SelArray.GetElement(pRuntime, i, SelValue); 1021 SelArray.GetElement(pRuntime, i, SelValue);
1024 iSelecting = SelValue.ToInt(pRuntime); 1022 iSelecting = SelValue.ToInt(pRuntime);
1025 array.push_back(iSelecting); 1023 array.push_back(iSelecting);
1026 } 1024 }
1027 } 1025 }
1028 1026
1029 if (m_bDelay) { 1027 if (m_bDelay) {
1030 AddDelay_WordArray(FP_CURRENTVALUEINDICES, array); 1028 AddDelay_WordArray(FP_CURRENTVALUEINDICES, array);
1031 } else { 1029 } else {
1032 Field::SetCurrentValueIndices(m_pFormFillEnv.Get(), m_FieldName, 1030 Field::SetCurrentValueIndices(m_pFormFillEnv.Get(), m_FieldName,
1033 m_nFormControlIndex, array); 1031 m_nFormControlIndex, array);
1034 } 1032 }
1035 } else { 1033 } else {
1036 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1034 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1037 if (FieldArray.empty()) 1035 if (FieldArray.empty())
1038 return FALSE; 1036 return false;
1039 1037
1040 CPDF_FormField* pFormField = FieldArray[0]; 1038 CPDF_FormField* pFormField = FieldArray[0];
1041 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && 1039 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX &&
1042 pFormField->GetFieldType() != FIELDTYPE_LISTBOX) { 1040 pFormField->GetFieldType() != FIELDTYPE_LISTBOX) {
1043 return FALSE; 1041 return false;
1044 } 1042 }
1045 1043
1046 if (pFormField->CountSelectedItems() == 1) { 1044 if (pFormField->CountSelectedItems() == 1) {
1047 vp << pFormField->GetSelectedIndex(0); 1045 vp << pFormField->GetSelectedIndex(0);
1048 } else if (pFormField->CountSelectedItems() > 1) { 1046 } else if (pFormField->CountSelectedItems() > 1) {
1049 CJS_Array SelArray; 1047 CJS_Array SelArray;
1050 for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) { 1048 for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) {
1051 SelArray.SetElement( 1049 SelArray.SetElement(
1052 pRuntime, i, CJS_Value(pRuntime, pFormField->GetSelectedIndex(i))); 1050 pRuntime, i, CJS_Value(pRuntime, pFormField->GetSelectedIndex(i)));
1053 } 1051 }
1054 vp << SelArray; 1052 vp << SelArray;
1055 } else { 1053 } else {
1056 vp << -1; 1054 vp << -1;
1057 } 1055 }
1058 } 1056 }
1059 1057
1060 return TRUE; 1058 return true;
1061 } 1059 }
1062 1060
1063 void Field::SetCurrentValueIndices(CPDFSDK_FormFillEnvironment* pFormFillEnv, 1061 void Field::SetCurrentValueIndices(CPDFSDK_FormFillEnvironment* pFormFillEnv,
1064 const CFX_WideString& swFieldName, 1062 const CFX_WideString& swFieldName,
1065 int nControlIndex, 1063 int nControlIndex,
1066 const std::vector<uint32_t>& array) { 1064 const std::vector<uint32_t>& array) {
1067 ASSERT(pFormFillEnv); 1065 ASSERT(pFormFillEnv);
1068 std::vector<CPDF_FormField*> FieldArray = 1066 std::vector<CPDF_FormField*> FieldArray =
1069 GetFormFields(pFormFillEnv, swFieldName); 1067 GetFormFields(pFormFillEnv, swFieldName);
1070 1068
1071 for (CPDF_FormField* pFormField : FieldArray) { 1069 for (CPDF_FormField* pFormField : FieldArray) {
1072 int nFieldType = pFormField->GetFieldType(); 1070 int nFieldType = pFormField->GetFieldType();
1073 if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_LISTBOX) { 1071 if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_LISTBOX) {
1074 uint32_t dwFieldFlags = pFormField->GetFieldFlags(); 1072 uint32_t dwFieldFlags = pFormField->GetFieldFlags();
1075 pFormField->ClearSelection(TRUE); 1073 pFormField->ClearSelection(true);
1076 for (size_t i = 0; i < array.size(); ++i) { 1074 for (size_t i = 0; i < array.size(); ++i) {
1077 if (i != 0 && !(dwFieldFlags & (1 << 21))) 1075 if (i != 0 && !(dwFieldFlags & (1 << 21)))
1078 break; 1076 break;
1079 if (array[i] < static_cast<uint32_t>(pFormField->CountOptions()) && 1077 if (array[i] < static_cast<uint32_t>(pFormField->CountOptions()) &&
1080 !pFormField->IsItemSelected(array[i])) { 1078 !pFormField->IsItemSelected(array[i])) {
1081 pFormField->SetItemSelection(array[i], TRUE); 1079 pFormField->SetItemSelection(array[i], true);
1082 } 1080 }
1083 } 1081 }
1084 UpdateFormField(pFormFillEnv, pFormField, TRUE, TRUE, TRUE); 1082 UpdateFormField(pFormFillEnv, pFormField, true, true, true);
1085 } 1083 }
1086 } 1084 }
1087 } 1085 }
1088 1086
1089 FX_BOOL Field::defaultStyle(IJS_Context* cc, 1087 bool Field::defaultStyle(IJS_Context* cc,
1090 CJS_PropValue& vp, 1088 CJS_PropValue& vp,
1091 CFX_WideString& sError) { 1089 CFX_WideString& sError) {
1092 return FALSE; 1090 return false;
1093 } 1091 }
1094 1092
1095 void Field::SetDefaultStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv, 1093 void Field::SetDefaultStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv,
1096 const CFX_WideString& swFieldName, 1094 const CFX_WideString& swFieldName,
1097 int nControlIndex) { 1095 int nControlIndex) {
1098 // Not supported. 1096 // Not supported.
1099 } 1097 }
1100 1098
1101 FX_BOOL Field::defaultValue(IJS_Context* cc, 1099 bool Field::defaultValue(IJS_Context* cc,
1102 CJS_PropValue& vp, 1100 CJS_PropValue& vp,
1103 CFX_WideString& sError) { 1101 CFX_WideString& sError) {
1104 ASSERT(m_pFormFillEnv); 1102 ASSERT(m_pFormFillEnv);
1105 1103
1106 if (vp.IsSetting()) { 1104 if (vp.IsSetting()) {
1107 if (!m_bCanSet) 1105 if (!m_bCanSet)
1108 return FALSE; 1106 return false;
1109 1107
1110 CFX_WideString WideStr; 1108 CFX_WideString WideStr;
1111 vp >> WideStr; 1109 vp >> WideStr;
1112 1110
1113 if (m_bDelay) { 1111 if (m_bDelay) {
1114 AddDelay_WideString(FP_DEFAULTVALUE, WideStr); 1112 AddDelay_WideString(FP_DEFAULTVALUE, WideStr);
1115 } else { 1113 } else {
1116 Field::SetDefaultValue(m_pFormFillEnv.Get(), m_FieldName, 1114 Field::SetDefaultValue(m_pFormFillEnv.Get(), m_FieldName,
1117 m_nFormControlIndex, WideStr); 1115 m_nFormControlIndex, WideStr);
1118 } 1116 }
1119 } else { 1117 } else {
1120 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1118 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1121 if (FieldArray.empty()) 1119 if (FieldArray.empty())
1122 return FALSE; 1120 return false;
1123 1121
1124 CPDF_FormField* pFormField = FieldArray[0]; 1122 CPDF_FormField* pFormField = FieldArray[0];
1125 if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON || 1123 if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON ||
1126 pFormField->GetFieldType() == FIELDTYPE_SIGNATURE) { 1124 pFormField->GetFieldType() == FIELDTYPE_SIGNATURE) {
1127 return FALSE; 1125 return false;
1128 } 1126 }
1129 1127
1130 vp << pFormField->GetDefaultValue(); 1128 vp << pFormField->GetDefaultValue();
1131 } 1129 }
1132 return TRUE; 1130 return true;
1133 } 1131 }
1134 1132
1135 void Field::SetDefaultValue(CPDFSDK_FormFillEnvironment* pFormFillEnv, 1133 void Field::SetDefaultValue(CPDFSDK_FormFillEnvironment* pFormFillEnv,
1136 const CFX_WideString& swFieldName, 1134 const CFX_WideString& swFieldName,
1137 int nControlIndex, 1135 int nControlIndex,
1138 const CFX_WideString& string) { 1136 const CFX_WideString& string) {
1139 // Not supported. 1137 // Not supported.
1140 } 1138 }
1141 1139
1142 FX_BOOL Field::doNotScroll(IJS_Context* cc, 1140 bool Field::doNotScroll(IJS_Context* cc,
1143 CJS_PropValue& vp, 1141 CJS_PropValue& vp,
1144 CFX_WideString& sError) { 1142 CFX_WideString& sError) {
1145 ASSERT(m_pFormFillEnv); 1143 ASSERT(m_pFormFillEnv);
1146 1144
1147 if (vp.IsSetting()) { 1145 if (vp.IsSetting()) {
1148 if (!m_bCanSet) 1146 if (!m_bCanSet)
1149 return FALSE; 1147 return false;
1150 1148
1151 bool bVP; 1149 bool bVP;
1152 vp >> bVP; 1150 vp >> bVP;
1153 1151
1154 if (m_bDelay) { 1152 if (m_bDelay) {
1155 AddDelay_Bool(FP_DONOTSCROLL, bVP); 1153 AddDelay_Bool(FP_DONOTSCROLL, bVP);
1156 } else { 1154 } else {
1157 Field::SetDoNotScroll(m_pFormFillEnv.Get(), m_FieldName, 1155 Field::SetDoNotScroll(m_pFormFillEnv.Get(), m_FieldName,
1158 m_nFormControlIndex, bVP); 1156 m_nFormControlIndex, bVP);
1159 } 1157 }
1160 } else { 1158 } else {
1161 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1159 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1162 if (FieldArray.empty()) 1160 if (FieldArray.empty())
1163 return FALSE; 1161 return false;
1164 1162
1165 CPDF_FormField* pFormField = FieldArray[0]; 1163 CPDF_FormField* pFormField = FieldArray[0];
1166 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) 1164 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
1167 return FALSE; 1165 return false;
1168 1166
1169 if (pFormField->GetFieldFlags() & FIELDFLAG_DONOTSCROLL) 1167 if (pFormField->GetFieldFlags() & FIELDFLAG_DONOTSCROLL)
1170 vp << true; 1168 vp << true;
1171 else 1169 else
1172 vp << false; 1170 vp << false;
1173 } 1171 }
1174 1172
1175 return TRUE; 1173 return true;
1176 } 1174 }
1177 1175
1178 void Field::SetDoNotScroll(CPDFSDK_FormFillEnvironment* pFormFillEnv, 1176 void Field::SetDoNotScroll(CPDFSDK_FormFillEnvironment* pFormFillEnv,
1179 const CFX_WideString& swFieldName, 1177 const CFX_WideString& swFieldName,
1180 int nControlIndex, 1178 int nControlIndex,
1181 bool b) { 1179 bool b) {
1182 // Not supported. 1180 // Not supported.
1183 } 1181 }
1184 1182
1185 FX_BOOL Field::doNotSpellCheck(IJS_Context* cc, 1183 bool Field::doNotSpellCheck(IJS_Context* cc,
1186 CJS_PropValue& vp, 1184 CJS_PropValue& vp,
1187 CFX_WideString& sError) { 1185 CFX_WideString& sError) {
1188 ASSERT(m_pFormFillEnv); 1186 ASSERT(m_pFormFillEnv);
1189 1187
1190 if (vp.IsSetting()) { 1188 if (vp.IsSetting()) {
1191 if (!m_bCanSet) 1189 if (!m_bCanSet)
1192 return FALSE; 1190 return false;
1193 1191
1194 bool bVP; 1192 bool bVP;
1195 vp >> bVP; 1193 vp >> bVP;
1196 } else { 1194 } else {
1197 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1195 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1198 if (FieldArray.empty()) 1196 if (FieldArray.empty())
1199 return FALSE; 1197 return false;
1200 1198
1201 CPDF_FormField* pFormField = FieldArray[0]; 1199 CPDF_FormField* pFormField = FieldArray[0];
1202 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD && 1200 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD &&
1203 pFormField->GetFieldType() != FIELDTYPE_COMBOBOX) { 1201 pFormField->GetFieldType() != FIELDTYPE_COMBOBOX) {
1204 return FALSE; 1202 return false;
1205 } 1203 }
1206 1204
1207 if (pFormField->GetFieldFlags() & FIELDFLAG_DONOTSPELLCHECK) 1205 if (pFormField->GetFieldFlags() & FIELDFLAG_DONOTSPELLCHECK)
1208 vp << true; 1206 vp << true;
1209 else 1207 else
1210 vp << false; 1208 vp << false;
1211 } 1209 }
1212 1210
1213 return TRUE; 1211 return true;
1214 } 1212 }
1215 1213
1216 void Field::SetDelay(FX_BOOL bDelay) { 1214 void Field::SetDelay(bool bDelay) {
1217 m_bDelay = bDelay; 1215 m_bDelay = bDelay;
1218 1216
1219 if (!m_bDelay) { 1217 if (!m_bDelay) {
1220 if (m_pJSDoc) 1218 if (m_pJSDoc)
1221 m_pJSDoc->DoFieldDelay(m_FieldName, m_nFormControlIndex); 1219 m_pJSDoc->DoFieldDelay(m_FieldName, m_nFormControlIndex);
1222 } 1220 }
1223 } 1221 }
1224 1222
1225 FX_BOOL Field::delay(IJS_Context* cc, 1223 bool Field::delay(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
1226 CJS_PropValue& vp,
1227 CFX_WideString& sError) {
1228 if (vp.IsSetting()) { 1224 if (vp.IsSetting()) {
1229 if (!m_bCanSet) 1225 if (!m_bCanSet)
1230 return FALSE; 1226 return false;
1231 1227
1232 bool bVP; 1228 bool bVP;
1233 vp >> bVP; 1229 vp >> bVP;
1234 1230
1235 SetDelay(bVP); 1231 SetDelay(bVP);
1236 } else { 1232 } else {
1237 vp << m_bDelay; 1233 vp << m_bDelay;
1238 } 1234 }
1239 return TRUE; 1235 return true;
1240 } 1236 }
1241 1237
1242 FX_BOOL Field::display(IJS_Context* cc, 1238 bool Field::display(IJS_Context* cc,
1243 CJS_PropValue& vp, 1239 CJS_PropValue& vp,
1244 CFX_WideString& sError) { 1240 CFX_WideString& sError) {
1245 if (vp.IsSetting()) { 1241 if (vp.IsSetting()) {
1246 if (!m_bCanSet) 1242 if (!m_bCanSet)
1247 return FALSE; 1243 return false;
1248 1244
1249 int nVP; 1245 int nVP;
1250 vp >> nVP; 1246 vp >> nVP;
1251 1247
1252 if (m_bDelay) { 1248 if (m_bDelay) {
1253 AddDelay_Int(FP_DISPLAY, nVP); 1249 AddDelay_Int(FP_DISPLAY, nVP);
1254 } else { 1250 } else {
1255 Field::SetDisplay(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, 1251 Field::SetDisplay(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
1256 nVP); 1252 nVP);
1257 } 1253 }
1258 } else { 1254 } else {
1259 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1255 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1260 if (FieldArray.empty()) 1256 if (FieldArray.empty())
1261 return FALSE; 1257 return false;
1262 1258
1263 CPDF_FormField* pFormField = FieldArray[0]; 1259 CPDF_FormField* pFormField = FieldArray[0];
1264 ASSERT(pFormField); 1260 ASSERT(pFormField);
1265 CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); 1261 CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
1266 CPDFSDK_Widget* pWidget = 1262 CPDFSDK_Widget* pWidget =
1267 pInterForm->GetWidget(GetSmartFieldControl(pFormField), true); 1263 pInterForm->GetWidget(GetSmartFieldControl(pFormField), true);
1268 if (!pWidget) 1264 if (!pWidget)
1269 return FALSE; 1265 return false;
1270 1266
1271 uint32_t dwFlag = pWidget->GetFlags(); 1267 uint32_t dwFlag = pWidget->GetFlags();
1272 1268
1273 if (ANNOTFLAG_INVISIBLE & dwFlag || ANNOTFLAG_HIDDEN & dwFlag) { 1269 if (ANNOTFLAG_INVISIBLE & dwFlag || ANNOTFLAG_HIDDEN & dwFlag) {
1274 vp << (int32_t)1; 1270 vp << (int32_t)1;
1275 } else { 1271 } else {
1276 if (ANNOTFLAG_PRINT & dwFlag) { 1272 if (ANNOTFLAG_PRINT & dwFlag) {
1277 if (ANNOTFLAG_NOVIEW & dwFlag) { 1273 if (ANNOTFLAG_NOVIEW & dwFlag) {
1278 vp << (int32_t)3; 1274 vp << (int32_t)3;
1279 } else { 1275 } else {
1280 vp << (int32_t)0; 1276 vp << (int32_t)0;
1281 } 1277 }
1282 } else { 1278 } else {
1283 vp << (int32_t)2; 1279 vp << (int32_t)2;
1284 } 1280 }
1285 } 1281 }
1286 } 1282 }
1287 1283
1288 return TRUE; 1284 return true;
1289 } 1285 }
1290 1286
1291 void Field::SetDisplay(CPDFSDK_FormFillEnvironment* pFormFillEnv, 1287 void Field::SetDisplay(CPDFSDK_FormFillEnvironment* pFormFillEnv,
1292 const CFX_WideString& swFieldName, 1288 const CFX_WideString& swFieldName,
1293 int nControlIndex, 1289 int nControlIndex,
1294 int number) { 1290 int number) {
1295 CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm(); 1291 CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm();
1296 std::vector<CPDF_FormField*> FieldArray = 1292 std::vector<CPDF_FormField*> FieldArray =
1297 GetFormFields(pFormFillEnv, swFieldName); 1293 GetFormFields(pFormFillEnv, swFieldName);
1298 for (CPDF_FormField* pFormField : FieldArray) { 1294 for (CPDF_FormField* pFormField : FieldArray) {
1299 if (nControlIndex < 0) { 1295 if (nControlIndex < 0) {
1300 bool bAnySet = false; 1296 bool bAnySet = false;
1301 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { 1297 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) {
1302 CPDF_FormControl* pFormControl = pFormField->GetControl(i); 1298 CPDF_FormControl* pFormControl = pFormField->GetControl(i);
1303 ASSERT(pFormControl); 1299 ASSERT(pFormControl);
1304 1300
1305 CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl, true); 1301 CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl, true);
1306 if (SetWidgetDisplayStatus(pWidget, number)) 1302 if (SetWidgetDisplayStatus(pWidget, number))
1307 bAnySet = true; 1303 bAnySet = true;
1308 } 1304 }
1309 1305
1310 if (bAnySet) 1306 if (bAnySet)
1311 UpdateFormField(pFormFillEnv, pFormField, TRUE, FALSE, TRUE); 1307 UpdateFormField(pFormFillEnv, pFormField, true, false, true);
1312 } else { 1308 } else {
1313 if (nControlIndex >= pFormField->CountControls()) 1309 if (nControlIndex >= pFormField->CountControls())
1314 return; 1310 return;
1315 1311
1316 CPDF_FormControl* pFormControl = pFormField->GetControl(nControlIndex); 1312 CPDF_FormControl* pFormControl = pFormField->GetControl(nControlIndex);
1317 if (!pFormControl) 1313 if (!pFormControl)
1318 return; 1314 return;
1319 1315
1320 CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl, true); 1316 CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl, true);
1321 if (SetWidgetDisplayStatus(pWidget, number)) 1317 if (SetWidgetDisplayStatus(pWidget, number))
1322 UpdateFormControl(pFormFillEnv, pFormControl, TRUE, FALSE, TRUE); 1318 UpdateFormControl(pFormFillEnv, pFormControl, true, false, true);
1323 } 1319 }
1324 } 1320 }
1325 } 1321 }
1326 1322
1327 FX_BOOL Field::doc(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { 1323 bool Field::doc(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
1328 if (!vp.IsGetting()) { 1324 if (!vp.IsGetting()) {
1329 return FALSE; 1325 return false;
1330 } 1326 }
1331 vp << m_pJSDoc->GetCJSDoc(); 1327 vp << m_pJSDoc->GetCJSDoc();
1332 return TRUE; 1328 return true;
1333 } 1329 }
1334 1330
1335 FX_BOOL Field::editable(IJS_Context* cc, 1331 bool Field::editable(IJS_Context* cc,
1336 CJS_PropValue& vp, 1332 CJS_PropValue& vp,
1337 CFX_WideString& sError) { 1333 CFX_WideString& sError) {
1338 if (vp.IsSetting()) { 1334 if (vp.IsSetting()) {
1339 if (!m_bCanSet) 1335 if (!m_bCanSet)
1340 return FALSE; 1336 return false;
1341 1337
1342 bool bVP; 1338 bool bVP;
1343 vp >> bVP; 1339 vp >> bVP;
1344 } else { 1340 } else {
1345 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1341 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1346 if (FieldArray.empty()) 1342 if (FieldArray.empty())
1347 return FALSE; 1343 return false;
1348 1344
1349 CPDF_FormField* pFormField = FieldArray[0]; 1345 CPDF_FormField* pFormField = FieldArray[0];
1350 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX) 1346 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX)
1351 return FALSE; 1347 return false;
1352 1348
1353 if (pFormField->GetFieldFlags() & FIELDFLAG_EDIT) 1349 if (pFormField->GetFieldFlags() & FIELDFLAG_EDIT)
1354 vp << true; 1350 vp << true;
1355 else 1351 else
1356 vp << false; 1352 vp << false;
1357 } 1353 }
1358 1354
1359 return TRUE; 1355 return true;
1360 } 1356 }
1361 1357
1362 FX_BOOL Field::exportValues(IJS_Context* cc, 1358 bool Field::exportValues(IJS_Context* cc,
1363 CJS_PropValue& vp, 1359 CJS_PropValue& vp,
1364 CFX_WideString& sError) { 1360 CFX_WideString& sError) {
1365 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1361 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1366 if (FieldArray.empty()) 1362 if (FieldArray.empty())
1367 return FALSE; 1363 return false;
1368 1364
1369 CPDF_FormField* pFormField = FieldArray[0]; 1365 CPDF_FormField* pFormField = FieldArray[0];
1370 if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX && 1366 if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX &&
1371 pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON) { 1367 pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON) {
1372 return FALSE; 1368 return false;
1373 } 1369 }
1374 1370
1375 if (vp.IsSetting()) { 1371 if (vp.IsSetting()) {
1376 if (!m_bCanSet) 1372 if (!m_bCanSet)
1377 return FALSE; 1373 return false;
1378 1374
1379 if (!vp.GetJSValue()->IsArrayObject()) 1375 if (!vp.GetJSValue()->IsArrayObject())
1380 return FALSE; 1376 return false;
1381 } else { 1377 } else {
1382 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); 1378 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
1383 CJS_Array ExportValusArray; 1379 CJS_Array ExportValusArray;
1384 if (m_nFormControlIndex < 0) { 1380 if (m_nFormControlIndex < 0) {
1385 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { 1381 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) {
1386 CPDF_FormControl* pFormControl = pFormField->GetControl(i); 1382 CPDF_FormControl* pFormControl = pFormField->GetControl(i);
1387 ExportValusArray.SetElement( 1383 ExportValusArray.SetElement(
1388 pRuntime, i, 1384 pRuntime, i,
1389 CJS_Value(pRuntime, pFormControl->GetExportValue().c_str())); 1385 CJS_Value(pRuntime, pFormControl->GetExportValue().c_str()));
1390 } 1386 }
1391 } else { 1387 } else {
1392 if (m_nFormControlIndex >= pFormField->CountControls()) 1388 if (m_nFormControlIndex >= pFormField->CountControls())
1393 return FALSE; 1389 return false;
1394 1390
1395 CPDF_FormControl* pFormControl = 1391 CPDF_FormControl* pFormControl =
1396 pFormField->GetControl(m_nFormControlIndex); 1392 pFormField->GetControl(m_nFormControlIndex);
1397 if (!pFormControl) 1393 if (!pFormControl)
1398 return FALSE; 1394 return false;
1399 1395
1400 ExportValusArray.SetElement( 1396 ExportValusArray.SetElement(
1401 pRuntime, 0, 1397 pRuntime, 0,
1402 CJS_Value(pRuntime, pFormControl->GetExportValue().c_str())); 1398 CJS_Value(pRuntime, pFormControl->GetExportValue().c_str()));
1403 } 1399 }
1404 vp << ExportValusArray; 1400 vp << ExportValusArray;
1405 } 1401 }
1406 return TRUE; 1402 return true;
1407 } 1403 }
1408 1404
1409 FX_BOOL Field::fileSelect(IJS_Context* cc, 1405 bool Field::fileSelect(IJS_Context* cc,
1410 CJS_PropValue& vp, 1406 CJS_PropValue& vp,
1411 CFX_WideString& sError) { 1407 CFX_WideString& sError) {
1412 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1408 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1413 if (FieldArray.empty()) 1409 if (FieldArray.empty())
1414 return FALSE; 1410 return false;
1415 1411
1416 CPDF_FormField* pFormField = FieldArray[0]; 1412 CPDF_FormField* pFormField = FieldArray[0];
1417 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) 1413 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
1418 return FALSE; 1414 return false;
1419 1415
1420 if (vp.IsSetting()) { 1416 if (vp.IsSetting()) {
1421 if (!m_bCanSet) 1417 if (!m_bCanSet)
1422 return FALSE; 1418 return false;
1423 1419
1424 bool bVP; 1420 bool bVP;
1425 vp >> bVP; 1421 vp >> bVP;
1426 } else { 1422 } else {
1427 if (pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT) 1423 if (pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT)
1428 vp << true; 1424 vp << true;
1429 else 1425 else
1430 vp << false; 1426 vp << false;
1431 } 1427 }
1432 return TRUE; 1428 return true;
1433 } 1429 }
1434 1430
1435 FX_BOOL Field::fillColor(IJS_Context* cc, 1431 bool Field::fillColor(IJS_Context* cc,
1436 CJS_PropValue& vp, 1432 CJS_PropValue& vp,
1437 CFX_WideString& sError) { 1433 CFX_WideString& sError) {
1438 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); 1434 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
1439 CJS_Array crArray; 1435 CJS_Array crArray;
1440 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1436 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1441 if (FieldArray.empty()) 1437 if (FieldArray.empty())
1442 return FALSE; 1438 return false;
1443 1439
1444 if (vp.IsSetting()) { 1440 if (vp.IsSetting()) {
1445 if (!m_bCanSet) 1441 if (!m_bCanSet)
1446 return FALSE; 1442 return false;
1447 1443
1448 if (!vp.GetJSValue()->IsArrayObject()) 1444 if (!vp.GetJSValue()->IsArrayObject())
1449 return FALSE; 1445 return false;
1450 1446
1451 vp >> crArray; 1447 vp >> crArray;
1452 1448
1453 CPWL_Color color; 1449 CPWL_Color color;
1454 color::ConvertArrayToPWLColor(pRuntime, crArray, &color); 1450 color::ConvertArrayToPWLColor(pRuntime, crArray, &color);
1455 if (m_bDelay) { 1451 if (m_bDelay) {
1456 AddDelay_Color(FP_FILLCOLOR, color); 1452 AddDelay_Color(FP_FILLCOLOR, color);
1457 } else { 1453 } else {
1458 Field::SetFillColor(m_pFormFillEnv.Get(), m_FieldName, 1454 Field::SetFillColor(m_pFormFillEnv.Get(), m_FieldName,
1459 m_nFormControlIndex, color); 1455 m_nFormControlIndex, color);
1460 } 1456 }
1461 } else { 1457 } else {
1462 CPDF_FormField* pFormField = FieldArray[0]; 1458 CPDF_FormField* pFormField = FieldArray[0];
1463 ASSERT(pFormField); 1459 ASSERT(pFormField);
1464 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 1460 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
1465 if (!pFormControl) 1461 if (!pFormControl)
1466 return FALSE; 1462 return false;
1467 1463
1468 int iColorType; 1464 int iColorType;
1469 pFormControl->GetBackgroundColor(iColorType); 1465 pFormControl->GetBackgroundColor(iColorType);
1470 1466
1471 CPWL_Color color; 1467 CPWL_Color color;
1472 if (iColorType == COLORTYPE_TRANSPARENT) { 1468 if (iColorType == COLORTYPE_TRANSPARENT) {
1473 color = CPWL_Color(COLORTYPE_TRANSPARENT); 1469 color = CPWL_Color(COLORTYPE_TRANSPARENT);
1474 } else if (iColorType == COLORTYPE_GRAY) { 1470 } else if (iColorType == COLORTYPE_GRAY) {
1475 color = CPWL_Color(COLORTYPE_GRAY, 1471 color = CPWL_Color(COLORTYPE_GRAY,
1476 pFormControl->GetOriginalBackgroundColor(0)); 1472 pFormControl->GetOriginalBackgroundColor(0));
1477 } else if (iColorType == COLORTYPE_RGB) { 1473 } else if (iColorType == COLORTYPE_RGB) {
1478 color = 1474 color =
1479 CPWL_Color(COLORTYPE_RGB, pFormControl->GetOriginalBackgroundColor(0), 1475 CPWL_Color(COLORTYPE_RGB, pFormControl->GetOriginalBackgroundColor(0),
1480 pFormControl->GetOriginalBackgroundColor(1), 1476 pFormControl->GetOriginalBackgroundColor(1),
1481 pFormControl->GetOriginalBackgroundColor(2)); 1477 pFormControl->GetOriginalBackgroundColor(2));
1482 } else if (iColorType == COLORTYPE_CMYK) { 1478 } else if (iColorType == COLORTYPE_CMYK) {
1483 color = CPWL_Color(COLORTYPE_CMYK, 1479 color = CPWL_Color(COLORTYPE_CMYK,
1484 pFormControl->GetOriginalBackgroundColor(0), 1480 pFormControl->GetOriginalBackgroundColor(0),
1485 pFormControl->GetOriginalBackgroundColor(1), 1481 pFormControl->GetOriginalBackgroundColor(1),
1486 pFormControl->GetOriginalBackgroundColor(2), 1482 pFormControl->GetOriginalBackgroundColor(2),
1487 pFormControl->GetOriginalBackgroundColor(3)); 1483 pFormControl->GetOriginalBackgroundColor(3));
1488 } else { 1484 } else {
1489 return FALSE; 1485 return false;
1490 } 1486 }
1491 1487
1492 color::ConvertPWLColorToArray(pRuntime, color, &crArray); 1488 color::ConvertPWLColorToArray(pRuntime, color, &crArray);
1493 vp << crArray; 1489 vp << crArray;
1494 } 1490 }
1495 1491
1496 return TRUE; 1492 return true;
1497 } 1493 }
1498 1494
1499 void Field::SetFillColor(CPDFSDK_FormFillEnvironment* pFormFillEnv, 1495 void Field::SetFillColor(CPDFSDK_FormFillEnvironment* pFormFillEnv,
1500 const CFX_WideString& swFieldName, 1496 const CFX_WideString& swFieldName,
1501 int nControlIndex, 1497 int nControlIndex,
1502 const CPWL_Color& color) { 1498 const CPWL_Color& color) {
1503 // Not supported. 1499 // Not supported.
1504 } 1500 }
1505 1501
1506 FX_BOOL Field::hidden(IJS_Context* cc, 1502 bool Field::hidden(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
1507 CJS_PropValue& vp,
1508 CFX_WideString& sError) {
1509 if (vp.IsSetting()) { 1503 if (vp.IsSetting()) {
1510 if (!m_bCanSet) 1504 if (!m_bCanSet)
1511 return FALSE; 1505 return false;
1512 1506
1513 bool bVP; 1507 bool bVP;
1514 vp >> bVP; 1508 vp >> bVP;
1515 1509
1516 if (m_bDelay) { 1510 if (m_bDelay) {
1517 AddDelay_Bool(FP_HIDDEN, bVP); 1511 AddDelay_Bool(FP_HIDDEN, bVP);
1518 } else { 1512 } else {
1519 Field::SetHidden(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, 1513 Field::SetHidden(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
1520 bVP); 1514 bVP);
1521 } 1515 }
1522 } else { 1516 } else {
1523 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1517 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1524 if (FieldArray.empty()) 1518 if (FieldArray.empty())
1525 return FALSE; 1519 return false;
1526 1520
1527 CPDF_FormField* pFormField = FieldArray[0]; 1521 CPDF_FormField* pFormField = FieldArray[0];
1528 ASSERT(pFormField); 1522 ASSERT(pFormField);
1529 CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); 1523 CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
1530 CPDFSDK_Widget* pWidget = 1524 CPDFSDK_Widget* pWidget =
1531 pInterForm->GetWidget(GetSmartFieldControl(pFormField), false); 1525 pInterForm->GetWidget(GetSmartFieldControl(pFormField), false);
1532 if (!pWidget) 1526 if (!pWidget)
1533 return FALSE; 1527 return false;
1534 1528
1535 uint32_t dwFlags = pWidget->GetFlags(); 1529 uint32_t dwFlags = pWidget->GetFlags();
1536 1530
1537 if (ANNOTFLAG_INVISIBLE & dwFlags || ANNOTFLAG_HIDDEN & dwFlags) 1531 if (ANNOTFLAG_INVISIBLE & dwFlags || ANNOTFLAG_HIDDEN & dwFlags)
1538 vp << true; 1532 vp << true;
1539 else 1533 else
1540 vp << false; 1534 vp << false;
1541 } 1535 }
1542 1536
1543 return TRUE; 1537 return true;
1544 } 1538 }
1545 1539
1546 void Field::SetHidden(CPDFSDK_FormFillEnvironment* pFormFillEnv, 1540 void Field::SetHidden(CPDFSDK_FormFillEnvironment* pFormFillEnv,
1547 const CFX_WideString& swFieldName, 1541 const CFX_WideString& swFieldName,
1548 int nControlIndex, 1542 int nControlIndex,
1549 bool b) { 1543 bool b) {
1550 int display = b ? 1 /*Hidden*/ : 0 /*Visible*/; 1544 int display = b ? 1 /*Hidden*/ : 0 /*Visible*/;
1551 SetDisplay(pFormFillEnv, swFieldName, nControlIndex, display); 1545 SetDisplay(pFormFillEnv, swFieldName, nControlIndex, display);
1552 } 1546 }
1553 1547
1554 FX_BOOL Field::highlight(IJS_Context* cc, 1548 bool Field::highlight(IJS_Context* cc,
1555 CJS_PropValue& vp, 1549 CJS_PropValue& vp,
1556 CFX_WideString& sError) { 1550 CFX_WideString& sError) {
1557 ASSERT(m_pFormFillEnv); 1551 ASSERT(m_pFormFillEnv);
1558 1552
1559 if (vp.IsSetting()) { 1553 if (vp.IsSetting()) {
1560 if (!m_bCanSet) 1554 if (!m_bCanSet)
1561 return FALSE; 1555 return false;
1562 1556
1563 CFX_ByteString strMode; 1557 CFX_ByteString strMode;
1564 vp >> strMode; 1558 vp >> strMode;
1565 1559
1566 if (m_bDelay) { 1560 if (m_bDelay) {
1567 AddDelay_String(FP_HIGHLIGHT, strMode); 1561 AddDelay_String(FP_HIGHLIGHT, strMode);
1568 } else { 1562 } else {
1569 Field::SetHighlight(m_pFormFillEnv.Get(), m_FieldName, 1563 Field::SetHighlight(m_pFormFillEnv.Get(), m_FieldName,
1570 m_nFormControlIndex, strMode); 1564 m_nFormControlIndex, strMode);
1571 } 1565 }
1572 } else { 1566 } else {
1573 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1567 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1574 if (FieldArray.empty()) 1568 if (FieldArray.empty())
1575 return FALSE; 1569 return false;
1576 1570
1577 CPDF_FormField* pFormField = FieldArray[0]; 1571 CPDF_FormField* pFormField = FieldArray[0];
1578 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) 1572 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
1579 return FALSE; 1573 return false;
1580 1574
1581 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 1575 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
1582 if (!pFormControl) 1576 if (!pFormControl)
1583 return FALSE; 1577 return false;
1584 1578
1585 int eHM = pFormControl->GetHighlightingMode(); 1579 int eHM = pFormControl->GetHighlightingMode();
1586 switch (eHM) { 1580 switch (eHM) {
1587 case CPDF_FormControl::None: 1581 case CPDF_FormControl::None:
1588 vp << L"none"; 1582 vp << L"none";
1589 break; 1583 break;
1590 case CPDF_FormControl::Push: 1584 case CPDF_FormControl::Push:
1591 vp << L"push"; 1585 vp << L"push";
1592 break; 1586 break;
1593 case CPDF_FormControl::Invert: 1587 case CPDF_FormControl::Invert:
1594 vp << L"invert"; 1588 vp << L"invert";
1595 break; 1589 break;
1596 case CPDF_FormControl::Outline: 1590 case CPDF_FormControl::Outline:
1597 vp << L"outline"; 1591 vp << L"outline";
1598 break; 1592 break;
1599 case CPDF_FormControl::Toggle: 1593 case CPDF_FormControl::Toggle:
1600 vp << L"toggle"; 1594 vp << L"toggle";
1601 break; 1595 break;
1602 } 1596 }
1603 } 1597 }
1604 1598
1605 return TRUE; 1599 return true;
1606 } 1600 }
1607 1601
1608 void Field::SetHighlight(CPDFSDK_FormFillEnvironment* pFormFillEnv, 1602 void Field::SetHighlight(CPDFSDK_FormFillEnvironment* pFormFillEnv,
1609 const CFX_WideString& swFieldName, 1603 const CFX_WideString& swFieldName,
1610 int nControlIndex, 1604 int nControlIndex,
1611 const CFX_ByteString& string) { 1605 const CFX_ByteString& string) {
1612 // Not supported. 1606 // Not supported.
1613 } 1607 }
1614 1608
1615 FX_BOOL Field::lineWidth(IJS_Context* cc, 1609 bool Field::lineWidth(IJS_Context* cc,
1616 CJS_PropValue& vp, 1610 CJS_PropValue& vp,
1617 CFX_WideString& sError) { 1611 CFX_WideString& sError) {
1618 if (vp.IsSetting()) { 1612 if (vp.IsSetting()) {
1619 if (!m_bCanSet) 1613 if (!m_bCanSet)
1620 return FALSE; 1614 return false;
1621 1615
1622 int iWidth; 1616 int iWidth;
1623 vp >> iWidth; 1617 vp >> iWidth;
1624 1618
1625 if (m_bDelay) { 1619 if (m_bDelay) {
1626 AddDelay_Int(FP_LINEWIDTH, iWidth); 1620 AddDelay_Int(FP_LINEWIDTH, iWidth);
1627 } else { 1621 } else {
1628 Field::SetLineWidth(m_pFormFillEnv.Get(), m_FieldName, 1622 Field::SetLineWidth(m_pFormFillEnv.Get(), m_FieldName,
1629 m_nFormControlIndex, iWidth); 1623 m_nFormControlIndex, iWidth);
1630 } 1624 }
1631 } else { 1625 } else {
1632 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1626 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1633 if (FieldArray.empty()) 1627 if (FieldArray.empty())
1634 return FALSE; 1628 return false;
1635 1629
1636 CPDF_FormField* pFormField = FieldArray[0]; 1630 CPDF_FormField* pFormField = FieldArray[0];
1637 ASSERT(pFormField); 1631 ASSERT(pFormField);
1638 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 1632 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
1639 if (!pFormControl) 1633 if (!pFormControl)
1640 return FALSE; 1634 return false;
1641 1635
1642 CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); 1636 CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
1643 if (!pFormField->CountControls()) 1637 if (!pFormField->CountControls())
1644 return FALSE; 1638 return false;
1645 1639
1646 CPDFSDK_Widget* pWidget = 1640 CPDFSDK_Widget* pWidget =
1647 pInterForm->GetWidget(pFormField->GetControl(0), false); 1641 pInterForm->GetWidget(pFormField->GetControl(0), false);
1648 if (!pWidget) 1642 if (!pWidget)
1649 return FALSE; 1643 return false;
1650 1644
1651 vp << (int32_t)pWidget->GetBorderWidth(); 1645 vp << (int32_t)pWidget->GetBorderWidth();
1652 } 1646 }
1653 1647
1654 return TRUE; 1648 return true;
1655 } 1649 }
1656 1650
1657 void Field::SetLineWidth(CPDFSDK_FormFillEnvironment* pFormFillEnv, 1651 void Field::SetLineWidth(CPDFSDK_FormFillEnvironment* pFormFillEnv,
1658 const CFX_WideString& swFieldName, 1652 const CFX_WideString& swFieldName,
1659 int nControlIndex, 1653 int nControlIndex,
1660 int number) { 1654 int number) {
1661 CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm(); 1655 CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm();
1662 std::vector<CPDF_FormField*> FieldArray = 1656 std::vector<CPDF_FormField*> FieldArray =
1663 GetFormFields(pFormFillEnv, swFieldName); 1657 GetFormFields(pFormFillEnv, swFieldName);
1664 for (CPDF_FormField* pFormField : FieldArray) { 1658 for (CPDF_FormField* pFormField : FieldArray) {
1665 if (nControlIndex < 0) { 1659 if (nControlIndex < 0) {
1666 FX_BOOL bSet = FALSE; 1660 bool bSet = false;
1667 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { 1661 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) {
1668 CPDF_FormControl* pFormControl = pFormField->GetControl(i); 1662 CPDF_FormControl* pFormControl = pFormField->GetControl(i);
1669 ASSERT(pFormControl); 1663 ASSERT(pFormControl);
1670 1664
1671 if (CPDFSDK_Widget* pWidget = 1665 if (CPDFSDK_Widget* pWidget =
1672 pInterForm->GetWidget(pFormControl, false)) { 1666 pInterForm->GetWidget(pFormControl, false)) {
1673 if (number != pWidget->GetBorderWidth()) { 1667 if (number != pWidget->GetBorderWidth()) {
1674 pWidget->SetBorderWidth(number); 1668 pWidget->SetBorderWidth(number);
1675 bSet = TRUE; 1669 bSet = true;
1676 } 1670 }
1677 } 1671 }
1678 } 1672 }
1679 if (bSet) 1673 if (bSet)
1680 UpdateFormField(pFormFillEnv, pFormField, TRUE, TRUE, TRUE); 1674 UpdateFormField(pFormFillEnv, pFormField, true, true, true);
1681 } else { 1675 } else {
1682 if (nControlIndex >= pFormField->CountControls()) 1676 if (nControlIndex >= pFormField->CountControls())
1683 return; 1677 return;
1684 if (CPDF_FormControl* pFormControl = 1678 if (CPDF_FormControl* pFormControl =
1685 pFormField->GetControl(nControlIndex)) { 1679 pFormField->GetControl(nControlIndex)) {
1686 if (CPDFSDK_Widget* pWidget = 1680 if (CPDFSDK_Widget* pWidget =
1687 pInterForm->GetWidget(pFormControl, false)) { 1681 pInterForm->GetWidget(pFormControl, false)) {
1688 if (number != pWidget->GetBorderWidth()) { 1682 if (number != pWidget->GetBorderWidth()) {
1689 pWidget->SetBorderWidth(number); 1683 pWidget->SetBorderWidth(number);
1690 UpdateFormControl(pFormFillEnv, pFormControl, TRUE, TRUE, TRUE); 1684 UpdateFormControl(pFormFillEnv, pFormControl, true, true, true);
1691 } 1685 }
1692 } 1686 }
1693 } 1687 }
1694 } 1688 }
1695 } 1689 }
1696 } 1690 }
1697 1691
1698 FX_BOOL Field::multiline(IJS_Context* cc, 1692 bool Field::multiline(IJS_Context* cc,
1699 CJS_PropValue& vp, 1693 CJS_PropValue& vp,
1700 CFX_WideString& sError) { 1694 CFX_WideString& sError) {
1701 ASSERT(m_pFormFillEnv); 1695 ASSERT(m_pFormFillEnv);
1702 1696
1703 if (vp.IsSetting()) { 1697 if (vp.IsSetting()) {
1704 if (!m_bCanSet) 1698 if (!m_bCanSet)
1705 return FALSE; 1699 return false;
1706 1700
1707 bool bVP; 1701 bool bVP;
1708 vp >> bVP; 1702 vp >> bVP;
1709 1703
1710 if (m_bDelay) { 1704 if (m_bDelay) {
1711 AddDelay_Bool(FP_MULTILINE, bVP); 1705 AddDelay_Bool(FP_MULTILINE, bVP);
1712 } else { 1706 } else {
1713 Field::SetMultiline(m_pFormFillEnv.Get(), m_FieldName, 1707 Field::SetMultiline(m_pFormFillEnv.Get(), m_FieldName,
1714 m_nFormControlIndex, bVP); 1708 m_nFormControlIndex, bVP);
1715 } 1709 }
1716 } else { 1710 } else {
1717 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1711 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1718 if (FieldArray.empty()) 1712 if (FieldArray.empty())
1719 return FALSE; 1713 return false;
1720 1714
1721 CPDF_FormField* pFormField = FieldArray[0]; 1715 CPDF_FormField* pFormField = FieldArray[0];
1722 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) 1716 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
1723 return FALSE; 1717 return false;
1724 1718
1725 if (pFormField->GetFieldFlags() & FIELDFLAG_MULTILINE) 1719 if (pFormField->GetFieldFlags() & FIELDFLAG_MULTILINE)
1726 vp << true; 1720 vp << true;
1727 else 1721 else
1728 vp << false; 1722 vp << false;
1729 } 1723 }
1730 1724
1731 return TRUE; 1725 return true;
1732 } 1726 }
1733 1727
1734 void Field::SetMultiline(CPDFSDK_FormFillEnvironment* pFormFillEnv, 1728 void Field::SetMultiline(CPDFSDK_FormFillEnvironment* pFormFillEnv,
1735 const CFX_WideString& swFieldName, 1729 const CFX_WideString& swFieldName,
1736 int nControlIndex, 1730 int nControlIndex,
1737 bool b) { 1731 bool b) {
1738 // Not supported. 1732 // Not supported.
1739 } 1733 }
1740 1734
1741 FX_BOOL Field::multipleSelection(IJS_Context* cc, 1735 bool Field::multipleSelection(IJS_Context* cc,
1742 CJS_PropValue& vp, 1736 CJS_PropValue& vp,
1743 CFX_WideString& sError) { 1737 CFX_WideString& sError) {
1744 ASSERT(m_pFormFillEnv); 1738 ASSERT(m_pFormFillEnv);
1745 1739
1746 if (vp.IsSetting()) { 1740 if (vp.IsSetting()) {
1747 if (!m_bCanSet) 1741 if (!m_bCanSet)
1748 return FALSE; 1742 return false;
1749 1743
1750 bool bVP; 1744 bool bVP;
1751 vp >> bVP; 1745 vp >> bVP;
1752 1746
1753 if (m_bDelay) { 1747 if (m_bDelay) {
1754 AddDelay_Bool(FP_MULTIPLESELECTION, bVP); 1748 AddDelay_Bool(FP_MULTIPLESELECTION, bVP);
1755 } else { 1749 } else {
1756 Field::SetMultipleSelection(m_pFormFillEnv.Get(), m_FieldName, 1750 Field::SetMultipleSelection(m_pFormFillEnv.Get(), m_FieldName,
1757 m_nFormControlIndex, bVP); 1751 m_nFormControlIndex, bVP);
1758 } 1752 }
1759 } else { 1753 } else {
1760 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1754 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1761 if (FieldArray.empty()) 1755 if (FieldArray.empty())
1762 return FALSE; 1756 return false;
1763 1757
1764 CPDF_FormField* pFormField = FieldArray[0]; 1758 CPDF_FormField* pFormField = FieldArray[0];
1765 if (pFormField->GetFieldType() != FIELDTYPE_LISTBOX) 1759 if (pFormField->GetFieldType() != FIELDTYPE_LISTBOX)
1766 return FALSE; 1760 return false;
1767 1761
1768 if (pFormField->GetFieldFlags() & FIELDFLAG_MULTISELECT) 1762 if (pFormField->GetFieldFlags() & FIELDFLAG_MULTISELECT)
1769 vp << true; 1763 vp << true;
1770 else 1764 else
1771 vp << false; 1765 vp << false;
1772 } 1766 }
1773 1767
1774 return TRUE; 1768 return true;
1775 } 1769 }
1776 1770
1777 void Field::SetMultipleSelection(CPDFSDK_FormFillEnvironment* pFormFillEnv, 1771 void Field::SetMultipleSelection(CPDFSDK_FormFillEnvironment* pFormFillEnv,
1778 const CFX_WideString& swFieldName, 1772 const CFX_WideString& swFieldName,
1779 int nControlIndex, 1773 int nControlIndex,
1780 bool b) { 1774 bool b) {
1781 // Not supported. 1775 // Not supported.
1782 } 1776 }
1783 1777
1784 FX_BOOL Field::name(IJS_Context* cc, 1778 bool Field::name(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
1785 CJS_PropValue& vp,
1786 CFX_WideString& sError) {
1787 if (!vp.IsGetting()) 1779 if (!vp.IsGetting())
1788 return FALSE; 1780 return false;
1789 1781
1790 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1782 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1791 if (FieldArray.empty()) 1783 if (FieldArray.empty())
1792 return FALSE; 1784 return false;
1793 1785
1794 vp << m_FieldName; 1786 vp << m_FieldName;
1795 1787
1796 return TRUE; 1788 return true;
1797 } 1789 }
1798 1790
1799 FX_BOOL Field::numItems(IJS_Context* cc, 1791 bool Field::numItems(IJS_Context* cc,
1800 CJS_PropValue& vp, 1792 CJS_PropValue& vp,
1801 CFX_WideString& sError) { 1793 CFX_WideString& sError) {
1802 if (!vp.IsGetting()) 1794 if (!vp.IsGetting())
1803 return FALSE; 1795 return false;
1804 1796
1805 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1797 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1806 if (FieldArray.empty()) 1798 if (FieldArray.empty())
1807 return FALSE; 1799 return false;
1808 1800
1809 CPDF_FormField* pFormField = FieldArray[0]; 1801 CPDF_FormField* pFormField = FieldArray[0];
1810 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && 1802 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX &&
1811 pFormField->GetFieldType() != FIELDTYPE_LISTBOX) { 1803 pFormField->GetFieldType() != FIELDTYPE_LISTBOX) {
1812 return FALSE; 1804 return false;
1813 } 1805 }
1814 1806
1815 vp << (int32_t)pFormField->CountOptions(); 1807 vp << (int32_t)pFormField->CountOptions();
1816 return TRUE; 1808 return true;
1817 } 1809 }
1818 1810
1819 FX_BOOL Field::page(IJS_Context* cc, 1811 bool Field::page(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
1820 CJS_PropValue& vp,
1821 CFX_WideString& sError) {
1822 if (!vp.IsGetting()) 1812 if (!vp.IsGetting())
1823 return FALSE; 1813 return false;
1824 1814
1825 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1815 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1826 if (FieldArray.empty()) 1816 if (FieldArray.empty())
1827 return FALSE; 1817 return false;
1828 1818
1829 CPDF_FormField* pFormField = FieldArray[0]; 1819 CPDF_FormField* pFormField = FieldArray[0];
1830 if (!pFormField) 1820 if (!pFormField)
1831 return FALSE; 1821 return false;
1832 1822
1833 std::vector<CPDFSDK_Widget*> widgets; 1823 std::vector<CPDFSDK_Widget*> widgets;
1834 m_pFormFillEnv->GetInterForm()->GetWidgets(pFormField, &widgets); 1824 m_pFormFillEnv->GetInterForm()->GetWidgets(pFormField, &widgets);
1835 1825
1836 if (widgets.empty()) { 1826 if (widgets.empty()) {
1837 vp << (int32_t)-1; 1827 vp << (int32_t)-1;
1838 return TRUE; 1828 return true;
1839 } 1829 }
1840 1830
1841 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); 1831 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
1842 CJS_Array PageArray; 1832 CJS_Array PageArray;
1843 for (size_t i = 0; i < widgets.size(); ++i) { 1833 for (size_t i = 0; i < widgets.size(); ++i) {
1844 CPDFSDK_PageView* pPageView = widgets[i]->GetPageView(); 1834 CPDFSDK_PageView* pPageView = widgets[i]->GetPageView();
1845 if (!pPageView) 1835 if (!pPageView)
1846 return FALSE; 1836 return false;
1847 1837
1848 PageArray.SetElement( 1838 PageArray.SetElement(
1849 pRuntime, i, CJS_Value(pRuntime, (int32_t)pPageView->GetPageIndex())); 1839 pRuntime, i, CJS_Value(pRuntime, (int32_t)pPageView->GetPageIndex()));
1850 } 1840 }
1851 1841
1852 vp << PageArray; 1842 vp << PageArray;
1853 return TRUE; 1843 return true;
1854 } 1844 }
1855 1845
1856 FX_BOOL Field::password(IJS_Context* cc, 1846 bool Field::password(IJS_Context* cc,
1857 CJS_PropValue& vp, 1847 CJS_PropValue& vp,
1858 CFX_WideString& sError) { 1848 CFX_WideString& sError) {
1859 ASSERT(m_pFormFillEnv); 1849 ASSERT(m_pFormFillEnv);
1860 1850
1861 if (vp.IsSetting()) { 1851 if (vp.IsSetting()) {
1862 if (!m_bCanSet) 1852 if (!m_bCanSet)
1863 return FALSE; 1853 return false;
1864 1854
1865 bool bVP; 1855 bool bVP;
1866 vp >> bVP; 1856 vp >> bVP;
1867 1857
1868 if (m_bDelay) { 1858 if (m_bDelay) {
1869 AddDelay_Bool(FP_PASSWORD, bVP); 1859 AddDelay_Bool(FP_PASSWORD, bVP);
1870 } else { 1860 } else {
1871 Field::SetPassword(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, 1861 Field::SetPassword(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
1872 bVP); 1862 bVP);
1873 } 1863 }
1874 } else { 1864 } else {
1875 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1865 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1876 if (FieldArray.empty()) 1866 if (FieldArray.empty())
1877 return FALSE; 1867 return false;
1878 1868
1879 CPDF_FormField* pFormField = FieldArray[0]; 1869 CPDF_FormField* pFormField = FieldArray[0];
1880 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) 1870 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
1881 return FALSE; 1871 return false;
1882 1872
1883 if (pFormField->GetFieldFlags() & FIELDFLAG_PASSWORD) 1873 if (pFormField->GetFieldFlags() & FIELDFLAG_PASSWORD)
1884 vp << true; 1874 vp << true;
1885 else 1875 else
1886 vp << false; 1876 vp << false;
1887 } 1877 }
1888 1878
1889 return TRUE; 1879 return true;
1890 } 1880 }
1891 1881
1892 void Field::SetPassword(CPDFSDK_FormFillEnvironment* pFormFillEnv, 1882 void Field::SetPassword(CPDFSDK_FormFillEnvironment* pFormFillEnv,
1893 const CFX_WideString& swFieldName, 1883 const CFX_WideString& swFieldName,
1894 int nControlIndex, 1884 int nControlIndex,
1895 bool b) { 1885 bool b) {
1896 // Not supported. 1886 // Not supported.
1897 } 1887 }
1898 1888
1899 FX_BOOL Field::print(IJS_Context* cc, 1889 bool Field::print(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
1900 CJS_PropValue& vp,
1901 CFX_WideString& sError) {
1902 CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); 1890 CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
1903 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1891 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1904 if (FieldArray.empty()) 1892 if (FieldArray.empty())
1905 return FALSE; 1893 return false;
1906 1894
1907 if (vp.IsSetting()) { 1895 if (vp.IsSetting()) {
1908 if (!m_bCanSet) 1896 if (!m_bCanSet)
1909 return FALSE; 1897 return false;
1910 1898
1911 bool bVP; 1899 bool bVP;
1912 vp >> bVP; 1900 vp >> bVP;
1913 1901
1914 for (CPDF_FormField* pFormField : FieldArray) { 1902 for (CPDF_FormField* pFormField : FieldArray) {
1915 if (m_nFormControlIndex < 0) { 1903 if (m_nFormControlIndex < 0) {
1916 FX_BOOL bSet = FALSE; 1904 bool bSet = false;
1917 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { 1905 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) {
1918 if (CPDFSDK_Widget* pWidget = 1906 if (CPDFSDK_Widget* pWidget =
1919 pInterForm->GetWidget(pFormField->GetControl(i), false)) { 1907 pInterForm->GetWidget(pFormField->GetControl(i), false)) {
1920 uint32_t dwFlags = pWidget->GetFlags(); 1908 uint32_t dwFlags = pWidget->GetFlags();
1921 if (bVP) 1909 if (bVP)
1922 dwFlags |= ANNOTFLAG_PRINT; 1910 dwFlags |= ANNOTFLAG_PRINT;
1923 else 1911 else
1924 dwFlags &= ~ANNOTFLAG_PRINT; 1912 dwFlags &= ~ANNOTFLAG_PRINT;
1925 1913
1926 if (dwFlags != pWidget->GetFlags()) { 1914 if (dwFlags != pWidget->GetFlags()) {
1927 pWidget->SetFlags(dwFlags); 1915 pWidget->SetFlags(dwFlags);
1928 bSet = TRUE; 1916 bSet = true;
1929 } 1917 }
1930 } 1918 }
1931 } 1919 }
1932 1920
1933 if (bSet) 1921 if (bSet)
1934 UpdateFormField(m_pFormFillEnv.Get(), pFormField, TRUE, FALSE, TRUE); 1922 UpdateFormField(m_pFormFillEnv.Get(), pFormField, true, false, true);
1935 } else { 1923 } else {
1936 if (m_nFormControlIndex >= pFormField->CountControls()) 1924 if (m_nFormControlIndex >= pFormField->CountControls())
1937 return FALSE; 1925 return false;
1938 if (CPDF_FormControl* pFormControl = 1926 if (CPDF_FormControl* pFormControl =
1939 pFormField->GetControl(m_nFormControlIndex)) { 1927 pFormField->GetControl(m_nFormControlIndex)) {
1940 if (CPDFSDK_Widget* pWidget = 1928 if (CPDFSDK_Widget* pWidget =
1941 pInterForm->GetWidget(pFormControl, true)) { 1929 pInterForm->GetWidget(pFormControl, true)) {
1942 uint32_t dwFlags = pWidget->GetFlags(); 1930 uint32_t dwFlags = pWidget->GetFlags();
1943 if (bVP) 1931 if (bVP)
1944 dwFlags |= ANNOTFLAG_PRINT; 1932 dwFlags |= ANNOTFLAG_PRINT;
1945 else 1933 else
1946 dwFlags &= ~ANNOTFLAG_PRINT; 1934 dwFlags &= ~ANNOTFLAG_PRINT;
1947 1935
1948 if (dwFlags != pWidget->GetFlags()) { 1936 if (dwFlags != pWidget->GetFlags()) {
1949 pWidget->SetFlags(dwFlags); 1937 pWidget->SetFlags(dwFlags);
1950 UpdateFormControl(m_pFormFillEnv.Get(), 1938 UpdateFormControl(m_pFormFillEnv.Get(),
1951 pFormField->GetControl(m_nFormControlIndex), 1939 pFormField->GetControl(m_nFormControlIndex),
1952 TRUE, FALSE, TRUE); 1940 true, false, true);
1953 } 1941 }
1954 } 1942 }
1955 } 1943 }
1956 } 1944 }
1957 } 1945 }
1958 } else { 1946 } else {
1959 CPDF_FormField* pFormField = FieldArray[0]; 1947 CPDF_FormField* pFormField = FieldArray[0];
1960 CPDFSDK_Widget* pWidget = 1948 CPDFSDK_Widget* pWidget =
1961 pInterForm->GetWidget(GetSmartFieldControl(pFormField), true); 1949 pInterForm->GetWidget(GetSmartFieldControl(pFormField), true);
1962 if (!pWidget) 1950 if (!pWidget)
1963 return FALSE; 1951 return false;
1964 1952
1965 if (pWidget->GetFlags() & ANNOTFLAG_PRINT) 1953 if (pWidget->GetFlags() & ANNOTFLAG_PRINT)
1966 vp << true; 1954 vp << true;
1967 else 1955 else
1968 vp << false; 1956 vp << false;
1969 } 1957 }
1970 1958
1971 return TRUE; 1959 return true;
1972 } 1960 }
1973 1961
1974 FX_BOOL Field::radiosInUnison(IJS_Context* cc, 1962 bool Field::radiosInUnison(IJS_Context* cc,
1975 CJS_PropValue& vp, 1963 CJS_PropValue& vp,
1976 CFX_WideString& sError) { 1964 CFX_WideString& sError) {
1977 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1965 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1978 if (FieldArray.empty()) 1966 if (FieldArray.empty())
1979 return FALSE; 1967 return false;
1980 1968
1981 if (vp.IsSetting()) { 1969 if (vp.IsSetting()) {
1982 if (!m_bCanSet) 1970 if (!m_bCanSet)
1983 return FALSE; 1971 return false;
1984 1972
1985 bool bVP; 1973 bool bVP;
1986 vp >> bVP; 1974 vp >> bVP;
1987 1975
1988 } else { 1976 } else {
1989 CPDF_FormField* pFormField = FieldArray[0]; 1977 CPDF_FormField* pFormField = FieldArray[0];
1990 if (pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON) 1978 if (pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON)
1991 return FALSE; 1979 return false;
1992 1980
1993 if (pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON) 1981 if (pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON)
1994 vp << true; 1982 vp << true;
1995 else 1983 else
1996 vp << false; 1984 vp << false;
1997 } 1985 }
1998 1986
1999 return TRUE; 1987 return true;
2000 } 1988 }
2001 1989
2002 FX_BOOL Field::readonly(IJS_Context* cc, 1990 bool Field::readonly(IJS_Context* cc,
2003 CJS_PropValue& vp, 1991 CJS_PropValue& vp,
2004 CFX_WideString& sError) { 1992 CFX_WideString& sError) {
2005 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1993 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
2006 if (FieldArray.empty()) 1994 if (FieldArray.empty())
2007 return FALSE; 1995 return false;
2008 1996
2009 if (vp.IsSetting()) { 1997 if (vp.IsSetting()) {
2010 if (!m_bCanSet) 1998 if (!m_bCanSet)
2011 return FALSE; 1999 return false;
2012 2000
2013 bool bVP; 2001 bool bVP;
2014 vp >> bVP; 2002 vp >> bVP;
2015 2003
2016 } else { 2004 } else {
2017 CPDF_FormField* pFormField = FieldArray[0]; 2005 CPDF_FormField* pFormField = FieldArray[0];
2018 if (pFormField->GetFieldFlags() & FIELDFLAG_READONLY) 2006 if (pFormField->GetFieldFlags() & FIELDFLAG_READONLY)
2019 vp << true; 2007 vp << true;
2020 else 2008 else
2021 vp << false; 2009 vp << false;
2022 } 2010 }
2023 2011
2024 return TRUE; 2012 return true;
2025 } 2013 }
2026 2014
2027 FX_BOOL Field::rect(IJS_Context* cc, 2015 bool Field::rect(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
2028 CJS_PropValue& vp,
2029 CFX_WideString& sError) {
2030 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); 2016 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
2031 CJS_Value Upper_Leftx(pRuntime); 2017 CJS_Value Upper_Leftx(pRuntime);
2032 CJS_Value Upper_Lefty(pRuntime); 2018 CJS_Value Upper_Lefty(pRuntime);
2033 CJS_Value Lower_Rightx(pRuntime); 2019 CJS_Value Lower_Rightx(pRuntime);
2034 CJS_Value Lower_Righty(pRuntime); 2020 CJS_Value Lower_Righty(pRuntime);
2035 2021
2036 if (vp.IsSetting()) { 2022 if (vp.IsSetting()) {
2037 if (!m_bCanSet) 2023 if (!m_bCanSet)
2038 return FALSE; 2024 return false;
2039 if (!vp.GetJSValue()->IsArrayObject()) 2025 if (!vp.GetJSValue()->IsArrayObject())
2040 return FALSE; 2026 return false;
2041 2027
2042 CJS_Array rcArray; 2028 CJS_Array rcArray;
2043 vp >> rcArray; 2029 vp >> rcArray;
2044 rcArray.GetElement(pRuntime, 0, Upper_Leftx); 2030 rcArray.GetElement(pRuntime, 0, Upper_Leftx);
2045 rcArray.GetElement(pRuntime, 1, Upper_Lefty); 2031 rcArray.GetElement(pRuntime, 1, Upper_Lefty);
2046 rcArray.GetElement(pRuntime, 2, Lower_Rightx); 2032 rcArray.GetElement(pRuntime, 2, Lower_Rightx);
2047 rcArray.GetElement(pRuntime, 3, Lower_Righty); 2033 rcArray.GetElement(pRuntime, 3, Lower_Righty);
2048 2034
2049 FX_FLOAT pArray[4] = {0.0f, 0.0f, 0.0f, 0.0f}; 2035 FX_FLOAT pArray[4] = {0.0f, 0.0f, 0.0f, 0.0f};
2050 pArray[0] = static_cast<FX_FLOAT>(Upper_Leftx.ToInt(pRuntime)); 2036 pArray[0] = static_cast<FX_FLOAT>(Upper_Leftx.ToInt(pRuntime));
2051 pArray[1] = static_cast<FX_FLOAT>(Lower_Righty.ToInt(pRuntime)); 2037 pArray[1] = static_cast<FX_FLOAT>(Lower_Righty.ToInt(pRuntime));
2052 pArray[2] = static_cast<FX_FLOAT>(Lower_Rightx.ToInt(pRuntime)); 2038 pArray[2] = static_cast<FX_FLOAT>(Lower_Rightx.ToInt(pRuntime));
2053 pArray[3] = static_cast<FX_FLOAT>(Upper_Lefty.ToInt(pRuntime)); 2039 pArray[3] = static_cast<FX_FLOAT>(Upper_Lefty.ToInt(pRuntime));
2054 2040
2055 CFX_FloatRect crRect(pArray); 2041 CFX_FloatRect crRect(pArray);
2056 if (m_bDelay) { 2042 if (m_bDelay) {
2057 AddDelay_Rect(FP_RECT, crRect); 2043 AddDelay_Rect(FP_RECT, crRect);
2058 } else { 2044 } else {
2059 Field::SetRect(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, 2045 Field::SetRect(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
2060 crRect); 2046 crRect);
2061 } 2047 }
2062 } else { 2048 } else {
2063 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 2049 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
2064 if (FieldArray.empty()) 2050 if (FieldArray.empty())
2065 return FALSE; 2051 return false;
2066 2052
2067 CPDF_FormField* pFormField = FieldArray[0]; 2053 CPDF_FormField* pFormField = FieldArray[0];
2068 CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); 2054 CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
2069 CPDFSDK_Widget* pWidget = 2055 CPDFSDK_Widget* pWidget =
2070 pInterForm->GetWidget(GetSmartFieldControl(pFormField), true); 2056 pInterForm->GetWidget(GetSmartFieldControl(pFormField), true);
2071 if (!pWidget) 2057 if (!pWidget)
2072 return FALSE; 2058 return false;
2073 2059
2074 CFX_FloatRect crRect = pWidget->GetRect(); 2060 CFX_FloatRect crRect = pWidget->GetRect();
2075 Upper_Leftx = CJS_Value(pRuntime, static_cast<int32_t>(crRect.left)); 2061 Upper_Leftx = CJS_Value(pRuntime, static_cast<int32_t>(crRect.left));
2076 Upper_Lefty = CJS_Value(pRuntime, static_cast<int32_t>(crRect.top)); 2062 Upper_Lefty = CJS_Value(pRuntime, static_cast<int32_t>(crRect.top));
2077 Lower_Rightx = CJS_Value(pRuntime, static_cast<int32_t>(crRect.right)); 2063 Lower_Rightx = CJS_Value(pRuntime, static_cast<int32_t>(crRect.right));
2078 Lower_Righty = CJS_Value(pRuntime, static_cast<int32_t>(crRect.bottom)); 2064 Lower_Righty = CJS_Value(pRuntime, static_cast<int32_t>(crRect.bottom));
2079 2065
2080 CJS_Array rcArray; 2066 CJS_Array rcArray;
2081 rcArray.SetElement(pRuntime, 0, Upper_Leftx); 2067 rcArray.SetElement(pRuntime, 0, Upper_Leftx);
2082 rcArray.SetElement(pRuntime, 1, Upper_Lefty); 2068 rcArray.SetElement(pRuntime, 1, Upper_Lefty);
2083 rcArray.SetElement(pRuntime, 2, Lower_Rightx); 2069 rcArray.SetElement(pRuntime, 2, Lower_Rightx);
2084 rcArray.SetElement(pRuntime, 3, Lower_Righty); 2070 rcArray.SetElement(pRuntime, 3, Lower_Righty);
2085 vp << rcArray; 2071 vp << rcArray;
2086 } 2072 }
2087 return TRUE; 2073 return true;
2088 } 2074 }
2089 2075
2090 void Field::SetRect(CPDFSDK_FormFillEnvironment* pFormFillEnv, 2076 void Field::SetRect(CPDFSDK_FormFillEnvironment* pFormFillEnv,
2091 const CFX_WideString& swFieldName, 2077 const CFX_WideString& swFieldName,
2092 int nControlIndex, 2078 int nControlIndex,
2093 const CFX_FloatRect& rect) { 2079 const CFX_FloatRect& rect) {
2094 CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm(); 2080 CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm();
2095 std::vector<CPDF_FormField*> FieldArray = 2081 std::vector<CPDF_FormField*> FieldArray =
2096 GetFormFields(pFormFillEnv, swFieldName); 2082 GetFormFields(pFormFillEnv, swFieldName);
2097 for (CPDF_FormField* pFormField : FieldArray) { 2083 for (CPDF_FormField* pFormField : FieldArray) {
2098 if (nControlIndex < 0) { 2084 if (nControlIndex < 0) {
2099 FX_BOOL bSet = FALSE; 2085 bool bSet = false;
2100 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { 2086 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) {
2101 CPDF_FormControl* pFormControl = pFormField->GetControl(i); 2087 CPDF_FormControl* pFormControl = pFormField->GetControl(i);
2102 ASSERT(pFormControl); 2088 ASSERT(pFormControl);
2103 2089
2104 if (CPDFSDK_Widget* pWidget = 2090 if (CPDFSDK_Widget* pWidget =
2105 pInterForm->GetWidget(pFormControl, false)) { 2091 pInterForm->GetWidget(pFormControl, false)) {
2106 CFX_FloatRect crRect = rect; 2092 CFX_FloatRect crRect = rect;
2107 2093
2108 CPDF_Page* pPDFPage = pWidget->GetPDFPage(); 2094 CPDF_Page* pPDFPage = pWidget->GetPDFPage();
2109 crRect.Intersect(pPDFPage->GetPageBBox()); 2095 crRect.Intersect(pPDFPage->GetPageBBox());
2110 2096
2111 if (!crRect.IsEmpty()) { 2097 if (!crRect.IsEmpty()) {
2112 CFX_FloatRect rcOld = pWidget->GetRect(); 2098 CFX_FloatRect rcOld = pWidget->GetRect();
2113 if (crRect.left != rcOld.left || crRect.right != rcOld.right || 2099 if (crRect.left != rcOld.left || crRect.right != rcOld.right ||
2114 crRect.top != rcOld.top || crRect.bottom != rcOld.bottom) { 2100 crRect.top != rcOld.top || crRect.bottom != rcOld.bottom) {
2115 pWidget->SetRect(crRect); 2101 pWidget->SetRect(crRect);
2116 bSet = TRUE; 2102 bSet = true;
2117 } 2103 }
2118 } 2104 }
2119 } 2105 }
2120 } 2106 }
2121 2107
2122 if (bSet) 2108 if (bSet)
2123 UpdateFormField(pFormFillEnv, pFormField, TRUE, TRUE, TRUE); 2109 UpdateFormField(pFormFillEnv, pFormField, true, true, true);
2124 } else { 2110 } else {
2125 if (nControlIndex >= pFormField->CountControls()) 2111 if (nControlIndex >= pFormField->CountControls())
2126 return; 2112 return;
2127 if (CPDF_FormControl* pFormControl = 2113 if (CPDF_FormControl* pFormControl =
2128 pFormField->GetControl(nControlIndex)) { 2114 pFormField->GetControl(nControlIndex)) {
2129 if (CPDFSDK_Widget* pWidget = 2115 if (CPDFSDK_Widget* pWidget =
2130 pInterForm->GetWidget(pFormControl, false)) { 2116 pInterForm->GetWidget(pFormControl, false)) {
2131 CFX_FloatRect crRect = rect; 2117 CFX_FloatRect crRect = rect;
2132 2118
2133 CPDF_Page* pPDFPage = pWidget->GetPDFPage(); 2119 CPDF_Page* pPDFPage = pWidget->GetPDFPage();
2134 crRect.Intersect(pPDFPage->GetPageBBox()); 2120 crRect.Intersect(pPDFPage->GetPageBBox());
2135 2121
2136 if (!crRect.IsEmpty()) { 2122 if (!crRect.IsEmpty()) {
2137 CFX_FloatRect rcOld = pWidget->GetRect(); 2123 CFX_FloatRect rcOld = pWidget->GetRect();
2138 if (crRect.left != rcOld.left || crRect.right != rcOld.right || 2124 if (crRect.left != rcOld.left || crRect.right != rcOld.right ||
2139 crRect.top != rcOld.top || crRect.bottom != rcOld.bottom) { 2125 crRect.top != rcOld.top || crRect.bottom != rcOld.bottom) {
2140 pWidget->SetRect(crRect); 2126 pWidget->SetRect(crRect);
2141 UpdateFormControl(pFormFillEnv, pFormControl, TRUE, TRUE, TRUE); 2127 UpdateFormControl(pFormFillEnv, pFormControl, true, true, true);
2142 } 2128 }
2143 } 2129 }
2144 } 2130 }
2145 } 2131 }
2146 } 2132 }
2147 } 2133 }
2148 } 2134 }
2149 2135
2150 FX_BOOL Field::required(IJS_Context* cc, 2136 bool Field::required(IJS_Context* cc,
2151 CJS_PropValue& vp, 2137 CJS_PropValue& vp,
2152 CFX_WideString& sError) { 2138 CFX_WideString& sError) {
2153 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 2139 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
2154 if (FieldArray.empty()) 2140 if (FieldArray.empty())
2155 return FALSE; 2141 return false;
2156 2142
2157 if (vp.IsSetting()) { 2143 if (vp.IsSetting()) {
2158 if (!m_bCanSet) 2144 if (!m_bCanSet)
2159 return FALSE; 2145 return false;
2160 2146
2161 bool bVP; 2147 bool bVP;
2162 vp >> bVP; 2148 vp >> bVP;
2163 2149
2164 } else { 2150 } else {
2165 CPDF_FormField* pFormField = FieldArray[0]; 2151 CPDF_FormField* pFormField = FieldArray[0];
2166 if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON) 2152 if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON)
2167 return FALSE; 2153 return false;
2168 2154
2169 if (pFormField->GetFieldFlags() & FIELDFLAG_REQUIRED) 2155 if (pFormField->GetFieldFlags() & FIELDFLAG_REQUIRED)
2170 vp << true; 2156 vp << true;
2171 else 2157 else
2172 vp << false; 2158 vp << false;
2173 } 2159 }
2174 2160
2175 return TRUE; 2161 return true;
2176 } 2162 }
2177 2163
2178 FX_BOOL Field::richText(IJS_Context* cc, 2164 bool Field::richText(IJS_Context* cc,
2179 CJS_PropValue& vp, 2165 CJS_PropValue& vp,
2180 CFX_WideString& sError) { 2166 CFX_WideString& sError) {
2181 ASSERT(m_pFormFillEnv); 2167 ASSERT(m_pFormFillEnv);
2182 2168
2183 if (vp.IsSetting()) { 2169 if (vp.IsSetting()) {
2184 if (!m_bCanSet) 2170 if (!m_bCanSet)
2185 return FALSE; 2171 return false;
2186 2172
2187 bool bVP; 2173 bool bVP;
2188 vp >> bVP; 2174 vp >> bVP;
2189 2175
2190 if (m_bDelay) { 2176 if (m_bDelay) {
2191 AddDelay_Bool(FP_RICHTEXT, bVP); 2177 AddDelay_Bool(FP_RICHTEXT, bVP);
2192 } 2178 }
2193 } else { 2179 } else {
2194 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 2180 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
2195 if (FieldArray.empty()) 2181 if (FieldArray.empty())
2196 return FALSE; 2182 return false;
2197 2183
2198 CPDF_FormField* pFormField = FieldArray[0]; 2184 CPDF_FormField* pFormField = FieldArray[0];
2199 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) 2185 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
2200 return FALSE; 2186 return false;
2201 2187
2202 if (pFormField->GetFieldFlags() & FIELDFLAG_RICHTEXT) 2188 if (pFormField->GetFieldFlags() & FIELDFLAG_RICHTEXT)
2203 vp << true; 2189 vp << true;
2204 else 2190 else
2205 vp << false; 2191 vp << false;
2206 } 2192 }
2207 2193
2208 return TRUE; 2194 return true;
2209 } 2195 }
2210 2196
2211 FX_BOOL Field::richValue(IJS_Context* cc, 2197 bool Field::richValue(IJS_Context* cc,
2212 CJS_PropValue& vp, 2198 CJS_PropValue& vp,
2213 CFX_WideString& sError) { 2199 CFX_WideString& sError) {
2214 return TRUE; 2200 return true;
2215 } 2201 }
2216 2202
2217 FX_BOOL Field::rotation(IJS_Context* cc, 2203 bool Field::rotation(IJS_Context* cc,
2218 CJS_PropValue& vp, 2204 CJS_PropValue& vp,
2219 CFX_WideString& sError) { 2205 CFX_WideString& sError) {
2220 ASSERT(m_pFormFillEnv); 2206 ASSERT(m_pFormFillEnv);
2221 2207
2222 if (vp.IsSetting()) { 2208 if (vp.IsSetting()) {
2223 if (!m_bCanSet) 2209 if (!m_bCanSet)
2224 return FALSE; 2210 return false;
2225 2211
2226 int nVP; 2212 int nVP;
2227 vp >> nVP; 2213 vp >> nVP;
2228 2214
2229 if (m_bDelay) { 2215 if (m_bDelay) {
2230 AddDelay_Int(FP_ROTATION, nVP); 2216 AddDelay_Int(FP_ROTATION, nVP);
2231 } else { 2217 } else {
2232 Field::SetRotation(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, 2218 Field::SetRotation(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
2233 nVP); 2219 nVP);
2234 } 2220 }
2235 } else { 2221 } else {
2236 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 2222 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
2237 if (FieldArray.empty()) 2223 if (FieldArray.empty())
2238 return FALSE; 2224 return false;
2239 2225
2240 CPDF_FormField* pFormField = FieldArray[0]; 2226 CPDF_FormField* pFormField = FieldArray[0];
2241 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 2227 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
2242 if (!pFormControl) 2228 if (!pFormControl)
2243 return FALSE; 2229 return false;
2244 2230
2245 vp << (int32_t)pFormControl->GetRotation(); 2231 vp << (int32_t)pFormControl->GetRotation();
2246 } 2232 }
2247 2233
2248 return TRUE; 2234 return true;
2249 } 2235 }
2250 2236
2251 void Field::SetRotation(CPDFSDK_FormFillEnvironment* pFormFillEnv, 2237 void Field::SetRotation(CPDFSDK_FormFillEnvironment* pFormFillEnv,
2252 const CFX_WideString& swFieldName, 2238 const CFX_WideString& swFieldName,
2253 int nControlIndex, 2239 int nControlIndex,
2254 int number) { 2240 int number) {
2255 // Not supported. 2241 // Not supported.
2256 } 2242 }
2257 2243
2258 FX_BOOL Field::strokeColor(IJS_Context* cc, 2244 bool Field::strokeColor(IJS_Context* cc,
2259 CJS_PropValue& vp, 2245 CJS_PropValue& vp,
2260 CFX_WideString& sError) { 2246 CFX_WideString& sError) {
2261 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); 2247 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
2262 CJS_Array crArray; 2248 CJS_Array crArray;
2263 2249
2264 if (vp.IsSetting()) { 2250 if (vp.IsSetting()) {
2265 if (!m_bCanSet) 2251 if (!m_bCanSet)
2266 return FALSE; 2252 return false;
2267 2253
2268 if (!vp.GetJSValue()->IsArrayObject()) 2254 if (!vp.GetJSValue()->IsArrayObject())
2269 return FALSE; 2255 return false;
2270 2256
2271 vp >> crArray; 2257 vp >> crArray;
2272 2258
2273 CPWL_Color color; 2259 CPWL_Color color;
2274 color::ConvertArrayToPWLColor(pRuntime, crArray, &color); 2260 color::ConvertArrayToPWLColor(pRuntime, crArray, &color);
2275 2261
2276 if (m_bDelay) { 2262 if (m_bDelay) {
2277 AddDelay_Color(FP_STROKECOLOR, color); 2263 AddDelay_Color(FP_STROKECOLOR, color);
2278 } else { 2264 } else {
2279 Field::SetStrokeColor(m_pFormFillEnv.Get(), m_FieldName, 2265 Field::SetStrokeColor(m_pFormFillEnv.Get(), m_FieldName,
2280 m_nFormControlIndex, color); 2266 m_nFormControlIndex, color);
2281 } 2267 }
2282 } else { 2268 } else {
2283 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 2269 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
2284 if (FieldArray.empty()) 2270 if (FieldArray.empty())
2285 return FALSE; 2271 return false;
2286 2272
2287 CPDF_FormField* pFormField = FieldArray[0]; 2273 CPDF_FormField* pFormField = FieldArray[0];
2288 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 2274 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
2289 if (!pFormControl) 2275 if (!pFormControl)
2290 return FALSE; 2276 return false;
2291 2277
2292 int iColorType; 2278 int iColorType;
2293 pFormControl->GetBorderColor(iColorType); 2279 pFormControl->GetBorderColor(iColorType);
2294 2280
2295 CPWL_Color color; 2281 CPWL_Color color;
2296 if (iColorType == COLORTYPE_TRANSPARENT) { 2282 if (iColorType == COLORTYPE_TRANSPARENT) {
2297 color = CPWL_Color(COLORTYPE_TRANSPARENT); 2283 color = CPWL_Color(COLORTYPE_TRANSPARENT);
2298 } else if (iColorType == COLORTYPE_GRAY) { 2284 } else if (iColorType == COLORTYPE_GRAY) {
2299 color = 2285 color =
2300 CPWL_Color(COLORTYPE_GRAY, pFormControl->GetOriginalBorderColor(0)); 2286 CPWL_Color(COLORTYPE_GRAY, pFormControl->GetOriginalBorderColor(0));
2301 } else if (iColorType == COLORTYPE_RGB) { 2287 } else if (iColorType == COLORTYPE_RGB) {
2302 color = CPWL_Color(COLORTYPE_RGB, pFormControl->GetOriginalBorderColor(0), 2288 color = CPWL_Color(COLORTYPE_RGB, pFormControl->GetOriginalBorderColor(0),
2303 pFormControl->GetOriginalBorderColor(1), 2289 pFormControl->GetOriginalBorderColor(1),
2304 pFormControl->GetOriginalBorderColor(2)); 2290 pFormControl->GetOriginalBorderColor(2));
2305 } else if (iColorType == COLORTYPE_CMYK) { 2291 } else if (iColorType == COLORTYPE_CMYK) {
2306 color = 2292 color =
2307 CPWL_Color(COLORTYPE_CMYK, pFormControl->GetOriginalBorderColor(0), 2293 CPWL_Color(COLORTYPE_CMYK, pFormControl->GetOriginalBorderColor(0),
2308 pFormControl->GetOriginalBorderColor(1), 2294 pFormControl->GetOriginalBorderColor(1),
2309 pFormControl->GetOriginalBorderColor(2), 2295 pFormControl->GetOriginalBorderColor(2),
2310 pFormControl->GetOriginalBorderColor(3)); 2296 pFormControl->GetOriginalBorderColor(3));
2311 } else { 2297 } else {
2312 return FALSE; 2298 return false;
2313 } 2299 }
2314 2300
2315 color::ConvertPWLColorToArray(pRuntime, color, &crArray); 2301 color::ConvertPWLColorToArray(pRuntime, color, &crArray);
2316 vp << crArray; 2302 vp << crArray;
2317 } 2303 }
2318 return TRUE; 2304 return true;
2319 } 2305 }
2320 2306
2321 void Field::SetStrokeColor(CPDFSDK_FormFillEnvironment* pFormFillEnv, 2307 void Field::SetStrokeColor(CPDFSDK_FormFillEnvironment* pFormFillEnv,
2322 const CFX_WideString& swFieldName, 2308 const CFX_WideString& swFieldName,
2323 int nControlIndex, 2309 int nControlIndex,
2324 const CPWL_Color& color) { 2310 const CPWL_Color& color) {
2325 // Not supported. 2311 // Not supported.
2326 } 2312 }
2327 2313
2328 FX_BOOL Field::style(IJS_Context* cc, 2314 bool Field::style(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
2329 CJS_PropValue& vp,
2330 CFX_WideString& sError) {
2331 ASSERT(m_pFormFillEnv); 2315 ASSERT(m_pFormFillEnv);
2332 2316
2333 if (vp.IsSetting()) { 2317 if (vp.IsSetting()) {
2334 if (!m_bCanSet) 2318 if (!m_bCanSet)
2335 return FALSE; 2319 return false;
2336 2320
2337 CFX_ByteString csBCaption; 2321 CFX_ByteString csBCaption;
2338 vp >> csBCaption; 2322 vp >> csBCaption;
2339 2323
2340 if (m_bDelay) { 2324 if (m_bDelay) {
2341 AddDelay_String(FP_STYLE, csBCaption); 2325 AddDelay_String(FP_STYLE, csBCaption);
2342 } else { 2326 } else {
2343 Field::SetStyle(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, 2327 Field::SetStyle(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
2344 csBCaption); 2328 csBCaption);
2345 } 2329 }
2346 } else { 2330 } else {
2347 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 2331 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
2348 if (FieldArray.empty()) 2332 if (FieldArray.empty())
2349 return FALSE; 2333 return false;
2350 2334
2351 CPDF_FormField* pFormField = FieldArray[0]; 2335 CPDF_FormField* pFormField = FieldArray[0];
2352 if (pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON && 2336 if (pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON &&
2353 pFormField->GetFieldType() != FIELDTYPE_CHECKBOX) { 2337 pFormField->GetFieldType() != FIELDTYPE_CHECKBOX) {
2354 return FALSE; 2338 return false;
2355 } 2339 }
2356 2340
2357 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 2341 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
2358 if (!pFormControl) 2342 if (!pFormControl)
2359 return FALSE; 2343 return false;
2360 2344
2361 CFX_WideString csWCaption = pFormControl->GetNormalCaption(); 2345 CFX_WideString csWCaption = pFormControl->GetNormalCaption();
2362 CFX_ByteString csBCaption; 2346 CFX_ByteString csBCaption;
2363 2347
2364 switch (csWCaption[0]) { 2348 switch (csWCaption[0]) {
2365 case L'l': 2349 case L'l':
2366 csBCaption = "circle"; 2350 csBCaption = "circle";
2367 break; 2351 break;
2368 case L'8': 2352 case L'8':
2369 csBCaption = "cross"; 2353 csBCaption = "cross";
2370 break; 2354 break;
2371 case L'u': 2355 case L'u':
2372 csBCaption = "diamond"; 2356 csBCaption = "diamond";
2373 break; 2357 break;
2374 case L'n': 2358 case L'n':
2375 csBCaption = "square"; 2359 csBCaption = "square";
2376 break; 2360 break;
2377 case L'H': 2361 case L'H':
2378 csBCaption = "star"; 2362 csBCaption = "star";
2379 break; 2363 break;
2380 default: // L'4' 2364 default: // L'4'
2381 csBCaption = "check"; 2365 csBCaption = "check";
2382 break; 2366 break;
2383 } 2367 }
2384 vp << csBCaption; 2368 vp << csBCaption;
2385 } 2369 }
2386 2370
2387 return TRUE; 2371 return true;
2388 } 2372 }
2389 2373
2390 void Field::SetStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv, 2374 void Field::SetStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv,
2391 const CFX_WideString& swFieldName, 2375 const CFX_WideString& swFieldName,
2392 int nControlIndex, 2376 int nControlIndex,
2393 const CFX_ByteString& string) { 2377 const CFX_ByteString& string) {
2394 // Not supported. 2378 // Not supported.
2395 } 2379 }
2396 2380
2397 FX_BOOL Field::submitName(IJS_Context* cc, 2381 bool Field::submitName(IJS_Context* cc,
2398 CJS_PropValue& vp, 2382 CJS_PropValue& vp,
2399 CFX_WideString& sError) { 2383 CFX_WideString& sError) {
2400 return TRUE; 2384 return true;
2401 } 2385 }
2402 2386
2403 FX_BOOL Field::textColor(IJS_Context* cc, 2387 bool Field::textColor(IJS_Context* cc,
2404 CJS_PropValue& vp, 2388 CJS_PropValue& vp,
2405 CFX_WideString& sError) { 2389 CFX_WideString& sError) {
2406 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); 2390 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
2407 CJS_Array crArray; 2391 CJS_Array crArray;
2408 2392
2409 if (vp.IsSetting()) { 2393 if (vp.IsSetting()) {
2410 if (!m_bCanSet) 2394 if (!m_bCanSet)
2411 return FALSE; 2395 return false;
2412 2396
2413 if (!vp.GetJSValue()->IsArrayObject()) 2397 if (!vp.GetJSValue()->IsArrayObject())
2414 return FALSE; 2398 return false;
2415 2399
2416 vp >> crArray; 2400 vp >> crArray;
2417 2401
2418 CPWL_Color color; 2402 CPWL_Color color;
2419 color::ConvertArrayToPWLColor(pRuntime, crArray, &color); 2403 color::ConvertArrayToPWLColor(pRuntime, crArray, &color);
2420 2404
2421 if (m_bDelay) { 2405 if (m_bDelay) {
2422 AddDelay_Color(FP_TEXTCOLOR, color); 2406 AddDelay_Color(FP_TEXTCOLOR, color);
2423 } else { 2407 } else {
2424 Field::SetTextColor(m_pFormFillEnv.Get(), m_FieldName, 2408 Field::SetTextColor(m_pFormFillEnv.Get(), m_FieldName,
2425 m_nFormControlIndex, color); 2409 m_nFormControlIndex, color);
2426 } 2410 }
2427 } else { 2411 } else {
2428 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 2412 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
2429 if (FieldArray.empty()) 2413 if (FieldArray.empty())
2430 return FALSE; 2414 return false;
2431 2415
2432 CPDF_FormField* pFormField = FieldArray[0]; 2416 CPDF_FormField* pFormField = FieldArray[0];
2433 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 2417 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
2434 if (!pFormControl) 2418 if (!pFormControl)
2435 return FALSE; 2419 return false;
2436 2420
2437 int iColorType; 2421 int iColorType;
2438 FX_ARGB color; 2422 FX_ARGB color;
2439 CPDF_DefaultAppearance FieldAppearance = 2423 CPDF_DefaultAppearance FieldAppearance =
2440 pFormControl->GetDefaultAppearance(); 2424 pFormControl->GetDefaultAppearance();
2441 FieldAppearance.GetColor(color, iColorType); 2425 FieldAppearance.GetColor(color, iColorType);
2442 int32_t a, r, g, b; 2426 int32_t a, r, g, b;
2443 ArgbDecode(color, a, r, g, b); 2427 ArgbDecode(color, a, r, g, b);
2444 2428
2445 CPWL_Color crRet = 2429 CPWL_Color crRet =
2446 CPWL_Color(COLORTYPE_RGB, r / 255.0f, g / 255.0f, b / 255.0f); 2430 CPWL_Color(COLORTYPE_RGB, r / 255.0f, g / 255.0f, b / 255.0f);
2447 2431
2448 if (iColorType == COLORTYPE_TRANSPARENT) 2432 if (iColorType == COLORTYPE_TRANSPARENT)
2449 crRet = CPWL_Color(COLORTYPE_TRANSPARENT); 2433 crRet = CPWL_Color(COLORTYPE_TRANSPARENT);
2450 2434
2451 color::ConvertPWLColorToArray(pRuntime, crRet, &crArray); 2435 color::ConvertPWLColorToArray(pRuntime, crRet, &crArray);
2452 vp << crArray; 2436 vp << crArray;
2453 } 2437 }
2454 return TRUE; 2438 return true;
2455 } 2439 }
2456 2440
2457 void Field::SetTextColor(CPDFSDK_FormFillEnvironment* pFormFillEnv, 2441 void Field::SetTextColor(CPDFSDK_FormFillEnvironment* pFormFillEnv,
2458 const CFX_WideString& swFieldName, 2442 const CFX_WideString& swFieldName,
2459 int nControlIndex, 2443 int nControlIndex,
2460 const CPWL_Color& color) { 2444 const CPWL_Color& color) {
2461 // Not supported. 2445 // Not supported.
2462 } 2446 }
2463 2447
2464 FX_BOOL Field::textFont(IJS_Context* cc, 2448 bool Field::textFont(IJS_Context* cc,
2465 CJS_PropValue& vp, 2449 CJS_PropValue& vp,
2466 CFX_WideString& sError) { 2450 CFX_WideString& sError) {
2467 ASSERT(m_pFormFillEnv); 2451 ASSERT(m_pFormFillEnv);
2468 2452
2469 if (vp.IsSetting()) { 2453 if (vp.IsSetting()) {
2470 if (!m_bCanSet) 2454 if (!m_bCanSet)
2471 return FALSE; 2455 return false;
2472 2456
2473 CFX_ByteString csFontName; 2457 CFX_ByteString csFontName;
2474 vp >> csFontName; 2458 vp >> csFontName;
2475 if (csFontName.IsEmpty()) 2459 if (csFontName.IsEmpty())
2476 return FALSE; 2460 return false;
2477 2461
2478 if (m_bDelay) { 2462 if (m_bDelay) {
2479 AddDelay_String(FP_TEXTFONT, csFontName); 2463 AddDelay_String(FP_TEXTFONT, csFontName);
2480 } else { 2464 } else {
2481 Field::SetTextFont(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, 2465 Field::SetTextFont(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
2482 csFontName); 2466 csFontName);
2483 } 2467 }
2484 } else { 2468 } else {
2485 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 2469 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
2486 if (FieldArray.empty()) 2470 if (FieldArray.empty())
2487 return FALSE; 2471 return false;
2488 2472
2489 CPDF_FormField* pFormField = FieldArray[0]; 2473 CPDF_FormField* pFormField = FieldArray[0];
2490 ASSERT(pFormField); 2474 ASSERT(pFormField);
2491 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 2475 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
2492 if (!pFormControl) 2476 if (!pFormControl)
2493 return FALSE; 2477 return false;
2494 2478
2495 int nFieldType = pFormField->GetFieldType(); 2479 int nFieldType = pFormField->GetFieldType();
2496 2480
2497 if (nFieldType == FIELDTYPE_PUSHBUTTON || 2481 if (nFieldType == FIELDTYPE_PUSHBUTTON ||
2498 nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_LISTBOX || 2482 nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_LISTBOX ||
2499 nFieldType == FIELDTYPE_TEXTFIELD) { 2483 nFieldType == FIELDTYPE_TEXTFIELD) {
2500 CPDF_Font* pFont = pFormControl->GetDefaultControlFont(); 2484 CPDF_Font* pFont = pFormControl->GetDefaultControlFont();
2501 if (!pFont) 2485 if (!pFont)
2502 return FALSE; 2486 return false;
2503 2487
2504 vp << pFont->GetBaseFont(); 2488 vp << pFont->GetBaseFont();
2505 } else { 2489 } else {
2506 return FALSE; 2490 return false;
2507 } 2491 }
2508 } 2492 }
2509 2493
2510 return TRUE; 2494 return true;
2511 } 2495 }
2512 2496
2513 void Field::SetTextFont(CPDFSDK_FormFillEnvironment* pFormFillEnv, 2497 void Field::SetTextFont(CPDFSDK_FormFillEnvironment* pFormFillEnv,
2514 const CFX_WideString& swFieldName, 2498 const CFX_WideString& swFieldName,
2515 int nControlIndex, 2499 int nControlIndex,
2516 const CFX_ByteString& string) { 2500 const CFX_ByteString& string) {
2517 // Not supported. 2501 // Not supported.
2518 } 2502 }
2519 2503
2520 FX_BOOL Field::textSize(IJS_Context* cc, 2504 bool Field::textSize(IJS_Context* cc,
2521 CJS_PropValue& vp, 2505 CJS_PropValue& vp,
2522 CFX_WideString& sError) { 2506 CFX_WideString& sError) {
2523 ASSERT(m_pFormFillEnv); 2507 ASSERT(m_pFormFillEnv);
2524 2508
2525 if (vp.IsSetting()) { 2509 if (vp.IsSetting()) {
2526 if (!m_bCanSet) 2510 if (!m_bCanSet)
2527 return FALSE; 2511 return false;
2528 2512
2529 int nVP; 2513 int nVP;
2530 vp >> nVP; 2514 vp >> nVP;
2531 2515
2532 if (m_bDelay) { 2516 if (m_bDelay) {
2533 AddDelay_Int(FP_TEXTSIZE, nVP); 2517 AddDelay_Int(FP_TEXTSIZE, nVP);
2534 } else { 2518 } else {
2535 Field::SetTextSize(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, 2519 Field::SetTextSize(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
2536 nVP); 2520 nVP);
2537 } 2521 }
2538 } else { 2522 } else {
2539 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 2523 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
2540 if (FieldArray.empty()) 2524 if (FieldArray.empty())
2541 return FALSE; 2525 return false;
2542 2526
2543 CPDF_FormField* pFormField = FieldArray[0]; 2527 CPDF_FormField* pFormField = FieldArray[0];
2544 ASSERT(pFormField); 2528 ASSERT(pFormField);
2545 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 2529 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
2546 if (!pFormControl) 2530 if (!pFormControl)
2547 return FALSE; 2531 return false;
2548 2532
2549 CPDF_DefaultAppearance FieldAppearance = 2533 CPDF_DefaultAppearance FieldAppearance =
2550 pFormControl->GetDefaultAppearance(); 2534 pFormControl->GetDefaultAppearance();
2551 2535
2552 CFX_ByteString csFontNameTag; 2536 CFX_ByteString csFontNameTag;
2553 FX_FLOAT fFontSize; 2537 FX_FLOAT fFontSize;
2554 FieldAppearance.GetFont(csFontNameTag, fFontSize); 2538 FieldAppearance.GetFont(csFontNameTag, fFontSize);
2555 2539
2556 vp << (int)fFontSize; 2540 vp << (int)fFontSize;
2557 } 2541 }
2558 2542
2559 return TRUE; 2543 return true;
2560 } 2544 }
2561 2545
2562 void Field::SetTextSize(CPDFSDK_FormFillEnvironment* pFormFillEnv, 2546 void Field::SetTextSize(CPDFSDK_FormFillEnvironment* pFormFillEnv,
2563 const CFX_WideString& swFieldName, 2547 const CFX_WideString& swFieldName,
2564 int nControlIndex, 2548 int nControlIndex,
2565 int number) { 2549 int number) {
2566 // Not supported. 2550 // Not supported.
2567 } 2551 }
2568 2552
2569 FX_BOOL Field::type(IJS_Context* cc, 2553 bool Field::type(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
2570 CJS_PropValue& vp,
2571 CFX_WideString& sError) {
2572 if (!vp.IsGetting()) 2554 if (!vp.IsGetting())
2573 return FALSE; 2555 return false;
2574 2556
2575 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 2557 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
2576 if (FieldArray.empty()) 2558 if (FieldArray.empty())
2577 return FALSE; 2559 return false;
2578 2560
2579 CPDF_FormField* pFormField = FieldArray[0]; 2561 CPDF_FormField* pFormField = FieldArray[0];
2580 switch (pFormField->GetFieldType()) { 2562 switch (pFormField->GetFieldType()) {
2581 case FIELDTYPE_UNKNOWN: 2563 case FIELDTYPE_UNKNOWN:
2582 vp << L"unknown"; 2564 vp << L"unknown";
2583 break; 2565 break;
2584 case FIELDTYPE_PUSHBUTTON: 2566 case FIELDTYPE_PUSHBUTTON:
2585 vp << L"button"; 2567 vp << L"button";
2586 break; 2568 break;
2587 case FIELDTYPE_CHECKBOX: 2569 case FIELDTYPE_CHECKBOX:
(...skipping 12 matching lines...) Expand all
2600 vp << L"text"; 2582 vp << L"text";
2601 break; 2583 break;
2602 case FIELDTYPE_SIGNATURE: 2584 case FIELDTYPE_SIGNATURE:
2603 vp << L"signature"; 2585 vp << L"signature";
2604 break; 2586 break;
2605 default: 2587 default:
2606 vp << L"unknown"; 2588 vp << L"unknown";
2607 break; 2589 break;
2608 } 2590 }
2609 2591
2610 return TRUE; 2592 return true;
2611 } 2593 }
2612 2594
2613 FX_BOOL Field::userName(IJS_Context* cc, 2595 bool Field::userName(IJS_Context* cc,
2614 CJS_PropValue& vp, 2596 CJS_PropValue& vp,
2615 CFX_WideString& sError) { 2597 CFX_WideString& sError) {
2616 ASSERT(m_pFormFillEnv); 2598 ASSERT(m_pFormFillEnv);
2617 2599
2618 if (vp.IsSetting()) { 2600 if (vp.IsSetting()) {
2619 if (!m_bCanSet) 2601 if (!m_bCanSet)
2620 return FALSE; 2602 return false;
2621 2603
2622 CFX_WideString swName; 2604 CFX_WideString swName;
2623 vp >> swName; 2605 vp >> swName;
2624 2606
2625 if (m_bDelay) { 2607 if (m_bDelay) {
2626 AddDelay_WideString(FP_USERNAME, swName); 2608 AddDelay_WideString(FP_USERNAME, swName);
2627 } else { 2609 } else {
2628 Field::SetUserName(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, 2610 Field::SetUserName(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
2629 swName); 2611 swName);
2630 } 2612 }
2631 } else { 2613 } else {
2632 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 2614 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
2633 if (FieldArray.empty()) 2615 if (FieldArray.empty())
2634 return FALSE; 2616 return false;
2635 2617
2636 CPDF_FormField* pFormField = FieldArray[0]; 2618 CPDF_FormField* pFormField = FieldArray[0];
2637 vp << (CFX_WideString)pFormField->GetAlternateName(); 2619 vp << (CFX_WideString)pFormField->GetAlternateName();
2638 } 2620 }
2639 2621
2640 return TRUE; 2622 return true;
2641 } 2623 }
2642 2624
2643 void Field::SetUserName(CPDFSDK_FormFillEnvironment* pFormFillEnv, 2625 void Field::SetUserName(CPDFSDK_FormFillEnvironment* pFormFillEnv,
2644 const CFX_WideString& swFieldName, 2626 const CFX_WideString& swFieldName,
2645 int nControlIndex, 2627 int nControlIndex,
2646 const CFX_WideString& string) { 2628 const CFX_WideString& string) {
2647 // Not supported. 2629 // Not supported.
2648 } 2630 }
2649 2631
2650 FX_BOOL Field::value(IJS_Context* cc, 2632 bool Field::value(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
2651 CJS_PropValue& vp,
2652 CFX_WideString& sError) {
2653 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); 2633 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
2654 2634
2655 if (vp.IsSetting()) { 2635 if (vp.IsSetting()) {
2656 if (!m_bCanSet) 2636 if (!m_bCanSet)
2657 return FALSE; 2637 return false;
2658 2638
2659 std::vector<CFX_WideString> strArray; 2639 std::vector<CFX_WideString> strArray;
2660 if (vp.GetJSValue()->IsArrayObject()) { 2640 if (vp.GetJSValue()->IsArrayObject()) {
2661 CJS_Array ValueArray; 2641 CJS_Array ValueArray;
2662 vp.GetJSValue()->ConvertToArray(pRuntime, ValueArray); 2642 vp.GetJSValue()->ConvertToArray(pRuntime, ValueArray);
2663 for (int i = 0, sz = ValueArray.GetLength(pRuntime); i < sz; i++) { 2643 for (int i = 0, sz = ValueArray.GetLength(pRuntime); i < sz; i++) {
2664 CJS_Value ElementValue(pRuntime); 2644 CJS_Value ElementValue(pRuntime);
2665 ValueArray.GetElement(pRuntime, i, ElementValue); 2645 ValueArray.GetElement(pRuntime, i, ElementValue);
2666 strArray.push_back(ElementValue.ToCFXWideString(pRuntime)); 2646 strArray.push_back(ElementValue.ToCFXWideString(pRuntime));
2667 } 2647 }
2668 } else { 2648 } else {
2669 CFX_WideString swValue; 2649 CFX_WideString swValue;
2670 vp >> swValue; 2650 vp >> swValue;
2671 strArray.push_back(swValue); 2651 strArray.push_back(swValue);
2672 } 2652 }
2673 2653
2674 if (m_bDelay) { 2654 if (m_bDelay) {
2675 AddDelay_WideStringArray(FP_VALUE, strArray); 2655 AddDelay_WideStringArray(FP_VALUE, strArray);
2676 } else { 2656 } else {
2677 Field::SetValue(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, 2657 Field::SetValue(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
2678 strArray); 2658 strArray);
2679 } 2659 }
2680 } else { 2660 } else {
2681 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 2661 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
2682 if (FieldArray.empty()) 2662 if (FieldArray.empty())
2683 return FALSE; 2663 return false;
2684 2664
2685 CPDF_FormField* pFormField = FieldArray[0]; 2665 CPDF_FormField* pFormField = FieldArray[0];
2686 switch (pFormField->GetFieldType()) { 2666 switch (pFormField->GetFieldType()) {
2687 case FIELDTYPE_PUSHBUTTON: 2667 case FIELDTYPE_PUSHBUTTON:
2688 return FALSE; 2668 return false;
2689 case FIELDTYPE_COMBOBOX: 2669 case FIELDTYPE_COMBOBOX:
2690 case FIELDTYPE_TEXTFIELD: { 2670 case FIELDTYPE_TEXTFIELD: {
2691 vp << pFormField->GetValue(); 2671 vp << pFormField->GetValue();
2692 } break; 2672 } break;
2693 case FIELDTYPE_LISTBOX: { 2673 case FIELDTYPE_LISTBOX: {
2694 if (pFormField->CountSelectedItems() > 1) { 2674 if (pFormField->CountSelectedItems() > 1) {
2695 CJS_Array ValueArray; 2675 CJS_Array ValueArray;
2696 CJS_Value ElementValue(pRuntime); 2676 CJS_Value ElementValue(pRuntime);
2697 int iIndex; 2677 int iIndex;
2698 for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) { 2678 for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) {
(...skipping 24 matching lines...) Expand all
2723 } 2703 }
2724 if (!bFind) 2704 if (!bFind)
2725 vp << L"Off"; 2705 vp << L"Off";
2726 } break; 2706 } break;
2727 default: 2707 default:
2728 vp << pFormField->GetValue(); 2708 vp << pFormField->GetValue();
2729 break; 2709 break;
2730 } 2710 }
2731 } 2711 }
2732 vp.GetJSValue()->MaybeCoerceToNumber(pRuntime); 2712 vp.GetJSValue()->MaybeCoerceToNumber(pRuntime);
2733 return TRUE; 2713 return true;
2734 } 2714 }
2735 2715
2736 void Field::SetValue(CPDFSDK_FormFillEnvironment* pFormFillEnv, 2716 void Field::SetValue(CPDFSDK_FormFillEnvironment* pFormFillEnv,
2737 const CFX_WideString& swFieldName, 2717 const CFX_WideString& swFieldName,
2738 int nControlIndex, 2718 int nControlIndex,
2739 const std::vector<CFX_WideString>& strArray) { 2719 const std::vector<CFX_WideString>& strArray) {
2740 ASSERT(pFormFillEnv); 2720 ASSERT(pFormFillEnv);
2741 if (strArray.empty()) 2721 if (strArray.empty())
2742 return; 2722 return;
2743 2723
2744 std::vector<CPDF_FormField*> FieldArray = 2724 std::vector<CPDF_FormField*> FieldArray =
2745 GetFormFields(pFormFillEnv, swFieldName); 2725 GetFormFields(pFormFillEnv, swFieldName);
2746 2726
2747 for (CPDF_FormField* pFormField : FieldArray) { 2727 for (CPDF_FormField* pFormField : FieldArray) {
2748 if (pFormField->GetFullName().Compare(swFieldName) != 0) 2728 if (pFormField->GetFullName().Compare(swFieldName) != 0)
2749 continue; 2729 continue;
2750 2730
2751 switch (pFormField->GetFieldType()) { 2731 switch (pFormField->GetFieldType()) {
2752 case FIELDTYPE_TEXTFIELD: 2732 case FIELDTYPE_TEXTFIELD:
2753 case FIELDTYPE_COMBOBOX: 2733 case FIELDTYPE_COMBOBOX:
2754 if (pFormField->GetValue() != strArray[0]) { 2734 if (pFormField->GetValue() != strArray[0]) {
2755 pFormField->SetValue(strArray[0], TRUE); 2735 pFormField->SetValue(strArray[0], true);
2756 UpdateFormField(pFormFillEnv, pFormField, TRUE, FALSE, TRUE); 2736 UpdateFormField(pFormFillEnv, pFormField, true, false, true);
2757 } 2737 }
2758 break; 2738 break;
2759 case FIELDTYPE_CHECKBOX: 2739 case FIELDTYPE_CHECKBOX:
2760 case FIELDTYPE_RADIOBUTTON: { 2740 case FIELDTYPE_RADIOBUTTON: {
2761 if (pFormField->GetValue() != strArray[0]) { 2741 if (pFormField->GetValue() != strArray[0]) {
2762 pFormField->SetValue(strArray[0], TRUE); 2742 pFormField->SetValue(strArray[0], true);
2763 UpdateFormField(pFormFillEnv, pFormField, TRUE, FALSE, TRUE); 2743 UpdateFormField(pFormFillEnv, pFormField, true, false, true);
2764 } 2744 }
2765 } break; 2745 } break;
2766 case FIELDTYPE_LISTBOX: { 2746 case FIELDTYPE_LISTBOX: {
2767 FX_BOOL bModified = FALSE; 2747 bool bModified = false;
2768 for (const auto& str : strArray) { 2748 for (const auto& str : strArray) {
2769 if (!pFormField->IsItemSelected(pFormField->FindOption(str))) { 2749 if (!pFormField->IsItemSelected(pFormField->FindOption(str))) {
2770 bModified = TRUE; 2750 bModified = true;
2771 break; 2751 break;
2772 } 2752 }
2773 } 2753 }
2774 if (bModified) { 2754 if (bModified) {
2775 pFormField->ClearSelection(TRUE); 2755 pFormField->ClearSelection(true);
2776 for (const auto& str : strArray) { 2756 for (const auto& str : strArray) {
2777 int index = pFormField->FindOption(str); 2757 int index = pFormField->FindOption(str);
2778 if (!pFormField->IsItemSelected(index)) 2758 if (!pFormField->IsItemSelected(index))
2779 pFormField->SetItemSelection(index, TRUE, TRUE); 2759 pFormField->SetItemSelection(index, true, true);
2780 } 2760 }
2781 UpdateFormField(pFormFillEnv, pFormField, TRUE, FALSE, TRUE); 2761 UpdateFormField(pFormFillEnv, pFormField, true, false, true);
2782 } 2762 }
2783 } break; 2763 } break;
2784 default: 2764 default:
2785 break; 2765 break;
2786 } 2766 }
2787 } 2767 }
2788 } 2768 }
2789 2769
2790 FX_BOOL Field::valueAsString(IJS_Context* cc, 2770 bool Field::valueAsString(IJS_Context* cc,
2791 CJS_PropValue& vp, 2771 CJS_PropValue& vp,
2792 CFX_WideString& sError) { 2772 CFX_WideString& sError) {
2793 if (!vp.IsGetting()) 2773 if (!vp.IsGetting())
2794 return FALSE; 2774 return false;
2795 2775
2796 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 2776 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
2797 if (FieldArray.empty()) 2777 if (FieldArray.empty())
2798 return FALSE; 2778 return false;
2799 2779
2800 CPDF_FormField* pFormField = FieldArray[0]; 2780 CPDF_FormField* pFormField = FieldArray[0];
2801 if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON) 2781 if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON)
2802 return FALSE; 2782 return false;
2803 2783
2804 if (pFormField->GetFieldType() == FIELDTYPE_CHECKBOX) { 2784 if (pFormField->GetFieldType() == FIELDTYPE_CHECKBOX) {
2805 if (!pFormField->CountControls()) 2785 if (!pFormField->CountControls())
2806 return FALSE; 2786 return false;
2807 2787
2808 if (pFormField->GetControl(0)->IsChecked()) 2788 if (pFormField->GetControl(0)->IsChecked())
2809 vp << L"Yes"; 2789 vp << L"Yes";
2810 else 2790 else
2811 vp << L"Off"; 2791 vp << L"Off";
2812 } else if (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON && 2792 } else if (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON &&
2813 !(pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON)) { 2793 !(pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON)) {
2814 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { 2794 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) {
2815 if (pFormField->GetControl(i)->IsChecked()) { 2795 if (pFormField->GetControl(i)->IsChecked()) {
2816 vp << pFormField->GetControl(i)->GetExportValue().c_str(); 2796 vp << pFormField->GetControl(i)->GetExportValue().c_str();
2817 break; 2797 break;
2818 } else { 2798 } else {
2819 vp << L"Off"; 2799 vp << L"Off";
2820 } 2800 }
2821 } 2801 }
2822 } else if (pFormField->GetFieldType() == FIELDTYPE_LISTBOX && 2802 } else if (pFormField->GetFieldType() == FIELDTYPE_LISTBOX &&
2823 (pFormField->CountSelectedItems() > 1)) { 2803 (pFormField->CountSelectedItems() > 1)) {
2824 vp << L""; 2804 vp << L"";
2825 } else { 2805 } else {
2826 vp << pFormField->GetValue().c_str(); 2806 vp << pFormField->GetValue().c_str();
2827 } 2807 }
2828 2808
2829 return TRUE; 2809 return true;
2830 } 2810 }
2831 2811
2832 FX_BOOL Field::browseForFileToSubmit(IJS_Context* cc, 2812 bool Field::browseForFileToSubmit(IJS_Context* cc,
2833 const std::vector<CJS_Value>& params, 2813 const std::vector<CJS_Value>& params,
2834 CJS_Value& vRet, 2814 CJS_Value& vRet,
2835 CFX_WideString& sError) { 2815 CFX_WideString& sError) {
2836 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 2816 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
2837 if (FieldArray.empty()) 2817 if (FieldArray.empty())
2838 return FALSE; 2818 return false;
2839 2819
2840 CPDF_FormField* pFormField = FieldArray[0]; 2820 CPDF_FormField* pFormField = FieldArray[0];
2841 if ((pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT) && 2821 if ((pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT) &&
2842 (pFormField->GetFieldType() == FIELDTYPE_TEXTFIELD)) { 2822 (pFormField->GetFieldType() == FIELDTYPE_TEXTFIELD)) {
2843 CFX_WideString wsFileName = m_pFormFillEnv->JS_fieldBrowse(); 2823 CFX_WideString wsFileName = m_pFormFillEnv->JS_fieldBrowse();
2844 if (!wsFileName.IsEmpty()) { 2824 if (!wsFileName.IsEmpty()) {
2845 pFormField->SetValue(wsFileName); 2825 pFormField->SetValue(wsFileName);
2846 UpdateFormField(m_pFormFillEnv.Get(), pFormField, TRUE, TRUE, TRUE); 2826 UpdateFormField(m_pFormFillEnv.Get(), pFormField, true, true, true);
2847 } 2827 }
2848 return TRUE; 2828 return true;
2849 } 2829 }
2850 return FALSE; 2830 return false;
2851 } 2831 }
2852 2832
2853 FX_BOOL Field::buttonGetCaption(IJS_Context* cc, 2833 bool Field::buttonGetCaption(IJS_Context* cc,
2854 const std::vector<CJS_Value>& params, 2834 const std::vector<CJS_Value>& params,
2855 CJS_Value& vRet, 2835 CJS_Value& vRet,
2856 CFX_WideString& sError) { 2836 CFX_WideString& sError) {
2857 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); 2837 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
2858 2838
2859 int nface = 0; 2839 int nface = 0;
2860 int iSize = params.size(); 2840 int iSize = params.size();
2861 if (iSize >= 1) 2841 if (iSize >= 1)
2862 nface = params[0].ToInt(pRuntime); 2842 nface = params[0].ToInt(pRuntime);
2863 2843
2864 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 2844 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
2865 if (FieldArray.empty()) 2845 if (FieldArray.empty())
2866 return FALSE; 2846 return false;
2867 2847
2868 CPDF_FormField* pFormField = FieldArray[0]; 2848 CPDF_FormField* pFormField = FieldArray[0];
2869 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) 2849 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
2870 return FALSE; 2850 return false;
2871 2851
2872 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 2852 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
2873 if (!pFormControl) 2853 if (!pFormControl)
2874 return FALSE; 2854 return false;
2875 2855
2876 if (nface == 0) 2856 if (nface == 0)
2877 vRet = CJS_Value(pRuntime, pFormControl->GetNormalCaption().c_str()); 2857 vRet = CJS_Value(pRuntime, pFormControl->GetNormalCaption().c_str());
2878 else if (nface == 1) 2858 else if (nface == 1)
2879 vRet = CJS_Value(pRuntime, pFormControl->GetDownCaption().c_str()); 2859 vRet = CJS_Value(pRuntime, pFormControl->GetDownCaption().c_str());
2880 else if (nface == 2) 2860 else if (nface == 2)
2881 vRet = CJS_Value(pRuntime, pFormControl->GetRolloverCaption().c_str()); 2861 vRet = CJS_Value(pRuntime, pFormControl->GetRolloverCaption().c_str());
2882 else 2862 else
2883 return FALSE; 2863 return false;
2884 2864
2885 return TRUE; 2865 return true;
2886 } 2866 }
2887 2867
2888 FX_BOOL Field::buttonGetIcon(IJS_Context* cc, 2868 bool Field::buttonGetIcon(IJS_Context* cc,
2889 const std::vector<CJS_Value>& params, 2869 const std::vector<CJS_Value>& params,
2890 CJS_Value& vRet, 2870 CJS_Value& vRet,
2891 CFX_WideString& sError) { 2871 CFX_WideString& sError) {
2892 CJS_Context* pContext = static_cast<CJS_Context*>(cc); 2872 CJS_Context* pContext = static_cast<CJS_Context*>(cc);
2893 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); 2873 CJS_Runtime* pRuntime = pContext->GetJSRuntime();
2894 2874
2895 int nface = 0; 2875 int nface = 0;
2896 int iSize = params.size(); 2876 int iSize = params.size();
2897 if (iSize >= 1) 2877 if (iSize >= 1)
2898 nface = params[0].ToInt(pRuntime); 2878 nface = params[0].ToInt(pRuntime);
2899 2879
2900 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 2880 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
2901 if (FieldArray.empty()) 2881 if (FieldArray.empty())
2902 return FALSE; 2882 return false;
2903 2883
2904 CPDF_FormField* pFormField = FieldArray[0]; 2884 CPDF_FormField* pFormField = FieldArray[0];
2905 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) 2885 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
2906 return FALSE; 2886 return false;
2907 2887
2908 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 2888 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
2909 if (!pFormControl) 2889 if (!pFormControl)
2910 return FALSE; 2890 return false;
2911 2891
2912 v8::Local<v8::Object> pObj = 2892 v8::Local<v8::Object> pObj =
2913 pRuntime->NewFxDynamicObj(CJS_Icon::g_nObjDefnID); 2893 pRuntime->NewFxDynamicObj(CJS_Icon::g_nObjDefnID);
2914 ASSERT(pObj.IsEmpty() == FALSE); 2894 ASSERT(pObj.IsEmpty() == false);
2915 2895
2916 CJS_Icon* pJS_Icon = static_cast<CJS_Icon*>(pRuntime->GetObjectPrivate(pObj)); 2896 CJS_Icon* pJS_Icon = static_cast<CJS_Icon*>(pRuntime->GetObjectPrivate(pObj));
2917 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); 2897 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject();
2918 2898
2919 CPDF_Stream* pIconStream = nullptr; 2899 CPDF_Stream* pIconStream = nullptr;
2920 if (nface == 0) 2900 if (nface == 0)
2921 pIconStream = pFormControl->GetNormalIcon(); 2901 pIconStream = pFormControl->GetNormalIcon();
2922 else if (nface == 1) 2902 else if (nface == 1)
2923 pIconStream = pFormControl->GetDownIcon(); 2903 pIconStream = pFormControl->GetDownIcon();
2924 else if (nface == 2) 2904 else if (nface == 2)
2925 pIconStream = pFormControl->GetRolloverIcon(); 2905 pIconStream = pFormControl->GetRolloverIcon();
2926 else 2906 else
2927 return FALSE; 2907 return false;
2928 2908
2929 pIcon->SetStream(pIconStream); 2909 pIcon->SetStream(pIconStream);
2930 vRet = CJS_Value(pRuntime, pJS_Icon); 2910 vRet = CJS_Value(pRuntime, pJS_Icon);
2931 return TRUE; 2911 return true;
2932 } 2912 }
2933 2913
2934 FX_BOOL Field::buttonImportIcon(IJS_Context* cc, 2914 bool Field::buttonImportIcon(IJS_Context* cc,
2935 const std::vector<CJS_Value>& params,
2936 CJS_Value& vRet,
2937 CFX_WideString& sError) {
2938 return TRUE;
2939 }
2940
2941 FX_BOOL Field::buttonSetCaption(IJS_Context* cc,
2942 const std::vector<CJS_Value>& params,
2943 CJS_Value& vRet,
2944 CFX_WideString& sError) {
2945 return FALSE;
2946 }
2947
2948 FX_BOOL Field::buttonSetIcon(IJS_Context* cc,
2949 const std::vector<CJS_Value>& params, 2915 const std::vector<CJS_Value>& params,
2950 CJS_Value& vRet, 2916 CJS_Value& vRet,
2951 CFX_WideString& sError) { 2917 CFX_WideString& sError) {
2952 return FALSE; 2918 return true;
2953 } 2919 }
2954 2920
2955 FX_BOOL Field::checkThisBox(IJS_Context* cc, 2921 bool Field::buttonSetCaption(IJS_Context* cc,
2956 const std::vector<CJS_Value>& params, 2922 const std::vector<CJS_Value>& params,
2957 CJS_Value& vRet, 2923 CJS_Value& vRet,
2958 CFX_WideString& sError) { 2924 CFX_WideString& sError) {
2925 return false;
2926 }
2927
2928 bool Field::buttonSetIcon(IJS_Context* cc,
2929 const std::vector<CJS_Value>& params,
2930 CJS_Value& vRet,
2931 CFX_WideString& sError) {
2932 return false;
2933 }
2934
2935 bool Field::checkThisBox(IJS_Context* cc,
2936 const std::vector<CJS_Value>& params,
2937 CJS_Value& vRet,
2938 CFX_WideString& sError) {
2959 int iSize = params.size(); 2939 int iSize = params.size();
2960 if (iSize < 1) 2940 if (iSize < 1)
2961 return FALSE; 2941 return false;
2962 2942
2963 if (!m_bCanSet) 2943 if (!m_bCanSet)
2964 return FALSE; 2944 return false;
2965 2945
2966 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); 2946 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
2967 int nWidget = params[0].ToInt(pRuntime); 2947 int nWidget = params[0].ToInt(pRuntime);
2968 2948
2969 bool bCheckit = true; 2949 bool bCheckit = true;
2970 if (iSize >= 2) 2950 if (iSize >= 2)
2971 bCheckit = params[1].ToBool(pRuntime); 2951 bCheckit = params[1].ToBool(pRuntime);
2972 2952
2973 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 2953 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
2974 if (FieldArray.empty()) 2954 if (FieldArray.empty())
2975 return FALSE; 2955 return false;
2976 2956
2977 CPDF_FormField* pFormField = FieldArray[0]; 2957 CPDF_FormField* pFormField = FieldArray[0];
2978 if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX && 2958 if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX &&
2979 pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON) 2959 pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON)
2980 return FALSE; 2960 return false;
2981 if (nWidget < 0 || nWidget >= pFormField->CountControls()) 2961 if (nWidget < 0 || nWidget >= pFormField->CountControls())
2982 return FALSE; 2962 return false;
2983 // TODO(weili): Check whether anything special needed for radio button, 2963 // TODO(weili): Check whether anything special needed for radio button,
2984 // otherwise merge these branches. 2964 // otherwise merge these branches.
2985 if (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON) 2965 if (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON)
2986 pFormField->CheckControl(nWidget, bCheckit, true); 2966 pFormField->CheckControl(nWidget, bCheckit, true);
2987 else 2967 else
2988 pFormField->CheckControl(nWidget, bCheckit, true); 2968 pFormField->CheckControl(nWidget, bCheckit, true);
2989 2969
2990 UpdateFormField(m_pFormFillEnv.Get(), pFormField, TRUE, TRUE, TRUE); 2970 UpdateFormField(m_pFormFillEnv.Get(), pFormField, true, true, true);
2991 return TRUE; 2971 return true;
2992 } 2972 }
2993 2973
2994 FX_BOOL Field::clearItems(IJS_Context* cc, 2974 bool Field::clearItems(IJS_Context* cc,
2995 const std::vector<CJS_Value>& params, 2975 const std::vector<CJS_Value>& params,
2996 CJS_Value& vRet, 2976 CJS_Value& vRet,
2997 CFX_WideString& sError) { 2977 CFX_WideString& sError) {
2998 return TRUE; 2978 return true;
2999 } 2979 }
3000 2980
3001 FX_BOOL Field::defaultIsChecked(IJS_Context* cc, 2981 bool Field::defaultIsChecked(IJS_Context* cc,
3002 const std::vector<CJS_Value>& params, 2982 const std::vector<CJS_Value>& params,
3003 CJS_Value& vRet, 2983 CJS_Value& vRet,
3004 CFX_WideString& sError) { 2984 CFX_WideString& sError) {
3005 if (!m_bCanSet) 2985 if (!m_bCanSet)
3006 return FALSE; 2986 return false;
3007 2987
3008 int iSize = params.size(); 2988 int iSize = params.size();
3009 if (iSize < 1) 2989 if (iSize < 1)
3010 return FALSE; 2990 return false;
3011 2991
3012 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); 2992 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
3013 int nWidget = params[0].ToInt(pRuntime); 2993 int nWidget = params[0].ToInt(pRuntime);
3014 2994
3015 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 2995 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
3016 if (FieldArray.empty()) 2996 if (FieldArray.empty())
3017 return FALSE; 2997 return false;
3018 2998
3019 CPDF_FormField* pFormField = FieldArray[0]; 2999 CPDF_FormField* pFormField = FieldArray[0];
3020 if (nWidget < 0 || nWidget >= pFormField->CountControls()) 3000 if (nWidget < 0 || nWidget >= pFormField->CountControls())
3021 return FALSE; 3001 return false;
3022 3002
3023 vRet = CJS_Value(pRuntime, 3003 vRet = CJS_Value(pRuntime,
3024 pFormField->GetFieldType() == FIELDTYPE_CHECKBOX || 3004 pFormField->GetFieldType() == FIELDTYPE_CHECKBOX ||
3025 pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON); 3005 pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON);
3026 3006
3027 return TRUE; 3007 return true;
3028 } 3008 }
3029 3009
3030 FX_BOOL Field::deleteItemAt(IJS_Context* cc, 3010 bool Field::deleteItemAt(IJS_Context* cc,
3031 const std::vector<CJS_Value>& params, 3011 const std::vector<CJS_Value>& params,
3032 CJS_Value& vRet, 3012 CJS_Value& vRet,
3033 CFX_WideString& sError) { 3013 CFX_WideString& sError) {
3034 return TRUE; 3014 return true;
3035 } 3015 }
3036 3016
3037 FX_BOOL Field::getArray(IJS_Context* cc, 3017 bool Field::getArray(IJS_Context* cc,
3038 const std::vector<CJS_Value>& params, 3018 const std::vector<CJS_Value>& params,
3039 CJS_Value& vRet, 3019 CJS_Value& vRet,
3040 CFX_WideString& sError) { 3020 CFX_WideString& sError) {
3041 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 3021 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
3042 if (FieldArray.empty()) 3022 if (FieldArray.empty())
3043 return FALSE; 3023 return false;
3044 3024
3045 std::vector<std::unique_ptr<CFX_WideString>> swSort; 3025 std::vector<std::unique_ptr<CFX_WideString>> swSort;
3046 for (CPDF_FormField* pFormField : FieldArray) { 3026 for (CPDF_FormField* pFormField : FieldArray) {
3047 swSort.push_back(std::unique_ptr<CFX_WideString>( 3027 swSort.push_back(std::unique_ptr<CFX_WideString>(
3048 new CFX_WideString(pFormField->GetFullName()))); 3028 new CFX_WideString(pFormField->GetFullName())));
3049 } 3029 }
3050 3030
3051 std::sort( 3031 std::sort(
3052 swSort.begin(), swSort.end(), 3032 swSort.begin(), swSort.end(),
3053 [](const std::unique_ptr<CFX_WideString>& p1, 3033 [](const std::unique_ptr<CFX_WideString>& p1,
(...skipping 10 matching lines...) Expand all
3064 ASSERT(!pObj.IsEmpty()); 3044 ASSERT(!pObj.IsEmpty());
3065 3045
3066 CJS_Field* pJSField = 3046 CJS_Field* pJSField =
3067 static_cast<CJS_Field*>(pRuntime->GetObjectPrivate(pObj)); 3047 static_cast<CJS_Field*>(pRuntime->GetObjectPrivate(pObj));
3068 Field* pField = static_cast<Field*>(pJSField->GetEmbedObject()); 3048 Field* pField = static_cast<Field*>(pJSField->GetEmbedObject());
3069 pField->AttachField(m_pJSDoc, *pStr); 3049 pField->AttachField(m_pJSDoc, *pStr);
3070 FormFieldArray.SetElement(pRuntime, j++, CJS_Value(pRuntime, pJSField)); 3050 FormFieldArray.SetElement(pRuntime, j++, CJS_Value(pRuntime, pJSField));
3071 } 3051 }
3072 3052
3073 vRet = CJS_Value(pRuntime, FormFieldArray); 3053 vRet = CJS_Value(pRuntime, FormFieldArray);
3074 return TRUE; 3054 return true;
3075 } 3055 }
3076 3056
3077 FX_BOOL Field::getItemAt(IJS_Context* cc, 3057 bool Field::getItemAt(IJS_Context* cc,
3078 const std::vector<CJS_Value>& params, 3058 const std::vector<CJS_Value>& params,
3079 CJS_Value& vRet, 3059 CJS_Value& vRet,
3080 CFX_WideString& sError) { 3060 CFX_WideString& sError) {
3081 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); 3061 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
3082 3062
3083 int iSize = params.size(); 3063 int iSize = params.size();
3084 int nIdx = -1; 3064 int nIdx = -1;
3085 if (iSize >= 1) 3065 if (iSize >= 1)
3086 nIdx = params[0].ToInt(pRuntime); 3066 nIdx = params[0].ToInt(pRuntime);
3087 3067
3088 FX_BOOL bExport = TRUE; 3068 bool bExport = true;
3089 if (iSize >= 2) 3069 if (iSize >= 2)
3090 bExport = params[1].ToBool(pRuntime); 3070 bExport = params[1].ToBool(pRuntime);
3091 3071
3092 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 3072 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
3093 if (FieldArray.empty()) 3073 if (FieldArray.empty())
3094 return FALSE; 3074 return false;
3095 3075
3096 CPDF_FormField* pFormField = FieldArray[0]; 3076 CPDF_FormField* pFormField = FieldArray[0];
3097 if ((pFormField->GetFieldType() == FIELDTYPE_LISTBOX) || 3077 if ((pFormField->GetFieldType() == FIELDTYPE_LISTBOX) ||
3098 (pFormField->GetFieldType() == FIELDTYPE_COMBOBOX)) { 3078 (pFormField->GetFieldType() == FIELDTYPE_COMBOBOX)) {
3099 if (nIdx == -1 || nIdx > pFormField->CountOptions()) 3079 if (nIdx == -1 || nIdx > pFormField->CountOptions())
3100 nIdx = pFormField->CountOptions() - 1; 3080 nIdx = pFormField->CountOptions() - 1;
3101 if (bExport) { 3081 if (bExport) {
3102 CFX_WideString strval = pFormField->GetOptionValue(nIdx); 3082 CFX_WideString strval = pFormField->GetOptionValue(nIdx);
3103 if (strval.IsEmpty()) 3083 if (strval.IsEmpty())
3104 vRet = CJS_Value(pRuntime, pFormField->GetOptionLabel(nIdx).c_str()); 3084 vRet = CJS_Value(pRuntime, pFormField->GetOptionLabel(nIdx).c_str());
3105 else 3085 else
3106 vRet = CJS_Value(pRuntime, strval.c_str()); 3086 vRet = CJS_Value(pRuntime, strval.c_str());
3107 } else { 3087 } else {
3108 vRet = CJS_Value(pRuntime, pFormField->GetOptionLabel(nIdx).c_str()); 3088 vRet = CJS_Value(pRuntime, pFormField->GetOptionLabel(nIdx).c_str());
3109 } 3089 }
3110 } else { 3090 } else {
3111 return FALSE; 3091 return false;
3112 } 3092 }
3113 3093
3114 return TRUE; 3094 return true;
3115 } 3095 }
3116 3096
3117 FX_BOOL Field::getLock(IJS_Context* cc, 3097 bool Field::getLock(IJS_Context* cc,
3118 const std::vector<CJS_Value>& params, 3098 const std::vector<CJS_Value>& params,
3119 CJS_Value& vRet, 3099 CJS_Value& vRet,
3120 CFX_WideString& sError) { 3100 CFX_WideString& sError) {
3121 return FALSE; 3101 return false;
3122 } 3102 }
3123 3103
3124 FX_BOOL Field::insertItemAt(IJS_Context* cc, 3104 bool Field::insertItemAt(IJS_Context* cc,
3125 const std::vector<CJS_Value>& params, 3105 const std::vector<CJS_Value>& params,
3126 CJS_Value& vRet, 3106 CJS_Value& vRet,
3127 CFX_WideString& sError) { 3107 CFX_WideString& sError) {
3128 return TRUE; 3108 return true;
3129 } 3109 }
3130 3110
3131 FX_BOOL Field::isBoxChecked(IJS_Context* cc, 3111 bool Field::isBoxChecked(IJS_Context* cc,
3132 const std::vector<CJS_Value>& params, 3112 const std::vector<CJS_Value>& params,
3133 CJS_Value& vRet, 3113 CJS_Value& vRet,
3134 CFX_WideString& sError) { 3114 CFX_WideString& sError) {
3135 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); 3115 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
3136 3116
3137 int nIndex = -1; 3117 int nIndex = -1;
3138 if (params.size() >= 1) 3118 if (params.size() >= 1)
3139 nIndex = params[0].ToInt(pRuntime); 3119 nIndex = params[0].ToInt(pRuntime);
3140 3120
3141 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 3121 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
3142 if (FieldArray.empty()) 3122 if (FieldArray.empty())
3143 return FALSE; 3123 return false;
3144 3124
3145 CPDF_FormField* pFormField = FieldArray[0]; 3125 CPDF_FormField* pFormField = FieldArray[0];
3146 if (nIndex < 0 || nIndex >= pFormField->CountControls()) { 3126 if (nIndex < 0 || nIndex >= pFormField->CountControls()) {
3147 return FALSE; 3127 return false;
3148 } 3128 }
3149 3129
3150 vRet = CJS_Value(pRuntime, 3130 vRet = CJS_Value(pRuntime,
3151 ((pFormField->GetFieldType() == FIELDTYPE_CHECKBOX || 3131 ((pFormField->GetFieldType() == FIELDTYPE_CHECKBOX ||
3152 pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON) && 3132 pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON) &&
3153 pFormField->GetControl(nIndex)->IsChecked() != 0)); 3133 pFormField->GetControl(nIndex)->IsChecked() != 0));
3154 return TRUE; 3134 return true;
3155 } 3135 }
3156 3136
3157 FX_BOOL Field::isDefaultChecked(IJS_Context* cc, 3137 bool Field::isDefaultChecked(IJS_Context* cc,
3158 const std::vector<CJS_Value>& params, 3138 const std::vector<CJS_Value>& params,
3159 CJS_Value& vRet, 3139 CJS_Value& vRet,
3160 CFX_WideString& sError) { 3140 CFX_WideString& sError) {
3161 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); 3141 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
3162 3142
3163 int nIndex = -1; 3143 int nIndex = -1;
3164 if (params.size() >= 1) 3144 if (params.size() >= 1)
3165 nIndex = params[0].ToInt(pRuntime); 3145 nIndex = params[0].ToInt(pRuntime);
3166 3146
3167 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 3147 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
3168 if (FieldArray.empty()) 3148 if (FieldArray.empty())
3169 return FALSE; 3149 return false;
3170 3150
3171 CPDF_FormField* pFormField = FieldArray[0]; 3151 CPDF_FormField* pFormField = FieldArray[0];
3172 if (nIndex < 0 || nIndex >= pFormField->CountControls()) 3152 if (nIndex < 0 || nIndex >= pFormField->CountControls())
3173 return FALSE; 3153 return false;
3174 3154
3175 vRet = CJS_Value(pRuntime, 3155 vRet = CJS_Value(pRuntime,
3176 ((pFormField->GetFieldType() == FIELDTYPE_CHECKBOX || 3156 ((pFormField->GetFieldType() == FIELDTYPE_CHECKBOX ||
3177 pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON) && 3157 pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON) &&
3178 pFormField->GetControl(nIndex)->IsDefaultChecked() != 0)); 3158 pFormField->GetControl(nIndex)->IsDefaultChecked() != 0));
3179 return TRUE; 3159 return true;
3180 } 3160 }
3181 3161
3182 FX_BOOL Field::setAction(IJS_Context* cc, 3162 bool Field::setAction(IJS_Context* cc,
3183 const std::vector<CJS_Value>& params, 3163 const std::vector<CJS_Value>& params,
3184 CJS_Value& vRet, 3164 CJS_Value& vRet,
3185 CFX_WideString& sError) { 3165 CFX_WideString& sError) {
3186 return TRUE; 3166 return true;
3187 } 3167 }
3188 3168
3189 FX_BOOL Field::setFocus(IJS_Context* cc, 3169 bool Field::setFocus(IJS_Context* cc,
3190 const std::vector<CJS_Value>& params, 3170 const std::vector<CJS_Value>& params,
3191 CJS_Value& vRet, 3171 CJS_Value& vRet,
3192 CFX_WideString& sError) { 3172 CFX_WideString& sError) {
3193 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 3173 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
3194 if (FieldArray.empty()) 3174 if (FieldArray.empty())
3195 return FALSE; 3175 return false;
3196 3176
3197 CPDF_FormField* pFormField = FieldArray[0]; 3177 CPDF_FormField* pFormField = FieldArray[0];
3198 int32_t nCount = pFormField->CountControls(); 3178 int32_t nCount = pFormField->CountControls();
3199 if (nCount < 1) 3179 if (nCount < 1)
3200 return FALSE; 3180 return false;
3201 3181
3202 CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); 3182 CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
3203 CPDFSDK_Widget* pWidget = nullptr; 3183 CPDFSDK_Widget* pWidget = nullptr;
3204 if (nCount == 1) { 3184 if (nCount == 1) {
3205 pWidget = pInterForm->GetWidget(pFormField->GetControl(0), false); 3185 pWidget = pInterForm->GetWidget(pFormField->GetControl(0), false);
3206 } else { 3186 } else {
3207 UnderlyingPageType* pPage = 3187 UnderlyingPageType* pPage =
3208 UnderlyingFromFPDFPage(m_pFormFillEnv->GetCurrentPage( 3188 UnderlyingFromFPDFPage(m_pFormFillEnv->GetCurrentPage(
3209 m_pFormFillEnv->GetUnderlyingDocument())); 3189 m_pFormFillEnv->GetUnderlyingDocument()));
3210 if (!pPage) 3190 if (!pPage)
3211 return FALSE; 3191 return false;
3212 if (CPDFSDK_PageView* pCurPageView = 3192 if (CPDFSDK_PageView* pCurPageView =
3213 m_pFormFillEnv->GetPageView(pPage, true)) { 3193 m_pFormFillEnv->GetPageView(pPage, true)) {
3214 for (int32_t i = 0; i < nCount; i++) { 3194 for (int32_t i = 0; i < nCount; i++) {
3215 if (CPDFSDK_Widget* pTempWidget = 3195 if (CPDFSDK_Widget* pTempWidget =
3216 pInterForm->GetWidget(pFormField->GetControl(i), false)) { 3196 pInterForm->GetWidget(pFormField->GetControl(i), false)) {
3217 if (pTempWidget->GetPDFPage() == pCurPageView->GetPDFPage()) { 3197 if (pTempWidget->GetPDFPage() == pCurPageView->GetPDFPage()) {
3218 pWidget = pTempWidget; 3198 pWidget = pTempWidget;
3219 break; 3199 break;
3220 } 3200 }
3221 } 3201 }
3222 } 3202 }
3223 } 3203 }
3224 } 3204 }
3225 3205
3226 if (pWidget) { 3206 if (pWidget) {
3227 CPDFSDK_Annot::ObservedPtr pObserved(pWidget); 3207 CPDFSDK_Annot::ObservedPtr pObserved(pWidget);
3228 m_pFormFillEnv->SetFocusAnnot(&pObserved); 3208 m_pFormFillEnv->SetFocusAnnot(&pObserved);
3229 } 3209 }
3230 3210
3231 return TRUE; 3211 return true;
3232 } 3212 }
3233 3213
3234 FX_BOOL Field::setItems(IJS_Context* cc, 3214 bool Field::setItems(IJS_Context* cc,
3235 const std::vector<CJS_Value>& params, 3215 const std::vector<CJS_Value>& params,
3236 CJS_Value& vRet, 3216 CJS_Value& vRet,
3237 CFX_WideString& sError) { 3217 CFX_WideString& sError) {
3238 return TRUE; 3218 return true;
3239 } 3219 }
3240 3220
3241 FX_BOOL Field::setLock(IJS_Context* cc, 3221 bool Field::setLock(IJS_Context* cc,
3242 const std::vector<CJS_Value>& params, 3222 const std::vector<CJS_Value>& params,
3243 CJS_Value& vRet, 3223 CJS_Value& vRet,
3244 CFX_WideString& sError) { 3224 CFX_WideString& sError) {
3245 return FALSE; 3225 return false;
3246 } 3226 }
3247 3227
3248 FX_BOOL Field::signatureGetModifications(IJS_Context* cc, 3228 bool Field::signatureGetModifications(IJS_Context* cc,
3249 const std::vector<CJS_Value>& params, 3229 const std::vector<CJS_Value>& params,
3250 CJS_Value& vRet, 3230 CJS_Value& vRet,
3251 CFX_WideString& sError) { 3231 CFX_WideString& sError) {
3252 return FALSE; 3232 return false;
3253 } 3233 }
3254 3234
3255 FX_BOOL Field::signatureGetSeedValue(IJS_Context* cc, 3235 bool Field::signatureGetSeedValue(IJS_Context* cc,
3256 const std::vector<CJS_Value>& params, 3236 const std::vector<CJS_Value>& params,
3257 CJS_Value& vRet, 3237 CJS_Value& vRet,
3258 CFX_WideString& sError) { 3238 CFX_WideString& sError) {
3259 return FALSE; 3239 return false;
3260 } 3240 }
3261 3241
3262 FX_BOOL Field::signatureInfo(IJS_Context* cc, 3242 bool Field::signatureInfo(IJS_Context* cc,
3263 const std::vector<CJS_Value>& params, 3243 const std::vector<CJS_Value>& params,
3264 CJS_Value& vRet, 3244 CJS_Value& vRet,
3265 CFX_WideString& sError) { 3245 CFX_WideString& sError) {
3266 return FALSE; 3246 return false;
3267 } 3247 }
3268 3248
3269 FX_BOOL Field::signatureSetSeedValue(IJS_Context* cc, 3249 bool Field::signatureSetSeedValue(IJS_Context* cc,
3270 const std::vector<CJS_Value>& params, 3250 const std::vector<CJS_Value>& params,
3271 CJS_Value& vRet, 3251 CJS_Value& vRet,
3272 CFX_WideString& sError) { 3252 CFX_WideString& sError) {
3273 return FALSE; 3253 return false;
3274 } 3254 }
3275 3255
3276 FX_BOOL Field::signatureSign(IJS_Context* cc, 3256 bool Field::signatureSign(IJS_Context* cc,
3277 const std::vector<CJS_Value>& params, 3257 const std::vector<CJS_Value>& params,
3278 CJS_Value& vRet, 3258 CJS_Value& vRet,
3279 CFX_WideString& sError) { 3259 CFX_WideString& sError) {
3280 return FALSE; 3260 return false;
3281 } 3261 }
3282 3262
3283 FX_BOOL Field::signatureValidate(IJS_Context* cc, 3263 bool Field::signatureValidate(IJS_Context* cc,
3284 const std::vector<CJS_Value>& params, 3264 const std::vector<CJS_Value>& params,
3285 CJS_Value& vRet, 3265 CJS_Value& vRet,
3286 CFX_WideString& sError) { 3266 CFX_WideString& sError) {
3287 return FALSE; 3267 return false;
3288 } 3268 }
3289 3269
3290 FX_BOOL Field::source(IJS_Context* cc, 3270 bool Field::source(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
3291 CJS_PropValue& vp,
3292 CFX_WideString& sError) {
3293 if (vp.IsGetting()) { 3271 if (vp.IsGetting()) {
3294 vp << (CJS_Object*)nullptr; 3272 vp << (CJS_Object*)nullptr;
3295 } 3273 }
3296 3274
3297 return TRUE; 3275 return true;
3298 } 3276 }
3299 3277
3300 void Field::AddDelay_Int(FIELD_PROP prop, int32_t n) { 3278 void Field::AddDelay_Int(FIELD_PROP prop, int32_t n) {
3301 CJS_DelayData* pNewData = 3279 CJS_DelayData* pNewData =
3302 new CJS_DelayData(prop, m_nFormControlIndex, m_FieldName); 3280 new CJS_DelayData(prop, m_nFormControlIndex, m_FieldName);
3303 pNewData->num = n; 3281 pNewData->num = n;
3304 m_pJSDoc->AddDelayData(pNewData); 3282 m_pJSDoc->AddDelayData(pNewData);
3305 } 3283 }
3306 3284
3307 void Field::AddDelay_Bool(FIELD_PROP prop, bool b) { 3285 void Field::AddDelay_Bool(FIELD_PROP prop, bool b) {
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
3495 } 3473 }
3496 } 3474 }
3497 3475
3498 void Field::AddField(CPDFSDK_FormFillEnvironment* pFormFillEnv, 3476 void Field::AddField(CPDFSDK_FormFillEnvironment* pFormFillEnv,
3499 int nPageIndex, 3477 int nPageIndex,
3500 int nFieldType, 3478 int nFieldType,
3501 const CFX_WideString& sName, 3479 const CFX_WideString& sName,
3502 const CFX_FloatRect& rcCoords) { 3480 const CFX_FloatRect& rcCoords) {
3503 // Not supported. 3481 // Not supported.
3504 } 3482 }
OLDNEW
« no previous file with comments | « fpdfsdk/javascript/Field.h ('k') | fpdfsdk/javascript/Icon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698