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

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

Issue 2473103003: Revert: Only create widgets if really needed (Closed)
Patch Set: 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') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "fpdfsdk/javascript/Field.h" 7 #include "fpdfsdk/javascript/Field.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 bool bChangeMark, 313 bool bChangeMark,
314 bool bResetAP, 314 bool bResetAP,
315 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);
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 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) {
347 CPDFSDK_InterForm* pInterForm = 346 CPDFSDK_InterForm* pInterForm =
348 static_cast<CPDFSDK_InterForm*>(pFormFillEnv->GetInterForm()); 347 static_cast<CPDFSDK_InterForm*>(pFormFillEnv->GetInterForm());
349 return pInterForm ? pInterForm->GetWidget(pFormControl, createIfNeeded) 348 return pInterForm ? pInterForm->GetWidget(pFormControl) : nullptr;
350 : nullptr;
351 } 349 }
352 350
353 bool Field::ValueIsOccur(CPDF_FormField* pFormField, 351 bool Field::ValueIsOccur(CPDF_FormField* pFormField,
354 CFX_WideString csOptLabel) { 352 CFX_WideString csOptLabel) {
355 for (int i = 0, sz = pFormField->CountOptions(); i < sz; i++) { 353 for (int i = 0, sz = pFormField->CountOptions(); i < sz; i++) {
356 if (csOptLabel.Compare(pFormField->GetOptionLabel(i)) == 0) 354 if (csOptLabel.Compare(pFormField->GetOptionLabel(i)) == 0)
357 return true; 355 return true;
358 } 356 }
359 357
360 return false; 358 return false;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 } 445 }
448 } else { 446 } else {
449 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 447 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
450 if (FieldArray.empty()) 448 if (FieldArray.empty())
451 return false; 449 return false;
452 450
453 CPDF_FormField* pFormField = FieldArray[0]; 451 CPDF_FormField* pFormField = FieldArray[0];
454 if (!pFormField) 452 if (!pFormField)
455 return false; 453 return false;
456 454
457 CPDFSDK_Widget* pWidget = GetWidget( 455 CPDFSDK_Widget* pWidget =
458 m_pFormFillEnv.Get(), GetSmartFieldControl(pFormField), false); 456 GetWidget(m_pFormFillEnv.Get(), GetSmartFieldControl(pFormField));
459 if (!pWidget) 457 if (!pWidget)
460 return false; 458 return false;
461 459
462 switch (pWidget->GetBorderStyle()) { 460 switch (pWidget->GetBorderStyle()) {
463 case BorderStyle::SOLID: 461 case BorderStyle::SOLID:
464 vp << L"solid"; 462 vp << L"solid";
465 break; 463 break;
466 case BorderStyle::DASH: 464 case BorderStyle::DASH:
467 vp << L"dashed"; 465 vp << L"dashed";
468 break; 466 break;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 else 502 else
505 return; 503 return;
506 504
507 std::vector<CPDF_FormField*> FieldArray = 505 std::vector<CPDF_FormField*> FieldArray =
508 GetFormFields(pFormFillEnv, swFieldName); 506 GetFormFields(pFormFillEnv, swFieldName);
509 for (CPDF_FormField* pFormField : FieldArray) { 507 for (CPDF_FormField* pFormField : FieldArray) {
510 if (nControlIndex < 0) { 508 if (nControlIndex < 0) {
511 bool bSet = false; 509 bool bSet = false;
512 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { 510 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) {
513 if (CPDFSDK_Widget* pWidget = 511 if (CPDFSDK_Widget* pWidget =
514 GetWidget(pFormFillEnv, pFormField->GetControl(i), false)) { 512 GetWidget(pFormFillEnv, pFormField->GetControl(i))) {
515 if (pWidget->GetBorderStyle() != nBorderStyle) { 513 if (pWidget->GetBorderStyle() != nBorderStyle) {
516 pWidget->SetBorderStyle(nBorderStyle); 514 pWidget->SetBorderStyle(nBorderStyle);
517 bSet = true; 515 bSet = true;
518 } 516 }
519 } 517 }
520 } 518 }
521 if (bSet) 519 if (bSet)
522 UpdateFormField(pFormFillEnv, pFormField, true, true, true); 520 UpdateFormField(pFormFillEnv, pFormField, true, true, true);
523 } else { 521 } else {
524 if (nControlIndex >= pFormField->CountControls()) 522 if (nControlIndex >= pFormField->CountControls())
525 return; 523 return;
526 if (CPDF_FormControl* pFormControl = 524 if (CPDF_FormControl* pFormControl =
527 pFormField->GetControl(nControlIndex)) { 525 pFormField->GetControl(nControlIndex)) {
528 if (CPDFSDK_Widget* pWidget = 526 if (CPDFSDK_Widget* pWidget = GetWidget(pFormFillEnv, pFormControl)) {
529 GetWidget(pFormFillEnv, pFormControl, false)) {
530 if (pWidget->GetBorderStyle() != nBorderStyle) { 527 if (pWidget->GetBorderStyle() != nBorderStyle) {
531 pWidget->SetBorderStyle(nBorderStyle); 528 pWidget->SetBorderStyle(nBorderStyle);
532 UpdateFormControl(pFormFillEnv, pFormControl, true, true, true); 529 UpdateFormControl(pFormFillEnv, pFormControl, true, true, true);
533 } 530 }
534 } 531 }
535 } 532 }
536 } 533 }
537 } 534 }
538 } 535 }
539 536
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 } 1250 }
1254 } else { 1251 } else {
1255 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1252 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1256 if (FieldArray.empty()) 1253 if (FieldArray.empty())
1257 return false; 1254 return false;
1258 1255
1259 CPDF_FormField* pFormField = FieldArray[0]; 1256 CPDF_FormField* pFormField = FieldArray[0];
1260 ASSERT(pFormField); 1257 ASSERT(pFormField);
1261 CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); 1258 CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
1262 CPDFSDK_Widget* pWidget = 1259 CPDFSDK_Widget* pWidget =
1263 pInterForm->GetWidget(GetSmartFieldControl(pFormField), true); 1260 pInterForm->GetWidget(GetSmartFieldControl(pFormField));
1264 if (!pWidget) 1261 if (!pWidget)
1265 return false; 1262 return false;
1266 1263
1267 uint32_t dwFlag = pWidget->GetFlags(); 1264 uint32_t dwFlag = pWidget->GetFlags();
1268 1265
1269 if (ANNOTFLAG_INVISIBLE & dwFlag || ANNOTFLAG_HIDDEN & dwFlag) { 1266 if (ANNOTFLAG_INVISIBLE & dwFlag || ANNOTFLAG_HIDDEN & dwFlag) {
1270 vp << (int32_t)1; 1267 vp << (int32_t)1;
1271 } else { 1268 } else {
1272 if (ANNOTFLAG_PRINT & dwFlag) { 1269 if (ANNOTFLAG_PRINT & dwFlag) {
1273 if (ANNOTFLAG_NOVIEW & dwFlag) { 1270 if (ANNOTFLAG_NOVIEW & dwFlag) {
(...skipping 17 matching lines...) Expand all
1291 CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm(); 1288 CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm();
1292 std::vector<CPDF_FormField*> FieldArray = 1289 std::vector<CPDF_FormField*> FieldArray =
1293 GetFormFields(pFormFillEnv, swFieldName); 1290 GetFormFields(pFormFillEnv, swFieldName);
1294 for (CPDF_FormField* pFormField : FieldArray) { 1291 for (CPDF_FormField* pFormField : FieldArray) {
1295 if (nControlIndex < 0) { 1292 if (nControlIndex < 0) {
1296 bool bAnySet = false; 1293 bool bAnySet = false;
1297 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { 1294 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) {
1298 CPDF_FormControl* pFormControl = pFormField->GetControl(i); 1295 CPDF_FormControl* pFormControl = pFormField->GetControl(i);
1299 ASSERT(pFormControl); 1296 ASSERT(pFormControl);
1300 1297
1301 CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl, true); 1298 CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl);
1302 if (SetWidgetDisplayStatus(pWidget, number)) 1299 if (SetWidgetDisplayStatus(pWidget, number))
1303 bAnySet = true; 1300 bAnySet = true;
1304 } 1301 }
1305 1302
1306 if (bAnySet) 1303 if (bAnySet)
1307 UpdateFormField(pFormFillEnv, pFormField, true, false, true); 1304 UpdateFormField(pFormFillEnv, pFormField, true, false, true);
1308 } else { 1305 } else {
1309 if (nControlIndex >= pFormField->CountControls()) 1306 if (nControlIndex >= pFormField->CountControls())
1310 return; 1307 return;
1311 1308
1312 CPDF_FormControl* pFormControl = pFormField->GetControl(nControlIndex); 1309 CPDF_FormControl* pFormControl = pFormField->GetControl(nControlIndex);
1313 if (!pFormControl) 1310 if (!pFormControl)
1314 return; 1311 return;
1315 1312
1316 CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl, true); 1313 CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl);
1317 if (SetWidgetDisplayStatus(pWidget, number)) 1314 if (SetWidgetDisplayStatus(pWidget, number))
1318 UpdateFormControl(pFormFillEnv, pFormControl, true, false, true); 1315 UpdateFormControl(pFormFillEnv, pFormControl, true, false, true);
1319 } 1316 }
1320 } 1317 }
1321 } 1318 }
1322 1319
1323 bool Field::doc(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { 1320 bool Field::doc(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
1324 if (!vp.IsGetting()) { 1321 if (!vp.IsGetting()) {
1325 return false; 1322 return false;
1326 } 1323 }
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1515 } 1512 }
1516 } else { 1513 } else {
1517 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1514 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1518 if (FieldArray.empty()) 1515 if (FieldArray.empty())
1519 return false; 1516 return false;
1520 1517
1521 CPDF_FormField* pFormField = FieldArray[0]; 1518 CPDF_FormField* pFormField = FieldArray[0];
1522 ASSERT(pFormField); 1519 ASSERT(pFormField);
1523 CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); 1520 CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
1524 CPDFSDK_Widget* pWidget = 1521 CPDFSDK_Widget* pWidget =
1525 pInterForm->GetWidget(GetSmartFieldControl(pFormField), false); 1522 pInterForm->GetWidget(GetSmartFieldControl(pFormField));
1526 if (!pWidget) 1523 if (!pWidget)
1527 return false; 1524 return false;
1528 1525
1529 uint32_t dwFlags = pWidget->GetFlags(); 1526 uint32_t dwFlags = pWidget->GetFlags();
1530 1527
1531 if (ANNOTFLAG_INVISIBLE & dwFlags || ANNOTFLAG_HIDDEN & dwFlags) 1528 if (ANNOTFLAG_INVISIBLE & dwFlags || ANNOTFLAG_HIDDEN & dwFlags)
1532 vp << true; 1529 vp << true;
1533 else 1530 else
1534 vp << false; 1531 vp << false;
1535 } 1532 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1630 CPDF_FormField* pFormField = FieldArray[0]; 1627 CPDF_FormField* pFormField = FieldArray[0];
1631 ASSERT(pFormField); 1628 ASSERT(pFormField);
1632 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 1629 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
1633 if (!pFormControl) 1630 if (!pFormControl)
1634 return false; 1631 return false;
1635 1632
1636 CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); 1633 CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
1637 if (!pFormField->CountControls()) 1634 if (!pFormField->CountControls())
1638 return false; 1635 return false;
1639 1636
1640 CPDFSDK_Widget* pWidget = 1637 CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormField->GetControl(0));
1641 pInterForm->GetWidget(pFormField->GetControl(0), false);
1642 if (!pWidget) 1638 if (!pWidget)
1643 return false; 1639 return false;
1644 1640
1645 vp << (int32_t)pWidget->GetBorderWidth(); 1641 vp << (int32_t)pWidget->GetBorderWidth();
1646 } 1642 }
1647 1643
1648 return true; 1644 return true;
1649 } 1645 }
1650 1646
1651 void Field::SetLineWidth(CPDFSDK_FormFillEnvironment* pFormFillEnv, 1647 void Field::SetLineWidth(CPDFSDK_FormFillEnvironment* pFormFillEnv,
1652 const CFX_WideString& swFieldName, 1648 const CFX_WideString& swFieldName,
1653 int nControlIndex, 1649 int nControlIndex,
1654 int number) { 1650 int number) {
1655 CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm(); 1651 CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm();
1656 std::vector<CPDF_FormField*> FieldArray = 1652 std::vector<CPDF_FormField*> FieldArray =
1657 GetFormFields(pFormFillEnv, swFieldName); 1653 GetFormFields(pFormFillEnv, swFieldName);
1658 for (CPDF_FormField* pFormField : FieldArray) { 1654 for (CPDF_FormField* pFormField : FieldArray) {
1659 if (nControlIndex < 0) { 1655 if (nControlIndex < 0) {
1660 bool bSet = false; 1656 bool bSet = false;
1661 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { 1657 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) {
1662 CPDF_FormControl* pFormControl = pFormField->GetControl(i); 1658 CPDF_FormControl* pFormControl = pFormField->GetControl(i);
1663 ASSERT(pFormControl); 1659 ASSERT(pFormControl);
1664 1660
1665 if (CPDFSDK_Widget* pWidget = 1661 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) {
1666 pInterForm->GetWidget(pFormControl, false)) {
1667 if (number != pWidget->GetBorderWidth()) { 1662 if (number != pWidget->GetBorderWidth()) {
1668 pWidget->SetBorderWidth(number); 1663 pWidget->SetBorderWidth(number);
1669 bSet = true; 1664 bSet = true;
1670 } 1665 }
1671 } 1666 }
1672 } 1667 }
1673 if (bSet) 1668 if (bSet)
1674 UpdateFormField(pFormFillEnv, pFormField, true, true, true); 1669 UpdateFormField(pFormFillEnv, pFormField, true, true, true);
1675 } else { 1670 } else {
1676 if (nControlIndex >= pFormField->CountControls()) 1671 if (nControlIndex >= pFormField->CountControls())
1677 return; 1672 return;
1678 if (CPDF_FormControl* pFormControl = 1673 if (CPDF_FormControl* pFormControl =
1679 pFormField->GetControl(nControlIndex)) { 1674 pFormField->GetControl(nControlIndex)) {
1680 if (CPDFSDK_Widget* pWidget = 1675 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) {
1681 pInterForm->GetWidget(pFormControl, false)) {
1682 if (number != pWidget->GetBorderWidth()) { 1676 if (number != pWidget->GetBorderWidth()) {
1683 pWidget->SetBorderWidth(number); 1677 pWidget->SetBorderWidth(number);
1684 UpdateFormControl(pFormFillEnv, pFormControl, true, true, true); 1678 UpdateFormControl(pFormFillEnv, pFormControl, true, true, true);
1685 } 1679 }
1686 } 1680 }
1687 } 1681 }
1688 } 1682 }
1689 } 1683 }
1690 } 1684 }
1691 1685
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1897 return false; 1891 return false;
1898 1892
1899 bool bVP; 1893 bool bVP;
1900 vp >> bVP; 1894 vp >> bVP;
1901 1895
1902 for (CPDF_FormField* pFormField : FieldArray) { 1896 for (CPDF_FormField* pFormField : FieldArray) {
1903 if (m_nFormControlIndex < 0) { 1897 if (m_nFormControlIndex < 0) {
1904 bool bSet = false; 1898 bool bSet = false;
1905 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { 1899 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) {
1906 if (CPDFSDK_Widget* pWidget = 1900 if (CPDFSDK_Widget* pWidget =
1907 pInterForm->GetWidget(pFormField->GetControl(i), false)) { 1901 pInterForm->GetWidget(pFormField->GetControl(i))) {
1908 uint32_t dwFlags = pWidget->GetFlags(); 1902 uint32_t dwFlags = pWidget->GetFlags();
1909 if (bVP) 1903 if (bVP)
1910 dwFlags |= ANNOTFLAG_PRINT; 1904 dwFlags |= ANNOTFLAG_PRINT;
1911 else 1905 else
1912 dwFlags &= ~ANNOTFLAG_PRINT; 1906 dwFlags &= ~ANNOTFLAG_PRINT;
1913 1907
1914 if (dwFlags != pWidget->GetFlags()) { 1908 if (dwFlags != pWidget->GetFlags()) {
1915 pWidget->SetFlags(dwFlags); 1909 pWidget->SetFlags(dwFlags);
1916 bSet = true; 1910 bSet = true;
1917 } 1911 }
1918 } 1912 }
1919 } 1913 }
1920 1914
1921 if (bSet) 1915 if (bSet)
1922 UpdateFormField(m_pFormFillEnv.Get(), pFormField, true, false, true); 1916 UpdateFormField(m_pFormFillEnv.Get(), pFormField, true, false, true);
1923 } else { 1917 } else {
1924 if (m_nFormControlIndex >= pFormField->CountControls()) 1918 if (m_nFormControlIndex >= pFormField->CountControls())
1925 return false; 1919 return false;
1926 if (CPDF_FormControl* pFormControl = 1920 if (CPDF_FormControl* pFormControl =
1927 pFormField->GetControl(m_nFormControlIndex)) { 1921 pFormField->GetControl(m_nFormControlIndex)) {
1928 if (CPDFSDK_Widget* pWidget = 1922 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) {
1929 pInterForm->GetWidget(pFormControl, true)) {
1930 uint32_t dwFlags = pWidget->GetFlags(); 1923 uint32_t dwFlags = pWidget->GetFlags();
1931 if (bVP) 1924 if (bVP)
1932 dwFlags |= ANNOTFLAG_PRINT; 1925 dwFlags |= ANNOTFLAG_PRINT;
1933 else 1926 else
1934 dwFlags &= ~ANNOTFLAG_PRINT; 1927 dwFlags &= ~ANNOTFLAG_PRINT;
1935 1928
1936 if (dwFlags != pWidget->GetFlags()) { 1929 if (dwFlags != pWidget->GetFlags()) {
1937 pWidget->SetFlags(dwFlags); 1930 pWidget->SetFlags(dwFlags);
1938 UpdateFormControl(m_pFormFillEnv.Get(), 1931 UpdateFormControl(m_pFormFillEnv.Get(),
1939 pFormField->GetControl(m_nFormControlIndex), 1932 pFormField->GetControl(m_nFormControlIndex),
1940 true, false, true); 1933 true, false, true);
1941 } 1934 }
1942 } 1935 }
1943 } 1936 }
1944 } 1937 }
1945 } 1938 }
1946 } else { 1939 } else {
1947 CPDF_FormField* pFormField = FieldArray[0]; 1940 CPDF_FormField* pFormField = FieldArray[0];
1948 CPDFSDK_Widget* pWidget = 1941 CPDFSDK_Widget* pWidget =
1949 pInterForm->GetWidget(GetSmartFieldControl(pFormField), true); 1942 pInterForm->GetWidget(GetSmartFieldControl(pFormField));
1950 if (!pWidget) 1943 if (!pWidget)
1951 return false; 1944 return false;
1952 1945
1953 if (pWidget->GetFlags() & ANNOTFLAG_PRINT) 1946 if (pWidget->GetFlags() & ANNOTFLAG_PRINT)
1954 vp << true; 1947 vp << true;
1955 else 1948 else
1956 vp << false; 1949 vp << false;
1957 } 1950 }
1958 1951
1959 return true; 1952 return true;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
2046 crRect); 2039 crRect);
2047 } 2040 }
2048 } else { 2041 } else {
2049 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 2042 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
2050 if (FieldArray.empty()) 2043 if (FieldArray.empty())
2051 return false; 2044 return false;
2052 2045
2053 CPDF_FormField* pFormField = FieldArray[0]; 2046 CPDF_FormField* pFormField = FieldArray[0];
2054 CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); 2047 CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
2055 CPDFSDK_Widget* pWidget = 2048 CPDFSDK_Widget* pWidget =
2056 pInterForm->GetWidget(GetSmartFieldControl(pFormField), true); 2049 pInterForm->GetWidget(GetSmartFieldControl(pFormField));
2057 if (!pWidget) 2050 if (!pWidget)
2058 return false; 2051 return false;
2059 2052
2060 CFX_FloatRect crRect = pWidget->GetRect(); 2053 CFX_FloatRect crRect = pWidget->GetRect();
2061 Upper_Leftx = CJS_Value(pRuntime, static_cast<int32_t>(crRect.left)); 2054 Upper_Leftx = CJS_Value(pRuntime, static_cast<int32_t>(crRect.left));
2062 Upper_Lefty = CJS_Value(pRuntime, static_cast<int32_t>(crRect.top)); 2055 Upper_Lefty = CJS_Value(pRuntime, static_cast<int32_t>(crRect.top));
2063 Lower_Rightx = CJS_Value(pRuntime, static_cast<int32_t>(crRect.right)); 2056 Lower_Rightx = CJS_Value(pRuntime, static_cast<int32_t>(crRect.right));
2064 Lower_Righty = CJS_Value(pRuntime, static_cast<int32_t>(crRect.bottom)); 2057 Lower_Righty = CJS_Value(pRuntime, static_cast<int32_t>(crRect.bottom));
2065 2058
2066 CJS_Array rcArray; 2059 CJS_Array rcArray;
(...skipping 13 matching lines...) Expand all
2080 CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm(); 2073 CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm();
2081 std::vector<CPDF_FormField*> FieldArray = 2074 std::vector<CPDF_FormField*> FieldArray =
2082 GetFormFields(pFormFillEnv, swFieldName); 2075 GetFormFields(pFormFillEnv, swFieldName);
2083 for (CPDF_FormField* pFormField : FieldArray) { 2076 for (CPDF_FormField* pFormField : FieldArray) {
2084 if (nControlIndex < 0) { 2077 if (nControlIndex < 0) {
2085 bool bSet = false; 2078 bool bSet = false;
2086 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { 2079 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) {
2087 CPDF_FormControl* pFormControl = pFormField->GetControl(i); 2080 CPDF_FormControl* pFormControl = pFormField->GetControl(i);
2088 ASSERT(pFormControl); 2081 ASSERT(pFormControl);
2089 2082
2090 if (CPDFSDK_Widget* pWidget = 2083 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) {
2091 pInterForm->GetWidget(pFormControl, false)) {
2092 CFX_FloatRect crRect = rect; 2084 CFX_FloatRect crRect = rect;
2093 2085
2094 CPDF_Page* pPDFPage = pWidget->GetPDFPage(); 2086 CPDF_Page* pPDFPage = pWidget->GetPDFPage();
2095 crRect.Intersect(pPDFPage->GetPageBBox()); 2087 crRect.Intersect(pPDFPage->GetPageBBox());
2096 2088
2097 if (!crRect.IsEmpty()) { 2089 if (!crRect.IsEmpty()) {
2098 CFX_FloatRect rcOld = pWidget->GetRect(); 2090 CFX_FloatRect rcOld = pWidget->GetRect();
2099 if (crRect.left != rcOld.left || crRect.right != rcOld.right || 2091 if (crRect.left != rcOld.left || crRect.right != rcOld.right ||
2100 crRect.top != rcOld.top || crRect.bottom != rcOld.bottom) { 2092 crRect.top != rcOld.top || crRect.bottom != rcOld.bottom) {
2101 pWidget->SetRect(crRect); 2093 pWidget->SetRect(crRect);
2102 bSet = true; 2094 bSet = true;
2103 } 2095 }
2104 } 2096 }
2105 } 2097 }
2106 } 2098 }
2107 2099
2108 if (bSet) 2100 if (bSet)
2109 UpdateFormField(pFormFillEnv, pFormField, true, true, true); 2101 UpdateFormField(pFormFillEnv, pFormField, true, true, true);
2110 } else { 2102 } else {
2111 if (nControlIndex >= pFormField->CountControls()) 2103 if (nControlIndex >= pFormField->CountControls())
2112 return; 2104 return;
2113 if (CPDF_FormControl* pFormControl = 2105 if (CPDF_FormControl* pFormControl =
2114 pFormField->GetControl(nControlIndex)) { 2106 pFormField->GetControl(nControlIndex)) {
2115 if (CPDFSDK_Widget* pWidget = 2107 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) {
2116 pInterForm->GetWidget(pFormControl, false)) {
2117 CFX_FloatRect crRect = rect; 2108 CFX_FloatRect crRect = rect;
2118 2109
2119 CPDF_Page* pPDFPage = pWidget->GetPDFPage(); 2110 CPDF_Page* pPDFPage = pWidget->GetPDFPage();
2120 crRect.Intersect(pPDFPage->GetPageBBox()); 2111 crRect.Intersect(pPDFPage->GetPageBBox());
2121 2112
2122 if (!crRect.IsEmpty()) { 2113 if (!crRect.IsEmpty()) {
2123 CFX_FloatRect rcOld = pWidget->GetRect(); 2114 CFX_FloatRect rcOld = pWidget->GetRect();
2124 if (crRect.left != rcOld.left || crRect.right != rcOld.right || 2115 if (crRect.left != rcOld.left || crRect.right != rcOld.right ||
2125 crRect.top != rcOld.top || crRect.bottom != rcOld.bottom) { 2116 crRect.top != rcOld.top || crRect.bottom != rcOld.bottom) {
2126 pWidget->SetRect(crRect); 2117 pWidget->SetRect(crRect);
(...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after
3175 return false; 3166 return false;
3176 3167
3177 CPDF_FormField* pFormField = FieldArray[0]; 3168 CPDF_FormField* pFormField = FieldArray[0];
3178 int32_t nCount = pFormField->CountControls(); 3169 int32_t nCount = pFormField->CountControls();
3179 if (nCount < 1) 3170 if (nCount < 1)
3180 return false; 3171 return false;
3181 3172
3182 CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); 3173 CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
3183 CPDFSDK_Widget* pWidget = nullptr; 3174 CPDFSDK_Widget* pWidget = nullptr;
3184 if (nCount == 1) { 3175 if (nCount == 1) {
3185 pWidget = pInterForm->GetWidget(pFormField->GetControl(0), false); 3176 pWidget = pInterForm->GetWidget(pFormField->GetControl(0));
3186 } else { 3177 } else {
3187 UnderlyingPageType* pPage = 3178 UnderlyingPageType* pPage =
3188 UnderlyingFromFPDFPage(m_pFormFillEnv->GetCurrentPage( 3179 UnderlyingFromFPDFPage(m_pFormFillEnv->GetCurrentPage(
3189 m_pFormFillEnv->GetUnderlyingDocument())); 3180 m_pFormFillEnv->GetUnderlyingDocument()));
3190 if (!pPage) 3181 if (!pPage)
3191 return false; 3182 return false;
3192 if (CPDFSDK_PageView* pCurPageView = 3183 if (CPDFSDK_PageView* pCurPageView =
3193 m_pFormFillEnv->GetPageView(pPage, true)) { 3184 m_pFormFillEnv->GetPageView(pPage, true)) {
3194 for (int32_t i = 0; i < nCount; i++) { 3185 for (int32_t i = 0; i < nCount; i++) {
3195 if (CPDFSDK_Widget* pTempWidget = 3186 if (CPDFSDK_Widget* pTempWidget =
3196 pInterForm->GetWidget(pFormField->GetControl(i), false)) { 3187 pInterForm->GetWidget(pFormField->GetControl(i))) {
3197 if (pTempWidget->GetPDFPage() == pCurPageView->GetPDFPage()) { 3188 if (pTempWidget->GetPDFPage() == pCurPageView->GetPDFPage()) {
3198 pWidget = pTempWidget; 3189 pWidget = pTempWidget;
3199 break; 3190 break;
3200 } 3191 }
3201 } 3192 }
3202 } 3193 }
3203 } 3194 }
3204 } 3195 }
3205 3196
3206 if (pWidget) { 3197 if (pWidget) {
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
3473 } 3464 }
3474 } 3465 }
3475 3466
3476 void Field::AddField(CPDFSDK_FormFillEnvironment* pFormFillEnv, 3467 void Field::AddField(CPDFSDK_FormFillEnvironment* pFormFillEnv,
3477 int nPageIndex, 3468 int nPageIndex,
3478 int nFieldType, 3469 int nFieldType,
3479 const CFX_WideString& sName, 3470 const CFX_WideString& sName,
3480 const CFX_FloatRect& rcCoords) { 3471 const CFX_FloatRect& rcCoords) {
3481 // Not supported. 3472 // Not supported.
3482 } 3473 }
OLDNEW
« no previous file with comments | « fpdfsdk/javascript/Field.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698