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

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

Issue 2251453002: Only create widgets if really needed. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/javascript/Field.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "fpdfsdk/javascript/Field.h" 7 #include "fpdfsdk/javascript/Field.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 } 255 }
256 256
257 void Field::UpdateFormControl(CPDFSDK_Document* pDocument, 257 void Field::UpdateFormControl(CPDFSDK_Document* pDocument,
258 CPDF_FormControl* pFormControl, 258 CPDF_FormControl* pFormControl,
259 FX_BOOL bChangeMark, 259 FX_BOOL bChangeMark,
260 FX_BOOL bResetAP, 260 FX_BOOL bResetAP,
261 FX_BOOL bRefresh) { 261 FX_BOOL bRefresh) {
262 ASSERT(pFormControl); 262 ASSERT(pFormControl);
263 263
264 CPDFSDK_InterForm* pForm = pDocument->GetInterForm(); 264 CPDFSDK_InterForm* pForm = pDocument->GetInterForm();
265 CPDFSDK_Widget* pWidget = pForm->GetWidget(pFormControl); 265 CPDFSDK_Widget* pWidget = pForm->GetWidget(pFormControl, false);
266 266
267 if (pWidget) { 267 if (pWidget) {
268 if (bResetAP) { 268 if (bResetAP) {
269 int nFieldType = pWidget->GetFieldType(); 269 int nFieldType = pWidget->GetFieldType();
270 if (nFieldType == FIELDTYPE_COMBOBOX || 270 if (nFieldType == FIELDTYPE_COMBOBOX ||
271 nFieldType == FIELDTYPE_TEXTFIELD) { 271 nFieldType == FIELDTYPE_TEXTFIELD) {
272 FX_BOOL bFormated = FALSE; 272 FX_BOOL bFormated = FALSE;
273 CFX_WideString sValue = pWidget->OnFormat(bFormated); 273 CFX_WideString sValue = pWidget->OnFormat(bFormated);
274 if (bFormated) 274 if (bFormated)
275 pWidget->ResetAppearance(sValue.c_str(), FALSE); 275 pWidget->ResetAppearance(sValue.c_str(), FALSE);
276 else 276 else
277 pWidget->ResetAppearance(nullptr, FALSE); 277 pWidget->ResetAppearance(nullptr, FALSE);
278 } else { 278 } else {
279 pWidget->ResetAppearance(nullptr, FALSE); 279 pWidget->ResetAppearance(nullptr, FALSE);
280 } 280 }
281 } 281 }
282 282
283 if (bRefresh) { 283 if (bRefresh) {
284 CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm(); 284 CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm();
285 CPDFSDK_Document* pDoc = pInterForm->GetDocument(); 285 CPDFSDK_Document* pDoc = pInterForm->GetDocument();
286 pDoc->UpdateAllViews(nullptr, pWidget); 286 pDoc->UpdateAllViews(nullptr, pWidget);
287 } 287 }
288 } 288 }
289 289
290 if (bChangeMark) 290 if (bChangeMark)
291 pDocument->SetChangeMark(); 291 pDocument->SetChangeMark();
292 } 292 }
293 293
294 CPDFSDK_Widget* Field::GetWidget(CPDFSDK_Document* pDocument, 294 CPDFSDK_Widget* Field::GetWidget(CPDFSDK_Document* pDocument,
295 CPDF_FormControl* pFormControl) { 295 CPDF_FormControl* pFormControl,
296 bool createIfNeeded) {
296 CPDFSDK_InterForm* pInterForm = 297 CPDFSDK_InterForm* pInterForm =
297 static_cast<CPDFSDK_InterForm*>(pDocument->GetInterForm()); 298 static_cast<CPDFSDK_InterForm*>(pDocument->GetInterForm());
298 return pInterForm ? pInterForm->GetWidget(pFormControl) : nullptr; 299 return pInterForm ? pInterForm->GetWidget(pFormControl, createIfNeeded)
300 : nullptr;
299 } 301 }
300 302
301 FX_BOOL Field::ValueIsOccur(CPDF_FormField* pFormField, 303 FX_BOOL Field::ValueIsOccur(CPDF_FormField* pFormField,
302 CFX_WideString csOptLabel) { 304 CFX_WideString csOptLabel) {
303 for (int i = 0, sz = pFormField->CountOptions(); i < sz; i++) { 305 for (int i = 0, sz = pFormField->CountOptions(); i < sz; i++) {
304 if (csOptLabel.Compare(pFormField->GetOptionLabel(i)) == 0) 306 if (csOptLabel.Compare(pFormField->GetOptionLabel(i)) == 0)
305 return TRUE; 307 return TRUE;
306 } 308 }
307 309
308 return FALSE; 310 return FALSE;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 } else { 398 } else {
397 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 399 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
398 if (FieldArray.empty()) 400 if (FieldArray.empty())
399 return FALSE; 401 return FALSE;
400 402
401 CPDF_FormField* pFormField = FieldArray[0]; 403 CPDF_FormField* pFormField = FieldArray[0];
402 if (!pFormField) 404 if (!pFormField)
403 return FALSE; 405 return FALSE;
404 406
405 CPDFSDK_Widget* pWidget = 407 CPDFSDK_Widget* pWidget =
406 GetWidget(m_pDocument, GetSmartFieldControl(pFormField)); 408 GetWidget(m_pDocument, GetSmartFieldControl(pFormField), false);
407 if (!pWidget) 409 if (!pWidget)
408 return FALSE; 410 return FALSE;
409 411
410 switch (pWidget->GetBorderStyle()) { 412 switch (pWidget->GetBorderStyle()) {
411 case BorderStyle::SOLID: 413 case BorderStyle::SOLID:
412 vp << L"solid"; 414 vp << L"solid";
413 break; 415 break;
414 case BorderStyle::DASH: 416 case BorderStyle::DASH:
415 vp << L"dashed"; 417 vp << L"dashed";
416 break; 418 break;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 else 454 else
453 return; 455 return;
454 456
455 std::vector<CPDF_FormField*> FieldArray = 457 std::vector<CPDF_FormField*> FieldArray =
456 GetFormFields(pDocument, swFieldName); 458 GetFormFields(pDocument, swFieldName);
457 for (CPDF_FormField* pFormField : FieldArray) { 459 for (CPDF_FormField* pFormField : FieldArray) {
458 if (nControlIndex < 0) { 460 if (nControlIndex < 0) {
459 FX_BOOL bSet = FALSE; 461 FX_BOOL bSet = FALSE;
460 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { 462 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) {
461 if (CPDFSDK_Widget* pWidget = 463 if (CPDFSDK_Widget* pWidget =
462 GetWidget(pDocument, pFormField->GetControl(i))) { 464 GetWidget(pDocument, pFormField->GetControl(i), false)) {
463 if (pWidget->GetBorderStyle() != nBorderStyle) { 465 if (pWidget->GetBorderStyle() != nBorderStyle) {
464 pWidget->SetBorderStyle(nBorderStyle); 466 pWidget->SetBorderStyle(nBorderStyle);
465 bSet = TRUE; 467 bSet = TRUE;
466 } 468 }
467 } 469 }
468 } 470 }
469 if (bSet) 471 if (bSet)
470 UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE); 472 UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE);
471 } else { 473 } else {
472 if (nControlIndex >= pFormField->CountControls()) 474 if (nControlIndex >= pFormField->CountControls())
473 return; 475 return;
474 if (CPDF_FormControl* pFormControl = 476 if (CPDF_FormControl* pFormControl =
475 pFormField->GetControl(nControlIndex)) { 477 pFormField->GetControl(nControlIndex)) {
476 if (CPDFSDK_Widget* pWidget = GetWidget(pDocument, pFormControl)) { 478 if (CPDFSDK_Widget* pWidget =
479 GetWidget(pDocument, pFormControl, false)) {
477 if (pWidget->GetBorderStyle() != nBorderStyle) { 480 if (pWidget->GetBorderStyle() != nBorderStyle) {
478 pWidget->SetBorderStyle(nBorderStyle); 481 pWidget->SetBorderStyle(nBorderStyle);
479 UpdateFormControl(pDocument, pFormControl, TRUE, TRUE, TRUE); 482 UpdateFormControl(pDocument, pFormControl, TRUE, TRUE, TRUE);
480 } 483 }
481 } 484 }
482 } 485 }
483 } 486 }
484 } 487 }
485 } 488 }
486 489
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
1201 } 1204 }
1202 } else { 1205 } else {
1203 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1206 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1204 if (FieldArray.empty()) 1207 if (FieldArray.empty())
1205 return FALSE; 1208 return FALSE;
1206 1209
1207 CPDF_FormField* pFormField = FieldArray[0]; 1210 CPDF_FormField* pFormField = FieldArray[0];
1208 ASSERT(pFormField); 1211 ASSERT(pFormField);
1209 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); 1212 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm();
1210 CPDFSDK_Widget* pWidget = 1213 CPDFSDK_Widget* pWidget =
1211 pInterForm->GetWidget(GetSmartFieldControl(pFormField)); 1214 pInterForm->GetWidget(GetSmartFieldControl(pFormField), true);
1212 if (!pWidget) 1215 if (!pWidget)
1213 return FALSE; 1216 return FALSE;
1214 1217
1215 uint32_t dwFlag = pWidget->GetFlags(); 1218 uint32_t dwFlag = pWidget->GetFlags();
1216 1219
1217 if (ANNOTFLAG_INVISIBLE & dwFlag || ANNOTFLAG_HIDDEN & dwFlag) { 1220 if (ANNOTFLAG_INVISIBLE & dwFlag || ANNOTFLAG_HIDDEN & dwFlag) {
1218 vp << (int32_t)1; 1221 vp << (int32_t)1;
1219 } else { 1222 } else {
1220 if (ANNOTFLAG_PRINT & dwFlag) { 1223 if (ANNOTFLAG_PRINT & dwFlag) {
1221 if (ANNOTFLAG_NOVIEW & dwFlag) { 1224 if (ANNOTFLAG_NOVIEW & dwFlag) {
(...skipping 17 matching lines...) Expand all
1239 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); 1242 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm();
1240 std::vector<CPDF_FormField*> FieldArray = 1243 std::vector<CPDF_FormField*> FieldArray =
1241 GetFormFields(pDocument, swFieldName); 1244 GetFormFields(pDocument, swFieldName);
1242 for (CPDF_FormField* pFormField : FieldArray) { 1245 for (CPDF_FormField* pFormField : FieldArray) {
1243 if (nControlIndex < 0) { 1246 if (nControlIndex < 0) {
1244 FX_BOOL bSet = FALSE; 1247 FX_BOOL bSet = FALSE;
1245 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { 1248 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) {
1246 CPDF_FormControl* pFormControl = pFormField->GetControl(i); 1249 CPDF_FormControl* pFormControl = pFormField->GetControl(i);
1247 ASSERT(pFormControl); 1250 ASSERT(pFormControl);
1248 1251
1249 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) { 1252 if (CPDFSDK_Widget* pWidget =
1253 pInterForm->GetWidget(pFormControl, true)) {
1250 uint32_t dwFlag = pWidget->GetFlags(); 1254 uint32_t dwFlag = pWidget->GetFlags();
1251 switch (number) { 1255 switch (number) {
1252 case 0: 1256 case 0:
1253 dwFlag &= (~ANNOTFLAG_INVISIBLE); 1257 dwFlag &= (~ANNOTFLAG_INVISIBLE);
1254 dwFlag &= (~ANNOTFLAG_HIDDEN); 1258 dwFlag &= (~ANNOTFLAG_HIDDEN);
1255 dwFlag &= (~ANNOTFLAG_NOVIEW); 1259 dwFlag &= (~ANNOTFLAG_NOVIEW);
1256 dwFlag |= ANNOTFLAG_PRINT; 1260 dwFlag |= ANNOTFLAG_PRINT;
1257 break; 1261 break;
1258 case 1: 1262 case 1:
1259 dwFlag &= (~ANNOTFLAG_INVISIBLE); 1263 dwFlag &= (~ANNOTFLAG_INVISIBLE);
(...skipping 20 matching lines...) Expand all
1280 } 1284 }
1281 } 1285 }
1282 1286
1283 if (bSet) 1287 if (bSet)
1284 UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE); 1288 UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE);
1285 } else { 1289 } else {
1286 if (nControlIndex >= pFormField->CountControls()) 1290 if (nControlIndex >= pFormField->CountControls())
1287 return; 1291 return;
1288 if (CPDF_FormControl* pFormControl = 1292 if (CPDF_FormControl* pFormControl =
1289 pFormField->GetControl(nControlIndex)) { 1293 pFormField->GetControl(nControlIndex)) {
1290 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) { 1294 if (CPDFSDK_Widget* pWidget =
1295 pInterForm->GetWidget(pFormControl, true)) {
1291 uint32_t dwFlag = pWidget->GetFlags(); 1296 uint32_t dwFlag = pWidget->GetFlags();
1292 switch (number) { 1297 switch (number) {
1293 case 0: 1298 case 0:
1294 dwFlag &= (~ANNOTFLAG_INVISIBLE); 1299 dwFlag &= (~ANNOTFLAG_INVISIBLE);
1295 dwFlag &= (~ANNOTFLAG_HIDDEN); 1300 dwFlag &= (~ANNOTFLAG_HIDDEN);
1296 dwFlag &= (~ANNOTFLAG_NOVIEW); 1301 dwFlag &= (~ANNOTFLAG_NOVIEW);
1297 dwFlag |= ANNOTFLAG_PRINT; 1302 dwFlag |= ANNOTFLAG_PRINT;
1298 break; 1303 break;
1299 case 1: 1304 case 1:
1300 dwFlag &= (~ANNOTFLAG_INVISIBLE); 1305 dwFlag &= (~ANNOTFLAG_INVISIBLE);
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1518 } 1523 }
1519 } else { 1524 } else {
1520 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1525 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1521 if (FieldArray.empty()) 1526 if (FieldArray.empty())
1522 return FALSE; 1527 return FALSE;
1523 1528
1524 CPDF_FormField* pFormField = FieldArray[0]; 1529 CPDF_FormField* pFormField = FieldArray[0];
1525 ASSERT(pFormField); 1530 ASSERT(pFormField);
1526 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); 1531 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm();
1527 CPDFSDK_Widget* pWidget = 1532 CPDFSDK_Widget* pWidget =
1528 pInterForm->GetWidget(GetSmartFieldControl(pFormField)); 1533 pInterForm->GetWidget(GetSmartFieldControl(pFormField), false);
1529 if (!pWidget) 1534 if (!pWidget)
1530 return FALSE; 1535 return FALSE;
1531 1536
1532 uint32_t dwFlags = pWidget->GetFlags(); 1537 uint32_t dwFlags = pWidget->GetFlags();
1533 1538
1534 if (ANNOTFLAG_INVISIBLE & dwFlags || ANNOTFLAG_HIDDEN & dwFlags) 1539 if (ANNOTFLAG_INVISIBLE & dwFlags || ANNOTFLAG_HIDDEN & dwFlags)
1535 vp << true; 1540 vp << true;
1536 else 1541 else
1537 vp << false; 1542 vp << false;
1538 } 1543 }
1539 1544
1540 return TRUE; 1545 return TRUE;
1541 } 1546 }
1542 1547
1543 void Field::SetHidden(CPDFSDK_Document* pDocument, 1548 void Field::SetHidden(CPDFSDK_Document* pDocument,
1544 const CFX_WideString& swFieldName, 1549 const CFX_WideString& swFieldName,
1545 int nControlIndex, 1550 int nControlIndex,
1546 bool b) { 1551 bool b) {
1547 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); 1552 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm();
1548 std::vector<CPDF_FormField*> FieldArray = 1553 std::vector<CPDF_FormField*> FieldArray =
1549 GetFormFields(pDocument, swFieldName); 1554 GetFormFields(pDocument, swFieldName);
1550 for (CPDF_FormField* pFormField : FieldArray) { 1555 for (CPDF_FormField* pFormField : FieldArray) {
1551 if (nControlIndex < 0) { 1556 if (nControlIndex < 0) {
1552 FX_BOOL bSet = FALSE; 1557 FX_BOOL bSet = FALSE;
1553 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { 1558 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) {
1554 if (CPDFSDK_Widget* pWidget = 1559 if (CPDFSDK_Widget* pWidget =
1555 pInterForm->GetWidget(pFormField->GetControl(i))) { 1560 pInterForm->GetWidget(pFormField->GetControl(i), false)) {
1556 uint32_t dwFlags = pWidget->GetFlags(); 1561 uint32_t dwFlags = pWidget->GetFlags();
1557 1562
1558 if (b) { 1563 if (b) {
1559 dwFlags &= (~ANNOTFLAG_INVISIBLE); 1564 dwFlags &= (~ANNOTFLAG_INVISIBLE);
1560 dwFlags &= (~ANNOTFLAG_NOVIEW); 1565 dwFlags &= (~ANNOTFLAG_NOVIEW);
1561 dwFlags |= (ANNOTFLAG_HIDDEN | ANNOTFLAG_PRINT); 1566 dwFlags |= (ANNOTFLAG_HIDDEN | ANNOTFLAG_PRINT);
1562 } else { 1567 } else {
1563 dwFlags &= (~ANNOTFLAG_INVISIBLE); 1568 dwFlags &= (~ANNOTFLAG_INVISIBLE);
1564 dwFlags &= (~ANNOTFLAG_HIDDEN); 1569 dwFlags &= (~ANNOTFLAG_HIDDEN);
1565 dwFlags &= (~ANNOTFLAG_NOVIEW); 1570 dwFlags &= (~ANNOTFLAG_NOVIEW);
1566 dwFlags |= ANNOTFLAG_PRINT; 1571 dwFlags |= ANNOTFLAG_PRINT;
1567 } 1572 }
1568 1573
1569 if (dwFlags != pWidget->GetFlags()) { 1574 if (dwFlags != pWidget->GetFlags()) {
1570 pWidget->SetFlags(dwFlags); 1575 pWidget->SetFlags(dwFlags);
1571 bSet = TRUE; 1576 bSet = TRUE;
1572 } 1577 }
1573 } 1578 }
1574 } 1579 }
1575 1580
1576 if (bSet) 1581 if (bSet)
1577 UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE); 1582 UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE);
1578 } else { 1583 } else {
1579 if (nControlIndex >= pFormField->CountControls()) 1584 if (nControlIndex >= pFormField->CountControls())
1580 return; 1585 return;
1581 if (CPDF_FormControl* pFormControl = 1586 if (CPDF_FormControl* pFormControl =
1582 pFormField->GetControl(nControlIndex)) { 1587 pFormField->GetControl(nControlIndex)) {
1583 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) { 1588 if (CPDFSDK_Widget* pWidget =
1589 pInterForm->GetWidget(pFormControl, false)) {
1584 uint32_t dwFlags = pWidget->GetFlags(); 1590 uint32_t dwFlags = pWidget->GetFlags();
1585 1591
1586 if (b) { 1592 if (b) {
1587 dwFlags &= (~ANNOTFLAG_INVISIBLE); 1593 dwFlags &= (~ANNOTFLAG_INVISIBLE);
1588 dwFlags &= (~ANNOTFLAG_NOVIEW); 1594 dwFlags &= (~ANNOTFLAG_NOVIEW);
1589 dwFlags |= (ANNOTFLAG_HIDDEN | ANNOTFLAG_PRINT); 1595 dwFlags |= (ANNOTFLAG_HIDDEN | ANNOTFLAG_PRINT);
1590 } else { 1596 } else {
1591 dwFlags &= (~ANNOTFLAG_INVISIBLE); 1597 dwFlags &= (~ANNOTFLAG_INVISIBLE);
1592 dwFlags &= (~ANNOTFLAG_HIDDEN); 1598 dwFlags &= (~ANNOTFLAG_HIDDEN);
1593 dwFlags &= (~ANNOTFLAG_NOVIEW); 1599 dwFlags &= (~ANNOTFLAG_NOVIEW);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1689 CPDF_FormField* pFormField = FieldArray[0]; 1695 CPDF_FormField* pFormField = FieldArray[0];
1690 ASSERT(pFormField); 1696 ASSERT(pFormField);
1691 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 1697 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
1692 if (!pFormControl) 1698 if (!pFormControl)
1693 return FALSE; 1699 return FALSE;
1694 1700
1695 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); 1701 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm();
1696 if (!pFormField->CountControls()) 1702 if (!pFormField->CountControls())
1697 return FALSE; 1703 return FALSE;
1698 1704
1699 CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormField->GetControl(0)); 1705 CPDFSDK_Widget* pWidget =
1706 pInterForm->GetWidget(pFormField->GetControl(0), false);
1700 if (!pWidget) 1707 if (!pWidget)
1701 return FALSE; 1708 return FALSE;
1702 1709
1703 vp << (int32_t)pWidget->GetBorderWidth(); 1710 vp << (int32_t)pWidget->GetBorderWidth();
1704 } 1711 }
1705 1712
1706 return TRUE; 1713 return TRUE;
1707 } 1714 }
1708 1715
1709 void Field::SetLineWidth(CPDFSDK_Document* pDocument, 1716 void Field::SetLineWidth(CPDFSDK_Document* pDocument,
1710 const CFX_WideString& swFieldName, 1717 const CFX_WideString& swFieldName,
1711 int nControlIndex, 1718 int nControlIndex,
1712 int number) { 1719 int number) {
1713 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); 1720 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm();
1714 std::vector<CPDF_FormField*> FieldArray = 1721 std::vector<CPDF_FormField*> FieldArray =
1715 GetFormFields(pDocument, swFieldName); 1722 GetFormFields(pDocument, swFieldName);
1716 for (CPDF_FormField* pFormField : FieldArray) { 1723 for (CPDF_FormField* pFormField : FieldArray) {
1717 if (nControlIndex < 0) { 1724 if (nControlIndex < 0) {
1718 FX_BOOL bSet = FALSE; 1725 FX_BOOL bSet = FALSE;
1719 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { 1726 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) {
1720 CPDF_FormControl* pFormControl = pFormField->GetControl(i); 1727 CPDF_FormControl* pFormControl = pFormField->GetControl(i);
1721 ASSERT(pFormControl); 1728 ASSERT(pFormControl);
1722 1729
1723 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) { 1730 if (CPDFSDK_Widget* pWidget =
1731 pInterForm->GetWidget(pFormControl, false)) {
1724 if (number != pWidget->GetBorderWidth()) { 1732 if (number != pWidget->GetBorderWidth()) {
1725 pWidget->SetBorderWidth(number); 1733 pWidget->SetBorderWidth(number);
1726 bSet = TRUE; 1734 bSet = TRUE;
1727 } 1735 }
1728 } 1736 }
1729 } 1737 }
1730 if (bSet) 1738 if (bSet)
1731 UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE); 1739 UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE);
1732 } else { 1740 } else {
1733 if (nControlIndex >= pFormField->CountControls()) 1741 if (nControlIndex >= pFormField->CountControls())
1734 return; 1742 return;
1735 if (CPDF_FormControl* pFormControl = 1743 if (CPDF_FormControl* pFormControl =
1736 pFormField->GetControl(nControlIndex)) { 1744 pFormField->GetControl(nControlIndex)) {
1737 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) { 1745 if (CPDFSDK_Widget* pWidget =
1746 pInterForm->GetWidget(pFormControl, false)) {
1738 if (number != pWidget->GetBorderWidth()) { 1747 if (number != pWidget->GetBorderWidth()) {
1739 pWidget->SetBorderWidth(number); 1748 pWidget->SetBorderWidth(number);
1740 UpdateFormControl(pDocument, pFormControl, TRUE, TRUE, TRUE); 1749 UpdateFormControl(pDocument, pFormControl, TRUE, TRUE, TRUE);
1741 } 1750 }
1742 } 1751 }
1743 } 1752 }
1744 } 1753 }
1745 } 1754 }
1746 } 1755 }
1747 1756
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
1958 return FALSE; 1967 return FALSE;
1959 1968
1960 bool bVP; 1969 bool bVP;
1961 vp >> bVP; 1970 vp >> bVP;
1962 1971
1963 for (CPDF_FormField* pFormField : FieldArray) { 1972 for (CPDF_FormField* pFormField : FieldArray) {
1964 if (m_nFormControlIndex < 0) { 1973 if (m_nFormControlIndex < 0) {
1965 FX_BOOL bSet = FALSE; 1974 FX_BOOL bSet = FALSE;
1966 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { 1975 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) {
1967 if (CPDFSDK_Widget* pWidget = 1976 if (CPDFSDK_Widget* pWidget =
1968 pInterForm->GetWidget(pFormField->GetControl(i))) { 1977 pInterForm->GetWidget(pFormField->GetControl(i), false)) {
1969 uint32_t dwFlags = pWidget->GetFlags(); 1978 uint32_t dwFlags = pWidget->GetFlags();
1970 if (bVP) 1979 if (bVP)
1971 dwFlags |= ANNOTFLAG_PRINT; 1980 dwFlags |= ANNOTFLAG_PRINT;
1972 else 1981 else
1973 dwFlags &= ~ANNOTFLAG_PRINT; 1982 dwFlags &= ~ANNOTFLAG_PRINT;
1974 1983
1975 if (dwFlags != pWidget->GetFlags()) { 1984 if (dwFlags != pWidget->GetFlags()) {
1976 pWidget->SetFlags(dwFlags); 1985 pWidget->SetFlags(dwFlags);
1977 bSet = TRUE; 1986 bSet = TRUE;
1978 } 1987 }
1979 } 1988 }
1980 } 1989 }
1981 1990
1982 if (bSet) 1991 if (bSet)
1983 UpdateFormField(m_pDocument, pFormField, TRUE, FALSE, TRUE); 1992 UpdateFormField(m_pDocument, pFormField, TRUE, FALSE, TRUE);
1984 } else { 1993 } else {
1985 if (m_nFormControlIndex >= pFormField->CountControls()) 1994 if (m_nFormControlIndex >= pFormField->CountControls())
1986 return FALSE; 1995 return FALSE;
1987 if (CPDF_FormControl* pFormControl = 1996 if (CPDF_FormControl* pFormControl =
1988 pFormField->GetControl(m_nFormControlIndex)) { 1997 pFormField->GetControl(m_nFormControlIndex)) {
1989 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) { 1998 if (CPDFSDK_Widget* pWidget =
1999 pInterForm->GetWidget(pFormControl, true)) {
1990 uint32_t dwFlags = pWidget->GetFlags(); 2000 uint32_t dwFlags = pWidget->GetFlags();
1991 if (bVP) 2001 if (bVP)
1992 dwFlags |= ANNOTFLAG_PRINT; 2002 dwFlags |= ANNOTFLAG_PRINT;
1993 else 2003 else
1994 dwFlags &= ~ANNOTFLAG_PRINT; 2004 dwFlags &= ~ANNOTFLAG_PRINT;
1995 2005
1996 if (dwFlags != pWidget->GetFlags()) { 2006 if (dwFlags != pWidget->GetFlags()) {
1997 pWidget->SetFlags(dwFlags); 2007 pWidget->SetFlags(dwFlags);
1998 UpdateFormControl(m_pDocument, 2008 UpdateFormControl(m_pDocument,
1999 pFormField->GetControl(m_nFormControlIndex), 2009 pFormField->GetControl(m_nFormControlIndex),
2000 TRUE, FALSE, TRUE); 2010 TRUE, FALSE, TRUE);
2001 } 2011 }
2002 } 2012 }
2003 } 2013 }
2004 } 2014 }
2005 } 2015 }
2006 } else { 2016 } else {
2007 CPDF_FormField* pFormField = FieldArray[0]; 2017 CPDF_FormField* pFormField = FieldArray[0];
2008 CPDFSDK_Widget* pWidget = 2018 CPDFSDK_Widget* pWidget =
2009 pInterForm->GetWidget(GetSmartFieldControl(pFormField)); 2019 pInterForm->GetWidget(GetSmartFieldControl(pFormField), true);
2010 if (!pWidget) 2020 if (!pWidget)
2011 return FALSE; 2021 return FALSE;
2012 2022
2013 if (pWidget->GetFlags() & ANNOTFLAG_PRINT) 2023 if (pWidget->GetFlags() & ANNOTFLAG_PRINT)
2014 vp << true; 2024 vp << true;
2015 else 2025 else
2016 vp << false; 2026 vp << false;
2017 } 2027 }
2018 2028
2019 return TRUE; 2029 return TRUE;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
2111 Field::SetRect(m_pDocument, m_FieldName, m_nFormControlIndex, crRect); 2121 Field::SetRect(m_pDocument, m_FieldName, m_nFormControlIndex, crRect);
2112 } 2122 }
2113 } else { 2123 } else {
2114 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 2124 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
2115 if (FieldArray.empty()) 2125 if (FieldArray.empty())
2116 return FALSE; 2126 return FALSE;
2117 2127
2118 CPDF_FormField* pFormField = FieldArray[0]; 2128 CPDF_FormField* pFormField = FieldArray[0];
2119 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); 2129 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm();
2120 CPDFSDK_Widget* pWidget = 2130 CPDFSDK_Widget* pWidget =
2121 pInterForm->GetWidget(GetSmartFieldControl(pFormField)); 2131 pInterForm->GetWidget(GetSmartFieldControl(pFormField), true);
2122 if (!pWidget) 2132 if (!pWidget)
2123 return FALSE; 2133 return FALSE;
2124 2134
2125 CFX_FloatRect crRect = pWidget->GetRect(); 2135 CFX_FloatRect crRect = pWidget->GetRect();
2126 Upper_Leftx = CJS_Value(pRuntime, static_cast<int32_t>(crRect.left)); 2136 Upper_Leftx = CJS_Value(pRuntime, static_cast<int32_t>(crRect.left));
2127 Upper_Lefty = CJS_Value(pRuntime, static_cast<int32_t>(crRect.top)); 2137 Upper_Lefty = CJS_Value(pRuntime, static_cast<int32_t>(crRect.top));
2128 Lower_Rightx = CJS_Value(pRuntime, static_cast<int32_t>(crRect.right)); 2138 Lower_Rightx = CJS_Value(pRuntime, static_cast<int32_t>(crRect.right));
2129 Lower_Righty = CJS_Value(pRuntime, static_cast<int32_t>(crRect.bottom)); 2139 Lower_Righty = CJS_Value(pRuntime, static_cast<int32_t>(crRect.bottom));
2130 2140
2131 CJS_Array rcArray; 2141 CJS_Array rcArray;
(...skipping 13 matching lines...) Expand all
2145 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); 2155 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm();
2146 std::vector<CPDF_FormField*> FieldArray = 2156 std::vector<CPDF_FormField*> FieldArray =
2147 GetFormFields(pDocument, swFieldName); 2157 GetFormFields(pDocument, swFieldName);
2148 for (CPDF_FormField* pFormField : FieldArray) { 2158 for (CPDF_FormField* pFormField : FieldArray) {
2149 if (nControlIndex < 0) { 2159 if (nControlIndex < 0) {
2150 FX_BOOL bSet = FALSE; 2160 FX_BOOL bSet = FALSE;
2151 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { 2161 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) {
2152 CPDF_FormControl* pFormControl = pFormField->GetControl(i); 2162 CPDF_FormControl* pFormControl = pFormField->GetControl(i);
2153 ASSERT(pFormControl); 2163 ASSERT(pFormControl);
2154 2164
2155 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) { 2165 if (CPDFSDK_Widget* pWidget =
2166 pInterForm->GetWidget(pFormControl, false)) {
2156 CFX_FloatRect crRect = rect; 2167 CFX_FloatRect crRect = rect;
2157 2168
2158 CPDF_Page* pPDFPage = pWidget->GetPDFPage(); 2169 CPDF_Page* pPDFPage = pWidget->GetPDFPage();
2159 crRect.Intersect(pPDFPage->GetPageBBox()); 2170 crRect.Intersect(pPDFPage->GetPageBBox());
2160 2171
2161 if (!crRect.IsEmpty()) { 2172 if (!crRect.IsEmpty()) {
2162 CFX_FloatRect rcOld = pWidget->GetRect(); 2173 CFX_FloatRect rcOld = pWidget->GetRect();
2163 if (crRect.left != rcOld.left || crRect.right != rcOld.right || 2174 if (crRect.left != rcOld.left || crRect.right != rcOld.right ||
2164 crRect.top != rcOld.top || crRect.bottom != rcOld.bottom) { 2175 crRect.top != rcOld.top || crRect.bottom != rcOld.bottom) {
2165 pWidget->SetRect(crRect); 2176 pWidget->SetRect(crRect);
2166 bSet = TRUE; 2177 bSet = TRUE;
2167 } 2178 }
2168 } 2179 }
2169 } 2180 }
2170 } 2181 }
2171 2182
2172 if (bSet) 2183 if (bSet)
2173 UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE); 2184 UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE);
2174 } else { 2185 } else {
2175 if (nControlIndex >= pFormField->CountControls()) 2186 if (nControlIndex >= pFormField->CountControls())
2176 return; 2187 return;
2177 if (CPDF_FormControl* pFormControl = 2188 if (CPDF_FormControl* pFormControl =
2178 pFormField->GetControl(nControlIndex)) { 2189 pFormField->GetControl(nControlIndex)) {
2179 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) { 2190 if (CPDFSDK_Widget* pWidget =
2191 pInterForm->GetWidget(pFormControl, false)) {
2180 CFX_FloatRect crRect = rect; 2192 CFX_FloatRect crRect = rect;
2181 2193
2182 CPDF_Page* pPDFPage = pWidget->GetPDFPage(); 2194 CPDF_Page* pPDFPage = pWidget->GetPDFPage();
2183 crRect.Intersect(pPDFPage->GetPageBBox()); 2195 crRect.Intersect(pPDFPage->GetPageBBox());
2184 2196
2185 if (!crRect.IsEmpty()) { 2197 if (!crRect.IsEmpty()) {
2186 CFX_FloatRect rcOld = pWidget->GetRect(); 2198 CFX_FloatRect rcOld = pWidget->GetRect();
2187 if (crRect.left != rcOld.left || crRect.right != rcOld.right || 2199 if (crRect.left != rcOld.left || crRect.right != rcOld.right ||
2188 crRect.top != rcOld.top || crRect.bottom != rcOld.bottom) { 2200 crRect.top != rcOld.top || crRect.bottom != rcOld.bottom) {
2189 pWidget->SetRect(crRect); 2201 pWidget->SetRect(crRect);
(...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after
3243 return FALSE; 3255 return FALSE;
3244 3256
3245 CPDF_FormField* pFormField = FieldArray[0]; 3257 CPDF_FormField* pFormField = FieldArray[0];
3246 int32_t nCount = pFormField->CountControls(); 3258 int32_t nCount = pFormField->CountControls();
3247 if (nCount < 1) 3259 if (nCount < 1)
3248 return FALSE; 3260 return FALSE;
3249 3261
3250 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); 3262 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm();
3251 CPDFSDK_Widget* pWidget = nullptr; 3263 CPDFSDK_Widget* pWidget = nullptr;
3252 if (nCount == 1) { 3264 if (nCount == 1) {
3253 pWidget = pInterForm->GetWidget(pFormField->GetControl(0)); 3265 pWidget = pInterForm->GetWidget(pFormField->GetControl(0), false);
3254 } else { 3266 } else {
3255 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); 3267 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
3256 UnderlyingPageType* pPage = UnderlyingFromFPDFPage( 3268 UnderlyingPageType* pPage = UnderlyingFromFPDFPage(
3257 pEnv->FFI_GetCurrentPage(m_pDocument->GetUnderlyingDocument())); 3269 pEnv->FFI_GetCurrentPage(m_pDocument->GetUnderlyingDocument()));
3258 if (!pPage) 3270 if (!pPage)
3259 return FALSE; 3271 return FALSE;
3260 if (CPDFSDK_PageView* pCurPageView = 3272 if (CPDFSDK_PageView* pCurPageView =
3261 m_pDocument->GetPageView(pPage, true)) { 3273 m_pDocument->GetPageView(pPage, true)) {
3262 for (int32_t i = 0; i < nCount; i++) { 3274 for (int32_t i = 0; i < nCount; i++) {
3263 if (CPDFSDK_Widget* pTempWidget = 3275 if (CPDFSDK_Widget* pTempWidget =
3264 pInterForm->GetWidget(pFormField->GetControl(i))) { 3276 pInterForm->GetWidget(pFormField->GetControl(i), false)) {
3265 if (pTempWidget->GetPDFPage() == pCurPageView->GetPDFPage()) { 3277 if (pTempWidget->GetPDFPage() == pCurPageView->GetPDFPage()) {
3266 pWidget = pTempWidget; 3278 pWidget = pTempWidget;
3267 break; 3279 break;
3268 } 3280 }
3269 } 3281 }
3270 } 3282 }
3271 } 3283 }
3272 } 3284 }
3273 3285
3274 if (pWidget) { 3286 if (pWidget) {
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
3541 } 3553 }
3542 } 3554 }
3543 3555
3544 void Field::AddField(CPDFSDK_Document* pDocument, 3556 void Field::AddField(CPDFSDK_Document* pDocument,
3545 int nPageIndex, 3557 int nPageIndex,
3546 int nFieldType, 3558 int nFieldType,
3547 const CFX_WideString& sName, 3559 const CFX_WideString& sName,
3548 const CFX_FloatRect& rcCoords) { 3560 const CFX_FloatRect& rcCoords) {
3549 // Not supported. 3561 // Not supported.
3550 } 3562 }
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