summaryrefslogtreecommitdiff
path: root/core/fpdfdoc/cpdf_formfield.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfdoc/cpdf_formfield.cpp')
-rw-r--r--core/fpdfdoc/cpdf_formfield.cpp100
1 files changed, 50 insertions, 50 deletions
diff --git a/core/fpdfdoc/cpdf_formfield.cpp b/core/fpdfdoc/cpdf_formfield.cpp
index b149ef6e2f..8399e79a13 100644
--- a/core/fpdfdoc/cpdf_formfield.cpp
+++ b/core/fpdfdoc/cpdf_formfield.cpp
@@ -42,7 +42,7 @@ const int kFormTextNoScroll = 0x400;
const int kFormTextComb = 0x800;
bool IsUnison(CPDF_FormField* pField) {
- if (pField->GetType() == CPDF_FormField::CheckBox)
+ if (pField->GetType() == CPDF_FormField::kCheckBox)
return true;
return (pField->GetFieldFlags() & 0x2000000) != 0;
}
@@ -130,23 +130,23 @@ void CPDF_FormField::InitFieldFlags() {
if (type_name == "Btn") {
if (flags & 0x8000) {
- m_Type = RadioButton;
+ m_Type = kRadioButton;
if (flags & 0x4000)
m_Flags |= kFormRadioNoToggleOff;
if (flags & 0x2000000)
m_Flags |= kFormRadioUnison;
} else if (flags & 0x10000) {
- m_Type = PushButton;
+ m_Type = kPushButton;
} else {
- m_Type = CheckBox;
+ m_Type = kCheckBox;
}
} else if (type_name == "Tx") {
if (flags & 0x100000) {
- m_Type = File;
+ m_Type = kFile;
} else if (flags & 0x2000000) {
- m_Type = RichText;
+ m_Type = kRichText;
} else {
- m_Type = Text;
+ m_Type = kText;
if (flags & 0x1000)
m_Flags |= kFormTextMultiLine;
if (flags & 0x2000)
@@ -159,17 +159,17 @@ void CPDF_FormField::InitFieldFlags() {
LoadDA();
} else if (type_name == "Ch") {
if (flags & 0x20000) {
- m_Type = ComboBox;
+ m_Type = kComboBox;
if (flags & 0x40000)
m_Flags |= kFormComboEdit;
} else {
- m_Type = ListBox;
+ m_Type = kListBox;
if (flags & 0x200000)
m_Flags |= kFormListMultiSelect;
}
LoadDA();
} else if (type_name == "Sig") {
- m_Type = Sign;
+ m_Type = kSign;
}
}
@@ -179,8 +179,8 @@ WideString CPDF_FormField::GetFullName() const {
bool CPDF_FormField::ResetField(NotificationOption notify) {
switch (m_Type) {
- case CPDF_FormField::CheckBox:
- case CPDF_FormField::RadioButton: {
+ case kCheckBox:
+ case kRadioButton: {
int iCount = CountControls();
// TODO(weili): Check whether anything special needs to be done for
// unison field. (When IsUnison(this) returns true/false.)
@@ -192,8 +192,8 @@ bool CPDF_FormField::ResetField(NotificationOption notify) {
m_pForm->GetFormNotify()->AfterCheckedStatusChange(this);
break;
}
- case CPDF_FormField::ComboBox:
- case CPDF_FormField::ListBox: {
+ case kComboBox:
+ case kListBox: {
ClearSelection(NotificationOption::kDoNotNotify);
WideString csValue;
int iIndex = GetDefaultSelectedItem();
@@ -208,9 +208,9 @@ bool CPDF_FormField::ResetField(NotificationOption notify) {
NotifyListOrComboBoxAfterChange();
break;
}
- case CPDF_FormField::Text:
- case CPDF_FormField::RichText:
- case CPDF_FormField::File:
+ case kText:
+ case kRichText:
+ case kFile:
default: {
const CPDF_Object* pDV = FPDF_GetFieldAttr(m_pDict.Get(), "DV");
WideString csDValue;
@@ -260,21 +260,21 @@ int CPDF_FormField::GetControlIndex(const CPDF_FormControl* pControl) const {
FormFieldType CPDF_FormField::GetFieldType() const {
switch (m_Type) {
- case PushButton:
+ case kPushButton:
return FormFieldType::kPushButton;
- case CheckBox:
+ case kCheckBox:
return FormFieldType::kCheckBox;
- case RadioButton:
+ case kRadioButton:
return FormFieldType::kRadioButton;
- case ComboBox:
+ case kComboBox:
return FormFieldType::kComboBox;
- case ListBox:
+ case kListBox:
return FormFieldType::kListBox;
- case Text:
- case RichText:
- case File:
+ case kText:
+ case kRichText:
+ case kFile:
return FormFieldType::kTextField;
- case Sign:
+ case kSign:
return FormFieldType::kSignature;
default:
return FormFieldType::kUnknown;
@@ -311,16 +311,16 @@ void CPDF_FormField::SetOpt(std::unique_ptr<CPDF_Object> pOpt) {
}
WideString CPDF_FormField::GetValue(bool bDefault) const {
- if (GetType() == CheckBox || GetType() == RadioButton)
+ if (GetType() == kCheckBox || GetType() == kRadioButton)
return GetCheckValue(bDefault);
const CPDF_Object* pValue =
FPDF_GetFieldAttr(m_pDict.Get(), bDefault ? "DV" : "V");
if (!pValue) {
if (!bDefault) {
- if (m_Type == RichText)
+ if (m_Type == kRichText)
pValue = FPDF_GetFieldAttr(m_pDict.Get(), "V");
- if (!pValue && m_Type != Text)
+ if (!pValue && m_Type != kText)
pValue = FPDF_GetFieldAttr(m_pDict.Get(), "DV");
}
if (!pValue)
@@ -354,15 +354,15 @@ bool CPDF_FormField::SetValue(const WideString& value,
bool bDefault,
NotificationOption notify) {
switch (m_Type) {
- case CheckBox:
- case RadioButton: {
+ case kCheckBox:
+ case kRadioButton: {
SetCheckValue(value, bDefault, notify);
return true;
}
- case File:
- case RichText:
- case Text:
- case ComboBox: {
+ case kFile:
+ case kRichText:
+ case kText:
+ case kComboBox: {
WideString csValue = value;
if (notify == NotificationOption::kNotify &&
!NotifyBeforeValueChange(csValue)) {
@@ -373,7 +373,7 @@ bool CPDF_FormField::SetValue(const WideString& value,
if (iIndex < 0) {
ByteString bsEncodeText = PDF_EncodeText(csValue);
m_pDict->SetNewFor<CPDF_String>(key, bsEncodeText, false);
- if (m_Type == RichText && !bDefault)
+ if (m_Type == kRichText && !bDefault)
m_pDict->SetNewFor<CPDF_String>("RV", bsEncodeText, false);
m_pDict->RemoveFor("I");
} else {
@@ -387,7 +387,7 @@ bool CPDF_FormField::SetValue(const WideString& value,
NotifyAfterValueChange();
break;
}
- case ListBox: {
+ case kListBox: {
int iIndex = FindOptionValue(value);
if (iIndex < 0)
return false;
@@ -499,7 +499,7 @@ bool CPDF_FormField::ClearSelection(NotificationOption notify) {
}
bool CPDF_FormField::IsItemSelected(int index) const {
- ASSERT(GetType() == ComboBox || GetType() == ListBox);
+ ASSERT(GetType() == kComboBox || GetType() == kListBox);
if (index < 0 || index >= CountOptions())
return false;
if (IsOptionSelected(index))
@@ -544,7 +544,7 @@ bool CPDF_FormField::IsItemSelected(int index) const {
bool CPDF_FormField::SetItemSelection(int index,
bool bSelected,
NotificationOption notify) {
- ASSERT(GetType() == ComboBox || GetType() == ListBox);
+ ASSERT(GetType() == kComboBox || GetType() == kListBox);
if (index < 0 || index >= CountOptions())
return false;
@@ -554,7 +554,7 @@ bool CPDF_FormField::SetItemSelection(int index,
return false;
}
if (bSelected) {
- if (GetType() == ListBox) {
+ if (GetType() == kListBox) {
SelectOption(index, true, NotificationOption::kDoNotNotify);
if (!(m_Flags & kFormListMultiSelect)) {
m_pDict->SetNewFor<CPDF_String>("V", PDF_EncodeText(opt_value), false);
@@ -575,7 +575,7 @@ bool CPDF_FormField::SetItemSelection(int index,
} else {
const CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict.Get(), "V");
if (pValue) {
- if (GetType() == ListBox) {
+ if (GetType() == kListBox) {
SelectOption(index, false, NotificationOption::kDoNotNotify);
if (pValue->IsString()) {
if (pValue->GetUnicodeText() == opt_value)
@@ -603,7 +603,7 @@ bool CPDF_FormField::SetItemSelection(int index,
}
bool CPDF_FormField::IsItemDefaultSelected(int index) const {
- ASSERT(GetType() == ComboBox || GetType() == ListBox);
+ ASSERT(GetType() == kComboBox || GetType() == kListBox);
if (index < 0 || index >= CountOptions())
return false;
int iDVIndex = GetDefaultSelectedItem();
@@ -611,7 +611,7 @@ bool CPDF_FormField::IsItemDefaultSelected(int index) const {
}
int CPDF_FormField::GetDefaultSelectedItem() const {
- ASSERT(GetType() == ComboBox || GetType() == ListBox);
+ ASSERT(GetType() == kComboBox || GetType() == kListBox);
const CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict.Get(), "DV");
if (!pValue)
return -1;
@@ -672,7 +672,7 @@ int CPDF_FormField::FindOptionValue(const WideString& csOptValue) const {
bool CPDF_FormField::CheckControl(int iControlIndex,
bool bChecked,
NotificationOption notify) {
- ASSERT(GetType() == CheckBox || GetType() == RadioButton);
+ ASSERT(GetType() == kCheckBox || GetType() == kRadioButton);
CPDF_FormControl* pControl = GetControl(iControlIndex);
if (!pControl)
return false;
@@ -724,7 +724,7 @@ bool CPDF_FormField::CheckControl(int iControlIndex,
}
WideString CPDF_FormField::GetCheckValue(bool bDefault) const {
- ASSERT(GetType() == CheckBox || GetType() == RadioButton);
+ ASSERT(GetType() == kCheckBox || GetType() == kRadioButton);
WideString csExport = L"Off";
int iCount = CountControls();
for (int i = 0; i < iCount; i++) {
@@ -742,7 +742,7 @@ WideString CPDF_FormField::GetCheckValue(bool bDefault) const {
bool CPDF_FormField::SetCheckValue(const WideString& value,
bool bDefault,
NotificationOption notify) {
- ASSERT(GetType() == CheckBox || GetType() == RadioButton);
+ ASSERT(GetType() == kCheckBox || GetType() == kRadioButton);
int iCount = CountControls();
for (int i = 0; i < iCount; i++) {
CPDF_FormControl* pControl = GetControl(i);
@@ -908,9 +908,9 @@ void CPDF_FormField::NotifyAfterValueChange() {
bool CPDF_FormField::NotifyListOrComboBoxBeforeChange(const WideString& value) {
switch (GetType()) {
- case ListBox:
+ case kListBox:
return NotifyBeforeSelectionChange(value);
- case ComboBox:
+ case kComboBox:
return NotifyBeforeValueChange(value);
default:
return true;
@@ -919,10 +919,10 @@ bool CPDF_FormField::NotifyListOrComboBoxBeforeChange(const WideString& value) {
void CPDF_FormField::NotifyListOrComboBoxAfterChange() {
switch (GetType()) {
- case ListBox:
+ case kListBox:
NotifyAfterSelectionChange();
break;
- case ComboBox:
+ case kComboBox:
NotifyAfterValueChange();
break;
default: