summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authortonikitoo <tonikitoo@igalia.com>2016-08-22 14:06:49 -0700
committerCommit bot <commit-bot@chromium.org>2016-08-22 14:06:49 -0700
commita73b8fee8751dae443af9437007261e4a1827a4f (patch)
tree64e6cc8a1d1c0e51ab03c167b8444bbf8ec224ce /fpdfsdk
parent9b99ebf5159d98cc83fb2e8ebac6750e158841d6 (diff)
downloadpdfium-a73b8fee8751dae443af9437007261e4a1827a4f.tar.xz
Implement Field::SetHidden using Field::SetDisplay.chromium/2837
Following up on [1], where the duplicated logic in Field::SetDisplay was factored out into a helper function, CL further cleans up a related method: ::SetHidden. Field::SetHidden(true), for instance, is equivalent to calling Field::SetDisplay(1), whereas Field::SetHidden(false) is equivalent to Field::SetDisplay(0); No behavior change is expected. [1] https://codereview.chromium.org/2255843002 Review-Url: https://codereview.chromium.org/2266193002
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/javascript/Field.cpp61
1 files changed, 2 insertions, 59 deletions
diff --git a/fpdfsdk/javascript/Field.cpp b/fpdfsdk/javascript/Field.cpp
index 3b69a5ac22..5c279d6b53 100644
--- a/fpdfsdk/javascript/Field.cpp
+++ b/fpdfsdk/javascript/Field.cpp
@@ -1531,65 +1531,8 @@ void Field::SetHidden(CPDFSDK_Document* pDocument,
const CFX_WideString& swFieldName,
int nControlIndex,
bool b) {
- CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm();
- std::vector<CPDF_FormField*> FieldArray =
- GetFormFields(pDocument, swFieldName);
- for (CPDF_FormField* pFormField : FieldArray) {
- if (nControlIndex < 0) {
- FX_BOOL bSet = FALSE;
- for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) {
- if (CPDFSDK_Widget* pWidget =
- pInterForm->GetWidget(pFormField->GetControl(i), false)) {
- uint32_t dwFlags = pWidget->GetFlags();
-
- if (b) {
- dwFlags &= (~ANNOTFLAG_INVISIBLE);
- dwFlags &= (~ANNOTFLAG_NOVIEW);
- dwFlags |= (ANNOTFLAG_HIDDEN | ANNOTFLAG_PRINT);
- } else {
- dwFlags &= (~ANNOTFLAG_INVISIBLE);
- dwFlags &= (~ANNOTFLAG_HIDDEN);
- dwFlags &= (~ANNOTFLAG_NOVIEW);
- dwFlags |= ANNOTFLAG_PRINT;
- }
-
- if (dwFlags != pWidget->GetFlags()) {
- pWidget->SetFlags(dwFlags);
- bSet = TRUE;
- }
- }
- }
-
- if (bSet)
- UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE);
- } else {
- if (nControlIndex >= pFormField->CountControls())
- return;
- if (CPDF_FormControl* pFormControl =
- pFormField->GetControl(nControlIndex)) {
- if (CPDFSDK_Widget* pWidget =
- pInterForm->GetWidget(pFormControl, false)) {
- uint32_t dwFlags = pWidget->GetFlags();
-
- if (b) {
- dwFlags &= (~ANNOTFLAG_INVISIBLE);
- dwFlags &= (~ANNOTFLAG_NOVIEW);
- dwFlags |= (ANNOTFLAG_HIDDEN | ANNOTFLAG_PRINT);
- } else {
- dwFlags &= (~ANNOTFLAG_INVISIBLE);
- dwFlags &= (~ANNOTFLAG_HIDDEN);
- dwFlags &= (~ANNOTFLAG_NOVIEW);
- dwFlags |= ANNOTFLAG_PRINT;
- }
-
- if (dwFlags != pWidget->GetFlags()) {
- pWidget->SetFlags(dwFlags);
- UpdateFormControl(pDocument, pFormControl, TRUE, FALSE, TRUE);
- }
- }
- }
- }
- }
+ int display = b ? 1 /*Hidden*/ : 0 /*Visible*/;
+ SetDisplay(pDocument, swFieldName, nControlIndex, display);
}
FX_BOOL Field::highlight(IJS_Context* cc,